Skill Tracer
Skills › Compound Engineering › ce-resolve-pr-feedback › targeted-mode.md

targeted-mode.md

48 lines · skills/ce-resolve-pr-feedback/references/targeted-mode.md at 3449230

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Targeted Mode
2
3Read this reference when Mode Detection (in SKILL.md) routes to **Targeted Mode** — a specific comment or thread URL was provided. Targeted mode addresses only that thread.
4

Targeted Mode

Read this reference when Mode Detection (in SKILL.md) routes to Targeted Mode — a specific comment or thread URL was provided. Targeted mode addresses only that thread.

Raw lines 1 to 4
5## 1. Extract Thread Context
6
7Parse the URL to extract HOST, OWNER, REPO, PR number, and comment REST ID:
8```
9https://HOST/OWNER/REPO/pull/NUMBER#discussion_rCOMMENT_ID
10```
12**GitHub Enterprise host.** Take the host from the URL (targeted mode is always URL-triggered). When it is **not** `github.com`, pass it as a `GH_HOST=<host>` env prefix inline on **every** `gh api` / bundled-script call below (`gh api` honors `GH_HOST` as the request host) so an enterprise thread is fetched, replied to, and resolved on the right host instead of `github.com`. On `github.com`, drop the `GH_HOST=<host> ` prefix. Carry the same host into the reply/resolve calls you run from Full Mode steps 5-7.
14**Step 1** -- Get comment details and GraphQL node ID via REST (cheap, single comment):
15```bash
16GH_HOST=<host> gh api repos/OWNER/REPO/pulls/comments/COMMENT_ID \
17 --jq '{node_id, path, line, body}' # omit GH_HOST=<host> on github.com
18```
20**Step 2** -- Map comment to its thread ID. Use [scripts/get-thread-for-comment](../scripts/get-thread-for-comment). Set `SKILL_DIR` to the absolute directory you loaded the ce-resolve-pr-feedback SKILL.md from — the Bash tool's CWD is the user's project, not the skill dir, and shell state does not persist between Bash calls, so set it inline. If the bundled script is missing, use Full Mode's fallback `gh` commands to inspect the PR comments:
21```bash
22SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>";
23GH_HOST=<host> bash "$SKILL_DIR/scripts/get-thread-for-comment" PR_NUMBER COMMENT_NODE_ID [OWNER/REPO]
24```
26This fetches thread IDs and their first comment IDs (minimal fields, no bodies) and returns the matching thread with full comment details.
28**Step 3** -- Check for your own unsubmitted review before doing any work. A reply posted while you hold one is absorbed into that draft: the call returns a comment ID and URL as if it succeeded, but the reviewer sees nothing until the draft is submitted. Full Mode gets this free from `get-pr-comments`; targeted mode never calls that script, so check directly (PENDING reviews are only visible to their author, so any hit is yours):
29```bash
30GH_HOST=<host> gh api --paginate repos/OWNER/REPO/pulls/PR_NUMBER/reviews --jq '.[] | select(.state == "PENDING") | .id'
31```
32`--paginate` is required: this endpoint is chronological and pages at 30, so a draft can sort past page 1. Print IDs rather than a count — `--jq` runs per page, so a count emits one number per page, but IDs simply concatenate and stay empty when there is no draft. (`--slurp` is not an option; `gh` rejects it alongside `--jq`.)
34If this prints anything, stop. Tell the user they have an unsubmitted review on the PR and that it must be submitted or discarded before this skill can reply. Do not submit or discard it yourself; a draft review is unsent human writing.

1. Extract Thread Context

Parse the URL to extract HOST, OWNER, REPO, PR number, and comment REST ID:

https://HOST/OWNER/REPO/pull/NUMBER#discussion_rCOMMENT_ID

