@thegpvc/gp-foundry 0.2.11 → 0.2.13
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/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 +125 -123
- package/package.json +1 -1
- package/skill/reference/node-types.md +23 -2
|
@@ -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.
|