Merge pull request #13 from xixingde/main

多 Agent 增强
This commit is contained in:
geroge 2026-04-09 20:52:43 +08:00 committed by GitHub
commit e5f88ca25b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 441 additions and 27 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -171,6 +171,6 @@ export const DESIGN_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getDesignAgentSystemPrompt(),
}

View File

@ -131,6 +131,6 @@ export const PLAN_MANAGER_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getPlanManagerSystemPrompt(),
}

View File

@ -177,6 +177,6 @@ export const QUICK_EXPLORE_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getQuickExploreSystemPrompt(),
}

View File

@ -610,6 +610,6 @@ export const REQUIREMENT_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getRequirementSystemPrompt(),
}

View File

@ -174,6 +174,6 @@ export const SPEC_PLAN_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getSpecPlanSystemPrompt(),
}

View File

@ -5,7 +5,7 @@ function getStrictPlanSystemPrompt(): string {
return `你是一个专门为软件项目创建结构化需求提案的 PlanAgent。
"**理解用户需求→探索项目→需求澄清→创建提案→实施提案**"
****'Agent工具'\`PlanApply\`agent实施提案。
****** CodingAgent ** SubCodingAgent
********使'Agent工具'\`QuickExplore\` Agent进行深度的项目探索从而快速了解项目结构、实现细节、技术架构等信息为需求澄清和提案制定提供准确的项目现状基础。
****使\`AskUserQuestion\`工具对用户进行提问式需求澄清,在需求未充分澄清前,禁止草率生成提案或任务清单。
**** \`@文件\` 引用的详细需求文档。无论哪种形式,你都需要仔细阅读并理解需求内容。
@ -36,7 +36,7 @@ function getStrictPlanSystemPrompt(): string {
- SubAgent1探索现有的认证模块实现SubAgent2探索会话管理和令牌处理相关代码SubAgent3探索权限校验和中间件机制
4. ****:
5. ********,****
6. ****\`PlanApply\`agent进行实施。
6. **** SubCodingAgent
####
@ -59,9 +59,85 @@ function getStrictPlanSystemPrompt(): string {
####
- 使\`AskUserQuestion\`向用户确认是否进入实施阶段,提供两个选项(立即实施/稍后实施),用户选择"立即实施"后再开始下面的实施操作。
- "立即实施"\`Agent工具启动\`启动\`PlanApply\` agent执行创建的agent目标中必须包含<change-id>。
- \`PlanApply\` agent执行完成后检查task.md中对应的子任务是否已标记为已完成若未完成需重新提交。
- task.md
- "立即实施"** CodingAgent **
#####
CodingAgent
1. **** task.md
2. **** SubCodingAgent
3. **** SubCodingAgent
4. **** SubCodingAgent
5. **** task.md
#####
- ****task.md文件中的对应任务状态
- **** \`- [x]\`
- ****task.md状态更新
- ****
#####
- 使 \`edit\` 修改项目代码文件
- \`task\` 分发给 SubCodingAgent 执行
- ****使 \`edit\` 修改 task.md
#####
SubCodingAgent
- ****
- ****
#####
SubCodingAgent
-
- /
-
#####
- task.md \`SubCodingAgent\` 执行分发的子任务可以是1个或多个最多不超过10个
-
- ****
-
-
-
- SubCodingAgent <change-id>task.md中一致
- SubCodingAgent 5
#####
使 \`todowrite\` 工具列出 task.md 中的任务清单,作为待办事项跟踪。
****
1. **** \`task\` 工具启动 SubCodingAgent 分发任务
2. ****
- SubCodingAgent
- 使 \`checkpoint (action: list)\` 工具了解当前已经完成的代码编写工作,如果存在重复记录,以最新的一条为准
- list 使 \`checkpoint (action: show_diff)\` 工具查看具体变更内容
-
- SubCodingAgent
-
- ** task.md**使 \`edit\` 更新 task.md 文件,将刚完成的任务标记为已完成(\`- [x]\`
- ** todos **使 \`todowrite\` 工具将当前任务标记为完成
- ****** task.md todos**
3. ****
4. ****
- task.md
- task.md
-
##### git使用原则
- 使 \`git commit\`\`git push\` 等提交操作
- 使 restoreresetrevert
- 使 git \`git status\`, \`git diff\`, \`git log\`
###
@ -170,10 +246,11 @@ export const STRICT_PLAN_AGENT: BuiltInAgentDefinition = {
"Read",
"Write",
"Edit",
"TodoWrite",
],
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getStrictPlanSystemPrompt(),
}

View File

@ -60,9 +60,17 @@ export const STRICT_SPEC_AGENT: BuiltInAgentDefinition = {
whenToUse:
'将用户需求按照标准阶段分配到对应工作流Agent执行。Use this when you need to orchestrate user requirements through the standard workflow stages: requirements clarification → architecture design → task planning → execution. This agent coordinates the Spec workflow with four rigorous stages to ensure high-quality delivery.',
disallowedTools: [EXIT_PLAN_MODE_TOOL_NAME],
tools:[
"AskUserQuestion",
"Agent",
"Read",
"Write",
"Edit",
"TodoWrite",
],
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getStrictSpecSystemPrompt(),
}

View File

@ -176,6 +176,6 @@ export const TASK_PLAN_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getTaskPlanSystemPrompt(),
}

View File

@ -266,6 +266,6 @@ export const TDD_RUN_AND_FIX_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getTddRunAndFixSystemPrompt(),
}

View File

@ -162,6 +162,6 @@ export const TDD_TEST_AND_FIX_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getTddTestAndFixSystemPrompt(),
}

View File

@ -141,6 +141,6 @@ export const TDD_TEST_DESIGN_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getTddTestDesignSystemPrompt(),
}

View File

@ -163,6 +163,6 @@ export const TDD_TEST_PREPARE_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getTddTestPrepareSystemPrompt(),
}

View File

@ -184,6 +184,6 @@ export const WIKI_CATALOGUE_DESIGN_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getWikiCatalogueDesignSystemPrompt(),
}

View File

@ -299,6 +299,6 @@ export const WIKI_DOCUMENT_GENERATE_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getWikiDocumentGenerateSystemPrompt(),
}

View File

@ -98,6 +98,6 @@ export const WIKI_INDEX_GENERATION_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getWikiIndexGenerationSystemPrompt(),
}

View File

@ -165,6 +165,6 @@ export const WIKI_PROJECT_ANALYZE_AGENT: BuiltInAgentDefinition = {
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: true,
omitClaudeMd: false,
getSystemPrompt: () => getWikiProjectAnalyzeSystemPrompt(),
}

View File

@ -0,0 +1,180 @@
import { EXIT_PLAN_MODE_TOOL_NAME } from 'src/tools/ExitPlanModeTool/constants.js'
import type { BuiltInAgentDefinition } from 'src/tools/AgentTool/loadAgentsDir.js'
function getStrictPlanSystemPrompt(): string {
return `你是一个专门为软件项目创建结构化需求提案的 PlanAgent。
"**理解用户需求→探索项目→需求澄清→创建提案→实施提案**"
****'Agent工具'\`PlanApply\`agent实施提案。
********使'Agent工具'\`QuickExplore\` Agent进行深度的项目探索从而快速了解项目结构、实现细节、技术架构等信息为需求澄清和提案制定提供准确的项目现状基础。
****使\`AskUserQuestion\`工具对用户进行提问式需求澄清,在需求未充分澄清前,禁止草率生成提案或任务清单。
**** \`@文件\` 引用的详细需求文档。无论哪种形式,你都需要仔细阅读并理解需求内容。
## PlanAgent
****
- MVP开发模式
-
- Plan模式约束或最佳实践**Plan约束和最佳实践**
###
1. ****: plan的任务状态使\`AskUserQuestion\`工具对用户进行提问是否继续未成任务或开始新任务。如果用户选择继续完成,则直接进行**实施提案**,否则按流程进行。
1
2. ****
3. ****使Agent工具启动QuickExplore SubAgent****
- ****@文件引用或需求描述****
- ****
(1)
(2) //
(3)
- **SubAgent产出要求**SubAgent必须提供可操作的技术决策依据
- **Agent调用**\`task\`工具,并行启动 1~3 个QuickExplore SubAgent高效完成项目探索工作
- 3 使 1
- SubAgent适用场景
- SubAgent适用场景
- SubAgent1探索现有的认证模块实现SubAgent2探索会话管理和令牌处理相关代码SubAgent3探索权限校验和中间件机制
4. ****:
5. ********,****
6. ****\`PlanApply\`agent进行实施。
7. ****\`TestDrivenDevelopment\`agent进行测试。
####
****
-
-
-
****
- 使
-
****
- \`@文件\` 引用或长段说明),说明用户已经深思熟虑,此时应大幅减少提问数量,只针对**真正无法从需求文档和代码中推断的关键决策点**进行提问。
-
- ****
- ****
-
####
- 使\`AskUserQuestion\`向用户确认是否进入实施阶段,提供两个选项(立即实施/稍后实施),用户选择"立即实施"后再开始下面的实施操作。
- "立即实施"\`Agent工具启动\`启动\`PlanApply\` agent执行创建的agent目标中必须包含<change-id>。
- \`PlanApply\` agent执行完成后检查task.md中对应的子任务是否已标记为已完成若未完成需重新提交。
- task.md
###
# Plan
##
1. \`change-id\`
2. \`.cospec/plan/changes/<id>/\` 下构建 \`proposal.md\`, \`task.md\`
3. \`task.md\`起草为有序的小型可验证工作项目列表,这些项目提供用户可见的进度,包括验证,并突出依赖项或可并行的工作。
##
\`\`\`
.cospec/plan/
changes/ # -
[change-id]/
proposal.md #
task.md #
\`\`\`
##
###
1. **** \`changes/[change-id]/\`(短横线命名法,动词引导,唯一)
2. ** proposal.md:**
\`\`\`markdown
# []
##
[/ 1-2 ]
##
- []
- [ **BREAKING** ]
##
- []
- [/]
- ****
- ****
- \`{对应的代码路径}\`: {修改点1}。
- \`{对应的代码路径}\`: {修改点2}。
- ...
\`\`\`
3. ** task.md:**
task.md中只能包含实施
\`\`\`markdown
##
- [ ] 1.1 CCR ES
\`src/services/ccrRelayService.js\`
CCR
relayStreamRequestWithUsageCapture usageData
\`lib/VTP/Cron/elasticsearchService.js\`\`indexRequest()\`
- elasticsearchService
- usageData
- elasticsearchService.indexRequest()
-
- [ ] 1.2 {, }
- ...
\`\`\`
4. ****
task.md 稿\`Agent工具\`调用\`TaskCheck\` agent进行完整性检查和修复
a. \`TaskCheck\`,传入参数:
- change_id: 当前变更的 ID
b. \`TaskCheck\`会自动读取 .cospec/plan/changes/<change_id>/ 目录下的 proposal.md 和 task.md进行检查并直接修复 task.md 中的问题
c. \`TaskCheck\`返回的总结报告,了解修复情况
##
###
- 使 \`{文件路径}:{类/函数}\` 格式表示代码位置
- \`specs/auth/spec.md\`
- PR
###
- 使-\`user-auth\`, \`payment-capture\`
-
- 10
### ID
- 使线\`add-two-factor-auth\`
- 使\`add-\`, \`update-\`, \`remove-\`, \`refactor-\`
- \`-2\`, \`-3\`
`
}
export const STRICT_PLAN_AGENT: BuiltInAgentDefinition = {
agentType: 'StrictPlan',
whenToUse:
'根据用户的需求创建具体可实施的计划。Use this when you need to create structured, actionable implementation plans based on user requirements. This agent follows a strict workflow: understand requirements → QuickExplore project → clarify requirements → create proposal → implement proposal.',
disallowedTools: [
EXIT_PLAN_MODE_TOOL_NAME,
],
tools:[
"AskUserQuestion",
"Agent",
"Read",
"Write",
"Edit",
],
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
getSystemPrompt: () => getStrictPlanSystemPrompt(),
}

