feat: add overridable review slash command (#4973)

This commit is contained in:
Aiden Cline
2025-12-01 22:18:58 -08:00
committed by GitHub
parent 1864e8c863
commit 6355ed6ae7
2 changed files with 93 additions and 14 deletions

View File

@@ -1,15 +1,12 @@
import z from "zod"
import { Config } from "../config/config"
import { Instance } from "../project/instance"
import PROMPT_INITIALIZE from "./template/initialize.txt"
import { Bus } from "../bus"
import { Identifier } from "../id/id"
import PROMPT_INITIALIZE from "./template/initialize.txt"
import PROMPT_REVIEW from "./template/review.txt"
export namespace Command {
export const Default = {
INIT: "init",
} as const
export const Event = {
Executed: Bus.event(
"command.executed",
@@ -36,10 +33,27 @@ export namespace Command {
})
export type Info = z.infer<typeof Info>
export const Default = {
INIT: "init",
REVIEW: "review",
} as const
const state = Instance.state(async () => {
const cfg = await Config.get()
const result: Record<string, Info> = {}
const result: Record<string, Info> = {
[Default.INIT]: {
name: Default.INIT,
description: "create/update AGENTS.md",
template: PROMPT_INITIALIZE.replace("${path}", Instance.worktree),
},
[Default.REVIEW]: {
name: Default.REVIEW,
description: "review changes [commit|branch|pr], defaults to uncommitted",
template: PROMPT_REVIEW.replace("${path}", Instance.worktree),
subtask: true,
},
}
for (const [name, command] of Object.entries(cfg.command ?? {})) {
result[name] = {
@@ -52,14 +66,6 @@ export namespace Command {
}
}
if (result[Default.INIT] === undefined) {
result[Default.INIT] = {
name: Default.INIT,
description: "create/update AGENTS.md",
template: PROMPT_INITIALIZE.replace("${path}", Instance.worktree),
}
}
return result
})