@thegpvc/gp-foundry 0.2.11 → 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.
@@ -1,6 +1,7 @@
1
1
  # agent-context
2
2
 
3
- Fetches GitHub issue/PR data via the Octokit REST API and formats it into a
3
+ Fetches GitHub issue/PR data via the Octokit REST API (plus one GraphQL query,
4
+ for review threads) and formats it into a
4
5
  labeled plaintext context file for an agent prompt. Writes the file to a temp
5
6
  path and exposes it via the `context-file` output.
6
7
 
@@ -14,10 +15,12 @@ This is a Node20 JavaScript action authored in TypeScript
14
15
  | `type` | yes | — | Context type: `issue`, `pr-diff`, `pr-review`, or `pr-full`. |
15
16
  | `number` | yes | — | Issue or PR number. |
16
17
  | `token` | yes | — | GitHub token used for API calls. |
18
+ | `checks-token` | no | `""` | Token used only to read check-run conclusions on the PR head. Pass `GITHUB_TOKEN` (job permission `checks: read`); empty skips the section. See below. |
17
19
  | `include-diff` | no | `"true"` | Include the full unified diff for PR types. Any value other than `"false"` is treated as true. |
18
20
  | `triggering-comment` | no | `""` | Body of the comment that triggered the workflow; appended as a final section when non-empty. |
19
21
  | `base-branch` | no | `""` | Optional base branch noted in the log for the comparison. The PR diff is always taken relative to the PR's own base ref; this input is surfaced for logging and downstream steps, not to re-target the diff. |
20
22
  | `trusted-authors` | no | `""` | Comma-separated logins whose posts are the harness's own output; framed as the agent's work item rather than as untrusted input. See below. |
