Skip to content

Commit a8fda06

Browse files
committed
Revert "fix: address PR #20 review findings and scope reviewer to diff only"
This reverts commit dec1e33.
1 parent dec1e33 commit a8fda06

7 files changed

Lines changed: 607 additions & 598 deletions

File tree

.github/workflows/agent-review.lock.yml

Lines changed: 571 additions & 542 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/agent-review.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ permissions:
1919
pull-requests: read
2020

2121
tools:
22+
bash: ["cat", "head", "tail", "grep", "wc", "ls", "find"]
2223
github:
2324
toolsets: [repos, pull_requests]
2425

@@ -40,21 +41,19 @@ Review PR #{{ github.event.pull_request.number }}: "{{ github.event.pull_request
4041

4142
## Review Process
4243

43-
1. **Fetch the PR diff** using the GitHub tool (`get-pull-request-diff` or equivalent).
44-
2. **Review only the changed lines** (`+` lines in the diff). Do not fetch or read full file contents — your entire review must be scoped to lines present in the diff.
45-
3. **Review for:**
44+
1. **Fetch the PR diff** using the GitHub tool.
45+
2. **Review for:**
4646
- TypeScript type safety issues (strict mode — no `any`, no unchecked nulls)
4747
- Code style: JSDoc block above every function, alphabetical params, explicit return types
4848
- Logic errors or bugs
4949
- Missing test coverage for new logic
50-
4. **Post inline review comments** only on lines that appear in the diff.
51-
5. **Submit your review:**
50+
3. **Post inline review comments** on specific lines where you find issues.
51+
4. **Submit your review:**
5252
- No issues: use `noop` with a brief summary.
5353
- Issues found: COMMENT with specific, actionable feedback.
5454

5555
## Important
5656

57-
- **Only comment on lines in the diff.** Do not flag pre-existing code that was not touched by this PR.
5857
- Be concise and constructive.
5958
- Don't nitpick formatting — Biome handles that.
6059
- Focus on correctness and type safety.

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,8 @@ If you're not using gh-aw, add these two steps to your agent job to write and up
288288
- name: Write token counts
289289
if: always()
290290
run: |
291-
turns_field=""
292-
if [ -n "$TURNS" ]; then
293-
turns_field=",\"turns\":$TURNS"
294-
fi
295-
printf '{"input_tokens":%s,"output_tokens":%s,"cache_read_tokens":%s,"cache_write_tokens":%s%s}\n' \
296-
"$INPUT_TOKENS" "$OUTPUT_TOKENS" "$CACHE_READ_TOKENS" "$CACHE_WRITE_TOKENS" "$turns_field" \
291+
printf '{"input_tokens":%s,"output_tokens":%s,"cache_read_tokens":%s,"cache_write_tokens":%s,"turns":%s}\n' \
292+
"$INPUT_TOKENS" "$OUTPUT_TOKENS" "$CACHE_READ_TOKENS" "$CACHE_WRITE_TOKENS" "$TURNS" \
297293
> /tmp/agent-tokens.json
298294
299295
- uses: actions/upload-artifact@v4

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/comment.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,21 @@ async function findExistingComment({
302302
repo: string;
303303
issueOrPrNumber: number;
304304
}): Promise<{ id: number; body: string } | null> {
305-
const gh = octokit as ReturnType<typeof import('@actions/github').getOctokit>;
306-
const comments = await gh.paginate(gh.rest.issues.listComments, {
307-
owner,
308-
repo,
309-
issue_number: issueOrPrNumber,
310-
per_page: 100,
311-
});
305+
try {
306+
const gh = octokit as ReturnType<typeof import('@actions/github').getOctokit>;
307+
const comments = await gh.paginate(gh.rest.issues.listComments, {
308+
owner,
309+
repo,
310+
issue_number: issueOrPrNumber,
311+
per_page: 100,
312+
});
312313

313-
const existing = comments.find((c) => c.body?.includes(COMMENT_MARKER));
314-
if (!existing) return null;
315-
return { id: existing.id, body: existing.body ?? '' };
314+
const existing = comments.find((c) => c.body?.includes(COMMENT_MARKER));
315+
if (!existing) return null;
316+
return { id: existing.id, body: existing.body ?? '' };
317+
} catch {
318+
return null;
319+
}
316320
}
317321

