refactor: 移除模板变量 {{change-name}} 替换功能,模板改为纯静态文本
This commit is contained in:
@@ -91,7 +91,7 @@ CLI 通过子命令提供帮助和版本信息,不使用 `--help`/`--version`
|
||||
- **四阶段固定**:discuss → plan → build → archive,不可自定义增删
|
||||
- **配置覆盖策略**:阶段级别全量覆盖,不支持字段级合并。自定义 plan 时需完整重写所有 documents
|
||||
- **配置文件名**:`.rune/config.yaml`,不是 `rune.yml`
|
||||
- **模板变量**:仅支持 `{{change-name}}`,不需要其他变量(信息已在上下文中)
|
||||
- **文档模板**:纯静态文本模板,不进行变量替换
|
||||
|
||||
### 各阶段行为
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ stages:
|
||||
depend: [design]
|
||||
```
|
||||
|
||||
计划阶段文档模板支持 `{{change-name}}` 变量,运行时会替换为实际变更名。
|
||||
计划阶段文档模板为纯静态文本,直接输出不作变量替换。
|
||||
|
||||
## 设计决策
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ export async function assemblePlanPrompt(
|
||||
}
|
||||
|
||||
if (doc.template) {
|
||||
const rendered = doc.template.replace(/\{\{change-name\}\}/g, changeName);
|
||||
parts.push(`\n### 格式模板:\n${rendered}`);
|
||||
parts.push(`\n### 格式模板:\n${doc.template}`);
|
||||
}
|
||||
|
||||
if (doc.depend && doc.depend.length > 0) {
|
||||
|
||||
@@ -250,7 +250,7 @@ rune status
|
||||
- 考虑边界情况和错误处理
|
||||
|
||||
请将文档写入指定路径。`,
|
||||
template: `# {{change-name}} 设计文档
|
||||
template: `# 设计文档
|
||||
|
||||
## 背景
|
||||
|
||||
@@ -279,7 +279,7 @@ rune status
|
||||
- 使用 checkbox 格式:- [ ] 待完成,- [x] 已完成
|
||||
|
||||
请将文档写入指定路径。`,
|
||||
template: `# {{change-name}} 任务列表
|
||||
template: `# 任务列表
|
||||
|
||||
- [ ]
|
||||
`,
|
||||
|
||||
@@ -56,9 +56,10 @@ describe("assemblePlanPrompt", () => {
|
||||
expect(prompt).not.toContain("# 已有设计");
|
||||
});
|
||||
|
||||
it("替换模板中的 {{change-name}}", async () => {
|
||||
it("包含格式模板(纯静态文本)", async () => {
|
||||
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "design");
|
||||
expect(prompt).toContain("user-auth 设计文档");
|
||||
expect(prompt).toContain("格式模板");
|
||||
expect(prompt).toContain("# 设计文档");
|
||||
expect(prompt).not.toContain("{{change-name}}");
|
||||
});
|
||||
|
||||
@@ -110,7 +111,7 @@ describe("assemblePlanPrompt", () => {
|
||||
{
|
||||
name: "spec",
|
||||
prompt: "生成规格",
|
||||
template: "# {{change-name}} 规格",
|
||||
template: "# 规格文档",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -118,7 +119,7 @@ describe("assemblePlanPrompt", () => {
|
||||
};
|
||||
const prompt = await assemblePlanPrompt(config, TMP_DIR, "my-feature", "spec");
|
||||
expect(prompt).toContain("spec");
|
||||
expect(prompt).toContain("my-feature 规格");
|
||||
expect(prompt).toContain("规格文档");
|
||||
expect(prompt).not.toContain("design");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ describe("defaultConfig", () => {
|
||||
it("design 文档有 template", () => {
|
||||
const designDoc = defaultConfig.stages.plan!.documents.find((d) => d.name === "design");
|
||||
expect(designDoc!.template).toBeTruthy();
|
||||
expect(designDoc!.template).toContain("{{change-name}}");
|
||||
expect(designDoc!.template).toContain("设计文档");
|
||||
});
|
||||
|
||||
it("task 文档有 template", () => {
|
||||
|
||||
@@ -115,7 +115,7 @@ stages:
|
||||
documents:
|
||||
- name: spec
|
||||
prompt: 生成规格文档
|
||||
template: "# {{change-name}} 规格"
|
||||
template: "# 规格文档"
|
||||
`,
|
||||
);
|
||||
|
||||
@@ -127,7 +127,7 @@ stages:
|
||||
await mkdir(getChangeDir(TMP_DIR, "test"), { recursive: true });
|
||||
const planPrompt = await assemblePlanPrompt(config, TMP_DIR, "test", "spec");
|
||||
expect(planPrompt).toContain("spec");
|
||||
expect(planPrompt).toContain("test 规格");
|
||||
expect(planPrompt).toContain("规格文档");
|
||||
expect(planPrompt).not.toContain("design");
|
||||
|
||||
expect(config.stages.build).toBeDefined();
|
||||
|
||||
Reference in New Issue
Block a user