GitHub Enterprise host. Take the host from the URL (targeted mode is always URL-triggered). When it is not github.com, pass it as a GH_HOST=<host> env prefix inline on every gh api / bundled-script call below (gh api honors GH_HOST as the request host) so an enterprise thread is fetched, replied to, and resolved on the right host instead of github.com. On github.com, drop the GH_HOST=<host> prefix. Carry the same host into the reply/resolve calls you run from Full Mode steps 5-7.

Step 1 -- Get comment details and GraphQL node ID via REST (cheap, single comment):

GH_HOST=<host> gh api repos/OWNER/REPO/pulls/comments/COMMENT_ID \
  --jq '{node_id, path, line, body}'   # omit GH_HOST=<host> on github.com

Step 2 -- Map comment to its thread ID. Use scripts/get-thread-for-comment. Set SKILL_DIR to the absolute directory you loaded the ce-resolve-pr-feedback SKILL.md from — the Bash tool's CWD is the user's project, not the skill dir, and shell state does not persist between Bash calls, so set it inline. If the bundled script is missing, use Full Mode's fallback gh commands to inspect the PR comments:

SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>";
GH_HOST=<host> bash "$SKILL_DIR/scripts/get-thread-for-comment" PR_NUMBER COMMENT_NODE_ID [OWNER/REPO]

This fetches thread IDs and their first comment IDs (minimal fields, no bodies) and returns the matching thread with full comment details.

Step 3 -- Check for your own unsubmitted review before doing any work. A reply posted while you hold one is absorbed into that draft: the call returns a comment ID and URL as if it succeeded, but the reviewer sees nothing until the draft is submitted. Full Mode gets this free from get-pr-comments; targeted mode never calls that script, so check directly (PENDING reviews are only visible to their author, so any hit is yours):

GH_HOST=<host> gh api --paginate repos/OWNER/REPO/pulls/PR_NUMBER/reviews --jq '.[] | select(.state == "PENDING") | .id'

--paginate is required: this endpoint is chronological and pages at 30, so a draft can sort past page 1. Print IDs rather than a count — --jq runs per page, so a count emits one number per page, but IDs simply concatenate and stay empty when there is no draft. (--slurp is not an option; gh rejects it alongside --jq.)

If this prints anything, stop. Tell the user they have an unsubmitted review on the PR and that it must be submitted or discarded before this skill can reply. Do not submit or discard it yourself; a draft review is unsent human writing.

