feat(agents): add visibleTo access control and orchestrator agents for TDD/Wiki workflows

- Add `visibleTo` field to `BaseAgentDefinition` to restrict agent visibility to specific parent agent types
- Filter agents with `visibleTo` restrictions from wildcard agent lists in prompt generation
- Add new `TDD_AGENT` and `WIKI_AGENT` orchestrator agents as entry points for TDD and Wiki workflows
- Register `WIKI_AGENT` in built-in agents list with workflow grouping comments
- Mark all TDD sub-agents (`TddRunAndFix`, `TddTestAndFix`, `TddTestDesign`, `TddTestPrepare`) as `visibleTo: ['TDD']`
- Mark all Wiki sub-agents (`WikiProjectAnalyze`, `WikiCatalogueDesign`, `WikiDocumentGenerate`, `WikiIndexGeneration`) as `visibleTo: ['WIKI']`
- Mark workflow-specific agents (`DesignAgent`, `QuickExplore`, `Requirement`, `SubCoding`, `TaskCheck`, `TaskPlan`, `StrictSpec`) with appropriate `visibleTo` restrictions
- Refactor `strict-project-wiki` and `strict-test` skills to delegate directly to orchestrator agents via `context: 'fork'`
- Remove stale package-level node_modules symlinks
This commit is contained in:
xixingde 2026-04-15 15:49:28 +08:00
parent 05c8fe9589
commit 75c510cb9d
61 changed files with 431 additions and 366 deletions

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/auto-bind@5.0.1/node_modules/auto-bind

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/bidi-js@1.0.3/node_modules/bidi-js

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/chalk@5.6.2/node_modules/chalk

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/cli-boxes@4.0.1/node_modules/cli-boxes

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/emoji-regex@10.6.0/node_modules/emoji-regex

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/figures@6.1.0/node_modules/figures

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/get-east-asian-width@1.5.0/node_modules/get-east-asian-width

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/indent-string@5.0.0/node_modules/indent-string

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/react@19.2.5/node_modules/react

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/react-reconciler@0.33.0+3f10a4be4e334a9b/node_modules/react-reconciler

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/signal-exit@4.1.0/node_modules/signal-exit

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/strip-ansi@7.2.0/node_modules/strip-ansi

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/supports-hyperlinks@4.4.0/node_modules/supports-hyperlinks

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/type-fest@5.5.0/node_modules/type-fest

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/usehooks-ts@3.1.1+3f10a4be4e334a9b/node_modules/usehooks-ts

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/wrap-ansi@10.0.0/node_modules/wrap-ansi

View File

@ -1 +0,0 @@
../../../node_modules/.bun/zod@3.25.76/node_modules/zod

View File

@ -1 +0,0 @@
../../../agent-tools

View File

