@thegpvc/gp-foundry 0.2.7 → 0.2.8
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/dist/cli/index.cjs
CHANGED
|
@@ -22,17 +22,17 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
22
22
|
Expecting one of '${i.join("', '")}'`);let o=`${e}Help`;return this.on(o,s=>{let a;typeof t=="function"?a=t({error:s.error,command:s.command}):a=t,a&&s.write(`${a}
|
|
23
23
|
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Bt(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",o="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?o=s[3]:i=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],i=s[3],o=s[4]),t&&o!=="0"?`${t}=${i}:${parseInt(o)+1}`:e})}Ut.Command=nt});var Kt=Ce(le=>{"use strict";I();var{Argument:Gt}=An(),{Command:tt}=Vt(),{CommanderError:Rr,InvalidArgumentError:Wt}=Je(),{Help:Ir}=Yn(),{Option:Yt}=Xn();le.program=new tt;le.createCommand=r=>new tt(r);le.createOption=(r,e)=>new Yt(r,e);le.createArgument=(r,e)=>new Gt(r,e);le.Command=tt;le.Option=Yt;le.Argument=Gt;le.Help=Ir;le.CommanderError=Rr;le.InvalidArgumentError=Wt;le.InvalidOptionArgumentError=Wt});var Cn=Ce((rs,it)=>{"use strict";I();var xn=process||{},Xt=xn.argv||[],kn=xn.env||{},Pr=!(kn.NO_COLOR||Xt.includes("--no-color"))&&(!!kn.FORCE_COLOR||Xt.includes("--color")||xn.platform==="win32"||(xn.stdout||{}).isTTY&&kn.TERM!=="dumb"||!!kn.CI),Mr=(r,e,t=r)=>i=>{let o=""+i,s=o.indexOf(e,r.length);return~s?r+Fr(o,e,t,s)+e:r+o+e},Fr=(r,e,t,i)=>{let o="",s=0;do o+=r.substring(s,i)+t,s=i+e.length,i=r.indexOf(e,s);while(~i);return o+r.substring(s)},Qt=(r=Pr)=>{let e=r?Mr:()=>String;return{isColorSupported:r,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")}};it.exports=Qt();it.exports.createColors=Qt});I();I();var Jt=wn(Kt(),1),{program:Wo,createCommand:Yo,createArgument:Ko,createOption:Jo,CommanderError:zo,InvalidArgumentError:Xo,InvalidOptionArgumentError:Qo,Command:zt,Argument:Zo,Option:es,Help:ns}=Jt.default;var Q=wn(Cn(),1),dr=require("child_process"),Y=require("fs"),ne=require("path");I();I();I();var En=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function Zt(r){return r.uses!==void 0}I();function ze(r){let e=r.auth;return e?.mode?{mode:e.mode,appIdSecret:e.app_id_secret??r.identity.app_id_secret,appKeySecret:e.app_key_secret??r.identity.app_key_secret,tokenSecret:e.token_secret}:r.identity.app_id_secret&&r.identity.app_key_secret?{mode:"app",appIdSecret:r.identity.app_id_secret,appKeySecret:r.identity.app_key_secret}:{mode:"github-token"}}I();I();function Xe(r){return`\${{ secrets.${r} }}`}function Ee(r,e){if(!e)return"";let t=r.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function ue(r){let e=ze(r.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?Xe(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}function Sn(r){let e=ze(r.config);if(!(e.mode!=="app"||!e.appIdSecret||!e.appKeySecret))return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:{"app-id":Xe(e.appIdSecret),"private-key":Xe(e.appKeySecret)}}}function vn(r,e={}){let t={token:ue(r)};return e.ref&&(t.ref=e.ref),e.fetchDepth!==void 0&&(t["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:t}}function Le(){return{uses:"./.github/agent-setup",name:"Setup agent toolchain"}}function ei(r){let e=r.config.identity,t=e.git_name??e.bot_login??"gp-foundry agent",i=e.git_email??`${e.bot_login??"gp-foundry-agent"}@users.noreply.github.com`;return ye({name:"Configure git identity",env:{GIT_NAME:t,GIT_EMAIL:i},run:`git config user.name "$GIT_NAME"
|
|
24
24
|
git config user.email "$GIT_EMAIL"`})}function Qe(r,e,t){let i={type:e,number:t,token:ue(r)},o=r.config.identity?.bot_login;return o&&(i["trusted-authors"]=o),{uses:r.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:i}}function De(r,e){let t=r.node,i=r.config,o={"role-file":Ee(r,t.files.role),model:i.agent.model,"comms-file":Ee(r,"agents/communication.md"),"scope-path":Ee(r,"agents/scope.yaml"),"claude-code-oauth-token":Xe(i.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN"),"github-token":ue(r)};e.withContext&&(o["context-file"]="${{ steps.ctx.outputs.context-file }}"),i.agent.conventions&&(o.conventions=i.agent.conventions);let s=typeof t.attrs.secrets=="string"?t.attrs.secrets.split(",").map(u=>u.trim()).filter(Boolean):[],a=[...new Set([...i.agent.secrets??[],...s])];a.length&&(o["extra-env"]=a.map(u=>`${u}=${Xe(u)}`).join(`
|
|
25
|
-
`));let d=t.files.prompt;return d&&(o["prompt-override-file"]=Ee(r,d)),{uses:r.actionRef("run-agent"),name:"Run agent",with:o}}function ye(r){return{shell:"bash",...r}}function ot(r){let e=r.attrs.permissions;if(e===void 0)return{};if(typeof e!="string"||!e.trim())throw new Error(`node '${r.id}': permissions= must be a non-empty string like "id-token: write"`);let t={},i=e.split(",").filter(o=>o.trim());if(!i.length)throw new Error(`node '${r.id}': permissions= has no entries \u2014 expected e.g. "id-token: write"`);for(let o of i){let s=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!s)throw new Error(`node '${r.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);t[s[1]]=s[2]}return t}function ti(r,e){let t;try{t=ot(r)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var Re="${{ github.event.issue.number }}",Ze="${{ github.event.pull_request.number }}",On="${{ github.event.pull_request.head.sha }}",ni="${{ github.event.pull_request.head.ref }}";function Se(r,e){let t=r.attrs.timeout;return typeof t=="number"?t:e}var jr=
|
|
25
|
+
`));let d=t.files.prompt;return d&&(o["prompt-override-file"]=Ee(r,d)),{uses:r.actionRef("run-agent"),name:"Run agent",with:o}}function ye(r){return{shell:"bash",...r}}function ot(r){let e=r.attrs.permissions;if(e===void 0)return{};if(typeof e!="string"||!e.trim())throw new Error(`node '${r.id}': permissions= must be a non-empty string like "id-token: write"`);let t={},i=e.split(",").filter(o=>o.trim());if(!i.length)throw new Error(`node '${r.id}': permissions= has no entries \u2014 expected e.g. "id-token: write"`);for(let o of i){let s=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!s)throw new Error(`node '${r.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);t[s[1]]=s[2]}return t}function ti(r,e){let t;try{t=ot(r)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var Re="${{ github.event.issue.number }}",Ze="${{ github.event.pull_request.number }}",On="${{ github.event.pull_request.head.sha }}",ni="${{ github.event.pull_request.head.ref }}";function Se(r,e){let t=r.attrs.timeout;return typeof t=="number"?t:e}var jr=10;function st(r){return Math.max(1,r-jr)}function $n(r,e){let t=[],i=Sn(r);return i&&t.push(i),t.push(vn(r,e)),t.push(ei(r)),t}function rt(r){let e=r.node,t=e.context??"issue",i=t==="pr-diff"||t==="pr-review",o=i?{contents:"read","pull-requests":"write"}:{contents:"read",issues:"write"},s=[],a=Sn(r);a&&s.push(a),s.push(vn(r,i?{ref:On,fetchDepth:0}:void 0));let d=typeof e.attrs.gates=="string"?e.attrs.gates:void 0,u=i&&d?d.split(",").map(h=>h.trim()).filter(Boolean):[],c=u.map((h,g)=>Lr(`gate-${h}`,g,u));u.forEach((h,g)=>{s.push({uses:r.actionRef("wait-for-checks"),id:c[g],name:`Wait for ${h}`,with:{sha:On,"workflow-name":h,token:ue(r)}})}),s.push(Le());let f=t==="pr-diff"?"pr-diff":t==="pr-review"?"pr-review":"issue";return s.push(Qe(r,f,i?Ze:Re)),u.length&&s.push(Dr(u,c)),s.push(De(r,{withContext:!0})),{jobId:e.id,name:e.id,permissions:o,timeoutMinutes:Se(e,15+15*u.length),steps:s}}function Lr(r,e,t){let i=a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),o=i(r)||`gate-${e+1}`;return t.filter((a,d)=>d!==e&&i(`gate-${a}`)===o).length>0?`${o}-${e+1}`:o}function Dr(r,e){let t={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},i=["{",' echo ""',' echo "=== CI GATES ==="'];return r.forEach((o,s)=>{t[`GATE_${s+1}_NAME`]=o,t[`GATE_${s+1}_RESULT`]=`\${{ steps.${e[s]}.outputs.conclusion }}`,i.push(` echo "$GATE_${s+1}_NAME: $GATE_${s+1}_RESULT"`)}),i.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"'),ye({name:"Record CI gate results in the context",env:t,run:i.join(`
|
|
26
26
|
`)})}function qr(r){let e=r.node,t=r.config,i=$n(r);i.push(ye({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:Re,ISSUE_TITLE:"${{ github.event.issue.title }}",PREFIX:t.repo.branch_prefix},run:[`SLUG=$(printf '%s' "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-50 | sed 's/-$//')`,'BRANCH="$PREFIX$ISSUE_NUMBER-$SLUG"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
27
|
-
`)}));let o=Se(e,
|
|
27
|
+
`)}));let o=Se(e,35);return i.push(Le()),i.push(Qe(r,"issue",Re)),i.push({...De(r,{withContext:!0}),timeoutMinutes:st(o)}),i.push({uses:r.actionRef("agent-fallback"),name:"Fallback: commit / push / PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}",token:ue(r),"agent-name":e.id,"base-branch":t.repo.base_branch,"issue-number":Re,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
|
|
28
28
|
|
|
29
29
|
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
30
|
|
|
31
31
|
Closes #${Re}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:o,steps:i}}function Br(r){let e=r.node,t=$n(r,{ref:ni,fetchDepth:0}),i=typeof e.attrs.max_attempts=="number"?e.attrs.max_attempts:3,o=`<!-- gp-foundry:attempt:${e.id} -->`,s=r.config.labels?.["needs-human"]??"needs-human",a=r.config.identity?.bot_login??"";t.push(ye({id:"attempts",name:`Enforce attempt budget (max ${i})`,env:{GH_TOKEN:ue(r),PR:Ze,MARKER:o,MAX:String(i),BOT_LOGIN:a},run:["# One request-changes verdict = one attempt. The jq filter reads the bot","# login from the environment (never interpolated into the script), and an","# empty BOT_LOGIN counts any reviewer's request-changes.","# (--paginate emits one count per page, so the counts are summed.)",`COUNT=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," [ .[]",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',' | select(.state == "CHANGES_REQUESTED" or ((.body // "") | test("Verdict.*REQUEST_CHANGES")))'," ] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}')",'[ -n "$COUNT" ] || COUNT=0','echo "attempts so far: $COUNT / $MAX"','if [ "$COUNT" -gt "$MAX" ]; then',` gh pr edit "$PR" --add-label "${s}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${s}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${e.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${s}\` and stopping. A human should take this over.\\n\\n%s' "$COUNT" "$MAX" "$MARKER")"`,' echo "exhausted=true" >> "$GITHUB_OUTPUT"',"else",` gh pr comment "$PR" --body "$(printf '%s attempt %s of %s' "$MARKER" "$COUNT" "$MAX")" >/dev/null`,' echo "exhausted=false" >> "$GITHUB_OUTPUT"',"fi"].join(`
|
|
32
|
-
`)}));let d="steps.attempts.outputs.exhausted != 'true'";return t.push({...Le(),if:d}),t.push({...Qe(r,"pr-review",Ze),if:d}),t.push({...De(r,{withContext:!0}),if:d,timeoutMinutes:st(Se(e,
|
|
33
|
-
`)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:Se(e,
|
|
32
|
+
`)}));let d="steps.attempts.outputs.exhausted != 'true'";return t.push({...Le(),if:d}),t.push({...Qe(r,"pr-review",Ze),if:d}),t.push({...De(r,{withContext:!0}),if:d,timeoutMinutes:st(Se(e,35))}),t.push(ye({name:"Commit and push fixes",if:`${d} && !cancelled()`,env:{BRANCH:ni},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${e.id}"`,"fi","# ...then push if HEAD is ahead of the remote (the agent may have committed itself).",'git fetch origin "$BRANCH" --quiet 2>/dev/null || true','if [ "$(git rev-parse HEAD)" != "$(git rev-parse "origin/$BRANCH" 2>/dev/null || echo none)" ]; then',' git push origin "HEAD:$BRANCH"',' echo "pushed fix to $BRANCH"',"else",' echo "no changes to push"',"fi"].join(`
|
|
33
|
+
`)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:Se(e,35),steps:t}}function ii(r){return`gp-foundry/human-approval (${String(r.attrs.environment??"production")})`}var Ur="github-actions";function Vr(r){return`${ii(r)}@${Ur}`}function Gr(r){let e=r.node,t=$n(r,{fetchDepth:0}),o=r.inEdges.map(s=>r.nodeById?.(s.from)).filter(s=>!!s&&s.type==="human-gate").map(Vr);return t.push({uses:r.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:ue(r),"checks-token":"${{ github.token }}","policy-path":Ee(r,e.files.policy),"base-branch":r.config.repo.base_branch,"branch-prefix":r.config.repo.branch_prefix,...r.config.identity?.bot_login?{"bot-login":r.config.identity.bot_login}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:Se(e,10),steps:t}}function Wr(r){let e=r.node,t=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:t,steps:[ye({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:ii(e),HEAD_SHA:On,ENVIRONMENT:t},run:['if ! gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$CHECK_NAME" \\',' -f head_sha="$HEAD_SHA" \\'," -f status=completed \\"," -f conclusion=success \\"," -f 'output[title]=Approved' \\",' -f "output[summary]=Environment \\"$ENVIRONMENT\\" was approved by a human for $HEAD_SHA."; then',' echo "::error::Approved for $ENVIRONMENT, but publishing the approval check failed."',' echo "::error::The merge gate requires \\"$CHECK_NAME\\" on $HEAD_SHA, so this PR will not merge until it is published."'," exit 1","fi",'echo "Approved for $ENVIRONMENT."'].join(`
|
|
34
34
|
`)})]}}function Yr(r){let e=r.node,t=r.config,i=$n(r,{fetchDepth:0}),o=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",s=typeof e.attrs.paths=="string"?e.attrs.paths:"";return o==="pr"&&i.push(ye({id:"branch",name:"Create branch",env:{PREFIX:t.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}"},run:['BRANCH="$PREFIX$NODE-$RUN_ID"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
35
|
-
`)})),i.push(Le()),i.push({...De(r,{withContext:!1}),timeoutMinutes:st(Se(e,15))}),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,15),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+=`
|
|
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+=`
|
|
36
36
|
|
|
37
37
|
`+t.mark.snippet),s+" "+o):s}function e(t,i){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=i,this.message=r(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(i){return this.name+": "+r(this,i)},ct=e,ct}var ut,pi;function ao(){if(pi)return ut;pi=1;let r=tn();function e(o,s,a,d,u){let c="",f="",h=Math.floor(u/2)-1;return d-s>h&&(c=" ... ",s=d-h+c.length),a-d>h&&(f=" ...",a=d+h-f.length),{str:c+o.slice(s,a).replace(/\t/g,"\u2192")+f,pos:d-s+c.length}}function t(o,s){return r.repeat(" ",s-o.length)+o}function i(o,s){if(s=Object.create(s||null),!o.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);let a=/\r?\n|\r|\0/g,d=[0],u=[],c,f=-1;for(;c=a.exec(o.buffer);)u.push(c.index),d.push(c.index+c[0].length),o.position<=c.index&&f<0&&(f=d.length-2);f<0&&(f=d.length-1);let h="",g=Math.min(o.line+s.linesAfter,u.length).toString().length,k=s.maxLength-(s.indent+g+3);for(let E=1;E<=s.linesBefore&&!(f-E<0);E++){let v=e(o.buffer,d[f-E],u[f-E],o.position-(d[f]-d[f-E]),k);h=r.repeat(" ",s.indent)+t((o.line-E+1).toString(),g)+" | "+v.str+`
|
|
38
38
|
`+h}let $=e(o.buffer,d[f],u[f],o.position,k);h+=r.repeat(" ",s.indent)+t((o.line+1).toString(),g)+" | "+$.str+`
|
package/package.json
CHANGED
|
@@ -46,6 +46,7 @@ Rules of thumb:
|
|
|
46
46
|
| `commit="none\|pr\|direct"` | `scheduled-agent` | how the lane persists output: `direct` (default) commits to base; `pr` opens a reviewed PR; `none` no commit/push (read-only lane) |
|
|
47
47
|
| `secrets="A,B"` | agent types | extra Actions secrets exposed to THIS lane's env (unioned with global `agent.secrets`); least-privilege scoping, e.g. a Sentry token only on the sweeper |
|
|
48
48
|
| `permissions="id-token: write"` | any job-emitting type | extra GitHub token scopes merged into the job's `permissions:` block (the attr wins on conflict); comma-separated `<scope>: read\|write\|none`. The generic opt-in for GitHub-native capabilities — e.g. `id-token: write` lets a consumer-owned setup step mint an OIDC token and federate into a cloud provider, with all provider specifics in consumer-owned composites |
|
|
49
|
+
| `timeout=N` | agent types | job `timeout-minutes` (default 35 producer/pr-fix, 20 scheduled-agent). For lanes that run an agent with a salvage epilogue (producer, pr-fix, scheduled-agent) the agent's own step cap is derived as `N − 10`: the 10-min margin lets a cold-cache toolchain setup (~7 min) run and the commit/push/open-PR salvage finish within the job cap, so an over-running agent fails its STEP (salvage still runs) instead of being job-cancelled (#12545/#12611). Raise `N` to give the agent more working time; the margin stays 10 |
|
|
49
50
|
| `policy="policy/merge.yaml"` | `merge-gate` | merge-policy file |
|
|
50
51
|
| `schedule="*/30 * * * *"` | `merge-gate`, sweeps | cron cadence |
|
|
51
52
|
| `environment=NAME` | `human-gate` | GitHub Environment gating approval (**required** on human-gate) |
|