23
+ | `trusted-framing` | no | `"work-item"` | How a `trusted-authors` post is framed: `work-item` (act on it) or `baseline` (the agent's own previous output, to compare against). Any other value fails the step. See below. |
21
24
  | `sanitize` | no | `"true"` | Neutralize prompt-injection in untrusted text before it lands in the context file. See below. |
22
25
 
23
26
  ## Outputs
@@ -29,13 +32,46 @@ This is a Node20 JavaScript action authored in TypeScript
29
32
  ## Context types
30
33
 
31
34
  - **`issue`** — issue header (number, title, labels, body) plus all issue comments.
32
- - **`pr-diff`** — PR header (title, file/line stats, body) plus the diff only.
33
- - **`pr-review`** — PR header, issue comments, reviews, inline review comments, and diff.
35
+ - **`pr-diff`** — PR header (title, head SHA, file/line stats, body), the
36
+ changed-file list, check runs (if `checks-token` is set), and the diff.
37
+ - **`pr-review`** — everything in `pr-diff`, plus issue comments, reviews, and
38
+ review threads, ahead of the diff.
34
39
  - **`pr-full`** — identical to `pr-review`.
35
40
 
36
- Empty sections are omitted. The diff is capped at ~100KB (100,000 bytes); larger
37
- diffs are truncated with a `[Diff truncated at 100KB. Use Read tool to examine
38
- full files.]` marker.
41
+ Empty sections are omitted. What the PR sections carry:
42
+
43
+ - **Changed files** — one line per file: status, path (and the previous path of
44
+ a rename), `+additions -deletions`.
45
+ - **Check runs on head** — `name: conclusion` (or the status, while a run is not
46
+ completed), sorted by name, the latest attempt per check name only. Read with
47
+ `checks-token`, not `token`: the Checks permission has no fine-grained-PAT
48
+ equivalent, so the harness token cannot see check runs and the workflow's
49
+ `GITHUB_TOKEN` can. Without `checks-token` there is no section; if the fetch
50
+ fails, the section is a one-line note that conclusions were unavailable.
51
+ - **Reviews** — each with the commit it was submitted against, marked
52
+ `(current head)` or `(not the current head)`, so a review of this head can be
53
+ told from a review of an older one.
54
+ - **Review threads** — grouped per thread, each led by its node id, `RESOLVED` /
55
+ `UNRESOLVED` (and `OUTDATED`), and `path:line`, then its comments, then the
56
+ reactions on the first comment with who left them. Threads exist only in the
57
+ GraphQL API; if that query fails, the section falls back to the flat REST
58
+ inline comments (`INLINE REVIEW COMMENTS`) with a note saying so.
59
+
60
+ None of the best-effort fetches (threads, check runs) can fail the step; the
61
+ underlying API error is logged as a workflow warning.
62
+
63
+ ### The diff
64
+
65
+ The diff is capped at ~100KB (100,000 bytes); larger diffs are truncated with a
66
+ `[Diff truncated at 100KB. Use Read tool to examine full files.]` marker.
67
+
68
+ GitHub refuses to serve a diff that is too large (HTTP 406, or a 422
69
+ `too_large`). The step does not fail on that: the diff section is assembled
70
+ instead from the per-file patches of the changed-file list, in order, up to
71
+ 200KB, under a line stating that the diff was too large for the API and how many
72
+ files are shown in full, truncated, and omitted (a file is omitted when the
73
+ budget has run out or when GitHub supplies no patch for it — binaries, very
74
+ large files). Any other error fetching the diff still fails the step.
39
75
 
40
76
  ## Untrusted text
41
77
 
@@ -52,8 +88,14 @@ collision-proof fence inside an `UNTRUSTED USER INPUT` banner. Per-body fencing
52
88
  over distinguishable.
53
89
 
54
90
  Titles are scrubbed in place instead of bannered — a banner per title would
55
- drown the structure it labels — and the diff is left verbatim, with a header
56
- noting that text inside a diff is data under review, never instructions.
91
+ drown the structure it labels. File paths and check-run names get the same
92
+ one-line scrub: both are chosen by the PR author.
93
+
94
+ The diff's text is left verbatim — no marker redaction, no secret masking; it
95
+ has to stay a faithful diff — under a header noting that text inside a diff is
96
+ data under review, never instructions. It is wrapped in a collision-proof fence
97
+ like every other body, so a diff that contains a markdown fence or a line like
98
+ `=== REVIEWS ===` cannot pass itself off as a section of the context.
57
99
 
58
100
  Neutralized markers and masked secrets are reported as workflow warnings, so an
59
101
  injection attempt shows up in the run log. Set `sanitize: "false"` only if the
@@ -71,6 +113,14 @@ control-stripped, secret-masked and fenced, but the banner says they are the wor
71
113
  item, and injection-marker redaction is skipped so ordinary review prose survives
72
114
  intact. Everyone else in the same file stays untrusted.
73
115
 
116
+ "Work item" is the right framing for a Fixer. It is the wrong one for a
117
+ re-reviewer, whose earlier review it would present as something to act on: the
118
+ agent would be told to obey its past self. `trusted-framing: baseline` frames the
119
+ same posts as the agent's own previous output — a baseline to compare the current
120
+ state against, not instructions to follow and not a conclusion to defer to, since
121
+ the code may have changed since. Only the banner text differs; the scrubbing,
122
+ the fence, and the note that quoted third-party text is still data are the same.
123
+
74
124
  ## Example
75
125
 
76
126
  ```yaml
@@ -79,7 +129,8 @@ intact. Everyone else in the same file stays untrusted.
79
129
  with:
80
130
  type: pr-review
81
131
  number: ${{ github.event.pull_request.number }}
82
- token: ${{ secrets.GITHUB_TOKEN }}
132
+ token: ${{ secrets.AGENT_PAT }}
133
+ checks-token: ${{ secrets.GITHUB_TOKEN }}
83
134
  triggering-comment: ${{ github.event.comment.body }}
84
135
 
85
136
  - name: Use the context
@@ -11,6 +11,15 @@ inputs:
11
11
  token:
12
12
  description: GitHub token for API calls
13
13
  required: true
14
+ checks-token:
15
+ description: >-
16
+ Optional token used ONLY to read check-run conclusions on the PR head
17
+ (latest attempt per check name). Separate from `token` because the Checks
18
+ permission has no fine-grained-PAT equivalent: the harness PAT cannot read
19
+ check runs, so pass GITHUB_TOKEN here (the job needs `checks: read`) while
20
+ `token` stays the harness token. Empty skips the checks section entirely;
21
+ a failed fetch renders a one-line "unavailable" note instead of failing.
22
+ default: ""
14
23
  include-diff:
15
24
  description: Whether to include the full diff (for PR types)
16
25
  default: "true"
@@ -25,13 +34,25 @@ inputs:
25
34
  Fixer's checklist IS the Reviewer's review, and banning it from acting on
26
35
  it is incoherent. Leave empty to treat every body as untrusted.
27
36
  default: ""
37
+ trusted-framing:
38
+ description: >-
39
+ How a `trusted-authors` post is framed for the agent reading it.
40
+ "work-item" (default): the post is the agent's work item, to act on --
41
+ right for a Fixer handed the Reviewer's review. "baseline": the post is
42
+ the agent's own previous output, a baseline to compare the current state
43
+ against -- not instructions to follow and not a conclusion to defer to,
44
+ since the code may have changed since. Use it for a re-reviewer, which
45
+ "work-item" would tell to obey its past self. Scrubbing and fencing are
46
+ identical either way. Any other value fails the step.
47
+ default: "work-item"
28
48
  sanitize:
29
49
  description: >-
30
50
  Neutralize prompt-injection in attacker-controlled text (issue/PR bodies,
31
51
  comments, review bodies, titles) before it is written to the context file:
32
52
  strips control/bidi sequences, caps length, neutralizes role-override
33
53
  markers, masks secret-looking strings, and wraps each body in a
34
- collision-proof fence inside an UNTRUSTED banner. On by default — the
54
+ collision-proof fence inside an UNTRUSTED banner. The diff is fenced too,
55
+ but its text is left verbatim. On by default — the
35
56
  agent reading this file holds a write token and a shell. Set "false" only
36
57
  if the consumer sanitizes some other way.
37
58
  default: "true"