fix(core): restore generic edit as fallback tool in agent sessions

This commit is contained in:
Ma 2026-04-16 22:10:04 +08:00
parent 964f53a526
commit 77b8a9a5a8
3 changed files with 7 additions and 1 deletions

View file

@ -56,6 +56,7 @@ describe("buildAgentSystemPrompt", () => {
expect(prompt).toContain("write_truth_file");
expect(prompt).toContain("rename_entity");
expect(prompt).toContain("patch_chapter_text");
expect(prompt).toContain("edit");
expect(prompt).toContain("grep");
expect(prompt).toContain("ls");
});
@ -66,7 +67,7 @@ describe("buildAgentSystemPrompt", () => {
expect(prompt).toContain("write_truth_file");
expect(prompt).toContain("用户要求重写/精修已有章节");
expect(prompt).toContain("revise_chapter");
expect(prompt).not.toContain("用户想做小修改(改名字、调设定)→ 用 edit 直接修改");
expect(prompt).toContain("只有当上述专用工具都不适合");
});
it("Chinese prompt warns NOT to call architect", () => {

View file

@ -240,6 +240,7 @@ export async function runAgentSession(
createWriteTruthFileTool(pipeline, projectRoot, bookId),
createRenameEntityTool(pipeline, projectRoot, bookId),
createPatchChapterTextTool(pipeline, projectRoot, bookId),
createEditTool(projectRoot),
createGrepTool(projectRoot),
createLsTool(projectRoot),
],

View file

@ -81,6 +81,7 @@ export function buildAgentSystemPrompt(bookId: string | null, language: string):
- **write_truth_file** story_biblevolume_outlinebook_rulescurrent_focus
- **rename_entity** /
- **patch_chapter_text**
- **edit** deterministic 使
- **grep** "哪一章提到了某个角色"
- **ls**
@ -92,6 +93,7 @@ export function buildAgentSystemPrompt(bookId: string | null, language: string):
- / revise_chapter
- rename_entity
- patch_chapter_text
- 使 edit
-
- ** architect**
- ****
@ -128,6 +130,7 @@ export function buildAgentSystemPrompt(bookId: string | null, language: string):
- **write_truth_file** Replace a canonical truth file in story/
- **rename_entity** Rename a character or entity across the book
- **patch_chapter_text** Apply a local deterministic patch to a chapter
- **edit** Generic exact string replacement editor (use only when the dedicated deterministic tools do not fit)
- **grep** Search content across chapters
- **ls** List files or chapters
@ -139,6 +142,7 @@ export function buildAgentSystemPrompt(bookId: string | null, language: string):
- Use revise_chapter for rewrite/polish/rework of existing chapters
- Use rename_entity for character/entity renames
- Use patch_chapter_text for local chapter fixes
- Use edit only as a last-resort generic editor after you have read the exact file content
- Chat directly for other questions
- **Do NOT call architect a book already exists**
- **Do NOT use emoji in your responses**