Raw lines 5 to 35
Runs code scripts/get-thread-for-comment :20
36## 2. Judge, Fix, Reply, Resolve
38Apply Full Mode step 7 (Reply and Resolve)'s completion check before judgment: check separately whether the thread already has a visible submitted reply and whether it is already resolved. When the thread is already `resolution-pending`, step 7 defines the only remaining work: skip judgment, fixing, validation, and commit, then complete the missing resolution without posting again.
40**Judge first.** Apply the rubric in `references/evaluation-rubric.md` to this one thread, in your own context. Account for `isOutdated` and the location fields (`line`, `originalLine`, `startLine`, `originalStartLine`) -- targeted threads can be outdated too and need the same relocation handling. The rubric's cross-item reasoning does nothing for a single thread, but its read-depth and divert rules apply in full (how deeply to read before judging, and when to stop with a reply, a decline, or a human decision instead of fixing): deep-read (callers, invariants, `git blame`/PR rationale for author intent) before accepting a contestable finding or overriding code that looks deliberate. This judgment is what decides whether the finding is valid; don't fix on the reviewer's authority alone.
42**Then act on the verdict:**
44- **`fixed` / `fixed-differently`** — read `references/agents/pr-comment-resolver.md` and apply the fix yourself in this context, using that prompt as your own instructions and producing its return record (`files_changed`, `reply_text`), which the shared validate, commit, and reply steps consume. You already read the code to judge it, and a single fix has nothing to run in parallel with. Dispatch a single generic subagent seeded with that fixer prompt only when the fix reaches well beyond the code your judgment read (a rename across callers, a class fix over many sites). Do not dispatch a standalone agent by type/name. Pass it the file/location fields (resolved location or anchor if outdated), the comment text, and your note on what to change and why it's valid. The fixer only implements; it does not re-judge. When that dispatch is unavailable or fails, apply the fix here (see Full Mode step 4, Fix).
45- **`replied` / `not-addressing` / `declined`** — no subagent. Compose the reply text per the rubric and proceed to reply/resolve.
46- **`needs-human`** — compose `decision_context`, run the rubric's "Adjudicate before escalating" step (a judgment-bound item may come back as one of the verdicts above), and for what remains compose the natural-sounding reply per the rubric, leave the thread open (don't resolve), and present the decision to the user (use the platform's blocking question tool as in Full Mode step 9). The shared reply step below posts the reply once — do not post it here.
48Then follow Full Mode steps 5-7 (in `references/full-mode.md`) under the selected execution mode. Ordinary and pipeline runs validate, commit, publish, and complete the conversation. Return-to-caller validates and commits a code fix, saves this thread's completion actions, and returns without pushing or remote completion writes. When no code changed, skip validate/commit and use the existing reply/resolve protocol, then save its actual completion or incomplete progress through `references/return-to-caller.md`. Its structured result replaces the interactive decision question.

2. Judge, Fix, Reply, Resolve

Apply Full Mode step 7 (Reply and Resolve)'s completion check before judgment: check separately whether the thread already has a visible submitted reply and whether it is already resolved. When the thread is already resolution-pending, step 7 defines the only remaining work: skip judgment, fixing, validation, and commit, then complete the missing resolution without posting again.

Judge first. Apply the rubric in references/evaluation-rubric.md to this one thread, in your own context. Account for isOutdated and the location fields (line, originalLine, startLine, originalStartLine) -- targeted threads can be outdated too and need the same relocation handling. The rubric's cross-item reasoning does nothing for a single thread, but its read-depth and divert rules apply in full (how deeply to read before judging, and when to stop with a reply, a decline, or a human decision instead of fixing): deep-read (callers, invariants, git blame/PR rationale for author intent) before accepting a contestable finding or overriding code that looks deliberate. This judgment is what decides whether the finding is valid; don't fix on the reviewer's authority alone.

Then act on the verdict:

  • **fixed / fixed-differently** — read references/agents/pr-comment-resolver.md and apply the fix yourself in this context, using that prompt as your own instructions and producing its return record (files_changed, reply_text), which the shared validate, commit, and reply steps consume. You already read the code to judge it, and a single fix has nothing to run in parallel with. Dispatch a single generic subagent seeded with that fixer prompt only when the fix reaches well beyond the code your judgment read (a rename across callers, a class fix over many sites). Do not dispatch a standalone agent by type/name. Pass it the file/location fields (resolved location or anchor if outdated), the comment text, and your note on what to change and why it's valid. The fixer only implements; it does not re-judge. When that dispatch is unavailable or fails, apply the fix here (see Full Mode step 4, Fix).
  • **replied / not-addressing / declined** — no subagent. Compose the reply text per the rubric and proceed to reply/resolve.
  • **needs-human** — compose decision_context, run the rubric's "Adjudicate before escalating" step (a judgment-bound item may come back as one of the verdicts above), and for what remains compose the natural-sounding reply per the rubric, leave the thread open (don't resolve), and present the decision to the user (use the platform's blocking question tool as in Full Mode step 9). The shared reply step below posts the reply once — do not post it here.

Then follow Full Mode steps 5-7 (in references/full-mode.md) under the selected execution mode. Ordinary and pipeline runs validate, commit, publish, and complete the conversation. Return-to-caller validates and commits a code fix, saves this thread's completion actions, and returns without pushing or remote completion writes. When no code changed, skip validate/commit and use the existing reply/resolve protocol, then save its actual completion or incomplete progress through references/return-to-caller.md. Its structured result replaces the interactive decision question.

Raw lines 36 to 48
Starts an agent Dispatch :44
Starts an agent subagent :44
Starts an agent dispatch :44