refactor(core): 移除 BASH_TOOL_EXTRA_NOTES 和 GIT_COMMIT_AND_PR_CREATION_INSTRUCTION

- 从模板引擎中移除这两个函数的注册
- 从 bash 工具描述中移除对应的模板变量
- 删除不再需要的 git-instructions.txt 文件
- 更新单元测试,移除相关测试用例
This commit is contained in:
2025-12-16 17:00:13 +08:00
parent 09dc046f8f
commit 87edd6e35b
4 changed files with 1 additions and 150 deletions
@@ -1,9 +1,8 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { describe, it, expect } from 'vitest';
import {
renderTemplate,
renderPromptTemplate,
createToolDescriptionContext,
clearGitInstructionsCache,
} from '../../../src/template/renderer.js';
import type { ExtendedTemplateContext } from '../../../src/template/types.js';
import {
@@ -160,14 +159,6 @@ describe('Template Renderer - 模板渲染器', () => {
});
describe('createToolDescriptionContext - 工具描述上下文', () => {
beforeEach(() => {
clearGitInstructionsCache();
});
afterEach(() => {
clearGitInstructionsCache();
});
it('包含工具名称变量', () => {
const context = createToolDescriptionContext();
expect(context.custom?.BASH_TOOL_NAME).toBe('bash');
@@ -181,8 +172,6 @@ describe('createToolDescriptionContext - 工具描述上下文', () => {
expect(typeof context.__functions__.CUSTOM_TIMEOUT_MS).toBe('function');
expect(typeof context.__functions__.MAX_TIMEOUT_MS).toBe('function');
expect(typeof context.__functions__.MAX_OUTPUT_CHARS).toBe('function');
expect(typeof context.__functions__.BASH_TOOL_EXTRA_NOTES).toBe('function');
expect(typeof context.__functions__.GIT_COMMIT_AND_PR_CREATION_INSTRUCTION).toBe('function');
});
it('函数返回正确的配置值', () => {
@@ -191,20 +180,6 @@ describe('createToolDescriptionContext - 工具描述上下文', () => {
expect(context.__functions__.MAX_TIMEOUT_MS()).toBe(MAX_TIMEOUT_MS);
expect(context.__functions__.MAX_OUTPUT_CHARS()).toBe(MAX_OUTPUT_CHARS);
});
it('BASH_TOOL_EXTRA_NOTES 默认返回空字符串', () => {
const context = createToolDescriptionContext();
expect(context.__functions__.BASH_TOOL_EXTRA_NOTES()).toBe('');
});
it('GIT_COMMIT_AND_PR_CREATION_INSTRUCTION 返回 Git 指令', () => {
const context = createToolDescriptionContext();
const gitInstructions = context.__functions__.GIT_COMMIT_AND_PR_CREATION_INSTRUCTION();
expect(typeof gitInstructions).toBe('string');
// 验证包含关键内容
expect(gitInstructions).toContain('Committing changes with git');
expect(gitInstructions).toContain('Creating pull requests');
});
});
describe('renderPromptTemplate - 提示词模板渲染', () => {