@ -14,6 +14,7 @@ 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'
import { PLAN_AGENT } from './built-in/planAgent.js'
import { WIKI_AGENT } from 'src/costrict/agents/wiki.js'
import { WIKI_PROJECT_ANALYZE_AGENT } from 'src/costrict/agents/wikiProjectAnalyze.js'
import { WIKI_CATALOGUE_DESIGN_AGENT } from 'src/costrict/agents/wikiCatalogueDesign.js'
import { WIKI_DOCUMENT_GENERATE_AGENT } from 'src/costrict/agents/wikiDocumentGenerate.js'
@ -22,7 +23,7 @@ import { TDD_RUN_AND_FIX_AGENT } from 'src/costrict/agents/tddRunAndFix.js'
import { TDD_TEST_AND_FIX_AGENT } from 'src/costrict/agents/tddTestAndFix.js'
import { TDD_TEST_DESIGN_AGENT } from 'src/costrict/agents/tddTestDesign.js'
import { TDD_TEST_PREPARE_AGENT } from 'src/costrict/agents/tddTestPrepare.js'
import { TDD_AGENT } from 'src/costrict/backup/tdd.js'
import { TDD_AGENT } from 'src/costrict/agents/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'
@ -73,10 +74,13 @@ export function getBuiltInAgents(): AgentDefinition[] {
SUB_CODING_AGENT,
TASK_CHECK_AGENT,
QUICK_EXPLORE_AGENT,
// WikiAgent workflow
WIKI_AGENT,
WIKI_PROJECT_ANALYZE_AGENT,
WIKI_CATALOGUE_DESIGN_AGENT,
WIKI_DOCUMENT_GENERATE_AGENT,
WIKI_INDEX_GENERATION_AGENT,
// TDD workflow
TDD_RUN_AND_FIX_AGENT,
TDD_TEST_AND_FIX_AGENT,
TDD_TEST_DESIGN_AGENT,

View File

@ -134,6 +134,12 @@ export type BaseAgentDefinition = {
* receives the full main-thread tool pool (including Agent tool).
* Use for agents launched directly via slash command from the main thread. */
isMainThread?: boolean
/** When set, this agent is only visible to the listed parent agent types and
* can only be scheduled by them. Callers whose `allowedAgentTypes` does not
* explicitly include this agent will not see it in their agent list.
* Example: `['StrictPlan']` means only the StrictPlan agent may schedule
* this agent. */
visibleTo?: string[]
}
// Built-in agents - dynamic prompts only, no static systemPrompt field

View File

@ -68,10 +68,12 @@ export async function getPrompt(
isCoordinator?: boolean,
allowedAgentTypes?: string[],
): Promise<string> {
// Filter agents by allowed types when Agent(x,y) restricts which agents can be spawned
// Filter agents by allowed types when Agent(x,y) restricts which agents can be spawned.
// In wildcard (no allowedAgentTypes) scenario, also hide agents that declare a visibleTo
// restriction — they are only meant for specific parent agent types.
const effectiveAgents = allowedAgentTypes
? agentDefinitions.filter(a => allowedAgentTypes.includes(a.agentType))
: agentDefinitions
: agentDefinitions.filter(a => !a.visibleTo || a.visibleTo.length === 0)
// Fork subagent feature: when enabled, insert the "When to fork" section
// (fork semantics, directive-style prompts) and swap in fork-aware examples.

View File

@ -1 +0,0 @@
../../../node_modules/.bun/highlight.js@11.11.1/node_modules/highlight.js

View File

@ -1 +0,0 @@
../../../node_modules/.bun/sharp@0.33.5/node_modules/sharp

View File

@ -1 +0,0 @@
../../../agent-tools

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk

View File

@ -1 +0,0 @@
../../../node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es

View File

@ -1 +0,0 @@
../../../node_modules/.bun/lru-cache@10.4.3/node_modules/lru-cache

View File

@ -1 +0,0 @@
../../../node_modules/.bun/p-map@4.0.0/node_modules/p-map

View File

@ -1 +0,0 @@
../../../node_modules/.bun/zod@3.25.76/node_modules/zod

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/@tailwindcss+vite@4.2.2+dd293d07542667d7/node_modules/@tailwindcss/vite

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/@types+react@19.2.14/node_modules/@types/react

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/@types+react-dom@19.2.3+273cdfb19a04c3e9/node_modules/@types/react-dom

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/@types+uuid@10.0.0/node_modules/@types/uuid

View File

@ -1 +0,0 @@
../../../../node_modules/.bun/@vitejs+plugin-react@4.7.0+dd293d07542667d7/node_modules/@vitejs/plugin-react

View File

@ -1 +0,0 @@
../../../node_modules/.bun/hono@4.12.12/node_modules/hono

View File

@ -1 +0,0 @@
../../../node_modules/.bun/react@19.2.5/node_modules/react

View File

@ -1 +0,0 @@
../../../node_modules/.bun/react-dom@19.2.5+3f10a4be4e334a9b/node_modules/react-dom

View File

@ -1 +0,0 @@
../../../node_modules/.bun/tailwindcss@4.2.2/node_modules/tailwindcss

View File

@ -1 +0,0 @@
../../../node_modules/.bun/typescript@5.9.3/node_modules/typescript

View File

@ -1 +0,0 @@
../../../node_modules/.bun/uuid@11.1.0/node_modules/uuid

View File

@ -1 +0,0 @@
../../../node_modules/.bun/vite@6.4.2+0926b6ad1c257d29/node_modules/vite

View File

@ -172,5 +172,6 @@ export const DESIGN_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['StrictSpec'],
getSystemPrompt: () => getDesignAgentSystemPrompt(),
}

View File

@ -178,5 +178,6 @@ export const QUICK_EXPLORE_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['StrictPlan'],
getSystemPrompt: () => getQuickExploreSystemPrompt(),
}

