feat: OpenCode 和 Claude Code 适配器及测试

This commit is contained in:
2026-06-08 17:24:24 +08:00
parent 6c2a229536
commit 7530a5a743
3 changed files with 216 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { existsSync } from "node:fs";
import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { STAGES } from "../types.ts";
const COMMANDS_DIR = ".claude/commands";
export async function injectClaudeCode(projectRoot: string): Promise<void> {
for (const stage of STAGES) {
const hasChangeName = stage !== "discuss";
const commandDir = join(projectRoot, COMMANDS_DIR);
await mkdir(commandDir, { recursive: true });
const commandPath = join(commandDir, `${stage}.md`);
if (!existsSync(commandPath)) {
const cmd = hasChangeName
? `rune ${stage} <变更名>`
: `rune ${stage}`;
const nameHint = hasChangeName
? "\n如果用户没有指定变更名称请向用户确认。"
: "";
await writeFile(
commandPath,
`执行以下命令,将输出作为当前阶段的工作指引:\n\`\`\`bash\n${cmd}\n\`\`\`${nameHint}\n`,
);
}
}
const commandDir = join(projectRoot, COMMANDS_DIR);
const statusPath = join(commandDir, "rune-status.md");
if (!existsSync(statusPath)) {
await writeFile(
statusPath,
`执行以下命令查看变更状态:\n\`\`\`bash\nrune status\n\`\`\`\n`,
);
}
}