Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <thread-id> --body "Fixed in the head."
quest pr resolve 12 <thread-id>
```

The writes are `POST /forge/<write>`, beside the reads: `open`, `close`,
Its read is `POST /forge/view`, answering the same `{"value", "asOf"}`. The
writes are `POST /forge/<write>`, 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
Expand Down Expand Up @@ -2428,7 +2432,14 @@ 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/<owner>/<repo>`, or naming that one by its owner and name
or on Kixel Quest; a URL or host elsewhere, such as github.com, names
another repository. 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
Expand Down
1 change: 1 addition & 0 deletions docs/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ When the repository has a `quest/` directory, it plans work as quests: Markdown
- Push with an explicit refspec, `git push <remote> refs/heads/<branch>:refs/heads/<branch>`: 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`.
19 changes: 19 additions & 0 deletions quest/m1/kixel-pull-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# [S] Open PRs' changed files for repositories Kixel Quest hosts

## Goal

Before making a new quest on a repository Kixel Quest hosts, an agent lists
the files each open PR changes through `quest`, as the guide's Creation
section asks, without `gh`.

## Plan

The guide (`assets/AGENTS.md`, Creation) has agents list open PRs' files with
`gh pr list --limit 1000 --json number,url,files` and `gh api` for the rest.
On a repository Kixel Quest hosts, `quest hook` denies both, and no `quest`
command lists them.

Recommendation: give the `pulls` read each open PR's changed paths, print
them with a `quest pr list --files` modeled on `gh pr list`, and have the
guide name it in place of the `gh` commands. Keeping this quest authorizes
that guide edit.
32 changes: 0 additions & 32 deletions quest/m1/kixel-pull-reads.md

This file was deleted.

5 changes: 5 additions & 0 deletions src/cli/forge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
type Opening,
type Pick,
type PullRequest,
type PullView,
type Repository,
type Status,
type Watch,
Expand Down Expand Up @@ -305,6 +306,10 @@ export class KixelQuestForge implements Forge, ForgeWrites {
};
}

view(pull: PullRequest): Promise<Answer<PullView>> {
return this.kixel.call("view", { pull });
}

async open(opening: Opening): Promise<OpenPull> {
return (await this.kixel.call("open", { opening })).value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
27 changes: 24 additions & 3 deletions src/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -114,7 +115,7 @@ import { KIXEL_QUEST_URL, kixelUrl, tokensPath } from "./tokens";
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";
Expand Down Expand Up @@ -946,13 +947,33 @@ export function main(argv: string[], out: Output): number | Promise<number> {

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 <author> <time> <url>) and review (review <state> <reviewer> <time> <url>) by time, and each " +
"review thread (thread <id> current|outdated resolved|unresolved <path>:<line>) followed by its " +
"comments. --json prints the same as one deterministic object. It reads the forge itself, never Kixel " +
"Quest's index, so a comment just posted shows.",
)
.argument("<pr>", PR_ARGUMENT)
.option("--json", "Print a deterministic JSON object")
.action((value: string, options: { json?: boolean }) => {
const { pull, hosted } = locatePull(value, root(), process.env);
const forge = hosted ? hostedForge(pull, forgeDependencies()) : new GitHubForge(gitHubDependencies(warn));
settle(forge.view(pull), ({ value: view }) => {
if (options.json) print(JSON.stringify(view));
else for (const line of viewLines(view)) print(line);
});
});
const bodyOptions = (command: Command) =>
command
.addOption(new Option("-b, --body <text>", "Body text").conflicts("bodyFile"))
Expand Down
Loading
Loading