View File

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

View File

@ -94,5 +94,6 @@ export const STRICT_SPEC_AGENT: BuiltInAgentDefinition = {
model: 'inherit',
omitClaudeMd: false,
isMainThread: true,
visibleTo: ['None'],
getSystemPrompt: () => getStrictSpecSystemPrompt(),
}

View File

@ -88,5 +88,6 @@ export const SUB_CODING_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['StrictPlan','StrictSpec'],
getSystemPrompt: () => getSubCodingSystemPrompt(),
}

View File

@ -127,5 +127,6 @@ export const TASK_CHECK_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['StrictPlan'],
getSystemPrompt: () => getTaskCheckSystemPrompt(),
}

View File

@ -177,5 +177,6 @@ export const TASK_PLAN_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['StrictSpec'],
getSystemPrompt: () => getTaskPlanSystemPrompt(),
}

138
src/costrict/agents/tdd.ts Normal file
View File

@ -0,0 +1,138 @@
import type { BuiltInAgentDefinition } from '@claude-code-best/builtin-tools/tools/AgentTool/loadAgentsDir.js'
function getStrictTDDSystemPrompt(): string {
return `You are executing a comprehensive testing workflow to ensure code quality.
---
User Input: $ARGUMENTS
---
## Testing Activity
After coding is complete, proactive testing should be performed as much as possible to ensure code correctness and avoid potential issues caused by changes.
---
## Testing Execution Process
Follow these steps in order, using the \`todowrite\` tool to track progress:
**Step 1: Execute Runnability Verification**
Use the \`@RunAndFix\` agent to verify the project can run/compile:
- The agent will automatically find and execute verification commands
- It will fix any coding issues encountered (syntax errors, type errors, logic bugs, etc.)
- It will exit and report non-coding issues (missing dependencies, environment problems, etc.)
- Wait for verification to complete and review the results
If verification fails with coding issues:
- The agent will have applied fixes automatically
- Proceed to confirm user requirements
If verification reports non-coding issues:
- These require manual resolution (e.g., npm install, environment setup)
- Pause and inform user that non-coding issues need to be resolved first
- Wait for user confirmation before continuing
**Step 2: Confirm User Requirements**
After project is verified to be buildable/runnable:
**If user provided input above ($ARGUMENTS is not empty)**:
- Use the user's input as the primary test scope and requirements
- The input may specify:
- Specific modules/features to test (e.g., "test the login module")
- Test types to focus on (e.g., "only unit tests for API layer")
- Specific files or paths (e.g., "test src/auth/login.ts")
- Additional context or constraints
**If no user input provided ($ARGUMENTS is empty)**:
1. If the user is using plan mode, search for requirement proposals in '.cospec/plan/changes/'
2. Otherwise, confirm the functional requirements based on the user's recent messages and code changes
3. Clearly identify what functionality needs to be tested
**IMPORTANT: After confirming user requirements, you MUST use the \`question\` tool to get user confirmation before proceeding to Step 3**
- Present the confirmed requirements to the user
- Ask if they want to proceed with test case generation or if they need adjustments
**Step 3: Generate Test Cases**
Use the \`@TestDesign\` agent to generate test cases:
- Input: User requirement description, related code paths
- The agent will design comprehensive test points covering:
- Normal scenarios
- Boundary conditions
- Exception handling
- Output: Test plan document saved to \`.cospec/test-plans/test-plan-*.md\`
Review the generated test plan with the user if needed
**Step 4: Execute Tests and Fix**
Use the \`@TestAndFix\` agent to execute tests and fix failures:
- Input: Test plan document path (optional), test scope
- The agent will:
- Execute the tests
- Diagnose failures systematically
- Apply fixes (prioritizing business code over test code)
- Re-run tests to verify fixes (max 3 rounds)
- Output: Test execution report with fix details
---
## Progress Tracking
Use the \`todowrite\` tool to manage and track progress through these steps:
1. Create todos at the start:
- Execute runnability verification with @RunAndFix
- Confirm user requirements
- Generate test cases with @TestDesign
- Execute tests and fix failures with @TestAndFix
2. Update todo status as you complete each step:
- Mark each step as \`in_progress\` when starting
- Mark each step as \`completed\` when finished
---
## Important Notes
- Ensure a test guide document (TEST_GUIDE.md or .cospec/TEST_GUIDE.md) exists so agents understand the project's testing mechanisms
- Test plan documents are saved to \`.cospec/test-plans/\` directory
- Automated fixes execute a maximum of 3 rounds; complex issues may require manual intervention
- Always prioritize fixing business code rather than lowering test standards
---
## Execution
Start by confirming the user requirements, then proceed with test case generation and execution. Follow the four-step process systematically, using the \`todowrite\` tool to track progress, to ensure thorough testing and quality code.
`
}
export const TDD_AGENT: BuiltInAgentDefinition = {
agentType: 'TDD',
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.',
tools:[
"AskUserQuestion",
"Agent(QuickExplore,TaskCheck,SubCoding)",
"Read",
"Write",
"Edit",
"TodoWrite",
],
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
// 通过斜杠命令从主线程启动时,使 resolveAgentTools 跳过 filterToolsForAgent
// 从而保留主线程完整工具集(包括 Agent 工具)。
isMainThread: true,
visibleTo: ['None'],
getSystemPrompt: () => getStrictTDDSystemPrompt(),
}

