⚠️ Core principle: knowledge first, planning second
Prohibited: directly planning execution with old knowledge Mandatory: knowledge research must be completed first, then task planning
1. Complete execution process (seven-layer architecture)
用户输入
↓
┌─────────────────────────────────────────────────────────────┐
│ 第零层:初始化检查层 (Initialization) ⭐ 最先执行 │
├─────────────────────────────────────────────────────────────┤
│ 1. 检查 .trae/knowledge/ 目录是否存在 │
│ └─ 不存在 → 自动创建 │
│ 2. 检查 index.json 是否存在 │
│ └─ 不存在 → 创建空索引 │
│ 3. 检查 _templates/ 目录是否存在 │
│ └─ 不存在 → 创建模板目录和模板文件 │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 第一层:任务解析层 (Task Parser) │
├─────────────────────────────────────────────────────────────┤
│ 1. 提取任务核心目标 │
│ 2. 识别涉及的技术领域/行业 │
│ 3. 判断是否需要外部知识(新框架/新版本/新领域 = 必须调研) │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 第二层:知识调研层 (Knowledge Research) ⭐ 核心层 │
├─────────────────────────────────────────────────────────────┤
│ 【强制执行】当涉及以下情况时,必须完成知识调研: │
│ - 新框架/新库(首次使用或版本更新) │
│ - 行业特定知识(金融/医疗/游戏等) │
│ - 技术栈变更(如 Vue2 → Vue3) │
│ - 跨领域任务(如 AI + Web) │
│ - ⭐ 无可用工作流(本地/GitHub/教程都找不到时必须调研) │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 第三层:工作流匹配层 (Workflow Matcher) │
├─────────────────────────────────────────────────────────────┤
│ [1/4] 检查本地工作流 → 找到 → 基于知识调研调整后执行 │
│ [2/4] 搜索 GitHub 开源项目 → 学习实现方案后执行 │
│ [3/4] 搜索文章和教程 → 提取步骤后执行 │
│ [4/4] 基于知识调研结果生成工作流 → 执行 │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 第四层:执行层 (Executor) │
├─────────────────────────────────────────────────────────────┤
│ 执行具体任务 │
│ ├── 成功 → 继续 │
│ └── 失败 → 知识补充调研 → 本地修复 → 联网搜索 → 跳过 │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 第五层:验证层 (Validator) - 强制执行 │
├─────────────────────────────────────────────────────────────┤
│ 1. 代码质量验证(语法/类型/内存泄漏) │
│ 2. 运行时验证(功能测试/边界测试) │
│ 3. 目标达成验证 │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 第六层:知识沉淀层 (Knowledge Persistence) │
├─────────────────────────────────────────────────────────────┤
│ - 保存工作流(如果是新的) │
│ - 保存知识摘要(供后续复用) │
│ - 记录踩坑经验(避免重复犯错) │
└─────────────────────────────────────────────────────────────┘
↓
输出报告
2. Detailed protocol of the knowledge research layer
2.1 Knowledge source priority matrix
| Priority | Knowledge source type | Example | Use case |
|---|---|---|---|
| P0 | Official documentation | react.dev, vuejs.org, python.org | API usage, best practices |
| P1 | Industry standards | OpenAPI Spec, W3C standards | Specifications, protocols |
| P2 | Official blogs | React Blog, Node.js Blog | Version changes, migration guides |
| P3 | GitHub repositories | Official repositories, Issues, Discussions | Real-world problems, known bugs |
| P4 | Technical communities | Stack Overflow, Dev.to | Specific problem solving |
| P5 | Professional tutorials | Official tutorials, certification courses | Systematic learning |
2.2 Trigger conditions for knowledge research
Situations where knowledge research must be triggered:
- New technology stack: frameworks/libraries used for the first time
- Version upgrades: such as Vue2→Vue3, React 17→18
- Industry-specific: domain knowledge such as finance/healthcare/gaming
- Cross-domain integration: AI + Web, mobile + backend
- No available workflow: when none can be found locally/on GitHub/in tutorials
3. Automatic repair mechanism
步骤执行失败
↓
尝试本地修复(最多3次)
↓ 失败
联网搜索解决方案
↓ 找到
执行联网方案
↓ 失败
跳过继续下一步(静默模式)
4. Trigger words
| Trigger word | Description |
|---|---|
开始、继续 |
Start autonomous execution |
自主执行、自动规划 |
Dynamically plan tasks |
自动修复 |
Automatically repair after failure |
autonomous、agent执行 |
English trigger word |
智能工作流、智能路由 |
Intelligent mode |