318322
/**

src/run.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ export async function run(): Promise<void> {
9999
if (!inputs.triggerEvent) resolvedTriggerEvent = runData.triggerEvent;
100100
resolvedTriggerRef = runData.triggerRef;
101101
resolvedTriggerType = runData.triggerType;
102-
// Prefer the agent workflow's name from the run data over ctx.workflowName (which is the
103-
// companion workflow). Only overwrite when non-empty so a failed getWorkflowRun() doesn't
104-
// blank out the name entirely.
105-
if (runData.workflowName) resolvedWorkflowName = runData.workflowName;
102+
// Always use the agent workflow's name from the run data — ctx.workflowName is the
103+
// companion workflow and would misattribute if used as a fallback here.
104+
resolvedWorkflowName = runData.workflowName;
106105
workflowRunTokens = runData.tokens;
107106
artifactTurns = runData.artifactTurns;
108107
}
@@ -139,17 +138,11 @@ export async function run(): Promise<void> {
139138
// Fall back to resolvedTriggerRef from resolveTrigger (companion workflow_run mode — it knows
140139
// whether a PR was found regardless of the triggering event name, e.g. issue_comment on a PR).
141140
// Last resort: buildTriggerRef from the event name and number.
142-
// Prefer resolvedTriggerType (set by resolveTrigger in workflow_run mode — already knows
143-
// PR vs issue) over resolvedTriggerEvent when building the ref label, so a manual
144-
// trigger_number without trigger_event doesn't default to the generic '#N' form for PRs.
145141
const triggerRef =
146142
ctx.triggerRef ??
147143
resolvedTriggerRef ??
148144
(resolvedTriggerNumber !== null
149-
? buildTriggerRef({
150-
eventName: resolvedTriggerType ?? resolvedTriggerEvent,
151-
number: resolvedTriggerNumber,
152-
})
145+
? buildTriggerRef({ eventName: resolvedTriggerEvent, number: resolvedTriggerNumber })
153146
: null);
154147

155148
// resolvedTriggerType is only set in companion workflow_run mode (from resolveTrigger).

src/workflow-run.ts

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async function checkConclusionJobCompleted({
180180
/** Workflow run ID */
181181
workflowRunId: number;
182182
}): Promise<boolean> {
183-
const attemptCheck = async (): Promise<boolean> => {
183+
try {
184184
const { data } = await octokit.rest.actions.listJobsForWorkflowRun({
185185
owner,
186186
repo,
@@ -198,24 +198,12 @@ async function checkConclusionJobCompleted({
198198
}
199199
core.info(`AgentMeter: conclusion job completed (${conclusionJob.conclusion}) — proceeding.`);
200200
return true;
201-
};
202-
203-
try {
204-
return await attemptCheck();
205-
} catch (firstError) {
206-
core.warning(
207-
`AgentMeter: could not check conclusion job status (attempt 1): ${firstError}. Retrying…`
208-
);
209-
try {
210-
return await attemptCheck();
211-
} catch (secondError) {
212-
// Both attempts failed — proceed rather than silently dropping the ingest. A transient
213-
// API hiccup or token-scope issue should not cause permanent data loss.
214-
core.warning(
215-
`AgentMeter: could not check conclusion job status (attempt 2): ${secondError}. Proceeding.`
216-
);
217-
return true;
218-
}
201+
} catch (error) {
202+
// Fail closed on API errors — proceeding on a failed gate check risks double-ingest.
203+
// A missing conclusion job (non-gh-aw workflow) is handled above as a successful
204+
// API call that returns no matching job, not as an exception.
205+
core.warning(`AgentMeter: could not check conclusion job status: ${error}. Skipping.`);
206+
return false;
219207
}
220208
}
221209

@@ -346,9 +334,9 @@ async function resolveTrigger({
346334
}
347335
}
348336

349-
// gh-aw issue branches are named agent/issue-N — anchor to the full branch name to
350-
// avoid substring matches in longer branch names like feature/agent/issue-12-fix.
351-
const issueMatch = headBranch.match(/^agent\/issue-(\d+)$/);
337+
// gh-aw issue branches are named agent/issue-N — require the full prefix to
338+
// avoid mismatching unrelated branches like feature/fix-issue-12-auth.
339+
const issueMatch = headBranch.match(/\bagent\/issue-(\d+)\b/);
352340
if (issueMatch?.[1]) {
353341
const num = parseInt(issueMatch[1], 10);
354342
return {

0 commit comments

Comments
 (0)