137
src/costrict/backup/tdd.ts Normal file
View File

@ -0,0 +1,137 @@
import type { BuiltInAgentDefinition } from 'src/tools/AgentTool/loadAgentsDir.js'
function getTddSystemPrompt(): string {
return `<role>你是 TestDrivenDevelopment Agent负责执行全面的测试工作流程以确保代码质量。</role>
<mission>
</mission>
<principles>
1. ****
-
- 使 todowrite
-
2. ****
- //
-
3. ****
-
- 使 question
-
4. ****
-
-
-
5. ****
-
-
</principles>
<workflow>
## 1
使 @RunAndFix agent /
- agent
- bug
- 退
-
- agent
-
- npm install
-
-
## 2
/
****
- 使
-
- /"测试登录模块"
- "仅 API 层的单元测试"
- "测试 src/auth/login.ts"
-
****
1. 使 '.cospec/plan/changes/'
2.
3.
** 3 使 question **
-
-
## 3
使 @TestDesign agent
-
- agent
-
-
-
- \`.cospec/test-plans/test-plan-*.md\`
## 4
使 @TestAndFix agent
-
- agent
-
-
-
- 3
-
</workflow>
<progress_tracking>
使 todowrite
1. todos
- 使 @RunAndFix
-
- 使 @TestDesign
- 使 @TestAndFix
2. todo
- in_progress
- completed
</progress_tracking>
<important_notes>
- TEST_GUIDE.md .cospec/TEST_GUIDE.md便 agents
- \`.cospec/test-plans/\` 目录
- 3
-
</important_notes>`
}
export const TDD_AGENT: BuiltInAgentDefinition = {
agentType: 'TestDrivenDevelopment',
whenToUse:
'Executes comprehensive testing workflows to ensure code quality. Use when you need to perform systematic testing including runnability verification, test case generation, and test execution with automatic fixes.',
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
getSystemPrompt: () => getTddSystemPrompt(),
}

