monoco-toolkit 0.3.11__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. monoco/core/automation/__init__.py +40 -0
  2. monoco/core/automation/field_watcher.py +296 -0
  3. monoco/core/automation/handlers.py +805 -0
  4. monoco/core/config.py +29 -11
  5. monoco/core/daemon/__init__.py +5 -0
  6. monoco/core/daemon/pid.py +290 -0
  7. monoco/core/git.py +15 -0
  8. monoco/core/hooks/context.py +74 -13
  9. monoco/core/injection.py +86 -8
  10. monoco/core/integrations.py +0 -24
  11. monoco/core/router/__init__.py +17 -0
  12. monoco/core/router/action.py +202 -0
  13. monoco/core/scheduler/__init__.py +63 -0
  14. monoco/core/scheduler/base.py +152 -0
  15. monoco/core/scheduler/engines.py +175 -0
  16. monoco/core/scheduler/events.py +197 -0
  17. monoco/core/scheduler/local.py +377 -0
  18. monoco/core/setup.py +9 -0
  19. monoco/core/sync.py +199 -4
  20. monoco/core/watcher/__init__.py +63 -0
  21. monoco/core/watcher/base.py +382 -0
  22. monoco/core/watcher/dropzone.py +152 -0
  23. monoco/core/watcher/im.py +460 -0
  24. monoco/core/watcher/issue.py +303 -0
  25. monoco/core/watcher/memo.py +192 -0
  26. monoco/core/watcher/task.py +238 -0
  27. monoco/daemon/app.py +3 -60
  28. monoco/daemon/commands.py +459 -25
  29. monoco/daemon/events.py +34 -0
  30. monoco/daemon/scheduler.py +157 -201
  31. monoco/daemon/services.py +42 -243
  32. monoco/features/agent/__init__.py +25 -7
  33. monoco/features/agent/cli.py +91 -57
  34. monoco/features/agent/engines.py +31 -170
  35. monoco/features/agent/resources/en/AGENTS.md +14 -14
  36. monoco/features/agent/resources/en/skills/monoco_role_engineer/SKILL.md +101 -0
  37. monoco/features/agent/resources/en/skills/monoco_role_manager/SKILL.md +95 -0
  38. monoco/features/agent/resources/en/skills/monoco_role_planner/SKILL.md +177 -0
  39. monoco/features/agent/resources/en/skills/monoco_role_reviewer/SKILL.md +139 -0
  40. monoco/features/agent/resources/zh/skills/monoco_role_engineer/SKILL.md +101 -0
  41. monoco/features/agent/resources/zh/skills/monoco_role_manager/SKILL.md +95 -0
  42. monoco/features/agent/resources/zh/skills/monoco_role_planner/SKILL.md +177 -0
  43. monoco/features/agent/resources/zh/skills/monoco_role_reviewer/SKILL.md +139 -0
  44. monoco/features/agent/worker.py +1 -1
  45. monoco/features/hooks/__init__.py +61 -6
  46. monoco/features/hooks/commands.py +281 -271
  47. monoco/features/hooks/dispatchers/__init__.py +23 -0
  48. monoco/features/hooks/dispatchers/agent_dispatcher.py +486 -0
  49. monoco/features/hooks/dispatchers/git_dispatcher.py +478 -0
  50. monoco/features/hooks/manager.py +357 -0
  51. monoco/features/hooks/models.py +262 -0
  52. monoco/features/hooks/parser.py +322 -0
  53. monoco/features/hooks/universal_interceptor.py +503 -0
  54. monoco/features/im/__init__.py +67 -0
  55. monoco/features/im/core.py +782 -0
  56. monoco/features/im/models.py +311 -0
  57. monoco/features/issue/commands.py +133 -60
  58. monoco/features/issue/core.py +385 -40
  59. monoco/features/issue/domain_commands.py +0 -19
  60. monoco/features/issue/resources/en/AGENTS.md +17 -122
  61. monoco/features/issue/resources/hooks/agent/before-tool.sh +102 -0
  62. monoco/features/issue/resources/hooks/agent/session-start.sh +88 -0
  63. monoco/features/issue/resources/hooks/{post-checkout.sh → git/git-post-checkout.sh} +10 -9
  64. monoco/features/issue/resources/hooks/git/git-pre-commit.sh +31 -0
  65. monoco/features/issue/resources/hooks/{pre-push.sh → git/git-pre-push.sh} +7 -13
  66. monoco/features/issue/resources/zh/AGENTS.md +18 -123
  67. monoco/features/memo/cli.py +15 -64
  68. monoco/features/memo/core.py +6 -34
  69. monoco/features/memo/models.py +24 -15
  70. monoco/features/memo/resources/en/AGENTS.md +31 -0
  71. monoco/features/memo/resources/zh/AGENTS.md +28 -5
  72. monoco/features/spike/commands.py +5 -3
  73. monoco/main.py +5 -3
  74. {monoco_toolkit-0.3.11.dist-info → monoco_toolkit-0.4.0.dist-info}/METADATA +1 -1
  75. monoco_toolkit-0.4.0.dist-info/RECORD +170 -0
  76. monoco/core/execution.py +0 -67
  77. monoco/features/agent/apoptosis.py +0 -44
  78. monoco/features/agent/manager.py +0 -127
  79. monoco/features/agent/resources/atoms/atom-code-dev.yaml +0 -61
  80. monoco/features/agent/resources/atoms/atom-issue-lifecycle.yaml +0 -73
  81. monoco/features/agent/resources/atoms/atom-knowledge.yaml +0 -55
  82. monoco/features/agent/resources/atoms/atom-review.yaml +0 -60
  83. monoco/features/agent/resources/en/skills/monoco_atom_core/SKILL.md +0 -99
  84. monoco/features/agent/resources/en/skills/monoco_workflow_agent_engineer/SKILL.md +0 -94
  85. monoco/features/agent/resources/en/skills/monoco_workflow_agent_manager/SKILL.md +0 -93
  86. monoco/features/agent/resources/en/skills/monoco_workflow_agent_planner/SKILL.md +0 -85
  87. monoco/features/agent/resources/en/skills/monoco_workflow_agent_reviewer/SKILL.md +0 -114
  88. monoco/features/agent/resources/workflows/workflow-dev.yaml +0 -83
  89. monoco/features/agent/resources/workflows/workflow-issue-create.yaml +0 -72
  90. monoco/features/agent/resources/workflows/workflow-review.yaml +0 -94
  91. monoco/features/agent/resources/zh/roles/monoco_role_engineer.yaml +0 -49
  92. monoco/features/agent/resources/zh/roles/monoco_role_manager.yaml +0 -46
  93. monoco/features/agent/resources/zh/roles/monoco_role_planner.yaml +0 -46
  94. monoco/features/agent/resources/zh/roles/monoco_role_reviewer.yaml +0 -47
  95. monoco/features/agent/resources/zh/skills/monoco_atom_core/SKILL.md +0 -99
  96. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_engineer/SKILL.md +0 -94
  97. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_manager/SKILL.md +0 -88
  98. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_planner/SKILL.md +0 -259
  99. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_reviewer/SKILL.md +0 -137
  100. monoco/features/agent/session.py +0 -169
  101. monoco/features/artifact/resources/zh/skills/monoco_atom_artifact/SKILL.md +0 -278
  102. monoco/features/glossary/resources/en/skills/monoco_atom_glossary/SKILL.md +0 -35
  103. monoco/features/glossary/resources/zh/skills/monoco_atom_glossary/SKILL.md +0 -35
  104. monoco/features/hooks/adapter.py +0 -67
  105. monoco/features/hooks/core.py +0 -441
  106. monoco/features/i18n/resources/en/skills/monoco_atom_i18n/SKILL.md +0 -96
  107. monoco/features/i18n/resources/en/skills/monoco_workflow_i18n_scan/SKILL.md +0 -105
  108. monoco/features/i18n/resources/zh/skills/monoco_atom_i18n/SKILL.md +0 -96
  109. monoco/features/i18n/resources/zh/skills/monoco_workflow_i18n_scan/SKILL.md +0 -105
  110. monoco/features/issue/resources/en/skills/monoco_atom_issue/SKILL.md +0 -165
  111. monoco/features/issue/resources/en/skills/monoco_workflow_issue_creation/SKILL.md +0 -167
  112. monoco/features/issue/resources/en/skills/monoco_workflow_issue_development/SKILL.md +0 -224
  113. monoco/features/issue/resources/en/skills/monoco_workflow_issue_management/SKILL.md +0 -159
  114. monoco/features/issue/resources/en/skills/monoco_workflow_issue_refinement/SKILL.md +0 -203
  115. monoco/features/issue/resources/hooks/pre-commit.sh +0 -41
  116. monoco/features/issue/resources/zh/skills/monoco_atom_issue_lifecycle/SKILL.md +0 -190
  117. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_creation/SKILL.md +0 -167
  118. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_development/SKILL.md +0 -224
  119. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_management/SKILL.md +0 -159
  120. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_refinement/SKILL.md +0 -203
  121. monoco/features/memo/resources/en/skills/monoco_atom_memo/SKILL.md +0 -77
  122. monoco/features/memo/resources/en/skills/monoco_workflow_note_processing/SKILL.md +0 -140
  123. monoco/features/memo/resources/zh/skills/monoco_atom_memo/SKILL.md +0 -77
  124. monoco/features/memo/resources/zh/skills/monoco_workflow_note_processing/SKILL.md +0 -140
  125. monoco/features/spike/resources/en/skills/monoco_atom_spike/SKILL.md +0 -76
  126. monoco/features/spike/resources/en/skills/monoco_workflow_research/SKILL.md +0 -121
  127. monoco/features/spike/resources/zh/skills/monoco_atom_spike/SKILL.md +0 -76
  128. monoco/features/spike/resources/zh/skills/monoco_workflow_research/SKILL.md +0 -121
  129. monoco_toolkit-0.3.11.dist-info/RECORD +0 -181
  130. {monoco_toolkit-0.3.11.dist-info → monoco_toolkit-0.4.0.dist-info}/WHEEL +0 -0
  131. {monoco_toolkit-0.3.11.dist-info → monoco_toolkit-0.4.0.dist-info}/entry_points.txt +0 -0
  132. {monoco_toolkit-0.3.11.dist-info → monoco_toolkit-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,47 +0,0 @@
1
- ---
2
- name: monoco_role_reviewer
3
- type: role
4
- description: Reviewer 角色 - 负责代码审计、架构合规检查和反馈
5
- version: 1.0.0
6
- author: Monoco Toolkit
7
-
8
- # 默认工作流
9
- workflow: monoco_workflow_agent_reviewer
10
-
11
- # 默认执行模式
12
- default_mode: autopilot
13
-
14
- # 触发条件
15
- trigger: 'issue.submitted'
16
- goal: 确保代码质量和流程合规
17
-
18
- # 角色偏好 / Mindset
19
- preferences:
20
- - 'Double Defense: 双层防御体系 - Engineer 自证 (Verify) + Reviewer 对抗 (Challenge)'
21
- - 'Try to Break It: 尝试破坏代码,寻找边界情况'
22
- - 'No Approve Without Test: 禁止未经测试直接 Approve'
23
- - 'Challenge Tests: 保留有价值的 Challenge Tests 并提交到代码库'
24
-
25
- # 系统提示
26
- system_prompt: |
27
- # Identity
28
- 你是由 Monoco Toolkit 驱动的 **Reviewer Agent**,负责代码质量检查。
29
-
30
- # Core Workflow
31
- 你的核心工作流定义在 `workflow-review` 中,采用**双层防御体系**:
32
- 1. **checkout**: 获取待评审的代码
33
- 2. **verify**: 验证 Engineer 提交的测试 (White-box)
34
- 3. **challenge**: 对抗测试,尝试破坏代码 (Black-box)
35
- 4. **review**: 代码审查,检查质量和可维护性
36
- 5. **decide**: 做出批准、拒绝或请求修改的决定
37
-
38
- # Mindset
39
- - **Double Defense**: Verify + Challenge
40
- - **Try to Break It**: 寻找边界情况和安全漏洞
41
- - **Quality First**: 质量是第一优先级
42
-
43
- # Rules
44
- - 必须先通过 Engineer 的测试 (Verify),再进行对抗测试 (Challenge)
45
- - 必须尝试编写至少一个边界测试用例
46
- - 禁止未经测试直接 Approve
47
- - 合并价值高的 Challenge Tests 到代码库
@@ -1,99 +0,0 @@
1
- ---
2
- name: monoco_atom_core
3
- description: Monoco Toolkit 的核心技能。提供项目初始化、配置管理和工作空间管理的基础命令。
4
- type: atom
5
- version: 1.0.0
6
- ---
7
-
8
- # Monoco 核心
9
-
10
- Monoco Toolkit 的核心功能和命令。
11
-
12
- ## 概述
13
-
14
- Monoco 是一个开发者生产力工具包,提供:
15
-
16
- - **项目初始化**: 标准化的项目结构
17
- - **配置管理**: 全局和项目级别的配置
18
- - **工作空间管理**: 多项目设置
19
-
20
- ## 核心命令
21
-
22
- ### 项目设置
23
-
24
- - **`monoco init`**: 初始化新的 Monoco 项目
25
- - 创建 `.monoco/` 目录及默认配置
26
- - 设置项目结构(Issues/, .references/ 等)
27
- - 生成初始文档
28
-
29
- ### 配置管理
30
-
31
- - **`monoco config`**: 管理配置
32
- - `monoco config get <key>`: 查看配置值
33
- - `monoco config set <key> <value>`: 更新配置
34
- - 支持全局(`~/.monoco/config.yaml`)和项目(`.monoco/config.yaml`)作用域
35
-
36
- ### Agent 集成
37
-
38
- - **`monoco sync`**: 与 agent 环境同步
39
- - 将系统提示注入到 agent 配置文件(GEMINI.md, CLAUDE.md 等)
40
- - 分发 skills 到 agent 框架目录
41
- - 遵循 `i18n.source_lang` 的语言配置
42
-
43
- - **`monoco uninstall`**: 清理 agent 集成
44
- - 从 agent 配置文件中移除托管块
45
- - 清理已分发的 skills
46
-
47
- ### Git 工作流集成
48
-
49
- Monoco 强制执行 **Feature Branch 工作流**以确保代码隔离和质量:
50
-
51
- - **`monoco init`**: 自动安装 Git Hooks
52
- - **pre-commit**: 运行 Issue Linter 和代码格式检查
53
- - **pre-push**: 执行测试套件和完整性验证
54
- - 所有 Hooks 可通过 `.monoco/config.yaml` 配置
55
-
56
- - **分支隔离策略**:
57
- - ⚠️ **强制要求**: 使用 `monoco issue start <ID> --branch` 创建隔离环境
58
- - 自动创建规范化分支名: `feat/<id>-<slug>`
59
- - **主干保护**: Linter 会阻止在 `main`/`master` 分支上的直接代码修改
60
-
61
- - **文件追踪**: `monoco issue sync-files` 自动同步 Git 变更到 Issue 元数据
62
-
63
- > 📖 **详细工作流**: 参见 `monoco-issue` skill 获取完整的 Issue 生命周期管理指南。
64
-
65
- ## 配置结构
66
-
67
- 配置以 YAML 格式存储在:
68
-
69
- - **全局**: `~/.monoco/config.yaml`
70
- - **项目**: `.monoco/config.yaml`
71
-
72
- 关键配置段:
73
-
74
- - `core`: 编辑器、日志级别、作者
75
- - `paths`: 目录路径(issues, spikes, specs)
76
- - `project`: 项目元数据、spike repos、工作空间成员
77
- - `i18n`: 国际化设置
78
- - `agent`: Agent 框架集成设置
79
-
80
- ## 最佳实践
81
-
82
- ### 基础操作
83
-
84
- 1. **优先使用 CLI 命令**,而不是手动编辑文件
85
- 2. **配置更改后运行 `monoco sync`** 以更新 agent 环境
86
- 3. **将 `.monoco/config.yaml` 提交到版本控制**,保持团队一致性
87
- 4. **保持全局配置最小化** - 大多数设置应该是项目特定的
88
-
89
- ### Git 工作流 (⚠️ CRITICAL for Agents)
90
-
91
- 5. **严格遵循分支隔离**:
92
- - ✅ 始终使用: `monoco issue start <ID> --branch`
93
- - ❌ 禁止在 `main`/`master` 分支直接修改代码
94
- - 📝 提交前运行: `monoco issue sync-files` 更新文件追踪
95
-
96
- 6. **质量门禁**:
97
- - Git Hooks 会自动运行检查,不要尝试绕过 (`--no-verify`)
98
- - 提交前确保 `monoco issue lint` 通过
99
- - 使用 `monoco issue submit` 生成交付报告
@@ -1,94 +0,0 @@
1
- ---
2
- name: monoco_workflow_agent_engineer
3
- description: Engineer 角色的标准化工作流 (Flow Skill)。定义从需求调研到代码提交的标准操作流程,确保测试覆盖和代码质量。
4
- type: workflow
5
- role: engineer
6
- version: 1.0.0
7
- ---
8
-
9
- # Engineer Flow
10
-
11
- Engineer 角色的标准化工作流,确保代码开发遵循 "Investigate → Code → Test → Report → Submit" 流程。
12
-
13
- ## 工作流状态机
14
-
15
- ```mermaid
16
- stateDiagram-v2
17
- [*] --> Investigate: 接收任务
18
-
19
- Investigate --> Code: 需求清晰
20
- Investigate --> Investigate: 需求模糊<br/>(请求澄清)
21
-
22
- Code --> Test: 编码完成
23
-
24
- Test --> Test: 测试失败<br/>(修复代码)
25
- Test --> Report: 测试通过
26
-
27
- Report --> Submit: 报告完成
28
-
29
- Submit --> [*]: 提交成功
30
- ```
31
-
32
- ## 执行步骤
33
-
34
- ### 1. Investigate (调研)
35
-
36
- - **目标**: 充分理解需求,识别技术风险和依赖
37
- - **输入**: Issue 描述、相关代码、依赖 Issue
38
- - **输出**: 技术方案草稿、风险清单
39
- - **检查点**:
40
- - [ ] 阅读并理解 Issue 描述
41
- - [ ] 识别相关代码文件
42
- - [ ] 检查依赖 Issue 状态
43
- - [ ] 评估技术可行性
44
-
45
- ### 2. Code (编码)
46
-
47
- - **目标**: 实现功能或修复缺陷
48
- - **前置条件**: 需求已清晰,分支已创建 (`monoco issue start <ID> --branch`)
49
- - **检查点**:
50
- - [ ] 遵循项目代码规范
51
- - [ ] 编写/更新必要的文档
52
- - [ ] 处理边界情况
53
-
54
- ### 3. Test (测试)
55
-
56
- - **目标**: 确保代码质量和功能正确性
57
- - **策略**: 循环测试直到通过
58
- - **检查点**:
59
- - [ ] 编写/更新单元测试
60
- - [ ] 运行测试套件 (`pytest`, `cargo test`, etc.)
61
- - [ ] 修复失败的测试
62
- - [ ] 检查测试覆盖率
63
-
64
- ### 4. Report (报告)
65
-
66
- - **目标**: 记录变更内容,更新 Issue 状态
67
- - **检查点**:
68
- - [ ] 更新 Issue 文件追踪 (`monoco issue sync-files`)
69
- - [ ] 编写变更摘要
70
- - [ ] 更新任务清单 (Checkboxes)
71
-
72
- ### 5. Submit (提交)
73
-
74
- - **目标**: 完成代码提交,进入评审流程
75
- - **检查点**:
76
- - [ ] 运行 `monoco issue lint` 检查合规性
77
- - [ ] 运行 `monoco issue submit <ID>`
78
- - [ ] 等待评审结果
79
-
80
- ## 决策分支
81
-
82
- | 条件 | 动作 |
83
- |------|------|
84
- | 需求不清晰 | 返回 Investigate,请求澄清 |
85
- | 测试失败 | 返回 Code,修复问题 |
86
- | Lint 失败 | 修复合规性问题,重新 Submit |
87
- | 评审拒绝 | 返回 Code,按反馈修改 |
88
-
89
- ## 合规要求
90
-
91
- - **禁止**: 跳过测试直接提交
92
- - **禁止**: 在 main/master 分支直接修改代码
93
- - **必须**: 使用 `monoco issue start --branch` 创建功能分支
94
- - **必须**: 所有单元测试通过后才能 Submit
@@ -1,88 +0,0 @@
1
- ---
2
- name: monoco_workflow_agent_manager
3
- description: Manager 角色的标准化工作流 (Flow Skill)。定义从 Inbox 整理到任务指派的标准操作流程,确保需求清晰和任务合理拆解。
4
- type: workflow
5
- role: manager
6
- version: 1.0.0
7
- ---
8
-
9
- # Manager Flow
10
-
11
- Manager 角色的标准化工作流,确保 "Inbox → Clarify → Decompose → Assign" 流程。
12
-
13
- ## 工作流状态机
14
-
15
- ```mermaid
16
- stateDiagram-v2
17
- [*] --> Inbox: 新需求/想法
18
-
19
- Inbox --> Clarify: 开始处理
20
- Inbox --> Inbox: 暂存<br/>(低优先级)
21
-
22
- Clarify --> Decompose: 需求清晰
23
- Clarify --> Clarify: 需更多信息<br/>(等待反馈)
24
-
25
- Decompose --> Assign: 拆解完成
26
- Decompose --> Decompose: 过于复杂<br/>(拆分为 Epic)
27
-
28
- Assign --> [*]: 指派完成
29
- ```
30
-
31
- ## 执行步骤
32
-
33
- ### 1. Inbox (收件箱)
34
-
35
- - **目标**: 收集和暂存所有 incoming 需求、想法和任务
36
- - **输入**: Memo、用户反馈、系统告警、技术债务
37
- - **检查点**:
38
- - [ ] 记录需求来源和背景
39
- - [ ] 初步分类 (Feature/Chore/Fix)
40
- - [ ] 评估紧急程度
41
-
42
- ### 2. Clarify (需求澄清)
43
-
44
- - **目标**: 将模糊的需求转化为清晰的描述
45
- - **策略**: 5W2H 分析法
46
- - **检查点**:
47
- - [ ] **What**: 要解决什么问题?
48
- - [ ] **Why**: 为什么重要?
49
- - [ ] **Who**: 谁是利益相关者?
50
- - [ ] **When**: 期望的完成时间?
51
- - [ ] **Where**: 影响范围?
52
- - [ ] **How**: 建议的实现方式?
53
- - [ ] **How Much**: 工作量预估?
54
-
55
- ### 3. Decompose (任务拆解)
56
-
57
- - **目标**: 将大任务拆分为可独立交付的子任务
58
- - **策略**: 垂直切片 (Vertical Slicing)
59
- - **检查点**:
60
- - [ ] 识别核心价值和依赖关系
61
- - [ ] 拆分为可独立交付的 Feature/Chore/Fix
62
- - [ ] 设置合理的优先级
63
- - [ ] 为复杂任务创建 Epic
64
-
65
- ### 4. Assign (任务指派)
66
-
67
- - **目标**: 将任务分配给合适的执行者
68
- - **检查点**:
69
- - [ ] 评估团队能力和负载
70
- - [ ] 明确验收标准 (Acceptance Criteria)
71
- - [ ] 设置合理的截止日期
72
- - [ ] 通知相关成员
73
-
74
- ## 决策分支
75
-
76
- | 条件 | 动作 |
77
- |------|------|
78
- | 需求过于模糊 | 返回 Inbox,等待更多信息 |
79
- | 任务过于复杂 | 创建 Epic,拆分为多个 Feature |
80
- | 依赖其他任务 | 设置依赖关系,调整优先级 |
81
- | 资源不足 | 调整范围或延期 |
82
-
83
- ## 合规要求
84
-
85
- - **必须**: 每个任务都有清晰的验收标准
86
- - **必须**: 复杂任务必须拆分为 Epic + Features
87
- - **禁止**: 指派没有澄清需求给 Engineer
88
- - **建议**: 使用 `monoco memo` 管理临时想法
@@ -1,259 +0,0 @@
1
- ---
2
- name: monoco_workflow_agent_planner
3
- description: Planner 角色的标准化工作流 (Flow Skill),负责分析、设计、规划和交接。
4
- type: workflow
5
- role: planner
6
- version: 1.0.0
7
- author: Monoco Toolkit
8
- ---
9
-
10
- # flow_planner
11
-
12
- Planner 角色的标准化工作流 (Flow Skill),负责分析、设计、规划和交接。
13
-
14
- ## 工作流状态机
15
-
16
- ```mermaid
17
- stateDiagram-v2
18
- [*] --> Analyze: 接收输入
19
-
20
- Analyze --> Design: 需求清晰
21
- Analyze --> Analyze: 信息不足<br/>(收集更多)
22
-
23
- Design --> Plan: 设计完成
24
- Design --> Design: 方案冲突<br/>(重新设计)
25
-
26
- Plan --> Handoff: 规划完成
27
- Plan --> Plan: 依赖复杂<br/>(调整计划)
28
-
29
- Handoff --> [*]: 交接成功
30
- ```
31
-
32
- ---
33
-
34
- ## 执行步骤
35
-
36
- ### 1. Analyze (分析)
37
-
38
- **目标**: 充分理解需求和上下文
39
-
40
- **入口条件**:
41
- - 接收到 Memo 或 Issue 输入
42
- - 或检测到需要细化的任务
43
-
44
- **自动执行检查点**:
45
-
46
- - [ ] **读取输入**: 读取 Memo 或 Issue 的完整内容
47
- - [ ] **识别上下文**: 识别相关代码文件、模块和依赖
48
- - [ ] **检查架构**: 检查现有架构和技术栈
49
- - [ ] **评估范围**: 评估影响范围和复杂度
50
- - [ ] **记录发现**: 将分析结果记录到 Issue 或创建新的研究 Issue
51
-
52
- **退出条件**:
53
- - 需求清晰明确 → 进入 Design
54
- - 信息不足 → 返回 Analyze,收集更多信息
55
-
56
- **命令参考**:
57
- ```bash
58
- # 读取 Memo
59
- monoco memo list
60
- monoco memo open <id>
61
-
62
- # 读取 Issue
63
- cat Issues/<type>/<status>/<issue-file>.md
64
-
65
- # 检查相关代码
66
- grep -r "pattern" monoco/
67
- ```
68
-
69
- ---
70
-
71
- ### 2. Design (设计)
72
-
73
- **目标**: 产出架构设计方案
74
-
75
- **入口条件**:
76
- - Analyze 阶段完成,需求清晰
77
-
78
- **自动执行检查点**:
79
-
80
- - [ ] **系统架构**: 设计系统架构和组件关系
81
- - [ ] **继承性评估**: 评估与现有系统的兼容性
82
- - [ ] **安全评估**: 识别安全风险和缓解措施
83
- - [ ] **性能评估**: 评估性能影响和优化方案
84
- - [ ] **可维护性**: 考虑可维护性和扩展性
85
- - [ ] **设计文档**: 编写架构设计文档 (Architecture Decision Record)
86
-
87
- **退出条件**:
88
- - 设计完成且通过自评 → 进入 Plan
89
- - 架构冲突 → 返回 Design,重新设计方案
90
-
91
- **设计输出模板**:
92
- ```markdown
93
- ## Architecture Design
94
-
95
- ### 1. 系统架构
96
- [架构图或描述]
97
-
98
- ### 2. 组件关系
99
- - Component A → Component B
100
- - 接口定义: ...
101
-
102
- ### 3. 技术选型
103
- - 语言/框架: ...
104
- - 依赖库: ...
105
-
106
- ### 4. 风险评估
107
- | 风险 | 影响 | 缓解措施 |
108
- |------|------|----------|
109
- | ... | ... | ... |
110
- ```
111
-
112
- ---
113
-
114
- ### 3. Plan (规划)
115
-
116
- **目标**: 制定可执行的任务计划
117
-
118
- **入口条件**:
119
- - Design 阶段完成,架构方案确定
120
-
121
- **自动执行检查点**:
122
-
123
- - [ ] **任务分解**: 将工作分解为可执行的单元 (Issue/Feature)
124
- - [ ] **依赖分析**: 识别任务间的依赖关系
125
- - [ ] **工作量估算**: 估算每个任务的工作量和优先级
126
- - [ ] **创建 Issue**: 使用 `monoco issue create` 创建子任务
127
- - [ ] **更新父 Issue**: 更新原始 Issue 的任务列表和依赖
128
-
129
- **退出条件**:
130
- - 规划完成 → 进入 Handoff
131
- - 依赖复杂 → 返回 Plan,调整任务分解
132
-
133
- **命令参考**:
134
- ```bash
135
- # 创建子任务
136
- monoco issue create feature -t "子任务标题" --parent <parent-id>
137
-
138
- # 更新 Issue
139
- monoco issue edit <id> --add-task "任务描述"
140
- ```
141
-
142
- ---
143
-
144
- ### 4. Handoff (交接)
145
-
146
- **目标**: 将任务交接给 Engineer
147
-
148
- **入口条件**:
149
- - Plan 阶段完成,任务已分解为可执行单元
150
-
151
- **自动执行检查点**:
152
-
153
- - [ ] **上下文摘要**: 生成完整的上下文摘要 (Context Summary)
154
- - [ ] **更新 Issue**: 更新 Issue 描述,包含技术设计和执行步骤
155
- - [ ] **标记状态**: 标记 Issue 为 `ready_for_dev`
156
- - [ ] **通知 Engineer**: 如系统支持,通知 Engineer 有新任务
157
-
158
- **交接文档模板**:
159
- ```markdown
160
- ## Handoff Document
161
-
162
- ### Context
163
- [任务背景和目标的简要描述]
164
-
165
- ### Architecture
166
- [架构设计的关键点]
167
-
168
- ### Implementation Guide
169
- [实现步骤和注意事项]
170
-
171
- ### Acceptance Criteria
172
- - [ ] 验收标准 1
173
- - [ ] 验收标准 2
174
-
175
- ### Related Files
176
- - `path/to/file1.py`
177
- - `path/to/file2.py`
178
-
179
- ### Dependencies
180
- - 依赖 Issue: #XXX
181
- - 阻塞 Issue: #YYY
182
- ```
183
-
184
- **退出条件**:
185
- - 交接成功 → 工作流结束
186
-
187
- ---
188
-
189
- ## 决策分支
190
-
191
- | 条件 | 动作 | 说明 |
192
- |------|------|------|
193
- | 信息不足 | 返回 Analyze | 收集更多信息,可能创建 Spike Issue |
194
- | 架构冲突 | 返回 Design | 重新设计方案,记录决策理由 |
195
- | 依赖复杂 | 返回 Plan | 调整任务分解,简化依赖关系 |
196
- | 规划完成 | 进入 Handoff | 交接给 Engineer |
197
-
198
- ---
199
-
200
- ## 与 Engineer 的协作
201
-
202
- ```
203
- Planner (Analyze → Design → Plan)
204
-
205
- 创建/细化 Issue
206
-
207
- Engineer (Investigate → Code → Test → Submit)
208
-
209
- Reviewer (Review → Approve/Reject)
210
-
211
- [如需要] → 返回 Planner 重新规划
212
- ```
213
-
214
- ### 协作接口
215
-
216
- **Planner → Engineer**:
217
- - 输出: 细化的 Issue + 架构设计文档
218
- - 格式: Issue 描述中包含 "## Implementation Guide" 章节
219
- - 标记: Issue 标记为 `ready_for_dev`
220
-
221
- **Engineer → Planner**:
222
- - 触发: Engineer 发现需求不清或架构问题
223
- - 动作: 标记 Issue 为 `needs_refine`,Planner 重新介入
224
-
225
- ---
226
-
227
- ## 使用方式
228
-
229
- ### 手动触发
230
-
231
- ```bash
232
- # 以 Planner 角色运行
233
- monoco agent run --role Planner --input Issues/Features/open/FEAT-XXXX.md
234
- ```
235
-
236
- ### 自动触发
237
-
238
- 当满足以下条件时自动触发:
239
- 1. 新 Memo 创建且包含 `#plan` 标签
240
- 2. Issue 被标记为 `needs_refine`
241
- 3. Epic 创建后需要分解为 Features
242
-
243
- ---
244
-
245
- ## 最佳实践
246
-
247
- 1. **Evidence Based**: 所有架构决策必须有代码或文档证据支持
248
- 2. **Incremental Design**: 优先采用增量式设计,避免过度设计
249
- 3. **Clear Boundaries**: 明确模块边界和接口契约
250
- 4. **Document First**: 先写设计文档,再创建实现任务
251
- 5. **Review Loop**: 复杂设计应经过 Review 后再交接
252
-
253
- ---
254
-
255
- ## 相关资源
256
-
257
- - Role 定义: `monoco/features/agent/resources/roles/planner.yaml`
258
- - Engineer Flow: `.agent/skills/flow_engineer/SKILL.md`
259
- - Reviewer Flow: `.agent/skills/flow_reviewer/SKILL.md`