@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.
Files changed (246) hide show
  1. package/README.md +14 -3
  2. package/dist/app/cli/index.d.ts +6 -0
  3. package/dist/app/cli/index.d.ts.map +1 -0
  4. package/dist/app/cli/index.js +6 -0
  5. package/dist/app/cli/index.js.map +1 -0
  6. package/dist/app/index.d.ts +6 -0
  7. package/dist/app/index.d.ts.map +1 -0
  8. package/dist/app/index.js +6 -0
  9. package/dist/app/index.js.map +1 -0
  10. package/dist/app/server/index.d.ts +7 -0
  11. package/dist/app/server/index.d.ts.map +1 -0
  12. package/dist/app/server/index.js +6 -0
  13. package/dist/app/server/index.js.map +1 -0
  14. package/dist/capabilities/assert/index.d.ts +5 -0
  15. package/dist/capabilities/assert/index.d.ts.map +1 -0
  16. package/dist/capabilities/assert/index.js +5 -0
  17. package/dist/capabilities/assert/index.js.map +1 -0
  18. package/dist/capabilities/automator/index.d.ts +6 -0
  19. package/dist/capabilities/automator/index.d.ts.map +1 -0
  20. package/dist/capabilities/automator/index.js +6 -0
  21. package/dist/capabilities/automator/index.js.map +1 -0
  22. package/dist/capabilities/automator/schemas/close.d.ts +5 -0
  23. package/dist/capabilities/automator/schemas/close.d.ts.map +1 -0
  24. package/dist/capabilities/automator/schemas/close.js +11 -0
  25. package/dist/capabilities/automator/schemas/close.js.map +1 -0
  26. package/dist/capabilities/automator/schemas/connect.d.ts +11 -0
  27. package/dist/capabilities/automator/schemas/connect.d.ts.map +1 -0
  28. package/dist/capabilities/automator/schemas/connect.js +19 -0
  29. package/dist/capabilities/automator/schemas/connect.js.map +1 -0
  30. package/dist/capabilities/automator/schemas/disconnect.d.ts +5 -0
  31. package/dist/capabilities/automator/schemas/disconnect.d.ts.map +1 -0
  32. package/dist/capabilities/automator/schemas/disconnect.js +11 -0
  33. package/dist/capabilities/automator/schemas/disconnect.js.map +1 -0
  34. package/dist/capabilities/automator/schemas/index.d.ts +4 -0
  35. package/dist/capabilities/automator/schemas/index.d.ts.map +1 -0
  36. package/dist/capabilities/automator/schemas/index.js +12 -0
  37. package/dist/capabilities/automator/schemas/index.js.map +1 -0
  38. package/dist/capabilities/automator/schemas/launch.d.ts +17 -0
  39. package/dist/capabilities/automator/schemas/launch.d.ts.map +1 -0
  40. package/dist/capabilities/automator/schemas/launch.js +26 -0
  41. package/dist/capabilities/automator/schemas/launch.js.map +1 -0
  42. package/dist/capabilities/element/index.d.ts +5 -0
  43. package/dist/capabilities/element/index.d.ts.map +1 -0
  44. package/dist/capabilities/element/index.js +5 -0
  45. package/dist/capabilities/element/index.js.map +1 -0
  46. package/dist/capabilities/index.d.ts +15 -0
  47. package/dist/capabilities/index.d.ts.map +1 -0
  48. package/dist/capabilities/index.js +14 -0
  49. package/dist/capabilities/index.js.map +1 -0
  50. package/dist/capabilities/miniprogram/index.d.ts +5 -0
  51. package/dist/capabilities/miniprogram/index.d.ts.map +1 -0
  52. package/dist/capabilities/miniprogram/index.js +5 -0
  53. package/dist/capabilities/miniprogram/index.js.map +1 -0
  54. package/dist/capabilities/network/index.d.ts +5 -0
  55. package/dist/capabilities/network/index.d.ts.map +1 -0
  56. package/dist/capabilities/network/index.js +5 -0
  57. package/dist/capabilities/network/index.js.map +1 -0
  58. package/dist/capabilities/page/index.d.ts +5 -0
  59. package/dist/capabilities/page/index.d.ts.map +1 -0
  60. package/dist/capabilities/page/index.js +5 -0
  61. package/dist/capabilities/page/index.js.map +1 -0
  62. package/dist/capabilities/record/index.d.ts +5 -0
  63. package/dist/capabilities/record/index.d.ts.map +1 -0
  64. package/dist/capabilities/record/index.js +5 -0
  65. package/dist/capabilities/record/index.js.map +1 -0
  66. package/dist/capabilities/schema-registry.d.ts +4 -0
  67. package/dist/capabilities/schema-registry.d.ts.map +1 -0
  68. package/dist/capabilities/schema-registry.js +18 -0
  69. package/dist/capabilities/schema-registry.js.map +1 -0
  70. package/dist/capabilities/schema-types.d.ts +22 -0
  71. package/dist/capabilities/schema-types.d.ts.map +1 -0
  72. package/dist/capabilities/schema-types.js +2 -0
  73. package/dist/capabilities/schema-types.js.map +1 -0
  74. package/dist/capabilities/snapshot/index.d.ts +5 -0
  75. package/dist/capabilities/snapshot/index.d.ts.map +1 -0
  76. package/dist/capabilities/snapshot/index.js +5 -0
  77. package/dist/capabilities/snapshot/index.js.map +1 -0
  78. package/dist/config/loader.js +1 -1
  79. package/dist/config/loader.js.map +1 -1
  80. package/dist/core/element-ref.d.ts +1 -43
  81. package/dist/core/element-ref.d.ts.map +1 -1
  82. package/dist/core/element-ref.js +1 -212
  83. package/dist/core/element-ref.js.map +1 -1
  84. package/dist/core/logger.d.ts +1 -54
  85. package/dist/core/logger.d.ts.map +1 -1
  86. package/dist/core/logger.js +1 -377
  87. package/dist/core/logger.js.map +1 -1
  88. package/dist/core/output.d.ts +1 -20
  89. package/dist/core/output.d.ts.map +1 -1
  90. package/dist/core/output.js +1 -55
  91. package/dist/core/output.js.map +1 -1
  92. package/dist/core/report-generator.d.ts +1 -23
  93. package/dist/core/report-generator.d.ts.map +1 -1
  94. package/dist/core/report-generator.js +1 -211
  95. package/dist/core/report-generator.js.map +1 -1
  96. package/dist/core/session.d.ts +2 -82
  97. package/dist/core/session.d.ts.map +1 -1
  98. package/dist/core/session.js +2 -305
  99. package/dist/core/session.js.map +1 -1
  100. package/dist/core/timeout.d.ts +1 -48
  101. package/dist/core/timeout.d.ts.map +1 -1
  102. package/dist/core/timeout.js +1 -66
  103. package/dist/core/timeout.js.map +1 -1
  104. package/dist/core/tool-logger.d.ts +1 -82
  105. package/dist/core/tool-logger.d.ts.map +1 -1
  106. package/dist/core/tool-logger.js +1 -452
  107. package/dist/core/tool-logger.js.map +1 -1
  108. package/dist/core/validation.d.ts +1 -38
  109. package/dist/core/validation.d.ts.map +1 -1
  110. package/dist/core/validation.js +1 -92
  111. package/dist/core/validation.js.map +1 -1
  112. package/dist/runtime/element/element-ref.d.ts +44 -0
  113. package/dist/runtime/element/element-ref.d.ts.map +1 -0
  114. package/dist/runtime/element/element-ref.js +214 -0
  115. package/dist/runtime/element/element-ref.js.map +1 -0
  116. package/dist/runtime/element/index.d.ts +2 -0
  117. package/dist/runtime/element/index.d.ts.map +1 -0
  118. package/dist/runtime/element/index.js +2 -0
  119. package/dist/runtime/element/index.js.map +1 -0
  120. package/dist/runtime/index.d.ts +10 -0
  121. package/dist/runtime/index.d.ts.map +1 -0
  122. package/dist/runtime/index.js +10 -0
  123. package/dist/runtime/index.js.map +1 -0
  124. package/dist/runtime/logging/index.d.ts +3 -0
  125. package/dist/runtime/logging/index.d.ts.map +1 -0
  126. package/dist/runtime/logging/index.js +3 -0
  127. package/dist/runtime/logging/index.js.map +1 -0
  128. package/dist/runtime/logging/logger.d.ts +55 -0
  129. package/dist/runtime/logging/logger.d.ts.map +1 -0
  130. package/dist/runtime/logging/logger.js +379 -0
  131. package/dist/runtime/logging/logger.js.map +1 -0
  132. package/dist/runtime/logging/tool-logger.d.ts +83 -0
  133. package/dist/runtime/logging/tool-logger.d.ts.map +1 -0
  134. package/dist/runtime/logging/tool-logger.js +454 -0
  135. package/dist/runtime/logging/tool-logger.js.map +1 -0
  136. package/dist/runtime/outputs/index.d.ts +3 -0
  137. package/dist/runtime/outputs/index.d.ts.map +1 -0
  138. package/dist/runtime/outputs/index.js +3 -0
  139. package/dist/runtime/outputs/index.js.map +1 -0
  140. package/dist/runtime/outputs/output-manager.d.ts +12 -0
  141. package/dist/runtime/outputs/output-manager.d.ts.map +1 -0
  142. package/dist/runtime/outputs/output-manager.js +39 -0
  143. package/dist/runtime/outputs/output-manager.js.map +1 -0
  144. package/dist/runtime/outputs/report-generator.d.ts +5 -0
  145. package/dist/runtime/outputs/report-generator.d.ts.map +1 -0
  146. package/dist/runtime/outputs/report-generator.js +175 -0
  147. package/dist/runtime/outputs/report-generator.js.map +1 -0
  148. package/dist/runtime/session/index.d.ts +3 -0
  149. package/dist/runtime/session/index.d.ts.map +1 -0
  150. package/dist/runtime/session/index.js +3 -0
  151. package/dist/runtime/session/index.js.map +1 -0
  152. package/dist/runtime/session/store.d.ts +28 -0
  153. package/dist/runtime/session/store.d.ts.map +1 -0
  154. package/dist/runtime/session/store.js +154 -0
  155. package/dist/runtime/session/store.js.map +1 -0
  156. package/dist/runtime/session/utils/cleanup.d.ts +3 -0
  157. package/dist/runtime/session/utils/cleanup.d.ts.map +1 -0
  158. package/dist/runtime/session/utils/cleanup.js +78 -0
  159. package/dist/runtime/session/utils/cleanup.js.map +1 -0
  160. package/dist/runtime/timeout/index.d.ts +2 -0
  161. package/dist/runtime/timeout/index.d.ts.map +1 -0
  162. package/dist/runtime/timeout/index.js +2 -0
  163. package/dist/runtime/timeout/index.js.map +1 -0
  164. package/dist/runtime/timeout/timeout.d.ts +49 -0
  165. package/dist/runtime/timeout/timeout.d.ts.map +1 -0
  166. package/dist/runtime/timeout/timeout.js +67 -0
  167. package/dist/runtime/timeout/timeout.js.map +1 -0
  168. package/dist/runtime/validation/index.d.ts +2 -0
  169. package/dist/runtime/validation/index.d.ts.map +1 -0
  170. package/dist/runtime/validation/index.js +2 -0
  171. package/dist/runtime/validation/index.js.map +1 -0
  172. package/dist/runtime/validation/validation.d.ts +39 -0
  173. package/dist/runtime/validation/validation.d.ts.map +1 -0
  174. package/dist/runtime/validation/validation.js +93 -0
  175. package/dist/runtime/validation/validation.js.map +1 -0
  176. package/dist/schemas/automator/miniprogram_close.json +12 -0
  177. package/dist/schemas/automator/miniprogram_connect.json +19 -0
  178. package/dist/schemas/automator/miniprogram_disconnect.json +12 -0
  179. package/dist/schemas/automator/miniprogram_launch.json +30 -0
  180. package/dist/server.js +1 -1
  181. package/dist/server.js.map +1 -1
  182. package/dist/tools/index.js +1 -1
  183. package/dist/tools/index.js.map +1 -1
  184. package/dist/tools/miniprogram.d.ts +0 -1
  185. package/dist/tools/miniprogram.d.ts.map +1 -1
  186. package/dist/tools/miniprogram.js +17 -29
  187. package/dist/tools/miniprogram.js.map +1 -1
  188. package/dist/tools/page.js +2 -2
  189. package/dist/tools/page.js.map +1 -1
  190. package/docs/directory-structure-and-code-style-best-practices.md +91 -0
  191. package/docs/migration/README.md +34 -0
  192. package/docs/migration/TC-ALIGN-01-notes.md +35 -0
  193. package/docs/migration/runtime-skeleton.md +50 -0
  194. package/docs/migration/tool-schema-strategy.md +75 -0
  195. package/docs//345/256/214/346/225/264/345/256/236/347/216/260/346/226/271/346/241/210.md +14 -14
  196. package/docs//347/254/254/344/270/200/347/211/210/346/234/254/346/226/271/346/241/210.md +7 -7
  197. package/package.json +4 -2
  198. package/docs/SIMPLE_USAGE.md +0 -210
  199. package/docs/architecture.E-Docs.md +0 -1359
  200. package/docs/architecture.F1.md +0 -720
  201. package/docs/architecture.F2.md +0 -871
  202. package/docs/architecture.F3.md +0 -905
  203. package/docs/architecture.md +0 -90
  204. package/docs/charter.A1.align.yaml +0 -170
  205. package/docs/charter.A2.align.yaml +0 -199
  206. package/docs/charter.A3.align.yaml +0 -242
  207. package/docs/charter.A4.align.yaml +0 -227
  208. package/docs/charter.B1.align.yaml +0 -179
  209. package/docs/charter.B2.align.yaml +0 -200
  210. package/docs/charter.B3.align.yaml +0 -200
  211. package/docs/charter.B4.align.yaml +0 -188
  212. package/docs/charter.C1.align.yaml +0 -190
  213. package/docs/charter.C2.align.yaml +0 -202
  214. package/docs/charter.C3.align.yaml +0 -211
  215. package/docs/charter.C4.align.yaml +0 -263
  216. package/docs/charter.C5.align.yaml +0 -220
  217. package/docs/charter.D1.align.yaml +0 -190
  218. package/docs/charter.D2.align.yaml +0 -234
  219. package/docs/charter.D3.align.yaml +0 -206
  220. package/docs/charter.E-Docs.align.yaml +0 -294
  221. package/docs/charter.F1.align.yaml +0 -193
  222. package/docs/charter.F2.align.yaml +0 -248
  223. package/docs/charter.F3.align.yaml +0 -287
  224. package/docs/charter.G.align.yaml +0 -174
  225. package/docs/charter.align.yaml +0 -111
  226. package/docs/maintenance.md +0 -682
  227. package/docs/playwright-mcp/350/260/203/347/240/224.md +0 -53
  228. package/docs/setup-guide.md +0 -775
  229. package/docs/tasks.A1.atomize.md +0 -296
  230. package/docs/tasks.A2.atomize.md +0 -408
  231. package/docs/tasks.A3.atomize.md +0 -564
  232. package/docs/tasks.A4.atomize.md +0 -496
  233. package/docs/tasks.B1.atomize.md +0 -352
  234. package/docs/tasks.B2.atomize.md +0 -561
  235. package/docs/tasks.B3.atomize.md +0 -508
  236. package/docs/tasks.B4.atomize.md +0 -504
  237. package/docs/tasks.C1.atomize.md +0 -540
  238. package/docs/tasks.C2.atomize.md +0 -665
  239. package/docs/tasks.C3.atomize.md +0 -745
  240. package/docs/tasks.C4.atomize.md +0 -908
  241. package/docs/tasks.C5.atomize.md +0 -755
  242. package/docs/tasks.D1.atomize.md +0 -547
  243. package/docs/tasks.D2.atomize.md +0 -619
  244. package/docs/tasks.D3.atomize.md +0 -790
  245. package/docs/tasks.E-Docs.atomize.md +0 -1204
  246. package/docs/tasks.atomize.md +0 -189
