monoco-toolkit 0.3.5__py3-none-any.whl → 0.3.9__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.
- monoco/cli/workspace.py +1 -1
- monoco/core/config.py +51 -0
- monoco/core/hooks/__init__.py +19 -0
- monoco/core/hooks/base.py +104 -0
- monoco/core/hooks/builtin/__init__.py +11 -0
- monoco/core/hooks/builtin/git_cleanup.py +266 -0
- monoco/core/hooks/builtin/logging_hook.py +78 -0
- monoco/core/hooks/context.py +131 -0
- monoco/core/hooks/registry.py +222 -0
- monoco/core/integrations.py +6 -0
- monoco/core/registry.py +2 -0
- monoco/core/setup.py +1 -1
- monoco/core/skills.py +226 -42
- monoco/features/{scheduler → agent}/__init__.py +4 -2
- monoco/features/{scheduler → agent}/cli.py +134 -80
- monoco/features/{scheduler → agent}/config.py +17 -3
- monoco/features/agent/defaults.py +55 -0
- monoco/features/agent/flow_skills.py +281 -0
- monoco/features/{scheduler → agent}/manager.py +39 -2
- monoco/features/{scheduler → agent}/models.py +6 -3
- monoco/features/{scheduler → agent}/reliability.py +1 -1
- monoco/features/agent/resources/skills/flow_engineer/SKILL.md +94 -0
- monoco/features/agent/resources/skills/flow_manager/SKILL.md +88 -0
- monoco/features/agent/resources/skills/flow_reviewer/SKILL.md +114 -0
- monoco/features/{scheduler → agent}/session.py +39 -5
- monoco/features/{scheduler → agent}/worker.py +2 -2
- monoco/features/i18n/resources/skills/i18n_scan_workflow/SKILL.md +105 -0
- monoco/features/issue/commands.py +427 -21
- monoco/features/issue/core.py +104 -0
- monoco/features/issue/criticality.py +553 -0
- monoco/features/issue/domain/models.py +28 -2
- monoco/features/issue/engine/machine.py +65 -37
- monoco/features/issue/git_service.py +185 -0
- monoco/features/issue/linter.py +291 -62
- monoco/features/issue/models.py +91 -14
- monoco/features/issue/resources/en/SKILL.md +48 -0
- monoco/features/issue/resources/skills/issue_lifecycle_workflow/SKILL.md +159 -0
- monoco/features/issue/resources/zh/SKILL.md +50 -0
- monoco/features/issue/test_priority_integration.py +1 -0
- monoco/features/issue/validator.py +185 -65
- monoco/features/memo/__init__.py +4 -0
- monoco/features/memo/adapter.py +32 -0
- monoco/features/memo/cli.py +112 -0
- monoco/features/memo/core.py +146 -0
- monoco/features/memo/resources/skills/note_processing_workflow/SKILL.md +140 -0
- monoco/features/memo/resources/zh/AGENTS.md +8 -0
- monoco/features/memo/resources/zh/SKILL.md +75 -0
- monoco/features/spike/resources/skills/research_workflow/SKILL.md +121 -0
- monoco/main.py +6 -3
- {monoco_toolkit-0.3.5.dist-info → monoco_toolkit-0.3.9.dist-info}/METADATA +1 -1
- {monoco_toolkit-0.3.5.dist-info → monoco_toolkit-0.3.9.dist-info}/RECORD +56 -35
- monoco/features/scheduler/defaults.py +0 -54
- monoco/features/skills/__init__.py +0 -0
- monoco/features/skills/core.py +0 -102
- /monoco/core/{hooks.py → githooks.py} +0 -0
- /monoco/features/{scheduler → agent}/engines.py +0 -0
- {monoco_toolkit-0.3.5.dist-info → monoco_toolkit-0.3.9.dist-info}/WHEEL +0 -0
- {monoco_toolkit-0.3.5.dist-info → monoco_toolkit-0.3.9.dist-info}/entry_points.txt +0 -0
- {monoco_toolkit-0.3.5.dist-info → monoco_toolkit-0.3.9.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from typing import Optional
|
|
3
|
-
from
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from pydantic import BaseModel, Field, ConfigDict
|
|
5
|
+
|
|
4
6
|
from .worker import Worker
|
|
7
|
+
from monoco.core.hooks import HookContext, HookRegistry, get_registry
|
|
8
|
+
from monoco.core.config import find_monoco_root
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
class Session(BaseModel):
|
|
@@ -10,6 +14,8 @@ class Session(BaseModel):
|
|
|
10
14
|
Persisted state of the session.
|
|
11
15
|
"""
|
|
12
16
|
|
|
17
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
18
|
+
|
|
13
19
|
id: str = Field(..., description="Unique session ID (likely UUID)")
|
|
14
20
|
issue_id: str = Field(..., description="The Issue ID this session is working on")
|
|
15
21
|
role_name: str = Field(..., description="Name of the role employed")
|
|
@@ -24,18 +30,27 @@ class Session(BaseModel):
|
|
|
24
30
|
# History could be a list of logs or pointers to git commits
|
|
25
31
|
# For now, let's keep it simple. The git log IS the history.
|
|
26
32
|
|
|
27
|
-
class Config:
|
|
28
|
-
arbitrary_types_allowed = True
|
|
29
|
-
|
|
30
33
|
|
|
31
34
|
class RuntimeSession:
|
|
32
35
|
"""
|
|
33
36
|
The in-memory wrapper around the Session model and the active Worker.
|
|
34
37
|
"""
|
|
35
38
|
|
|
36
|
-
def __init__(
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
session_model: Session,
|
|
42
|
+
worker: Worker,
|
|
43
|
+
hook_registry: Optional[HookRegistry] = None,
|
|
44
|
+
project_root: Optional[Path] = None,
|
|
45
|
+
):
|
|
37
46
|
self.model = session_model
|
|
38
47
|
self.worker = worker
|
|
48
|
+
self.hook_registry = hook_registry or get_registry()
|
|
49
|
+
self.project_root = project_root or find_monoco_root()
|
|
50
|
+
|
|
51
|
+
def _create_hook_context(self) -> HookContext:
|
|
52
|
+
"""Create a HookContext from the current session state."""
|
|
53
|
+
return HookContext.from_runtime_session(self, self.project_root)
|
|
39
54
|
|
|
40
55
|
def start(self, context: Optional[dict] = None):
|
|
41
56
|
print(
|
|
@@ -46,6 +61,10 @@ class RuntimeSession:
|
|
|
46
61
|
self.model.updated_at = datetime.now()
|
|
47
62
|
|
|
48
63
|
try:
|
|
64
|
+
# Execute on_session_start hooks
|
|
65
|
+
hook_context = self._create_hook_context()
|
|
66
|
+
self.hook_registry.execute_on_session_start(hook_context)
|
|
67
|
+
|
|
49
68
|
self.worker.start(context)
|
|
50
69
|
# Async mode: we assume it started running.
|
|
51
70
|
# Use poll or refresh_status to check later.
|
|
@@ -82,6 +101,21 @@ class RuntimeSession:
|
|
|
82
101
|
|
|
83
102
|
def terminate(self):
|
|
84
103
|
print(f"Session {self.model.id}: Terminating")
|
|
104
|
+
|
|
105
|
+
# Execute on_session_end hooks before stopping worker
|
|
106
|
+
# This allows hooks to perform cleanup while session context is still valid
|
|
107
|
+
try:
|
|
108
|
+
hook_context = self._create_hook_context()
|
|
109
|
+
results = self.hook_registry.execute_on_session_end(hook_context)
|
|
110
|
+
|
|
111
|
+
# Log hook results
|
|
112
|
+
for result in results:
|
|
113
|
+
if result.status == "failure":
|
|
114
|
+
print(f" Hook warning: {result.message}")
|
|
115
|
+
except Exception as e:
|
|
116
|
+
# Don't let hook errors prevent session termination
|
|
117
|
+
print(f" Hook execution error: {e}")
|
|
118
|
+
|
|
85
119
|
self.worker.stop()
|
|
86
120
|
self.model.status = "terminated"
|
|
87
121
|
self.model.updated_at = datetime.now()
|
|
@@ -38,8 +38,8 @@ class Worker:
|
|
|
38
38
|
import sys
|
|
39
39
|
|
|
40
40
|
# Prepare the prompt
|
|
41
|
-
# We treat '
|
|
42
|
-
if (self.role.name == "drafter" or self.role.name == "
|
|
41
|
+
# We treat 'Planner' as a drafter when context is provided (Draft Mode)
|
|
42
|
+
if (self.role.name == "drafter" or self.role.name == "Planner") and context:
|
|
43
43
|
issue_type = context.get("type", "feature")
|
|
44
44
|
description = context.get("description", "No description")
|
|
45
45
|
prompt = (
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: i18n-scan-workflow
|
|
3
|
+
description: I18n 扫描工作流 (Flow Skill)。定义从扫描缺失翻译到生成翻译任务的标准操作流程,确保多语言文档质量。
|
|
4
|
+
type: flow
|
|
5
|
+
domain: i18n
|
|
6
|
+
version: 1.0.0
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# I18n Scan Workflow
|
|
10
|
+
|
|
11
|
+
I18n 扫描的标准化工作流,确保 "Scan → Identify → Generate Tasks" 流程。
|
|
12
|
+
|
|
13
|
+
## 工作流状态机
|
|
14
|
+
|
|
15
|
+
```mermaid
|
|
16
|
+
stateDiagram-v2
|
|
17
|
+
[*] --> Scan: 触发扫描
|
|
18
|
+
|
|
19
|
+
Scan --> Identify: 扫描完成
|
|
20
|
+
Scan --> Scan: 配置错误<br/>(修复配置)
|
|
21
|
+
|
|
22
|
+
Identify --> GenerateTasks: 发现缺失
|
|
23
|
+
Identify --> [*]: 无缺失<br/>(完成)
|
|
24
|
+
|
|
25
|
+
GenerateTasks --> [*]: 任务生成完成
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 执行步骤
|
|
29
|
+
|
|
30
|
+
### 1. Scan (扫描)
|
|
31
|
+
|
|
32
|
+
- **目标**: 扫描项目中所有文档,识别翻译覆盖情况
|
|
33
|
+
- **输入**: 项目文件、i18n 配置
|
|
34
|
+
- **输出**: 扫描报告
|
|
35
|
+
- **检查点**:
|
|
36
|
+
- [ ] 检查 `.monoco/config.yaml` 中的 i18n 配置
|
|
37
|
+
- [ ] 运行 `monoco i18n scan`
|
|
38
|
+
- [ ] 确认源语言和目标语言设置正确
|
|
39
|
+
- [ ] 验证排除规则(.gitignore、build 目录等)
|
|
40
|
+
|
|
41
|
+
### 2. Identify (识别缺失)
|
|
42
|
+
|
|
43
|
+
- **目标**: 分析扫描结果,识别具体缺失的翻译
|
|
44
|
+
- **策略**: 对比源文件和目标文件
|
|
45
|
+
- **检查点**:
|
|
46
|
+
- [ ] 列出所有缺失翻译的源文件
|
|
47
|
+
- [ ] 识别缺失的目标语言
|
|
48
|
+
- [ ] 评估缺失翻译的影响范围
|
|
49
|
+
- [ ] 按优先级排序(核心文档优先)
|
|
50
|
+
|
|
51
|
+
### 3. Generate Tasks (生成任务)
|
|
52
|
+
|
|
53
|
+
- **目标**: 为缺失的翻译创建追踪任务
|
|
54
|
+
- **策略**: 根据缺失情况创建 Issue 或备忘录
|
|
55
|
+
- **检查点**:
|
|
56
|
+
- [ ] 为核心文档缺失创建 Feature Issue
|
|
57
|
+
- [ ] 为次要文档缺失创建 Memo 提醒
|
|
58
|
+
- [ ] 在 Issue 中标注需要翻译的文件路径
|
|
59
|
+
- [ ] 设置合理的优先级和截止日期
|
|
60
|
+
|
|
61
|
+
## 决策分支
|
|
62
|
+
|
|
63
|
+
| 条件 | 动作 |
|
|
64
|
+
|------|------|
|
|
65
|
+
| 配置错误 | 修复 `.monoco/config.yaml`,重新扫描 |
|
|
66
|
+
| 无缺失翻译 | 流程完成,无需进一步操作 |
|
|
67
|
+
| 大量缺失 | 创建 Epic,拆分为多个 Feature |
|
|
68
|
+
| 关键文档缺失 | 高优先级,立即创建 Issue |
|
|
69
|
+
|
|
70
|
+
## 合规要求
|
|
71
|
+
|
|
72
|
+
- **必须**: 扫描前验证 i18n 配置正确
|
|
73
|
+
- **必须**: 所有核心文档必须有对应翻译
|
|
74
|
+
- **建议**: 定期运行扫描(如每周)
|
|
75
|
+
- **建议**: 将翻译任务与功能开发绑定
|
|
76
|
+
|
|
77
|
+
## 相关命令
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 扫描缺失翻译
|
|
81
|
+
monoco i18n scan
|
|
82
|
+
|
|
83
|
+
# 创建翻译任务
|
|
84
|
+
monoco issue create feature -t "翻译 {filename} 到 {lang}"
|
|
85
|
+
|
|
86
|
+
# 添加备忘录
|
|
87
|
+
monoco memo add "需要翻译: {filepath}"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 输出示例
|
|
91
|
+
|
|
92
|
+
扫描完成后,应生成如下报告:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
I18n Scan Report
|
|
96
|
+
================
|
|
97
|
+
Source Language: en
|
|
98
|
+
Target Languages: zh, ja
|
|
99
|
+
|
|
100
|
+
Missing Translations:
|
|
101
|
+
- docs/guide.md → zh/guide.md [MISSING]
|
|
102
|
+
- docs/api.md → ja/api.md [MISSING]
|
|
103
|
+
|
|
104
|
+
Coverage: 85%
|
|
105
|
+
```
|