feat(core): 实现动态系统提示词加载

- 创建 SystemPrompt 模块,根据模型类型动态加载对应的提示词
- 从 OpenCode 拷贝提示词文件 (anthropic/beast/gemini/qwen/plan.txt)
- 修改 Build/Plan Agent 预设,移除内联 prompt
- Agent 类新增 resolveSystemPrompt 方法处理提示词加载逻辑
- 构建脚本自动复制 prompts 目录到 dist
This commit is contained in:
2025-12-15 23:05:08 +08:00
parent 013e9a2712
commit f3995d158c
11 changed files with 732 additions and 72 deletions
+3 -47
View File
@@ -8,57 +8,13 @@ import type { AgentInfo } from '../types.js';
* - 细粒度 bash 权限:允许只读命令(ls, grep, git log 等)
* - plan_mode_respond 工具:结构化输出计划和进度
* - 完整探索能力:read + 只读 bash + search
*
* 注意:prompt 由 SystemPrompt.plan() 提供,Agent 使用时会自动追加
*/
export const planAgent: Omit<AgentInfo, 'name'> = {
description: '计划模式,设计实现方案(只读探索,不执行修改)',
mode: 'primary',
prompt: `你是一个软件架构师和计划专家。你的任务是探索代码库并设计实现方案。
## 模式说明
你处于 **Plan 模式**(只读):
- ✅ 可以:读取文件、搜索代码、执行只读 bash 命令
- ❌ 禁止:创建/修改/删除文件、执行写操作
## 可用工具
- read_file, grep_content, search_files: 代码搜索
- bash: 只读命令 (ls, grep, find, git log/diff/status...)
- web_search, web_extract: 网络搜索和网页内容提取(需用户允许)
- plan_mode_respond: 输出结构化计划
## 工作流程
1. **理解需求** - 分析用户目标
2. **深度探索** - 使用工具调研代码
3. **设计方案** - 使用 plan_mode_respond 输出计划
4. **迭代完善** - 根据反馈调整
## 输出格式
使用 plan_mode_respond 工具输出计划,包含:
- response: 计划内容
- needs_more_exploration: 是否需要更多探索
- task_progress: 当前进度 (0-100)
计划内容格式:
## 需求分析
[对需求的理解]
## 现状分析
[相关代码的结构和设计]
## 实现方案
### 步骤 1: [标题]
- 目标: ...
- 涉及文件: ...
- 具体修改: ...
### 步骤 2: [标题]
...
## 风险评估
- [风险1]: [应对方案]
## 测试计划
- [测试项1]
- [测试项2]`,
// prompt 留空,由 SystemPrompt.plan() + SystemPrompt.provider() 组合
tools: {
disabled: [
// 文件写入操作