@thegpvc/gp-foundry 0.2.8 → 0.2.10
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 +4 -0
- package/README.md +6 -0
- package/actions/config-loader/dist/index.cjs +36 -36
- package/actions/merge-gate/dist/index.cjs +26 -26
- package/actions/run-agent/README.md +56 -10
- package/actions/run-agent/action.yml +141 -18
- package/dist/cli/index.cjs +116 -112
- package/package.json +2 -2
- package/schema/config.schema.json +4 -0
- package/skill/SKILL.md +4 -3
- package/skill/reference/node-types.md +7 -2
- package/skill/templates/foundry.config.yaml +1 -0
package/dist/cli/index.cjs
CHANGED
|
@@ -1,134 +1,138 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`).replace(/^/gm," ".repeat(s))}let
|
|
4
|
-
`)}padWidth(e,
|
|
2
|
+
"use strict";var Sr=Object.create;var Vt=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var vr=Object.getOwnPropertyNames;var xr=Object.getPrototypeOf,Cr=Object.prototype.hasOwnProperty;var Or=(i,e,n)=>()=>{if(n)throw n[0];try{return i&&(e=i(i=0)),e}catch(r){throw n=[r],r}};var ve=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var Tr=(i,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of vr(e))!Cr.call(i,o)&&o!==n&&Vt(i,o,{get:()=>e[o],enumerable:!(r=$r(e,o))||r.enumerable});return i};var xn=(i,e,n)=>(n=i!=null?Sr(xr(i)):{},Tr(e||!i||!i.__esModule?Vt(n,"default",{value:i,enumerable:!0}):n,i));var Rr,B,I=Or(()=>{"use strict";Rr=()=>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=Rr()});var en=ve(zn=>{"use strict";I();var Cn=class extends Error{constructor(e,n,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=n,this.exitCode=e,this.nestedError=void 0}},Jn=class extends Cn{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};zn.CommanderError=Cn;zn.InvalidArgumentError=Jn});var On=ve(Qn=>{"use strict";I();var{InvalidArgumentError:Nr}=en(),Xn=class{constructor(e,n){switch(this.description=n||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,n){return n===this.defaultValue||!Array.isArray(n)?[e]:n.concat(e)}default(e,n){return this.defaultValue=e,this.defaultValueDescription=n,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(n,r)=>{if(!this.argChoices.includes(n))throw new Nr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,r):n},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ir(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}Qn.Argument=Xn;Qn.humanReadableArgName=Ir});var et=ve(Wt=>{"use strict";I();var{humanReadableArgName:Hr}=On(),Zn=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let n=e.commands.filter(o=>!o._hidden),r=e._getHelpCommand();return r&&!r._hidden&&n.push(r),this.sortSubcommands&&n.sort((o,s)=>o.name().localeCompare(s.name())),n}compareOptions(e,n){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(n))}visibleOptions(e){let n=e.options.filter(o=>!o.hidden),r=e._getHelpOption();if(r&&!r.hidden){let o=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!o&&!s?n.push(r):r.long&&!s?n.push(e.createOption(r.long,r.description)):r.short&&!o&&n.push(e.createOption(r.short,r.description))}return this.sortOptions&&n.sort(this.compareOptions),n}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let n=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(s=>!s.hidden);n.push(...o)}return this.sortOptions&&n.sort(this.compareOptions),n}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(n=>{n.description=n.description||e._argsDescription[n.name()]||""}),e.registeredArguments.find(n=>n.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(r=>Hr(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(n?" "+n:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,n){return n.visibleCommands(e).reduce((r,o)=>Math.max(r,n.subcommandTerm(o).length),0)}longestOptionTermLength(e,n){return n.visibleOptions(e).reduce((r,o)=>Math.max(r,n.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,n){return n.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,n.optionTerm(o).length),0)}longestArgumentTermLength(e,n){return n.visibleArguments(e).reduce((r,o)=>Math.max(r,n.argumentTerm(o).length),0)}commandUsage(e){let n=e._name;e._aliases[0]&&(n=n+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+n+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let n=[];return e.argChoices&&n.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&n.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&n.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&n.push(`env: ${e.envVar}`),n.length>0?`${e.description} (${n.join(", ")})`:e.description}argumentDescription(e){let n=[];if(e.argChoices&&n.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&n.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),n.length>0){let r=`(${n.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,n){let r=n.padWidth(e,n),o=n.helpWidth||80,s=2,u=2;function a(E,k){if(k){let x=`${E.padEnd(r+u)}${k}`;return n.wrap(x,o-s,r+u)}return E}function d(E){return E.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(s))}let l=[`Usage: ${n.commandUsage(e)}`,""],p=n.commandDescription(e);p.length>0&&(l=l.concat([n.wrap(p,o,0),""]));let m=n.visibleArguments(e).map(E=>a(n.argumentTerm(E),n.argumentDescription(E)));m.length>0&&(l=l.concat(["Arguments:",d(m),""]));let h=n.visibleOptions(e).map(E=>a(n.optionTerm(E),n.optionDescription(E)));if(h.length>0&&(l=l.concat(["Options:",d(h),""])),this.showGlobalOptions){let E=n.visibleGlobalOptions(e).map(k=>a(n.optionTerm(k),n.optionDescription(k)));E.length>0&&(l=l.concat(["Global Options:",d(E),""]))}let $=n.visibleCommands(e).map(E=>a(n.subcommandTerm(E),n.subcommandDescription(E)));return $.length>0&&(l=l.concat(["Commands:",d($),""])),l.join(`
|
|
4
|
+
`)}padWidth(e,n){return Math.max(n.longestOptionTermLength(e,n),n.longestGlobalOptionTermLength(e,n),n.longestSubcommandTermLength(e,n),n.longestArgumentTermLength(e,n))}wrap(e,n,r,o=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",u=new RegExp(`[\\n][${s}]+`);if(e.match(u))return e;let a=n-r;if(a<o)return e;let d=e.slice(0,r),l=e.slice(r).replace(`\r
|
|
5
5
|
`,`
|
|
6
|
-
`),
|
|
7
|
-
|.{1,${
|
|
8
|
-
`?"":(
|
|
9
|
-
`)}};
|
|
10
|
-
(Did you mean one of ${
|
|
11
|
-
(Did you mean ${
|
|
12
|
-
- specify the name in Command constructor or using .name()`);return
|
|
13
|
-
Expecting one of '${
|
|
14
|
-
- already used by option '${
|
|
6
|
+
`),p=" ".repeat(r),h="\\s\u200B",$=new RegExp(`
|
|
7
|
+
|.{1,${a-1}}([${h}]|$)|[^${h}]+?([${h}]|$)`,"g"),E=l.match($)||[];return d+E.map((k,x)=>k===`
|
|
8
|
+
`?"":(x>0?p:"")+k.trimEnd()).join(`
|
|
9
|
+
`)}};Wt.Help=Zn});var rt=ve(it=>{"use strict";I();var{InvalidArgumentError:Pr}=en(),nt=class{constructor(e,n){this.flags=e,this.description=n||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=Fr(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,n){return this.defaultValue=e,this.defaultValueDescription=n,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let n=e;return typeof e=="string"&&(n={[e]:!0}),this.implied=Object.assign(this.implied||{},n),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,n){return n===this.defaultValue||!Array.isArray(n)?[e]:n.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(n,r)=>{if(!this.argChoices.includes(n))throw new Pr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,r):n},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Mr(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},tt=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(n=>{n.negate?this.negativeOptions.set(n.attributeName(),n):this.positiveOptions.set(n.attributeName(),n)}),this.negativeOptions.forEach((n,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,n){let r=n.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,s=o!==void 0?o:!1;return n.negate===(s===e)}};function Mr(i){return i.split("-").reduce((e,n)=>e+n[0].toUpperCase()+n.slice(1))}function Fr(i){let e,n,r=i.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),n=r.shift(),!e&&/^-[^-]$/.test(n)&&(e=n,n=void 0),{shortFlag:e,longFlag:n}}it.Option=nt;it.DualOptions=tt});var Kt=ve(Yt=>{"use strict";I();function Dr(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let n=[];for(let r=0;r<=i.length;r++)n[r]=[r];for(let r=0;r<=e.length;r++)n[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=i.length;o++){let s=1;i[o-1]===e[r-1]?s=0:s=1,n[o][r]=Math.min(n[o-1][r]+1,n[o][r-1]+1,n[o-1][r-1]+s),o>1&&r>1&&i[o-1]===e[r-2]&&i[o-2]===e[r-1]&&(n[o][r]=Math.min(n[o][r],n[o-2][r-2]+1))}return n[i.length][e.length]}function jr(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let n=i.startsWith("--");n&&(i=i.slice(2),e=e.map(u=>u.slice(2)));let r=[],o=3,s=.4;return e.forEach(u=>{if(u.length<=1)return;let a=Dr(i,u),d=Math.max(i.length,u.length);(d-a)/d>s&&(a<o?(o=a,r=[u]):a===o&&r.push(u))}),r.sort((u,a)=>u.localeCompare(a)),n&&(r=r.map(u=>`--${u}`)),r.length>1?`
|
|
10
|
+
(Did you mean one of ${r.join(", ")}?)`:r.length===1?`
|
|
11
|
+
(Did you mean ${r[0]}?)`:""}Yt.suggestSimilar=jr});var Zt=ve(Qt=>{"use strict";I();var Lr=require("events").EventEmitter,ot=require("child_process"),_e=require("path"),st=require("fs"),X=require("process"),{Argument:qr,humanReadableArgName:Ur}=On(),{CommanderError:at}=en(),{Help:Br}=et(),{Option:Jt,DualOptions:Gr}=rt(),{suggestSimilar:zt}=Kt(),lt=class i extends Lr{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:n=>X.stdout.write(n),writeErr:n=>X.stderr.write(n),getOutHelpWidth:()=>X.stdout.isTTY?X.stdout.columns:void 0,getErrHelpWidth:()=>X.stderr.isTTY?X.stderr.columns:void 0,outputError:(n,r)=>r(n)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let n=this;n;n=n.parent)e.push(n);return e}command(e,n,r){let o=n,s=r;typeof o=="object"&&o!==null&&(s=o,o=null),s=s||{};let[,u,a]=e.match(/([^ ]+) *(.*)/),d=this.createCommand(u);return o&&(d.description(o),d._executableHandler=!0),s.isDefault&&(this._defaultCommandName=d._name),d._hidden=!!(s.noHelp||s.hidden),d._executableFile=s.executableFile||null,a&&d.arguments(a),this._registerCommand(d),d.parent=this,d.copyInheritedSettings(this),o?this:d}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Br,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,n){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
12
|
+
- specify the name in Command constructor or using .name()`);return n=n||{},n.isDefault&&(this._defaultCommandName=e._name),(n.noHelp||n.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,n){return new qr(e,n)}argument(e,n,r,o){let s=this.createArgument(e,n);return typeof r=="function"?s.default(o).argParser(r):s.default(r),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(n=>{this.argument(n)}),this}addArgument(e){let n=this.registeredArguments.slice(-1)[0];if(n&&n.variadic)throw new Error(`only the last argument can be variadic '${n.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,n){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,r,o]=e.match(/([^ ]+) *(.*)/),s=n??"display help for command",u=this.createCommand(r);return u.helpOption(!1),o&&u.arguments(o),s&&u.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=u,this}addHelpCommand(e,n){return typeof e!="object"?(this.helpCommand(e,n),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,n){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
|
+
Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(n):this._lifeCycleHooks[e]=[n],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=n=>{if(n.code!=="commander.executeSubCommandAsync")throw n},this}_exit(e,n,r){this._exitCallback&&this._exitCallback(new at(e,n,r)),X.exit(e)}action(e){let n=r=>{let o=this.registeredArguments.length,s=r.slice(0,o);return this._storeOptionsAsProperties?s[o]=this:s[o]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=n,this}createOption(e,n){return new Jt(e,n)}_callParseArg(e,n,r,o){try{return e.parseArg(n,r)}catch(s){if(s.code==="commander.invalidArgument"){let u=`${o} ${s.message}`;this.error(u,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let n=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(n){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
|
|
14
|
+
- already used by option '${n.flags}'`)}this.options.push(e)}_registerCommand(e){let n=o=>[o.name()].concat(o.aliases()),r=n(e).find(o=>this._findCommand(o));if(r){let o=n(this._findCommand(r)).join("|"),s=n(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${o}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let n=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let o=(s,u,a)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let d=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,d,u):s!==null&&e.variadic&&(s=e._concatValue(s,d)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,a)};return this.on("option:"+n,s=>{let u=`error: option '${e.flags}' argument '${s}' is invalid.`;o(s,u,"cli")}),e.envVar&&this.on("optionEnv:"+n,s=>{let u=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;o(s,u,"env")}),this}_optionEx(e,n,r,o,s){if(typeof n=="object"&&n instanceof Jt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let u=this.createOption(n,r);if(u.makeOptionMandatory(!!e.mandatory),typeof o=="function")u.default(s).argParser(o);else if(o instanceof RegExp){let a=o;o=(d,l)=>{let p=a.exec(d);return p?p[0]:l},u.default(s).argParser(o)}else u.default(o);return this.addOption(u)}option(e,n,r,o){return this._optionEx({},e,n,r,o)}requiredOption(e,n,r,o){return this._optionEx({mandatory:!0},e,n,r,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,n){return this.setOptionValueWithSource(e,n,void 0)}setOptionValueWithSource(e,n,r){return this._storeOptionsAsProperties?this[e]=n:this._optionValues[e]=n,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let n;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(n=r.getOptionValueSource(e))}),n}_prepareUserArgs(e,n){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(n=n||{},e===void 0&&n.from===void 0){X.versions?.electron&&(n.from="electron");let o=X.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(n.from="eval")}e===void 0&&(e=X.argv),this.rawArgs=e.slice();let r;switch(n.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":X.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${n.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,n){let r=this._prepareUserArgs(e,n);return this._parseCommand([],r),this}async parseAsync(e,n){let r=this._prepareUserArgs(e,n);return await this._parseCommand([],r),this}_executeSubCommand(e,n){n=n.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function s(p,m){let h=_e.resolve(p,m);if(st.existsSync(h))return h;if(o.includes(_e.extname(m)))return;let $=o.find(E=>st.existsSync(`${h}${E}`));if($)return`${h}${$}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let p;try{p=st.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=_e.resolve(_e.dirname(p),a)}if(a){let p=s(a,u);if(!p&&!e._executableFile&&this._scriptPath){let m=_e.basename(this._scriptPath,_e.extname(this._scriptPath));m!==this._name&&(p=s(a,`${m}-${e._name}`))}u=p||u}r=o.includes(_e.extname(u));let d;X.platform!=="win32"?r?(n.unshift(u),n=Xt(X.execArgv).concat(n),d=ot.spawn(X.argv[0],n,{stdio:"inherit"})):d=ot.spawn(u,n,{stdio:"inherit"}):(n.unshift(u),n=Xt(X.execArgv).concat(n),d=ot.spawn(X.execPath,n,{stdio:"inherit"})),d.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(m=>{X.on(m,()=>{d.killed===!1&&d.exitCode===null&&d.kill(m)})});let l=this._exitCallback;d.on("close",p=>{p=p??1,l?l(new at(p,"commander.executeSubCommandAsync","(close)")):X.exit(p)}),d.on("error",p=>{if(p.code==="ENOENT"){let m=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",h=`'${u}' does not exist
|
|
15
15
|
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
|
-
- ${
|
|
17
|
+
- ${m}`;throw new Error(h)}else if(p.code==="EACCES")throw new Error(`'${u}' not executable`);if(!l)X.exit(1);else{let m=new at(1,"commander.executeSubCommandAsync","(error)");m.nestedError=p,l(m)}}),this.runningCommand=d}_dispatchSubcommand(e,n,r){let o=this._findCommand(e);o||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,o,"preSubcommand"),s=this._chainOrCall(s,()=>{if(o._executableHandler)this._executeSubCommand(o,n.concat(r));else return o._parseCommand(n,r)}),s}_dispatchHelpCommand(e){e||this.help();let n=this._findCommand(e);return n&&!n._executableHandler&&n.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,n)=>{e.required&&this.args[n]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,s)=>{let u=o;if(o!==null&&r.parseArg){let a=`error: command-argument value '${o}' is invalid for argument '${r.name()}'.`;u=this._callParseArg(r,o,s,a)}return u};this._checkNumberOfArguments();let n=[];this.registeredArguments.forEach((r,o)=>{let s=r.defaultValue;r.variadic?o<this.args.length?(s=this.args.slice(o),r.parseArg&&(s=s.reduce((u,a)=>e(r,a,u),r.defaultValue))):s===void 0&&(s=[]):o<this.args.length&&(s=this.args[o],r.parseArg&&(s=e(r,s,r.defaultValue))),n[o]=s}),this.processedArgs=n}_chainOrCall(e,n){return e&&e.then&&typeof e.then=="function"?e.then(()=>n()):n()}_chainOrCallHooks(e,n){let r=e,o=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[n]!==void 0).forEach(s=>{s._lifeCycleHooks[n].forEach(u=>{o.push({hookedCommand:s,callback:u})})}),n==="postAction"&&o.reverse(),o.forEach(s=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,n,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(s=>{o=this._chainOrCall(o,()=>s(this,n))}),o}_parseCommand(e,n){let r=this.parseOptions(n);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),n=r.unknown,this.args=e.concat(n),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),n);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(n),this._dispatchSubcommand(this._defaultCommandName,e,n);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let u;return u=this._chainOrCallHooks(u,"preAction"),u=this._chainOrCall(u,()=>this._actionHandler(this.processedArgs)),this.parent&&(u=this._chainOrCall(u,()=>{this.parent.emit(s,e,n)})),u=this._chainOrCallHooks(u,"postAction"),u}if(this.parent&&this.parent.listenerCount(s))o(),this._processArguments(),this.parent.emit(s,e,n);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,n);this.listenerCount("command:*")?this.emit("command:*",e,n):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(n=>n._name===e||n._aliases.includes(e))}_findOption(e){return this.options.find(n=>n.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(n=>{n.mandatory&&e.getOptionValue(n.attributeName())===void 0&&e.missingMandatoryOptionValue(n)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(s=>r.conflictsWith.includes(s.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let n=[],r=[],o=n,s=e.slice();function u(d){return d.length>1&&d[0]==="-"}let a=null;for(;s.length;){let d=s.shift();if(d==="--"){o===r&&o.push(d),o.push(...s);break}if(a&&!u(d)){this.emit(`option:${a.name()}`,d);continue}if(a=null,u(d)){let l=this._findOption(d);if(l){if(l.required){let p=s.shift();p===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,p)}else if(l.optional){let p=null;s.length>0&&!u(s[0])&&(p=s.shift()),this.emit(`option:${l.name()}`,p)}else this.emit(`option:${l.name()}`);a=l.variadic?l:null;continue}}if(d.length>2&&d[0]==="-"&&d[1]!=="-"){let l=this._findOption(`-${d[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,d.slice(2)):(this.emit(`option:${l.name()}`),s.unshift(`-${d.slice(2)}`));continue}}if(/^--[^=]+=/.test(d)){let l=d.indexOf("="),p=this._findOption(d.slice(0,l));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,d.slice(l+1));continue}}if(u(d)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&n.length===0&&r.length===0){if(this._findCommand(d)){n.push(d),s.length>0&&r.push(...s);break}else if(this._getHelpCommand()&&d===this._getHelpCommand().name()){n.push(d),s.length>0&&n.push(...s);break}else if(this._defaultCommandName){r.push(d),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){o.push(d),s.length>0&&o.push(...s);break}o.push(d)}return{operands:n,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},n=this.options.length;for(let r=0;r<n;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,n)=>Object.assign(e,n.opts()),{})}error(e,n){this._outputConfiguration.outputError(`${e}
|
|
18
18
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
19
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
20
|
-
`),this.outputHelp({error:!0}));let
|
|
21
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,
|
|
22
|
-
Expecting one of '${
|
|
23
|
-
`)}),this}_outputHelpIfRequested(e){let
|
|
24
|
-
git config user.email "$GIT_EMAIL"`})}function
|
|
25
|
-
`));let d=
|
|
26
|
-
`)})}function
|
|
27
|
-
`)}))
|
|
20
|
+
`),this.outputHelp({error:!0}));let r=n||{},o=r.exitCode||1,s=r.code||"commander.error";this._exit(o,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in X.env){let n=e.attributeName();(this.getOptionValue(n)===void 0||["default","config","env"].includes(this.getOptionValueSource(n)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,X.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Gr(this.options),n=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&n(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!n(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"implied")})})}missingArgument(e){let n=`error: missing required argument '${e}'`;this.error(n,{code:"commander.missingArgument"})}optionMissingArgument(e){let n=`error: option '${e.flags}' argument missing`;this.error(n,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let n=`error: required option '${e.flags}' not specified`;this.error(n,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,n){let r=u=>{let a=u.attributeName(),d=this.getOptionValue(a),l=this.options.find(m=>m.negate&&a===m.attributeName()),p=this.options.find(m=>!m.negate&&a===m.attributeName());return l&&(l.presetArg===void 0&&d===!1||l.presetArg!==void 0&&d===l.presetArg)?l:p||u},o=u=>{let a=r(u),d=a.attributeName();return this.getOptionValueSource(d)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${o(e)} cannot be used with ${o(n)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let n="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],s=this;do{let u=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);o=o.concat(u),s=s.parent}while(s&&!s._enablePositionalOptions);n=zt(e,o)}let r=`error: unknown option '${e}'${n}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let n=this.registeredArguments.length,r=n===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${n} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],n="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(s=>{o.push(s.name()),s.alias()&&o.push(s.alias())}),n=zt(e,o)}let r=`error: unknown command '${e}'${n}`;this.error(r,{code:"commander.unknownCommand"})}version(e,n,r){if(e===void 0)return this._version;this._version=e,n=n||"-V, --version",r=r||"output the version number";let o=this.createOption(n,r);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
21
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,n){return e===void 0&&n===void 0?this._description:(this._description=e,n&&(this._argsDescription=n),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let n=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(n=this.commands[this.commands.length-1]),e===n._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let o=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${o}'`)}return n._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(n=>this.alias(n)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let n=this.registeredArguments.map(r=>Ur(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?n:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=_e.basename(e,_e.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let n=this.createHelp();return n.helpWidth===void 0&&(n.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),n.formatHelp(this,n)}_getHelpContext(e){e=e||{};let n={error:!!e.error},r;return n.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),n.write=e.write||r,n.command=this,n}outputHelp(e){let n;typeof e=="function"&&(n=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(n&&(o=n(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}helpOption(e,n){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",n=n??"display help for command",this._helpOption=this.createOption(e,n),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let n=X.exitCode||0;n===0&&e&&typeof e!="function"&&e.error&&(n=1),this._exit(n,"commander.help","(outputHelp)")}addHelpText(e,n){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
22
|
+
Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,s=>{let u;typeof n=="function"?u=n({error:s.error,command:s.command}):u=n,u&&s.write(`${u}
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let n=this._getHelpOption();n&&e.find(o=>n.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Xt(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let n,r="127.0.0.1",o="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?n=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(n=s[1],/^\d+$/.test(s[3])?o=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(n=s[1],r=s[3],o=s[4]),n&&o!=="0"?`${n}=${r}:${parseInt(o)+1}`:e})}Qt.Command=lt});var ii=ve(ue=>{"use strict";I();var{Argument:ei}=On(),{Command:ct}=Zt(),{CommanderError:Vr,InvalidArgumentError:ni}=en(),{Help:Wr}=et(),{Option:ti}=rt();ue.program=new ct;ue.createCommand=i=>new ct(i);ue.createOption=(i,e)=>new ti(i,e);ue.createArgument=(i,e)=>new ei(i,e);ue.Command=ct;ue.Option=ti;ue.Argument=ei;ue.Help=Wr;ue.CommanderError=Vr;ue.InvalidArgumentError=ni;ue.InvalidOptionArgumentError=ni});var Nn=ve((Es,ut)=>{"use strict";I();var Rn=process||{},si=Rn.argv||[],Tn=Rn.env||{},Yr=!(Tn.NO_COLOR||si.includes("--no-color"))&&(!!Tn.FORCE_COLOR||si.includes("--color")||Rn.platform==="win32"||(Rn.stdout||{}).isTTY&&Tn.TERM!=="dumb"||!!Tn.CI),Kr=(i,e,n=i)=>r=>{let o=""+r,s=o.indexOf(e,i.length);return~s?i+Jr(o,e,n,s)+e:i+o+e},Jr=(i,e,n,r)=>{let o="",s=0;do o+=i.substring(s,r)+n,s=r+e.length,r=i.indexOf(e,s);while(~r);return o+i.substring(s)},ai=(i=Yr)=>{let e=i?Kr:()=>String;return{isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};ut.exports=ai();ut.exports.createColors=ai});I();I();var ri=xn(ii(),1),{program:ds,createCommand:ps,createArgument:fs,createOption:hs,CommanderError:ms,InvalidArgumentError:gs,InvalidOptionArgumentError:bs,Command:oi,Argument:ys,Option:ws,Help:_s}=ri.default;var Q=xn(Nn(),1),Er=require("child_process"),Y=require("fs"),ne=require("path");I();I();I();var qe=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function li(i){return i.uses!==void 0}I();function nn(i){let e=i.auth;return e?.mode?{mode:e.mode,appIdSecret:e.app_id_secret??i.identity.app_id_secret,appKeySecret:e.app_key_secret??i.identity.app_key_secret,tokenSecret:e.token_secret}:i.identity.app_id_secret&&i.identity.app_key_secret?{mode:"app",appIdSecret:i.identity.app_id_secret,appKeySecret:i.identity.app_key_secret}:{mode:"github-token"}}I();I();function dt(i){let e=i.attrs.gates;if(e===void 0)return[];if(typeof e!="string")throw new Error(`node '${i.id}': gates= must be a string like "ci.yml" or "lint?90"`);let n=[];for(let r of e.split(",").map(o=>o.trim()).filter(Boolean)){let o=/^(.*?)(?:\?([^?]*))?$/.exec(r),s=o[1].trim(),u=o[2];if(!s)throw new Error(`node '${i.id}': gates= entry '${r}' names no workflow or check`);let a={name:s,kind:/\.ya?ml$/i.test(s)?"workflow":"check"};if(u!==void 0){if(!/^[1-9]\d*$/.test(u.trim()))throw new Error(`node '${i.id}': gates= entry '${r}' has a bad grace suffix \u2014 expected '?<seconds>' with a whole number >= 1, e.g. "${s}?90"`);a.graceSeconds=Number(u.trim())}n.push(a)}return n}function ci(i){try{return dt(i)}catch{return[]}}function pt(i){let e=i.attrs.skip;if(e===void 0)return[];if(typeof e!="string"||!e.trim())throw new Error(`node '${i.id}': skip= must be a non-empty string like "draft,unchanged-diff"`);let n=[],r=new Set;for(let o of e.split(",").map(s=>s.trim()).filter(Boolean))if(!r.has(o))if(r.add(o),o==="draft"||o==="bot-author"||o==="unchanged-diff")n.push({kind:o});else if(o.startsWith("label:")&&o.slice(6).trim())n.push({kind:"label",label:o.slice(6).trim()});else throw new Error(`node '${i.id}': unknown skip= entry '${o}' \u2014 expected draft, bot-author, label:<key> or unchanged-diff`);if(!n.length)throw new Error(`node '${i.id}': skip= has no entries`);return n}function Ie(i){try{return pt(i)}catch{return[]}}function tn(i){return i.context==="pr-diff"||i.context==="pr-review"}function rn(i){return i.attrs.select==="sweep"&&i.type==="pr-review"&&tn(i)&&i.attrs.schedule!==void 0}function Ue(i){return(i.type==="pr-review"||i.type==="analyst")&&tn(i)&&i.attrs.schedule===void 0&&Ie(i).length>0}function on(i){return rn(i)?`${i.id}_select`:`${i.id}_guard`}function In(i){return`<!-- gp-foundry:diff:${i.id}:`}var ui="**Verdict:**";I();function Be(i){return`\${{ secrets.${i} }}`}function Ae(i,e){if(!e)return"";let n=i.specDir?.replace(/\/+$/,"");return n?`${n}/${e}`:e}function ce(i){let e=nn(i.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?Be(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}function Hn(i){let e=nn(i.config);if(!(e.mode!=="app"||!e.appIdSecret||!e.appKeySecret))return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:{"app-id":Be(e.appIdSecret),"private-key":Be(e.appKeySecret)}}}function Pn(i,e={}){let n={token:ce(i)};return e.ref&&(n.ref=e.ref),i.node.attrs.checkout==="partial"?(n["fetch-depth"]=0,n.filter="blob:none"):e.fetchDepth!==void 0&&(n["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:n}}function Ge(){return{uses:"./.github/agent-setup",name:"Setup agent toolchain"}}function di(i){let e=i.config.identity,n=e.git_name??e.bot_login??"gp-foundry agent",r=e.git_email??`${e.bot_login??"gp-foundry-agent"}@users.noreply.github.com`;return se({name:"Configure git identity",env:{GIT_NAME:n,GIT_EMAIL:r},run:`git config user.name "$GIT_NAME"
|
|
24
|
+
git config user.email "$GIT_EMAIL"`})}function sn(i,e,n){let r={type:e,number:n,token:ce(i)},o=i.config.identity?.bot_login;return o&&(r["trusted-authors"]=o),{uses:i.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:r}}function Ve(i,e){let n=i.node,r=i.config,o={"role-file":Ae(i,n.files.role),model:r.agent.model,"comms-file":Ae(i,"agents/communication.md"),"scope-path":Ae(i,"agents/scope.yaml"),...r.agent.api_key_secret?{"anthropic-api-key":Be(r.agent.api_key_secret)}:{"claude-code-oauth-token":Be(r.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")},"github-token":ce(i)};e.withContext&&(o["context-file"]="${{ steps.ctx.outputs.context-file }}"),r.agent.conventions&&(o.conventions=r.agent.conventions);let s=typeof n.attrs.secrets=="string"?n.attrs.secrets.split(",").map(l=>l.trim()).filter(Boolean):[],u=[...new Set([...r.agent.secrets??[],...s])];u.length&&(o["extra-env"]=u.map(l=>`${l}=${Be(l)}`).join(`
|
|
25
|
+
`));let a=n.attrs.agent_attempts;a!==void 0&&(o["max-attempts"]=String(a));let d=n.files.prompt;return d&&(o["prompt-override-file"]=Ae(i,d)),{uses:i.actionRef("run-agent"),name:"Run agent",with:o}}function se(i){return{shell:"bash",...i}}function ht(i){let e=i.attrs.permissions;if(e===void 0)return{};if(typeof e!="string"||!e.trim())throw new Error(`node '${i.id}': permissions= must be a non-empty string like "id-token: write"`);let n={},r=e.split(",").filter(o=>o.trim());if(!r.length)throw new Error(`node '${i.id}': permissions= has no entries \u2014 expected e.g. "id-token: write"`);for(let o of r){let s=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!s)throw new Error(`node '${i.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);n[s[1]]=s[2]}return n}function fi(i,e){let n;try{n=ht(i)}catch{return e}return Object.keys(n).length?{...e,permissions:{...e.permissions,...n}}:e}var He="${{ github.event.issue.number }}",We="${{ github.event.pull_request.number }}",mt="${{ github.event.pull_request.head.sha }}",pi="${{ github.event.pull_request.head.ref }}";function xe(i,e){let n=i.attrs.timeout;return typeof n=="number"?n:e}var zr=10;function Mn(i){return Math.max(1,i-zr)}function Fn(i,e){let n=[],r=Hn(i);return r&&n.push(r),n.push(Pn(i,e)),n.push(di(i)),n}function ft(i){let e=i.node,n=e.context??"issue",r=n==="pr-diff"||n==="pr-review",o=r?{contents:"read","pull-requests":"write"}:{contents:"read",issues:"write"},s=rn(e),u=!s&&Ue(e),a=on(e),d=s?"${{ matrix.pr.number }}":We,l=s?"${{ matrix.pr.sha }}":mt,p=[],m=Hn(i);m&&p.push(m),p.push(Pn(i,r?{ref:l,fetchDepth:0}:void 0));let h=r?ci(e):[],$=h.map(F=>F.name),E=$.map((F,L)=>Qr(`gate-${F}`,L,$));h.forEach((F,L)=>{p.push({uses:i.actionRef("wait-for-checks"),id:E[L],name:`Wait for ${F.name}`,with:{sha:l,...F.kind==="workflow"?{"workflow-name":F.name,token:ce(i)}:{"check-name":F.name,token:"${{ github.token }}"},...F.graceSeconds!==void 0?{"missing-grace-seconds":F.graceSeconds}:{}}})}),h.some(F=>F.kind==="check")&&(o.checks="read"),p.push(Ge());let k=n==="pr-diff"?"pr-diff":n==="pr-review"?"pr-review":"issue";p.push(sn(i,k,r?d:He)),$.length&&p.push(Zr($,E));let x=xe(e,$.length?15+15*$.length:25),M=Ve(i,{withContext:!0});p.push($.length?M:{...M,timeoutMinutes:Mn(x)});let H={jobId:e.id,name:e.id,permissions:o,timeoutMinutes:x,steps:p};return s?(H.needs=[a],H.if=`needs.${a}.outputs.count != '0'`,H.strategy={"fail-fast":!1,matrix:{pr:`\${{ fromJSON(needs.${a}.outputs.prs) }}`}}):u&&(H.needs=[a],H.if=`needs.${a}.outputs.run == 'true'`,Ie(e).some(F=>F.kind==="unchanged-diff")&&p.push(Xr(i,a))),H}function Xr(i,e){return se({name:"Stamp the review with the diff hash",if:`\${{ success() && needs.${e}.outputs.diff_hash != '' }}`,env:{GH_TOKEN:ce(i),PR:We,HEAD_SHA:`\${{ needs.${e}.outputs.head_sha }}`,DIFF_HASH:`\${{ needs.${e}.outputs.diff_hash }}`,BOT_LOGIN:i.config.identity?.bot_login??"",MARKER_PREFIX:In(i.node)},run:["# Best-effort: a missing stamp only means the next event is reviewed again.",`ID=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," .[] | select(.user.login == env.BOT_LOGIN and .commit_id == env.HEAD_SHA)",` | select((.body // "") | contains(env.MARKER_PREFIX) | not) | .id' 2>/dev/null | tail -n 1) || ID=""`,'if [ -z "$ID" ]; then',' echo "no unstamped review by $BOT_LOGIN on $HEAD_SHA \u2014 nothing to stamp"'," exit 0","fi",`BODY=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$ID" --jq '.body // ""') || exit 0`,'gh api --method PUT "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$ID" \\',` -f body="$(printf '%s\\n\\n%s%s -->' "$BODY" "$MARKER_PREFIX" "$DIFF_HASH")" >/dev/null \\`,' || echo "::warning::could not stamp review $ID with the diff hash"'].join(`
|
|
26
|
+
`)})}function Qr(i,e,n){let r=u=>u.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),o=r(i)||`gate-${e+1}`;return n.filter((u,a)=>a!==e&&r(`gate-${u}`)===o).length>0?`${o}-${e+1}`:o}function Zr(i,e){let n={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},r=["{",' echo ""',' echo "=== CI GATES ==="'];return i.forEach((o,s)=>{n[`GATE_${s+1}_NAME`]=o,n[`GATE_${s+1}_RESULT`]=`\${{ steps.${e[s]}.outputs.conclusion }}`,r.push(` echo "$GATE_${s+1}_NAME: $GATE_${s+1}_RESULT"`)}),r.push(' echo ""',` echo "A gate whose result is not 'success' is a blocking finding: say which one"`,` echo "failed and request changes. 'timeout' or 'skipped' means CI never gave an"`,' echo "answer \u2014 treat it as unverified, not as a pass."','} >> "$CONTEXT_FILE"'),se({name:"Record CI gate results in the context",env:n,run:r.join(`
|
|
27
|
+
`)})}function eo(i){let e=i.node,n=i.config,r=Fn(i);r.push(se({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:He,ISSUE_TITLE:"${{ github.event.issue.title }}",PREFIX:n.repo.branch_prefix},run:[`SLUG=$(printf '%s' "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-50 | sed 's/-$//')`,'BRANCH="$PREFIX$ISSUE_NUMBER-$SLUG"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
28
|
+
`)}));let o=xe(e,35);return r.push(Ge()),r.push(sn(i,"issue",He)),r.push({...Ve(i,{withContext:!0}),timeoutMinutes:Mn(o)}),r.push({uses:i.actionRef("agent-fallback"),name:"Fallback: commit / push / PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}",token:ce(i),"agent-name":e.id,"base-branch":n.repo.base_branch,"issue-number":He,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
|
|
28
29
|
|
|
29
30
|
The agent finished but didn't open a PR itself, so one was created automatically. See the commits and the linked issue for context.
|
|
30
31
|
|
|
31
|
-
Closes #${
|
|
32
|
-
`)}));let
|
|
33
|
-
`)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:
|
|
34
|
-
`)})]}}function
|
|
35
|
-
`)})),i.push(Le()),i.push({...De(r,{withContext:!1}),timeoutMinutes:st(Se(e,20))}),o==="pr"?i.push({uses:r.actionRef("agent-fallback"),name:"Commit, push branch, open PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}","base-branch":t.repo.base_branch,token:ue(r),"agent-name":e.id,"scope-path":Ee(r,"agents/scope.yaml"),"pr-title":`${e.id}: scheduled update`,"pr-body":`Scheduled output from the \`${e.id}\` lane \u2014 review and merge like any agent PR.`,...s?{"allowed-paths":s}:{}}}):o==="direct"&&i.push({uses:r.actionRef("agent-fallback"),name:"Strip protected paths, commit, push",with:{branch:t.repo.base_branch,"base-branch":t.repo.base_branch,token:ue(r),"agent-name":e.id,"scope-path":Ee(r,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...s?{"allowed-paths":s}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:Se(e,20),steps:i}}function ri(r,e,t){let i=r.node,o=[],s=Sn(r);s&&o.push(s),o.push(vn(r,t?{ref:On,fetchDepth:0}:void 0)),o.push(Le()),o.push(Qe(r,t?"pr-review":"issue",t?Ze:Re)),i.files.role&&o.push(De(r,{withContext:!0}));let a=i.attrs.on_complete_label;if(typeof a=="string"&&a){let d=r.config.labels?.[a]??a;o.push(ye({name:"Apply completion label",env:{GH_TOKEN:ue(r),NUM:t?Ze:Re},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${d}'`}))}return ti(i,{jobId:i.id,name:i.id,needs:e,permissions:t?{contents:"read","pull-requests":"write",issues:"write"}:{contents:"read",issues:"write"},timeoutMinutes:Se(i,15),steps:o})}var Kr={analyst:rt,"issue-agent":rt,"pr-review":rt,producer:qr,"pr-fix":Br,"merge-gate":Gr,"human-gate":Wr,"scheduled-agent":Yr,start:()=>null,exit:()=>null};function at(r,e,t){let i=Kr[r.type];if(!i)return null;let o=i(t);return o&&ti(r,o)}I();var Jr=new Set(En);function qe(r){let e=new Map(r.nodes.map(a=>[a.id,a])),t=new Map,i=new Map;for(let a of r.nodes)t.set(a.id,[]),i.set(a.id,[]);for(let a of r.edges)t.get(a.to)?.push(a),i.get(a.from)?.push(a);let o=new Map,s=new Set;for(let a of r.nodes){if(a.type!=="fan_in")continue;let d=t.get(a.id)??[];if(d.length<2)continue;let u=[],c,f=!0;for(let $ of d){let E=e.get($.from);if(!E||!Jr.has(E.type)){f=!1;break}let v=t.get(E.id)??[],P=i.get(E.id)??[];if(v.length!==1||P.length!==1||P[0].to!==a.id){f=!1;break}let F=e.get(v[0].from);if(!F||F.type!=="parallel"){f=!1;break}if(v[0].on||v[0].when){f=!1;break}if(c===void 0)c=F.id;else if(c!==F.id){f=!1;break}u.push(E.id)}if(!f||c===void 0)continue;let h=t.get(c)??[],g=i.get(c)??[];if(h.length!==1||!h[0].on)continue;let k=new Set(u);if(!(!g.every($=>k.has($.to))||g.length!==u.length)){o.set(a.id,{parallelId:c,entryEdge:h[0],legIds:u,faninId:a.id}),s.add(c);for(let $ of u)s.add($)}}return{byFanin:o,memberIds:s}}var lt=new Set(En);function en(r,e={}){let t=[],i=new Map(r.nodes.map(a=>[a.id,a]));for(let a of r.nodes)a.declared||t.push({level:"error",code:"node.undeclared",message:`node '${a.id}' is referenced in an edge but never declared`,where:{node:a.id,line:a.line},hint:`add a node statement, e.g. ${a.id} [type=...]`});for(let a of r.nodes){if(lt.has(a.type)&&!a.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${a.id}' (type ${a.type}) needs a role="..." job description`,where:{node:a.id,line:a.line}}),a.attrs.permissions!==void 0){try{ot(a)}catch(d){t.push({level:"error",code:"node.bad-permissions",message:d.message,where:{node:a.id,line:a.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(a.type==="start"||a.type==="exit"||a.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${a.id}' (type ${a.type}) is ignored \u2014 this node emits no workflow job`,where:{node:a.id,line:a.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}a.type==="human-gate"&&a.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${a.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:a.id,line:a.line}}),a.type==="merge-gate"&&!a.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${a.id}' has no policy="..."; default merge policy will be used`,where:{node:a.id,line:a.line}})}if(e.fileExists)for(let a of r.nodes)for(let d of["role","policy","prompt","tools"]){let u=a.files[d];u&&!e.fileExists(u)&&t.push({level:"error",code:"file.missing",message:`node '${a.id}' references ${d}="${u}" which does not exist`,where:{node:a.id,line:a.line,file:u}})}if(e.roles){let a=new Map;for(let u of r.nodes)a.set(u.id,[]);for(let u of r.edges){let c=i.get(u.to);c&&a.get(u.from)?.push({node:c,edge:u})}let d=u=>(e.roles?.get(u.id)?.role??u.id).toLowerCase();for(let u of r.nodes){let c=e.roles.get(u.id);if(!c?.handoffs)continue;let f=a.get(u.id)??[],h=new Set(f.flatMap(k=>[k.node.id.toLowerCase(),d(k.node)])),g=new Set(c.handoffs.map(k=>String(k.to).toLowerCase()));for(let k of c.handoffs)h.has(String(k.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${c.role}' (node '${u.id}') declares a handoff to '${k.to}' but there is no matching out-edge`,where:{node:u.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:k,edge:$}of f)k.type==="exit"&&!$.when||!g.has(k.id.toLowerCase())&&!g.has(d(k))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${u.id}' has an out-edge to '${k.id}' not declared as a handoff in role '${c.role}'`,where:{node:u.id,edge:[u.id,k.id]},hint:"document the handoff in the role, or remove the edge"})}}let o=(a,d)=>{if(typeof a=="string"){let u=a.match(/<[A-Za-z][^<>]{0,80}>/);u&&t.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${u[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(a))a.forEach((u,c)=>o(u,`${d}[${c}]`));else if(a&&typeof a=="object")for(let[u,c]of Object.entries(a))o(c,d?`${d}.${u}`:u)};if(o(r.config,""),e.fileExists&&(r.config.runtime?.mode??"pinned")==="vendored"){let a=new Set,d=!1;for(let u of r.nodes)lt.has(u.type)&&(d=!0,a.add("run-agent")),lt.has(u.type)&&u.type!=="scheduled-agent"&&a.add("agent-context"),(u.type==="producer"||u.type==="scheduled-agent")&&a.add("agent-fallback"),u.type==="merge-gate"&&a.add("merge-gate"),u.type==="pr-review"&&u.attrs.gates!==void 0&&a.add("wait-for-checks");for(let u of a)e.fileExists(`actions/${u}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${u}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});d&&!e.fileExists("agent-setup/action.yml")&&t.push({level:"warning",code:"runtime.agent-setup-missing",message:"generated agent jobs use ./.github/agent-setup, which does not exist",hint:"run `gp-foundry vendor` (or `gp-foundry init`) to scaffold the agent-setup shim"})}{let{byFanin:a,memberIds:d}=qe(r);for(let u of r.nodes)if(u.type==="parallel"&&!d.has(u.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${u.id}' is not part of a clean diamond (need: exactly one in-edge carrying on=, \u22652 bare out-edges to agent legs that each flow into one fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),u.type==="fan_in"){let c=a.get(u.id);if(!c)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${u.id}' is not the join of a clean diamond (need \u22652 legs, each with exactly one in-edge from a shared parallel and one out-edge into this fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!u.files.role&&u.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${u.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:u.id,line:u.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let f=c.legIds.filter(h=>i.get(h)?.type==="pr-review");f.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${u.id}' lanes [${f.join(", ")}] are pr-review typed \u2014 if a lane role posts a '**Verdict:**' review, the merge gate acts on ONE lane's opinion and the join is bypassed`,where:{node:u.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(ze(r.config).mode==="github-token"){let a=r.edges.filter(d=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(d.on??"")||/^(label=|verdict=)/.test(d.when??""));a.length&&t.push({level:r.config.auth?.mode==="github-token"?"error":"warning",code:"auth.github-token-no-cascade",message:`auth mode 'github-token': commits/PRs made with GITHUB_TOKEN do not trigger other workflows, so ${a.length} event-cascade edge(s) (pull_request.opened/synchronize/push) will not fire and the harness will stall`,hint:"use auth.mode 'app' or 'pat' (a fine-grained PAT secret), or drive those stages via explicit dispatch"})}return!r.config.identity?.bot_login&&r.edges.some(a=>/^verdict=/.test(a.when??""))&&t.push({level:"warning",code:"auth.no-bot-login",message:"identity.bot_login is unset, so verdict-triggered workflows (fixer, human-gate) guard only on the verdict marker \u2014 any user who can review the PR can fire them",hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"}),r.nodes.some(a=>a.type==="start"||a.attrs.schedule!==void 0||a.type==="merge-gate")||t.push({level:"warning",code:"graph.no-entry",message:"harness has no entry node (a start node or a scheduled node) \u2014 nothing will trigger it"}),t}I();var zr=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),oi=new Set(["start"]);function nn(r){let e=[],t=new Set(r.nodes.map(c=>c.id)),i=new Map(r.nodes.map(c=>[c.id,c])),o=new Map;for(let c of t)o.set(c,[]);for(let c of r.edges)t.has(c.from)&&t.has(c.to)&&o.get(c.from).push(c.to);let s=r.nodes.filter(c=>oi.has(c.type)||c.attrs.schedule!==void 0||c.type==="merge-gate"),a=new Set,d=s.map(c=>c.id);for(;d.length;){let c=d.pop();if(!a.has(c)){a.add(c);for(let f of o.get(c)??[])d.push(f)}}for(let c of r.nodes)!a.has(c.id)&&!oi.has(c.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${c.id}' is unreachable from any entry (start/scheduled) node`,where:{node:c.id,line:c.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let c of r.nodes)(o.get(c.id)??[]).length===0&&!zr.has(c.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${c.id}' (type ${c.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:c.id,line:c.line},hint:"route it to a next node, or make it an exit"});for(let c of Zr(t,o)){if(!(c.length>1||(o.get(c[0])??[]).includes(c[0])))continue;let h=new Set(c),g=[];for(let k of c)for(let $ of o.get(k)??[])h.has($)||g.push({from:k,to:$});g.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${c.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:c[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):g.some(k=>Qr(Xr(r,k.from,k.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${c.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:c[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let u=new Map;for(let c of r.edges){let f=`${c.on??""}|${c.when??""}`;u.has(c.from)||u.set(c.from,new Map);let h=u.get(c.from);h.has(f)||h.set(f,new Set),h.get(f).add(c.to)}for(let[c,f]of u)for(let[h,g]of f)g.size>1&&h!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${c}' has multiple edges with identical trigger/guard (${h}) to different targets: ${[...g].join(", ")}`,where:{node:c},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Xr(r,e,t){return r.edges.find(i=>i.from===e&&i.to===t)?.when}function Qr(r){return r?/(>=|>|attempts|max|count|limit)/i.test(r):!1}function Zr(r,e){let t=0,i=new Map,o=new Map,s=new Set,a=[],d=[],u=c=>{i.set(c,t),o.set(c,t),t++,a.push(c),s.add(c);for(let f of e.get(c)??[])i.has(f)?s.has(f)&&o.set(c,Math.min(o.get(c),i.get(f))):(u(f),o.set(c,Math.min(o.get(c),o.get(f))));if(o.get(c)===i.get(c)){let f=[],h;do h=a.pop(),s.delete(h),f.push(h);while(h!==c);d.push(f.reverse())}};for(let c of r)i.has(c)||u(c);return d}I();var eo=new Set(["pr-review","pr-fix"]);function no(r,e){return e.labels?.[r]??r}function Hn(r){return eo.has(r.type)||r.context==="pr-diff"||r.context==="pr-review"}function si(r,e,t){let i=(o,s)=>{r[o]??={},r[o].types??=[],r[o].types.includes(s)||r[o].types.push(s)};switch(e){case"issues.opened":return i("issues","opened");case"issues.labeled":return i("issues","labeled");case"issue_comment.created":return i("issue_comment","created");case"pull_request.opened":return i("pull_request","opened");case"pull_request.synchronize":return i("pull_request","synchronize");case"pull_request.labeled":return i("pull_request","labeled");case"pull_request.closed":return i("pull_request","closed");case"pull_request_review.submitted":return i("pull_request_review","submitted");case"push":if(Hn(t))return i("pull_request","synchronize");r.push??={};return;case"workflow_dispatch":r.workflow_dispatch??={};return;default:r[e]??={}}}function Tn(r,e){return r==="push"&&Hn(e)?"pull_request.synchronize":r}function ci(r){let[e,t]=r.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function to(r,e,t){if(r.on)return{events:r.on.split(",").map(s=>s.trim()).filter(Boolean),guard:r.when?Nn(r.when,e,t):void 0};if(!r.when)return;let i=r.when;if(i.startsWith("label="))return{events:[Hn(e)?"pull_request.labeled":"issues.labeled"],guard:Nn(i,e,t)};if(i.startsWith("verdict="))return{events:["pull_request_review.submitted"],guard:Nn(i,e,t)}}function Nn(r,e,t){if(r.startsWith("label="))return`github.event.label.name == '${no(r.slice(6),t)}'`;let i=r==="verdict=approve"?"APPROVE":r==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(i){let o=`contains(github.event.review.body, '**Verdict:** ${i}')`,s=io(t);return s?`${o} && ${s}`:o}}function io(r){let e=r.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function ai(r){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(r)}function ro(r){let e=r.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function li(r,e,t){let i=ro(t),o=[...e].filter(ai);if(!i||o.length===0)return r;let s=[...e].filter(d=>!ai(d)),a=s.length?`(${s.map(ci).join(" || ")} || ${i})`:i;return r?`(${r}) && ${a}`:a}function oo(r){if(r.attrs.schedule!==void 0)return{group:r.id,"cancel-in-progress":!1};let t=Hn(r)||r.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${r.id}-${t}`,"cancel-in-progress":r.type==="issue-agent"}}function ui(r){let e={},t=new Map(r.nodes.map(s=>[s.id,s])),i=new Map;for(let s of r.nodes)i.set(s.id,[]);for(let s of r.edges)i.get(s.to)?.push(s);let o=qe(r);for(let s of r.nodes){if(s.type==="start"||s.type==="exit"||o.memberIds.has(s.id))continue;let a=o.byFanin.get(s.id);if(a){let $=a.entryEdge,E=t.get(a.legIds[0]),v={},P=($.on??"").split(",").map(K=>K.trim()).filter(Boolean);for(let K of P)si(v,K,E);let F={nodeId:s.id,triggers:v,dispatches:[]},L=new Set(P.map(K=>Tn(K,E))),D=li($.when?Nn($.when,E,r.config):void 0,L,r.config);D&&(F.guard=D);let oe=P.some(K=>Tn(K,E).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";F.concurrency={group:`${s.id}-${oe}`,"cancel-in-progress":!1},e[s.id]=F;continue}if(s.type==="parallel"||s.type==="fan_in")continue;let d={},u=new Set,c=new Set,f=new Set,h=[];if(s.attrs.schedule!==void 0)d.schedule=[{cron:String(s.attrs.schedule)}],d.workflow_dispatch={};else{for(let $ of i.get(s.id)??[]){let E=to($,s,r.config);if(E){for(let v of E.events)si(d,v,s);for(let v of E.events)f.add(Tn(v,s));if(E.guard)u.add(E.guard);else for(let v of E.events)c.add(Tn(v,s))}}if(u.size&&c.size)for(let $ of c)u.add(ci($))}for(let $ of r.edges)$.from===s.id&&$.do&&h.push({toNode:$.to,when:$.when});let g=li(u.size?[...u].join(" || "):void 0,f,r.config),k={nodeId:s.id,triggers:d,dispatches:h};g&&(k.guard=g),Object.keys(d).length&&(k.concurrency=oo(s)),e[s.id]=k}return{perNode:e}}I();I();function so(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ie={},Rn={},ve={},di;function tn(){if(di)return ve;di=1;function r(a){return typeof a>"u"||a===null}function e(a){return typeof a=="object"&&a!==null}function t(a){return Array.isArray(a)?a:r(a)?[]:[a]}function i(a,d){if(d){let u=Object.keys(d);for(let c=0,f=u.length;c<f;c+=1){let h=u[c];a[h]=d[h]}}return a}function o(a,d){let u="";for(let c=0;c<d;c+=1)u+=a;return u}function s(a){return a===0&&Number.NEGATIVE_INFINITY===1/a}return ve.isNothing=r,ve.isObject=e,ve.toArray=t,ve.repeat=o,ve.isNegativeZero=s,ve.extend=i,ve}var ct,fi;function rn(){if(fi)return ct;fi=1;function r(t,i){let o="",s=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(o+='in "'+t.mark.name+'" '),o+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!i&&t.mark.snippet&&(o+=`
|
|
32
|
+
Closes #${He}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:o,steps:r}}function no(i){let e=i.node,n=Fn(i,{ref:pi,fetchDepth:0}),r=typeof e.attrs.max_attempts=="number"?e.attrs.max_attempts:3,o=`<!-- gp-foundry:attempt:${e.id} -->`,s=i.config.labels?.["needs-human"]??"needs-human",u=i.config.identity?.bot_login??"";n.push(se({id:"attempts",name:`Enforce attempt budget (max ${r})`,env:{GH_TOKEN:ce(i),PR:We,MARKER:o,MAX:String(r),BOT_LOGIN:u},run:["# One request-changes verdict = one attempt. The jq filter reads the bot","# login from the environment (never interpolated into the script), and an","# empty BOT_LOGIN counts any reviewer's request-changes.","# (--paginate emits one count per page, so the counts are summed.)",`COUNT=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," [ .[]",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',' | select(.state == "CHANGES_REQUESTED" or ((.body // "") | test("Verdict.*REQUEST_CHANGES")))'," ] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}')",'[ -n "$COUNT" ] || COUNT=0','echo "attempts so far: $COUNT / $MAX"','if [ "$COUNT" -gt "$MAX" ]; then',` gh pr edit "$PR" --add-label "${s}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${s}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${e.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${s}\` and stopping. A human should take this over.\\n\\n%s' "$COUNT" "$MAX" "$MARKER")"`,' echo "exhausted=true" >> "$GITHUB_OUTPUT"',"else",` gh pr comment "$PR" --body "$(printf '%s attempt %s of %s' "$MARKER" "$COUNT" "$MAX")" >/dev/null`,' echo "exhausted=false" >> "$GITHUB_OUTPUT"',"fi"].join(`
|
|
33
|
+
`)}));let a="steps.attempts.outputs.exhausted != 'true'";return n.push({...Ge(),if:a}),n.push({...sn(i,"pr-review",We),if:a}),n.push({...Ve(i,{withContext:!0}),if:a,timeoutMinutes:Mn(xe(e,35))}),n.push(se({name:"Commit and push fixes",if:`${a} && !cancelled()`,env:{BRANCH:pi},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${e.id}"`,"fi","# ...then push if HEAD is ahead of the remote (the agent may have committed itself).",'git fetch origin "$BRANCH" --quiet 2>/dev/null || true','if [ "$(git rev-parse HEAD)" != "$(git rev-parse "origin/$BRANCH" 2>/dev/null || echo none)" ]; then',' git push origin "HEAD:$BRANCH"',' echo "pushed fix to $BRANCH"',"else",' echo "no changes to push"',"fi"].join(`
|
|
34
|
+
`)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:xe(e,35),steps:n}}function hi(i){return`gp-foundry/human-approval (${String(i.attrs.environment??"production")})`}var to="github-actions";function io(i){return`${hi(i)}@${to}`}function ro(i){let e=i.node,n=Fn(i,{fetchDepth:0}),o=i.inEdges.map(s=>i.nodeById?.(s.from)).filter(s=>!!s&&s.type==="human-gate").map(io);return n.push({uses:i.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:ce(i),"checks-token":"${{ github.token }}","policy-path":Ae(i,e.files.policy),"base-branch":i.config.repo.base_branch,"branch-prefix":i.config.repo.branch_prefix,...i.config.identity?.bot_login?{"bot-login":i.config.identity.bot_login}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:xe(e,10),steps:n}}function oo(i){let e=i.node,n=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:n,steps:[se({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:hi(e),HEAD_SHA:mt,ENVIRONMENT:n},run:['if ! gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$CHECK_NAME" \\',' -f head_sha="$HEAD_SHA" \\'," -f status=completed \\"," -f conclusion=success \\"," -f 'output[title]=Approved' \\",' -f "output[summary]=Environment \\"$ENVIRONMENT\\" was approved by a human for $HEAD_SHA."; then',' echo "::error::Approved for $ENVIRONMENT, but publishing the approval check failed."',' echo "::error::The merge gate requires \\"$CHECK_NAME\\" on $HEAD_SHA, so this PR will not merge until it is published."'," exit 1","fi",'echo "Approved for $ENVIRONMENT."'].join(`
|
|
35
|
+
`)})]}}function so(i){let e=i.node,n=i.config,r=Fn(i,{fetchDepth:0}),o=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",s=typeof e.attrs.paths=="string"?e.attrs.paths:"";return o==="pr"&&r.push(se({id:"branch",name:"Create branch",env:{PREFIX:n.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}"},run:['BRANCH="$PREFIX$NODE-$RUN_ID"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
36
|
+
`)})),r.push(Ge()),r.push({...Ve(i,{withContext:!1}),id:"agent",timeoutMinutes:Mn(xe(e,20))}),o==="pr"?r.push({uses:i.actionRef("agent-fallback"),name:"Commit, push branch, open PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}","base-branch":n.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":Ae(i,"agents/scope.yaml"),"pr-title":`${e.id}: scheduled update`,"pr-body":`Scheduled output from the \`${e.id}\` lane \u2014 review and merge like any agent PR.`,...s?{"allowed-paths":s}:{}}}):o==="direct"&&(r.push({uses:i.actionRef("agent-fallback"),name:"Strip protected paths, commit, push",with:{branch:n.repo.base_branch,"base-branch":n.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":Ae(i,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...s?{"allowed-paths":s}:{}}}),r.push(se({id:"recovery",name:"Create recovery branch",if:"${{ !cancelled() && steps.agent.outcome == 'failure' }}",env:{PREFIX:n.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:['BRANCH="$PREFIX$NODE-recovery-$RUN_ID-$RUN_ATTEMPT"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
37
|
+
`)})),r.push({uses:i.actionRef("agent-fallback"),name:"Preserve failed agent output for review",if:"${{ !cancelled() && steps.agent.outcome == 'failure' && steps.recovery.outcome == 'success' }}",with:{branch:"${{ steps.recovery.outputs.branch }}","base-branch":n.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":Ae(i,"agents/scope.yaml"),"pr-title":`${e.id}: recover incomplete scheduled output`,"pr-body":`Partial output from a failed \`${e.id}\` run. Review for completeness before merging. Run: \${{ github.server_url }}/\${{ github.repository }}/actions/runs/\${{ github.run_id }}`,"pr-label":i.config.labels?.["needs-human"]??"needs-human",...s?{"allowed-paths":s}:{}}})),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:xe(e,20),steps:r}}function mi(i,e,n){let r=i.node,o=[],s=Hn(i);s&&o.push(s),o.push(Pn(i,n?{ref:mt,fetchDepth:0}:void 0)),o.push(Ge()),o.push(sn(i,n?"pr-review":"issue",n?We:He)),r.files.role&&o.push(Ve(i,{withContext:!0}));let u=r.attrs.on_complete_label;if(typeof u=="string"&&u){let a=i.config.labels?.[u]??u;o.push(se({name:"Apply completion label",env:{GH_TOKEN:ce(i),NUM:n?We:He},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${a}'`}))}return fi(r,{jobId:r.id,name:r.id,needs:e,permissions:n?{contents:"read","pull-requests":"write",issues:"write"}:{contents:"read",issues:"write"},timeoutMinutes:xe(r,15),steps:o})}var ao={analyst:ft,"issue-agent":ft,"pr-review":ft,producer:eo,"pr-fix":no,"merge-gate":ro,"human-gate":oo,"scheduled-agent":so,start:()=>null,exit:()=>null};function gt(i,e,n){let r=ao[i.type];if(!r)return null;let o=r(n);return o&&fi(i,o)}I();var lo=new Set(qe);function Pe(i){let e=new Map(i.nodes.map(u=>[u.id,u])),n=new Map,r=new Map;for(let u of i.nodes)n.set(u.id,[]),r.set(u.id,[]);for(let u of i.edges)n.get(u.to)?.push(u),r.get(u.from)?.push(u);let o=new Map,s=new Set;for(let u of i.nodes){if(u.type!=="fan_in")continue;let a=n.get(u.id)??[];if(a.length<2)continue;let d=[],l,p=!0;for(let E of a){let k=e.get(E.from);if(!k||!lo.has(k.type)){p=!1;break}let x=n.get(k.id)??[],M=r.get(k.id)??[];if(x.length!==1||M.length!==1||M[0].to!==u.id){p=!1;break}let H=e.get(x[0].from);if(!H||H.type!=="parallel"){p=!1;break}if(x[0].on||x[0].when){p=!1;break}if(l===void 0)l=H.id;else if(l!==H.id){p=!1;break}d.push(k.id)}if(!p||l===void 0)continue;let m=n.get(l)??[],h=r.get(l)??[];if(m.length!==1||!m[0].on)continue;let $=new Set(d);if(!(!h.every(E=>$.has(E.to))||h.length!==d.length)){o.set(u.id,{parallelId:l,entryEdge:m[0],legIds:d,faninId:u.id}),s.add(l);for(let E of d)s.add(E)}}return{byFanin:o,memberIds:s}}var an=new Set(qe);function ln(i,e={}){let n=[],r=new Map(i.nodes.map(a=>[a.id,a])),o=Pe(i).memberIds;for(let a of i.nodes)a.declared||n.push({level:"error",code:"node.undeclared",message:`node '${a.id}' is referenced in an edge but never declared`,where:{node:a.id,line:a.line},hint:`add a node statement, e.g. ${a.id} [type=...]`});for(let a of i.nodes){if(an.has(a.type)&&!a.files.role&&n.push({level:"error",code:"node.missing-role",message:`agent node '${a.id}' (type ${a.type}) needs a role="..." job description`,where:{node:a.id,line:a.line}}),a.attrs.permissions!==void 0){try{ht(a)}catch(d){n.push({level:"error",code:"node.bad-permissions",message:d.message,where:{node:a.id,line:a.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(a.type==="start"||a.type==="exit"||a.type==="parallel")&&n.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${a.id}' (type ${a.type}) is ignored \u2014 this node emits no workflow job`,where:{node:a.id,line:a.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(a.attrs.agent_attempts!==void 0){let d=a.attrs.agent_attempts;(typeof d!="number"||!Number.isInteger(d)||d<1)&&n.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${a.id}' must be a whole number >= 1, got ${JSON.stringify(d)}`,where:{node:a.id,line:a.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),an.has(a.type)||n.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${a.id}' (type ${a.type}) is ignored \u2014 this node runs no agent`,where:{node:a.id,line:a.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}if(a.attrs.cancel_in_progress!==void 0&&(typeof a.attrs.cancel_in_progress!="boolean"&&n.push({level:"error",code:"node.bad-cancel-in-progress",message:`cancel_in_progress= on '${a.id}' must be true or false, got ${JSON.stringify(a.attrs.cancel_in_progress)}`,where:{node:a.id,line:a.line}}),!an.has(a.type)||o.has(a.id)?n.push({level:"warning",code:"node.cancel-in-progress-ignored",message:`cancel_in_progress= on '${a.id}' is ignored \u2014 it applies to an agent node that owns its own workflow`,where:{node:a.id,line:a.line},hint:"set it on a standalone agent lane (analyst, issue-agent, producer, pr-review, pr-fix, scheduled-agent)"}):a.attrs.cancel_in_progress===!0&&(a.type==="producer"||a.type==="pr-fix"||a.type==="scheduled-agent"&&a.attrs.commit!=="none")&&n.push({level:"warning",code:"node.cancel-in-progress-discards-work",message:`cancel_in_progress=true on '${a.id}' (type ${a.type}): a cancelled run skips the commit/push salvage, so whatever the agent had written but not yet pushed is lost`,where:{node:a.id,line:a.line},hint:"keep it for lanes where the newer event supersedes the older run's work; otherwise leave the default (queue)"})),a.attrs.checkout!==void 0&&(a.attrs.checkout!=="partial"?n.push({level:"error",code:"node.bad-checkout",message:`checkout= on '${a.id}' must be "partial", got ${JSON.stringify(a.attrs.checkout)}`,where:{node:a.id,line:a.line},hint:`checkout="partial" is a blob-less clone with full history; omit the attr for the lane's default checkout`}):(a.type==="start"||a.type==="exit"||a.type==="parallel"||a.type==="human-gate")&&n.push({level:"warning",code:"node.checkout-ignored",message:`checkout= on '${a.id}' (type ${a.type}) is ignored \u2014 this node checks nothing out`,where:{node:a.id,line:a.line}})),a.attrs.gates!==void 0)try{dt(a)}catch(d){n.push({level:"error",code:"node.bad-gates",message:d.message,where:{node:a.id,line:a.line},hint:'comma-separated workflow files or check-run names, each with an optional ?<seconds> grace \u2014 e.g. gates="ci.yml, e2e (chromium)?90"'})}if(a.attrs.skip!==void 0){let d=[];try{d=pt(a)}catch(p){n.push({level:"error",code:"node.bad-skip",message:p.message,where:{node:a.id,line:a.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}(a.type==="pr-review"||a.type==="analyst")&&tn(a)&&a.attrs.schedule===void 0&&!o.has(a.id)||n.push({level:"error",code:"node.skip-unsupported",message:`skip= on '${a.id}' is not supported here \u2014 it needs a standalone, event-driven pr-review/analyst node with context="pr-diff" or "pr-review"`,where:{node:a.id,line:a.line},hint:a.attrs.select!==void 0||a.attrs.schedule!==void 0?'a scheduled (select="sweep") lane picks its own PRs; skip= guards a lane that reacts to PR events':o.has(a.id)?"a diamond leg has no guard job of its own; put the review lane outside the diamond":'set context="pr-diff" on the node \u2014 skip= reads the pull request the event is about'}),d.some(p=>p.kind==="unchanged-diff")&&!i.config.identity?.bot_login&&n.push({level:"error",code:"node.skip-needs-bot-login",message:`skip="unchanged-diff" on '${a.id}' compares against the bot's last review, but identity.bot_login is unset`,where:{node:a.id,line:a.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"})}a.attrs.select!==void 0&&(a.attrs.select!=="sweep"?n.push({level:"error",code:"node.bad-select",message:`select= on '${a.id}' must be "sweep", got ${JSON.stringify(a.attrs.select)}`,where:{node:a.id,line:a.line}}):a.type!=="pr-review"||!tn(a)||o.has(a.id)?n.push({level:"error",code:"node.select-unsupported",message:`select="sweep" on '${a.id}' needs a standalone pr-review node with context="pr-diff" or "pr-review"`,where:{node:a.id,line:a.line}}):a.attrs.schedule===void 0?n.push({level:"error",code:"node.sweep-no-schedule",message:`select="sweep" on '${a.id}' needs schedule="<cron>" \u2014 a sweep is driven by its schedule, not by PR events`,where:{node:a.id,line:a.line},hint:'e.g. schedule="*/15 * * * *"'}):i.config.identity?.bot_login||n.push({level:"warning",code:"node.sweep-no-bot-login",message:`select="sweep" on '${a.id}': identity.bot_login is unset, so ANY review carrying a '**Verdict:**' marker counts as the decision \u2014 a user can pre-empt the lane by posting one`,where:{node:a.id,line:a.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the verdict"})),a.type==="human-gate"&&a.attrs.environment===void 0&&n.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${a.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:a.id,line:a.line}}),a.type==="merge-gate"&&!a.files.policy&&n.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${a.id}' has no policy="..."; default merge policy will be used`,where:{node:a.id,line:a.line}})}if(e.fileExists)for(let a of i.nodes)for(let d of["role","policy","prompt","tools"]){let l=a.files[d];l&&!e.fileExists(l)&&n.push({level:"error",code:"file.missing",message:`node '${a.id}' references ${d}="${l}" which does not exist`,where:{node:a.id,line:a.line,file:l}})}if(e.roles){let a=new Map;for(let l of i.nodes)a.set(l.id,[]);for(let l of i.edges){let p=r.get(l.to);p&&a.get(l.from)?.push({node:p,edge:l})}let d=l=>(e.roles?.get(l.id)?.role??l.id).toLowerCase();for(let l of i.nodes){let p=e.roles.get(l.id);if(!p?.handoffs)continue;let m=a.get(l.id)??[],h=new Set(m.flatMap(E=>[E.node.id.toLowerCase(),d(E.node)])),$=new Set(p.handoffs.map(E=>String(E.to).toLowerCase()));for(let E of p.handoffs)h.has(String(E.to).toLowerCase())||n.push({level:"warning",code:"role.handoff-no-edge",message:`role '${p.role}' (node '${l.id}') declares a handoff to '${E.to}' but there is no matching out-edge`,where:{node:l.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:E,edge:k}of m)E.type==="exit"&&!k.when||!$.has(E.id.toLowerCase())&&!$.has(d(E))&&n.push({level:"warning",code:"role.edge-no-handoff",message:`node '${l.id}' has an out-edge to '${E.id}' not declared as a handoff in role '${p.role}'`,where:{node:l.id,edge:[l.id,E.id]},hint:"document the handoff in the role, or remove the edge"})}}let s=(a,d)=>{if(typeof a=="string"){let l=a.match(/<[A-Za-z][^<>]{0,80}>/);l&&n.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${l[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(a))a.forEach((l,p)=>s(l,`${d}[${p}]`));else if(a&&typeof a=="object")for(let[l,p]of Object.entries(a))s(p,d?`${d}.${l}`:l)};if(s(i.config,""),e.fileExists&&(i.config.runtime?.mode??"pinned")==="vendored"){let a=new Set,d=!1;for(let l of i.nodes)an.has(l.type)&&(d=!0,a.add("run-agent")),an.has(l.type)&&l.type!=="scheduled-agent"&&a.add("agent-context"),(l.type==="producer"||l.type==="scheduled-agent")&&a.add("agent-fallback"),l.type==="merge-gate"&&a.add("merge-gate"),l.type==="pr-review"&&l.attrs.gates!==void 0&&a.add("wait-for-checks");for(let l of a)e.fileExists(`actions/${l}/action.yml`)||n.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${l}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});d&&!e.fileExists("agent-setup/action.yml")&&n.push({level:"warning",code:"runtime.agent-setup-missing",message:"generated agent jobs use ./.github/agent-setup, which does not exist",hint:"run `gp-foundry vendor` (or `gp-foundry init`) to scaffold the agent-setup shim"})}{let{byFanin:a,memberIds:d}=Pe(i);for(let l of i.nodes)if(l.type==="parallel"&&!d.has(l.id)&&n.push({level:"error",code:"diamond.malformed",message:`parallel '${l.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:l.id,line:l.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),l.type==="fan_in"){let p=a.get(l.id);if(!p)n.push({level:"error",code:"diamond.malformed",message:`fan_in '${l.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:l.id,line:l.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!l.files.role&&l.attrs.on_complete_label===void 0&&n.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${l.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:l.id,line:l.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let m=p.legIds.filter(h=>r.get(h)?.type==="pr-review");m.length&&n.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${l.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:l.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(nn(i.config).mode==="github-token"){let a=i.edges.filter(d=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(d.on??"")||/^(label=|verdict=)/.test(d.when??""));a.length&&n.push({level:i.config.auth?.mode==="github-token"?"error":"warning",code:"auth.github-token-no-cascade",message:`auth mode 'github-token': commits/PRs made with GITHUB_TOKEN do not trigger other workflows, so ${a.length} event-cascade edge(s) (pull_request.opened/synchronize/push) will not fire and the harness will stall`,hint:"use auth.mode 'app' or 'pat' (a fine-grained PAT secret), or drive those stages via explicit dispatch"})}return!i.config.identity?.bot_login&&i.edges.some(a=>/^verdict=/.test(a.when??""))&&n.push({level:"warning",code:"auth.no-bot-login",message:"identity.bot_login is unset, so verdict-triggered workflows (fixer, human-gate) guard only on the verdict marker \u2014 any user who can review the PR can fire them",hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"}),i.nodes.some(a=>a.type==="start"||a.attrs.schedule!==void 0||a.type==="merge-gate")||n.push({level:"warning",code:"graph.no-entry",message:"harness has no entry node (a start node or a scheduled node) \u2014 nothing will trigger it"}),n}I();var co=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),gi=new Set(["start"]);function cn(i){let e=[],n=new Set(i.nodes.map(l=>l.id)),r=new Map(i.nodes.map(l=>[l.id,l])),o=new Map;for(let l of n)o.set(l,[]);for(let l of i.edges)n.has(l.from)&&n.has(l.to)&&o.get(l.from).push(l.to);let s=i.nodes.filter(l=>gi.has(l.type)||l.attrs.schedule!==void 0||l.type==="merge-gate"),u=new Set,a=s.map(l=>l.id);for(;a.length;){let l=a.pop();if(!u.has(l)){u.add(l);for(let p of o.get(l)??[])a.push(p)}}for(let l of i.nodes)!u.has(l.id)&&!gi.has(l.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${l.id}' is unreachable from any entry (start/scheduled) node`,where:{node:l.id,line:l.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let l of i.nodes)(o.get(l.id)??[]).length===0&&!co.has(l.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${l.id}' (type ${l.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:l.id,line:l.line},hint:"route it to a next node, or make it an exit"});for(let l of fo(n,o)){if(!(l.length>1||(o.get(l[0])??[]).includes(l[0])))continue;let m=new Set(l),h=[];for(let $ of l)for(let E of o.get($)??[])m.has(E)||h.push({from:$,to:E});h.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${l.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:l[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):h.some($=>po(uo(i,$.from,$.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${l.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:l[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let d=new Map;for(let l of i.edges){let p=`${l.on??""}|${l.when??""}`;d.has(l.from)||d.set(l.from,new Map);let m=d.get(l.from);m.has(p)||m.set(p,new Set),m.get(p).add(l.to)}for(let[l,p]of d)for(let[m,h]of p)h.size>1&&m!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${l}' has multiple edges with identical trigger/guard (${m}) to different targets: ${[...h].join(", ")}`,where:{node:l},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function uo(i,e,n){return i.edges.find(r=>r.from===e&&r.to===n)?.when}function po(i){return i?/(>=|>|attempts|max|count|limit)/i.test(i):!1}function fo(i,e){let n=0,r=new Map,o=new Map,s=new Set,u=[],a=[],d=l=>{r.set(l,n),o.set(l,n),n++,u.push(l),s.add(l);for(let p of e.get(l)??[])r.has(p)?s.has(p)&&o.set(l,Math.min(o.get(l),r.get(p))):(d(p),o.set(l,Math.min(o.get(l),o.get(p))));if(o.get(l)===r.get(l)){let p=[],m;do m=u.pop(),s.delete(m),p.push(m);while(m!==l);a.push(p.reverse())}};for(let l of i)r.has(l)||d(l);return a}I();var ho=new Set(qe),mo=new Set(["pr-review","pr-fix"]);function go(i,e){return e.labels?.[i]??i}function jn(i){return mo.has(i.type)||i.context==="pr-diff"||i.context==="pr-review"}function bt(i,e,n){let r=(o,s)=>{i[o]??={},i[o].types??=[],i[o].types.includes(s)||i[o].types.push(s)};switch(e){case"issues.opened":return r("issues","opened");case"issues.labeled":return r("issues","labeled");case"issue_comment.created":return r("issue_comment","created");case"pull_request.opened":return r("pull_request","opened");case"pull_request.synchronize":return r("pull_request","synchronize");case"pull_request.labeled":return r("pull_request","labeled");case"pull_request.closed":return r("pull_request","closed");case"pull_request.ready_for_review":return r("pull_request","ready_for_review");case"pull_request_review.submitted":return r("pull_request_review","submitted");case"push":if(jn(n))return r("pull_request","synchronize");i.push??={};return;case"workflow_dispatch":i.workflow_dispatch??={};return;default:i[e]??={}}}function un(i,e){return i==="push"&&jn(e)?"pull_request.synchronize":i}function _i(i){let[e,n]=i.split(".");return n?`(github.event_name == '${e}' && github.event.action == '${n}')`:`github.event_name == '${e}'`}function bo(i,e,n){if(i.on){let o=i.on.split(",").map(u=>u.trim()).filter(Boolean),s=o.map(u=>un(u,e));return{events:o,guard:i.when?Dn(i.when,s,n):void 0}}if(!i.when)return;let r=i.when;if(r.startsWith("label=")){let o=[jn(e)?"pull_request.labeled":"issues.labeled"];return{events:o,guard:Dn(r,o,n)}}if(r.startsWith("verdict=")){let o=["pull_request_review.submitted"];return{events:o,guard:Dn(r,o,n)}}}function Dn(i,e,n){if(i.startsWith("label=")){let o=`github.event.label.name == '${go(i.slice(6),n)}'`,s=yo(e);return s?`${o} && ${s}`:o}let r=i==="verdict=approve"?"APPROVE":i==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(r){let o=`contains(github.event.review.body, '**Verdict:** ${r}')`,s=wo(n);return s?`${o} && ${s}`:o}}function yo(i){if(i.length&&i.every(e=>e.split(".")[0]==="issues"))return"github.event.issue.state == 'open'";if(i.length&&i.every(e=>e.split(".")[0]==="pull_request"))return"github.event.pull_request.state == 'open'"}function wo(i){let e=i.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function bi(i){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(i)}function _o(i){let e=i.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function yi(i,e,n){let r=_o(n),o=[...e].filter(bi);if(!r||o.length===0)return i;let s=[...e].filter(a=>!bi(a)),u=s.length?`(${s.map(_i).join(" || ")} || ${r})`:r;return i?`(${i}) && ${u}`:u}function wi(i,e){let n=i.attrs.cancel_in_progress;return typeof n=="boolean"&&ho.has(i.type)?n:e}function Ao(i){if(i.attrs.schedule!==void 0)return{group:i.id,"cancel-in-progress":wi(i,!1)};let n=jn(i)||i.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${i.id}-${n}`,"cancel-in-progress":wi(i,i.type==="issue-agent")}}function Ai(i){let e={},n=new Map(i.nodes.map(s=>[s.id,s])),r=new Map;for(let s of i.nodes)r.set(s.id,[]);for(let s of i.edges)r.get(s.to)?.push(s);let o=Pe(i);for(let s of i.nodes){if(s.type==="start"||s.type==="exit"||o.memberIds.has(s.id))continue;let u=o.byFanin.get(s.id);if(u){let E=u.entryEdge,k=n.get(u.legIds[0]),x={},M=(E.on??"").split(",").map(K=>K.trim()).filter(Boolean);for(let K of M)bt(x,K,k);let H={nodeId:s.id,triggers:x,dispatches:[]},F=new Set(M.map(K=>un(K,k))),L=yi(E.when?Dn(E.when,[...F],i.config):void 0,F,i.config);L&&(H.guard=L);let re=M.some(K=>un(K,k).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";H.concurrency={group:`${s.id}-${re}`,"cancel-in-progress":!1},e[s.id]=H;continue}if(s.type==="parallel"||s.type==="fan_in")continue;let a={},d=new Set,l=new Set,p=new Set,m=[];if(s.attrs.schedule!==void 0)a.schedule=[{cron:String(s.attrs.schedule)}],a.workflow_dispatch={};else{for(let E of r.get(s.id)??[]){let k=bo(E,s,i.config);if(k){for(let x of k.events)bt(a,x,s);for(let x of k.events)p.add(un(x,s));if(k.guard)d.add(k.guard);else for(let x of k.events)l.add(un(x,s))}}if(a.pull_request&&Ue(s)&&Ie(s).some(E=>E.kind==="draft")&&(bt(a,"pull_request.ready_for_review",s),p.add("pull_request.ready_for_review"),l.add("pull_request.ready_for_review")),d.size&&l.size)for(let E of l)d.add(_i(E))}for(let E of i.edges)E.from===s.id&&E.do&&m.push({toNode:E.to,when:E.when});let h=yi(d.size?[...d].join(" || "):void 0,p,i.config),$={nodeId:s.id,triggers:a,dispatches:m};h&&($.guard=h),Object.keys(a).length&&($.concurrency=Ao(s)),e[s.id]=$}return{perNode:e}}I();I();function ko(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ie={},Ln={},Ce={},ki;function dn(){if(ki)return Ce;ki=1;function i(u){return typeof u>"u"||u===null}function e(u){return typeof u=="object"&&u!==null}function n(u){return Array.isArray(u)?u:i(u)?[]:[u]}function r(u,a){if(a){let d=Object.keys(a);for(let l=0,p=d.length;l<p;l+=1){let m=d[l];u[m]=a[m]}}return u}function o(u,a){let d="";for(let l=0;l<a;l+=1)d+=u;return d}function s(u){return u===0&&Number.NEGATIVE_INFINITY===1/u}return Ce.isNothing=i,Ce.isObject=e,Ce.toArray=n,Ce.repeat=o,Ce.isNegativeZero=s,Ce.extend=r,Ce}var yt,Ei;function pn(){if(Ei)return yt;Ei=1;function i(n,r){let o="",s=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(o+='in "'+n.mark.name+'" '),o+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!r&&n.mark.snippet&&(o+=`
|
|
36
38
|
|
|
37
|
-
`+
|
|
38
|
-
`+
|
|
39
|
-
`,
|
|
40
|
-
`;for(let
|
|
41
|
-
`}return
|
|
42
|
-
\r`;function
|
|
43
|
-
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function j(
|
|
44
|
-
`,
|
|
45
|
-
`,b?1+
|
|
46
|
-
`);break}y?
|
|
47
|
-
`,b?1+
|
|
48
|
-
`,
|
|
49
|
-
`,
|
|
50
|
-
`,b?1+
|
|
51
|
-
`),
|
|
52
|
-
`,w);
|
|
53
|
-
`&&(_+=
|
|
54
|
-
`+
|
|
55
|
-
`,
|
|
56
|
-
`||
|
|
57
|
-
`)?"+":w?"":"-";return C
|
|
58
|
-
`}function
|
|
59
|
-
`?
|
|
60
|
-
`);return
|
|
61
|
-
`||
|
|
62
|
-
`:"")+
|
|
63
|
-
`+
|
|
64
|
-
`,
|
|
65
|
-
`+
|
|
66
|
-
`:""}return
|
|
67
|
-
`)}]}}
|
|
39
|
+
`+n.mark.snippet),s+" "+o):s}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=i(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+i(this,r)},yt=e,yt}var wt,Si;function Eo(){if(Si)return wt;Si=1;let i=dn();function e(o,s,u,a,d){let l="",p="",m=Math.floor(d/2)-1;return a-s>m&&(l=" ... ",s=a-m+l.length),u-a>m&&(p=" ...",u=a+m-p.length),{str:l+o.slice(s,u).replace(/\t/g,"\u2192")+p,pos:a-s+l.length}}function n(o,s){return i.repeat(" ",s-o.length)+o}function r(o,s){if(s=Object.create(s||null),!o.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);let u=/\r?\n|\r|\0/g,a=[0],d=[],l,p=-1;for(;l=u.exec(o.buffer);)d.push(l.index),a.push(l.index+l[0].length),o.position<=l.index&&p<0&&(p=a.length-2);p<0&&(p=a.length-1);let m="",h=Math.min(o.line+s.linesAfter,d.length).toString().length,$=s.maxLength-(s.indent+h+3);for(let k=1;k<=s.linesBefore&&!(p-k<0);k++){let x=e(o.buffer,a[p-k],d[p-k],o.position-(a[p]-a[p-k]),$);m=i.repeat(" ",s.indent)+n((o.line-k+1).toString(),h)+" | "+x.str+`
|
|
40
|
+
`+m}let E=e(o.buffer,a[p],d[p],o.position,$);m+=i.repeat(" ",s.indent)+n((o.line+1).toString(),h)+" | "+E.str+`
|
|
41
|
+
`,m+=i.repeat("-",s.indent+h+3+E.pos)+`^
|
|
42
|
+
`;for(let k=1;k<=s.linesAfter&&!(p+k>=d.length);k++){let x=e(o.buffer,a[p+k],d[p+k],o.position-(a[p]-a[p+k]),$);m+=i.repeat(" ",s.indent)+n((o.line+k+1).toString(),h)+" | "+x.str+`
|
|
43
|
+
`}return m.replace(/\n$/,"")}return wt=r,wt}var _t,$i;function oe(){if($i)return _t;$i=1;let i=pn(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(s){let u={};return s!==null&&Object.keys(s).forEach(function(a){s[a].forEach(function(d){u[String(d)]=a})}),u}function o(s,u){if(u=u||{},Object.keys(u).forEach(function(a){if(e.indexOf(a)===-1)throw new i('Unknown option "'+a+'" is met in definition of "'+s+'" YAML type.')}),this.options=u,this.tag=s,this.kind=u.kind||null,this.resolve=u.resolve||function(){return!0},this.construct=u.construct||function(a){return a},this.instanceOf=u.instanceOf||null,this.predicate=u.predicate||null,this.represent=u.represent||null,this.representName=u.representName||null,this.defaultStyle=u.defaultStyle||null,this.multi=u.multi||!1,this.styleAliases=r(u.styleAliases||null),n.indexOf(this.kind)===-1)throw new i('Unknown kind "'+this.kind+'" is specified for "'+s+'" YAML type.')}return _t=o,_t}var At,vi;function Yi(){if(vi)return At;vi=1;let i=pn(),e=oe();function n(s,u){let a=[];return s[u].forEach(function(d){let l=a.length;a.forEach(function(p,m){p.tag===d.tag&&p.kind===d.kind&&p.multi===d.multi&&(l=m)}),a[l]=d}),a}function r(){let s={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function u(a){a.multi?(s.multi[a.kind].push(a),s.multi.fallback.push(a)):s[a.kind][a.tag]=s.fallback[a.tag]=a}for(let a=0,d=arguments.length;a<d;a+=1)arguments[a].forEach(u);return s}function o(s){return this.extend(s)}return o.prototype.extend=function(u){let a=[],d=[];if(u instanceof e)d.push(u);else if(Array.isArray(u))d=d.concat(u);else if(u&&(Array.isArray(u.implicit)||Array.isArray(u.explicit)))u.implicit&&(a=a.concat(u.implicit)),u.explicit&&(d=d.concat(u.explicit));else throw new i("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");a.forEach(function(p){if(!(p instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(p.loadKind&&p.loadKind!=="scalar")throw new i("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(p.multi)throw new i("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),d.forEach(function(p){if(!(p instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let l=Object.create(o.prototype);return l.implicit=(this.implicit||[]).concat(a),l.explicit=(this.explicit||[]).concat(d),l.compiledImplicit=n(l,"implicit"),l.compiledExplicit=n(l,"explicit"),l.compiledTypeMap=r(l.compiledImplicit,l.compiledExplicit),l},At=o,At}var kt,xi;function Ki(){if(xi)return kt;xi=1;let i=oe();return kt=new i("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),kt}var Et,Ci;function Ji(){if(Ci)return Et;Ci=1;let i=oe();return Et=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Et}var St,Oi;function zi(){if(Oi)return St;Oi=1;let i=oe();return St=new i("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),St}var $t,Ti;function Xi(){if(Ti)return $t;Ti=1;let i=Yi();return $t=new i({explicit:[Ki(),Ji(),zi()]}),$t}var vt,Ri;function Qi(){if(Ri)return vt;Ri=1;let i=oe();function e(o){if(o===null)return!0;let s=o.length;return s===1&&o==="~"||s===4&&(o==="null"||o==="Null"||o==="NULL")}function n(){return null}function r(o){return o===null}return vt=new i("tag:yaml.org,2002:null",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),vt}var xt,Ni;function Zi(){if(Ni)return xt;Ni=1;let i=oe();function e(o){if(o===null)return!1;let s=o.length;return s===4&&(o==="true"||o==="True"||o==="TRUE")||s===5&&(o==="false"||o==="False"||o==="FALSE")}function n(o){return o==="true"||o==="True"||o==="TRUE"}function r(o){return Object.prototype.toString.call(o)==="[object Boolean]"}return xt=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{lowercase:function(o){return o?"true":"false"},uppercase:function(o){return o?"TRUE":"FALSE"},camelcase:function(o){return o?"True":"False"}},defaultStyle:"lowercase"}),xt}var Ct,Ii;function er(){if(Ii)return Ct;Ii=1;let i=dn(),e=oe();function n(l){return l>=48&&l<=57||l>=65&&l<=70||l>=97&&l<=102}function r(l){return l>=48&&l<=55}function o(l){return l>=48&&l<=57}function s(l){if(l===null)return!1;let p=l.length,m=0,h=!1;if(!p)return!1;let $=l[m];if(($==="-"||$==="+")&&($=l[++m]),$==="0"){if(m+1===p)return!0;if($=l[++m],$==="b"){for(m++;m<p;m++){if($=l[m],$!=="0"&&$!=="1")return!1;h=!0}return h&&isFinite(u(l))}if($==="x"){for(m++;m<p;m++){if(!n(l.charCodeAt(m)))return!1;h=!0}return h&&isFinite(u(l))}if($==="o"){for(m++;m<p;m++){if(!r(l.charCodeAt(m)))return!1;h=!0}return h&&isFinite(u(l))}}for(;m<p;m++){if(!o(l.charCodeAt(m)))return!1;h=!0}return h?isFinite(u(l)):!1}function u(l){let p=l,m=1,h=p[0];if((h==="-"||h==="+")&&(h==="-"&&(m=-1),p=p.slice(1),h=p[0]),p==="0")return 0;if(h==="0"){if(p[1]==="b")return m*parseInt(p.slice(2),2);if(p[1]==="x")return m*parseInt(p.slice(2),16);if(p[1]==="o")return m*parseInt(p.slice(2),8)}return m*parseInt(p,10)}function a(l){return u(l)}function d(l){return Object.prototype.toString.call(l)==="[object Number]"&&l%1===0&&!i.isNegativeZero(l)}return Ct=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:s,construct:a,predicate:d,represent:{binary:function(l){return l>=0?"0b"+l.toString(2):"-0b"+l.toString(2).slice(1)},octal:function(l){return l>=0?"0o"+l.toString(8):"-0o"+l.toString(8).slice(1)},decimal:function(l){return l.toString(10)},hexadecimal:function(l){return l>=0?"0x"+l.toString(16).toUpperCase():"-0x"+l.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ct}var Ot,Hi;function nr(){if(Hi)return Ot;Hi=1;let i=dn(),e=oe(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function o(l){return l===null||!n.test(l)?!1:isFinite(parseFloat(l,10))?!0:r.test(l)}function s(l){let p=l.toLowerCase(),m=p[0]==="-"?-1:1;return"+-".indexOf(p[0])>=0&&(p=p.slice(1)),p===".inf"?m===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:p===".nan"?NaN:m*parseFloat(p,10)}let u=/^[-+]?[0-9]+e/;function a(l,p){if(isNaN(l))switch(p){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===l)switch(p){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===l)switch(p){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(l))return"-0.0";let m=l.toString(10);return u.test(m)?m.replace("e",".e"):m}function d(l){return Object.prototype.toString.call(l)==="[object Number]"&&(l%1!==0||i.isNegativeZero(l))}return Ot=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:o,construct:s,predicate:d,represent:a,defaultStyle:"lowercase"}),Ot}var Tt,Pi;function tr(){return Pi||(Pi=1,Tt=Xi().extend({implicit:[Qi(),Zi(),er(),nr()]})),Tt}var Rt,Mi;function ir(){return Mi||(Mi=1,Rt=tr()),Rt}var Nt,Fi;function rr(){if(Fi)return Nt;Fi=1;let i=oe(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(u){return u===null?!1:e.exec(u)!==null||n.exec(u)!==null}function o(u){let a=0,d=null,l=e.exec(u);if(l===null&&(l=n.exec(u)),l===null)throw new Error("Date resolve error");let p=+l[1],m=+l[2]-1,h=+l[3];if(!l[4])return new Date(Date.UTC(p,m,h));let $=+l[4],E=+l[5],k=+l[6];if(l[7]){for(a=l[7].slice(0,3);a.length<3;)a+="0";a=+a}if(l[9]){let M=+l[10],H=+(l[11]||0);d=(M*60+H)*6e4,l[9]==="-"&&(d=-d)}let x=new Date(Date.UTC(p,m,h,$,E,k,a));return d&&x.setTime(x.getTime()-d),x}function s(u){return u.toISOString()}return Nt=new i("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:o,instanceOf:Date,represent:s}),Nt}var It,Di;function or(){if(Di)return It;Di=1;let i=oe();function e(n){return n==="<<"||n===null}return It=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),It}var Ht,ji;function sr(){if(ji)return Ht;ji=1;let i=oe(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
44
|
+
\r`;function n(u){if(u===null)return!1;let a=0,d=u.length,l=e;for(let p=0;p<d;p++){let m=l.indexOf(u.charAt(p));if(!(m>64)){if(m<0)return!1;a+=6}}return a%8===0}function r(u){let a=u.replace(/[\r\n=]/g,""),d=a.length,l=e,p=0,m=[];for(let $=0;$<d;$++)$%4===0&&$&&(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)),p=p<<6|l.indexOf(a.charAt($));let h=d%4*6;return h===0?(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)):h===18?(m.push(p>>10&255),m.push(p>>2&255)):h===12&&m.push(p>>4&255),new Uint8Array(m)}function o(u){let a="",d=0,l=u.length,p=e;for(let h=0;h<l;h++)h%3===0&&h&&(a+=p[d>>18&63],a+=p[d>>12&63],a+=p[d>>6&63],a+=p[d&63]),d=(d<<8)+u[h];let m=l%3;return m===0?(a+=p[d>>18&63],a+=p[d>>12&63],a+=p[d>>6&63],a+=p[d&63]):m===2?(a+=p[d>>10&63],a+=p[d>>4&63],a+=p[d<<2&63],a+=p[64]):m===1&&(a+=p[d>>2&63],a+=p[d<<4&63],a+=p[64],a+=p[64]),a}function s(u){return Object.prototype.toString.call(u)==="[object Uint8Array]"}return Ht=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:s,represent:o}),Ht}var Pt,Li;function ar(){if(Li)return Pt;Li=1;let i=oe(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(s){if(s===null)return!0;let u=[],a=s;for(let d=0,l=a.length;d<l;d+=1){let p=a[d],m=!1;if(n.call(p)!=="[object Object]")return!1;let h;for(h in p)if(e.call(p,h))if(!m)m=!0;else return!1;if(!m)return!1;if(u.indexOf(h)===-1)u.push(h);else return!1}return!0}function o(s){return s!==null?s:[]}return Pt=new i("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:o}),Pt}var Mt,qi;function lr(){if(qi)return Mt;qi=1;let i=oe(),e=Object.prototype.toString;function n(o){if(o===null)return!0;let s=o,u=new Array(s.length);for(let a=0,d=s.length;a<d;a+=1){let l=s[a];if(e.call(l)!=="[object Object]")return!1;let p=Object.keys(l);if(p.length!==1)return!1;u[a]=[p[0],l[p[0]]]}return!0}function r(o){if(o===null)return[];let s=o,u=new Array(s.length);for(let a=0,d=s.length;a<d;a+=1){let l=s[a],p=Object.keys(l);u[a]=[p[0],l[p[0]]]}return u}return Mt=new i("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:r}),Mt}var Ft,Ui;function cr(){if(Ui)return Ft;Ui=1;let i=oe(),e=Object.prototype.hasOwnProperty;function n(o){if(o===null)return!0;let s=o;for(let u in s)if(e.call(s,u)&&s[u]!==null)return!1;return!0}function r(o){return o!==null?o:{}}return Ft=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:r}),Ft}var Dt,Bi;function Lt(){return Bi||(Bi=1,Dt=ir().extend({implicit:[rr(),or()],explicit:[sr(),ar(),lr(),cr()]})),Dt}var Gi;function So(){if(Gi)return Ln;Gi=1;let i=dn(),e=pn(),n=Eo(),r=Lt(),o=Object.prototype.hasOwnProperty,s=1,u=2,a=3,d=4,l=1,p=2,m=3,h=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,$=/[\x85\u2028\u2029]/,E=/[,\[\]{}]/,k=/^(?:!|!!|![0-9A-Za-z-]+!)$/,x=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function M(t){return Object.prototype.toString.call(t)}function H(t){return t===10||t===13}function F(t){return t===9||t===32}function L(t){return t===9||t===32||t===10||t===13}function Z(t){return t===44||t===91||t===93||t===123||t===125}function re(t){if(t>=48&&t<=57)return t-48;let f=t|32;return f>=97&&f<=102?f-97+10:-1}function K(t){return t===120?2:t===117?4:t===85?8:0}function pe(t){return t>=48&&t<=57?t-48:-1}function fe(t){switch(t){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
45
|
+
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function j(t){return t<=65535?String.fromCharCode(t):String.fromCharCode((t-65536>>10)+55296,(t-65536&1023)+56320)}function ae(t,f,y){f==="__proto__"?Object.defineProperty(t,f,{configurable:!0,enumerable:!0,writable:!0,value:y}):t[f]=y}let Re=new Array(256),te=new Array(256);for(let t=0;t<256;t++)Re[t]=fe(t)?1:0,te[t]=fe(t);function ee(t,f){this.input=t,this.filename=f.filename||null,this.schema=f.schema||r,this.onWarning=f.onWarning||null,this.legacy=f.legacy||!1,this.json=f.json||!1,this.listener=f.listener||null,this.maxDepth=typeof f.maxDepth=="number"?f.maxDepth:100,this.maxTotalMergeKeys=typeof f.maxTotalMergeKeys=="number"?f.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function gn(t,f){let y={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return y.snippet=n(y),new e(f,y)}function N(t,f){throw gn(t,f)}function Fe(t,f){t.onWarning&&t.onWarning.call(null,gn(t,f))}function me(t,f,y){let A=t.anchorMapTransactions;if(A.length!==0){let b=A[A.length-1];o.call(b,f)||(b[f]={existed:o.call(t.anchorMap,f),value:t.anchorMap[f]})}t.anchorMap[f]=y}function Bn(t){t.anchorMapTransactions.push(Object.create(null))}function Ne(t){let f=t.anchorMapTransactions.pop(),y=t.anchorMapTransactions;if(y.length===0)return;let A=y[y.length-1],b=Object.keys(f);for(let O=0,c=b.length;O<c;O+=1){let g=b[O];o.call(A,g)||(A[g]=f[g])}}function Gn(t){let f=t.anchorMapTransactions.pop(),y=Object.keys(f);for(let A=y.length-1;A>=0;A-=1){let b=f[y[A]];b.existed?t.anchorMap[y[A]]=b.value:delete t.anchorMap[y[A]]}}function ze(t){return{position:t.position,line:t.line,lineStart:t.lineStart,lineIndent:t.lineIndent,firstTabInLine:t.firstTabInLine,tag:t.tag,anchor:t.anchor,kind:t.kind,result:t.result}}function De(t,f){t.position=f.position,t.line=f.line,t.lineStart=f.lineStart,t.lineIndent=f.lineIndent,t.firstTabInLine=f.firstTabInLine,t.tag=f.tag,t.anchor=f.anchor,t.kind=f.kind,t.result=f.result}let bn={YAML:function(f,y,A){f.version!==null&&N(f,"duplication of %YAML directive"),A.length!==1&&N(f,"YAML directive accepts exactly one argument");let b=/^([0-9]+)\.([0-9]+)$/.exec(A[0]);b===null&&N(f,"ill-formed argument of the YAML directive");let O=parseInt(b[1],10),c=parseInt(b[2],10);O!==1&&N(f,"unacceptable YAML version of the document"),f.version=A[0],f.checkLineBreaks=c<2,c!==1&&c!==2&&Fe(f,"unsupported YAML version of the document")},TAG:function(f,y,A){let b;A.length!==2&&N(f,"TAG directive accepts exactly two arguments");let O=A[0];b=A[1],k.test(O)||N(f,"ill-formed tag handle (first argument) of the TAG directive"),o.call(f.tagMap,O)&&N(f,'there is a previously declared suffix for "'+O+'" tag handle'),x.test(b)||N(f,"ill-formed tag prefix (second argument) of the TAG directive");try{b=decodeURIComponent(b)}catch{N(f,"tag prefix is malformed: "+b)}f.tagMap[O]=b}};function le(t,f,y,A){if(f<y){let b=t.input.slice(f,y);if(A)for(let O=0,c=b.length;O<c;O+=1){let g=b.charCodeAt(O);g===9||g>=32&&g<=1114111||N(t,"expected valid JSON character")}else h.test(b)&&N(t,"the stream contains non-printable characters");t.result+=b}}function $e(t,f,y,A){i.isObject(y)||N(t,"cannot merge mappings; the provided source object is unacceptable");let b=Object.keys(y);for(let O=0,c=b.length;O<c;O+=1){let g=b[O];t.maxTotalMergeKeys!==-1&&++t.totalMergeKeys>t.maxTotalMergeKeys&&N(t,"merge keys exceeded maxTotalMergeKeys ("+t.maxTotalMergeKeys+")"),o.call(f,g)||(ae(f,g,y[g]),A[g]=!0)}}function ge(t,f,y,A,b,O,c,g,v){if(Array.isArray(b)){b=Array.prototype.slice.call(b);for(let w=0,_=b.length;w<_;w+=1)Array.isArray(b[w])&&N(t,"nested arrays are not supported inside keys"),typeof b=="object"&&M(b[w])==="[object Object]"&&(b[w]="[object Object]")}if(typeof b=="object"&&M(b)==="[object Object]"&&(b="[object Object]"),b=String(b),f===null&&(f={}),A==="tag:yaml.org,2002:merge")if(Array.isArray(O))for(let w=0,_=O.length;w<_;w+=1)$e(t,f,O[w],y);else $e(t,f,O,y);else!t.json&&!o.call(y,b)&&o.call(f,b)&&(t.line=c||t.line,t.lineStart=g||t.lineStart,t.position=v||t.position,N(t,"duplicated mapping key")),ae(f,b,O),delete y[b];return f}function je(t){let f=t.input.charCodeAt(t.position);f===10?t.position++:f===13?(t.position++,t.input.charCodeAt(t.position)===10&&t.position++):N(t,"a line break is expected"),t.line+=1,t.lineStart=t.position,t.firstTabInLine=-1}function z(t,f,y){let A=0,b=t.input.charCodeAt(t.position);for(;b!==0;){for(;F(b);)b===9&&t.firstTabInLine===-1&&(t.firstTabInLine=t.position),b=t.input.charCodeAt(++t.position);if(f&&b===35)do b=t.input.charCodeAt(++t.position);while(b!==10&&b!==13&&b!==0);if(H(b))for(je(t),b=t.input.charCodeAt(t.position),A++,t.lineIndent=0;b===32;)t.lineIndent++,b=t.input.charCodeAt(++t.position);else break}return y!==-1&&A!==0&&t.lineIndent<y&&Fe(t,"deficient indentation"),A}function Le(t){let f=t.position,y=t.input.charCodeAt(f);return!!((y===45||y===46)&&y===t.input.charCodeAt(f+1)&&y===t.input.charCodeAt(f+2)&&(f+=3,y=t.input.charCodeAt(f),y===0||L(y)))}function be(t,f){f===1?t.result+=" ":f>1&&(t.result+=i.repeat(`
|
|
46
|
+
`,f-1))}function yn(t,f,y){let A,b,O,c,g,v,w=t.kind,_=t.result,C=t.input.charCodeAt(t.position);if(L(C)||Z(C)||C===35||C===38||C===42||C===33||C===124||C===62||C===39||C===34||C===37||C===64||C===96)return!1;if(C===63||C===45){let S=t.input.charCodeAt(t.position+1);if(L(S)||y&&Z(S))return!1}for(t.kind="scalar",t.result="",A=b=t.position,O=!1;C!==0;){if(C===58){let S=t.input.charCodeAt(t.position+1);if(L(S)||y&&Z(S))break}else if(C===35){let S=t.input.charCodeAt(t.position-1);if(L(S))break}else{if(t.position===t.lineStart&&Le(t)||y&&Z(C))break;if(H(C))if(c=t.line,g=t.lineStart,v=t.lineIndent,z(t,!1,-1),t.lineIndent>=f){O=!0,C=t.input.charCodeAt(t.position);continue}else{t.position=b,t.line=c,t.lineStart=g,t.lineIndent=v;break}}O&&(le(t,A,b,!1),be(t,t.line-c),A=b=t.position,O=!1),F(C)||(b=t.position+1),C=t.input.charCodeAt(++t.position)}return le(t,A,b,!1),t.result?!0:(t.kind=w,t.result=_,!1)}function wn(t,f){let y,A,b=t.input.charCodeAt(t.position);if(b!==39)return!1;for(t.kind="scalar",t.result="",t.position++,y=A=t.position;(b=t.input.charCodeAt(t.position))!==0;)if(b===39)if(le(t,y,t.position,!0),b=t.input.charCodeAt(++t.position),b===39)y=t.position,t.position++,A=t.position;else return!0;else H(b)?(le(t,y,A,!0),be(t,z(t,!1,f)),y=A=t.position):t.position===t.lineStart&&Le(t)?N(t,"unexpected end of the document within a single quoted scalar"):(t.position++,F(b)||(A=t.position));N(t,"unexpected end of the stream within a single quoted scalar")}function Xe(t,f){let y,A,b,O=t.input.charCodeAt(t.position);if(O!==34)return!1;for(t.kind="scalar",t.result="",t.position++,y=A=t.position;(O=t.input.charCodeAt(t.position))!==0;){if(O===34)return le(t,y,t.position,!0),t.position++,!0;if(O===92){if(le(t,y,t.position,!0),O=t.input.charCodeAt(++t.position),H(O))z(t,!1,f);else if(O<256&&Re[O])t.result+=te[O],t.position++;else if((b=K(O))>0){let c=b,g=0;for(;c>0;c--)O=t.input.charCodeAt(++t.position),(b=re(O))>=0?g=(g<<4)+b:N(t,"expected hexadecimal character");t.result+=j(g),t.position++}else N(t,"unknown escape sequence");y=A=t.position}else H(O)?(le(t,y,A,!0),be(t,z(t,!1,f)),y=A=t.position):t.position===t.lineStart&&Le(t)?N(t,"unexpected end of the document within a double quoted scalar"):(t.position++,F(O)||(A=t.position))}N(t,"unexpected end of the stream within a double quoted scalar")}function _n(t,f){let y=!0,A,b,O,c=t.tag,g,v=t.anchor,w,_,C,S,R=Object.create(null),T,P,D,q=t.input.charCodeAt(t.position);if(q===91)w=93,S=!1,g=[];else if(q===123)w=125,S=!0,g={};else return!1;for(t.anchor!==null&&me(t,t.anchor,g),q=t.input.charCodeAt(++t.position);q!==0;){if(z(t,!0,f),q=t.input.charCodeAt(t.position),q===w)return t.position++,t.tag=c,t.anchor=v,t.kind=S?"mapping":"sequence",t.result=g,!0;if(y?q===44&&N(t,"expected the node content, but found ','"):N(t,"missed comma between flow collection entries"),P=T=D=null,_=C=!1,q===63){let W=t.input.charCodeAt(t.position+1);L(W)&&(_=C=!0,t.position++,z(t,!0,f))}A=t.line,b=t.lineStart,O=t.position,we(t,f,s,!1,!0),P=t.tag,T=t.result,z(t,!0,f),q=t.input.charCodeAt(t.position),(C||t.line===A)&&q===58&&(_=!0,q=t.input.charCodeAt(++t.position),z(t,!0,f),we(t,f,s,!1,!0),D=t.result),S?ge(t,g,R,P,T,D,A,b,O):_?g.push(ge(t,null,R,P,T,D,A,b,O)):g.push(T),z(t,!0,f),q=t.input.charCodeAt(t.position),q===44?(y=!0,q=t.input.charCodeAt(++t.position)):y=!1}N(t,"unexpected end of the stream within a flow collection")}function An(t,f){let y,A=l,b=!1,O=!1,c=f,g=0,v=!1,w,_=t.input.charCodeAt(t.position);if(_===124)y=!1;else if(_===62)y=!0;else return!1;for(t.kind="scalar",t.result="";_!==0;)if(_=t.input.charCodeAt(++t.position),_===43||_===45)l===A?A=_===43?m:p:N(t,"repeat of a chomping mode identifier");else if((w=pe(_))>=0)w===0?N(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):O?N(t,"repeat of an indentation width identifier"):(c=f+w-1,O=!0);else break;if(F(_)){do _=t.input.charCodeAt(++t.position);while(F(_));if(_===35)do _=t.input.charCodeAt(++t.position);while(!H(_)&&_!==0)}for(;_!==0;){for(je(t),t.lineIndent=0,_=t.input.charCodeAt(t.position);(!O||t.lineIndent<c)&&_===32;)t.lineIndent++,_=t.input.charCodeAt(++t.position);if(!O&&t.lineIndent>c&&(c=t.lineIndent),H(_)){g++;continue}if(!O&&c===0&&N(t,"missing indentation for block scalar"),t.lineIndent<c){A===m?t.result+=i.repeat(`
|
|
47
|
+
`,b?1+g:g):A===l&&b&&(t.result+=`
|
|
48
|
+
`);break}y?F(_)?(v=!0,t.result+=i.repeat(`
|
|
49
|
+
`,b?1+g:g)):v?(v=!1,t.result+=i.repeat(`
|
|
50
|
+
`,g+1)):g===0?b&&(t.result+=" "):t.result+=i.repeat(`
|
|
51
|
+
`,g):t.result+=i.repeat(`
|
|
52
|
+
`,b?1+g:g),b=!0,O=!0,g=0;let C=t.position;for(;!H(_)&&_!==0;)_=t.input.charCodeAt(++t.position);le(t,C,t.position,!1)}return!0}function ye(t,f){let y=t.tag,A=t.anchor,b=[],O=!1;if(t.firstTabInLine!==-1)return!1;t.anchor!==null&&me(t,t.anchor,b);let c=t.input.charCodeAt(t.position);for(;c!==0&&(t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,N(t,"tab characters must not be used in indentation")),c===45);){let g=t.input.charCodeAt(t.position+1);if(!L(g))break;if(O=!0,t.position++,z(t,!0,-1)&&t.lineIndent<=f){b.push(null),c=t.input.charCodeAt(t.position);continue}let v=t.line;if(we(t,f,a,!1,!0),b.push(t.result),z(t,!0,-1),c=t.input.charCodeAt(t.position),(t.line===v||t.lineIndent>f)&&c!==0)N(t,"bad indentation of a sequence entry");else if(t.lineIndent<f)break}return O?(t.tag=y,t.anchor=A,t.kind="sequence",t.result=b,!0):!1}function kn(t,f,y){let A,b,O,c,g=t.tag,v=t.anchor,w={},_=Object.create(null),C=null,S=null,R=null,T=!1,P=!1;if(t.firstTabInLine!==-1)return!1;t.anchor!==null&&me(t,t.anchor,w);let D=t.input.charCodeAt(t.position);for(;D!==0;){!T&&t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,N(t,"tab characters must not be used in indentation"));let q=t.input.charCodeAt(t.position+1),W=t.line;if((D===63||D===58)&&L(q))D===63?(T&&(ge(t,w,_,C,S,null,b,O,c),C=S=R=null),P=!0,T=!0,A=!0):T?(T=!1,A=!0):N(t,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),t.position+=1,D=q;else{if(b=t.line,O=t.lineStart,c=t.position,!we(t,y,u,!1,!0))break;if(t.line===W){for(D=t.input.charCodeAt(t.position);F(D);)D=t.input.charCodeAt(++t.position);if(D===58)D=t.input.charCodeAt(++t.position),L(D)||N(t,"a whitespace character is expected after the key-value separator within a block mapping"),T&&(ge(t,w,_,C,S,null,b,O,c),C=S=R=null),P=!0,T=!1,A=!1,C=t.tag,S=t.result;else if(P)N(t,"can not read an implicit mapping pair; a colon is missed");else return t.tag=g,t.anchor=v,!0}else if(P)N(t,"can not read a block mapping entry; a multiline key may not be an implicit key");else return t.tag=g,t.anchor=v,!0}if((t.line===W||t.lineIndent>f)&&(T&&(b=t.line,O=t.lineStart,c=t.position),we(t,f,d,!0,A)&&(T?S=t.result:R=t.result),T||(ge(t,w,_,C,S,R,b,O,c),C=S=R=null),z(t,!0,-1),D=t.input.charCodeAt(t.position)),(t.line===W||t.lineIndent>f)&&D!==0)N(t,"bad indentation of a mapping entry");else if(t.lineIndent<f)break}return T&&ge(t,w,_,C,S,null,b,O,c),P&&(t.tag=g,t.anchor=v,t.kind="mapping",t.result=w),P}function Vn(t){let f=!1,y=!1,A,b,O=t.input.charCodeAt(t.position);if(O!==33)return!1;t.tag!==null&&N(t,"duplication of a tag property"),O=t.input.charCodeAt(++t.position),O===60?(f=!0,O=t.input.charCodeAt(++t.position)):O===33?(y=!0,A="!!",O=t.input.charCodeAt(++t.position)):A="!";let c=t.position;if(f){do O=t.input.charCodeAt(++t.position);while(O!==0&&O!==62);t.position<t.length?(b=t.input.slice(c,t.position),O=t.input.charCodeAt(++t.position)):N(t,"unexpected end of the stream within a verbatim tag")}else{for(;O!==0&&!L(O);)O===33&&(y?N(t,"tag suffix cannot contain exclamation marks"):(A=t.input.slice(c-1,t.position+1),k.test(A)||N(t,"named tag handle cannot contain such characters"),y=!0,c=t.position+1)),O=t.input.charCodeAt(++t.position);b=t.input.slice(c,t.position),E.test(b)&&N(t,"tag suffix cannot contain flow indicator characters")}b&&!x.test(b)&&N(t,"tag name cannot contain such characters: "+b);try{b=decodeURIComponent(b)}catch{N(t,"tag name is malformed: "+b)}return f?t.tag=b:o.call(t.tagMap,A)?t.tag=t.tagMap[A]+b:A==="!"?t.tag="!"+b:A==="!!"?t.tag="tag:yaml.org,2002:"+b:N(t,'undeclared tag handle "'+A+'"'),!0}function En(t){let f=t.input.charCodeAt(t.position);if(f!==38)return!1;t.anchor!==null&&N(t,"duplication of an anchor property"),f=t.input.charCodeAt(++t.position);let y=t.position;for(;f!==0&&!L(f)&&!Z(f);)f=t.input.charCodeAt(++t.position);return t.position===y&&N(t,"name of an anchor node must contain at least one character"),t.anchor=t.input.slice(y,t.position),!0}function Sn(t){let f=t.input.charCodeAt(t.position);if(f!==42)return!1;f=t.input.charCodeAt(++t.position);let y=t.position;for(;f!==0&&!L(f)&&!Z(f);)f=t.input.charCodeAt(++t.position);t.position===y&&N(t,"name of an alias node must contain at least one character");let A=t.input.slice(y,t.position);return o.call(t.anchorMap,A)||N(t,'unidentified alias "'+A+'"'),t.result=t.anchorMap[A],z(t,!0,-1),!0}function Wn(t,f,y,A){let b=ze(t);return Bn(t),De(t,f),t.tag=null,t.anchor=null,t.kind=null,t.result=null,kn(t,y,A)&&t.kind==="mapping"?(Ne(t),!0):(Gn(t),De(t,b),!1)}function we(t,f,y,A,b){let O,c,g=1,v=!1,w=!1,_=null,C,S,R;t.depth>=t.maxDepth&&N(t,"nesting exceeded maxDepth ("+t.maxDepth+")"),t.depth+=1,t.listener!==null&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null;let T=O=c=d===y||a===y;if(A&&z(t,!0,-1)&&(v=!0,t.lineIndent>f?g=1:t.lineIndent===f?g=0:t.lineIndent<f&&(g=-1)),g===1)for(;;){let P=t.input.charCodeAt(t.position),D=ze(t);if(v&&(P===33&&t.tag!==null||P===38&&t.anchor!==null)||!Vn(t)&&!En(t))break;_===null&&(_=D),z(t,!0,-1)?(v=!0,c=T,t.lineIndent>f?g=1:t.lineIndent===f?g=0:t.lineIndent<f&&(g=-1)):c=!1}if(c&&(c=v||b),g===1||d===y)if(s===y||u===y?S=f:S=f+1,R=t.position-t.lineStart,g===1)if(c&&(ye(t,R)||kn(t,R,S))||_n(t,S))w=!0;else{let P=t.input.charCodeAt(t.position);_!==null&&T&&!c&&P!==124&&P!==62&&Wn(t,_,_.position-_.lineStart,S)||O&&An(t,S)||wn(t,S)||Xe(t,S)?w=!0:Sn(t)?(w=!0,(t.tag!==null||t.anchor!==null)&&N(t,"alias node should not have any properties")):yn(t,S,s===y)&&(w=!0,t.tag===null&&(t.tag="?")),t.anchor!==null&&me(t,t.anchor,t.result)}else g===0&&(w=c&&ye(t,R));if(t.tag===null)t.anchor!==null&&me(t,t.anchor,t.result);else if(t.tag==="?"){t.result!==null&&t.kind!=="scalar"&&N(t,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+t.kind+'"');for(let P=0,D=t.implicitTypes.length;P<D;P+=1)if(C=t.implicitTypes[P],C.resolve(t.result)){t.result=C.construct(t.result),t.tag=C.tag,t.anchor!==null&&me(t,t.anchor,t.result);break}}else if(t.tag!=="!"){if(o.call(t.typeMap[t.kind||"fallback"],t.tag))C=t.typeMap[t.kind||"fallback"][t.tag];else{C=null;let P=t.typeMap.multi[t.kind||"fallback"];for(let D=0,q=P.length;D<q;D+=1)if(t.tag.slice(0,P[D].tag.length)===P[D].tag){C=P[D];break}}C||N(t,"unknown tag !<"+t.tag+">"),t.result!==null&&C.kind!==t.kind&&N(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+C.kind+'", not "'+t.kind+'"'),C.resolve(t.result,t.tag)?(t.result=C.construct(t.result,t.tag),t.anchor!==null&&me(t,t.anchor,t.result)):N(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return t.listener!==null&&t.listener("close",t),t.depth-=1,t.tag!==null||t.anchor!==null||w}function Yn(t){let f=t.position,y=!1,A;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);(A=t.input.charCodeAt(t.position))!==0&&(z(t,!0,-1),A=t.input.charCodeAt(t.position),!(t.lineIndent>0||A!==37));){y=!0,A=t.input.charCodeAt(++t.position);let b=t.position;for(;A!==0&&!L(A);)A=t.input.charCodeAt(++t.position);let O=t.input.slice(b,t.position),c=[];for(O.length<1&&N(t,"directive name must not be less than one character in length");A!==0;){for(;F(A);)A=t.input.charCodeAt(++t.position);if(A===35){do A=t.input.charCodeAt(++t.position);while(A!==0&&!H(A));break}if(H(A))break;for(b=t.position;A!==0&&!L(A);)A=t.input.charCodeAt(++t.position);c.push(t.input.slice(b,t.position))}A!==0&&je(t),o.call(bn,O)?bn[O](t,O,c):Fe(t,'unknown document directive "'+O+'"')}if(z(t,!0,-1),t.lineIndent===0&&t.input.charCodeAt(t.position)===45&&t.input.charCodeAt(t.position+1)===45&&t.input.charCodeAt(t.position+2)===45?(t.position+=3,z(t,!0,-1)):y&&N(t,"directives end mark is expected"),we(t,t.lineIndent-1,d,!1,!0),z(t,!0,-1),t.checkLineBreaks&&$.test(t.input.slice(f,t.position))&&Fe(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Le(t)){t.input.charCodeAt(t.position)===46&&(t.position+=3,z(t,!0,-1));return}t.position<t.length-1&&N(t,"end of the stream or a document separator is expected")}function $n(t,f){t=String(t),f=f||{},t.length!==0&&(t.charCodeAt(t.length-1)!==10&&t.charCodeAt(t.length-1)!==13&&(t+=`
|
|
53
|
+
`),t.charCodeAt(0)===65279&&(t=t.slice(1)));let y=new ee(t,f),A=t.indexOf("\0");for(A!==-1&&(y.position=A,N(y,"null byte is not allowed in input")),y.input+="\0";y.input.charCodeAt(y.position)===32;)y.lineIndent+=1,y.position+=1;for(;y.position<y.length-1;)Yn(y);return y.documents}function vn(t,f,y){f!==null&&typeof f=="object"&&typeof y>"u"&&(y=f,f=null);let A=$n(t,y);if(typeof f!="function")return A;for(let b=0,O=A.length;b<O;b+=1)f(A[b])}function Kn(t,f){let y=$n(t,f);if(y.length!==0){if(y.length===1)return y[0];throw new e("expected a single document in the stream, but found more")}}return Ln.loadAll=vn,Ln.load=Kn,Ln}var jt={},Vi;function $o(){if(Vi)return jt;Vi=1;let i=dn(),e=pn(),n=Lt(),r=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=65279,u=9,a=10,d=13,l=32,p=33,m=34,h=35,$=37,E=38,k=39,x=42,M=44,H=45,F=58,L=61,Z=62,re=63,K=64,pe=91,fe=93,j=96,ae=123,Re=124,te=125,ee={};ee[0]="\\0",ee[7]="\\a",ee[8]="\\b",ee[9]="\\t",ee[10]="\\n",ee[11]="\\v",ee[12]="\\f",ee[13]="\\r",ee[27]="\\e",ee[34]='\\"',ee[92]="\\\\",ee[133]="\\N",ee[160]="\\_",ee[8232]="\\L",ee[8233]="\\P";let gn=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],N=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Fe(c,g){if(g===null)return{};let v={},w=Object.keys(g);for(let _=0,C=w.length;_<C;_+=1){let S=w[_],R=String(g[S]);S.slice(0,2)==="!!"&&(S="tag:yaml.org,2002:"+S.slice(2));let T=c.compiledTypeMap.fallback[S];T&&o.call(T.styleAliases,R)&&(R=T.styleAliases[R]),v[S]=R}return v}function me(c){let g,v,w=c.toString(16).toUpperCase();if(c<=255)g="x",v=2;else if(c<=65535)g="u",v=4;else if(c<=4294967295)g="U",v=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+g+i.repeat("0",v-w.length)+w}let Bn=1,Ne=2;function Gn(c){this.schema=c.schema||n,this.indent=Math.max(1,c.indent||2),this.noArrayIndent=c.noArrayIndent||!1,this.skipInvalid=c.skipInvalid||!1,this.flowLevel=i.isNothing(c.flowLevel)?-1:c.flowLevel,this.styleMap=Fe(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==='"'?Ne:Bn,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 ze(c,g){let v=i.repeat(" ",g),w=0,_="",C=c.length;for(;w<C;){let S,R=c.indexOf(`
|
|
54
|
+
`,w);R===-1?(S=c.slice(w),w=C):(S=c.slice(w,R+1),w=R+1),S.length&&S!==`
|
|
55
|
+
`&&(_+=v),_+=S}return _}function De(c,g){return`
|
|
56
|
+
`+i.repeat(" ",c.indent*g)}function bn(c,g){for(let v=0,w=c.implicitTypes.length;v<w;v+=1)if(c.implicitTypes[v].resolve(g))return!0;return!1}function le(c){return c===l||c===u}function $e(c){return c>=32&&c<=126||c>=161&&c<=55295&&c!==8232&&c!==8233||c>=57344&&c<=65533&&c!==s||c>=65536&&c<=1114111}function ge(c){return $e(c)&&c!==s&&c!==d&&c!==a}function je(c,g,v){let w=ge(c),_=w&&!le(c);return(v?w:w&&c!==M&&c!==pe&&c!==fe&&c!==ae&&c!==te)&&c!==h&&!(g===F&&!_)||ge(g)&&!le(g)&&c===h||g===F&&_}function z(c){return $e(c)&&c!==s&&!le(c)&&c!==H&&c!==re&&c!==F&&c!==M&&c!==pe&&c!==fe&&c!==ae&&c!==te&&c!==h&&c!==E&&c!==x&&c!==p&&c!==Re&&c!==L&&c!==Z&&c!==k&&c!==m&&c!==$&&c!==K&&c!==j}function Le(c){return!le(c)&&c!==F}function be(c,g){let v=c.charCodeAt(g),w;return v>=55296&&v<=56319&&g+1<c.length&&(w=c.charCodeAt(g+1),w>=56320&&w<=57343)?(v-55296)*1024+w-56320+65536:v}function yn(c){return/^\n* /.test(c)}let wn=1,Xe=2,_n=3,An=4,ye=5;function kn(c,g,v,w,_,C,S,R){let T,P=0,D=null,q=!1,W=!1,Gt=w!==-1,Qe=-1,Ze=z(be(c,0))&&Le(be(c,c.length-1));if(g||S)for(T=0;T<c.length;P>=65536?T+=2:T++){if(P=be(c,T),!$e(P))return ye;Ze=Ze&&je(P,D,R),D=P}else{for(T=0;T<c.length;P>=65536?T+=2:T++){if(P=be(c,T),P===a)q=!0,Gt&&(W=W||T-Qe-1>w&&c[Qe+1]!==" ",Qe=T);else if(!$e(P))return ye;Ze=Ze&&je(P,D,R),D=P}W=W||Gt&&T-Qe-1>w&&c[Qe+1]!==" "}return!q&&!W?Ze&&!S&&!_(c)?wn:C===Ne?ye:Xe:v>9&&yn(c)?ye:S?C===Ne?ye:Xe:W?An:_n}function Vn(c,g,v,w,_){c.dump=(function(){if(g.length===0)return c.quotingType===Ne?'""':"''";if(!c.noCompatMode&&(gn.indexOf(g)!==-1||N.test(g)))return c.quotingType===Ne?'"'+g+'"':"'"+g+"'";let C=c.indent*Math.max(1,v),S=c.lineWidth===-1?-1:Math.max(Math.min(c.lineWidth,40),c.lineWidth-C),R=w||c.flowLevel>-1&&v>=c.flowLevel;function T(P){return bn(c,P)}switch(kn(g,R,c.indent,S,T,c.quotingType,c.forceQuotes&&!w,_)){case wn:return g;case Xe:return"'"+g.replace(/'/g,"''")+"'";case _n:return"|"+En(g,c.indent)+Sn(ze(g,C));case An:return">"+En(g,c.indent)+Sn(ze(Wn(g,S),C));case ye:return'"'+Yn(g)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function En(c,g){let v=yn(c)?String(g):"",w=c[c.length-1]===`
|
|
57
|
+
`,C=w&&(c[c.length-2]===`
|
|
58
|
+
`||c===`
|
|
59
|
+
`)?"+":w?"":"-";return v+C+`
|
|
60
|
+
`}function Sn(c){return c[c.length-1]===`
|
|
61
|
+
`?c.slice(0,-1):c}function Wn(c,g){let v=/(\n+)([^\n]*)/g,w=(function(){let R=c.indexOf(`
|
|
62
|
+
`);return R=R!==-1?R:c.length,v.lastIndex=R,we(c.slice(0,R),g)})(),_=c[0]===`
|
|
63
|
+
`||c[0]===" ",C,S;for(;S=v.exec(c);){let R=S[1],T=S[2];C=T[0]===" ",w+=R+(!_&&!C&&T!==""?`
|
|
64
|
+
`:"")+we(T,g),_=C}return w}function we(c,g){if(c===""||c[0]===" ")return c;let v=/ [^ ]/g,w,_=0,C,S=0,R=0,T="";for(;w=v.exec(c);)R=w.index,R-_>g&&(C=S>_?S:R,T+=`
|
|
65
|
+
`+c.slice(_,C),_=C+1),S=R;return T+=`
|
|
66
|
+
`,c.length-_>g&&S>_?T+=c.slice(_,S)+`
|
|
67
|
+
`+c.slice(S+1):T+=c.slice(_),T.slice(1)}function Yn(c){let g="",v=0;for(let w=0;w<c.length;v>=65536?w+=2:w++){v=be(c,w);let _=ee[v];!_&&$e(v)?(g+=c[w],v>=65536&&(g+=c[w+1])):g+=_||me(v)}return g}function $n(c,g,v){let w="",_=c.tag;for(let C=0,S=v.length;C<S;C+=1){let R=v[C];c.replacer&&(R=c.replacer.call(v,String(C),R)),(y(c,g,R,!1,!1)||typeof R>"u"&&y(c,g,null,!1,!1))&&(w!==""&&(w+=","+(c.condenseFlow?"":" ")),w+=c.dump)}c.tag=_,c.dump="["+w+"]"}function vn(c,g,v,w){let _="",C=c.tag;for(let S=0,R=v.length;S<R;S+=1){let T=v[S];c.replacer&&(T=c.replacer.call(v,String(S),T)),(y(c,g+1,T,!0,!0,!1,!0)||typeof T>"u"&&y(c,g+1,null,!0,!0,!1,!0))&&((!w||_!=="")&&(_+=De(c,g)),c.dump&&a===c.dump.charCodeAt(0)?_+="-":_+="- ",_+=c.dump)}c.tag=C,c.dump=_||"[]"}function Kn(c,g,v){let w="",_=c.tag,C=Object.keys(v);for(let S=0,R=C.length;S<R;S+=1){let T="";w!==""&&(T+=", "),c.condenseFlow&&(T+='"');let P=C[S],D=v[P];c.replacer&&(D=c.replacer.call(v,P,D)),y(c,g,P,!1,!1)&&(c.dump.length>1024&&(T+="? "),T+=c.dump+(c.condenseFlow?'"':"")+":"+(c.condenseFlow?"":" "),y(c,g,D,!1,!1)&&(T+=c.dump,w+=T))}c.tag=_,c.dump="{"+w+"}"}function t(c,g,v,w){let _="",C=c.tag,S=Object.keys(v);if(c.sortKeys===!0)S.sort();else if(typeof c.sortKeys=="function")S.sort(c.sortKeys);else if(c.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let R=0,T=S.length;R<T;R+=1){let P="";(!w||_!=="")&&(P+=De(c,g));let D=S[R],q=v[D];if(c.replacer&&(q=c.replacer.call(v,D,q)),!y(c,g+1,D,!0,!0,!0))continue;let W=c.tag!==null&&c.tag!=="?"||c.dump&&c.dump.length>1024;W&&(c.dump&&a===c.dump.charCodeAt(0)?P+="?":P+="? "),P+=c.dump,W&&(P+=De(c,g)),y(c,g+1,q,!0,W)&&(c.dump&&a===c.dump.charCodeAt(0)?P+=":":P+=": ",P+=c.dump,_+=P)}c.tag=C,c.dump=_||"{}"}function f(c,g,v){let w=v?c.explicitTypes:c.implicitTypes;for(let _=0,C=w.length;_<C;_+=1){let S=w[_];if((S.instanceOf||S.predicate)&&(!S.instanceOf||typeof g=="object"&&g instanceof S.instanceOf)&&(!S.predicate||S.predicate(g))){if(v?S.multi&&S.representName?c.tag=S.representName(g):c.tag=S.tag:c.tag="?",S.represent){let R=c.styleMap[S.tag]||S.defaultStyle,T;if(r.call(S.represent)==="[object Function]")T=S.represent(g,R);else if(o.call(S.represent,R))T=S.represent[R](g,R);else throw new e("!<"+S.tag+'> tag resolver accepts not "'+R+'" style');c.dump=T}return!0}}return!1}function y(c,g,v,w,_,C,S){c.tag=null,c.dump=v,f(c,v,!1)||f(c,v,!0);let R=r.call(c.dump),T=w;w&&(w=c.flowLevel<0||c.flowLevel>g);let P=R==="[object Object]"||R==="[object Array]",D,q;if(P&&(D=c.duplicates.indexOf(v),q=D!==-1),(c.tag!==null&&c.tag!=="?"||q||c.indent!==2&&g>0)&&(_=!1),q&&c.usedDuplicates[D])c.dump="*ref_"+D;else{if(P&&q&&!c.usedDuplicates[D]&&(c.usedDuplicates[D]=!0),R==="[object Object]")w&&Object.keys(c.dump).length!==0?(t(c,g,c.dump,_),q&&(c.dump="&ref_"+D+c.dump)):(Kn(c,g,c.dump),q&&(c.dump="&ref_"+D+" "+c.dump));else if(R==="[object Array]")w&&c.dump.length!==0?(c.noArrayIndent&&!S&&g>0?vn(c,g-1,c.dump,_):vn(c,g,c.dump,_),q&&(c.dump="&ref_"+D+c.dump)):($n(c,g,c.dump),q&&(c.dump="&ref_"+D+" "+c.dump));else if(R==="[object String]")c.tag!=="?"&&Vn(c,c.dump,g,C,T);else{if(R==="[object Undefined]")return!1;if(c.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+R)}if(c.tag!==null&&c.tag!=="?"){let W=encodeURI(c.tag[0]==="!"?c.tag.slice(1):c.tag).replace(/!/g,"%21");c.tag[0]==="!"?W="!"+W:W.slice(0,18)==="tag:yaml.org,2002:"?W="!!"+W.slice(18):W="!<"+W+">",c.dump=W+" "+c.dump}}return!0}function A(c,g){let v=[],w=[];b(c,v,w);let _=w.length;for(let C=0;C<_;C+=1)g.duplicates.push(v[w[C]]);g.usedDuplicates=new Array(_)}function b(c,g,v){if(c!==null&&typeof c=="object"){let w=g.indexOf(c);if(w!==-1)v.indexOf(w)===-1&&v.push(w);else if(g.push(c),Array.isArray(c))for(let _=0,C=c.length;_<C;_+=1)b(c[_],g,v);else{let _=Object.keys(c);for(let C=0,S=_.length;C<S;C+=1)b(c[_[C]],g,v)}}}function O(c,g){g=g||{};let v=new Gn(g);v.noRefs||A(c,v);let w=c;return v.replacer&&(w=v.replacer.call({"":w},"",w)),y(v,0,w,!0,!0)?v.dump+`
|
|
68
|
+
`:""}return jt.dump=O,jt}var Wi;function vo(){if(Wi)return ie;Wi=1;let i=So(),e=$o();function n(r,o){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+o+" instead, which is now safe by default.")}}return ie.Type=oe(),ie.Schema=Yi(),ie.FAILSAFE_SCHEMA=Xi(),ie.JSON_SCHEMA=tr(),ie.CORE_SCHEMA=ir(),ie.DEFAULT_SCHEMA=Lt(),ie.load=i.load,ie.loadAll=i.loadAll,ie.dump=e.dump,ie.YAMLException=pn(),ie.types={binary:sr(),float:nr(),map:zi(),null:Qi(),pairs:lr(),set:cr(),timestamp:rr(),bool:Zi(),int:er(),merge:or(),omap:ar(),seq:Ji(),str:Ki()},ie.safeLoad=n("safeLoad","load"),ie.safeLoadAll=n("safeLoadAll","loadAll"),ie.safeDump=n("safeDump","dump"),ie}var xo=vo(),ke=ko(xo),{Type:na,Schema:ta,FAILSAFE_SCHEMA:ia,JSON_SCHEMA:ra,CORE_SCHEMA:oa,DEFAULT_SCHEMA:sa,load:aa,loadAll:la,dump:ca,YAMLException:ua,types:da,safeLoad:pa,safeLoadAll:fa,safeDump:ha}=ke;I();var Co="${{ github.event.pull_request.number }}",Oo=10;function ur(i){return rn(i.node)?Ro(i):Ue(i.node)?To(i):null}function To(i){let e=i.node,n=Ie(e),r={GH_TOKEN:"${{ github.token }}",PR:Co,NODE:e.id,BOT_LOGIN:i.config.identity?.bot_login??""},o=["# Decide whether this lane should run for the PR. Every read here fails OPEN:","# a lane that runs once too often costs a run, one that is wrongly skipped","# costs a review nobody knows is missing.",'RUN=true; REASON=""; HEAD_SHA=""; DIFF_HASH=""',"finish() {",' { echo "run=$RUN"; echo "reason=$REASON"; echo "head_sha=$HEAD_SHA"; echo "diff_hash=$DIFF_HASH"; } >> "$GITHUB_OUTPUT"',' if [ "$RUN" = "true" ]; then echo "Running $NODE."; else echo "::notice::Skipping $NODE: $REASON"; fi'," exit 0","}",'skip() { RUN=false; REASON="$1"; finish; }',"","# Live PR state, not the event payload: the run may have queued for a while.",'PR_JSON=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" 2>/dev/null) || PR_JSON=""','if [ -z "$PR_JSON" ]; then',' echo "::warning::could not read PR #$PR \u2014 not skipping"'," finish","fi",`HEAD_SHA=$(jq -r '.head.sha // ""' <<< "$PR_JSON")`],s=0;for(let u of n)if(o.push(""),u.kind==="draft")o.push("# draft",`if [ "$(jq -r '.draft' <<< "$PR_JSON")" = "true" ]; then skip "the PR is a draft"; fi`);else if(u.kind==="bot-author")o.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(u.kind==="label"){s+=1;let a=`SKIP_LABEL_${s}`;r[a]=i.config.labels?.[u.label]??u.label,o.push(`# label:${u.label}`,`if jq -e --arg l "$${a}" 'any(.labels[]?; .name == $l)' <<< "$PR_JSON" >/dev/null; then`,` skip "the PR carries the label $${a}"`,"fi")}else r.MARKER_PREFIX=In(e),r.EVENT_ACTION="${{ github.event.action }}",o.push("# unchanged-diff: hash the PR's merge-base diff and compare it with the hash","# stamped into this bot's last review. Blob ids and hunk positions are","# dropped first, so a rebase or a merge from the base branch that leaves the","# change itself untouched hashes the same. Only a push (synchronize) is","# ever skipped this way: a label, a ready-for-review or a re-request is",'# someone asking for a review, and "nothing changed" is no answer to that.',`BASE_SHA=$(jq -r '.base.sha // ""' <<< "$PR_JSON")`,'if [ -n "$HEAD_SHA" ] && [ -n "$BASE_SHA" ] \\',' && DIFF=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA" -H "Accept: application/vnd.github.diff" 2>/dev/null) \\',' && [ -n "$DIFF" ]; then',` DIFF_HASH=$(printf '%s\\n' "$DIFF" \\`," | sed -E -e '/^index [0-9a-f]+\\.\\.[0-9a-f]+/d' -e 's/^@@ -[0-9,]+ \\+[0-9,]+ @@/@@/' \\"," | sha256sum | cut -d' ' -f1)",` LAST=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`,' .[] | select(.user.login == env.BOT_LOGIN) | (.body // "")',` | select(contains(env.MARKER_PREFIX)) | split(env.MARKER_PREFIX) | last | .[0:64]' 2>/dev/null | tail -n 1) || LAST=""`,' if [ "$EVENT_ACTION" = "synchronize" ] && [ -n "$LAST" ] && [ "$LAST" = "$DIFF_HASH" ]; then',' skip "the diff is unchanged since the last review"'," fi","else",' echo "::warning::could not hash the diff of PR #$PR \u2014 not skipping on unchanged-diff"',"fi");return o.push("","finish"),{jobId:on(e),name:`${e.id} skip guard`,permissions:{contents:"read","pull-requests":"read"},timeoutMinutes:5,outputs:{run:"${{ steps.decide.outputs.run }}",reason:"${{ steps.decide.outputs.reason }}",head_sha:"${{ steps.decide.outputs.head_sha }}",diff_hash:"${{ steps.decide.outputs.diff_hash }}"},steps:[se({id:"decide",name:"Decide whether to run",env:r,run:o.join(`
|
|
69
|
+
`)})]}}function Ro(i){let e=i.node,n=["# Pick the PR heads that are ready for a decision. Selection is a pure","# function of repo state \u2014 no agent, no randomness \u2014 and every read fails","# CLOSED: a head whose state cannot be read is left for the next sweep.","#","# candidate open, not a draft, on a harness branch","# reviews in no review is still being waited on (no pending review request)","# checks in every check-run on the head is completed, no commit status pending","# undecided no verdict review on this exact head yet",`LIST=$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&sort=created&direction=asc&per_page=100" --paginate --jq '`," .[] | select(.draft | not)"," | select(.head.ref | startswith(env.PREFIX))",` | "\\(.number) \\(.head.sha) \\((.requested_reviewers | length) + (.requested_teams | length))"') || {`,' echo "::error::could not list open pull requests"'," exit 1","}","SELECTED='[]'","while read -r NUM SHA REQUESTED; do",' [ -n "$NUM" ] || continue',' if [ "$REQUESTED" != "0" ]; then echo "#$NUM: $REQUESTED review request(s) outstanding"; continue; fi',` RUNNING=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100" --paginate --jq '`,` [.check_runs[] | select(.status != "completed")] | length' | awk '{s+=$1} END {print s+0}') || { echo "#$NUM: could not read check-runs"; continue; }`,' if [ "$RUNNING" != "0" ]; then echo "#$NUM: $RUNNING check-run(s) still running"; continue; fi',` STATUS=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/status" --jq '`,` if .total_count == 0 then "none" else .state end') || { echo "#$NUM: could not read commit status"; continue; }`,' if [ "$STATUS" = "pending" ]; then echo "#$NUM: a commit status is pending"; continue; fi',` DECIDED=$(SHA="$SHA" gh api "repos/$GITHUB_REPOSITORY/pulls/$NUM/reviews?per_page=100" --paginate --jq '`," [ .[] | select(.commit_id == env.SHA)",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',` | select((.body // "") | contains(env.VERDICT_MARKER)) ] | length' | awk '{s+=$1} END {print s+0}') || { echo "#$NUM: could not read reviews"; continue; }`,' if [ "$DECIDED" != "0" ]; then echo "#$NUM: already decided at $SHA"; continue; fi',' echo "#$NUM: selected at $SHA"',` SELECTED=$(jq -c --argjson n "$NUM" --arg s "$SHA" '. + [{number: $n, sha: $s}]' <<< "$SELECTED")`,` if [ "$(jq 'length' <<< "$SELECTED")" -ge "$LIMIT" ]; then`,' echo "limit of $LIMIT reached \u2014 the rest wait for the next sweep"'," break"," fi",'done <<< "$LIST"',`{ echo "prs=$SELECTED"; echo "count=$(jq 'length' <<< "$SELECTED")"; } >> "$GITHUB_OUTPUT"`].join(`
|
|
70
|
+
`);return{jobId:on(e),name:`${e.id} sweep select`,permissions:{contents:"read","pull-requests":"read",checks:"read",statuses:"read"},timeoutMinutes:10,outputs:{prs:"${{ steps.select.outputs.prs }}",count:"${{ steps.select.outputs.count }}"},steps:[se({id:"select",name:"Select pull requests ready for a decision",env:{GH_TOKEN:"${{ github.token }}",PREFIX:i.config.repo.branch_prefix,BOT_LOGIN:i.config.identity?.bot_login??"",VERDICT_MARKER:ui,LIMIT:String(Oo)},run:n})]}}I();var dr=[" /^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 No="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.\n# Edit harness.dot / roles / foundry.config.yaml and run `gp-foundry build`.\n";function Io(i){let e=i.runtime??{};if(e.mode==="vendored")return o=>`./.github/actions/${o}`;let n=e.owner_repo??"thegpvc/gp-foundry",r=e.ref??"v1";return o=>`${n}/actions/${o}@${r}`}function Ho(i){let e={};return i.name&&(e.name=i.name),i.id&&(e.id=i.id),i.if&&(e.if=i.if),i.timeoutMinutes&&(e["timeout-minutes"]=i.timeoutMinutes),li(i)?(e.uses=i.uses,i.with&&Object.keys(i.with).length&&(e.with=i.with)):(i.shell&&(e.shell=i.shell),i.env&&Object.keys(i.env).length&&(e.env=i.env),e.run=i.run),e}function pr(i){return String(i.attrs.name??i.id)}function Po(i,e){let n=e?`${e.replace(/\/+$/,"")}/agents/scope.yaml`:"agents/scope.yaml";return{name:"immutable-paths guard",on:{pull_request:{types:["opened","synchronize","reopened"]}},permissions:{contents:"read"},jobs:{"immutable-paths":{"runs-on":"ubuntu-latest",if:`startsWith(github.event.pull_request.head.ref, '${i.repo.branch_prefix}')`,"timeout-minutes":5,steps:[{name:"Checkout",uses:"actions/checkout@v5",with:{"fetch-depth":0}},{name:"Fail if the PR touches an immutable path",shell:"bash",env:{SCOPE_PATH:n,BASE_SHA:"${{ github.event.pull_request.base.sha }}",HEAD_SHA:"${{ github.event.pull_request.head.sha }}"},run:["# The immutable_paths list, read without a YAML parser. This scan is","# shared with the agent-fallback composite (src/shared/immutable-paths.ts);","# a test fails if the two copies drift.",'PATHS=""','HAS_KEY=""','if [ -f "$SCOPE_PATH" ]; then',` grep -q '^immutable_paths[[:space:]]*:' "$SCOPE_PATH" && HAS_KEY=1`," PATHS=$(awk '",...dr,` ' "$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(`
|
|
71
|
+
`)}]}}}}function fr(i,e,n=""){let r=[],o=Io(i.config),s=new Map(i.nodes.map(h=>[h.id,h])),u=new Map,a=new Map;for(let h of i.nodes)u.set(h.id,[]),a.set(h.id,[]);for(let h of i.edges)u.get(h.from)?.push(h),a.get(h.to)?.push(h);let d=h=>({config:i.config,node:h,outEdges:u.get(h.id)??[],inEdges:a.get(h.id)??[],actionRef:o,nodeById:$=>s.get($),specDir:n}),l=(h,$)=>{let E={"runs-on":"ubuntu-latest"},k=h.if??$;return k&&(E.if=k),h.environment&&(E.environment=h.environment),h.permissions&&Object.keys(h.permissions).length&&(E.permissions=h.permissions),h.timeoutMinutes&&(E["timeout-minutes"]=h.timeoutMinutes),h.needs?.length&&(E.needs=h.needs),h.outputs&&Object.keys(h.outputs).length&&(E.outputs=h.outputs),h.strategy&&(E.strategy=h.strategy),E.steps=h.steps.map(Ho),E},p=(h,$)=>{let E=ke.dump($,{lineWidth:-1,noRefs:!0,quotingType:'"'});r.push({path:`.github/workflows/${h}.yml`,contents:No+E,generated:!0})},m=Pe(i);p("immutable-guard",Po(i.config,n));for(let h of i.nodes){if(m.memberIds.has(h.id))continue;let $=e.perNode[h.id];if(!$||Object.keys($.triggers).length===0)continue;let E=m.byFanin.get(h.id);if(E){let H={};for(let Z of E.legIds){let{skip:re,select:K,...pe}=s.get(Z).attrs,fe={...s.get(Z),attrs:pe},j=gt(fe,i,d(fe));j&&(H[j.jobId]=l(j,$.guard))}let F=JSON.stringify($.triggers).includes('"pull_request"'),L=mi(d(h),E.legIds,F);H[L.jobId]=l(L),p(h.id,{name:pr(h),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:H});continue}let k=gt(h,i,d(h));if(!k)continue;let x=ur(d(h)),M=x?{[x.jobId]:l(x,$.guard),[k.jobId]:l(k)}:{[k.jobId]:l(k,$.guard)};p(h.id,{name:pr(h),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:M})}return r}I();function Mo(i){switch(i.type){case"start":case"exit":return["([","])"];case"human-gate":return["{{","}}"];case"merge-gate":return["[/","/]"];case"parallel":case"fan_in":return["[[","]]"];default:return["[","]"]}}function Fo(i){let e=i.files.role?.replace(/^.*\//,"").replace(/\.md$/,""),n=e&&e!==i.id?`${e} \xB7 ${i.type}`:i.type;return`${i.id}<br/><small>${n}</small>`}function qn(i){let e=["```mermaid","flowchart TD"];for(let n of i.nodes){let[r,o]=Mo(n);e.push(` ${n.id}${r}"${Fo(n)}"${o}`)}for(let n of i.edges){let r=[n.on,n.when].filter(Boolean).join(" \xB7 ");e.push(r?` ${n.from} -->|"${r}"| ${n.to}`:` ${n.from} --> ${n.to}`)}return e.push("```",""),`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
|
|
68
72
|
|
|
69
|
-
# ${
|
|
73
|
+
# ${i.config?.name&&i.config.name!=="harness"?i.config.name:i.name} \u2014 agent harness
|
|
70
74
|
|
|
71
75
|
${e.join(`
|
|
72
|
-
`)}`}I();var
|
|
73
|
-
`){
|
|
74
|
-
`;)o++;continue}if(
|
|
75
|
-
`&&
|
|
76
|
-
`&&
|
|
77
|
-
`)}function
|
|
78
|
-
`),e.hint&&process.stderr.write(` ${
|
|
79
|
-
`)}}function
|
|
80
|
-
`),
|
|
81
|
-
`)}function
|
|
82
|
-
`));process.stdout.write(
|
|
83
|
-
`))}),
|
|
84
|
-
`)),process.stdout.write(
|
|
76
|
+
`)}`}I();var Do=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),jo=new Set(["role","prompt","policy","tools"]);function Lo(i){let e=[],n=[],r=1,o=0,s=i;for(;o<s.length;){let u=s[o];if(u===`
|
|
77
|
+
`){r++,o++;continue}if(u===" "||u===" "||u==="\r"){o++;continue}if(u==="/"&&s[o+1]==="/"){for(;o<s.length&&s[o]!==`
|
|
78
|
+
`;)o++;continue}if(u==="/"&&s[o+1]==="*"){for(o+=2;o<s.length&&!(s[o]==="*"&&s[o+1]==="/");)s[o]===`
|
|
79
|
+
`&&r++,o++;o+=2;continue}if(u==="-"&&s[o+1]===">"){e.push({kind:"arrow",value:"->",line:r}),o+=2;continue}if(u==="{"){e.push({kind:"lbrace",value:u,line:r}),o++;continue}if(u==="}"){e.push({kind:"rbrace",value:u,line:r}),o++;continue}if(u==="["){e.push({kind:"lbrack",value:u,line:r}),o++;continue}if(u==="]"){e.push({kind:"rbrack",value:u,line:r}),o++;continue}if(u==="="){e.push({kind:"eq",value:u,line:r}),o++;continue}if(u===","){e.push({kind:"comma",value:u,line:r}),o++;continue}if(u===";"){e.push({kind:"semi",value:u,line:r}),o++;continue}if(u==='"'){let a=o+1,d="";for(;a<s.length&&s[a]!=='"';){if(s[a]==="\\"&&a+1<s.length){d+=s[a+1],a+=2;continue}s[a]===`
|
|
80
|
+
`&&r++,d+=s[a],a++}a>=s.length&&n.push({message:"unterminated string",line:r}),e.push({kind:"id",value:d,line:r}),o=a+1;continue}if(/[A-Za-z0-9_]/.test(u)){let a=o,d="";for(;a<s.length&&/[A-Za-z0-9_.\-]/.test(s[a]);)d+=s[a],a++;e.push({kind:"id",value:d,line:r}),o=a;continue}n.push({message:`unexpected character '${u}'`,line:r}),o++}return{toks:e,errors:n}}function qo(i){return i==="true"?!0:i==="false"?!1:/^-?\d+$/.test(i)?Number(i):i}function fn(i){let{toks:e,errors:n}=Lo(i),r=[],o=[],s=new Map,u="harness",a=0,d=()=>e[a],l=()=>e[a++],p=(k,x)=>n.push({message:k,line:x});d()?.kind==="id"&&d()?.value==="digraph"?(l(),d()?.kind==="id"&&d()?.value!==void 0&&(u=l().value),d()?.kind==="lbrace"?l():p("expected '{' after digraph header",d()?.line)):p("expected 'digraph' keyword",d()?.line);function m(){let k={};if(d()?.kind!=="lbrack")return{attrs:k};let x=l().line;for(;d()&&d().kind!=="rbrack";){let M=l();if(!M||M.kind!=="id"){p("expected attribute name",M?.line);break}if(d()?.kind!=="eq"){p(`expected '=' after attribute '${M.value}'`,M.line);break}l();let H=l();if(!H||H.kind!=="id"){p(`expected value for attribute '${M.value}'`,H?.line);break}k[M.value]=H.value,d()?.kind==="comma"&&l()}return d()?.kind==="rbrack"?l():p("unterminated attribute list '['",x),{attrs:k,line:x}}function h(k,x){let M=s.get(k);return M||(M={id:k,type:"analyst",attrs:{},files:{},raw:{},line:x},s.set(k,M),r.push(M)),M}function $(k,x,M){k.declared=!0,k.raw={...k.raw,...x},M!==void 0&&(k.line=k.line??M);for(let[H,F]of Object.entries(x))H==="type"?(Do.has(F)||p(`unknown node type '${F}' on node '${k.id}'`,M),k.type=F):H==="context"?k.context=F:jo.has(H)?k.files[H]=F:k.attrs[H]=qo(F)}let E=0;for(;d()&&d().kind!=="rbrace"&&!(E++>1e5);){let k=d();if(k.kind==="semi"){l();continue}if(k.kind!=="id"){p(`unexpected token '${k.value}'`,k.line),l();continue}let x=l();if(d()?.kind==="arrow"){let M=[{id:x.value,line:x.line}];for(;d()?.kind==="arrow";){l();let L=l();if(!L||L.kind!=="id"){p("expected node id after '->'",L?.line);break}M.push({id:L.value,line:L.line})}let{attrs:H,line:F}=m();for(let L=0;L+1<M.length;L++){let Z=M[L],re=M[L+1];h(Z.id,Z.line),h(re.id,re.line);let K={from:Z.id,to:re.id,raw:{...H},line:F??Z.line};H.on!==void 0&&(K.on=H.on),H.when!==void 0&&(K.when=H.when),H.do!==void 0&&(K.do=H.do),o.push(K)}}else{let{attrs:M,line:H}=m(),F=h(x.value,x.line);$(F,M,H??x.line)}d()?.kind==="semi"&&l()}return d()?.kind==="rbrace"&&l(),{name:u,nodes:r,edges:o,errors:n}}I();var hn=require("fs");var Ye={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 Un(i){if(!i||!(0,hn.existsSync)(i))return structuredClone(Ye);let e=ke.load((0,hn.readFileSync)(i,"utf8"))??{};return{...Ye,...e,identity:{...Ye.identity,...e.identity??{}},agent:{...Ye.agent,...e.agent??{}},repo:{...Ye.repo,...e.repo??{}},labels:{...Ye.labels,...e.labels??{}}}}function he(i,e){let n=fn((0,hn.readFileSync)(i,"utf8")),r=Un(e);return{harness:{name:n.name,nodes:n.nodes,edges:n.edges,config:r,sourcePath:i},parseErrors:n.errors}}function Ke(i,e={},n={}){let r=[...ln(i,e),...cn(i)],o=fr(i,Ai(i),n.specDir??"");return o.push({path:".github/HARNESS.md",contents:qn(i),generated:!0}),{files:o,diagnostics:r}}function mn(i){return i.some(e=>e.level==="error")}I();var Uo=/^---\r?\n([\s\S]*?)\r?\n---/;function hr(i){let e=Uo.exec(i);if(e)try{let n=ke.load(e[1]);if(n&&typeof n=="object")return n}catch{return}}I();var mr=require("fs"),Ee=require("path"),gr=require("url"),Me=xn(Nn(),1);function de(i){return(0,gr.fileURLToPath)(new URL(`../../${i}`,B))}function J(i){process.stdout.write(JSON.stringify(i,null,2)+`
|
|
81
|
+
`)}function qt(i){for(let e of i){let n=e.level==="error"?Me.default.red("error"):e.level==="warning"?Me.default.yellow("warn"):Me.default.blue("info"),r=e.where?.node?Me.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${n} ${Me.default.dim(e.code)}${r} ${e.message}
|
|
82
|
+
`),e.hint&&process.stderr.write(` ${Me.default.dim("hint: "+e.hint)}
|
|
83
|
+
`)}}function Se(i){let e=(0,Ee.resolve)(i.dot??".github/harness.dot"),n=(0,Ee.dirname)(e),r=i.config?(0,Ee.resolve)(i.config):void 0;if(!r){for(let s of[(0,Ee.join)(n,"foundry.config.yaml"),(0,Ee.join)(n,"agents/foundry.config.yaml")])if((0,mr.existsSync)(s)){r=s;break}}let o=n.endsWith(".github")?(0,Ee.dirname)(n):n;return{dot:e,config:r,base:n,root:o}}I();var Ut=require("child_process"),U=require("fs"),V=require("path");var G=xn(Nn(),1);var Bt=require("path");function Je(i,e={}){try{return{ok:!0,out:(0,Ut.execFileSync)("gh",i,{encoding:"utf8",stdio:["ignore","pipe","pipe"],cwd:e.cwd}).trim()}}catch(n){return{ok:!1,out:n.stderr?.toString().trim()??String(n.message)}}}function Oe(i,e){let n=Je(i,{cwd:e});if(!n.ok)return null;try{return JSON.parse(n.out)}catch{return null}}function _r(){let i=de("actions");return(0,U.readdirSync)(i,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,U.existsSync)((0,V.join)(i,e.name,"action.yml"))).map(e=>e.name)}function Ar(i){let e=Un(i),n=new Map([["build","ready to implement"],["plan","needs design first"]]),r=[];for(let[o,s]of n)r.push({name:e.labels?.[o]??o,description:s,color:o==="build"?"0e8a16":"5319e7"});return r.push({name:"needs-human",description:"agents are blocked; a human should take over",color:"b60205"}),r.push({name:"needs-rebase",description:"PR conflicts with base; the janitor sweep rebases it",color:"d93f0b"}),r}function br(i){let e={ok:G.default.green("\u2713"),warn:G.default.yellow("!"),fail:G.default.red("\u2717"),skip:G.default.dim("-")};for(let n of i)process.stdout.write(`${e[n.status]} ${n.name.padEnd(28)} ${n.detail}
|
|
84
|
+
`),n.hint&&n.status!=="ok"&&process.stdout.write(` ${G.default.dim("hint: "+n.hint)}
|
|
85
|
+
`)}function Bo(i,e){let n=i.nodes.filter(r=>r.type==="merge-gate");return n.length===0?!1:n.some(r=>{if(!r.files.policy)return!0;let o=(0,V.dirname)(i.sourcePath??""),s=(0,V.join)(e,o,r.files.policy);if(!(0,U.existsSync)(s))return!0;try{let u=ke.load((0,U.readFileSync)(s,"utf8"));return(u?.require_ci??u?.requireCi)!==!1}catch{return!0}})}function yr(i){let e=[];for(let r of _r()){let o=de(`actions/${r}`),s=(0,V.join)(i,".github/actions",r);(0,U.mkdirSync)(s,{recursive:!0}),(0,U.cpSync)((0,V.join)(o,"action.yml"),(0,V.join)(s,"action.yml")),(0,U.existsSync)((0,V.join)(o,"dist"))&&(0,U.cpSync)((0,V.join)(o,"dist"),(0,V.join)(s,"dist"),{recursive:!0}),e.push(`.github/actions/${r}/`)}let n=(0,V.join)(i,".github/agent-setup/action.yml");return(0,U.existsSync)(n)||((0,U.mkdirSync)((0,V.dirname)(n),{recursive:!0}),(0,U.writeFileSync)(n,(0,U.readFileSync)(de("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function Go(i){(0,U.mkdirSync)(i,{recursive:!0}),(0,U.cpSync)(de("skill/SKILL.md"),(0,V.join)(i,"SKILL.md")),(0,U.cpSync)(de("skill/reference"),(0,V.join)(i,"reference"),{recursive:!0}),(0,U.cpSync)(de("skill/templates"),(0,V.join)(i,"templates"),{recursive:!0})}function wr(i){let e=[],{dot:n,config:r,base:o,root:s}=Se(i);if(!(0,U.existsSync)(n))return e.push({name:"harness",status:"fail",detail:`no harness.dot at ${n}`,hint:"run `gp-foundry init`"}),{checks:e,failed:!0};let{harness:u,parseErrors:a}=he(n,r),d=j=>(0,U.existsSync)((0,V.join)(o,j)),l=(0,Bt.relative)(s,o).replace(/\\/g,"/"),{files:p,diagnostics:m}=Ke(u,{fileExists:d},{specDir:l}),h=m.filter(j=>j.level==="error").length+a.length,$=m.filter(j=>j.level==="warning");e.push(h?{name:"validate",status:"fail",detail:`${h} error(s)`,hint:"run `gp-foundry validate` for details"}:{name:"validate",status:$.length?"warn":"ok",detail:$.length?`${$.length} warning(s): ${$.map(j=>j.code).join(", ")}`:"no diagnostics"});let E=p.filter(j=>{let ae=(0,V.join)(s,j.path);return((0,U.existsSync)(ae)?(0,U.readFileSync)(ae,"utf8"):null)!==j.contents});if(e.push(E.length?{name:"workflows in sync",status:"fail",detail:`${E.length} file(s) drifted: ${E.slice(0,3).map(j=>j.path).join(", ")}${E.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${p.length} generated files match`}),(u.config.runtime?.mode??"pinned")==="vendored"){let j=_r().filter(ae=>!(0,U.existsSync)((0,V.join)(s,".github/actions",ae,"action.yml")));e.push(j.length?{name:"vendored actions",status:"fail",detail:`missing: ${j.join(", ")}`,hint:"run `gp-foundry vendor`"}:{name:"vendored actions",status:"ok",detail:"all runtime actions vendored"})}if(e.push((0,U.existsSync)((0,V.join)(s,".github/agent-setup/action.yml"))?{name:"agent-setup shim",status:"ok",detail:".github/agent-setup/action.yml present"}:{name:"agent-setup shim",status:"fail",detail:"missing \u2014 every agent job needs it",hint:"run `gp-foundry vendor` (or `init`)"}),!Je(["auth","status"]).ok)return e.push({name:"gh cli",status:"skip",detail:"gh missing or unauthenticated \u2014 skipping repo checks",hint:"install GitHub CLI and `gh auth login`"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"gh cli",status:"ok",detail:"authenticated"});let x=Oe(["repo","view","--json","nameWithOwner,defaultBranchRef"],s);if(!x)return e.push({name:"github repo",status:"skip",detail:"not a GitHub repo (or no remote) \u2014 skipping labels/secrets checks",hint:"create it with `gh repo create`, then re-run `gp-foundry up` to create labels"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"github repo",status:"ok",detail:x.nameWithOwner});let M=x.defaultBranchRef?.name;M&&e.push(M===u.config.repo.base_branch?{name:"base branch",status:"ok",detail:M}:{name:"base branch",status:"fail",detail:`config says '${u.config.repo.base_branch}' but the repo default is '${M}'`,hint:"fix repo.base_branch in foundry.config.yaml and re-run `gp-foundry up`"});let H=new Set((Oe(["label","list","--json","name","--limit","1000"],s)??[]).map(j=>j.name)),F=Ar(r).map(j=>j.name),L=F.filter(j=>!H.has(j));e.push(L.length?{name:"labels",status:"fail",detail:`missing: ${L.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:F.join(", ")});let Z=new Set((Oe(["secret","list","--json","name"],s)??[]).map(j=>j.name)),re=[u.config.agent.api_key_secret||(u.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")],K=u.config.auth;K?.mode==="pat"&&K.token_secret&&re.push(K.token_secret),K?.mode==="app"&&re.push(K.app_id_secret??"APP_ID",K.app_key_secret??"APP_PRIVATE_KEY");let pe=re.filter(j=>!Z.has(j));if(e.push(pe.length?{name:"secrets",status:"fail",detail:`missing: ${pe.join(", ")}`,hint:`gh secret set ${pe[0]}`}:{name:"secrets",status:"ok",detail:re.join(", ")}),Bo(u,s)){let ae=p.filter(te=>/\/workflows\/.*\.yml$/.test(te.path)&&te.contents.includes("actions/merge-gate")).map(te=>(0,V.join)(s,te.path)).filter(te=>(0,U.existsSync)(te)).map(te=>(0,U.readFileSync)(te,"utf8")),Re=ae.filter(te=>!te.includes("checks-token"));ae.length&&Re.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${Re.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 fe=Je(["--version"]);try{let j=(0,Ut.execFileSync)("git",["status","--porcelain",".github"],{cwd:s,encoding:"utf8"}).trim();e.push(j?{name:"committed",status:"warn",detail:".github/ has uncommitted changes",hint:"commit + push so GitHub picks them up"}:{name:"committed",status:"ok",detail:".github/ clean"})}catch{e.push({name:"committed",status:"skip",detail:"not a git repo"})}return{checks:e,failed:e.some(j=>j.status==="fail")}}function Vo(i){let{dot:e,config:n,root:r}=Se(i);if(!Je(["auth","status"]).ok)return{error:"gh missing or unauthenticated \u2014 status needs the GitHub CLI",hint:"install the GitHub CLI and run `gh auth login`"};let o=Oe(["repo","view","--json","nameWithOwner"],r);if(!o)return{error:"not a GitHub repo (or no remote)",hint:"create it with `gh repo create`, push, then re-run `gp-foundry status`"};let{harness:s}=he(e,n),u=s.config.repo.branch_prefix,a=Date.now(),d=x=>Math.round((a-Date.parse(x))/36e5),l={};for(let x of["plan","build","needs-human"]){let M=x==="needs-human"?"needs-human":s.config.labels?.[x]??x,H=Oe(["issue","list","--label",M,"--state","open","--json","number,title,createdAt","--limit","50"],r)??[];l[M]=H.map(F=>({number:F.number,title:F.title,ageHours:d(F.createdAt)}))}let m=(Oe(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],r)??[]).filter(x=>x.headRefName.startsWith(u)),h=[],$=new Set;for(let x of m)for(let M of x.body?.matchAll(/[Cc]loses #(\d+)/g)??[])$.add(Number(M[1]));let E=s.config.labels?.build??"build";for(let x of l[E]??[])!$.has(x.number)&&x.ageHours>=2&&h.push({kind:"issue-no-pr",number:x.number,title:x.title,detail:`labeled ${E} ${x.ageHours}h ago, no open PR closes it`});for(let x of m)x.updatedAt&&d(x.updatedAt)>=4&&h.push({kind:"pr-idle",number:x.number,title:x.title,detail:`no activity for ${d(x.updatedAt)}h`});let k=(Oe(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],r)??[]).filter(x=>d(x.createdAt)<=24).map(x=>({workflow:x.name,url:x.url,ageHours:d(x.createdAt)}));return{repo:o.nameWithOwner,lanes:l,prs:m.map(x=>({number:x.number,title:x.title,labels:x.labels.map(M=>M.name),mergeable:x.mergeable,headRefName:x.headRefName})),stalled:h,recentFailures:k}}function kr(i){i.command("vendor").description("Copy the runtime-core actions into .github/actions/ (self-contained repo)").option("--dir <path>","target repo root",".").option("--json","machine-readable output").action(e=>{let n=yr(e.dir);if(e.json)return J({written:n});for(let r of n)process.stdout.write(G.default.green(`vendored ${r}
|
|
86
|
+
`));process.stdout.write(G.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
|
|
87
|
+
`))}),i.command("skill").description("Install the Claude skill (Socratic setup) into .claude/skills/gp-foundry/").option("--user","install for all projects (~/.claude/skills/) instead of this repo").option("--dir <path>","target repo root (project mode)",".").option("--json","machine-readable output").action(e=>{let n=process.env.HOME??process.env.USERPROFILE??".",r=e.user?(0,V.join)(n,".claude/skills/gp-foundry"):(0,V.join)(e.dir,".claude/skills/gp-foundry");if(Go(r),e.json)return J({installed:r});process.stdout.write(G.default.green(`installed skill \u2192 ${r}
|
|
88
|
+
`)),process.stdout.write(G.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
|
|
85
89
|
The skill interviews you Socratically, drafts harness.dot + roles, and drives this CLI.
|
|
86
|
-
`))}),
|
|
90
|
+
`))}),i.command("doctor").description("Preflight the factory: config, drift, vendored actions, gh auth, labels, secrets").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{checks:n,failed:r}=wr(e);e.json?J({ok:!r,checks:n}):(br(n),process.stdout.write(r?G.default.red(`
|
|
87
91
|
not ready \u2014 fix the \u2717 items above
|
|
88
|
-
`):
|
|
92
|
+
`):G.default.green(`
|
|
89
93
|
factory is ready
|
|
90
|
-
`))),process.exit(
|
|
91
|
-
`)),
|
|
92
|
-
`))),process.exit(1)),e.json)return J(
|
|
93
|
-
${
|
|
94
|
+
`))),process.exit(r?1:0)}),i.command("status").description("Factory dashboard: work in flight, stalled items, recent failures").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let n=Vo(e);if("error"in n&&(e.json?J(n):(process.stderr.write(G.default.red(n.error+`
|
|
95
|
+
`)),n.hint&&process.stderr.write(G.default.dim("hint: "+n.hint+`
|
|
96
|
+
`))),process.exit(1)),e.json)return J(n);process.stdout.write(G.default.bold(`
|
|
97
|
+
${n.repo} \u2014 factory status
|
|
94
98
|
|
|
95
|
-
`));for(let[
|
|
96
|
-
`));for(let s of o.slice(0,10))process.stdout.write(` #${s.number} ${s.title} ${
|
|
97
|
-
`)}process.stdout.write(
|
|
98
|
-
agent PRs (${
|
|
99
|
-
`));for(let
|
|
100
|
-
`);if(
|
|
101
|
-
stalled (${
|
|
102
|
-
`));for(let
|
|
103
|
-
`)}if(
|
|
104
|
-
failed runs, last 24h (${
|
|
105
|
-
`));for(let
|
|
106
|
-
`)}!
|
|
99
|
+
`));for(let[r,o]of Object.entries(n.lanes)){process.stdout.write(G.default.cyan(`${r} (${o.length})
|
|
100
|
+
`));for(let s of o.slice(0,10))process.stdout.write(` #${s.number} ${s.title} ${G.default.dim(`(${s.ageHours}h)`)}
|
|
101
|
+
`)}process.stdout.write(G.default.cyan(`
|
|
102
|
+
agent PRs (${n.prs.length})
|
|
103
|
+
`));for(let r of n.prs)process.stdout.write(` #${r.number} ${r.title} ${G.default.dim(r.mergeable??"")} ${r.labels.length?G.default.yellow(r.labels.join(",")):""}
|
|
104
|
+
`);if(n.stalled.length){process.stdout.write(G.default.red(`
|
|
105
|
+
stalled (${n.stalled.length})
|
|
106
|
+
`));for(let r of n.stalled)process.stdout.write(` #${r.number} ${r.title} \u2014 ${r.detail}
|
|
107
|
+
`)}if(n.recentFailures.length){process.stdout.write(G.default.red(`
|
|
108
|
+
failed runs, last 24h (${n.recentFailures.length})
|
|
109
|
+
`));for(let r of n.recentFailures.slice(0,10))process.stdout.write(` ${r.workflow} ${G.default.dim(`${r.ageHours}h ago`)} ${r.url}
|
|
110
|
+
`)}!n.stalled.length&&!n.recentFailures.length&&process.stdout.write(G.default.green(`
|
|
107
111
|
no stalled work, no recent failures
|
|
108
|
-
`))}),
|
|
109
|
-
`))}else
|
|
110
|
-
`)));let
|
|
111
|
-
`));let{checks:
|
|
112
|
-
`),
|
|
112
|
+
`))}),i.command("up").description("Bring the factory up: create labels, vendor actions, build workflows, run doctor").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{dot:n,config:r,base:o,root:s}=Se(e),u={};if(Je(["auth","status"]).ok&&Oe(["repo","view","--json","nameWithOwner"],s)){let k=[];for(let x of Ar(r))Je(["label","create",x.name,"--color",x.color,"--description",x.description],{cwd:s}).ok&&k.push(x.name);u.labels=k,e.json||process.stdout.write(G.default.green(`labels ensured (created: ${k.length?k.join(", "):"none \u2014 already present"})
|
|
113
|
+
`))}else u.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(G.default.yellow("skipped label creation (gh unavailable or no GitHub repo yet) \u2014 re-run `gp-foundry up` once the repo exists\n"));let{harness:a}=he(n,r);(a.config.runtime?.mode??"pinned")==="vendored"&&(u.vendored=yr(s),e.json||process.stdout.write(G.default.green(`vendored ${u.vendored.length} runtime action(s)
|
|
114
|
+
`)));let d=k=>(0,U.existsSync)((0,V.join)(o,k)),l=(0,Bt.relative)(s,o).replace(/\\/g,"/"),{files:p,diagnostics:m}=Ke(a,{fileExists:d},{specDir:l});mn(m)&&(e.json?J({ok:!1,diagnostics:m}):process.stderr.write(G.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let k of p){let x=(0,V.join)(s,k.path);(0,U.mkdirSync)((0,V.dirname)(x),{recursive:!0}),(0,U.writeFileSync)(x,k.contents)}u.wrote=p.map(k=>k.path);let h=p.filter(k=>k.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(G.default.green(`built ${h} workflows + HARNESS.md
|
|
115
|
+
`));let{checks:$,failed:E}=wr(e);if(u.checks=$,u.ok=!E,e.json)return J(u);process.stdout.write(`
|
|
116
|
+
`),br($),process.stdout.write(E?G.default.yellow(`
|
|
113
117
|
almost there \u2014 fix the \u2717 items above, commit .github/, push, then file an issue
|
|
114
|
-
`):
|
|
118
|
+
`):G.default.green(`
|
|
115
119
|
factory is up \u2014 commit .github/, push, then file an issue to watch it run
|
|
116
|
-
`)),process.exit(
|
|
117
|
-
`));for(let
|
|
120
|
+
`)),process.exit(E?1:0)})}var Te=new oi,Wo=JSON.parse((0,Y.readFileSync)(de("package.json"),"utf8")).version;Te.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(Wo);function Yo(i,e){let n=new Map;for(let r of i.nodes){if(!r.files.role)continue;let o=(0,ne.join)(e,r.files.role);if((0,Y.existsSync)(o)){let s=hr((0,Y.readFileSync)(o,"utf8"));s&&n.set(r.id,s)}}return n}var Ko=[["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"]];Te.command("init").description("Scaffold a starter harness (harness.dot + config + roles + scope + policy) into a repo").option("--dir <path>","target repo root",".").option("--force","overwrite existing files").option("--json","machine-readable output").action(i=>{let e=(0,ne.resolve)(i.dir),n=[],r=[],o=(a,d)=>{let l=(0,ne.join)(e,a);if((0,Y.existsSync)(l)&&!i.force){r.push(a);return}(0,Y.mkdirSync)((0,ne.dirname)(l),{recursive:!0}),(0,Y.writeFileSync)(l,d),n.push(a)},s="main";try{let a=(0,Er.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();a&&(s=a)}catch{}for(let[a,d]of Ko){let l=(0,Y.readFileSync)(de(a),"utf8");d.endsWith("foundry.config.yaml")&&s!=="main"&&(l=l.replace(/^(\s*base_branch:\s*)main\b/m,`$1${s}`)),o(d,l)}let u=(0,ne.join)(e,".github/harness.dot");if((0,Y.existsSync)(u))for(let a of fn((0,Y.readFileSync)(u,"utf8")).nodes){if(!a.files.role)continue;let d=a.files.role.replace(/^.*\//,"").replace(/\.md$/,""),l=de(`roles/software/${d}.md`),p=(0,Y.existsSync)(l)?l:de("skill/templates/role.md");o((0,ne.join)(".github",a.files.role),(0,Y.readFileSync)(p,"utf8"))}if(i.json)return J({written:n,skipped:r});for(let a of n)process.stdout.write(Q.default.green(`created ${a}
|
|
121
|
+
`));for(let a of r)process.stderr.write(Q.default.yellow(`skipped ${a} (exists; --force to overwrite)
|
|
118
122
|
`));process.stdout.write(["",Q.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${Q.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${Q.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${Q.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${Q.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",Q.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
|
|
119
|
-
`))})
|
|
120
|
-
`)),process.exit(1));let{harness:s,parseErrors:
|
|
121
|
-
`));process.exit(1)}let
|
|
123
|
+
`))});Te.command("build").description("Compile harness.dot \u2192 .github/workflows/*.yml (+ HARNESS.md)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--out <dir>","output repo root (default: dir of harness.dot)").option("--check","verify generated files are in sync; exit 1 on drift").option("--dry-run","print what would be written; do not write").option("--force","write even if there are error diagnostics").option("--json","machine-readable output").action(i=>{let{dot:e,config:n,base:r,root:o}=Se(i);(0,Y.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e}
|
|
124
|
+
`)),process.exit(1));let{harness:s,parseErrors:u}=he(e,n);if(u.length){if(i.json)J({parseErrors:u});else for(let h of u)process.stderr.write(Q.default.red(`parse: ${h.message}${h.line?` (line ${h.line})`:""}
|
|
125
|
+
`));process.exit(1)}let a=(0,ne.resolve)(i.out??o),d=(0,ne.relative)(a,r).replace(/\\/g,"/"),l=h=>(0,Y.existsSync)((0,ne.join)(r,h)),{files:p,diagnostics:m}=Ke(s,{fileExists:l},{specDir:d});if(i.json||qt(m),i.check){let h=p.filter($=>{let E=(0,ne.join)(a,$.path);return((0,Y.existsSync)(E)?(0,Y.readFileSync)(E,"utf8"):null)!==$.contents});if(i.json)J({upToDate:h.length===0,drift:h.map($=>$.path),diagnostics:m});else if(h.length){for(let $ of h)process.stderr.write(Q.default.yellow(`drift: ${$.path}
|
|
122
126
|
`));process.stderr.write(Q.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}else process.stdout.write(Q.default.green(`up to date
|
|
123
|
-
`));process.exit(
|
|
124
|
-
`)),process.exit(1)),
|
|
125
|
-
`)+
|
|
126
|
-
`);return}for(let
|
|
127
|
-
`))}
|
|
128
|
-
`)),process.exit(1));let{harness:o,parseErrors:s}=
|
|
129
|
-
`));
|
|
130
|
-
`)),process.exit(1));let{harness:
|
|
131
|
-
`)})
|
|
132
|
-
`)),process.exit(1));let{harness:o}=
|
|
133
|
-
`)),process.exit(1)),e.json?J({node:
|
|
134
|
-
`)});
|
|
127
|
+
`));process.exit(h.length?1:0)}if(mn(m)&&!i.force&&(i.json?J({ok:!1,diagnostics:m,wrote:[]}):process.stderr.write(Q.default.red(`errors present \u2014 not writing (use --force to override)
|
|
128
|
+
`)),process.exit(1)),i.dryRun){if(i.json)J({diagnostics:m,files:p});else for(let h of p)process.stdout.write(Q.default.cyan(`--- ${h.path}
|
|
129
|
+
`)+h.contents+`
|
|
130
|
+
`);return}for(let h of p){let $=(0,ne.join)(a,h.path);(0,Y.mkdirSync)((0,ne.dirname)($),{recursive:!0}),(0,Y.writeFileSync)($,h.contents),i.json||process.stdout.write(Q.default.green(`wrote ${h.path}
|
|
131
|
+
`))}i.json&&J({ok:!mn(m),diagnostics:m,wrote:p.map(h=>h.path)})});Te.command("validate").description("Validate the harness (structural + files + role handoffs + topology)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(i=>{let{dot:e,config:n,base:r}=Se(i);(0,Y.existsSync)(e)||(i.json?J({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
132
|
+
`)),process.exit(1));let{harness:o,parseErrors:s}=he(e,n),u=p=>(0,Y.existsSync)((0,ne.join)(r,p)),a=Yo(o,r),d=[...ln(o,{fileExists:u,roles:a}),...cn(o)],l=d.some(p=>p.level==="error")||s.length>0;if(i.json)J({ok:!l,parseErrors:s,diagnostics:d});else{for(let p of s)process.stderr.write(Q.default.red(`parse: ${p.message}
|
|
133
|
+
`));qt(d)}process.exit(l?1:0)});Te.command("graph").description("Print the harness topology (Mermaid, or --json for the IR)").option("--dot <path>","path to harness.dot").option("--json","output the parsed nodes/edges as JSON").action(i=>{let{dot:e}=Se(i);(0,Y.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
134
|
+
`)),process.exit(1));let{harness:n}=he(e);i.json?J({name:n.name,nodes:n.nodes,edges:n.edges}):process.stdout.write(qn(n)+`
|
|
135
|
+
`)});Te.command("explain <node>").description("Show the workflow a single node compiles to").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action((i,e)=>{let{dot:n,config:r}=Se(e);(0,Y.existsSync)(n)||(e.json?J({error:`no harness.dot at ${n}`}):process.stderr.write(Q.default.red(`no harness.dot at ${n} \u2014 run \`gp-foundry init\` first
|
|
136
|
+
`)),process.exit(1));let{harness:o}=he(n,r),{files:s}=Ke(o),u=s.find(a=>a.path.endsWith(`/${i}.yml`))??s.find(a=>a.path.startsWith(".github/workflows/")&&new RegExp(`^ ${i}:`,"m").test(a.contents));u||(e.json?J({error:`no generated workflow for node '${i}'`}):process.stderr.write(Q.default.red(`no generated workflow for node '${i}'
|
|
137
|
+
`)),process.exit(1)),e.json?J({node:i,path:u.path,contents:u.contents}):process.stdout.write(u.contents+`
|
|
138
|
+
`)});kr(Te);Te.parseAsync(process.argv);
|