@@ -1,227 +0,0 @@
1
- # Charter: A4 - 搭建 lint / format / commit hooks
2
- # Task ID: TASK-2025-001-A4
3
- # Stage: Align (对齐阶段)
4
- # Status: RETROSPECTIVE (追溯补齐)
5
- # Created: 2025-10-02 (追溯)
6
-
7
- ---
8
-
9
- ## Goal (目标)
10
-
11
- 配置代码质量工具(ESLint 和 Prettier)以及可选的 Git 提交钩子(Husky),确保代码风格一致性和基本代码质量标准,为团队协作和代码审查提供自动化保障。
12
-
13
- ## Background (背景)
14
-
15
- 代码质量和风格一致性对于团队协作至关重要。A4 任务作为"可选"任务,旨在:
16
-
17
- 1. 配置 ESLint 进行代码静态检查(类型安全、潜在错误)
18
- 2. 配置 Prettier 进行代码格式化(风格统一)
19
- 3. 安装 Husky 支持 Git Hooks(为未来自动化检查预留)
20
- 4. (可选)配置 pre-commit 钩子自动运行检查
21
-
22
- **注意**:任务定义明确标注"可选",因此不强制要求所有功能都完全实现。
23
-
24
- ## Scope (范围)
25
-
26
- ### In Scope (范围内)
27
-
28
- - ✅ 配置 ESLint
29
- - `.eslintrc.cjs` - ESLint 配置文件
30
- - @typescript-eslint/parser - TypeScript 解析器
31
- - @typescript-eslint/eslint-plugin - TypeScript 规则插件
32
- - eslint-config-prettier - 禁用与 Prettier 冲突的规则
33
- - 自定义规则(no-explicit-any, no-unused-vars 等)
34
- - package.json scripts.lint - 运行 linter
35
-
36
- - ✅ 配置 Prettier
37
- - `.prettierrc` - Prettier 配置文件
38
- - `.prettierignore` - Prettier 忽略规则
39
- - 代码风格规则(semi, singleQuote, printWidth 等)
40
- - package.json scripts.format - 格式化代码
41
- - package.json scripts.format:check - 检查格式
42
-
43
- - ✅ 安装 Husky
44
- - husky 依赖包
45
- - .husky/ 目录
46
- - package.json scripts.prepare - 自动安装 hooks
47
-
48
- - ⚠️ 配置 Git Hooks(可选,部分实现)
49
- - Husky 已安装
50
- - 但未配置自定义 pre-commit hook
51
-
52
- ### Out of Scope (范围外)
53
-
54
- - ❌ 强制代码风格(通过 CI 阻止提交)
55
- - ❌ 自动修复所有 lint 错误
56
- - ❌ 复杂的 lint 规则定制
57
- - ❌ Commitlint(提交消息检查)
58
- - ❌ 其他 Git Hooks(pre-push, commit-msg 等)
59
-
60
- ## Constraints (约束条件)
61
-
62
- ### Technical Constraints (技术约束)
63
-
64
- - **ESLint 版本**: 8.57.0
65
- - 理由: 稳定版本,TypeScript 支持良好
66
- - 验证: package.json devDependencies
67
-
68
- - **Prettier 版本**: 3.3.2
69
- - 理由: 最新稳定版
70
- - 验证: package.json devDependencies
71
-
72
- - **TypeScript 兼容性**: 必须支持
73
- - 理由: 项目使用 TypeScript
74
- - 验证: @typescript-eslint/parser 和 plugin
75
-
76
- - **Prettier 与 ESLint 集成**: 避免冲突
77
- - 理由: 两者都控制代码风格可能冲突
78
- - 验证: eslint-config-prettier 禁用冲突规则
79
-
80
- - **Husky 版本**: 9.0.11
81
- - 理由: 支持现代 Git Hooks 配置
82
- - 验证: package.json devDependencies
83
-
84
- ### Business Constraints (业务约束)
85
-
86
- - 配置必须简单易懂,便于团队成员调整
87
- - Lint 规则不应过于严格,避免阻碍开发
88
- - Format 规则应符合主流 TypeScript 风格
89
- - 工具必须可选运行,不强制自动化(hook 可选)
90
-
91
- ## Success Criteria (完成标准 / DoD)
92
-
93
- ### Deliverables (交付物)
94
-
95
- 1. ✅ **ESLint 配置 (.eslintrc.cjs)**
96
- - parser: '@typescript-eslint/parser'
97
- - extends: eslint:recommended + @typescript-eslint/recommended + prettier
98
- - plugins: ['@typescript-eslint']
99
- - parserOptions: project tsconfig.json, ES2022, module
100
- - env: node, es2022, jest
101
- - rules: 自定义规则(no-explicit-any: warn, no-unused-vars: error 等)
102
- - ignorePatterns: dist, node_modules
103
-
104
- 2. ✅ **Prettier 配置 (.prettierrc + .prettierignore)**
105
- - .prettierrc:
106
- - semi: false
107
- - singleQuote: true
108
- - printWidth: 100
109
- - trailingComma: 'es5'
110
- - tabWidth: 2
111
- - arrowParens: 'always'
112
- - endOfLine: 'lf'
113
- - .prettierignore:
114
- - node_modules, dist, coverage, *.log, .DS_Store, .llm, docs
115
-
116
- 3. ✅ **Package.json 配置**
117
- - devDependencies: eslint, @typescript-eslint/*, prettier, eslint-config-prettier, husky
118
- - scripts.lint: "eslint . --ext .ts"
119
- - scripts.format: "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\""
120
- - scripts.format:check: "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\""
121
- - scripts.prepare: "husky install"
122
-
123
- 4. ✅ **Husky 安装**
124
- - .husky/ 目录存在
125
- - .husky/_/ 包含 husky 模板文件
126
- - prepare 脚本可运行
127
-
128
- 5. ⚠️ **Git Hooks(可选,未完全实现)**
129
- - Husky 已安装
130
- - 但未配置自定义 pre-commit hook
131
- - 开发者可手动运行 lint/format
132
-
133
- 6. ✅ **可执行性验证**
134
- - `pnpm lint` 成功运行,检测代码问题
135
- - `pnpm format:check` 成功运行,检测格式问题
136
- - `pnpm format` 可格式化代码
137
-
138
- ### Quality Standards (质量标准)
139
-
140
- - **Lint 规则**: 平衡严格性和开发体验
141
- - **Format 规则**: 符合主流 TypeScript 风格
142
- - **集成性**: ESLint 和 Prettier 无冲突
143
- - **可选性**: 工具可手动运行,不强制自动化
144
-
145
- ## Open Questions (开放问题)
146
-
147
- 以下问题在实施过程中已经决议:
148
-
149
- 1. **Q**: ESLint 还是 TSLint?
150
- - **决议**: ESLint
151
- - **理由**: TSLint 已弃用,ESLint 通过 @typescript-eslint 支持 TypeScript
152
- - **来源**: 官方推荐
153
-
154
- 2. **Q**: 如何避免 ESLint 和 Prettier 规则冲突?
155
- - **决议**: 使用 eslint-config-prettier
156
- - **理由**: 自动禁用 ESLint 中与 Prettier 冲突的格式规则
157
- - **来源**: 最佳实践
158
-
159
- 3. **Q**: Prettier 代码风格选择?
160
- - **决议**: semi: false, singleQuote: true, printWidth: 100
161
- - **理由**: 符合现代 TypeScript/JavaScript 主流风格
162
- - **来源**: 社区标准
163
-
164
- 4. **Q**: 是否启用严格的 lint 规则?
165
- - **决议**: 部分严格(no-explicit-any: warn, no-unused-vars: error)
166
- - **理由**: 平衡代码质量和开发体验,any 警告不阻止开发
167
- - **来源**: 渐进式类型安全
168
-
169
- 5. **Q**: 是否配置 pre-commit hook?
170
- - **决议**: 安装 Husky 但未配置自定义 hook
171
- - **理由**: 任务标记"可选",工具可手动运行
172
- - **来源**: 任务定义 A4: "可选"
173
-
174
- 6. **Q**: pre-commit hook 应该运行什么?
175
- - **决议**: 未配置(可选)
176
- - **可选方案**: lint-staged 运行 lint + format 仅对暂存文件
177
- - **来源**: 最佳实践(但未实现)
178
-
179
- 7. **Q**: 是否格式化文档文件(docs/)?
180
- - **决议**: 排除(.prettierignore 包含 docs)
181
- - **理由**: 文档可能包含特殊格式,避免破坏
182
- - **来源**: 项目特性
183
-
184
- ## Risks (风险)
185
-
186
- ### Technical Risks (技术风险)
187
-
188
- - ⚠️ **ESLint 规则过于严格导致开发受阻**
189
- - 影响: 开发者频繁遇到 lint 错误
190
- - 缓解: no-explicit-any 设为 warn(警告)而非 error
191
-
192
- - ⚠️ **Prettier 和 ESLint 规则冲突**
193
- - 影响: 格式化后 lint 报错,或反之
194
- - 缓解: 使用 eslint-config-prettier 禁用冲突规则
195
-
196
- - ⚠️ **Husky hooks 在某些环境不工作**
197
- - 影响: Windows/特殊 Git 环境可能 hooks 失效
198
- - 缓解: 未配置强制 hooks,工具可手动运行
199
-
200
- - ⚠️ **未配置 pre-commit hook 可能导致代码质量下降**
201
- - 影响: 开发者可能忘记运行 lint/format
202
- - 缓解: 可通过 CI/CD 补充检查(Stage H)
203
-
204
- ### Process Risks (流程风险)
205
-
206
- - ⚠️ **追溯补齐文档**
207
- - 影响: 本文档为追溯性创建,非正常 6A 流程
208
- - 缓解: 明确标注 RETROSPECTIVE,等待用户批准
209
-
210
- ## Dependencies (依赖)
211
-
212
- - **前置任务**:
213
- - A3(建立 TypeScript 工程)- 依赖 TypeScript 配置和项目结构
214
-
215
- - **后续任务**:
216
- - B1-B5(核心框架搭建)- 代码将遵循 lint/format 规则
217
- - H(CI/CD)- 可在 CI 中运行 lint/format 检查
218
-
219
- ## Approval (批准)
220
-
221
- - **Status**: ⏳ 等待用户批准追溯补齐文档
222
- - **Technical Implementation**: ✅ 大部分完成(ESLint + Prettier 完整,Husky 安装,hooks 未配置)
223
- - **Process Compliance**: ❌ 流程违规(跳过 Align/Approve),通过追溯补齐修正
224
-
225
- ---
226
-
227
- **注**: 本文档为追溯性创建,用于补齐 A4 任务的流程文档。技术实现大部分完成(lint ✓, format ✓, husky 安装 ✓),commit hooks 未配置(任务标记"可选"),现等待用户批准追溯补齐的合理性。
@@ -1,179 +0,0 @@
1
- # Charter: [B1] MCP Server 骨架
2
-
3
- task_id: B1
4
- task_name: MCP Server 骨架实现
5
- stage: B
6
- phase: Align (Retrospective)
7
- created_at: "2025-10-02"
8
- status: COMPLETED
9
- estimated_hours: 2-3
10
- actual_hours: 2
11
-
12
- ## Goal (目标)
13
-
14
- 实现可运行的 MCP Server 骨架,支持 stdio transport 连接,能够启动并响应基本的 MCP 协议请求。
15
-
16
- **核心交付物**:
17
- - `src/server.ts` - MCP Server 入口文件
18
- - `startServer(config)` 函数
19
- - ListToolsRequestSchema 处理器
20
- - 优雅关闭机制
21
-
22
- ## Non-Goals (非目标)
23
-
24
- - ❌ 不实现具体工具(留给 C1-C5)
25
- - ❌ 不实现配置文件解析(留给 E2)
26
- - ❌ 不实现 CLI 入口(留给 E3)
27
- - ❌ 不实现 SessionStore 内部逻辑(属于 B2)
28
-
29
- ## Scope (范围)
30
-
31
- ### In Scope (包含)
32
-
33
- 1. **Server 实例化**
34
- - ✅ 使用 `@modelcontextprotocol/sdk` 的 Server 类
35
- - ✅ 设置 name 和 version
36
- - ✅ 配置 capabilities: `{ tools: {} }`
37
-
38
- 2. **Transport 配置**
39
- - ✅ 使用 `StdioServerTransport`
40
- - ✅ 调用 `server.connect(transport)`
41
- - ✅ 输出启动日志到 stderr
42
-
43
- 3. **工具注册集成**
44
- - ✅ 调用 `registerTools(server, context)`
45
- - ✅ 传递 SessionStore 的 getSession/deleteSession 回调
46
- - ✅ 支持 capabilities 参数
47
-
48
- 4. **ListToolsRequestSchema 处理**
49
- - ✅ 返回 registerTools 注册的工具列表
50
- - ✅ 符合 MCP 协议规范
51
-
52
- 5. **优雅关闭**
53
- - ✅ 监听 SIGINT 和 SIGTERM
54
- - ✅ 调用 sessionStore.dispose()
55
- - ✅ 输出关闭日志
56
-
57
- ### Out of Scope (不包含)
58
-
59
- - ❌ SessionStore 内部实现
60
- - ❌ 具体工具 handler 逻辑
61
- - ❌ 配置文件解析
62
- - ❌ CLI 参数处理
63
- - ❌ 错误监控和重试
64
-
65
- ## Constraints (约束)
66
-
67
- ### Technical Constraints (技术约束)
68
-
69
- 1. **MCP 协议兼容**
70
- - 必须使用官方 SDK (`@modelcontextprotocol/sdk`)
71
- - 遵循 stdio transport 规范
72
- - 正确处理 JSON-RPC 消息
73
-
74
- 2. **TypeScript 规范**
75
- - ESNext + ESM 模式
76
- - 导入使用 `.js` 后缀
77
- - 严格类型检查
78
-
79
- 3. **日志输出**
80
- - 使用 `console.error` 避免干扰 stdio
81
- - 不输出到 stdout(被 MCP 协议占用)
82
-
83
- 4. **依赖注入**
84
- - SessionStore 作为外部依赖
85
- - registerTools 通过参数传入
86
-
87
- ### Business Constraints (业务约束)
88
-
89
- 1. **启动时间**: <1 秒
90
- 2. **内存占用**: 启动时 <50MB
91
- 3. **兼容性**: 支持 Node.js 18+
92
-
93
- ## Success Criteria (成功标准)
94
-
95
- ### Functional Criteria (功能标准)
96
-
97
- - ✅ 运行 `node dist/server.js` 成功启动
98
- - ✅ MCP 客户端可连接
99
- - ✅ `list_tools` 请求返回工具列表
100
- - ✅ CTRL+C 触发优雅关闭
101
- - ✅ sessionStore.dispose() 被调用
102
-
103
- ### Quality Criteria (质量标准)
104
-
105
- - ✅ TypeScript 编译 0 错误
106
- - ✅ 代码行数 <100 行(实际 64 行)
107
- - ✅ 无 ESLint 错误
108
- - ✅ JSDoc 注释完整
109
-
110
- ### Documentation Criteria (文档标准)
111
-
112
- - ✅ 函数签名有 JSDoc
113
- - ✅ README 更新启动说明
114
- - ⏳ charter.B1.align.yaml (本文档)
115
- - ⏳ tasks.B1.atomize.md (任务卡)
116
-
117
- ## Definition of Done (完成标准)
118
-
119
- **代码**:
120
- - ✅ `src/server.ts` 实现完成 (64 lines)
121
- - ✅ TypeScript 编译通过
122
- - ✅ 集成 SessionStore 和 registerTools
123
-
124
- **测试**:
125
- - ✅ 手动测试:启动 Server 并连接
126
- - ✅ 集成测试:通过其他工具测试间接验证
127
-
128
- **文档**:
129
- - ⏳ charter.B1.align.yaml (追溯)
130
- - ⏳ tasks.B1.atomize.md (追溯)
131
- - ⏳ session_log (追溯)
132
-
133
- **Git**:
134
- - ✅ 已提交(随 A2-B1-B2 修复提交)
135
-
136
- ## Dependencies (依赖)
137
-
138
- **前置任务**:
139
- - ✅ A3: 仓库结构初始化
140
- - ✅ `@modelcontextprotocol/sdk` 已安装
141
-
142
- **后续任务**:
143
- - B1 → B2 (Server 需要 SessionStore)
144
- - B1 → C5 (registerTools 函数)
145
-
146
- ## Risks (风险)
147
-
148
- ### Technical Risks (技术风险)
149
-
150
- 1. **MCP SDK 升级** - 🟢 低风险
151
- - 影响:API 变更可能破坏兼容
152
- - 缓解:锁定 SDK 版本
153
-
154
- 2. **stdio 干扰** - 🟢 已缓解
155
- - 风险:日志输出到 stdout 干扰协议
156
- - 缓解:所有日志使用 console.error
157
-
158
- ### Business Risks (业务风险)
159
-
160
- 1. **启动失败** - 🟢 已缓解
161
- - 影响:Server 无法启动导致服务不可用
162
- - 缓解:错误日志清晰,便于排查
163
-
164
- ## Open Questions (未决问题)
165
-
166
- - ❓ 是否需要支持多个 transport(HTTP/WebSocket)?(当前仅 stdio)
167
- - ❓ 是否需要健康检查端点?(当前无)
168
-
169
- ## References (参考资料)
170
-
171
- - `docs/完整实现方案.md` - Server 架构设计
172
- - `docs/第一版本方案.md` - MCP 集成方案
173
- - `@modelcontextprotocol/sdk` 文档
174
-
175
- ---
176
-
177
- **Approval**: ✅ RETROSPECTIVE APPROVED
178
- **Implementation**: ✅ COMPLETED
179
- **Documentation**: ⏳ IN PROGRESS
@@ -1,200 +0,0 @@
1
- # Charter: [B2] SessionStore 实现
2
-
3
- task_id: B2
4
- task_name: SessionStore 会话管理器
5
- stage: B
6
- phase: Align (Retrospective)
7
- created_at: "2025-10-02"
8
- status: COMPLETED
9
- estimated_hours: 2-3
10
- actual_hours: 3
11
-
12
- ## Goal (目标)
13
-
14
- 实现会话隔离的 SessionStore,管理多个 MCP 会话的生命周期、资源清理和超时回收。
15
-
16
- **核心交付物**:
17
- - `src/core/session.ts` (~200 lines)
18
- - `tests/unit/session.test.ts` (93 tests)
19
- - SessionStore 类:get/set/delete/dispose/getOrCreate/updateActivity
20
- - 自动超时清理机制
21
-
22
- ## Non-Goals (非目标)
23
-
24
- - ❌ 不实现持久化存储(仅内存)
25
- - ❌ 不实现会话共享(跨进程)
26
- - ❌ 不实现会话迁移
27
- - ❌ 不实现分布式锁
28
-
29
- ## Scope (范围)
30
-
31
- ### In Scope (包含)
32
-
33
- 1. **SessionState 接口**
34
- - ✅ sessionId: string
35
- - ✅ miniProgram: MiniProgram | null
36
- - ✅ ideProcess: ChildProcess | null
37
- - ✅ elementCache: Map<string, Element>
38
- - ✅ createdAt, lastActivity: Date
39
- - ✅ outputDir: string
40
-
41
- 2. **SessionStore 类**
42
- - ✅ get(sessionId): SessionState | undefined
43
- - ✅ set(sessionId, state): void
44
- - ✅ delete(sessionId): void
45
- - ✅ dispose(): Promise<void>
46
- - ✅ getOrCreate(sessionId): SessionState
47
- - ✅ updateActivity(sessionId): void
48
-
49
- 3. **超时清理**
50
- - ✅ 定时检查会话活动时间
51
- - ✅ 超时会话自动清理
52
- - ✅ 调用 miniProgram.disconnect() 和 ideProcess.kill()
53
- - ✅ 清理元素缓存
54
-
55
- 4. **配置选项**
56
- - ✅ sessionTimeout: number (默认 30 分钟)
57
- - ✅ outputDir: string (默认 .mcp-artifacts)
58
- - ✅ cleanupInterval: number (默认 60 秒)
59
-
60
- 5. **资源清理**
61
- - ✅ disconnect miniProgram
62
- - ✅ kill ideProcess
63
- - ✅ clear elementCache
64
- - ✅ 日志输出清理结果
65
-
66
- ### Out of Scope (不包含)
67
-
68
- - ❌ 持久化到磁盘/数据库
69
- - ❌ 会话状态序列化
70
- - ❌ 跨进程会话共享
71
- - ❌ 会话快照和恢复
72
-
73
- ## Constraints (约束)
74
-
75
- ### Technical Constraints (技术约束)
76
-
77
- 1. **内存安全**
78
- - 必须防止内存泄漏
79
- - 超时会话必须被清理
80
- - 资源释放必须彻底
81
-
82
- 2. **并发安全**
83
- - 支持多会话并发访问
84
- - Map 操作原子性
85
- - 避免竞态条件
86
-
87
- 3. **TypeScript 规范**
88
- - 完整类型定义
89
- - 泛型约束
90
- - 严格模式
91
-
92
- 4. **测试覆盖**
93
- - 单元测试覆盖率 >95%
94
- - 93 个测试用例
95
- - 覆盖所有边界条件
96
-
97
- ### Business Constraints (业务约束)
98
-
99
- 1. **会话超时**: 默认 30 分钟
100
- 2. **清理周期**: 每 60 秒检查一次
101
- 3. **资源限制**: 支持最多 100 个并发会话
102
- 4. **性能要求**: 会话操作 <10ms
103
-
104
- ## Success Criteria (成功标准)
105
-
106
- ### Functional Criteria (功能标准)
107
-
108
- - ✅ get/set/delete 操作正常
109
- - ✅ getOrCreate 自动创建会话
110
- - ✅ updateActivity 更新时间戳
111
- - ✅ 超时会话自动清理
112
- - ✅ dispose 清理所有会话
113
- - ✅ 资源释放完整(miniProgram/ideProcess/cache)
114
-
115
- ### Quality Criteria (质量标准)
116
-
117
- - ✅ TypeScript 编译 0 错误
118
- - ✅ 93 个测试用例全部通过
119
- - ✅ 代码覆盖率 >95%
120
- - ✅ 无 ESLint 错误
121
- - ✅ JSDoc 注释完整
122
-
123
- ### Documentation Criteria (文档标准)
124
-
125
- - ✅ SessionState 接口文档
126
- - ✅ SessionStore API 文档
127
- - ✅ 配置选项说明
128
- - ⏳ charter.B2.align.yaml (本文档)
129
- - ⏳ tasks.B2.atomize.md (任务卡)
130
-
131
- ## Definition of Done (完成标准)
132
-
133
- **代码**:
134
- - ✅ `src/core/session.ts` 实现完成 (~200 lines)
135
- - ✅ TypeScript 编译通过
136
- - ✅ 所有公共方法实现
137
-
138
- **测试**:
139
- - ✅ `tests/unit/session.test.ts` (93 tests)
140
- - ✅ 覆盖所有方法
141
- - ✅ 测试超时清理逻辑
142
- - ✅ 测试资源释放
143
-
144
- **文档**:
145
- - ⏳ charter.B2.align.yaml (追溯)
146
- - ⏳ tasks.B2.atomize.md (追溯)
147
- - ⏳ session_log (追溯)
148
-
149
- **Git**:
150
- - ✅ 已提交(随 A2-B1-B2 修复提交)
151
-
152
- ## Dependencies (依赖)
153
-
154
- **前置任务**:
155
- - ✅ A3: 仓库结构初始化
156
- - ✅ TypeScript 配置完成
157
-
158
- **后续任务**:
159
- - B2 → B1 (Server 依赖 SessionStore)
160
- - B2 → C1-C4 (工具需要会话管理)
161
-
162
- ## Risks (风险)
163
-
164
- ### Technical Risks (技术风险)
165
-
166
- 1. **内存泄漏** - 🟢 已缓解
167
- - 影响:长时间运行内存溢出
168
- - 缓解:定时清理 + dispose 机制
169
-
170
- 2. **资源泄漏** - 🟢 已缓解
171
- - 影响:进程/连接未关闭
172
- - 缓解:完整的清理流程 + 测试验证
173
-
174
- 3. **并发问题** - 🟢 低风险
175
- - 影响:竞态条件导致状态不一致
176
- - 缓解:Map 原子操作,简单锁机制
177
-
178
- ### Business Risks (业务风险)
179
-
180
- 1. **超时配置不当** - 🟡 中风险
181
- - 影响:会话过早清理或内存占用过高
182
- - 缓解:可配置超时时间,默认值经过测试
183
-
184
- ## Open Questions (未决问题)
185
-
186
- - ✅ 会话超时时间设置为多少合适?(已确定:30 分钟)
187
- - ✅ 是否需要会话持久化?(否,仅内存存储)
188
- - ❓ 是否需要支持会话优先级?(当前无)
189
-
190
- ## References (参考资料)
191
-
192
- - `docs/完整实现方案.md` - 会话管理架构
193
- - `src/types.ts` - SessionState 接口定义
194
- - Node.js ChildProcess API 文档
195
-
196
- ---
197
-
198
- **Approval**: ✅ RETROSPECTIVE APPROVED
199
- **Implementation**: ✅ COMPLETED
200
- **Documentation**: ⏳ IN PROGRESS