@a2f0/agent-tool 0.1.80 → 0.1.81
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.
- package/README.md +3 -2
- package/package.json +1 -1
- package/skills/cross-agent-review/SKILL.md +16 -11
- package/src/cli.ts +5 -5
- package/src/config.ts +3 -3
- package/src/doctor.ts +1 -0
- package/src/harnesses.ts +6 -4
- package/src/processes/session.ts +1 -1
- package/src/review/reviewEffort.ts +12 -7
- package/src/review/reviewPrompt.ts +2 -0
- package/src/review/solicitAgyReview.ts +170 -0
- package/src/skills/bundled.ts +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# agent-tool
|
|
2
2
|
|
|
3
3
|
agent-tool is a command-line tool and a set of portable skills for repositories
|
|
4
|
-
where Claude Code, Codex, OpenCode, or Hermes make the
|
|
4
|
+
where Antigravity CLI (`agy`), Claude Code, Codex, OpenCode, or Hermes make the
|
|
5
|
+
changes. It provides shared Git,
|
|
5
6
|
GitHub, review, validation, and release workflows: independent agent reviews of
|
|
6
7
|
a committed branch, guarded pushes and squash merges of the exact reviewed
|
|
7
8
|
commit, package versioning, brand image rendering, screenshot capture into a
|
|
@@ -34,7 +35,7 @@ npm install --save-dev --save-exact @a2f0/agent-tool
|
|
|
34
35
|
|
|
35
36
|
Version preparation needs Bun 1.4 or newer. GitHub operations require an
|
|
36
37
|
authenticated `gh` supporting `pr checks --json`, and independent reviews require
|
|
37
|
-
an authenticated Claude Code, Codex, or OpenCode CLI. A compiled standalone
|
|
38
|
+
an authenticated Antigravity CLI (`agy`), Claude Code, Codex, or OpenCode CLI. A compiled standalone
|
|
38
39
|
executable needs no Bun or Node at runtime.
|
|
39
40
|
|
|
40
41
|
Add `"agent-tool": "agent-tool"` to package scripts, or invoke
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cross-agent-review
|
|
3
|
-
description: Review committed branch changes with an independent Claude Code, Codex, or OpenCode reviewer, and repair actionable findings when requested.
|
|
3
|
+
description: Review committed branch changes with an independent Antigravity CLI (agy), Claude Code, Codex, or OpenCode reviewer, and repair actionable findings when requested.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Cross-Agent Review
|
|
@@ -11,10 +11,12 @@ and release rules in the repository; do not assume Bun, a workspace layout, or
|
|
|
11
11
|
particular CI job names.
|
|
12
12
|
|
|
13
13
|
Select an independent reviewer using a different model/provider from the author
|
|
14
|
-
when possible, not merely a different CLI: Hermes and
|
|
15
|
-
model as another harness
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
when possible, not merely a different CLI: Hermes, OpenCode, and `agy` can use
|
|
15
|
+
the same model as another harness (`agy` selects a model through
|
|
16
|
+
`review.agyModel`, so it can run a Claude model when authoring with Gemini or a
|
|
17
|
+
Gemini model when authoring with Claude). Hermes can coordinate this skill but
|
|
18
|
+
is not a `review` adapter. Honor a requested reviewer or effort; otherwise use
|
|
19
|
+
an available independent reviewer.
|
|
18
20
|
Run `agent-tool doctor` if CLI compatibility is uncertain.
|
|
19
21
|
|
|
20
22
|
Run noisy validation or repair checks through
|
|
@@ -24,9 +26,10 @@ Keep `agent-tool review` direct: it retains reviewer stderr in a private local
|
|
|
24
26
|
log and displays the complete final review. Never hide, truncate, or substitute
|
|
25
27
|
a command success receipt for findings and the final verdict.
|
|
26
28
|
|
|
27
|
-
Review committed changes with `agent-tool review
|
|
28
|
-
or `agent-tool review opencode`. Optional effort is
|
|
29
|
-
`xhigh`, or `max`. For a local or non-GitHub repository,
|
|
29
|
+
Review committed changes with `agent-tool review agy`, `agent-tool review claude`,
|
|
30
|
+
`agent-tool review codex`, or `agent-tool review opencode`. Optional effort is
|
|
31
|
+
`low`, `medium`, `high`, `xhigh`, or `max`. For a local or non-GitHub repository,
|
|
32
|
+
add `--base <commit-or-ref>`.
|
|
30
33
|
For a coordinated GitHub review, pin the fetched base using
|
|
31
34
|
`AGENT_TOOL_REVIEW_BASE_REF`, the base branch name such as `main` (not a
|
|
32
35
|
remote-tracking ref like `origin/main`), and `AGENT_TOOL_REVIEW_BASE_OID`, its
|
|
@@ -44,9 +47,11 @@ Observations under `Upstream (agent-tool):` concern files agent-tool generated
|
|
|
44
47
|
in the repository; they carry no severity and do not block. Report them for
|
|
45
48
|
agent-tool instead of editing those files.
|
|
46
49
|
|
|
47
|
-
If a CLI is unavailable, out of credits, or returns an unusable review, try
|
|
48
|
-
available reviewer
|
|
49
|
-
|
|
50
|
+
If a CLI is unavailable, out of credits, or returns an unusable review, try
|
|
51
|
+
another available reviewer (including `agy`, `claude`, `codex`, or `opencode`,
|
|
52
|
+
picking a different model/provider from the author) and disclose the fallback.
|
|
53
|
+
Do not silently convert a failed review into CLEAN or call an in-session review
|
|
54
|
+
independent.
|
|
50
55
|
|
|
51
56
|
For report-only requests, report findings without changing files or history.
|
|
52
57
|
When repairs are authorized, address actionable BLOCKER and MAJOR findings,
|
package/src/cli.ts
CHANGED
|
@@ -65,7 +65,7 @@ Usage: agent-tool [--repo <directory>] [--config <file>] <command>
|
|
|
65
65
|
release plan <package.json> [--github-output] [--allow-private-source]
|
|
66
66
|
release verify <package> <version> <merge-oid> --workflow name [--timeout seconds]
|
|
67
67
|
logs <file> [--max-bytes N] [--tail-lines N] Bounded local log tail
|
|
68
|
-
review <claude|codex|opencode> [effort] [--base <local-ref>]
|
|
68
|
+
review <agy|claude|codex|opencode> [effort] [--base <local-ref>]
|
|
69
69
|
review carry <reviewed-head> <new-head> [--base <ref>] Whether a clean review covers a base-merge and versions-only head
|
|
70
70
|
pr open [title] [--body-file file] Body from the file or stdin; branch already pushed
|
|
71
71
|
pr merge <subject-or-empty> <head-oid> <base-branch>
|
|
@@ -79,8 +79,8 @@ Usage: agent-tool [--repo <directory>] [--config <file>] <command>
|
|
|
79
79
|
dependencies check-terraform-plan <json-file> Read-only destructive-plan check
|
|
80
80
|
dependencies diff --base <ref> Declared dependencies added, removed, or changed since base
|
|
81
81
|
skills list
|
|
82
|
-
skills install [--harness <all|claude|codex|opencode|hermes>] [--apply]
|
|
83
|
-
skills check [--harness <all|claude|codex|opencode|hermes>]
|
|
82
|
+
skills install [--harness <all|agy|claude|codex|opencode|hermes>] [--apply]
|
|
83
|
+
skills check [--harness <all|agy|claude|codex|opencode|hermes>]
|
|
84
84
|
bun install [--cwd <dir>] Frozen-lockfile install with the pinned Bun
|
|
85
85
|
bun add <name@version>... [--dev|--optional|--peer] [--exact] [--cwd <dir>]
|
|
86
86
|
bun update <name[@version]>... [--cwd <dir>] Change versions of declared dependencies only
|
|
@@ -169,7 +169,7 @@ export function main(argv = process.argv.slice(2)): number | Promise<number> {
|
|
|
169
169
|
if (command === "doctor") {
|
|
170
170
|
usage(args.length === 0, "Usage: agent-tool doctor");
|
|
171
171
|
const result = doctor(process.cwd()); output(result);
|
|
172
|
-
return result.tools.find(item => item.name === "git")?.compatible && result.tools.some(item => ["claude", "codex", "opencode"].includes(item.name) && item.compatible) ? 0 : 1;
|
|
172
|
+
return result.tools.find(item => item.name === "git")?.compatible && result.tools.some(item => ["agy", "claude", "codex", "opencode"].includes(item.name) && item.compatible) ? 0 : 1;
|
|
173
173
|
}
|
|
174
174
|
if (command === "images") {
|
|
175
175
|
const action = args.shift();
|
|
@@ -266,7 +266,7 @@ export function main(argv = process.argv.slice(2)): number | Promise<number> {
|
|
|
266
266
|
if (command === "checks") { usage(args.shift() === "binaries", "Usage: checks binaries [--staged|--all|--range range|--from-upstream]"); return binariesCommand(args); }
|
|
267
267
|
if (command === "review" && args[0] === "carry") return carryReviewCommand(root, args.slice(1));
|
|
268
268
|
if (command === "review") {
|
|
269
|
-
const name = args.shift(); usage(!!name, "Usage: agent-tool review <claude|codex|opencode> [effort] [--base ref]");
|
|
269
|
+
const name = args.shift(); usage(!!name, "Usage: agent-tool review <agy|claude|codex|opencode> [effort] [--base ref]");
|
|
270
270
|
let effort: string | undefined, base: string | undefined;
|
|
271
271
|
while (args.length) {
|
|
272
272
|
const value = args.shift()!;
|
package/src/config.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface AgentToolConfig extends WorkflowConfig {
|
|
|
19
19
|
schemaVersion: 1;
|
|
20
20
|
subject: { conventional: boolean; maxLength: number; types: string[]; lowercaseInitial: boolean; rejectTerminalPeriod: boolean; ignoreGenerated: boolean };
|
|
21
21
|
merge: { requireChecks: boolean; requiredChecks: RequiredCheck[]; requireStrictBaseFreshness: boolean; checksTimeoutSeconds: number };
|
|
22
|
-
review: { claudeModel: string | null; codexModel: string | null; opencodeModel: string; opencodeVariants: Record<string, string>; timeoutMs: number };
|
|
22
|
+
review: { agyModel: string | null; claudeModel: string | null; codexModel: string | null; opencodeModel: string; opencodeVariants: Record<string, string>; timeoutMs: number };
|
|
23
23
|
versions: { packages: string[] | null; bundles: string[]; lockfile: "bun.lock" | null; validate: string[][]; commitMessage: string };
|
|
24
24
|
pr: { rejectClaudeBranding: boolean };
|
|
25
25
|
images: ImagesConfig;
|
|
@@ -42,7 +42,7 @@ export const DEFAULT_CONFIG: AgentToolConfig = {
|
|
|
42
42
|
ignoreGenerated: false,
|
|
43
43
|
},
|
|
44
44
|
merge: { requireChecks: true, requiredChecks: [], requireStrictBaseFreshness: false, checksTimeoutSeconds: 900 },
|
|
45
|
-
review: { claudeModel: null, codexModel: null, opencodeModel: "deepseek/deepseek-v4-pro", opencodeVariants: { low: "low", medium: "medium", high: "high", xhigh: "max", max: "max" }, timeoutMs: 600_000 },
|
|
45
|
+
review: { agyModel: null, claudeModel: null, codexModel: null, opencodeModel: "deepseek/deepseek-v4-pro", opencodeVariants: { low: "low", medium: "medium", high: "high", xhigh: "max", max: "max" }, timeoutMs: 600_000 },
|
|
46
46
|
versions: { packages: null, bundles: [], lockfile: "bun.lock", validate: [], commitMessage: "chore: bump package versions" },
|
|
47
47
|
pr: { rejectClaudeBranding: false },
|
|
48
48
|
images: { targets: {} },
|
|
@@ -127,7 +127,7 @@ export function parseConfig(source: string): AgentToolConfig {
|
|
|
127
127
|
keys(entry, ["name", "workflow"], "merge.requiredChecks entry");
|
|
128
128
|
if (typeof check.name !== "string" || !check.name.trim() || (check.workflow !== undefined && (typeof check.workflow !== "string" || !check.workflow.trim()))) invalid("merge.requiredChecks");
|
|
129
129
|
}
|
|
130
|
-
for (const key of ["claudeModel", "codexModel"] as const) {
|
|
130
|
+
for (const key of ["agyModel", "claudeModel", "codexModel"] as const) {
|
|
131
131
|
if (result.review[key] !== null && (typeof result.review[key] !== "string" || !/^[^\s]+$/.test(result.review[key]!))) invalid(`review.${key}`);
|
|
132
132
|
}
|
|
133
133
|
const variants = object(result.review.opencodeVariants, "review.opencodeVariants");
|
package/src/doctor.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { loadConfig } from "./config";
|
|
|
4
4
|
const specifications = [
|
|
5
5
|
{ name: "git", help: [] as string[], flags: [] as string[] },
|
|
6
6
|
{ name: "gh", help: ["pr", "checks", "--help"], flags: ["--json"] },
|
|
7
|
+
{ name: "agy", help: ["--help"], flags: ["--input-format", "--output-format", "--disable-slash-commands", "--settings", "--effort"] },
|
|
7
8
|
{ name: "claude", help: ["--help"], flags: ["--safe-mode", "--permission-mode", "--effort"] },
|
|
8
9
|
{ name: "codex", help: ["exec", "--help"], flags: ["--ignore-user-config", "--ignore-rules", "--strict-config", "--ephemeral", "--output-last-message"] },
|
|
9
10
|
// OpenCode 2: the variant rides in --model as provider/model#variant, and --standalone runs a private server.
|
package/src/harnesses.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type PrContext, resolveReviewContext, run } from "./git/prContext";
|
|
2
2
|
import { withPinnedReviewInput } from "./review/pinnedReviewInput";
|
|
3
|
-
import { resolveReviewEffort, type ReviewEffort } from "./review/reviewEffort";
|
|
4
|
-
import { buildReviewPrompt, CLAUDE_ACCESS_NOTE, CODEX_ACCESS_NOTE, OPENCODE_ACCESS_NOTE } from "./review/reviewPrompt";
|
|
3
|
+
import { DEFAULT_AGY_EFFORT, resolveReviewEffort, type ReviewEffort } from "./review/reviewEffort";
|
|
4
|
+
import { AGY_ACCESS_NOTE, buildReviewPrompt, CLAUDE_ACCESS_NOTE, CODEX_ACCESS_NOTE, OPENCODE_ACCESS_NOTE } from "./review/reviewPrompt";
|
|
5
|
+
import { spawnAgyReview } from "./review/solicitAgyReview";
|
|
5
6
|
import { spawnClaudeReview } from "./review/solicitClaudeCodeReview";
|
|
6
7
|
import { spawnCodexReview } from "./review/solicitCodexReview";
|
|
7
8
|
import { spawnOpencodeReview } from "./review/solicitOpencodeReview";
|
|
8
9
|
|
|
9
10
|
export interface Harness {
|
|
10
|
-
name: "claude" | "codex" | "opencode";
|
|
11
|
+
name: "agy" | "claude" | "codex" | "opencode";
|
|
11
12
|
executable: string;
|
|
12
13
|
skillDirectory: string;
|
|
13
14
|
defaultEffort: ReviewEffort;
|
|
@@ -17,6 +18,7 @@ export interface Harness {
|
|
|
17
18
|
|
|
18
19
|
/** Harness-specific discovery and invocation stay behind this small boundary. */
|
|
19
20
|
export const HARNESSES: readonly Harness[] = [
|
|
21
|
+
{ name: "agy", executable: "agy", skillDirectory: ".agents/skills", defaultEffort: DEFAULT_AGY_EFFORT, accessNote: AGY_ACCESS_NOTE, review: spawnAgyReview },
|
|
20
22
|
{ name: "claude", executable: "claude", skillDirectory: ".claude/skills", defaultEffort: "xhigh", accessNote: CLAUDE_ACCESS_NOTE, review: spawnClaudeReview },
|
|
21
23
|
{ name: "codex", executable: "codex", skillDirectory: ".agents/skills", defaultEffort: "high", accessNote: CODEX_ACCESS_NOTE, review: spawnCodexReview },
|
|
22
24
|
{ name: "opencode", executable: "opencode", skillDirectory: ".opencode/skills", defaultEffort: "high", accessNote: OPENCODE_ACCESS_NOTE, review: spawnOpencodeReview },
|
|
@@ -24,7 +26,7 @@ export const HARNESSES: readonly Harness[] = [
|
|
|
24
26
|
|
|
25
27
|
export function harnessNamed(name: string): Harness {
|
|
26
28
|
const harness = HARNESSES.find(item => item.name === name);
|
|
27
|
-
if (!harness) throw new Error(`Unknown harness '${name}'; choose claude, codex, or opencode.`);
|
|
29
|
+
if (!harness) throw new Error(`Unknown harness '${name}'; choose agy, claude, codex, or opencode.`);
|
|
28
30
|
return harness;
|
|
29
31
|
}
|
|
30
32
|
|
package/src/processes/session.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { ancestors, type ProcessRow } from "./table";
|
|
|
9
9
|
|
|
10
10
|
const SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "mksh", "pdksh", "oksh", "lksh", "yash", "posh", "osh", "ysh", "csh", "tcsh", "fish", "nu", "elvish", "xonsh"]);
|
|
11
11
|
// Agent harnesses by program name.
|
|
12
|
-
const HARNESSES = new Set(["claude", "codex", "opencode", "hermes", "omp", "gemini", "cursor-agent", "amp", "goose", "aider", "crush", "qwen"]);
|
|
12
|
+
const HARNESSES = new Set(["agy", "claude", "codex", "opencode", "hermes", "omp", "gemini", "cursor-agent", "amp", "goose", "aider", "crush", "qwen"]);
|
|
13
13
|
// Sandboxes a harness may start a shell through, which stay running as the shell's parent.
|
|
14
14
|
const SANDBOXES = new Set(["bwrap", "sandbox-exec", "codex-linux-sandbox"]);
|
|
15
15
|
const INTERPRETER = /^(?:node|nodejs|bun|deno|python[0-9.]*|ruby|perl)$/;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reasoning-effort levels accepted by the reviewer CLIs. `claude --effort`
|
|
3
|
-
*
|
|
4
|
-
* `
|
|
2
|
+
* Reasoning-effort levels accepted by the reviewer CLIs. `claude --effort` and
|
|
3
|
+
* `agy --effort` document this exact set (`low|medium|high|xhigh|max`, with
|
|
4
|
+
* `agy` failing loudly if the selected model does not support the requested
|
|
5
|
+
* level); `codex` takes the same names via its `model_reasoning_effort` config
|
|
6
|
+
* key.
|
|
5
7
|
*/
|
|
6
8
|
export const REVIEW_EFFORT_LEVELS = [
|
|
7
9
|
"low",
|
|
@@ -14,11 +16,14 @@ export const REVIEW_EFFORT_LEVELS = [
|
|
|
14
16
|
export type ReviewEffort = (typeof REVIEW_EFFORT_LEVELS)[number];
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
|
-
* Per-agent defaults.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Per-agent defaults. Antigravity CLI (`agy`) reviews at `high`, supported across
|
|
20
|
+
* its Claude and Gemini models; Claude reviews at `xhigh`; Codex reviews at
|
|
21
|
+
* `high`, which also pins the level rather than inheriting whatever
|
|
22
|
+
* `~/.codex/config.toml` happens to set. Opencode reviews at `high` too: it is
|
|
23
|
+
* the cheap fallback reviewer, and its deepseek-v4-pro model pays per thinking
|
|
24
|
+
* token.
|
|
21
25
|
*/
|
|
26
|
+
export const DEFAULT_AGY_EFFORT: ReviewEffort = "high";
|
|
22
27
|
export const DEFAULT_CLAUDE_EFFORT: ReviewEffort = "xhigh";
|
|
23
28
|
export const DEFAULT_CODEX_EFFORT: ReviewEffort = "high";
|
|
24
29
|
export const DEFAULT_OPENCODE_EFFORT: ReviewEffort = "high";
|
|
@@ -26,6 +26,8 @@ function runGit(rootDir: string, args: string[]): string {
|
|
|
26
26
|
* tools and no shell, while Codex reads the repo *through* its shell — telling
|
|
27
27
|
* Codex "you cannot run commands" would talk it out of reading files at all.
|
|
28
28
|
*/
|
|
29
|
+
export const AGY_ACCESS_NOTE =
|
|
30
|
+
"Read the surrounding files in the immutable repository snapshot when a finding depends on code the diff does not show; your read_file tool is confined to that snapshot, and you have no shell, edit, or network access";
|
|
29
31
|
export const CLAUDE_ACCESS_NOTE =
|
|
30
32
|
"Read the surrounding files in the immutable repository snapshot when a finding depends on code the diff does not show; you have Read, Grep, and Glob for that. You cannot run commands, so do not plan to build, typecheck, or execute tests";
|
|
31
33
|
export const CODEX_ACCESS_NOTE =
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { mkdtempSync, realpathSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { loadConfig } from "../config";
|
|
5
|
+
import { MAX_BUFFER_BYTES, spawnExitCode } from "../git/prContext";
|
|
6
|
+
import { withReviewDiagnostics } from "./diagnostics";
|
|
7
|
+
import { reviewExecutable } from "./executable";
|
|
8
|
+
import type { ReviewEffort } from "./reviewEffort";
|
|
9
|
+
import { spawnReviewer } from "./reviewerProcess";
|
|
10
|
+
import { type ReviewerEnv, relayReviewWithRetry } from "./runReview";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Session-only Antigravity CLI (`--settings`) JSON confining the review to the
|
|
14
|
+
* immutable snapshot. `Deny > Ask > Allow`, so denying commands, file writes,
|
|
15
|
+
* URLs, and MCP tools overrides any broader allow rule in the user's global
|
|
16
|
+
* `~/.gemini/antigravity-cli/settings.json`. Leaving `agentMode` empty and
|
|
17
|
+
* `toolPermission` at `request-review` turns off `auto` mode and makes every
|
|
18
|
+
* unlisted action (such as reading files outside the snapshot) fall back to
|
|
19
|
+
* headless auto-deny (https://antigravity.google/docs/cli/headless#permissions-in-headless-mode),
|
|
20
|
+
* while explicit `read_file` directory rules grant recursive read access to the
|
|
21
|
+
* snapshot alone under both resolved and symlinked temp spellings
|
|
22
|
+
* (https://antigravity.google/docs/permissions#supported-cli-actions-and-matching-rules).
|
|
23
|
+
*/
|
|
24
|
+
export function buildAgyReviewSettings(snapshotRoot: string): string {
|
|
25
|
+
const normalized = path.resolve(snapshotRoot).replaceAll("\\", "/");
|
|
26
|
+
const resolved = realpathSync(snapshotRoot).replaceAll("\\", "/");
|
|
27
|
+
const allow = [...new Set([normalized, resolved])].map(
|
|
28
|
+
(root) => `read_file(${root})`,
|
|
29
|
+
);
|
|
30
|
+
return JSON.stringify({
|
|
31
|
+
agentMode: "",
|
|
32
|
+
toolPermission: "request-review",
|
|
33
|
+
allowNonWorkspaceAccess: false,
|
|
34
|
+
disableSlashCommands: true,
|
|
35
|
+
permissions: {
|
|
36
|
+
allow,
|
|
37
|
+
deny: [
|
|
38
|
+
"command(*)",
|
|
39
|
+
"unsandboxed(*)",
|
|
40
|
+
"write_file(*)",
|
|
41
|
+
"read_url(*)",
|
|
42
|
+
"execute_url(*)",
|
|
43
|
+
"download_url(*)",
|
|
44
|
+
"mcp(*)",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build the `agy` argv for a non-interactive review. Stream JSON on stdin and
|
|
52
|
+
* stdout avoids argv length limits on large diffs while returning one machine-
|
|
53
|
+
* readable terminal `result` event instead of TUI output.
|
|
54
|
+
*/
|
|
55
|
+
export function buildAgyReviewArgs(
|
|
56
|
+
effort: ReviewEffort,
|
|
57
|
+
snapshotRoot: string,
|
|
58
|
+
model?: string | null,
|
|
59
|
+
): string[] {
|
|
60
|
+
return [
|
|
61
|
+
"--input-format",
|
|
62
|
+
"stream-json",
|
|
63
|
+
"--output-format",
|
|
64
|
+
"stream-json",
|
|
65
|
+
"--disable-slash-commands",
|
|
66
|
+
...(model ? ["--model", model] : []),
|
|
67
|
+
"--effort",
|
|
68
|
+
effort,
|
|
69
|
+
"--settings",
|
|
70
|
+
buildAgyReviewSettings(snapshotRoot),
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
75
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Extract the terminal `result` event from `agy --output-format stream-json`
|
|
80
|
+
* NDJSON output. Non-JSON lines are ignored so diagnostic noise cannot hide a
|
|
81
|
+
* real result event; a missing or non-SUCCESS terminal result yields an empty
|
|
82
|
+
* review and optional error message so the caller fails or retries cleanly.
|
|
83
|
+
*/
|
|
84
|
+
export function extractAgyStreamResult(stdout: string): {
|
|
85
|
+
readonly status: string | null;
|
|
86
|
+
readonly review: string;
|
|
87
|
+
readonly error: string | null;
|
|
88
|
+
} {
|
|
89
|
+
let found: { status: string | null; review: string; error: string | null } = {
|
|
90
|
+
status: null,
|
|
91
|
+
review: "",
|
|
92
|
+
error: null,
|
|
93
|
+
};
|
|
94
|
+
for (const line of stdout.split("\n")) {
|
|
95
|
+
const trimmed = line.trim();
|
|
96
|
+
if (!trimmed) continue;
|
|
97
|
+
let parsed: unknown;
|
|
98
|
+
try {
|
|
99
|
+
parsed = JSON.parse(trimmed);
|
|
100
|
+
} catch {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!isRecord(parsed) || parsed.event !== "result") continue;
|
|
104
|
+
const result = parsed.result;
|
|
105
|
+
if (!isRecord(result)) continue;
|
|
106
|
+
const status = typeof result.status === "string" ? result.status : null;
|
|
107
|
+
const response = typeof result.response === "string" ? result.response : "";
|
|
108
|
+
const error = typeof result.error === "string" ? result.error : null;
|
|
109
|
+
found = { status, review: status === "SUCCESS" ? response : "", error };
|
|
110
|
+
}
|
|
111
|
+
return found;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Run `agy` over an already-built review prompt in an empty neutral working
|
|
116
|
+
* directory (so repository-controlled `AGENTS.md`, `GEMINI.md`, hooks, MCP
|
|
117
|
+
* configs, and skills never load) and relay the terminal response. User-global
|
|
118
|
+
* `~/.gemini/` rules, skills, hooks, and plugins still load because `agy` has
|
|
119
|
+
* no `--safe-mode` flag; `--settings` denies commands, writes, URLs, and MCP
|
|
120
|
+
* tools over any user-global allow rules.
|
|
121
|
+
*/
|
|
122
|
+
export async function spawnAgyReview(
|
|
123
|
+
prompt: string,
|
|
124
|
+
effort: ReviewEffort,
|
|
125
|
+
snapshotRoot: string,
|
|
126
|
+
env: ReviewerEnv = process.env,
|
|
127
|
+
): Promise<number> {
|
|
128
|
+
const executable = reviewExecutable("agy", env);
|
|
129
|
+
if (executable === undefined) {
|
|
130
|
+
process.stderr.write("Antigravity CLI (`agy`) executable unavailable outside the repository.\n");
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
// Load config before creating the temp directory so a bad config never leaks it.
|
|
134
|
+
const reviewConfig = loadConfig().review;
|
|
135
|
+
const outDir = mkdtempSync(path.join(tmpdir(), "agent-tool-agy-"));
|
|
136
|
+
const streamInput = `${JSON.stringify({ event: "user", message: { content: prompt } })}\n`;
|
|
137
|
+
try {
|
|
138
|
+
return await relayReviewWithRetry("agy", async () => {
|
|
139
|
+
const result = await withReviewDiagnostics("agy", (fd) =>
|
|
140
|
+
spawnReviewer(
|
|
141
|
+
executable,
|
|
142
|
+
buildAgyReviewArgs(effort, snapshotRoot, reviewConfig.agyModel),
|
|
143
|
+
{
|
|
144
|
+
stderr: fd,
|
|
145
|
+
input: streamInput,
|
|
146
|
+
maxBuffer: MAX_BUFFER_BYTES,
|
|
147
|
+
timeoutMs: reviewConfig.timeoutMs,
|
|
148
|
+
// Neutral empty cwd keeps agy from loading branch-controlled
|
|
149
|
+
// AGENTS.md, GEMINI.md, hooks, MCP configs, or skills.
|
|
150
|
+
cwd: outDir,
|
|
151
|
+
env,
|
|
152
|
+
},
|
|
153
|
+
),
|
|
154
|
+
);
|
|
155
|
+
const exitCode = spawnExitCode("agy", result);
|
|
156
|
+
const parsed = extractAgyStreamResult(result.stdout ?? "");
|
|
157
|
+
if (exitCode !== 0) {
|
|
158
|
+
if (parsed.error) process.stderr.write(`agy review error: ${parsed.error}\n`);
|
|
159
|
+
return { exitCode, review: "" };
|
|
160
|
+
}
|
|
161
|
+
if (parsed.status !== null && parsed.status !== "SUCCESS") {
|
|
162
|
+
if (parsed.error) process.stderr.write(`agy review error: ${parsed.error}\n`);
|
|
163
|
+
return { exitCode: 1, review: "" };
|
|
164
|
+
}
|
|
165
|
+
return { exitCode: 0, review: parsed.review };
|
|
166
|
+
});
|
|
167
|
+
} finally {
|
|
168
|
+
rmSync(outDir, { recursive: true, force: true });
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/skills/bundled.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const BUNDLED_SKILLS: Readonly<Record<string, string>> = {
|
|
3
3
|
"app-store-readiness": "---\nname: app-store-readiness\ndescription: Audit and prepare iOS, Android, and web apps for release, covering platform interface guidance, accessibility, privacy disclosures, store metadata, and likely review blockers. Use for a readiness assessment or pre-submission preparation, not ordinary feature implementation.\n---\n\n# App Store Readiness\n\nProduce an evidence-backed release decision for the requested platforms.\nTreat store approval, build acceptance, automated accessibility checks, and\nhuman usability as separate outcomes. A successful build or beta upload does\nnot establish readiness.\n\n## Establish the candidate\n\nRead the repository's instructions, release documentation, and readiness\nguide (`docs/readiness.md` when present). Identify the source revision, app\nIDs, version/build, supported devices and OS/browser versions, distribution\ntracks, and the artifact actually tested. Map the user journeys and\napplicable features: accounts, payments, user content, ads/tracking,\nsensitive permissions, children, background work, local storage, and external\nservices. Mark irrelevant checks **N/A** with a reason.\n\nUse the user's scope. A report-only request stays read-only.\nPreparation/dogfooding can include reversible fixes and local tests. This\nskill does not by itself authorize uploads, submission, publication, messages\nto reviewers, changes to pricing or store declarations, or purchases. Existing\nexplicit authorization still applies; do not ask for it again. Do not\nfabricate review contacts, privacy answers, age ratings, or product claims.\n\n## Check the applicable platforms\n\nRead only the references for the requested platforms:\n\n- [iOS / iPadOS](references/ios.md): Apple review risks, HIG,\n accessibility, and submission evidence.\n- [Android](references/android.md): Play policy, Material/Compose\n accessibility, release behavior, and console evidence.\n- [Web](references/web.md): WCAG, browser behavior, privacy/support pages,\n and deployment evidence.\n\nOpen the current official sources linked there. Record the access date and\nthe exact requirement, deadline, exception, and distribution context that\naffect this candidate. Do not reuse remembered target API, SDK, billing, or\nregional payment rules. If a documentation page is only a JavaScript shell,\ntry its official linked documentation or an official text/JSON representation\nbefore relying on it. If a source is inaccessible, mark that decision\nunverified rather than silently assuming it is current. Distinguish mandatory\nstore policies from interface recommendations, chosen accessibility targets,\nand repository conventions. Do not present a guideline preference as certain\nrejection.\n\n## Gather evidence, repair, and retest\n\nTrace important claims from listing/policy → source and dependencies → built\nartifact → runtime behavior. Run the repository's documented readiness lanes\n(`docs/readiness.md`) when present against the candidate for artifact and\nstore-record evidence; their reports leave manual, declaration, and policy\nchecks unverified by design. Inspect\npublic links and actual store configuration when access is available; never\ninfer console completion from local metadata files. Keep credentials,\nreviewer contact details, user records, and private diagnostics out of reports\nand Git. Use local, disposable test data and dedicated devices where\navailable.\n\nExercise launch, the core task, settings, dismissal/back navigation,\nbackground/foreground, and persistence/failure paths. Include a compact\nlayout, large text/zoom, light/dark modes, localization, and relevant\nassistive input. For accessibility, inspect names, roles, states, reading\norder, focus, adjustment actions, contrast, and target sizes. Test the\nshipping configuration, including minification and extensions/widgets where\napplicable. Follow the repository's validation commands; do not invent a\nsubstitute gate.\n\nRecord reproducible failures with platform, device/configuration, affected\njourney, and supporting evidence. Repair actionable issues within scope and\nretest the affected paths. If fixing one finding changes data flows,\npermissions, commerce, or declared capabilities, reconcile the resulting\npolicy/metadata impact. Escalate product decisions only when needed; keep\nunrelated checks moving. Do not add accounts, analytics, permission prompts,\nor generic compliance UI merely to satisfy an inapplicable checklist.\n\n## Prepare the reviewer packet\n\nTreat what the reviewer receives as part of the candidate. Before a first\nsubmission, and whenever the core flow changes, the review notes answer\nwithout being asked:\n\n- the app's purpose and audience, the problem it solves, and why it is worth\n having over established apps in its category;\n- how to reach each main feature from launch, with demo credentials, sample\n files, or a statement that none are needed;\n- each external service the core features rely on (data providers,\n authentication, payments, AI), or a statement that there are none;\n- regional differences in features or content, or confirmation that there are\n none;\n- authorization for regulated services or third-party material, or why it\n does not apply;\n- where to find a screen recording on a physical device running the latest\n OS, starting at launch and covering the typical flow plus any account\n creation, login, and deletion, user-content reporting and blocking, and\n access to paid content.\n\nApple sends exactly this list as a Guideline 2.1 \"Information Needed\" request,\nwhich costs a first submission a full review round trip. Keep the notes under\nversion control when the repository keeps its listing metadata, guard their\ncoverage with a test, and keep recordings outside Git. Never commit demo\ncredentials: enter them in the console's sign-in fields (App Store Connect's\nApp Review Information, Play Console's App access) and have the committed notes\nsay where they are. Check every claim in the\nnotes against the submitted build. A recording or physical-device test the\nagent cannot perform is an owner prerequisite with an exact next action, never\na pass.\n\n## Deliver the readiness record\n\nUse the repository's existing report convention or a concise PR attachment.\nInclude:\n\n- Candidate revision/artifact, audit date, devices, commands, and official\n source links.\n- Per-platform result: **ready within tested scope**, **not ready**, or\n **incomplete**.\n- Findings with severity (blocker / major / minor / advisory), evidence,\n source or design basis, remediation, and retest outcome. Separate fixed\n findings from open ones.\n- A coverage table with **verified**, **failed**, **unverified**, and\n **N/A**. A source-only inspection is not a runtime pass; a simulator is not\n physical-device coverage; an automated scan is not a VoiceOver/TalkBack\n session or complete WCAG conformance.\n- Remaining release prerequisites with owner and an exact next action.\n Unverified submission-critical items prevent a ready verdict. Explain\n inaccessible-console or manual-testing limits without claiming those checks\n passed.\n\nKeep reusable procedure in the skill and dated findings in the report.\nRe-audit changes made after the tested candidate; do not carry evidence across\nunrelated artifacts. When shipping is requested, hand the concrete fixes and\nunresolved release prerequisites to the repository's shipping workflow.\nMerging improvements is distinct from declaring the app ready for public store\nsubmission.\n\n## Ownership\n\nagent-tool (`a2f0/agent-tool`) owns this skill in `skills/app-store-readiness/`.\nRepositories get it from `agent-tool skills install --apply`; do not edit the\ninstalled copy. Change it in agent-tool by PR. A repository's readiness guide,\nlanes, devices, and store records belong in its own docs, such as\n`docs/readiness.md`.\n",
|
|
4
4
|
"audit-trails": "---\nname: audit-trails\ndescription: Audit application workflows for missing or incomplete audit trails and produce an evidence-backed report or GitHub issue. Use for a requested audit-coverage review, not a general security review or a checklist inspection within the product.\n---\n\n# Audit Trails\n\nTrace consequential application changes from their entrypoints to durable\nhistory and authorized readers. Identify missing events, incomplete attribution,\nmisleading events, and inaccessible history. A timestamp, application log, or\ncurrent-state row alone is not a history of who changed what.\n\nWork from repository code and local tests. Do not read production data or\ncredentials, implement findings, deploy, or ship changes as part of this skill.\nCreate or update a GitHub issue when the user requested one; otherwise return\nthe report without publishing. Honor authorization already given in the session.\n\n## Establish scope\n\nStart [usage tracking](references/usage-receipts.md) now, before audit work or\ndelegation. Save a baseline and run/batch identity beside the private report;\ncheckpoint usage with coverage after each slice and before a pause. A resume\nkeeps the run identity, previous receipts, and publication handle, but starts a\nnew nonoverlapping batch. Missing counters must be disclosed, not estimated.\n\nRead repository guidance and its product and retention documentation. Resolve\nthe repository with `gh repo view --json nameWithOwner`. Record the audited\ncommit, dirty paths, requested focus, and exclusions. Do not claim a committed\nrevision describes uncommitted behavior. Use a clean worktree if dirty files\nwould affect a probe of the committed revision.\n\nRead the repository's own audit notes (its `AGENTS.md` or the docs it points\nto) when present: they may map entrypoints, the shared event store and its\nhelpers, migrations, readers, capability checks, and a local probe harness.\nTreat such a map as a starting point, not a coverage claim. Otherwise discover\nthe entrypoints, event stores, migrations, and readers yourself.\n\nWith no focus, inventory the application and prioritize access changes,\ndestructive actions, financial changes, and externally initiated work. Review\nmanageable slices sequentially; keep a coverage table so partial work is not\nreported as a complete audit. With `resume <report-path>`, verify the recorded\nrepository and revision, reuse its evidence, and continue unchecked paths. If\nthe revision changed, revalidate affected findings before carrying them forward.\n\nKeep reports and scratch probes outside the checkout unless the user requested\na repository artifact. Record the report's absolute path for resuming.\n\n## Trace coverage\n\nInventory write entrypoints: UI/API mutations, authentication hooks, webhooks,\nscheduled jobs, inbound messages, maintenance scripts, and shared helpers used\nby REST or MCP. Read-only sensitive access is a separate requirement; flag it\nonly when repository policy or the requested scope requires an access log.\n\nFor each selected workflow, follow:\n\n1. Actor and organization resolution, authorization, and validation.\n2. The actual persisted mutation and its success, no-op, and failure paths.\n3. Event writes through direct calls, shared helpers, database triggers, or\n provider-specific histories. Read migrations in order, including dropped\n and replacement triggers; when trigger coverage is uncertain, inspect the\n final schema in a scratch database with every migration applied, not one\n built before a later migration. Search results are leads, not proof of\n absence.\n4. Atomicity between the change and its event; conditional writes, stale saves,\n retries, and duplicate webhooks must not produce misleading success events.\n5. Stable action, resource/subject IDs, time, actor snapshot, and minimal useful\n change details. Distinguish the initiating human, API key/channel, and system\n or provider actor. Never recommend fabricating a human for background work.\n6. Authorized retrieval in the workspace feed and relevant record history,\n tenant/capability boundaries, and what remains after deletion or retention.\n\nTreat a separate contract or provider history as existing coverage. Report a\nshared-feed integration gap separately from a missing durable trail. Likewise,\ndocumented purge behavior is not automatically a defect, and historical gaps\ncannot be repaired by inventing actors, timestamps, or old values.\n\nProposed details should use an allowlist. Do not copy secrets, tokens, document\ncontents, screening reports, or unrestricted payloads into events or issues.\nIf a new event would expose restricted data through a broadly readable feed,\ninclude the required reader permission change in the proposal.\n\n## Verify and rank\n\nBefore promoting a finding, trace the write and all plausible event mechanisms.\nUse an existing test or a small synthetic local probe when it can resolve a\nmaterial uncertainty. A useful probe changes a record, inspects durable history,\nand checks rollback, replay, or reader isolation where relevant. Record the\ncommand and result. Do not create tests that merely search for helper names.\n\nLabel evidence **Reproduced** (a local behavior probe or test) or **Traced**\n(a complete source path). Keep unresolved suspicions under **Unverified leads**.\nDo not present absence from a grep result as a verified finding.\n\nRank impact with a concrete explanation: high for changes to access, money,\nor destructive operations that cannot be attributed; medium for ordinary\nbusiness changes or missing shared visibility with another durable trail;\nlow for presentation or convenience gaps. Adjust to actual product behavior.\n\nSearch existing issues before publication. Link matching work and avoid opening\nduplicates. Recheck code before reusing a historical finding.\n\n## Deliver\n\nUse [the report template](references/report-template.md). Each finding needs a\ntrigger, actual and expected behavior, revision-pinned evidence, impact,\nrecommended event/reader behavior, and observable acceptance criteria. Include\nchecked coverage, unverified leads, and explicit limitations.\n\nInclude an **Audit usage receipt** in every report, even for partial work,\nzero findings, or unavailable counters. Follow [usage publication and\nreadback](references/usage-receipts.md#publish-and-resume): the receipt goes in\nthe issue body so findings and accounting publish together. Preserve existing\npublication and security-disclosure authorization; without it, save locally.\nPrefer one ranked report issue unless the user requested separate issues. If a\nmatching issue already covers the audit, update it only when authorized to do\nso; otherwise link it in the report. Never recreate an issue to retry a failed\nreceipt update. Report incomplete publication alongside the saved report.\n\nReturn the issue or report link, the highest-impact gaps, what was actually\nchecked, and remaining scope. Discovery does not imply the gaps were fixed.\n\n## Ownership\n\nagent-tool (`a2f0/agent-tool`) owns this skill in `skills/audit-trails/`.\nRepositories get it from `agent-tool skills install --apply`; do not edit the\ninstalled copy. Change it in agent-tool by PR. Repository-specific audit maps,\nprobe harnesses, and retention rules go in that repository's `AGENTS.md` or the\ndocs it points to.\n",
|
|
5
|
-
"cross-agent-review": "---\nname: cross-agent-review\ndescription: Review committed branch changes with an independent Claude Code, Codex, or OpenCode reviewer, and repair actionable findings when requested.\n---\n\n# Cross-Agent Review\n\nUse the installed `agent-tool` executable. Read the repository's development and\nreview policy and `agent-tool.json` when present. Keep project validation commands\nand release rules in the repository; do not assume Bun, a workspace layout, or\nparticular CI job names.\n\nSelect an independent reviewer using a different model/provider from the author\nwhen possible, not merely a different CLI: Hermes and
|
|
5
|
+
"cross-agent-review": "---\nname: cross-agent-review\ndescription: Review committed branch changes with an independent Antigravity CLI (agy), Claude Code, Codex, or OpenCode reviewer, and repair actionable findings when requested.\n---\n\n# Cross-Agent Review\n\nUse the installed `agent-tool` executable. Read the repository's development and\nreview policy and `agent-tool.json` when present. Keep project validation commands\nand release rules in the repository; do not assume Bun, a workspace layout, or\nparticular CI job names.\n\nSelect an independent reviewer using a different model/provider from the author\nwhen possible, not merely a different CLI: Hermes, OpenCode, and `agy` can use\nthe same model as another harness (`agy` selects a model through\n`review.agyModel`, so it can run a Claude model when authoring with Gemini or a\nGemini model when authoring with Claude). Hermes can coordinate this skill but\nis not a `review` adapter. Honor a requested reviewer or effort; otherwise use\nan available independent reviewer.\nRun `agent-tool doctor` if CLI compatibility is uncertain.\n\nRun noisy validation or repair checks through\n`agent-tool run --label <check> -- <command> [args...]`. Read its bounded failure\ntail and use `agent-tool logs <log>` or a targeted search for more evidence.\nKeep `agent-tool review` direct: it retains reviewer stderr in a private local\nlog and displays the complete final review. Never hide, truncate, or substitute\na command success receipt for findings and the final verdict.\n\nReview committed changes with `agent-tool review agy`, `agent-tool review claude`,\n`agent-tool review codex`, or `agent-tool review opencode`. Optional effort is\n`low`, `medium`, `high`, `xhigh`, or `max`. For a local or non-GitHub repository,\nadd `--base <commit-or-ref>`.\nFor a coordinated GitHub review, pin the fetched base using\n`AGENT_TOOL_REVIEW_BASE_REF`, the base branch name such as `main` (not a\nremote-tracking ref like `origin/main`), and `AGENT_TOOL_REVIEW_BASE_OID`, its\nfetched commit. Fetch from the repository that owns the PR, which can differ\nfrom the checkout's origin.\n\nUse `agent-tool repo context --fetch` to resolve and fetch the PR's own base,\nthen record the exact base and HEAD before reviewing. The tool reviews raw committed\nfiles and excludes worktree edits. A zero exit means a complete review was\nreturned; it does not mean the findings are non-blocking. Read the final\n`VERDICT: BLOCKER|MAJOR|MINOR|SUGGESTION|CLEAN` and the findings. A reviewer\nthat labels findings `[P0]` through `[P3]` uses the same scale: `[P0]` and\n`[P1]` are BLOCKER and MAJOR, `[P2]` and `[P3]` are MINOR and SUGGESTION.\nObservations under `Upstream (agent-tool):` concern files agent-tool generated\nin the repository; they carry no severity and do not block. Report them for\nagent-tool instead of editing those files.\n\nIf a CLI is unavailable, out of credits, or returns an unusable review, try\nanother available reviewer (including `agy`, `claude`, `codex`, or `opencode`,\npicking a different model/provider from the author) and disclose the fallback.\nDo not silently convert a failed review into CLEAN or call an in-session review\nindependent.\n\nFor report-only requests, report findings without changing files or history.\nWhen repairs are authorized, address actionable BLOCKER and MAJOR findings,\nvalidate with the repository's relevant checks, commit the repairs, and review\nthe new HEAD. Continue while meaningful progress is possible; report an impasse\nwhen progress requires a material user decision. A repaired commit is unreviewed\nuntil the next review completes. Preserve unrelated work.\n\nBefore reporting success, confirm HEAD still matches the reviewed commit and\nthat an existing PR points to that same commit. If the base moved, refresh it and\nreview again before shipping, unless the new HEAD only integrated the base and\nprepared versions and `agent-tool review carry <reviewed-head> <new-head>`\naccepts it; then report the review as carried, with both heads. Report\nreviewer, exact base and head IDs, verdict, remaining findings, validation, and\nany repairs performed. This skill does not authorize pushing, opening a PR, or\nmerging unless the user requested that work.\n",
|
|
6
6
|
"explicit-state-machines": "---\nname: explicit-state-machines\ndescription: Find implicit state machines in a repository, or across many repositories, and refactor them into explicit ones (a closed set of states, typed events, one pure transition function) without changing behavior. Use when the user asks to \"find all of the implicit state machines\", to replace tangled boolean flags or scattered status writes, or to dogfood this pass across repositories; not for adding a state-machine library or redesigning features.\n---\n\n# Explicit State Machines\n\nAn implicit state machine is code that moves through modes (idle, loading,\nfailed, done) without naming them: several booleans that are only valid in\nsome combinations, a status string written from many places, nullable fields\nwhose presence means \"we are in phase X\", or effects that chain off each other\nto advance a process. Bugs live in the combinations nobody named:\n`isLoading && error`, a retry that fires after `done`, a dialog both open and\nsubmitting twice.\n\nAn explicit machine names every state once, carries each state's data only in\nthat state, and changes state only through one function of `(state, event)`.\nThe pass finds the implicit ones, converts those where the conversion removes\nimpossible states or scattered transitions, and proves behavior did not change.\n\n## Find candidates\n\n`agent-tool state-machines` ranks tracked source files by two signals:\nlifecycle booleans toggled together (`isLoading`, `hasError`,\n`_running`, `busy.current`, `this.#rendered`), and status-like fields assigned\nthree or more string values from three or more places (`step.status = ...`).\nIt reads extensionless scripts by their shebang and is read-only. It skips\nSQL comparisons, status fields whose every write is an `UPDATE` naming its\nfrom-state, and enum case payload labels (`.ended(shouldResume: true)`).\n\n- `agent-tool state-machines [path...] [--limit N] [--min-score N] [--json]`\n scans the current repository; each path names the repository holding it.\n If the repository's pinned agent-tool lacks the command, run\n `bunx --bun @a2f0/agent-tool@latest state-machines`.\n- `--limit N` (default 25 per repository, 0 for all), `--min-score N`\n (default 3), `--json` for agents.\n\nThe script finds leads, not verdicts, and it misses whole families. Also read\nfor these by hand, starting from the places state lives (stores, providers,\nhooks, workers, sync loops, connection handlers, upload and checkout flows,\nwizards, CLI subcommands that resume):\n\n- `loading`/`error`/`data` held as separate fields, or a nullable `error`\n beside a non-null `data`; any nullable value paired with a boolean or a\n second nullable (`nowPlaying` with `interruptedNoise`, `reservation` with\n `editing`). The scanner sees booleans only.\n- State split between a context and per-component state that an effect\n re-syncs, and \"already handled\" dedupe fields that quietly mean \"confirmed\n started\".\n- Fields that are set together and cleared together (`startedAt`, `jobId`,\n `abortController`) and so encode \"running\".\n- `useEffect` chains where one effect sets state that triggers the next.\n- Retry, polling, and reconnect loops guarded by counters and flags.\n- Status columns or enums whose transitions are enforced nowhere (any writer\n may set any value), in the database or in API handlers.\n- Shell, Python, or Expect scripts that track progress with several\n variables.\n- One nullable `error` shared by a load phase and user actions: starting an\n action clears the load's failure, so the view falls back to \"Loading...\"\n after a failed load. Split a `loading | ready | failed` load machine from\n the actions' own errors.\n\n## Decide what to convert\n\nConvert a candidate only when at least one holds:\n\n1. Two or more of its variables can hold a combination that is meaningless\n (`isLoading && isError`, `data` set while `status === \"failed\"`).\n2. Its transitions are written in several places, so no single place says\n which moves are legal.\n3. A bug or missing guard follows from either (an event handled in a state\n where it must be ignored). Fix the bug in the same change, with a test that\n fails before it, and say so in the PR.\n\nLeave it alone when the flags are independent (a theme toggle and a sidebar\ntoggle are a product of two machines, not one), when there is a single\nboolean, when a status is only read (an API response's field mirrored into\nUI), when it already is a discriminated union with one writer, or when the\nmodule is about to be deleted. Also leave alone:\n\n- Status columns whose writes all live in one module, each a conditional\n update naming the states it may leave (`UPDATE ... WHERE status = $from`),\n so that module reads as the transition table. Where writers are spread out\n or name no from-state, add one `ALLOWED` table and check it in the update\n instead; a value `CHECK` alone does not enforce transitions. A database\n transition trigger only restates a guarded module and breaks fixtures that\n simulate races by setting states.\n- Monotone flags with one writer each that move one way and are read only\n by cleanup (lock held, applying, committed), and append-only accumulators.\n- Static records checked by one validator, and before/after comparisons that\n validate rather than track progress.\n- Effect and promise guards (`cancelled`, `mounted`) on their own.\n- One request in flight plus one \"run again\" flag, both written from one\n function (`pending` with `started`): three reachable phases, one writer.\n- A ref mirroring a state to block a double click before re-render\n (`isSubmitting` with `isSubmittingRef`), written together. The missing\n mirror is the bug: a `busy` guard read from a click handler's render lets\n two clicks start the work twice.\n- Flags in different components (a parent's `editing`, and `busy` in a child\n that only exists while editing): the mount already excludes the bad pair.\n- Latest-wins request counters with one writer (`++request` paired with\n `request === current`): already the recommended guard, not a machine.\n- A one-time focus-return ref written together with the close event.\n- A single set-once setup flag (`isConfigured`).\n- A memoized single teardown promise (`closing ??= teardown()`) with a\n one-way `closed` flag only that teardown sets.\n- A boolean that is only an event's payload field\n (`interruptionEnded(shouldResume:)`): it is part of an event, not state.\n\nRecord each one you leave and why, so the next pass does not reread it.\n\n## Convert\n\nFollow `references/patterns.md` for the language at hand. In every language:\n\n1. List the states and the data each one carries; list the events. Write the\n transition table before the code, and keep it in the PR body.\n2. Model states as a closed type: a TypeScript discriminated union on a\n `status` (or the repository's existing tag name), a Swift enum with\n associated values, a Kotlin sealed interface, a Python `Enum` or tagged\n dataclasses, a Go typed constant with a transition function.\n3. Write one pure `transition(state, event)` (a reducer). Make the switch\n exhaustive (`never` check, `assertNever`, `@unique` enums, sealed `when`).\n Say explicitly what an event does in a state where it does not apply:\n ignore it (return the same state) or throw in development; never fall\n through silently.\n4. Keep every guard the old code had. A `cancelled` flag or an unmount check\n that drops a stale response must become a request tag carried by the\n state and its events (only the current request may finish), never a bare\n \"is it loading?\" check, which accepts `start(A) -> reset -> start(B) ->\n succeed(A)`. Test that sequence. A cleaned-up effect's callbacks (its own\n abort's rejection included) must not dispatch either; see `patterns.md`.\n5. Move side effects out of the transition: effects run on entering a state\n (a worker loop that switches on it, or an effect keyed on the state's whole\n identity: `status` plus its request tag), not inside the reducer. An\n effect keyed on `status` alone misses `loading(A) -> loading(B)` and never\n starts B; test a replacement request.\n6. Keep call sites small: derive old booleans from the state\n (`const isLoading = state.status === \"loading\"`) where many readers use\n them, rather than rewriting every consumer in the same change.\n7. Derive old booleans so they stay stable across intermediate states: an\n effect keyed on `editing` must not refire when a replacement passes\n through `reserving`. Keep effects tied to an event, not a state (resuming\n audio on a press), in the handler.\n8. Use no new dependency. Use a state-machine library (XState, Robot) only if\n the repository already depends on it.\n9. Test the transition table directly: every legal transition, a sample of\n ignored events per state, and the impossible combinations that the old\n code allowed. Keep the existing behavior tests passing unchanged; a test\n that must change shows a behavior change, which belongs in its own PR.\n Run the new behavior tests against the old file (`git show <base>:<file>`\n into a copy kept aside) to prove the refactor changed nothing and that a\n bug's regression test fails before its fix. For output that is printed or\n saved as JSON, assert key order too.\n10. Check every new guard against existing listeners: a guard that only acts\n in `ready` breaks a listener reacting to an event fired mid-render.\n11. Treat \"initial\" props (`initialEditing`) as one-time requests, on mount or\n when they turn true, not as levels that re-apply whenever another input\n changes. Fold a mirrored prop the machine depends on (`canWrite`) into the\n state, synced by one effect declared before the request effect.\n\n## Ship\n\n- Work on a `refactor/<topic>` branch (`fix/<topic>` when the change fixes a\n bug) and ship with the repository's `ship-pr` skill: its validation, its\n independent review, its merge policy.\n- Check file-count or naming budgets (ls-lint) before adding a machine module\n and its test; a full directory may need the tests in an existing file.\n- One PR per repository per pass, unless the diff passes about 600 lines or\n spans unrelated areas; then one PR per area, each independently valid. In\n large repositories plan one PR per machine: formatted transition tables\n and their tests grow fast.\n- The PR body lists each converted machine (file, states, events, the\n impossible combinations removed, any bug fixed) and each candidate left\n alone with its reason.\n- Repository-specific findings (where machines cluster, conventions such as\n the tag name or reducer location) go in that repository's agent guidance.\n Cross-repository lessons go in `references/lessons.md` here, by PR to\n agent-tool.\n\n## Across many repositories\n\nA pass over many repositories follows the coordinating workspace's sweep\nrules (status, ledger, one delegate per repository, `ship-pr` each). Run\n`agent-tool state-machines --json` in each repository first, attach its slice\nto that repository's delegate brief, and remind delegates to read beyond the\nscript's list.\nRepositories whose push hook or ship policy runs a full browser, simulator,\nor package gate need a heavy slot to ship: a delegate without one prepares a\nreviewed commit or open PR and hands off to a finisher that holds one.\n\n## Ownership\n\nagent-tool (`a2f0/agent-tool`) owns this skill in\n`skills/explicit-state-machines/`, and the `state-machines` scanner with its\ntests in `src/stateMachines/`. Repositories get it from\n`agent-tool skills install --apply`; do not edit the installed copy. Change it\nin agent-tool by PR, and send cross-repository lessons to\n`references/lessons.md` there. Repository-specific conventions still go in\nthat repository's `AGENTS.md`.\n",
|
|
7
7
|
"open-issue": "---\nname: open-issue\ndescription: Open a GitHub issue the user explicitly requested, assigned to the authenticated GitHub user, with a reviewable title and body.\n---\n\n# Open Issue\n\nOpen an issue only when the user explicitly asks for one; finding a bug,\nrecording evidence, or following another skill does not authorize it. Follow\nrepository guidance for where issues belong, labels, and templates.\n\nResolve the target repository with `agent-tool repo context` (its `repo`\nfield) from the checkout, or the `owner/repo` the user named; never infer it\nfrom a folder name. Before creating, search open issues for a duplicate:\n\n```sh\ngh issue list --repo <owner/repo> --state open --search '<key words>' --json number,title,url\n```\n\nIf one matches, report it instead of opening another, and assign it with\n`gh issue edit <number> --repo <owner/repo> --add-assignee @me` when the user\nwants it tracked.\n\nWrite a specific title and a body that states the observed behavior, the\nexpected behavior, and reproduction steps or evidence (commands, versions,\nlinks). Never include secret values. Use only labels that already exist\n(`gh label list --repo <owner/repo>`). Put the body in a temporary file, then\ncreate the issue assigned to the authenticated GitHub user:\n\n```sh\ngh issue create --repo <owner/repo> --title '<title>' --body-file /path/to/issue-body.md --assignee @me\n```\n\nAlways pass `--assignee @me`; assign other people only when the user names\nthem, in addition to `@me` unless the user says otherwise. Confirm the result\nwith `gh issue view <url> --json url,assignees` and, if the assignee is missing,\nadd it with `gh issue edit <url> --add-assignee @me`. Report the issue URL and\nits assignees, or the exact error if assignment failed.\n",
|
|
8
8
|
"open-pr": "---\nname: open-pr\ndescription: Open a GitHub pull request for the current feature branch with a validated title and a reviewable description.\n---\n\n# Open PR\n\nUse the installed `agent-tool`. Follow repository policy for validation, commits,\nand branch naming. Resolve the repository and default branch with `agent-tool repo context`;\ndo not assume the branch is named main. Preserve unrelated work and finish\nrequested changes and appropriate checks before publishing them.\n\nEnsure the intended commit is on a feature branch and use\n`agent-tool branch push <reviewed-head> --remote <remote>` through normal hooks.\nIt names the destination explicitly and verifies local/remote HEAD afterward;\na changed result needs another review. Respect existing push authorization.\nIf the user only requested a draft description, prepare it without publishing.\n\nWrite a title that satisfies the data-only `agent-tool.json` subject policy.\nDescribe the concrete resulting behavior and relevant validation. When the\nbranch changes package manifests, run\n`agent-tool dependencies diff --base <base-oid>` and name every `newPackages`\nentry in the body with its manifest and version, so a reviewer sees new\nthird-party code however it was added. Put multiline body text in a temporary\nfile, then run:\n\n```sh\nagent-tool pr open 'feat: describe the change' --body-file /path/to/pr-body.txt\n```\n\nOmitting the title uses the latest commit subject. The tool refuses duplicate\nopen PRs and requires the branch to be pushed at its local HEAD. It does not\npush for you. Resolve a fork's head/base identities explicitly if the repository\nuses fork PRs; the initial open helper supports same-repository branches.\n\nReport the created PR link and any remaining validation or review work. Run\n`agent-tool teardown` first, stop what the work started, and report what remains.\n",
|