View File

@ -267,5 +267,6 @@ export const TDD_RUN_AND_FIX_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['TDD'],
getSystemPrompt: () => getTddRunAndFixSystemPrompt(),
}

View File

@ -163,5 +163,6 @@ export const TDD_TEST_AND_FIX_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['TDD'],
getSystemPrompt: () => getTddTestAndFixSystemPrompt(),
}

View File

@ -142,5 +142,6 @@ export const TDD_TEST_DESIGN_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['TDD'],
getSystemPrompt: () => getTddTestDesignSystemPrompt(),
}

View File

@ -164,5 +164,6 @@ export const TDD_TEST_PREPARE_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['TDD'],
getSystemPrompt: () => getTddTestPrepareSystemPrompt(),
}

227
src/costrict/agents/wiki.ts Normal file
View File

@ -0,0 +1,227 @@
import type { BuiltInAgentDefinition } from '@claude-code-best/builtin-tools/tools/AgentTool/loadAgentsDir.js'
function getWikiSystemPrompt(): string {
return `# 项目技术文档智能生成
##
,
,,
:
1. ,
2. AI代码生成的精准性,AI生成更符合项目规范的代码
3.
4.
##
用户输入: $ARGUMENTS
: 如果没有,,****,,
##
\${path}/.costrict/wiki/
##
###
1.
- ****: 使 \`Agent\` 工具委派给对应的子 agent 执行,参考下方"子任务Prompt模板",填充对应参数
- ****: 4N个子任务(N=),
- **SubAgent生成文档**: 4,\`Agent\`工具,并行启动最多3个WikiDocumentGenerate SubAgent,高效完成文档生成任务
- 串行执行原则: 除任务4外,,,
- 并行工具调用: 只读类操作(),10
- 上下文管理: 通过子任务分解避免单个会话上下文过长,
2.
- 输出目录: 所有生成的文件必须输出到 .costrict/wiki/
- 中间文件: 分析过程中的临时文件输出到 .costrict/wiki/.staging/
- 路径规范: 所有文件引用使用相对项目根目录的相对路径
3.
- 输入完整: 给子 agent ,
- 核心原则: 所有子任务执行需遵循"实事求是、简洁高效、质量优先",
- 信息传递: 子任务完成后,
4. Prompt模板
\`\`\`json
{
"subagent_type": "{AgentName}",
"description": "{任务简短描述}",
"prompt": "
{}
##
用户输入: $ARGUMENTS
: 如果没有,,****,,
## ()
{Agent传递的输入信息,}
##
\${path}/.costrict/wiki/
\${path}/.costrict/wiki/.staging/
##
1. {1}
2. {2}
...
##
1. 实事求是: 所有结论必须基于项目真实信息,
2. 保持简洁: 只输出关键信息,
3. 并行工具调用: 只读类操作可并行执行(10)
4. 路径引用: 使用相对项目根目录的相对路径
5. 质量优先: 关注对AI理解项目有价值的内容
##
- {}
- Agent的输出文件路径已在其system prompt中定义,
- {AgentName} agent
"
}
\`\`\`
: 模板中所有\`{}\`占位符需替换为实际内容,无对应内容的章节可直接删除,禁止保留占位符或空章节。
### 子任务1: 项目分类分析
**AgentName**: \`WikiProjectAnalyze\`
****: ,
####
1. 使 list
2. 使 read (README.mdpackage.jsontsconfig.json等)
3.
4. JSON
####
- ,
- JSON ,
### 子任务2: 文档结构设计
**AgentName**: \`WikiCatalogueDesign\`
****: ,
####
1. 使 read
2.
3. ,
4.
####
-
- prompt
- JSON
### 任务3: 读取文档结构定义并规划子任务
: 本任务在父Agent中执行,Agent
1. 使 \`read\` 工具读取 .costrict/wiki/.staging/catalogue.json
2. JSON ,:
- catalogue.json JSON : \`[{文档1}, {文档2}, ...]\`
- =
- = , titlepromptsections
3. ,4
### 🔄 子任务组4: 动态文档生成N个子任务
****: ,3,N个(N=),
**AgentName**: \`WikiDocumentGenerate\`
****:
1. 3 \`Agent\` 工具调用
2. prompt
3. 采用并行批次执行: 每批最多并行3个SubAgent,
****:
####
1. 使 read
2. ,
3.
4.
5.
#### (catalogue.json提取)
- : { catalogue.json title}
- : { catalogue.json prompt}
- : { catalogue.json sections}
- 项目分析结果: .costrict/wiki/.staging/basic_analyze.json
####
- \`Agent\` 工具调用(subagent_type: "WikiDocumentGenerate")
- ****: 3SubAgent,\`Agent\`工具实现并行,当前批次完成后再启动下一批
- ,5
### 子任务4.1: 文档生成-1
...
... ()
### 子任务4.N: 文档生成-N
...
####
- ,
- 使
### 子任务5: 索引文件生成
**AgentName**: \`WikiIndexGeneration\`
****: ,便
####
1. 使 list .costrict/wiki/ .md
2. 使 read
3. ()
4.
####
- 使 .costrict/wiki/{}
- 100
- 30
##
,:
1.
2. (.costrict/wiki/.staging/basic_analyze.json)
3. (.costrict/wiki/.staging/catalogue.json)
4. (.costrict/wiki/*.md)
5. (.costrict/wiki/index.md)
6.
##
1. ****: agent中执行使 \`Agent\` 工具委派给对应的子 agent 执行,参考上方"子任务Prompt模板"填充参数
2. ****: 4N个子任务(N=),,,3WikiDocumentGenerate SubAgent,\`Agent\`工具实现并行
3. ****: 4,,
4. ****: ,,
5. ****: ,****
6. ****: ,
,****,,
`
}
export const WIKI_AGENT: BuiltInAgentDefinition = {
agentType: 'WIKI',
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.',
tools:[
"Agent(WikiCatalogueDesign,WikiDocumentGenerate,WikiIndexGeneration,WikiProjectAnalyze)",
"Read",
"Write",
"Edit",
"TodoWrite",
],
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
// 通过斜杠命令从主线程启动时,使 resolveAgentTools 跳过 filterToolsForAgent
// 从而保留主线程完整工具集(包括 Agent 工具)。
isMainThread: true,
visibleTo: ['None'],
getSystemPrompt: () => getWikiSystemPrompt(),
}

