feat: 内置默认配置及测试
This commit is contained in:
83
src/defaults/config.ts
Normal file
83
src/defaults/config.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import type { RuneConfig } from "../types.ts";
|
||||
|
||||
export const defaultConfig: RuneConfig = {
|
||||
stages: {
|
||||
discuss: {
|
||||
prompt: `你是一位经验丰富的软件架构师和技术顾问。
|
||||
用户将与你讨论一个软件开发需求。
|
||||
|
||||
你的职责是:
|
||||
1. 深入理解用户的需求背景和目标
|
||||
2. 提出关键问题澄清模糊之处
|
||||
3. 分析技术可行性和潜在风险
|
||||
4. 提供专业的架构建议
|
||||
|
||||
请与用户自由讨论,不要急于输出文档。讨论充分后,建议用户使用 /plan <变更名> 进入规划阶段。`,
|
||||
},
|
||||
plan: {
|
||||
documents: [
|
||||
{
|
||||
name: "design",
|
||||
prompt: `请根据之前的讨论内容,生成一份设计文档。
|
||||
|
||||
要求:
|
||||
- 清晰描述背景和目标
|
||||
- 列出方案选项并给出推荐
|
||||
- 定义关键接口和数据结构
|
||||
- 考虑边界情况和错误处理
|
||||
|
||||
请将文档写入指定路径。`,
|
||||
template: `# {{change-name}} 设计文档
|
||||
|
||||
## 背景
|
||||
|
||||
## 目标
|
||||
|
||||
## 方案
|
||||
|
||||
## 接口设计
|
||||
|
||||
## 注意事项
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "task",
|
||||
prompt: `请根据设计文档,生成一份任务列表。
|
||||
|
||||
要求:
|
||||
- 将设计拆分为可独立执行的小任务
|
||||
- 每个任务应该足够具体,能直接编码实现
|
||||
- 任务之间有合理的依赖顺序
|
||||
- 使用 checkbox 格式:- [ ] 待完成,- [x] 已完成
|
||||
|
||||
请将文档写入指定路径。`,
|
||||
template: `# {{change-name}} 任务列表
|
||||
|
||||
- [ ]
|
||||
`,
|
||||
},
|
||||
],
|
||||
},
|
||||
build: {
|
||||
prompt: `你是一位高级软件工程师。
|
||||
请按照任务列表,逐个完成编码任务。
|
||||
|
||||
要求:
|
||||
- 严格按顺序执行,从第一个未完成的任务开始
|
||||
- 每完成一个任务,立即更新 task.md 中对应项为 [x]
|
||||
- 遵循项目现有的代码风格和约定
|
||||
- 编写必要的测试
|
||||
- 完成所有任务后,提示用户可以使用 /archive <变更名> 归档`,
|
||||
},
|
||||
archive: {
|
||||
prompt: `当前变更已进入归档阶段。
|
||||
|
||||
请确认:
|
||||
1. 所有任务已标记为已完成
|
||||
2. 如有未完成项,提醒用户并中止归档
|
||||
3. 如全部完成,总结本轮变更内容
|
||||
|
||||
归档后,建议用户使用 /discuss 开始下一轮需求讨论。`,
|
||||
},
|
||||
},
|
||||
};
|
||||
58
tests/defaults/config.test.ts
Normal file
58
tests/defaults/config.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { describe, it, expect } from "bun:test";
|
||||
import { defaultConfig } from "../../src/defaults/config.ts";
|
||||
|
||||
describe("defaultConfig", () => {
|
||||
it("包含所有四个阶段的配置", () => {
|
||||
expect(defaultConfig.stages.discuss).toBeDefined();
|
||||
expect(defaultConfig.stages.plan).toBeDefined();
|
||||
expect(defaultConfig.stages.build).toBeDefined();
|
||||
expect(defaultConfig.stages.archive).toBeDefined();
|
||||
});
|
||||
|
||||
it("discuss 阶段有 prompt", () => {
|
||||
expect(defaultConfig.stages.discuss!.prompt).toBeTruthy();
|
||||
expect(typeof defaultConfig.stages.discuss!.prompt).toBe("string");
|
||||
});
|
||||
|
||||
it("plan 阶段包含 design 和 task 两个文档配置", () => {
|
||||
const docs = defaultConfig.stages.plan!.documents;
|
||||
expect(docs).toHaveLength(2);
|
||||
expect(docs[0].name).toBe("design");
|
||||
expect(docs[1].name).toBe("task");
|
||||
for (const doc of docs) {
|
||||
expect(doc.prompt).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it("plan 的 task 文档配置存在", () => {
|
||||
const taskDoc = defaultConfig.stages.plan!.documents.find(
|
||||
(d) => d.name === "task",
|
||||
);
|
||||
expect(taskDoc).toBeDefined();
|
||||
expect(taskDoc!.prompt).toBeTruthy();
|
||||
});
|
||||
|
||||
it("design 文档有 template", () => {
|
||||
const designDoc = defaultConfig.stages.plan!.documents.find(
|
||||
(d) => d.name === "design",
|
||||
);
|
||||
expect(designDoc!.template).toBeTruthy();
|
||||
expect(designDoc!.template).toContain("{{change-name}}");
|
||||
});
|
||||
|
||||
it("task 文档有 template", () => {
|
||||
const taskDoc = defaultConfig.stages.plan!.documents.find(
|
||||
(d) => d.name === "task",
|
||||
);
|
||||
expect(taskDoc!.template).toBeTruthy();
|
||||
expect(taskDoc!.template).toContain("- [ ]");
|
||||
});
|
||||
|
||||
it("build 阶段有 prompt", () => {
|
||||
expect(defaultConfig.stages.build!.prompt).toBeTruthy();
|
||||
});
|
||||
|
||||
it("archive 阶段有 prompt", () => {
|
||||
expect(defaultConfig.stages.archive!.prompt).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user