@creatoria/miniapp-mcp 0.1.3 → 0.2.0
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.
- package/README.md +14 -3
- package/dist/app/cli/index.d.ts +6 -0
- package/dist/app/cli/index.d.ts.map +1 -0
- package/dist/app/cli/index.js +6 -0
- package/dist/app/cli/index.js.map +1 -0
- package/dist/app/index.d.ts +6 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +6 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/server/index.d.ts +7 -0
- package/dist/app/server/index.d.ts.map +1 -0
- package/dist/app/server/index.js +6 -0
- package/dist/app/server/index.js.map +1 -0
- package/dist/capabilities/assert/index.d.ts +5 -0
- package/dist/capabilities/assert/index.d.ts.map +1 -0
- package/dist/capabilities/assert/index.js +5 -0
- package/dist/capabilities/assert/index.js.map +1 -0
- package/dist/capabilities/automator/index.d.ts +6 -0
- package/dist/capabilities/automator/index.d.ts.map +1 -0
- package/dist/capabilities/automator/index.js +6 -0
- package/dist/capabilities/automator/index.js.map +1 -0
- package/dist/capabilities/automator/schemas/close.d.ts +5 -0
- package/dist/capabilities/automator/schemas/close.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/close.js +11 -0
- package/dist/capabilities/automator/schemas/close.js.map +1 -0
- package/dist/capabilities/automator/schemas/connect.d.ts +11 -0
- package/dist/capabilities/automator/schemas/connect.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/connect.js +19 -0
- package/dist/capabilities/automator/schemas/connect.js.map +1 -0
- package/dist/capabilities/automator/schemas/disconnect.d.ts +5 -0
- package/dist/capabilities/automator/schemas/disconnect.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/disconnect.js +11 -0
- package/dist/capabilities/automator/schemas/disconnect.js.map +1 -0
- package/dist/capabilities/automator/schemas/index.d.ts +4 -0
- package/dist/capabilities/automator/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/index.js +12 -0
- package/dist/capabilities/automator/schemas/index.js.map +1 -0
- package/dist/capabilities/automator/schemas/launch.d.ts +17 -0
- package/dist/capabilities/automator/schemas/launch.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/launch.js +26 -0
- package/dist/capabilities/automator/schemas/launch.js.map +1 -0
- package/dist/capabilities/element/index.d.ts +5 -0
- package/dist/capabilities/element/index.d.ts.map +1 -0
- package/dist/capabilities/element/index.js +5 -0
- package/dist/capabilities/element/index.js.map +1 -0
- package/dist/capabilities/index.d.ts +15 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +14 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/miniprogram/index.d.ts +5 -0
- package/dist/capabilities/miniprogram/index.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/index.js +5 -0
- package/dist/capabilities/miniprogram/index.js.map +1 -0
- package/dist/capabilities/network/index.d.ts +5 -0
- package/dist/capabilities/network/index.d.ts.map +1 -0
- package/dist/capabilities/network/index.js +5 -0
- package/dist/capabilities/network/index.js.map +1 -0
- package/dist/capabilities/page/index.d.ts +5 -0
- package/dist/capabilities/page/index.d.ts.map +1 -0
- package/dist/capabilities/page/index.js +5 -0
- package/dist/capabilities/page/index.js.map +1 -0
- package/dist/capabilities/record/index.d.ts +5 -0
- package/dist/capabilities/record/index.d.ts.map +1 -0
- package/dist/capabilities/record/index.js +5 -0
- package/dist/capabilities/record/index.js.map +1 -0
- package/dist/capabilities/schema-registry.d.ts +4 -0
- package/dist/capabilities/schema-registry.d.ts.map +1 -0
- package/dist/capabilities/schema-registry.js +18 -0
- package/dist/capabilities/schema-registry.js.map +1 -0
- package/dist/capabilities/schema-types.d.ts +22 -0
- package/dist/capabilities/schema-types.d.ts.map +1 -0
- package/dist/capabilities/schema-types.js +2 -0
- package/dist/capabilities/schema-types.js.map +1 -0
- package/dist/capabilities/snapshot/index.d.ts +5 -0
- package/dist/capabilities/snapshot/index.d.ts.map +1 -0
- package/dist/capabilities/snapshot/index.js +5 -0
- package/dist/capabilities/snapshot/index.js.map +1 -0
- package/dist/config/loader.js +1 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/core/element-ref.d.ts +1 -43
- package/dist/core/element-ref.d.ts.map +1 -1
- package/dist/core/element-ref.js +1 -212
- package/dist/core/element-ref.js.map +1 -1
- package/dist/core/logger.d.ts +1 -54
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +1 -377
- package/dist/core/logger.js.map +1 -1
- package/dist/core/output.d.ts +1 -20
- package/dist/core/output.d.ts.map +1 -1
- package/dist/core/output.js +1 -55
- package/dist/core/output.js.map +1 -1
- package/dist/core/report-generator.d.ts +1 -23
- package/dist/core/report-generator.d.ts.map +1 -1
- package/dist/core/report-generator.js +1 -211
- package/dist/core/report-generator.js.map +1 -1
- package/dist/core/session.d.ts +2 -82
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +2 -305
- package/dist/core/session.js.map +1 -1
- package/dist/core/timeout.d.ts +1 -48
- package/dist/core/timeout.d.ts.map +1 -1
- package/dist/core/timeout.js +1 -66
- package/dist/core/timeout.js.map +1 -1
- package/dist/core/tool-logger.d.ts +1 -82
- package/dist/core/tool-logger.d.ts.map +1 -1
- package/dist/core/tool-logger.js +1 -452
- package/dist/core/tool-logger.js.map +1 -1
- package/dist/core/validation.d.ts +1 -38
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +1 -92
- package/dist/core/validation.js.map +1 -1
- package/dist/runtime/element/element-ref.d.ts +44 -0
- package/dist/runtime/element/element-ref.d.ts.map +1 -0
- package/dist/runtime/element/element-ref.js +214 -0
- package/dist/runtime/element/element-ref.js.map +1 -0
- package/dist/runtime/element/index.d.ts +2 -0
- package/dist/runtime/element/index.d.ts.map +1 -0
- package/dist/runtime/element/index.js +2 -0
- package/dist/runtime/element/index.js.map +1 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/logging/index.d.ts +3 -0
- package/dist/runtime/logging/index.d.ts.map +1 -0
- package/dist/runtime/logging/index.js +3 -0
- package/dist/runtime/logging/index.js.map +1 -0
- package/dist/runtime/logging/logger.d.ts +55 -0
- package/dist/runtime/logging/logger.d.ts.map +1 -0
- package/dist/runtime/logging/logger.js +379 -0
- package/dist/runtime/logging/logger.js.map +1 -0
- package/dist/runtime/logging/tool-logger.d.ts +83 -0
- package/dist/runtime/logging/tool-logger.d.ts.map +1 -0
- package/dist/runtime/logging/tool-logger.js +454 -0
- package/dist/runtime/logging/tool-logger.js.map +1 -0
- package/dist/runtime/outputs/index.d.ts +3 -0
- package/dist/runtime/outputs/index.d.ts.map +1 -0
- package/dist/runtime/outputs/index.js +3 -0
- package/dist/runtime/outputs/index.js.map +1 -0
- package/dist/runtime/outputs/output-manager.d.ts +12 -0
- package/dist/runtime/outputs/output-manager.d.ts.map +1 -0
- package/dist/runtime/outputs/output-manager.js +39 -0
- package/dist/runtime/outputs/output-manager.js.map +1 -0
- package/dist/runtime/outputs/report-generator.d.ts +5 -0
- package/dist/runtime/outputs/report-generator.d.ts.map +1 -0
- package/dist/runtime/outputs/report-generator.js +175 -0
- package/dist/runtime/outputs/report-generator.js.map +1 -0
- package/dist/runtime/session/index.d.ts +3 -0
- package/dist/runtime/session/index.d.ts.map +1 -0
- package/dist/runtime/session/index.js +3 -0
- package/dist/runtime/session/index.js.map +1 -0
- package/dist/runtime/session/store.d.ts +28 -0
- package/dist/runtime/session/store.d.ts.map +1 -0
- package/dist/runtime/session/store.js +154 -0
- package/dist/runtime/session/store.js.map +1 -0
- package/dist/runtime/session/utils/cleanup.d.ts +3 -0
- package/dist/runtime/session/utils/cleanup.d.ts.map +1 -0
- package/dist/runtime/session/utils/cleanup.js +78 -0
- package/dist/runtime/session/utils/cleanup.js.map +1 -0
- package/dist/runtime/timeout/index.d.ts +2 -0
- package/dist/runtime/timeout/index.d.ts.map +1 -0
- package/dist/runtime/timeout/index.js +2 -0
- package/dist/runtime/timeout/index.js.map +1 -0
- package/dist/runtime/timeout/timeout.d.ts +49 -0
- package/dist/runtime/timeout/timeout.d.ts.map +1 -0
- package/dist/runtime/timeout/timeout.js +67 -0
- package/dist/runtime/timeout/timeout.js.map +1 -0
- package/dist/runtime/validation/index.d.ts +2 -0
- package/dist/runtime/validation/index.d.ts.map +1 -0
- package/dist/runtime/validation/index.js +2 -0
- package/dist/runtime/validation/index.js.map +1 -0
- package/dist/runtime/validation/validation.d.ts +39 -0
- package/dist/runtime/validation/validation.d.ts.map +1 -0
- package/dist/runtime/validation/validation.js +93 -0
- package/dist/runtime/validation/validation.js.map +1 -0
- package/dist/schemas/automator/miniprogram_close.json +12 -0
- package/dist/schemas/automator/miniprogram_connect.json +19 -0
- package/dist/schemas/automator/miniprogram_disconnect.json +12 -0
- package/dist/schemas/automator/miniprogram_launch.json +30 -0
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/miniprogram.d.ts +0 -1
- package/dist/tools/miniprogram.d.ts.map +1 -1
- package/dist/tools/miniprogram.js +17 -29
- package/dist/tools/miniprogram.js.map +1 -1
- package/dist/tools/page.js +2 -2
- package/dist/tools/page.js.map +1 -1
- package/docs/directory-structure-and-code-style-best-practices.md +91 -0
- package/docs/migration/README.md +34 -0
- package/docs/migration/TC-ALIGN-01-notes.md +35 -0
- package/docs/migration/runtime-skeleton.md +50 -0
- package/docs/migration/tool-schema-strategy.md +75 -0
- package/docs//345/256/214/346/225/264/345/256/236/347/216/260/346/226/271/346/241/210.md +14 -14
- package/docs//347/254/254/344/270/200/347/211/210/346/234/254/346/226/271/346/241/210.md +7 -7
- package/package.json +4 -2
- package/docs/SIMPLE_USAGE.md +0 -210
- package/docs/architecture.E-Docs.md +0 -1359
- package/docs/architecture.F1.md +0 -720
- package/docs/architecture.F2.md +0 -871
- package/docs/architecture.F3.md +0 -905
- package/docs/architecture.md +0 -90
- package/docs/charter.A1.align.yaml +0 -170
- package/docs/charter.A2.align.yaml +0 -199
- package/docs/charter.A3.align.yaml +0 -242
- package/docs/charter.A4.align.yaml +0 -227
- package/docs/charter.B1.align.yaml +0 -179
- package/docs/charter.B2.align.yaml +0 -200
- package/docs/charter.B3.align.yaml +0 -200
- package/docs/charter.B4.align.yaml +0 -188
- package/docs/charter.C1.align.yaml +0 -190
- package/docs/charter.C2.align.yaml +0 -202
- package/docs/charter.C3.align.yaml +0 -211
- package/docs/charter.C4.align.yaml +0 -263
- package/docs/charter.C5.align.yaml +0 -220
- package/docs/charter.D1.align.yaml +0 -190
- package/docs/charter.D2.align.yaml +0 -234
- package/docs/charter.D3.align.yaml +0 -206
- package/docs/charter.E-Docs.align.yaml +0 -294
- package/docs/charter.F1.align.yaml +0 -193
- package/docs/charter.F2.align.yaml +0 -248
- package/docs/charter.F3.align.yaml +0 -287
- package/docs/charter.G.align.yaml +0 -174
- package/docs/charter.align.yaml +0 -111
- package/docs/maintenance.md +0 -682
- package/docs/playwright-mcp/350/260/203/347/240/224.md +0 -53
- package/docs/setup-guide.md +0 -775
- package/docs/tasks.A1.atomize.md +0 -296
- package/docs/tasks.A2.atomize.md +0 -408
- package/docs/tasks.A3.atomize.md +0 -564
- package/docs/tasks.A4.atomize.md +0 -496
- package/docs/tasks.B1.atomize.md +0 -352
- package/docs/tasks.B2.atomize.md +0 -561
- package/docs/tasks.B3.atomize.md +0 -508
- package/docs/tasks.B4.atomize.md +0 -504
- package/docs/tasks.C1.atomize.md +0 -540
- package/docs/tasks.C2.atomize.md +0 -665
- package/docs/tasks.C3.atomize.md +0 -745
- package/docs/tasks.C4.atomize.md +0 -908
- package/docs/tasks.C5.atomize.md +0 -755
- package/docs/tasks.D1.atomize.md +0 -547
- package/docs/tasks.D2.atomize.md +0 -619
- package/docs/tasks.D3.atomize.md +0 -790
- package/docs/tasks.E-Docs.atomize.md +0 -1204
- package/docs/tasks.atomize.md +0 -189
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
# Charter: [D3] Recording and Replay System
|
|
2
|
-
|
|
3
|
-
task_id: D3
|
|
4
|
-
task_name: 录制与回放系统实现
|
|
5
|
-
stage: D
|
|
6
|
-
phase: Align (Retrospective)
|
|
7
|
-
created_at: "2025-10-02"
|
|
8
|
-
status: COMPLETED
|
|
9
|
-
estimated_hours: 3-4
|
|
10
|
-
actual_hours: 3.5
|
|
11
|
-
|
|
12
|
-
## Goal (目标)
|
|
13
|
-
|
|
14
|
-
实现完整的工具调用序列录制与回放系统,支持保存测试场景、复现操作流程,为自动化测试和场景复用提供基础能力。
|
|
15
|
-
|
|
16
|
-
**核心交付物**:
|
|
17
|
-
- `src/tools/record.ts` - 录制/回放工具实现 (428 lines)
|
|
18
|
-
- `tests/unit/record.test.ts` - 完整单元测试 (422 lines)
|
|
19
|
-
- 6 个 MCP 工具:record_start, record_stop, record_list, record_get, record_delete, record_replay
|
|
20
|
-
- ActionSequence 数据结构定义
|
|
21
|
-
|
|
22
|
-
## Non-Goals (非目标)
|
|
23
|
-
|
|
24
|
-
- ❌ 不实现视频录制(仅录制工具调用序列)
|
|
25
|
-
- ❌ 不实现性能分析(仅记录 duration,不做分析)
|
|
26
|
-
- ❌ 不实现自动断言生成(回放仅执行,不验证)
|
|
27
|
-
- ❌ 不实现远程存储(仅本地文件系统)
|
|
28
|
-
- ❌ 不实现编辑/修改已保存序列的能力
|
|
29
|
-
|
|
30
|
-
## Scope (范围)
|
|
31
|
-
|
|
32
|
-
### In Scope (包含)
|
|
33
|
-
|
|
34
|
-
1. **录制管理**
|
|
35
|
-
- ✅ 启动录制(record_start):设置名称和描述
|
|
36
|
-
- ✅ 停止录制(record_stop):保存到 JSON 文件
|
|
37
|
-
- ✅ 自动生成 sequence ID(时间戳+随机数)
|
|
38
|
-
- ✅ 记录状态管理(SessionState.recording)
|
|
39
|
-
|
|
40
|
-
2. **动作捕获**
|
|
41
|
-
- ✅ RecordedAction 数据结构:timestamp/toolName/args/duration/success/error
|
|
42
|
-
- ✅ recordAction() 内部函数:被工具包装器调用
|
|
43
|
-
- ✅ 过滤掉录制工具自身的调用
|
|
44
|
-
- ✅ 支持成功和失败操作的记录
|
|
45
|
-
|
|
46
|
-
3. **序列管理**
|
|
47
|
-
- ✅ 列出所有序列(record_list):返回摘要信息
|
|
48
|
-
- ✅ 获取序列详情(record_get):返回完整 actions
|
|
49
|
-
- ✅ 删除序列(record_delete):从文件系统移除
|
|
50
|
-
- ✅ 文件存储位置:`{outputDir}/sequences/{sequenceId}.json`
|
|
51
|
-
|
|
52
|
-
4. **回放执行**
|
|
53
|
-
- ✅ 按序执行录制的工具调用(record_replay)
|
|
54
|
-
- ✅ 支持 continueOnError 模式
|
|
55
|
-
- ✅ 返回详细执行结果(success/failure 统计)
|
|
56
|
-
- ✅ 动态导入 tools 模块
|
|
57
|
-
|
|
58
|
-
5. **数据结构**
|
|
59
|
-
- ✅ ActionSequence: id/name/description/createdAt/actions[]
|
|
60
|
-
- ✅ RecordedAction: timestamp/toolName/args/duration/success/error
|
|
61
|
-
- ✅ SessionState.recording: isRecording/startedAt/currentSequence
|
|
62
|
-
|
|
63
|
-
### Out of Scope (不包含)
|
|
64
|
-
|
|
65
|
-
- ❌ 序列编辑功能(无法修改已保存序列)
|
|
66
|
-
- ❌ 条件逻辑(if/else/loop)
|
|
67
|
-
- ❌ 变量和参数化
|
|
68
|
-
- ❌ 回放速度控制
|
|
69
|
-
- ❌ 断点调试
|
|
70
|
-
- ❌ 远程共享序列
|
|
71
|
-
|
|
72
|
-
## Constraints (约束)
|
|
73
|
-
|
|
74
|
-
### Technical Constraints (技术约束)
|
|
75
|
-
|
|
76
|
-
1. **存储格式**
|
|
77
|
-
- 必须使用 JSON 格式(便于人工阅读和编辑)
|
|
78
|
-
- 文件命名:`{sequenceId}.json`
|
|
79
|
-
- 目录:`{outputDir}/sequences/`
|
|
80
|
-
|
|
81
|
-
2. **录制状态**
|
|
82
|
-
- 同一 Session 只能同时录制一个序列
|
|
83
|
-
- 录制状态存储在 SessionState.recording
|
|
84
|
-
- 停止录制后自动清空状态
|
|
85
|
-
|
|
86
|
-
3. **工具集成**
|
|
87
|
-
- recordAction() 必须被所有工具包装器调用
|
|
88
|
-
- 录制工具自身不应被录制
|
|
89
|
-
- 回放时使用动态导入(避免循环依赖)
|
|
90
|
-
|
|
91
|
-
4. **错误处理**
|
|
92
|
-
- 录制失败的操作也应被记录
|
|
93
|
-
- 回放可选择在错误时停止或继续
|
|
94
|
-
- 所有错误信息完整保留
|
|
95
|
-
|
|
96
|
-
### Business Constraints (业务约束)
|
|
97
|
-
|
|
98
|
-
1. **存储容量**: 单个序列 <10MB(典型测试场景 <100 个操作)
|
|
99
|
-
2. **回放性能**: 操作间延迟 <10ms(不模拟真实延迟)
|
|
100
|
-
3. **兼容性**: 序列格式向后兼容
|
|
101
|
-
|
|
102
|
-
## Success Criteria (成功标准)
|
|
103
|
-
|
|
104
|
-
### Functional Criteria (功能标准)
|
|
105
|
-
|
|
106
|
-
- ✅ 启动录制并获得 sequenceId
|
|
107
|
-
- ✅ 执行工具调用时自动记录到当前序列
|
|
108
|
-
- ✅ 停止录制后生成 JSON 文件
|
|
109
|
-
- ✅ list/get/delete 操作正常工作
|
|
110
|
-
- ✅ 回放成功重现录制的操作序列
|
|
111
|
-
- ✅ continueOnError=false 时遇到错误立即停止
|
|
112
|
-
- ✅ continueOnError=true 时继续执行并统计失败数
|
|
113
|
-
|
|
114
|
-
### Quality Criteria (质量标准)
|
|
115
|
-
|
|
116
|
-
- ✅ TypeScript 编译 0 错误
|
|
117
|
-
- ✅ 单元测试覆盖率 >90% (422 lines 测试代码)
|
|
118
|
-
- ✅ 无 ESLint 错误
|
|
119
|
-
- ✅ JSDoc 注释完整
|
|
120
|
-
- ✅ JSON 格式美化输出(2 空格缩进)
|
|
121
|
-
|
|
122
|
-
### Documentation Criteria (文档标准)
|
|
123
|
-
|
|
124
|
-
- ✅ 函数签名有 JSDoc
|
|
125
|
-
- ✅ 数据结构注释清晰
|
|
126
|
-
- ⏳ charter.D3.align.yaml (本文档)
|
|
127
|
-
- ⏳ tasks.D3.atomize.md (任务卡)
|
|
128
|
-
|
|
129
|
-
## Definition of Done (完成标准)
|
|
130
|
-
|
|
131
|
-
**代码**:
|
|
132
|
-
- ✅ `src/tools/record.ts` 实现完成 (428 lines)
|
|
133
|
-
- ✅ 6 个工具全部实现
|
|
134
|
-
- ✅ 集成到 registerTools (tools/index.ts)
|
|
135
|
-
- ✅ SessionState 扩展 recording 字段
|
|
136
|
-
- ✅ TypeScript 编译通过
|
|
137
|
-
|
|
138
|
-
**测试**:
|
|
139
|
-
- ✅ `tests/unit/record.test.ts` (422 lines)
|
|
140
|
-
- ✅ 所有核心函数有单元测试
|
|
141
|
-
- ✅ 边界情况覆盖(已录制/未录制/文件不存在等)
|
|
142
|
-
- ✅ 所有测试通过
|
|
143
|
-
|
|
144
|
-
**文档**:
|
|
145
|
-
- ⏳ charter.D3.align.yaml (追溯)
|
|
146
|
-
- ⏳ tasks.D3.atomize.md (追溯)
|
|
147
|
-
- ⏳ session_log (追溯)
|
|
148
|
-
|
|
149
|
-
**Git**:
|
|
150
|
-
- ✅ 已提交(feat: [D3] 录制回放能力实现)
|
|
151
|
-
|
|
152
|
-
## Dependencies (依赖)
|
|
153
|
-
|
|
154
|
-
**前置任务**:
|
|
155
|
-
- ✅ B2: SessionStore 和 SessionState 定义
|
|
156
|
-
- ✅ C1-C4: 核心工具实现(需要被录制)
|
|
157
|
-
- ✅ C5: registerTools 机制
|
|
158
|
-
|
|
159
|
-
**后续任务**:
|
|
160
|
-
- D3 → E4: 示例项目(使用录制序列)
|
|
161
|
-
- D3 → G1: 集成测试(使用回放验证)
|
|
162
|
-
|
|
163
|
-
## Risks (风险)
|
|
164
|
-
|
|
165
|
-
### Technical Risks (技术风险)
|
|
166
|
-
|
|
167
|
-
1. **循环依赖** - 🟢 已缓解
|
|
168
|
-
- 风险:record.ts 导入 tools/index.ts 导致循环依赖
|
|
169
|
-
- 缓解:使用动态导入 `await import('./index.js')`
|
|
170
|
-
|
|
171
|
-
2. **存储空间** - 🟢 低风险
|
|
172
|
-
- 风险:大量序列占用磁盘空间
|
|
173
|
-
- 缓解:用户手动管理,提供 delete 工具
|
|
174
|
-
|
|
175
|
-
3. **格式兼容性** - 🟡 中风险
|
|
176
|
-
- 风险:未来工具 API 变更导致旧序列无法回放
|
|
177
|
-
- 缓解:保留 toolName 和 args 原始结构
|
|
178
|
-
|
|
179
|
-
### Business Risks (业务风险)
|
|
180
|
-
|
|
181
|
-
1. **回放失败** - 🟡 中风险
|
|
182
|
-
- 影响:序列依赖特定状态(如页面路径)
|
|
183
|
-
- 缓解:记录完整 args,包括 pagePath 等上下文
|
|
184
|
-
|
|
185
|
-
2. **误用风险** - 🟢 低风险
|
|
186
|
-
- 影响:用户误以为回放会自动验证结果
|
|
187
|
-
- 缓解:文档明确说明回放不包含断言
|
|
188
|
-
|
|
189
|
-
## Open Questions (未决问题)
|
|
190
|
-
|
|
191
|
-
- ❓ 是否需要支持序列参数化(变量替换)?(当前不支持)
|
|
192
|
-
- ❓ 是否需要支持序列合并/拆分?(当前不支持)
|
|
193
|
-
- ❓ 是否需要记录页面截图作为视觉参考?(当前不支持)
|
|
194
|
-
|
|
195
|
-
## References (参考资料)
|
|
196
|
-
|
|
197
|
-
- `docs/完整实现方案.md` - 录制/回放架构设计
|
|
198
|
-
- `docs/微信小程序自动化完整操作手册.md` - 自动化 API 参考
|
|
199
|
-
- `src/types.ts` - ActionSequence/RecordedAction 定义
|
|
200
|
-
- Playwright Inspector 录制功能 - 设计灵感
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
**Approval**: ✅ RETROSPECTIVE APPROVED
|
|
205
|
-
**Implementation**: ✅ COMPLETED
|
|
206
|
-
**Documentation**: ⏳ IN PROGRESS
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
# E1: Documentation Enhancement - Project Charter
|
|
2
|
-
|
|
3
|
-
## Metadata
|
|
4
|
-
task_id: E1
|
|
5
|
-
stage: E - Documentation & Examples
|
|
6
|
-
status: PLANNED
|
|
7
|
-
created: 2025-10-02
|
|
8
|
-
author: Claude Code
|
|
9
|
-
approver: TBD
|
|
10
|
-
|
|
11
|
-
## 1. Goals (目标)
|
|
12
|
-
|
|
13
|
-
### Primary Goal (主要目标)
|
|
14
|
-
Complete and polish the project documentation system to ensure developers can quickly understand, configure, and use the MCP server for WeChat Mini Program automation.
|
|
15
|
-
|
|
16
|
-
完善 creatoria-miniapp-mcp 项目文档,提供清晰的使用指南、API 参考和实际示例,降低新用户上手门槛,提升项目可维护性。
|
|
17
|
-
|
|
18
|
-
### Success Criteria (成功标准)
|
|
19
|
-
- [ ] README.md provides 5-minute quickstart path
|
|
20
|
-
- [ ] All 59 tools have complete API documentation with examples
|
|
21
|
-
- [ ] At least 5 realistic usage examples covering major scenarios
|
|
22
|
-
- [ ] Troubleshooting guide covers common errors and debugging workflows
|
|
23
|
-
- [ ] Setup guide enables zero-to-running in <15 minutes
|
|
24
|
-
- [ ] Documentation is consistent, searchable, and cross-referenced
|
|
25
|
-
|
|
26
|
-
### Key Metrics (关键指标)
|
|
27
|
-
- Documentation coverage: 100% of tools (59/59)
|
|
28
|
-
- Example coverage: 5+ realistic scenarios
|
|
29
|
-
- Quickstart completion time: <5 minutes (first run)
|
|
30
|
-
- Setup completion time: <15 minutes (environment + config)
|
|
31
|
-
|
|
32
|
-
## 2. Non-Goals (非目标)
|
|
33
|
-
|
|
34
|
-
- ❌ Multi-language documentation (English/Chinese only, not other languages)
|
|
35
|
-
- ❌ Interactive documentation website (Markdown files only for E1)
|
|
36
|
-
- ❌ Video tutorials or screencasts (defer to Stage F)
|
|
37
|
-
- ❌ Auto-generated API docs from TypeScript types (manual curation for now)
|
|
38
|
-
- ❌ Migration guides from other automation frameworks
|
|
39
|
-
- ❌ Performance benchmarking documentation
|
|
40
|
-
- ❌ Advanced architecture deep-dives (keep in ADRs)
|
|
41
|
-
|
|
42
|
-
## 3. Scope (范围)
|
|
43
|
-
|
|
44
|
-
### In Scope
|
|
45
|
-
|
|
46
|
-
#### 3.1 README.md Enhancement
|
|
47
|
-
- **Current State**: Basic structure exists with installation and configuration sections
|
|
48
|
-
- **Target State**:
|
|
49
|
-
- Hero section with value proposition
|
|
50
|
-
- Quickstart (<5 minutes to first successful command)
|
|
51
|
-
- Core features overview (59 tools categorized into 7 groups)
|
|
52
|
-
- 3 inline code examples (navigation, interaction, assertion)
|
|
53
|
-
- Clear navigation to detailed docs
|
|
54
|
-
- Badges (CI status, license, version)
|
|
55
|
-
|
|
56
|
-
#### 3.2 API Documentation (docs/api/)
|
|
57
|
-
- **Current State**: Framework exists with README + category files (placeholders)
|
|
58
|
-
- **Target State**:
|
|
59
|
-
- `docs/api/README.md`: Tool catalog + basic workflows
|
|
60
|
-
- `docs/api/automator.md`: 4 tools (launch, connect, disconnect, close)
|
|
61
|
-
- `docs/api/miniprogram.md`: 6 tools (navigate, evaluate, screenshot, etc.)
|
|
62
|
-
- `docs/api/page.md`: 8 tools (query, data, wait, scroll, etc.)
|
|
63
|
-
- `docs/api/element.md`: 23 tools (attributes, interactions, component methods)
|
|
64
|
-
- `docs/api/assert.md`: 9 tools (exists, text, attribute, data, etc.)
|
|
65
|
-
- `docs/api/snapshot.md`: 3 tools (capture, restore, compare)
|
|
66
|
-
- `docs/api/record.md`: 6 tools (start, stop, save, replay, etc.)
|
|
67
|
-
|
|
68
|
-
**Format per tool**: Function description, parameters (with types), return value, code example, usage notes, common errors
|
|
69
|
-
|
|
70
|
-
#### 3.3 Usage Examples (examples/)
|
|
71
|
-
- **Current State**: `01-basic-navigation.md` exists (created previously)
|
|
72
|
-
- **Target State**: 5+ examples covering:
|
|
73
|
-
1. ✅ `01-basic-navigation.md` (existing - review/enhance)
|
|
74
|
-
2. `02-element-interaction.md` (tap, input, swiper, scroll, picker)
|
|
75
|
-
3. `03-assertion-testing.md` (automated test workflow with asserts)
|
|
76
|
-
4. `04-snapshot-debugging.md` (capture/restore state for debugging)
|
|
77
|
-
5. `05-record-replay.md` (record user flow, replay for regression testing)
|
|
78
|
-
6. (Optional) `06-e2e-shopping.md` (complete shopping cart flow)
|
|
79
|
-
|
|
80
|
-
**Format**: Scenario description, prerequisites, step-by-step code with explanations, expected output, troubleshooting tips
|
|
81
|
-
|
|
82
|
-
#### 3.4 Troubleshooting Guide (docs/troubleshooting.md)
|
|
83
|
-
- **Current State**: File exists with basic structure
|
|
84
|
-
- **Target State**:
|
|
85
|
-
- **FAQ Section**: Top 10-15 common questions
|
|
86
|
-
- **Error Reference**: Categorized by source (Automator, MCP, Network, Configuration)
|
|
87
|
-
- **Debugging Workflows**: Step-by-step diagnostic procedures
|
|
88
|
-
- **Best Practices**: Performance, reliability, maintainability tips
|
|
89
|
-
- **Common Pitfalls**: Element resolution, page state, timing issues
|
|
90
|
-
|
|
91
|
-
#### 3.5 Setup Guide (docs/setup-guide.md)
|
|
92
|
-
- **Current State**: File exists with basic installation steps
|
|
93
|
-
- **Target State**:
|
|
94
|
-
- **Environment Requirements**: Detailed version requirements (Node, WeChat DevTools, OS)
|
|
95
|
-
- **WeChat DevTools Setup**: Automation port configuration, security settings
|
|
96
|
-
- **MCP Client Configuration**: Claude Desktop, Cline, custom clients
|
|
97
|
-
- **Verification Steps**: How to confirm everything is working
|
|
98
|
-
- **Configuration Options**: All .mcp.json options explained
|
|
99
|
-
- **Common Setup Issues**: Permission errors, port conflicts, path issues
|
|
100
|
-
|
|
101
|
-
#### 3.6 Contributing Guide (CONTRIBUTING.md)
|
|
102
|
-
- **Current State**: File exists
|
|
103
|
-
- **Target State**:
|
|
104
|
-
- **6A Workflow**: Detailed explanation of Align/Architect/Atomize/Approve/Automate/Assess
|
|
105
|
-
- **Development Environment**: Setup, tools, commands
|
|
106
|
-
- **Code Standards**: TypeScript, testing, documentation conventions
|
|
107
|
-
- **Tool Development**: How to add new tools, register, test, document
|
|
108
|
-
- **PR Process**: Branch strategy, commit conventions, review checklist
|
|
109
|
-
|
|
110
|
-
### Out of Scope (for E1)
|
|
111
|
-
- Translation to languages other than English/Chinese
|
|
112
|
-
- Interactive API playground
|
|
113
|
-
- Auto-generated docs from code (revisit in Stage F)
|
|
114
|
-
- Migration guides from Playwright/Cypress
|
|
115
|
-
- Video/screencast tutorials (defer to Stage F)
|
|
116
|
-
|
|
117
|
-
## 4. Context & Background (背景)
|
|
118
|
-
|
|
119
|
-
### Current Documentation State
|
|
120
|
-
```
|
|
121
|
-
✅ Exists with content:
|
|
122
|
-
- README.md (basic structure)
|
|
123
|
-
- docs/api/README.md (framework)
|
|
124
|
-
- docs/api/*.md (category files with placeholders)
|
|
125
|
-
- examples/01-basic-navigation.md
|
|
126
|
-
- docs/troubleshooting.md (basic structure)
|
|
127
|
-
- docs/setup-guide.md (basic steps)
|
|
128
|
-
- CONTRIBUTING.md (exists)
|
|
129
|
-
|
|
130
|
-
❌ Needs enhancement:
|
|
131
|
-
- All API docs need complete tool documentation (59 tools)
|
|
132
|
-
- Need 4+ additional examples
|
|
133
|
-
- Troubleshooting needs FAQ and error reference
|
|
134
|
-
- Setup guide needs detailed configuration explanations
|
|
135
|
-
- README needs quickstart and inline examples
|
|
136
|
-
- CONTRIBUTING needs 6A workflow documentation
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Implementation Context
|
|
140
|
-
- Stage D2 (Snapshot capabilities) completed
|
|
141
|
-
- All 59 tools are implemented and tested (290+ tests passing)
|
|
142
|
-
- ElementRef protocol is stable
|
|
143
|
-
- SessionStore and OutputManager are production-ready
|
|
144
|
-
- MCP server is functional end-to-end
|
|
145
|
-
- Record tools implemented in Stage D2
|
|
146
|
-
|
|
147
|
-
### User Personas
|
|
148
|
-
1. **New Users**: Need quickstart and simple examples
|
|
149
|
-
2. **Integration Developers**: Need complete API reference
|
|
150
|
-
3. **Test Engineers**: Need assertion and recording examples
|
|
151
|
-
4. **Troubleshooters**: Need error reference and debugging guides
|
|
152
|
-
5. **Contributors**: Need development workflow documentation
|
|
153
|
-
|
|
154
|
-
## 5. Constraints & Assumptions (约束与假设)
|
|
155
|
-
|
|
156
|
-
### Constraints
|
|
157
|
-
- Documentation must be Markdown-based (portable, version-controlled)
|
|
158
|
-
- Examples must be runnable or clearly fictional with explanations
|
|
159
|
-
- API docs must stay synchronized with code (manual update protocol in CONTRIBUTING.md)
|
|
160
|
-
- All code examples must use TypeScript/JavaScript (no other languages)
|
|
161
|
-
- Documentation size: Keep individual files <2000 lines for readability
|
|
162
|
-
- Bilingual support: English and Chinese (mixed is acceptable)
|
|
163
|
-
|
|
164
|
-
### Assumptions
|
|
165
|
-
- Readers have basic WeChat Mini Program knowledge
|
|
166
|
-
- Readers understand MCP protocol basics (or can reference MCP docs)
|
|
167
|
-
- Example code doesn't need to be copy-pastable (conceptual clarity prioritized)
|
|
168
|
-
- Manual documentation maintenance is acceptable for now (no auto-generation)
|
|
169
|
-
- Most users will access docs via GitHub (Markdown rendering)
|
|
170
|
-
|
|
171
|
-
### Dependencies
|
|
172
|
-
- Stage D completion (all 59 tools implemented)
|
|
173
|
-
- Access to tool schemas and type definitions (src/tools/)
|
|
174
|
-
- Understanding of ElementRef protocol (src/core/element-ref.ts)
|
|
175
|
-
- Knowledge of SessionStore lifecycle (src/core/session-store.ts)
|
|
176
|
-
- Test files as source of usage examples (tests/unit/)
|
|
177
|
-
|
|
178
|
-
## 6. Risks & Mitigation (风险与缓解)
|
|
179
|
-
|
|
180
|
-
### Risks
|
|
181
|
-
|
|
182
|
-
| Risk | Impact | Probability | Mitigation |
|
|
183
|
-
|------|--------|-------------|------------|
|
|
184
|
-
| Documentation becomes outdated as code evolves | High | Medium | Establish update protocol in CONTRIBUTING.md, add checklist to PR template |
|
|
185
|
-
| Examples don't match user scenarios | Medium | Medium | Base on test files, collect feedback, iterate |
|
|
186
|
-
| API docs too technical for beginners | Medium | Low | Add beginner-friendly intro sections, progressive disclosure |
|
|
187
|
-
| Inconsistent formatting across docs | Low | Medium | Create documentation template, review all docs for consistency |
|
|
188
|
-
| Missing error codes in troubleshooting | Medium | Low | Cross-reference miniprogram-automator errors, add placeholders |
|
|
189
|
-
| Work underestimated | Medium | Medium | Focus on core content, avoid over-polishing |
|
|
190
|
-
|
|
191
|
-
### Open Questions
|
|
192
|
-
1. **API Documentation Generation**: Should we invest in auto-generation from Zod schemas, or maintain manually?
|
|
193
|
-
- **Current Decision**: Manual for E1 (faster), revisit automation in Stage F
|
|
194
|
-
|
|
195
|
-
2. **Example Code Verification**: Do we need a test suite that validates example code?
|
|
196
|
-
- **Decision Needed**: Defer to E2 or Stage G
|
|
197
|
-
|
|
198
|
-
3. **Documentation Site**: Should we use VitePress/Docusaurus for better UX?
|
|
199
|
-
- **Current Decision**: Markdown files only for E1 (simplicity), revisit in Stage G
|
|
200
|
-
|
|
201
|
-
4. **Localization Strategy**: Should we maintain separate EN/CN files or mixed?
|
|
202
|
-
- **Current Decision**: Mixed bilingual (headers in both languages) for critical docs
|
|
203
|
-
|
|
204
|
-
5. **Example Mini Program**: Do we need a dedicated demo project?
|
|
205
|
-
- **Decision Needed**: Check if existing test project can serve this purpose
|
|
206
|
-
|
|
207
|
-
## 7. Success Definition (完成标准)
|
|
208
|
-
|
|
209
|
-
### Definition of Done (DoD)
|
|
210
|
-
- [ ] README.md updated with quickstart, examples, and navigation
|
|
211
|
-
- [ ] All 59 tools documented in docs/api/ with required format (function, params, return, example, notes, errors)
|
|
212
|
-
- [ ] 5+ usage examples created in examples/ directory
|
|
213
|
-
- [ ] docs/troubleshooting.md includes FAQ (10+ items), error reference (20+ codes), debugging workflows (3+ scenarios)
|
|
214
|
-
- [ ] docs/setup-guide.md covers environment requirements, DevTools config, MCP client setup, verification steps
|
|
215
|
-
- [ ] docs/architecture.md created with system overview, design decisions
|
|
216
|
-
- [ ] CONTRIBUTING.md enhanced with 6A workflow, tool development guide
|
|
217
|
-
- [ ] All documentation cross-referenced (internal links working)
|
|
218
|
-
- [ ] Documentation reviewed for consistency, clarity, and completeness
|
|
219
|
-
- [ ] All new/updated files committed to git with proper commit message
|
|
220
|
-
|
|
221
|
-
### Acceptance Tests
|
|
222
|
-
1. **Quickstart Test**: New user can run first automation command in <5 minutes following README
|
|
223
|
-
2. **API Lookup Test**: Developer can find tool documentation and example for any of 59 tools in <2 minutes
|
|
224
|
-
3. **Example Test**: User can understand and adapt example code for their scenario in <10 minutes
|
|
225
|
-
4. **Troubleshooting Test**: User encountering error can find solution in troubleshooting.md in <5 minutes
|
|
226
|
-
5. **Setup Test**: New user can configure environment end-to-end in <15 minutes following setup-guide.md
|
|
227
|
-
|
|
228
|
-
### Evidence Collection
|
|
229
|
-
- Screenshots of rendered Markdown in GitHub
|
|
230
|
-
- Feedback from 2+ external reviewers (if available)
|
|
231
|
-
- Checklist completion for all DoD items
|
|
232
|
-
- Git commit log showing all documentation updates
|
|
233
|
-
- Session log documenting work performed
|
|
234
|
-
|
|
235
|
-
## 8. Timeline & Effort (时间与工作量)
|
|
236
|
-
|
|
237
|
-
### Estimated Effort
|
|
238
|
-
- README enhancement: 30 minutes
|
|
239
|
-
- API documentation (59 tools): 2-3 hours (3-4 minutes per tool)
|
|
240
|
-
- Usage examples (4 new + 1 enhancement): 2 hours (30 minutes each)
|
|
241
|
-
- Troubleshooting enhancement: 1 hour
|
|
242
|
-
- Setup guide enhancement: 30 minutes
|
|
243
|
-
- Architecture document: 45 minutes
|
|
244
|
-
- CONTRIBUTING enhancement: 30 minutes
|
|
245
|
-
- Cross-referencing and review: 1 hour
|
|
246
|
-
- **Total**: 7-9 hours
|
|
247
|
-
|
|
248
|
-
### Phasing (分阶段执行)
|
|
249
|
-
- **Phase 1** (2 hours): README + Setup Guide + Architecture (unblock new users)
|
|
250
|
-
- **Phase 2** (3 hours): API Documentation (reference completion)
|
|
251
|
-
- **Phase 3** (2 hours): Examples (learning materials)
|
|
252
|
-
- **Phase 4** (1.5 hours): Troubleshooting + CONTRIBUTING + Review
|
|
253
|
-
|
|
254
|
-
### Blockers
|
|
255
|
-
- None identified (all dependencies complete)
|
|
256
|
-
|
|
257
|
-
## 9. Stakeholders & Communication (相关方与沟通)
|
|
258
|
-
|
|
259
|
-
### Stakeholders
|
|
260
|
-
- **Primary**: Project maintainers (documentation owners)
|
|
261
|
-
- **Secondary**: Future contributors (need clear docs to contribute)
|
|
262
|
-
- **Tertiary**: End users (developers using the MCP server)
|
|
263
|
-
|
|
264
|
-
### Communication Plan
|
|
265
|
-
- Commit messages reference E1 task
|
|
266
|
-
- Update .llm/state.json with progress
|
|
267
|
-
- Create .llm/qa/E1-acceptance.md with evidence
|
|
268
|
-
- Session log in .llm/session_log/ if work spans multiple sessions
|
|
269
|
-
|
|
270
|
-
## 10. References (参考文档)
|
|
271
|
-
|
|
272
|
-
### Related Documents
|
|
273
|
-
- `docs/完整实现方案.md`: Original architecture
|
|
274
|
-
- `docs/微信小程序自动化完整操作手册.md`: Source of truth for tool capabilities
|
|
275
|
-
- `.llm/prompts/task.cards.md`: E1 task definition
|
|
276
|
-
- `CONTRIBUTING.md`: Documentation contribution guidelines (to be enhanced)
|
|
277
|
-
- `docs/charter.e1.align.yaml`: Original Chinese charter (superseded by this)
|
|
278
|
-
- `docs/architecture.e1.md`: Original Chinese architecture (superseded by architecture.E1.md)
|
|
279
|
-
|
|
280
|
-
### External References
|
|
281
|
-
- MCP Protocol Documentation: https://modelcontextprotocol.io/
|
|
282
|
-
- WeChat Mini Program Docs: https://developers.weixin.qq.com/miniprogram/dev/framework/
|
|
283
|
-
- Markdown Style Guide: https://www.markdownguide.org/
|
|
284
|
-
- GitHub Flavored Markdown: https://github.github.com/gfm/
|
|
285
|
-
|
|
286
|
-
---
|
|
287
|
-
|
|
288
|
-
**Approval Required**: YES (Align stage requires explicit approval before Atomize)
|
|
289
|
-
|
|
290
|
-
**Next Steps After Approval**:
|
|
291
|
-
1. Create `docs/tasks.E1.atomize.md` (break into implementation tasks)
|
|
292
|
-
2. Proceed to Atomize stage (detailed task breakdown)
|
|
293
|
-
3. Update `.llm/state.json` with E1 APPROVED status
|
|
294
|
-
4. Begin implementation with Phase 1 (README + Setup Guide + Architecture)
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
task: F1
|
|
2
|
-
name: "结构化日志增强 (Structured Logging Enhancement)"
|
|
3
|
-
parent_stage: "F - Observability & Artifacts"
|
|
4
|
-
version: "1.0"
|
|
5
|
-
date: "2025-10-03"
|
|
6
|
-
status: "Align"
|
|
7
|
-
|
|
8
|
-
# ==============================================================================
|
|
9
|
-
# 1. MISSION & SCOPE
|
|
10
|
-
# ==============================================================================
|
|
11
|
-
|
|
12
|
-
mission: |
|
|
13
|
-
增强现有日志系统,为每个 MCP 工具调用自动记录结构化信息(工具名、参数、
|
|
14
|
-
开始/结束时间、耗时、状态、错误),支持控制台输出格式化和可选的文件持久化,
|
|
15
|
-
提供完整的操作审计和调试能力。
|
|
16
|
-
|
|
17
|
-
goals:
|
|
18
|
-
- id: G1
|
|
19
|
-
description: "自动记录工具调用生命周期"
|
|
20
|
-
rationale: "每个工具调用应自动记录 START/END 事件,无需手动编写日志代码"
|
|
21
|
-
acceptance_criteria:
|
|
22
|
-
- "工具调用前自动记录 START 日志(工具名、参数)"
|
|
23
|
-
- "工具调用后自动记录 END 日志(工具名、结果、耗时)"
|
|
24
|
-
- "工具调用失败时记录 ERROR 日志(错误信息、堆栈)"
|
|
25
|
-
- "日志中包含 sessionId 和 timestamp"
|
|
26
|
-
|
|
27
|
-
- id: G2
|
|
28
|
-
description: "结构化日志格式"
|
|
29
|
-
rationale: "日志应易于机器解析(JSON)和人类阅读(格式化文本)"
|
|
30
|
-
acceptance_criteria:
|
|
31
|
-
- "每条日志为 JSON 对象(timestamp, level, sessionId, toolName, message, context, duration)"
|
|
32
|
-
- "控制台输出格式化为易读文本"
|
|
33
|
-
- "支持日志级别过滤(DEBUG, INFO, WARN, ERROR)"
|
|
34
|
-
|
|
35
|
-
- id: G3
|
|
36
|
-
description: "可选的文件持久化"
|
|
37
|
-
rationale: "长时间测试或 CI 环境需要保存日志到文件"
|
|
38
|
-
acceptance_criteria:
|
|
39
|
-
- "通过配置启用文件日志(默认禁用)"
|
|
40
|
-
- "日志文件按会话分离(outputDir/logs/session-{sessionId}.log)"
|
|
41
|
-
- "文件日志为 JSON Lines 格式(每行一个 JSON 对象)"
|
|
42
|
-
|
|
43
|
-
non_goals:
|
|
44
|
-
- "日志轮转(依赖外部工具如 logrotate)"
|
|
45
|
-
- "日志查询 API(用户使用 jq/grep 等工具)"
|
|
46
|
-
- "实时日志流传输"
|
|
47
|
-
- "日志加密"
|
|
48
|
-
|
|
49
|
-
# ==============================================================================
|
|
50
|
-
# 2. CONTEXT & CONSTRAINTS
|
|
51
|
-
# ==============================================================================
|
|
52
|
-
|
|
53
|
-
context:
|
|
54
|
-
current_state: |
|
|
55
|
-
- ConsoleLogger 已实现基础功能(info/warn/error/debug)
|
|
56
|
-
- 当前日志输出到 stderr,格式为:timestamp LEVEL [sessionId] [toolName]: message {context}
|
|
57
|
-
- 工具调用需要手动添加日志语句
|
|
58
|
-
- 无耗时统计
|
|
59
|
-
- 无文件持久化
|
|
60
|
-
|
|
61
|
-
dependencies:
|
|
62
|
-
- "B4: Logger 接口定义(src/types.ts:Logger)"
|
|
63
|
-
- "E1-E4: 配置系统(可配置 logLevel, enableFileLog, outputDir)"
|
|
64
|
-
- "C5: 工具注册器(src/tools/index.ts - 需集成自动日志)"
|
|
65
|
-
|
|
66
|
-
constraints:
|
|
67
|
-
technical:
|
|
68
|
-
- "日志不能阻塞工具执行(异步写入)"
|
|
69
|
-
- "保持 Logger 接口向后兼容"
|
|
70
|
-
- "文件写入错误不应中断工具执行"
|
|
71
|
-
|
|
72
|
-
business:
|
|
73
|
-
- "文件日志默认禁用(避免未预期的磁盘写入)"
|
|
74
|
-
- "不破坏现有 395 个单元测试"
|
|
75
|
-
|
|
76
|
-
timeline:
|
|
77
|
-
- "预计完成时间:1-1.5 小时"
|
|
78
|
-
|
|
79
|
-
# ==============================================================================
|
|
80
|
-
# 3. SUCCESS CRITERIA
|
|
81
|
-
# ==============================================================================
|
|
82
|
-
|
|
83
|
-
success_criteria:
|
|
84
|
-
functional:
|
|
85
|
-
- id: SC1
|
|
86
|
-
description: "自动日志注入"
|
|
87
|
-
verification: "调用任意工具,验证 START/END 日志自动出现"
|
|
88
|
-
|
|
89
|
-
- id: SC2
|
|
90
|
-
description: "结构化信息完整"
|
|
91
|
-
verification: "检查日志包含所有必需字段(timestamp, level, sessionId, toolName, duration)"
|
|
92
|
-
|
|
93
|
-
- id: SC3
|
|
94
|
-
description: "文件持久化可选"
|
|
95
|
-
verification: "启用 enableFileLog,验证日志写入文件;禁用时不写入"
|
|
96
|
-
|
|
97
|
-
non_functional:
|
|
98
|
-
- id: NFR1
|
|
99
|
-
description: "性能开销 <5%"
|
|
100
|
-
verification: "对比启用/禁用增强日志的工具执行时间"
|
|
101
|
-
|
|
102
|
-
- id: NFR2
|
|
103
|
-
description: "向后兼容"
|
|
104
|
-
verification: "所有现有测试通过"
|
|
105
|
-
|
|
106
|
-
# ==============================================================================
|
|
107
|
-
# 4. RISKS & MITIGATION
|
|
108
|
-
# ==============================================================================
|
|
109
|
-
|
|
110
|
-
risks:
|
|
111
|
-
- id: R1
|
|
112
|
-
description: "文件写入失败(磁盘满、权限问题)"
|
|
113
|
-
probability: "Low"
|
|
114
|
-
impact: "Low"
|
|
115
|
-
mitigation: "捕获文件写入异常,仅记录 stderr 警告,不中断工具执行"
|
|
116
|
-
|
|
117
|
-
- id: R2
|
|
118
|
-
description: "日志输出影响性能"
|
|
119
|
-
probability: "Medium"
|
|
120
|
-
impact: "Medium"
|
|
121
|
-
mitigation: "异步文件写入,批量缓冲(每 100 条或 5 秒刷新)"
|
|
122
|
-
|
|
123
|
-
# ==============================================================================
|
|
124
|
-
# 5. DELIVERABLES
|
|
125
|
-
# ==============================================================================
|
|
126
|
-
|
|
127
|
-
deliverables:
|
|
128
|
-
code:
|
|
129
|
-
- path: "src/core/logger.ts"
|
|
130
|
-
description: "增强 ConsoleLogger:添加文件写入、批量缓冲"
|
|
131
|
-
type: "enhancement"
|
|
132
|
-
|
|
133
|
-
- path: "src/core/tool-logger.ts"
|
|
134
|
-
description: "工具调用日志包装器(auto-log wrapper)"
|
|
135
|
-
type: "new"
|
|
136
|
-
|
|
137
|
-
- path: "src/tools/index.ts"
|
|
138
|
-
description: "集成 tool-logger 到工具调用流程"
|
|
139
|
-
type: "integration"
|
|
140
|
-
|
|
141
|
-
- path: "src/types.ts"
|
|
142
|
-
description: "新增 ToolLogEntry, LoggerConfig 类型"
|
|
143
|
-
type: "enhancement"
|
|
144
|
-
|
|
145
|
-
tests:
|
|
146
|
-
- path: "tests/unit/logger-enhanced.test.ts"
|
|
147
|
-
description: "增强日志功能测试(文件写入、缓冲、耗时)"
|
|
148
|
-
estimated_tests: 15
|
|
149
|
-
|
|
150
|
-
- path: "tests/unit/tool-logger.test.ts"
|
|
151
|
-
description: "工具调用日志包装器测试"
|
|
152
|
-
estimated_tests: 10
|
|
153
|
-
|
|
154
|
-
docs:
|
|
155
|
-
- path: "docs/observability.md"
|
|
156
|
-
description: "F1 部分:结构化日志配置和使用"
|
|
157
|
-
|
|
158
|
-
# ==============================================================================
|
|
159
|
-
# 6. OPEN QUESTIONS
|
|
160
|
-
# ==============================================================================
|
|
161
|
-
|
|
162
|
-
open_questions:
|
|
163
|
-
- question: "日志缓冲策略?"
|
|
164
|
-
proposed_answer: "100 条或 5 秒,先达到为准"
|
|
165
|
-
status: "proposed"
|
|
166
|
-
|
|
167
|
-
- question: "日志文件最大大小?"
|
|
168
|
-
proposed_answer: "单文件 10MB,超过则警告(不自动轮转)"
|
|
169
|
-
status: "proposed"
|
|
170
|
-
|
|
171
|
-
# ==============================================================================
|
|
172
|
-
# 7. APPROVAL CHECKLIST
|
|
173
|
-
# ==============================================================================
|
|
174
|
-
|
|
175
|
-
approval_checklist:
|
|
176
|
-
- [ ] Goals 清晰且可衡量
|
|
177
|
-
- [ ] Success criteria 可验证
|
|
178
|
-
- [ ] Risks 已识别
|
|
179
|
-
- [ ] Deliverables 完整
|
|
180
|
-
- [ ] Open questions 已解决
|
|
181
|
-
|
|
182
|
-
# ==============================================================================
|
|
183
|
-
# METADATA
|
|
184
|
-
# ==============================================================================
|
|
185
|
-
|
|
186
|
-
metadata:
|
|
187
|
-
created_by: "ClaudeCode"
|
|
188
|
-
created_at: "2025-10-03T02:30:00Z"
|
|
189
|
-
task: "F1 - Structured Logging"
|
|
190
|
-
parent_stage: "F - Observability & Artifacts"
|
|
191
|
-
estimated_effort: "1-1.5 hours"
|
|
192
|
-
priority: "HIGH"
|
|
193
|
-
status: "Ready for Architect"
|