View File

@ -185,5 +185,6 @@ export const WIKI_CATALOGUE_DESIGN_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['WIKI'],
getSystemPrompt: () => getWikiCatalogueDesignSystemPrompt(),
}

View File

@ -300,5 +300,6 @@ export const WIKI_DOCUMENT_GENERATE_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['WIKI'],
getSystemPrompt: () => getWikiDocumentGenerateSystemPrompt(),
}

View File

@ -99,5 +99,6 @@ export const WIKI_INDEX_GENERATION_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['WIKI'],
getSystemPrompt: () => getWikiIndexGenerationSystemPrompt(),
}

View File

@ -166,5 +166,6 @@ export const WIKI_PROJECT_ANALYZE_AGENT: BuiltInAgentDefinition = {
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
visibleTo: ['WIKI'],
getSystemPrompt: () => getWikiProjectAnalyzeSystemPrompt(),
}

View File

@ -1,225 +1,32 @@
import { getProjectRoot } from '../../bootstrap/state.js'
import { registerBundledSkill } from 'src/skills/bundledSkills.js'
// Orchestrator prompt for the /project-wiki skill.
// Uses `Agent` tool (CSC equivalent of opencode's `task` tool) to delegate
// sub-tasks to WikiProjectAnalyze, WikiCatalogueDesign, WikiDocumentGenerate,
// and WikiIndexGeneration agents.
// At runtime, ${path} and $ARGUMENTS are replaced with actual values.
const PROJECT_WIKI_PROMPT = `# 项目技术文档智能生成
##
,
,,
:
1. ,
2. AI代码生成的精准性,AI生成更符合项目规范的代码
3.
4.
##
用户输入: $ARGUMENTS
: 如果没有,,****,,
##
\${path}/.costrict/wiki/
##
###
1.
- ****: 使 \`Agent\` 工具委派给对应的子 agent 执行,参考下方"子任务Prompt模板",填充对应参数
- ****: 4N个子任务(N=),
- **SubAgent生成文档**: 4,\`Agent\`工具,并行启动最多3个WikiDocumentGenerate SubAgent,高效完成文档生成任务
- 串行执行原则: 除任务4外,,,
- 并行工具调用: 只读类操作(),10
- 上下文管理: 通过子任务分解避免单个会话上下文过长,
2.
- 输出目录: 所有生成的文件必须输出到 .costrict/wiki/
- 中间文件: 分析过程中的临时文件输出到 .costrict/wiki/.staging/
- 路径规范: 所有文件引用使用相对项目根目录的相对路径
3.
- 输入完整: 给子 agent ,
- 核心原则: 所有子任务执行需遵循"实事求是、简洁高效、质量优先",
- 信息传递: 子任务完成后,
4. Prompt模板
\`\`\`json
{
"subagent_type": "{AgentName}",
"description": "{任务简短描述}",
"prompt": "
{}
##
用户输入: $ARGUMENTS
: 如果没有,,****,,
## ()
{Agent传递的输入信息,}
##
\${path}/.costrict/wiki/
\${path}/.costrict/wiki/.staging/
##
1. {1}
2. {2}
...
##
1. 实事求是: 所有结论必须基于项目真实信息,
2. 保持简洁: 只输出关键信息,
3. 并行工具调用: 只读类操作可并行执行(10)
4. 路径引用: 使用相对项目根目录的相对路径
5. 质量优先: 关注对AI理解项目有价值的内容
##
- {}
- Agent的输出文件路径已在其system prompt中定义,
- {AgentName} agent
"
}
\`\`\`
: 模板中所有\`{}\`占位符需替换为实际内容,无对应内容的章节可直接删除,禁止保留占位符或空章节。
### 子任务1: 项目分类分析
**AgentName**: \`WikiProjectAnalyze\`
****: ,
####
1. 使 list
2. 使 read (README.mdpackage.jsontsconfig.json等)
3.
4. JSON
####
- ,
- JSON ,
### 子任务2: 文档结构设计
**AgentName**: \`WikiCatalogueDesign\`
****: ,
####
1. 使 read
2.
3. ,
4.
####
-
- prompt
- JSON
### 任务3: 读取文档结构定义并规划子任务
: 本任务在父Agent中执行,Agent
1. 使 \`read\` 工具读取 .costrict/wiki/.staging/catalogue.json
2. JSON ,:
- catalogue.json JSON : \`[{文档1}, {文档2}, ...]\`
- =
- = , titlepromptsections
3. ,4
### 🔄 子任务组4: 动态文档生成N个子任务
****: ,3,N个(N=),
**AgentName**: \`WikiDocumentGenerate\`
****:
1. 3 \`Agent\` 工具调用
2. prompt
3. 采用并行批次执行: 每批最多并行3个SubAgent,
****:
####
1. 使 read
2. ,
3.
4.
5.
#### (catalogue.json提取)
- : { catalogue.json title}
- : { catalogue.json prompt}
- : { catalogue.json sections}
- 项目分析结果: .costrict/wiki/.staging/basic_analyze.json
####
- \`Agent\` 工具调用(subagent_type: "WikiDocumentGenerate")
- ****: 3SubAgent,\`Agent\`工具实现并行,当前批次完成后再启动下一批
- ,5
### 子任务4.1: 文档生成-1
...
... ()
### 子任务4.N: 文档生成-N
...
####
- ,
- 使
### 子任务5: 索引文件生成
**AgentName**: \`WikiIndexGeneration\`
****: ,便
####
1. 使 list .costrict/wiki/ .md
2. 使 read
3. ()
4.
####
- 使 .costrict/wiki/{}
- 100
- 30
##
,:
1.
2. (.costrict/wiki/.staging/basic_analyze.json)
3. (.costrict/wiki/.staging/catalogue.json)
4. (.costrict/wiki/*.md)
5. (.costrict/wiki/index.md)
6.
##
1. ****: agent中执行使 \`Agent\` 工具委派给对应的子 agent 执行,参考上方"子任务Prompt模板"填充参数
2. ****: 4N个子任务(N=),,,3WikiDocumentGenerate SubAgent,\`Agent\`工具实现并行
3. ****: 4,,
4. ****: ,,
5. ****: ,****
6. ****: ,
,****,,`
export function registerProjectWikiSkill(): void {
registerBundledSkill({
name: 'project-wiki',
name: 'strict-project-wiki',
description:
'为项目生成完整的技术文档体系,包括项目分析、文档结构设计、技术文档生成和索引文件创建。',
userInvocable: true,
disableModelInvocation: true,
context: 'fork',
agent: 'WIKI',
async getPromptForCommand(args) {
const path = getProjectRoot()
const prompt = PROJECT_WIKI_PROMPT.replace(/\$\{path\}/g, path).replace(
/\$ARGUMENTS/g,
args || '',
)
return [{ type: 'text', text: prompt }]
const userRequest = args.trim()
if (!userRequest) {
return [
{
type: 'text',
text: '请提供需要规划的需求描述。用法: /strict-project-wiki <需求描述>',
},
]
}
return [
{
type: 'text',
text: `用户输入:${userRequest}`,
},
]
},
})
}

