@thegpvc/gp-foundry 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/agent-context/README.md +60 -9
- package/actions/agent-context/action.yml +22 -1
- package/actions/agent-context/dist/index.cjs +79 -45
- package/actions/config-loader/dist/index.cjs +1 -1
- package/actions/run-agent/README.md +9 -0
- package/actions/run-agent/action.yml +84 -0
- package/actions/sanitize-untrusted-input/README.md +24 -5
- package/actions/sanitize-untrusted-input/dist/index.cjs +30 -28
- package/actions/setup-agent/README.md +1 -0
- package/actions/setup-agent/action.yml +13 -1
- package/dist/cli/index.cjs +120 -111
- package/package.json +1 -1
- package/schema/config.schema.json +7 -1
- package/skill/reference/node-types.md +28 -2
- package/skill/templates/foundry.config.yaml +1 -0
- package/skill/templates/scope.yaml +2 -1
|
@@ -81,7 +81,7 @@ ${s}`;break;case"retry":Rw(s)&&(A[n]=s);break;case"id":bw(s)&&(A[n]=s);break;cas
|
|
|
81
81
|
`+h.slice(R,M),R=M+1),N=G;return Y+=`
|
|
82
82
|
`,h.length-R>m&&N>R?Y+=h.slice(R,N)+`
|
|
83
83
|
`+h.slice(N+1):Y+=h.slice(R),Y.slice(1)}function Al(h){let m="",F=0;for(let k=0;k<h.length;F>=65536?k+=2:k++){F=mA(h,k);let R=pe[F];!R&&OA(F)?(m+=h[k],F>=65536&&(m+=h[k+1])):m+=R||CA(F)}return m}function ho(h,m,F){let k="",R=h.tag;for(let M=0,N=F.length;M<N;M+=1){let G=F[M];h.replacer&&(G=h.replacer.call(F,String(M),G)),(D(h,m,G,!1,!1)||typeof G>"u"&&D(h,m,null,!1,!1))&&(k!==""&&(k+=","+(h.condenseFlow?"":" ")),k+=h.dump)}h.tag=R,h.dump="["+k+"]"}function fo(h,m,F,k){let R="",M=h.tag;for(let N=0,G=F.length;N<G;N+=1){let Y=F[N];h.replacer&&(Y=h.replacer.call(F,String(N),Y)),(D(h,m+1,Y,!0,!0,!1,!0)||typeof Y>"u"&&D(h,m+1,null,!0,!0,!1,!0))&&((!k||R!=="")&&(R+=sn(h,m)),h.dump&&o===h.dump.charCodeAt(0)?R+="-":R+="- ",R+=h.dump)}h.tag=M,h.dump=R||"[]"}function rl(h,m,F){let k="",R=h.tag,M=Object.keys(F);for(let N=0,G=M.length;N<G;N+=1){let Y="";k!==""&&(Y+=", "),h.condenseFlow&&(Y+='"');let H=M[N],P=F[H];h.replacer&&(P=h.replacer.call(F,H,P)),D(h,m,H,!1,!1)&&(h.dump.length>1024&&(Y+="? "),Y+=h.dump+(h.condenseFlow?'"':"")+":"+(h.condenseFlow?"":" "),D(h,m,P,!1,!1)&&(Y+=h.dump,k+=Y))}h.tag=R,h.dump="{"+k+"}"}function a(h,m,F,k){let R="",M=h.tag,N=Object.keys(F);if(h.sortKeys===!0)N.sort();else if(typeof h.sortKeys=="function")N.sort(h.sortKeys);else if(h.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let G=0,Y=N.length;G<Y;G+=1){let H="";(!k||R!=="")&&(H+=sn(h,m));let P=N[G],ce=F[P];if(h.replacer&&(ce=h.replacer.call(F,P,ce)),!D(h,m+1,P,!0,!0,!0))continue;let De=h.tag!==null&&h.tag!=="?"||h.dump&&h.dump.length>1024;De&&(h.dump&&o===h.dump.charCodeAt(0)?H+="?":H+="? "),H+=h.dump,De&&(H+=sn(h,m)),D(h,m+1,ce,!0,De)&&(h.dump&&o===h.dump.charCodeAt(0)?H+=":":H+=": ",H+=h.dump,R+=H)}h.tag=M,h.dump=R||"{}"}function p(h,m,F){let k=F?h.explicitTypes:h.implicitTypes;for(let R=0,M=k.length;R<M;R+=1){let N=k[R];if((N.instanceOf||N.predicate)&&(!N.instanceOf||typeof m=="object"&&m instanceof N.instanceOf)&&(!N.predicate||N.predicate(m))){if(F?N.multi&&N.representName?h.tag=N.representName(m):h.tag=N.tag:h.tag="?",N.represent){let G=h.styleMap[N.tag]||N.defaultStyle,Y;if(r.call(N.represent)==="[object Function]")Y=N.represent(m,G);else if(n.call(N.represent,G))Y=N.represent[G](m,G);else throw new e("!<"+N.tag+'> tag resolver accepts not "'+G+'" style');h.dump=Y}return!0}}return!1}function D(h,m,F,k,R,M,N){h.tag=null,h.dump=F,p(h,F,!1)||p(h,F,!0);let G=r.call(h.dump),Y=k;k&&(k=h.flowLevel<0||h.flowLevel>m);let H=G==="[object Object]"||G==="[object Array]",P,ce;if(H&&(P=h.duplicates.indexOf(F),ce=P!==-1),(h.tag!==null&&h.tag!=="?"||ce||h.indent!==2&&m>0)&&(R=!1),ce&&h.usedDuplicates[P])h.dump="*ref_"+P;else{if(H&&ce&&!h.usedDuplicates[P]&&(h.usedDuplicates[P]=!0),G==="[object Object]")k&&Object.keys(h.dump).length!==0?(a(h,m,h.dump,R),ce&&(h.dump="&ref_"+P+h.dump)):(rl(h,m,h.dump),ce&&(h.dump="&ref_"+P+" "+h.dump));else if(G==="[object Array]")k&&h.dump.length!==0?(h.noArrayIndent&&!N&&m>0?fo(h,m-1,h.dump,R):fo(h,m,h.dump,R),ce&&(h.dump="&ref_"+P+h.dump)):(ho(h,m,h.dump),ce&&(h.dump="&ref_"+P+" "+h.dump));else if(G==="[object String]")h.tag!=="?"&&el(h,h.dump,m,M,Y);else{if(G==="[object Undefined]")return!1;if(h.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+G)}if(h.tag!==null&&h.tag!=="?"){let De=encodeURI(h.tag[0]==="!"?h.tag.slice(1):h.tag).replace(/!/g,"%21");h.tag[0]==="!"?De="!"+De:De.slice(0,18)==="tag:yaml.org,2002:"?De="!!"+De.slice(18):De="!<"+De+">",h.dump=De+" "+h.dump}}return!0}function b(h,m){let F=[],k=[];w(h,F,k);let R=k.length;for(let M=0;M<R;M+=1)m.duplicates.push(F[k[M]]);m.usedDuplicates=new Array(R)}function w(h,m,F){if(h!==null&&typeof h=="object"){let k=m.indexOf(h);if(k!==-1)F.indexOf(k)===-1&&F.push(k);else if(m.push(h),Array.isArray(h))for(let R=0,M=h.length;R<M;R+=1)w(h[R],m,F);else{let R=Object.keys(h);for(let M=0,N=R.length;M<N;M+=1)w(h[R[M]],m,F)}}}function L(h,m){m=m||{};let F=new Xc(m);F.noRefs||b(h,F);let k=h;return F.replacer&&(k=F.replacer.call({"":k},"",k)),D(F,0,k,!0,!0)?F.dump+`
|
|
84
|
-
`:""}return nd.dump=L,nd}var p0;function NG(){if(p0)return Xe;p0=1;let t=bG(),e=SG();function A(r,n){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}return Xe.Type=ot(),Xe.Schema=m0(),Xe.FAILSAFE_SCHEMA=k0(),Xe.JSON_SCHEMA=F0(),Xe.CORE_SCHEMA=M0(),Xe.DEFAULT_SCHEMA=sd(),Xe.load=t.load,Xe.loadAll=t.loadAll,Xe.dump=e.dump,Xe.YAMLException=Si(),Xe.types={binary:T0(),float:N0(),map:D0(),null:R0(),pairs:x0(),set:Y0(),timestamp:U0(),bool:b0(),int:S0(),merge:L0(),omap:v0(),seq:w0(),str:y0()},Xe.safeLoad=A("safeLoad","load"),Xe.safeLoadAll=A("safeLoadAll","loadAll"),Xe.safeDump=A("safeDump","dump"),Xe}var FG=NG(),id=kG(FG),{Type:M$,Schema:U$,FAILSAFE_SCHEMA:L$,JSON_SCHEMA:T$,CORE_SCHEMA:v$,DEFAULT_SCHEMA:x$,load:Y$,loadAll:G$,dump:_$,YAMLException:J$,types:H$,safeLoad:q$,safeLoadAll:V$,safeDump:O$}=id;var tE=Ht(Wf(),1),AE=Ht(bR(),1);var SR={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://gp-foundry/schema/config.schema.json",title:"FoundryConfig",description:"Consumer-repo global config (foundry.config.yaml). Mirrors src/ir/types.ts FoundryConfig, extended with an optional `personas` map keyed by node/role for per-persona overrides.",type:"object",required:["name","identity","agent","repo","labels"],additionalProperties:!0,properties:{name:{type:"string",minLength:1,description:"Human-readable name of the harness/agent fleet."},identity:{type:"object",additionalProperties:!1,description:"How the agent authenticates and signs commits. Generalized: no hardcoded bot login or app-secret names.",properties:{app_id_secret:{type:"string",description:"Name of the Actions secret holding the GitHub App id."},app_key_secret:{type:"string",description:"Name of the Actions secret holding the GitHub App private key."},bot_login:{type:"string",description:'The bot login used for commits/PRs, e.g. "my-agent[bot]".'},git_name:{type:"string"},git_email:{type:"string",format:"email"}}},agent:{type:"object",required:["cli","model"],additionalProperties:!1,description:"The coding-agent CLI + default model.",properties:{cli:{type:"string",minLength:1,description:'The agent CLI binary, e.g. "claude".'},model:{type:"string",minLength:1,description:'Default model id, e.g. "claude-opus-4-8".'},oauth_token_secret:{type:"string",description:"Name of the Actions secret holding the agent OAuth token."},api_key_secret:{type:"string",description:"Name of the Actions secret holding an Anthropic API key. When set, agents authenticate with it INSTEAD of the OAuth token: usage-billed and not bound to one person's subscription seat."},allowed_tools:{$ref:"#/$defs/allowedTools",description:"Default allowed-tools list for the agent CLI."}}},repo:{type:"object",required:["base_branch","branch_prefix"],additionalProperties:!1,properties:{base_branch:{type:"string",minLength:1},branch_prefix:{type:"string",minLength:1}}},labels:{type:"object",description:"semantic role -> repo label (the drift-killer).",additionalProperties:{type:"string"}},markers:{type:"object",description:"parseable markers shared by prompts + guards + enforcers.",additionalProperties:{type:"string"}},size:{type:"object",additionalProperties:!1,properties:{warn_additions:{type:"integer",minimum:0},hard_additions:{type:"integer",minimum:0},exclude_globs:{type:"array",items:{type:"string"}}}},runtime:{type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["pinned","vendored"]},ref:{type:"string"},owner_repo:{type:"string"}}},personas:{type:"object",description:"Per-node/per-role overrides, keyed by the node/persona key passed as the `node` input. Any field here shadows the top-level default when that persona is resolved.",additionalProperties:{$ref:"#/$defs/persona"}}},$defs:{allowedTools:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},persona:{type:"object",additionalProperties:!0,description:"Overrides for one persona/role. Every field is optional; unspecified fields fall back to the top-level config.",properties:{model:{type:"string",minLength:1},cli:{type:"string",minLength:1},allowed_tools:{$ref:"#/$defs/allowedTools"},labels:{type:"object",additionalProperties:{type:"string"}},identity:{type:"object",additionalProperties:!1,properties:{app_id_secret:{type:"string"},app_key_secret:{type:"string"},bot_login:{type:"string"},git_name:{type:"string"},git_email:{type:"string",format:"email"}}}}}}};var LO=tE.default.default??tE.default,TO=AE.default.default??AE.default,Kc=null;function vO(){if(Kc)return Kc;let t=new LO({allErrors:!0,allowUnionTypes:!0});return TO(t),Kc=t.compile(SR),Kc}function FR(t){return t==null?[]:(Array.isArray(t)?t:t.split(",")).map(A=>A.trim()).filter(A=>A.length>0)}function MR(t,e){let A=e!=null&&t.personas?t.personas[e]??{}:{};e!=null&&t.personas&&!(e in t.personas)&&zw(`config-loader: node "${e}" has no persona entry; using top-level defaults.`);let r={...t.identity,...A.identity??{}},n={...t.labels,...A.labels??{}},s=FR(A.allowed_tools??t.agent.allowed_tools);return{name:t.name,node:e,model:A.model??t.agent.model,cli:A.cli??t.agent.cli,allowedTools:s,labels:n,identity:r,oauthTokenSecret:t.agent.oauth_token_secret??null,repo:t.repo,markers:t.markers??{},size:t.size??null,runtime:t.runtime??null}}function UR(t){let e;try{e=(0,NR.readFileSync)(t,"utf8")}catch(n){throw new Error(`config-loader: could not read config at "${t}": ${n.message}`)}let A;try{A=id.load(e)}catch(n){throw new Error(`config-loader: failed to parse YAML at "${t}": ${n.message}`)}if(A==null||typeof A!="object"||Array.isArray(A))throw new Error(`config-loader: config at "${t}" must be a YAML mapping.`);let r=vO();if(!r(A)){let n=(r.errors??[]).map(s=>` - ${s.instancePath||"/"} ${s.message??"is invalid"}`).join(`
|
|
84
|
+
`:""}return nd.dump=L,nd}var p0;function NG(){if(p0)return Xe;p0=1;let t=bG(),e=SG();function A(r,n){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}return Xe.Type=ot(),Xe.Schema=m0(),Xe.FAILSAFE_SCHEMA=k0(),Xe.JSON_SCHEMA=F0(),Xe.CORE_SCHEMA=M0(),Xe.DEFAULT_SCHEMA=sd(),Xe.load=t.load,Xe.loadAll=t.loadAll,Xe.dump=e.dump,Xe.YAMLException=Si(),Xe.types={binary:T0(),float:N0(),map:D0(),null:R0(),pairs:x0(),set:Y0(),timestamp:U0(),bool:b0(),int:S0(),merge:L0(),omap:v0(),seq:w0(),str:y0()},Xe.safeLoad=A("safeLoad","load"),Xe.safeLoadAll=A("safeLoadAll","loadAll"),Xe.safeDump=A("safeDump","dump"),Xe}var FG=NG(),id=kG(FG),{Type:M$,Schema:U$,FAILSAFE_SCHEMA:L$,JSON_SCHEMA:T$,CORE_SCHEMA:v$,DEFAULT_SCHEMA:x$,load:Y$,loadAll:G$,dump:_$,YAMLException:J$,types:H$,safeLoad:q$,safeLoadAll:V$,safeDump:O$}=id;var tE=Ht(Wf(),1),AE=Ht(bR(),1);var SR={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://gp-foundry/schema/config.schema.json",title:"FoundryConfig",description:"Consumer-repo global config (foundry.config.yaml). Mirrors src/ir/types.ts FoundryConfig, extended with an optional `personas` map keyed by node/role for per-persona overrides.",type:"object",required:["name","identity","agent","repo","labels"],additionalProperties:!0,properties:{name:{type:"string",minLength:1,description:"Human-readable name of the harness/agent fleet."},identity:{type:"object",additionalProperties:!1,description:"How the agent authenticates and signs commits. Generalized: no hardcoded bot login or app-secret names.",properties:{app_id_secret:{type:"string",description:"Name of the Actions secret holding the GitHub App id."},app_key_secret:{type:"string",description:"Name of the Actions secret holding the GitHub App private key."},bot_login:{type:"string",description:'The bot login used for commits/PRs, e.g. "my-agent[bot]".'},git_name:{type:"string"},git_email:{type:"string",format:"email"}}},agent:{type:"object",required:["cli","model"],additionalProperties:!1,description:"The coding-agent CLI + default model.",properties:{cli:{type:"string",minLength:1,description:'The agent CLI binary, e.g. "claude".'},model:{type:"string",minLength:1,description:'Default model id, e.g. "claude-opus-4-8".'},oauth_token_secret:{type:"string",description:"Name of the Actions secret holding the agent OAuth token."},api_key_secret:{type:"string",description:"Name of the Actions secret holding an Anthropic API key. When set, agents authenticate with it INSTEAD of the OAuth token: usage-billed and not bound to one person's subscription seat."},allowed_tools:{$ref:"#/$defs/allowedTools",description:"Default allowed-tools list for the agent CLI."}}},repo:{type:"object",required:["base_branch","branch_prefix"],additionalProperties:!1,properties:{base_branch:{type:"string",minLength:1},branch_prefix:{type:"string",minLength:1},authors:{type:"array",minItems:1,items:{type:"string",minLength:1},description:"Only pull requests opened by these GitHub logins reach the PR lanes (pr-review, pr-fix, PR-context analysts, review panels, sweeps). Case-insensitive. A node's own authors= attribute overrides it for that lane."}}},labels:{type:"object",description:"semantic role -> repo label (the drift-killer).",additionalProperties:{type:"string"}},markers:{type:"object",description:"parseable markers shared by prompts + guards + enforcers.",additionalProperties:{type:"string"}},size:{type:"object",additionalProperties:!1,properties:{warn_additions:{type:"integer",minimum:0},hard_additions:{type:"integer",minimum:0},exclude_globs:{type:"array",items:{type:"string"}}}},runtime:{type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["pinned","vendored"]},ref:{type:"string"},owner_repo:{type:"string"}}},personas:{type:"object",description:"Per-node/per-role overrides, keyed by the node/persona key passed as the `node` input. Any field here shadows the top-level default when that persona is resolved.",additionalProperties:{$ref:"#/$defs/persona"}}},$defs:{allowedTools:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},persona:{type:"object",additionalProperties:!0,description:"Overrides for one persona/role. Every field is optional; unspecified fields fall back to the top-level config.",properties:{model:{type:"string",minLength:1},cli:{type:"string",minLength:1},allowed_tools:{$ref:"#/$defs/allowedTools"},labels:{type:"object",additionalProperties:{type:"string"}},identity:{type:"object",additionalProperties:!1,properties:{app_id_secret:{type:"string"},app_key_secret:{type:"string"},bot_login:{type:"string"},git_name:{type:"string"},git_email:{type:"string",format:"email"}}}}}}};var LO=tE.default.default??tE.default,TO=AE.default.default??AE.default,Kc=null;function vO(){if(Kc)return Kc;let t=new LO({allErrors:!0,allowUnionTypes:!0});return TO(t),Kc=t.compile(SR),Kc}function FR(t){return t==null?[]:(Array.isArray(t)?t:t.split(",")).map(A=>A.trim()).filter(A=>A.length>0)}function MR(t,e){let A=e!=null&&t.personas?t.personas[e]??{}:{};e!=null&&t.personas&&!(e in t.personas)&&zw(`config-loader: node "${e}" has no persona entry; using top-level defaults.`);let r={...t.identity,...A.identity??{}},n={...t.labels,...A.labels??{}},s=FR(A.allowed_tools??t.agent.allowed_tools);return{name:t.name,node:e,model:A.model??t.agent.model,cli:A.cli??t.agent.cli,allowedTools:s,labels:n,identity:r,oauthTokenSecret:t.agent.oauth_token_secret??null,repo:t.repo,markers:t.markers??{},size:t.size??null,runtime:t.runtime??null}}function UR(t){let e;try{e=(0,NR.readFileSync)(t,"utf8")}catch(n){throw new Error(`config-loader: could not read config at "${t}": ${n.message}`)}let A;try{A=id.load(e)}catch(n){throw new Error(`config-loader: failed to parse YAML at "${t}": ${n.message}`)}if(A==null||typeof A!="object"||Array.isArray(A))throw new Error(`config-loader: config at "${t}" must be a YAML mapping.`);let r=vO();if(!r(A)){let n=(r.errors??[]).map(s=>` - ${s.instancePath||"/"} ${s.message??"is invalid"}`).join(`
|
|
85
85
|
`);throw new Error(`config-loader: config at "${t}" failed schema validation:
|
|
86
86
|
${n}`)}return A}function LR(){let t=vh("config-path",{required:!0}),e=vh("node"),A=e.trim()===""?null:e.trim(),r=UR(t),n=MR(r,A);Ft("name",n.name),Ft("model",n.model),Ft("cli",n.cli),Ft("allowed-tools",n.allowedTools.join(",")),Ft("labels-json",JSON.stringify(n.labels)),Ft("bot-login",n.identity.bot_login??""),Ft("git-name",n.identity.git_name??""),Ft("git-email",n.identity.git_email??""),Ft("app-id-secret",n.identity.app_id_secret??""),Ft("app-key-secret",n.identity.app_key_secret??""),Ft("oauth-token-secret",n.oauthTokenSecret??""),Ft("json",JSON.stringify(n)),jw(`config-loader: resolved "${n.name}"`+(A?` (persona: ${A})`:"")+` \u2192 model=${n.model}, cli=${n.cli}, tools=[${n.allowedTools.join(", ")}]`)}var xO=process.env.GITHUB_ACTIONS==="true"||process.env.CONFIG_LOADER_RUN==="1";if(xO)try{LR()}catch(t){$w(t.message)}0&&(module.exports={loadConfig,normalizeTools,resolveConfig,run});
|
|
87
87
|
/*! Bundled license information:
|
|
@@ -41,6 +41,9 @@ Rationale: the agent reads *who it is* and *what to do* before it reads the
|
|
|
41
41
|
| `claude-code-oauth-token` | one of | `""` | OAuth token (one subscription seat); passed explicitly (composites have no `secrets`). |
|
|
42
42
|
| `anthropic-api-key` | one of | `""` | Anthropic API key (usage-billed, no seat). Pass exactly one of the two credentials; both or neither fails the step. |
|
|
43
43
|
| `github-token` | no | `""` | Token for the agent's own `gh`/git calls (`GH_TOKEN`/`GITHUB_TOKEN`). |
|
|
44
|
+
| `repo-guides` | no | `true` | `false` excludes every `CLAUDE.md` / `AGENTS.md` under the workspace from the CLI's auto-load (`--settings` `claudeMdExcludes`). |
|
|
45
|
+
| `step-summary` | no | `true` | Write the agent's final output to the job summary (truncated at 900 KB with a pointer to the log). |
|
|
46
|
+
| `step-summary-heading` | no | `Agent output` | Heading for that job-summary section. |
|
|
44
47
|
| `comms-file` | no | `.github/agents/communication.md` | Team communication guide, included verbatim if it exists. |
|
|
45
48
|
| `extra-args` | no | `""` | Extra args appended verbatim to the `claude` invocation. |
|
|
46
49
|
| `extra-env` | no | `""` | Newline-separated `NAME=VALUE` pairs exported before the CLI runs. |
|
|
@@ -53,6 +56,12 @@ Rationale: the agent reads *who it is* and *what to do* before it reads the
|
|
|
53
56
|
`claude -p --model <model> --allowedTools <allowed-tools> <extra-args> < <promptfile>`.
|
|
54
57
|
- `stderr` is captured to a file. If non-empty, it is emitted as a single
|
|
55
58
|
`::warning::` group. `stdout` streams to the job log normally.
|
|
59
|
+
- Everything the agent prints is wrapped in `::stop-commands::<random token>` /
|
|
60
|
+
`::<token>::`, so a line such as `::error::…` or `::add-mask::…` in a quoted
|
|
61
|
+
diff is logged as text instead of being executed as a workflow command.
|
|
62
|
+
- With no `github-token`, `GH_TOKEN`/`GITHUB_TOKEN` are removed from the agent's
|
|
63
|
+
environment (the compiler withholds the token from a role whose `tools:` cannot
|
|
64
|
+
run `gh`); a role that does list `gh` gets a warning that its calls are anonymous.
|
|
56
65
|
- A nonzero exit **fails the step**, preserving the CLI's own exit code. PR lanes
|
|
57
66
|
preserve partial output through guarded fallback steps. Failed direct-commit
|
|
58
67
|
scheduled lanes recover output on a separate PR labeled `needs-human`; they
|
|
@@ -81,6 +81,28 @@ inputs:
|
|
|
81
81
|
(passthrough for flags like --max-turns, --add-dir, etc.).
|
|
82
82
|
required: false
|
|
83
83
|
default: ""
|
|
84
|
+
repo-guides:
|
|
85
|
+
description: >-
|
|
86
|
+
Whether the CLI auto-loads the repository's own CLAUDE.md / AGENTS.md files
|
|
87
|
+
into every turn. "true" (default) leaves the CLI's behaviour alone. "false"
|
|
88
|
+
excludes every CLAUDE.md and AGENTS.md under the workspace (via
|
|
89
|
+
`--settings` `claudeMdExcludes`): the role, conventions and scope are then
|
|
90
|
+
the whole of the agent's standing instructions. For a repo whose guide is
|
|
91
|
+
large, that is a real share of every turn's input.
|
|
92
|
+
required: false
|
|
93
|
+
default: "true"
|
|
94
|
+
step-summary:
|
|
95
|
+
description: >-
|
|
96
|
+
Write the agent's final output to the job summary ($GITHUB_STEP_SUMMARY) under a
|
|
97
|
+
heading, so a reviewer can read it without opening the log. "true" (default) or
|
|
98
|
+
"false". Output over the summary size limit is truncated with a note; the log keeps
|
|
99
|
+
the full text.
|
|
100
|
+
required: false
|
|
101
|
+
default: "true"
|
|
102
|
+
step-summary-heading:
|
|
103
|
+
description: Heading for the job-summary section. Defaults to "Agent output".
|
|
104
|
+
required: false
|
|
105
|
+
default: "Agent output"
|
|
84
106
|
max-attempts:
|
|
85
107
|
description: >-
|
|
86
108
|
How many times to run the CLI when it exits non-zero for a reason that is
|
|
@@ -199,6 +221,9 @@ runs:
|
|
|
199
221
|
EXTRA_ENV: ${{ inputs.extra-env }}
|
|
200
222
|
MAX_ATTEMPTS: ${{ inputs.max-attempts }}
|
|
201
223
|
RETRY_BASE_DELAY_SECONDS: ${{ inputs.retry-base-delay-seconds }}
|
|
224
|
+
STEP_SUMMARY: ${{ inputs.step-summary }}
|
|
225
|
+
REPO_GUIDES: ${{ inputs.repo-guides }}
|
|
226
|
+
STEP_SUMMARY_HEADING: ${{ inputs.step-summary-heading }}
|
|
202
227
|
run: |
|
|
203
228
|
set -uo pipefail
|
|
204
229
|
|
|
@@ -251,6 +276,35 @@ runs:
|
|
|
251
276
|
echo "::warning::no allowed-tools input and no tools: in role front-matter; claude will use its defaults"
|
|
252
277
|
fi
|
|
253
278
|
|
|
279
|
+
# No token was passed (the compiler withholds it from a role whose tools
|
|
280
|
+
# cannot use it): drop the empty variables rather than leave them set, and
|
|
281
|
+
# say so if the role has since gained `gh` — its calls would be anonymous.
|
|
282
|
+
if [ -z "${GH_TOKEN:-}" ]; then
|
|
283
|
+
unset GH_TOKEN GITHUB_TOKEN
|
|
284
|
+
case ",${ALLOWED_TOOLS}," in
|
|
285
|
+
*"(gh:"*|*"(gh "*|*"(gh)"*) echo "::warning::run-agent: the role's tools mention gh but no github-token was passed — its gh calls will be unauthenticated. If the role gained gh recently, re-run \`gp-foundry build\`." ;;
|
|
286
|
+
esac
|
|
287
|
+
fi
|
|
288
|
+
|
|
289
|
+
# repo-guides=false: keep the repo's own CLAUDE.md / AGENTS.md out of the
|
|
290
|
+
# CLI's auto-loaded memory. The patterns are absolute, so they are built
|
|
291
|
+
# here, where the workspace path is known. Passed as its own argv entry —
|
|
292
|
+
# EXTRA_ARGS is word-split and could not carry a JSON value intact.
|
|
293
|
+
SETTINGS_ARGS=()
|
|
294
|
+
if [ "${REPO_GUIDES:-true}" = "false" ]; then
|
|
295
|
+
WS="${GITHUB_WORKSPACE:-$PWD}"
|
|
296
|
+
SETTINGS_JSON="$(printf '{"claudeMdExcludes":["%s/CLAUDE.md","%s/AGENTS.md","%s/**/CLAUDE.md","%s/**/AGENTS.md"]}' "$WS" "$WS" "$WS" "$WS")"
|
|
297
|
+
SETTINGS_ARGS=(--settings "$SETTINGS_JSON")
|
|
298
|
+
echo "::notice::run-agent: repo-guides=false — CLAUDE.md / AGENTS.md under ${WS} are not auto-loaded"
|
|
299
|
+
fi
|
|
300
|
+
|
|
301
|
+
# Everything the agent prints is DATA. A review that quotes a diff can
|
|
302
|
+
# contain a line like "::error::…" or "::add-mask::…", and the runner
|
|
303
|
+
# would execute it as a workflow command. stop-commands suspends command
|
|
304
|
+
# processing until the matching token; the token is random and never
|
|
305
|
+
# exported, so nothing the agent prints can end the suspension early.
|
|
306
|
+
stop_token() { printf 'gpf-%s' "$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')"; }
|
|
307
|
+
|
|
254
308
|
STDERR_LOG="$(mktemp)"
|
|
255
309
|
STDOUT_LOG="$(mktemp)"
|
|
256
310
|
EXIT_FILE="$(mktemp)"
|
|
@@ -315,19 +369,29 @@ runs:
|
|
|
315
369
|
# shellcheck disable=SC2086
|
|
316
370
|
# The prompt goes in on stdin, not argv: Linux limits each argument to
|
|
317
371
|
# 128 KiB and a large PR diff exceeds it.
|
|
372
|
+
STOP="$(stop_token)"
|
|
373
|
+
echo "::stop-commands::${STOP}"
|
|
318
374
|
( set +e
|
|
319
375
|
claude -p \
|
|
320
376
|
--model "$MODEL" \
|
|
321
377
|
--allowedTools "$ALLOWED_TOOLS" \
|
|
378
|
+
${SETTINGS_ARGS[@]+"${SETTINGS_ARGS[@]}"} \
|
|
322
379
|
$EXTRA_ARGS \
|
|
323
380
|
< "$PROMPT_FILE" 2> "$STDERR_LOG"
|
|
324
381
|
echo $? > "$EXIT_FILE" ) | tee "$STDOUT_LOG"
|
|
382
|
+
# The resume marker must start a line, whatever the output ended with.
|
|
383
|
+
echo
|
|
384
|
+
echo "::${STOP}::"
|
|
325
385
|
AGENT_EXIT="$(cat "$EXIT_FILE" 2>/dev/null || echo 1)"
|
|
326
386
|
[ -n "$AGENT_EXIT" ] || AGENT_EXIT=1
|
|
327
387
|
|
|
328
388
|
if [ -s "$STDERR_LOG" ]; then
|
|
329
389
|
echo "::warning::Claude produced stderr output:"
|
|
390
|
+
STOP="$(stop_token)"
|
|
391
|
+
echo "::stop-commands::${STOP}"
|
|
330
392
|
cat "$STDERR_LOG"
|
|
393
|
+
echo
|
|
394
|
+
echo "::${STOP}::"
|
|
331
395
|
fi
|
|
332
396
|
|
|
333
397
|
if [ "$AGENT_EXIT" -eq 0 ]; then
|
|
@@ -356,6 +420,26 @@ runs:
|
|
|
356
420
|
DELAY=$((DELAY * 2))
|
|
357
421
|
done
|
|
358
422
|
|
|
423
|
+
# The final message is the product of an analyst lane. Put it where a
|
|
424
|
+
# person looks first: the job summary. GitHub caps a summary at 1 MiB, so
|
|
425
|
+
# a long output is cut with a pointer to the log, which keeps all of it.
|
|
426
|
+
if [ "${STEP_SUMMARY:-true}" = "true" ] && [ -n "${GITHUB_STEP_SUMMARY:-}" ] && [ -s "$STDOUT_LOG" ]; then
|
|
427
|
+
SUMMARY_LIMIT=900000
|
|
428
|
+
{
|
|
429
|
+
echo "### ${STEP_SUMMARY_HEADING:-Agent output}"
|
|
430
|
+
echo
|
|
431
|
+
if [ "$(wc -c < "$STDOUT_LOG")" -gt "$SUMMARY_LIMIT" ]; then
|
|
432
|
+
head -c "$SUMMARY_LIMIT" "$STDOUT_LOG"
|
|
433
|
+
echo
|
|
434
|
+
echo
|
|
435
|
+
echo "_Output truncated at ${SUMMARY_LIMIT} bytes; the job log has the full text._"
|
|
436
|
+
else
|
|
437
|
+
cat "$STDOUT_LOG"
|
|
438
|
+
fi
|
|
439
|
+
echo
|
|
440
|
+
} >> "$GITHUB_STEP_SUMMARY"
|
|
441
|
+
fi
|
|
442
|
+
|
|
359
443
|
if [ "$AGENT_EXIT" -ne 0 ]; then
|
|
360
444
|
echo "::error::agent exited with code $AGENT_EXIT — failing the step so the run is visibly red"
|
|
361
445
|
exit "$AGENT_EXIT"
|
|
@@ -25,14 +25,33 @@ Applied in order by `sanitize()`:
|
|
|
25
25
|
2. **Length cap** — truncate the raw input to `maxLength` (default 20k chars) to
|
|
26
26
|
blunt context-stuffing and cost attacks; truncation is annotated.
|
|
27
27
|
3. **Injection neutralization** — replace high-signal hijack markers
|
|
28
|
-
(`ignore previous instructions`, `you are now…`,
|
|
28
|
+
(`ignore previous instructions`, `disregard the above`, `you are now…`,
|
|
29
29
|
ChatML/`[INST]` special tokens, `<system>` tags, `reveal your prompt`,
|
|
30
30
|
covert "without telling the user" directives, …) with a visible redaction
|
|
31
31
|
marker. Callers can add `extraInjectionPhrases`.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
- **Role markers are neutralized anywhere in a line**, not only at line
|
|
33
|
+
start: an all-caps role + colon (`SYSTEM:`, `ASSISTANT:`, `DEVELOPER:`), a
|
|
34
|
+
role in any case + colon followed by an imperative (`System: ignore …`),
|
|
35
|
+
`[SYSTEM]`, `<system>`, and a heading that is only the role (`### System`).
|
|
36
|
+
Lowercase prose and config (`the system: it restarts nightly`,
|
|
37
|
+
`system: true`, `role: "system"`, `## System requirements`) are left alone.
|
|
38
|
+
- **Verdict directives** (`recommend approve`, `approve this PR`) are
|
|
39
|
+
neutralized only on a line that also carries a role/override marker; on
|
|
40
|
+
their own they are ordinary review conversation.
|
|
41
|
+
- **Reveal/leak directives** must be aimed at the model's own material
|
|
42
|
+
(`your api key`, `the token you were given`, `system prompt`) or open a
|
|
43
|
+
sentence with `reveal`/`disclose`/`leak`/`exfiltrate`. A leak verb merely
|
|
44
|
+
near the word "token" (`Show the token expiry`) is not a hit.
|
|
45
|
+
4. **Secret masking** — mask strings that are *shaped* like credentials: GitHub
|
|
46
|
+
tokens (`ghp_`/`github_pat_`), `sk-`/`sk-ant-` keys, AWS access-key ids,
|
|
47
|
+
Slack/Google keys, opaque Bearer tokens, JWTs, PEM private-key blocks, and
|
|
48
|
+
`*_SECRET=…` style assignments whose value looks like a secret (env-style or
|
|
49
|
+
quoted: 8+ chars mixing letters and digits, or 16+ high-entropy chars;
|
|
50
|
+
otherwise 16+ chars, letters plus two or more digits, high entropy). The
|
|
51
|
+
words token/secret/password/key in prose, and assignments to identifiers or
|
|
52
|
+
references (`token = getToken()`, `API_KEY: process.env.API_KEY`,
|
|
53
|
+
`${{ secrets.X }}`), are not masked. Short or all-letter secrets in an
|
|
54
|
+
unquoted assignment (`password: hunter2`) are therefore not caught.
|
|
36
55
|
5. **Backtick fencing** — wrap the content in a code fence whose length is
|
|
37
56
|
strictly greater than any backtick run inside the body, so the content cannot
|
|
38
57
|
break out of its block.
|