From d08696cf4c2f4f5af1585b951aeb554346d9d68b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 02:10:58 -0800 Subject: [PATCH 1/9] chore(quest): claim quest/m1/kixel-pull-reads.md Quest-Claim: 08c4598e16801dc9 From 2775e441561446b856c986fd002e4ae582cbd4c7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 02:19:20 -0800 Subject: [PATCH 2/9] feat(forge)!: read a PR's discussion with quest pr view, and steer gh away from Kixel Quest `quest pr view` prints a PR's title, body, comments, reviews, and review threads with their comments, on GitHub or a repository Kixel Quest hosts, through a new `view` read on the forge interface and wire. `quest hook` denies a `gh pr` or `gh api` call aimed at a repository Kixel Quest hosts, naming the quest command to run, and `quest context` prints the rule under Checked. Co-Authored-By: Claude Opus 5.5 --- README.md | 17 ++- docs/context.md | 1 + quest/m1/kixel-pull-reads.md | 32 ----- src/cli/forge.ts | 5 + src/cli/hooks.ts | 2 +- src/cli/main.ts | 27 +++- src/cli/rules.ts | 150 ++++++++++++++++++-- src/cli/status.ts | 34 ++++- src/core/forge.ts | 88 +++++++++++- src/core/index.ts | 4 + src/github/forge.ts | 6 + src/github/online-review.ts | 4 +- src/github/view.ts | 61 ++++++++ test/forge-view.test.ts | 264 +++++++++++++++++++++++++++++++++++ test/kixel-fakes.ts | 34 +++++ test/rules.test.ts | 48 +++++++ 16 files changed, 722 insertions(+), 55 deletions(-) delete mode 100644 quest/m1/kixel-pull-reads.md create mode 100644 src/github/view.ts create mode 100644 test/forge-view.test.ts diff --git a/README.md b/README.md index 8df9281d..c54175d0 100644 --- a/README.md +++ b/README.md @@ -660,17 +660,21 @@ Kixel Quest's queue lands by fast-forwarding the base and drops once the head moves, so it takes no `--squash`, `--rebase`, or `--direct`. `quest review` records its rounds in the PR body there too. -Where `gh` cannot reach, `quest pr` opens, edits, and comments on PRs and -resolves review threads, with `gh pr`'s flags; it works on GitHub too: +Where `gh` cannot reach, `quest pr` reads, opens, edits, and comments on PRs +and resolves review threads, with `gh pr`'s flags; it works on GitHub too. +`quest pr view` prints a PR's body, comments, reviews, and every review thread +with its comments, read from the forge itself rather than an index: ```sh +quest pr view 12 quest pr create --title "Plan the forge" --body-file .tmp/body.md --draft quest pr edit 12 --body-file .tmp/body.md quest pr comment 12 --thread --body "Fixed in the head." quest pr resolve 12 ``` -The writes are `POST /forge/`, beside the reads: `open`, `close`, +Its read is `POST /forge/view`, answering the same `{"value", "asOf"}`. The +writes are `POST /forge/`, beside the reads: `open`, `close`, `edit`, `comment`, `resolve`, `hold`, `ready`, `release`, and `pick`, each answering `{"value", "asOf"}` with `asOf` null. A 409 with `{"error"}` refuses the write as things stand, such as a PR another session holds, a second open @@ -2405,7 +2409,12 @@ hook on shell commands and file edits denies, with the rule as the reason: or `comment`, or `gh api` with a `body` field) without a `(Written by ...)` line; - a scratch file written under `/tmp`, outside the checkout, by a redirection, - `tee`, `mkdir`, `mktemp`, `git clone` or `worktree add`, or a file edit. + `tee`, `mkdir`, `mktemp`, `git clone` or `worktree add`, or a file edit; +- in a checkout whose origin is on [Kixel Quest](#work-on-a-repository-kixel-quest-hosts), + a `gh pr` or `gh api` call aimed at that repository, which `gh` cannot reach: + one naming no repository, through `--repo`, `GH_REPO`, a PR URL, or an + endpoint's `repos//`, or naming that one; the reason names the + `quest` command to run, such as `quest pr view`. For Claude Code, `Stop` and `SubagentStop` hooks refuse to end an agent's turn while a `quest gate` command it started still runs in the background, naming diff --git a/docs/context.md b/docs/context.md index 2e9be509..32ed19a4 100644 --- a/docs/context.md +++ b/docs/context.md @@ -93,3 +93,4 @@ When the repository has a `quest/` directory, it plans work as quests: Markdown - Push with an explicit refspec, `git push refs/heads/:refs/heads/`: a bare branch name can push to the base instead, as under `push.default=upstream` when the branch tracks it. - Never rebase or force-push, even a branch only you hold; merge the base instead, when the branch conflicts with it or a landing step refuses the head. - Put scratch files, such as PR bodies, logs, patches, helper scripts, and temporary clones, in the checkout's `.tmp/`, never `/tmp`, so they disappear with the worktree. +- On a repository Kixel Quest hosts, `gh` cannot reach its PRs: use `quest pr view`, `create`, `edit`, `comment`, and `resolve`, and `quest status`, `ready`, and `merge`. diff --git a/quest/m1/kixel-pull-reads.md b/quest/m1/kixel-pull-reads.md deleted file mode 100644 index 40401d41..00000000 --- a/quest/m1/kixel-pull-reads.md +++ /dev/null @@ -1,32 +0,0 @@ -# [M] PR bodies and comments for repositories Kixel Quest hosts - -## Goal - -An agent working on a repository Kixel Quest hosts reads a PR's body, -comments, and reviews through `quest`, and is steered to `quest pr` when it -reaches for `gh`, so `/quest-iterate` and `/quest-review` run there without -`gh`. - -## Plan - -The forge writes gave `quest pr` its create, edit, comment, and resolve, but -an agent still reads a PR's body and discussion with `gh pr view`, which -cannot reach Kixel Quest, and nothing tells it to use `quest pr` instead. - -- Add a `view` read to the forge interface and its wire, typed in - `quest/core` like the others: the body, title, comments, and reviews, as - `quest pr view ` prints them. GitHub's backend reads them as `gh pr view - --comments` shows them. -- `quest hook` denies `gh pr` and `gh api` calls in a checkout whose origin - is on Kixel Quest, naming the `quest pr` command to run, through a checked - rule in `src/cli/rules.ts` that adds one line to the Checked section `quest - context` prints: ✅ hook denial with a Checked line (rejected: a prose rule in - `quest context` only; neither). The maintainer settled this in - [moq-dev/quest#769](https://github.com/moq-dev/quest/pull/769#issuecomment-6944655958), - since an agent without it tries `gh`, fails, and has no pointer to the - command that works. - -Tests: against the fake Kixel Quest, `quest pr view` prints a PR's body and -comments; and the hook denies `gh pr view` in a checkout whose origin is on -Kixel Quest while it lets the same call through on a GitHub checkout. - diff --git a/src/cli/forge.ts b/src/cli/forge.ts index df45ba3d..75d0a9b9 100644 --- a/src/cli/forge.ts +++ b/src/cli/forge.ts @@ -17,6 +17,7 @@ import { type Opening, type Pick, type PullRequest, + type PullView, type Repository, type Status, type Watch, @@ -298,6 +299,10 @@ export class KixelQuestForge implements Forge, ForgeWrites { }; } + view(pull: PullRequest): Promise> { + return this.kixel.call("view", { pull }); + } + async open(opening: Opening): Promise { return (await this.kixel.call("open", { opening })).value; } diff --git a/src/cli/hooks.ts b/src/cli/hooks.ts index 04db36ab..12d81961 100644 --- a/src/cli/hooks.ts +++ b/src/cli/hooks.ts @@ -341,7 +341,7 @@ export function hook(input: unknown, deps: HookDependencies = { env: process.env ) throw new Error("expected a PreToolUse hook's JSON input with tool_name and tool_input"); if (!usesQuest(value.cwd)) return ""; - const rules = broken({ tool: value.tool_name, input: value.tool_input, cwd: value.cwd }); + const rules = broken({ tool: value.tool_name, input: value.tool_input, cwd: value.cwd }, deps.env); if (rules.length === 0) { if (value.tool_name === "Bash" && typeof value.tool_input.command === "string") logCall( diff --git a/src/cli/main.ts b/src/cli/main.ts index 0bd49e78..87cf3046 100644 --- a/src/cli/main.ts +++ b/src/cli/main.ts @@ -45,6 +45,7 @@ import { } from "./agent"; import type { ForgeWrites, Hold, Repository } from "../core"; import { GitHubWrites } from "./writes"; +import { GitHubForge } from "../github/forge"; import { type ClaimDependencies, held, openDrafts, reach, target, upstream, upstreamRefs } from "./claims"; import { type ForgeDependencies, @@ -121,7 +122,7 @@ import { describe, notUpstream, releaseQuest, startQuest } from "./start"; import { CONTEXT, GUIDE, GUIDE_SECTIONS, SKILLS, guideSections, sectionHeading, skill } from "./skills"; import { type Terminal, Theme } from "./theme"; import { type Snapshot, checkout, collect, load, snapshot, under } from "./tree"; -import { statusLines } from "./status"; +import { statusLines, viewLines } from "./status"; import { TOKEN_MAX_MISSING, daysBefore, runTokenMax, usage, usageDependencies, usageLines } from "./usage"; import { waitForActivity, WaitTimeout } from "./wait"; import { version } from "./version"; @@ -952,13 +953,33 @@ export function main(argv: string[], out: Output): number | Promise { const pr = program .command("pr") - .summary("Open, edit, and comment on pull requests, and resolve their review threads") + .summary("Read, open, edit, and comment on pull requests, and resolve their review threads") .description( - "Open, edit, and comment on pull requests, and resolve their review threads, on GitHub or on a " + + "Read, open, edit, and comment on pull requests, and resolve their review threads, on GitHub or on a " + "repository Kixel Quest hosts, where gh cannot reach. Flags follow gh pr's.\n\n" + FORGE_WRITES + "Exits 0 when done, 3 when refused, 2 for invalid arguments, and 1 for other failures.", ); + pr.command("view") + .description( + "Print a PR's title, body, comments, reviews, and review threads with their comments, resolved ones " + + "included. Plain output prints url, state, draft, author, and title lines; then each post after a -- " + + "line, as a header line and its text: the body under a body line, each comment " + + "(comment