View File

@ -1,125 +1,30 @@
import { registerBundledSkill } from 'src/skills/bundledSkills.js'
const TDD_PROMPT = `You are executing a comprehensive testing workflow to ensure code quality.
---
User Input: $ARGUMENTS
---
## Testing Activity
After coding is complete, proactive testing should be performed as much as possible to ensure code correctness and avoid potential issues caused by changes.
---
## Testing Execution Process
Follow these steps in order, using the \`todowrite\` tool to track progress:
**Step 1: Execute Runnability Verification**
Use the \`@RunAndFix\` agent to verify the project can run/compile:
- The agent will automatically find and execute verification commands
- It will fix any coding issues encountered (syntax errors, type errors, logic bugs, etc.)
- It will exit and report non-coding issues (missing dependencies, environment problems, etc.)
- Wait for verification to complete and review the results
If verification fails with coding issues:
- The agent will have applied fixes automatically
- Proceed to confirm user requirements
If verification reports non-coding issues:
- These require manual resolution (e.g., npm install, environment setup)
- Pause and inform user that non-coding issues need to be resolved first
- Wait for user confirmation before continuing
**Step 2: Confirm User Requirements**
After project is verified to be buildable/runnable:
**If user provided input above ($ARGUMENTS is not empty)**:
- Use the user's input as the primary test scope and requirements
- The input may specify:
- Specific modules/features to test (e.g., "test the login module")
- Test types to focus on (e.g., "only unit tests for API layer")
- Specific files or paths (e.g., "test src/auth/login.ts")
- Additional context or constraints
**If no user input provided ($ARGUMENTS is empty)**:
1. If the user is using plan mode, search for requirement proposals in '.cospec/plan/changes/'
2. Otherwise, confirm the functional requirements based on the user's recent messages and code changes
3. Clearly identify what functionality needs to be tested
**IMPORTANT: After confirming user requirements, you MUST use the \`question\` tool to get user confirmation before proceeding to Step 3**
- Present the confirmed requirements to the user
- Ask if they want to proceed with test case generation or if they need adjustments
**Step 3: Generate Test Cases**
Use the \`@TestDesign\` agent to generate test cases:
- Input: User requirement description, related code paths
- The agent will design comprehensive test points covering:
- Normal scenarios
- Boundary conditions
- Exception handling
- Output: Test plan document saved to \`.cospec/test-plans/test-plan-*.md\`
Review the generated test plan with the user if needed
**Step 4: Execute Tests and Fix**
Use the \`@TestAndFix\` agent to execute tests and fix failures:
- Input: Test plan document path (optional), test scope
- The agent will:
- Execute the tests
- Diagnose failures systematically
- Apply fixes (prioritizing business code over test code)
- Re-run tests to verify fixes (max 3 rounds)
- Output: Test execution report with fix details
---
## Progress Tracking
Use the \`todowrite\` tool to manage and track progress through these steps:
1. Create todos at the start:
- Execute runnability verification with @RunAndFix
- Confirm user requirements
- Generate test cases with @TestDesign
- Execute tests and fix failures with @TestAndFix
2. Update todo status as you complete each step:
- Mark each step as \`in_progress\` when starting
- Mark each step as \`completed\` when finished
---
## Important Notes
- Ensure a test guide document (TEST_GUIDE.md or .cospec/TEST_GUIDE.md) exists so agents understand the project's testing mechanisms
- Test plan documents are saved to \`.cospec/test-plans/\` directory
- Automated fixes execute a maximum of 3 rounds; complex issues may require manual intervention
- Always prioritize fixing business code rather than lowering test standards
---
## Execution
Start by confirming the user requirements, then proceed with test case generation and execution. Follow the four-step process systematically, using the \`todowrite\` tool to track progress, to ensure thorough testing and quality code.`
export function registerTddSkill(): void {
registerBundledSkill({
name: 'test',
name: 'strict-test',
description:
'execute comprehensive testing workflow: confirm requirements, generate test cases, and execute tests with automated fixes',
userInvocable: true,
disableModelInvocation: true,
context: 'fork',
agent: 'TDD',
async getPromptForCommand(args) {
const prompt = TDD_PROMPT.replace(/\$ARGUMENTS/g, args || '')
return [{ type: 'text', text: prompt }]
const userRequest = args.trim()
if (!userRequest) {
return [
{
type: 'text',
text: '请提供需要规划的需求描述。用法: /strict-test <需求描述>',
},
]
}
return [
{
type: 'text',
text: `用户输入:${userRequest}`,
},
]
},
})
}