refactor(core): 简化 Agent 提示词系统,移除 provider 动态加载

- 直接在 build.ts 和 plan.ts 中定义 prompt 字段
- 简化 system-prompt.ts,移除 provider/forProvider/plan 函数
- 简化 agent.ts 中的 resolveSystemPrompt 方法
- 删除不再需要的提示词文件 (anthropic/beast/gemini/qwen/plan.txt)
- 更新 package.json build 脚本,移除复制 prompts 目录
This commit is contained in:
2025-12-16 13:48:56 +08:00
parent 7f51d33319
commit f7b934a69e
10 changed files with 159 additions and 701 deletions
+44 -12
View File
@@ -1,24 +1,53 @@
import type { AgentInfo } from '../types.js';
/**
* Plan Agent 专用提示词
*/
const PLAN_PROMPT = `<system-reminder>
# Plan Mode - System Reminder
CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:
ANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,
or ANY other bash command to manipulate files - commands may ONLY read/inspect.
This ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user
edit requests. You may ONLY observe, analyze, and plan. Any modification attempt
is a critical violation. ZERO exceptions.
---
## Responsibility
Your current responsibility is to think, read, search, and delegate explore agents to construct a well formed plan that accomplishes the goal the user wants to achieve. Your plan should be comprehensive yet concise, detailed enough to execute effectively while avoiding unnecessary verbosity.
Ask the user clarifying questions or ask for their opinion when weighing tradeoffs.
**NOTE:** At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.
---
## Important
The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
</system-reminder>`;
/**
* 计划 Agent
* 主模式,设计实现方案(只读探索,不执行修改
* 主模式,设计实现方案(只读探索,可写入计划文件
*
* 特性:
* - 细粒度 bash 权限:允许只读命令(ls, grep, git log 等)
* - plan_mode_respond 工具:结构化输出计划和进度
* - 完整探索能力:read + 只读 bash + search
*
* 注意:prompt 由 SystemPrompt.plan() 提供,Agent 使用时会自动追加
* - 限制写入:只能写入 ~/.ai-terminal-assistant/plan/ 目录
*/
export const planAgent: Omit<AgentInfo, 'name'> = {
description: '计划模式,设计实现方案(只读探索,不执行修改',
description: '计划模式,设计实现方案(只读探索,可写入计划文件',
mode: 'primary',
// prompt 留空,由 SystemPrompt.plan() + SystemPrompt.provider() 组合
prompt: PLAN_PROMPT,
tools: {
enabled: [
// 文件读取(只读)
// 文件操作,限制只能写入 plan 目录
'read_file',
'write_file',
'list_directory',
'search_files',
'grep_content',
@@ -42,8 +71,9 @@ export const planAgent: Omit<AgentInfo, 'name'> = {
// Todo 管理
'todoread',
'todowrite',
// Plan 模式响应
'plan_mode_respond',
// Plan 模式工具
'ask_user_question',
'exit_plan_mode',
// 代码分析
'repo_map',
'skill',
@@ -53,9 +83,11 @@ export const planAgent: Omit<AgentInfo, 'name'> = {
permission: {
file: {
read: 'allow',
write: 'deny',
edit: 'deny',
delete: 'deny',
write: 'allow',
edit: 'allow',
delete: 'ask',
// 只允许写入计划目录
allowedWritePaths: ['~/.ai-terminal-assistant/plan/*'],
},
bash: {
enabled: true,