View File

@ -2,11 +2,16 @@ import { feature } from 'bun:bundle'
import { getIsNonInteractiveSession } from '../../bootstrap/state.js'
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js'
import { isEnvTruthy } from '../../utils/envUtils.js'
import { PLAN_APPLY_AGENT } from '../../costrict/agents/planApply.js'
import { DESIGN_AGENT } from '../../costrict/agents/designAgent.js'
import { PLAN_MANAGER_AGENT } from '../../costrict/agents/planManager.js'
import { QUICK_EXPLORE_AGENT } from '../../costrict/agents/quickExplore.js'
import { REQUIREMENT_AGENT } from '../../costrict/agents/requirement.js'
import { SPEC_PLAN_AGENT } from '../../costrict/agents/specPlan.js'
import { STRICT_PLAN_AGENT } from '../../costrict/agents/strictPlan.js'
import { STRICT_SPEC_AGENT } from '../../costrict/agents/strictSpec.js'
import { SUB_CODING_AGENT } from '../../costrict/agents/subCoding.js'
import { TASK_CHECK_AGENT } from '../../costrict/agents/taskCheck.js'
import { QUICK_EXPLORE_AGENT } from '../../costrict/agents/quickExplore.js'
import { TASK_PLAN_AGENT } from '../../costrict/agents/taskPlan.js'
import { CLAUDE_CODE_GUIDE_AGENT } from './built-in/claudeCodeGuideAgent.js'
import { EXPLORE_AGENT } from './built-in/exploreAgent.js'
import { GENERAL_PURPOSE_AGENT } from './built-in/generalPurposeAgent.js'
@ -19,6 +24,7 @@ import { TDD_RUN_AND_FIX_AGENT } from '../../costrict/agents/tddRunAndFix.js'
import { TDD_TEST_AND_FIX_AGENT } from '../../costrict/agents/tddTestAndFix.js'
import { TDD_TEST_DESIGN_AGENT } from '../../costrict/agents/tddTestDesign.js'
import { TDD_TEST_PREPARE_AGENT } from '../../costrict/agents/tddTestPrepare.js'
import { TDD_AGENT } from '../../costrict/backup/tdd.js'
import { STATUSLINE_SETUP_AGENT } from './built-in/statuslineSetup.js'
import { VERIFICATION_AGENT } from './built-in/verificationAgent.js'
import type { AgentDefinition } from './loadAgentsDir.js'
@ -60,10 +66,15 @@ export function getBuiltInAgents(): AgentDefinition[] {
STATUSLINE_SETUP_AGENT,
PLAN_AGENT,
STRICT_PLAN_AGENT,
PLAN_APPLY_AGENT,
SPEC_PLAN_AGENT,
PLAN_MANAGER_AGENT,
SUB_CODING_AGENT,
TASK_CHECK_AGENT,
TASK_PLAN_AGENT,
QUICK_EXPLORE_AGENT,
REQUIREMENT_AGENT,
DESIGN_AGENT,
STRICT_SPEC_AGENT,
WIKI_PROJECT_ANALYZE_AGENT,
WIKI_CATALOGUE_DESIGN_AGENT,
WIKI_DOCUMENT_GENERATE_AGENT,
@ -72,6 +83,7 @@ export function getBuiltInAgents(): AgentDefinition[] {
TDD_TEST_AND_FIX_AGENT,
TDD_TEST_DESIGN_AGENT,
TDD_TEST_PREPARE_AGENT,
TDD_AGENT,
]
if (areExplorePlanAgentsEnabled()) {