@leocm/flowcraft 0.0.0-stage → 2.1.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 (269) hide show
  1. package/README.md +855 -3
  2. package/bin/cli.js +108 -0
  3. package/flowcraft.yaml +30 -0
  4. package/install.sh +24 -0
  5. package/lib/args.js +38 -0
  6. package/lib/config.js +20 -0
  7. package/lib/copy.js +131 -0
  8. package/lib/fix.js +110 -0
  9. package/lib/fsutil.js +104 -0
  10. package/lib/global.js +229 -0
  11. package/lib/init.js +43 -0
  12. package/lib/runtime.js +84 -0
  13. package/lib/version.js +55 -0
  14. package/lib/wizard.js +125 -0
  15. package/package.json +31 -4
  16. package/presets/backend.yaml +20 -0
  17. package/presets/default.yaml +15 -0
  18. package/presets/frontend.yaml +20 -0
  19. package/presets/quick-fix.yaml +15 -0
  20. package/setup/.claude/commands/P0.5.md +1 -0
  21. package/setup/.claude/commands/P0.md +1 -0
  22. package/setup/.claude/commands/P1.md +1 -0
  23. package/setup/.claude/commands/P2.md +1 -0
  24. package/setup/.claude/commands/P3.md +1 -0
  25. package/setup/.claude/commands/P4.md +1 -0
  26. package/setup/.claude/commands/P5.md +1 -0
  27. package/setup/.claude/commands/code-analysis-init.md +1 -0
  28. package/setup/.claude/commands/code-analysis-rebuild.md +1 -0
  29. package/setup/.claude/commands/code-analysis-show-memory.md +1 -0
  30. package/setup/.claude/commands/code-analysis-update.md +1 -0
  31. package/setup/.claude/hooks/check-phase-advancement.py +180 -0
  32. package/setup/.claude/hooks/check-phase-test.py +152 -0
  33. package/setup/.claude/hooks/check-phase-write.py +235 -0
  34. package/setup/.claude/hooks/dispatch.py +67 -0
  35. package/setup/.claude/hooks/file-suggestion.py +45 -0
  36. package/setup/.claude/hooks/flowcraft_env.py +137 -0
  37. package/setup/.claude/hooks/log_session.py +93 -0
  38. package/setup/.claude/hooks/permission-request.py +125 -0
  39. package/setup/.claude/hooks/post-tool-failure.py +36 -0
  40. package/setup/.claude/hooks/pre-compact.py +66 -0
  41. package/setup/.claude/hooks/review-runner.py +846 -0
  42. package/setup/.claude/hooks/session-end.py +184 -0
  43. package/setup/.claude/hooks/session-start.py +188 -0
  44. package/setup/.claude/hooks/settings.json +0 -0
  45. package/setup/.claude/hooks/setup-keys.py +282 -0
  46. package/setup/.claude/hooks/statusline.py +63 -0
  47. package/setup/.claude/hooks/stop-check.py +171 -0
  48. package/setup/.claude/hooks/subagent-start.py +50 -0
  49. package/setup/.claude/hooks/subagent-stop.py +63 -0
  50. package/setup/.claude/hooks/task-completed.py +57 -0
  51. package/setup/.claude/hooks/task_manager.py +592 -0
  52. package/setup/.claude/hooks/user-prompt-submit.py +85 -0
  53. package/setup/.claude/project-state.md +109 -0
  54. package/setup/.claude/settings.json +237 -0
  55. package/setup/.claude/settings.local.json +13 -0
  56. package/setup/.claude/skills/P5report/SKILL.md +77 -0
  57. package/setup/.claude/skills/Pstatus/SKILL.md +68 -0
  58. package/setup/.claude/skills/archive/SKILL.md +196 -0
  59. package/setup/.claude/skills/brainstorming/SKILL.md +155 -0
  60. package/setup/.claude/skills/brainstorming/scripts/frame-template.html +213 -0
  61. package/setup/.claude/skills/brainstorming/scripts/helper.js +167 -0
  62. package/setup/.claude/skills/brainstorming/scripts/server.cjs +723 -0
  63. package/setup/.claude/skills/brainstorming/scripts/start-server.py +245 -0
  64. package/setup/.claude/skills/brainstorming/scripts/stop-server.py +178 -0
  65. package/setup/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  66. package/setup/.claude/skills/brainstorming/visual-companion.md +298 -0
  67. package/setup/.claude/skills/checkpoint/SKILL.md +42 -0
  68. package/setup/.claude/skills/chrome-integration/SKILL.md +67 -0
  69. package/setup/.claude/skills/code-analysis/SKILL.md +1243 -0
  70. package/setup/.claude/skills/code-review/SKILL.md +265 -0
  71. package/setup/.claude/skills/cross-review/SKILL.md +41 -0
  72. package/setup/.claude/skills/executing-plans/SKILL.md +64 -0
  73. package/setup/.claude/skills/git-prep/SKILL.md +50 -0
  74. package/setup/.claude/skills/gitnexus/gitnexus-cli/SKILL.md +67 -0
  75. package/setup/.claude/skills/gitnexus/gitnexus-debugging/SKILL.md +89 -0
  76. package/setup/.claude/skills/gitnexus/gitnexus-exploring/SKILL.md +78 -0
  77. package/setup/.claude/skills/gitnexus/gitnexus-guide/SKILL.md +66 -0
  78. package/setup/.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +97 -0
  79. package/setup/.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md +121 -0
  80. package/setup/.claude/skills/graphify/SKILL.md +49 -0
  81. package/setup/.claude/skills/openspec-apply-change/SKILL.md +185 -0
  82. package/setup/.claude/skills/openspec-archive-change/SKILL.md +182 -0
  83. package/setup/.claude/skills/openspec-bulk-archive-change/SKILL.md +339 -0
  84. package/setup/.claude/skills/openspec-continue-change/SKILL.md +118 -0
  85. package/setup/.claude/skills/openspec-explore/SKILL.md +311 -0
  86. package/setup/.claude/skills/openspec-ff-change/SKILL.md +113 -0
  87. package/setup/.claude/skills/openspec-new-change/SKILL.md +77 -0
  88. package/setup/.claude/skills/openspec-onboard/SKILL.md +573 -0
  89. package/setup/.claude/skills/openspec-propose/SKILL.md +149 -0
  90. package/setup/.claude/skills/openspec-sync-specs/SKILL.md +262 -0
  91. package/setup/.claude/skills/openspec-update-change/SKILL.md +91 -0
  92. package/setup/.claude/skills/openspec-verify-change/SKILL.md +175 -0
  93. package/setup/.claude/skills/oss-version-check/SKILL.md +71 -0
  94. package/setup/.claude/skills/oss-version-check/check_oss_version.py +205 -0
  95. package/setup/.claude/skills/phase/SKILL.md +63 -0
  96. package/setup/.claude/skills/playwright/SKILL.md +86 -0
  97. package/setup/.claude/skills/playwright-cli/SKILL.md +420 -0
  98. package/setup/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  99. package/setup/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  100. package/setup/.claude/skills/playwright-cli/references/references/element-attributes.md +23 -0
  101. package/setup/.claude/skills/playwright-cli/references/references/playwright-tests.md +39 -0
  102. package/setup/.claude/skills/playwright-cli/references/references/request-mocking.md +87 -0
  103. package/setup/.claude/skills/playwright-cli/references/references/running-code.md +241 -0
  104. package/setup/.claude/skills/playwright-cli/references/references/session-management.md +225 -0
  105. package/setup/.claude/skills/playwright-cli/references/references/storage-state.md +275 -0
  106. package/setup/.claude/skills/playwright-cli/references/references/test-generation.md +433 -0
  107. package/setup/.claude/skills/playwright-cli/references/references/tracing.md +139 -0
  108. package/setup/.claude/skills/playwright-cli/references/references/video-recording.md +143 -0
  109. package/setup/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  110. package/setup/.claude/skills/playwright-cli/references/running-code.md +241 -0
  111. package/setup/.claude/skills/playwright-cli/references/session-management.md +225 -0
  112. package/setup/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  113. package/setup/.claude/skills/playwright-cli/references/test-generation.md +433 -0
  114. package/setup/.claude/skills/playwright-cli/references/tracing.md +139 -0
  115. package/setup/.claude/skills/playwright-cli/references/video-recording.md +143 -0
  116. package/setup/.claude/skills/review/SKILL.md +98 -0
  117. package/setup/.claude/skills/review-tools/SKILL.md +76 -0
  118. package/setup/.claude/skills/subagent-driven-development/SKILL.md +94 -0
  119. package/setup/.claude/skills/task/SKILL.md +26 -0
  120. package/setup/.claude/skills/test-driven-development/SKILL.md +320 -0
  121. package/setup/.claude/skills/test-driven-development/writing-good-tests.md +198 -0
  122. package/setup/.claude/skills/ui-ux-pro-max/SKILL.md +377 -0
  123. package/setup/.claude/skills/ui-ux-pro-max/data/charts.csv +26 -0
  124. package/setup/.claude/skills/ui-ux-pro-max/data/colors.csv +97 -0
  125. package/setup/.claude/skills/ui-ux-pro-max/data/icons.csv +101 -0
  126. package/setup/.claude/skills/ui-ux-pro-max/data/landing.csv +31 -0
  127. package/setup/.claude/skills/ui-ux-pro-max/data/products.csv +97 -0
  128. package/setup/.claude/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  129. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  130. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  131. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  132. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  133. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  134. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  135. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  136. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  137. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  138. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  139. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  140. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  141. package/setup/.claude/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  142. package/setup/.claude/skills/ui-ux-pro-max/data/styles.csv +68 -0
  143. package/setup/.claude/skills/ui-ux-pro-max/data/typography.csv +58 -0
  144. package/setup/.claude/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  145. package/setup/.claude/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  146. package/setup/.claude/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  147. package/setup/.claude/skills/ui-ux-pro-max/scripts/core.py +253 -0
  148. package/setup/.claude/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  149. package/setup/.claude/skills/ui-ux-pro-max/scripts/search.py +114 -0
  150. package/setup/.claude/skills/ui-ux-standards/SKILL.md +154 -0
  151. package/setup/.claude/skills/verification-before-completion/SKILL.md +120 -0
  152. package/setup/.claude/skills/wiki-read/SKILL.md +190 -0
  153. package/setup/.claude/skills/writing-plans/SKILL.md +168 -0
  154. package/setup/.claude/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  155. package/setup/.claude/tasks/.last-session +1 -0
  156. package/setup/.codex/.agents/skills/P5report/SKILL.md +77 -0
  157. package/setup/.codex/.agents/skills/Pstatus/SKILL.md +30 -0
  158. package/setup/.codex/.agents/skills/archive/SKILL.md +196 -0
  159. package/setup/.codex/.agents/skills/brainstorming/SKILL.md +155 -0
  160. package/setup/.codex/.agents/skills/brainstorming/scripts/frame-template.html +213 -0
  161. package/setup/.codex/.agents/skills/brainstorming/scripts/helper.js +167 -0
  162. package/setup/.codex/.agents/skills/brainstorming/scripts/server.cjs +723 -0
  163. package/setup/.codex/.agents/skills/brainstorming/scripts/start-server.py +245 -0
  164. package/setup/.codex/.agents/skills/brainstorming/scripts/stop-server.py +178 -0
  165. package/setup/.codex/.agents/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  166. package/setup/.codex/.agents/skills/brainstorming/visual-companion.md +298 -0
  167. package/setup/.codex/.agents/skills/checkpoint/SKILL.md +42 -0
  168. package/setup/.codex/.agents/skills/chrome-integration/SKILL.md +67 -0
  169. package/setup/.codex/.agents/skills/code-analysis/SKILL.md +1243 -0
  170. package/setup/.codex/.agents/skills/code-review/SKILL.md +265 -0
  171. package/setup/.codex/.agents/skills/cross-review/SKILL.md +42 -0
  172. package/setup/.codex/.agents/skills/executing-plans/SKILL.md +64 -0
  173. package/setup/.codex/.agents/skills/git-prep/SKILL.md +50 -0
  174. package/setup/.codex/.agents/skills/gitnexus/gitnexus-cli/SKILL.md +67 -0
  175. package/setup/.codex/.agents/skills/gitnexus/gitnexus-debugging/SKILL.md +89 -0
  176. package/setup/.codex/.agents/skills/gitnexus/gitnexus-exploring/SKILL.md +78 -0
  177. package/setup/.codex/.agents/skills/gitnexus/gitnexus-guide/SKILL.md +66 -0
  178. package/setup/.codex/.agents/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +97 -0
  179. package/setup/.codex/.agents/skills/gitnexus/gitnexus-refactoring/SKILL.md +121 -0
  180. package/setup/.codex/.agents/skills/graphify/SKILL.md +49 -0
  181. package/setup/.codex/.agents/skills/openspec-apply-change/SKILL.md +185 -0
  182. package/setup/.codex/.agents/skills/openspec-archive-change/SKILL.md +182 -0
  183. package/setup/.codex/.agents/skills/openspec-bulk-archive-change/SKILL.md +339 -0
  184. package/setup/.codex/.agents/skills/openspec-continue-change/SKILL.md +118 -0
  185. package/setup/.codex/.agents/skills/openspec-explore/SKILL.md +311 -0
  186. package/setup/.codex/.agents/skills/openspec-ff-change/SKILL.md +113 -0
  187. package/setup/.codex/.agents/skills/openspec-new-change/SKILL.md +77 -0
  188. package/setup/.codex/.agents/skills/openspec-onboard/SKILL.md +573 -0
  189. package/setup/.codex/.agents/skills/openspec-propose/SKILL.md +149 -0
  190. package/setup/.codex/.agents/skills/openspec-sync-specs/SKILL.md +262 -0
  191. package/setup/.codex/.agents/skills/openspec-update-change/SKILL.md +91 -0
  192. package/setup/.codex/.agents/skills/openspec-verify-change/SKILL.md +175 -0
  193. package/setup/.codex/.agents/skills/oss-version-check/SKILL.md +71 -0
  194. package/setup/.codex/.agents/skills/oss-version-check/check_oss_version.py +205 -0
  195. package/setup/.codex/.agents/skills/phase/SKILL.md +63 -0
  196. package/setup/.codex/.agents/skills/playwright/SKILL.md +86 -0
  197. package/setup/.codex/.agents/skills/playwright-cli/SKILL.md +420 -0
  198. package/setup/.codex/.agents/skills/playwright-cli/references/element-attributes.md +23 -0
  199. package/setup/.codex/.agents/skills/playwright-cli/references/playwright-tests.md +39 -0
  200. package/setup/.codex/.agents/skills/playwright-cli/references/references/element-attributes.md +23 -0
  201. package/setup/.codex/.agents/skills/playwright-cli/references/references/playwright-tests.md +39 -0
  202. package/setup/.codex/.agents/skills/playwright-cli/references/references/request-mocking.md +87 -0
  203. package/setup/.codex/.agents/skills/playwright-cli/references/references/running-code.md +241 -0
  204. package/setup/.codex/.agents/skills/playwright-cli/references/references/session-management.md +225 -0
  205. package/setup/.codex/.agents/skills/playwright-cli/references/references/storage-state.md +275 -0
  206. package/setup/.codex/.agents/skills/playwright-cli/references/references/test-generation.md +433 -0
  207. package/setup/.codex/.agents/skills/playwright-cli/references/references/tracing.md +139 -0
  208. package/setup/.codex/.agents/skills/playwright-cli/references/references/video-recording.md +143 -0
  209. package/setup/.codex/.agents/skills/playwright-cli/references/request-mocking.md +87 -0
  210. package/setup/.codex/.agents/skills/playwright-cli/references/running-code.md +241 -0
  211. package/setup/.codex/.agents/skills/playwright-cli/references/session-management.md +225 -0
  212. package/setup/.codex/.agents/skills/playwright-cli/references/storage-state.md +275 -0
  213. package/setup/.codex/.agents/skills/playwright-cli/references/test-generation.md +433 -0
  214. package/setup/.codex/.agents/skills/playwright-cli/references/tracing.md +139 -0
  215. package/setup/.codex/.agents/skills/playwright-cli/references/video-recording.md +143 -0
  216. package/setup/.codex/.agents/skills/review/SKILL.md +98 -0
  217. package/setup/.codex/.agents/skills/review-tools/SKILL.md +76 -0
  218. package/setup/.codex/.agents/skills/subagent-driven-development/SKILL.md +94 -0
  219. package/setup/.codex/.agents/skills/task/SKILL.md +27 -0
  220. package/setup/.codex/.agents/skills/test-driven-development/SKILL.md +320 -0
  221. package/setup/.codex/.agents/skills/test-driven-development/writing-good-tests.md +198 -0
  222. package/setup/.codex/.agents/skills/ui-ux-pro-max/SKILL.md +377 -0
  223. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/charts.csv +26 -0
  224. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/colors.csv +97 -0
  225. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/icons.csv +101 -0
  226. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/landing.csv +31 -0
  227. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/products.csv +97 -0
  228. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  229. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  230. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  231. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  232. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  233. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  234. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  235. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  236. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  237. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  238. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  239. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  240. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  241. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  242. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/styles.csv +68 -0
  243. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/typography.csv +58 -0
  244. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  245. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  246. package/setup/.codex/.agents/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  247. package/setup/.codex/.agents/skills/ui-ux-pro-max/scripts/core.py +253 -0
  248. package/setup/.codex/.agents/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  249. package/setup/.codex/.agents/skills/ui-ux-pro-max/scripts/search.py +114 -0
  250. package/setup/.codex/.agents/skills/ui-ux-standards/SKILL.md +154 -0
  251. package/setup/.codex/.agents/skills/verification-before-completion/SKILL.md +120 -0
  252. package/setup/.codex/.agents/skills/wiki-read/SKILL.md +190 -0
  253. package/setup/.codex/.agents/skills/writing-plans/SKILL.md +168 -0
  254. package/setup/.codex/.agents/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  255. package/setup/.codex/config.toml +10 -0
  256. package/setup/.codex/hooks/log_session.py +92 -0
  257. package/setup/.codex/hooks/review-runner.py +851 -0
  258. package/setup/.codex/hooks/sdlc-codex-hook.cjs +1039 -0
  259. package/setup/.codex/hooks/setup-keys.py +287 -0
  260. package/setup/.codex/hooks.json +121 -0
  261. package/setup/.codex/model-catalog.json +154 -0
  262. package/setup/.codex/project-state.md +103 -0
  263. package/setup/AGENTS.md +722 -0
  264. package/setup/CLAUDE.md +717 -0
  265. package/setup/install.sh +24 -0
  266. package/setup/tests/test_decision_timeout.py +241 -0
  267. package/setup/tests/test_hook_guards.py +357 -0
  268. package/setup/tests/test_sdlc_bootstrap.py +167 -0
  269. package/setup/tests/test_task_manager.py +148 -0
@@ -0,0 +1,1243 @@
1
+ ---
2
+ name: code-analysis
3
+ description: "Smart code analysis: module-level architecture/requirements/process/interface docs. | 触发词:代码分析/分析代码/生成wiki"
4
+ ---
5
+
6
+ Smart code-analysis skill; **must analyze to module level (Module Level)**, combining docs and code for multi-dimensional analysis to generate complete module-level architecture docs.
7
+
8
+ ## Command parameters (命令参数)
9
+
10
+ Usage: `/code-analysis <argument> [module name]`
11
+
12
+ | Argument | Description | Use case |
13
+ |------|------|----------|
14
+ | **init** | initialize the Wiki directory structure | first use; build the wiki framework from scratch |
15
+ | **rebuild** | full rebuild of all module docs | major project structure changes, badly outdated docs |
16
+ | **update** | incremental update of a specified module | daily development, doc sync after code changes |
17
+ | **module name** | optional; the module to operate on | precise targeting, e.g. `settlement-center`, `apply-trip` |
18
+
19
+ ### init — Initialize Wiki (full initialization)
20
+
21
+ Run on first use or when rebuilding the wiki; creates the complete directory skeleton and analyzes all module code:
22
+
23
+ ```
24
+ wiki/
25
+ ├── main/ # Wiki global entry
26
+ │ ├── index.md # global index (with module index table)
27
+ │ ├── 架构总览.md # project overall architecture
28
+ │ ├── 交互流程.md # inter-system interaction
29
+ │ ├── 安全设计.md # security architecture
30
+ │ ├── 数据流向.md # data flow
31
+ │ ├── 系统设计.md # technology selection
32
+ │ ├── 需求总览.md # requirements overview
33
+ │ ├── 流程总览.md # process overview
34
+ │ └── 接口总览.md # interface overview
35
+ └── {module}/ # per-module wiki
36
+ ├── index.md # module index (required)
37
+ ├── 01-architecture/ # architecture docs
38
+ │ ├── index.md # architecture doc index (required)
39
+ │ ├── 架构总览.md # module overview + architecture diagram + domain model
40
+ │ ├── 模块结构.md # module split + subsystems + key classes
41
+ │ ├── 术语表.md # key term definitions
42
+ │ └── 依赖关系.md # internal/external module dependencies
43
+ ├── 02-requirements/ # requirements docs
44
+ │ ├── index.md # requirements doc index (required)
45
+ │ ├── 需求总览.md # functional requirements + P0/P1/P2 priorities
46
+ │ └── 缺陷记录.md # defect records
47
+ ├── 03-processes/ # process docs
48
+ │ ├── index.md # process doc index (required)
49
+ │ ├── 流程总览.md # process overview + relationship diagram
50
+ │ └── {business-function}.md # per business process (e.g. reconciliation, invoicing)
51
+ ├── 04-interfaces/ # interface docs
52
+ │ ├── index.md # interface doc index (required)
53
+ │ └── {function-module}.md # interfaces named by function module (e.g. user, settlement)
54
+ └── 05-plan/ # plan docs
55
+ └── index.md # plan doc index (required)
56
+ ```
57
+
58
+ **Directory structure notes (目录结构说明):**
59
+
60
+ | Directory | Required files | Optional files | Description |
61
+ |------|----------|----------|------|
62
+ | main | index.md + 8 global docs | none | Wiki global entry |
63
+ | 01-architecture | index.md + 架构总览.md | 模块结构.md, 术语表.md, 依赖关系.md | architecture docs |
64
+ | 02-requirements | index.md + 需求总览.md | 缺陷记录.md | requirements docs |
65
+ | 03-processes | index.md + 流程总览.md | {business-function}.md | process docs |
66
+ | 04-interfaces | index.md | {function-module}.md | interface docs |
67
+ | 05-plan | index.md | {task-name}.md | plan docs |
68
+
69
+ **Execution steps (执行步骤, one-shot complete flow):**
70
+
71
+ 1. **Scan the project root**
72
+ - identify all project modules (Maven pom.xml / Gradle build.gradle / package.json / go.mod / Cargo.toml etc.)
73
+ - extract module names (e.g. settlement-center, apply-trip)
74
+ - build the file-path-prefix → module-name mapping
75
+
76
+ 2. **Create the directory skeleton**
77
+ - create the main directory and all global doc skeletons
78
+ - generate the directory structure for each module name
79
+ - generate empty `index.md` index file skeletons
80
+
81
+ 3. **Full analysis of all modules (auto-run rebuild)**
82
+ - iterate over all identified modules
83
+ - scan module source directories (e.g. src/main/java, src, cmd, handlers)
84
+ - identify per-language key code components (Java: Controller/Service/Handler/Entity; Go: Handler/Service/Model; Python: View/Service/Model; JS: Component/Service/Hook)
85
+ - read source code in detail; extract architecture, processes, interfaces
86
+ - generate/overwrite docs under `01-architecture/`, `02-requirements/`, `03-processes/`, `04-interfaces/`
87
+
88
+ 4. **Generate global docs**
89
+ - update the global docs under main (架构总览, 交互流程, etc.)
90
+ - generate the module index table recording each module's basic info
91
+
92
+ 5. **Update the global index**
93
+ - generate the complete `main/index.md` global index
94
+ - update `main/架构总览.md` (module list, tech stack)
95
+ - update `main/接口总览.md` (interface stats for all modules)
96
+
97
+ **Module basic-info extraction (模块基础信息提取):**
98
+
99
+ | Info | Source | Purpose |
100
+ |------|------|------|
101
+ | module name | pom.xml artifactId / package.json name / go.mod module / Cargo.toml package | directory naming, index |
102
+ | source path | source dir in build config / actual directory structure | code scan path |
103
+ | port | config files (application.yml/properties, config.yaml, .env) / startup class | interface location |
104
+ | tech stack | dependencies in build config / package.json / requirements.txt / go.mod | architecture docs |
105
+ | external dependencies | dependency declarations in build config | dependency docs |
106
+
107
+ **Command**: `/code-analysis init` → completes all initialization and analysis in one step
108
+
109
+ **Note**: init overwrites analysis content in existing docs; manually added comments must be backed up in advance.
110
+
111
+ **init self-check list (init 完成自检清单, all must pass before finishing):**
112
+
113
+ | # | Check | Verification |
114
+ |---|--------|----------|
115
+ | 1 | all module directories created | `ls wiki/{module}/` has 01-04 subdirectories |
116
+ | 2 | main global directory created | `ls wiki/main/` has index.md + 8 global docs |
117
+ | 3 | architecture doc generated for each module | `.md` files exist under `wiki/{module}/01-architecture/` |
118
+ | 4 | requirements doc generated for each module | `.md` files exist under `wiki/{module}/02-requirements/` |
119
+ | 5 | process doc generated for each module | `.md` files exist under `wiki/{module}/03-processes/` |
120
+ | 6 | interface doc generated for each module | `.md` files exist under `wiki/{module}/04-interfaces/` |
121
+ | 7 | main/index.md updated with module index | contains all identified module names and paths |
122
+ | 8 | main/架构总览.md updated | contains module list and tech stack |
123
+ | 9 | main/接口总览.md updated | contains interface stats for all modules |
124
+
125
+ **When self-check fails**: re-execute failed items → re-check → loop at most 3 times → if still failing, report to the user
126
+
127
+ ---
128
+
129
+ ## Final verification requirements (最终校验要求)
130
+
131
+ **After every init/rebuild/update, final verification must run to ensure Wiki completeness.**
132
+
133
+ ### index.md levels and counts
134
+
135
+ | Level | Path | Count | Description |
136
+ |------|------|------|------|
137
+ | Level 1 | `wiki/main/index.md` | 1 | Wiki global entry |
138
+ | Level 2 | `wiki/{module}/index.md` | 16 | 16 module entries |
139
+ | Level 3 | `wiki/{module}/{01-04}/index.md` | 64 | 16 modules × 4 subdirectories |
140
+ | **Total** | | **81** | |
141
+
142
+ ### Verification checklist (校验清单)
143
+
144
+ | # | Check | Verification | Pass standard |
145
+ |---|--------|----------|----------|
146
+ | 1 | total index.md count | `find wiki -name "index.md" \| wc -l` | = 81 |
147
+ | 2 | main/index.md exists | `ls wiki/main/index.md` | file exists |
148
+ | 3 | main/{01-04}/index.md | `ls wiki/main/*/index.md` | 0 (main needs no subdirectories) |
149
+ | 4 | module-root index.md | `ls wiki/*/index.md \| wc -l` | 17 (main + 16 modules) |
150
+ | 5 | module-subdir index.md | `ls wiki/*/*/index.md \| wc -l` | 64 |
151
+ | 6 | every module has 01-04 dirs | `ls wiki/*/` | all four directories exist |
152
+ | 7 | every 01-04 dir has docs | `ls wiki/*/01-architecture/*.md` | at least 1 .md |
153
+ | 8 | main has full global docs | `ls wiki/main/*.md \| wc -l` | ≥ 8 |
154
+ | 9 | total doc count reasonable | `find wiki -name "*.md" \| wc -l` | ≥ expected minimum |
155
+
156
+ ### Verification commands (校验命令)
157
+
158
+ ```bash
159
+ # 1. check total index.md count (should be 81)
160
+ find wiki -name "index.md" | wc -l
161
+
162
+ # 2. check index.md counts per level
163
+ echo "main/index.md: $(ls wiki/main/index.md 2>/dev/null && echo 1 || echo 0)"
164
+ echo "main/{01-04}/index.md: $(ls wiki/main/*/index.md 2>/dev/null | wc -l)"
165
+ echo "module root index.md: $(ls wiki/*/index.md 2>/dev/null | wc -l)"
166
+ echo "module subdir index.md: $(ls wiki/*/*/index.md 2>/dev/null | wc -l)"
167
+
168
+ # 3. check each module's directory structure
169
+ for dir in wiki/*/; do echo "=== $(basename $dir) ===" && ls -d $dir/01-architecture $dir/02-requirements $dir/03-processes $dir/04-interfaces 2>/dev/null | wc -l; done
170
+
171
+ # 4. check total doc count
172
+ find wiki -name "*.md" | wc -l
173
+ ```
174
+
175
+ ### Verification failure handling (校验失败处理)
176
+
177
+ | Problem | Handling |
178
+ |------|----------|
179
+ | missing index.md | **immediately** generate it |
180
+ | missing directory | create the directory structure |
181
+ | missing doc | dispatch a sub-agent to supplement analysis |
182
+ | **task must not end until verification passes** | — |
183
+ ### rebuild — Full rebuild and optimization (全量对比优化)
184
+
185
+ Fully re-scan all modules; optimize, complete, and correct existing docs by comparison:
186
+
187
+ **Core principle (核心原则)**:
188
+ - target dir or md file missing → must read source code and related materials in detail, give complete process, design thinking, and architecture info
189
+
190
+ **Execution steps**:
191
+
192
+ 1. **Scan all modules** (same as init step 3): identify modules, scan source, read code, extract architecture/process/interface
193
+ 2. **Compare with existing docs**: read the current .md docs; diff against the latest code analysis
194
+ 3. **Apply changes with memory**: use the change memory to decide keep/skip/accept for each diff
195
+
196
+ **Change memory (变更记忆)**:
197
+
198
+ `/code-analysis show-memory` shows existing change records. Each record contains:
199
+ - `k`: keyword (summary keyword of the change content)
200
+ - `f`: file (file-name prefix match)
201
+ - `d`: decision (skip/keep/accept)
202
+
203
+ **Match rules (匹配规则)**:
204
+ - change content contains the same keyword → auto-apply the previous decision
205
+ - change content similarity > 80% → auto-apply the previous decision
206
+ - new change type → must ask the user
207
+
208
+ **Memory management (记忆管理)**:
209
+ - `/code-analysis clear-memory` → clear all memory and start over
210
+ - `/code-analysis show-memory` → view current memory content
211
+
212
+ **Update strategy (更新策略)**:
213
+
214
+ | Case | Handling |
215
+ |------|----------|
216
+ | manual edit is correct | keep; do not overwrite |
217
+ | manual edit is wrong | flag the issue; do not overwrite |
218
+ | AI misunderstanding | correct to the right content |
219
+ | AI analysis omission | supplement missing content |
220
+ | code changed | update to the latest analysis result |
221
+
222
+ **rebuild self-check list (rebuild 完成自检清单, all must pass before finishing):**
223
+
224
+ | # | Check | Verification |
225
+ |---|--------|----------|
226
+ | 1 | all identified modules' source scanned | each module has a corresponding source dir (java/py/go/js etc.) with source files |
227
+ | 2 | architecture docs generated for all modules | `.md` files under `wiki/{module}/01-architecture/` |
228
+ | 3 | requirements docs generated for all modules | `.md` files under `wiki/{module}/02-requirements/` |
229
+ | 4 | process docs generated for all modules | `.md` files under `wiki/{module}/03-processes/` |
230
+ | 5 | interface docs generated for all modules | `.md` files under `wiki/{module}/04-interfaces/` |
231
+ | 6 | main/架构总览.md updated | contains all current modules and tech stack |
232
+ | 7 | main/接口总览.md updated | interface count and module distribution correct |
233
+
234
+ **When self-check fails**: re-execute failed items → re-check → loop at most 3 times → if still failing, report to the user
235
+
236
+ ### update — Incremental update (增量更新)
237
+
238
+ Detect code changes via git diff, identify affected modules automatically, and update only relevant docs:
239
+
240
+ **Execution steps (执行步骤)**:
241
+
242
+ 1. **Detect changed files**:
243
+ ```bash
244
+ git diff --name-only HEAD # committed changes
245
+ git diff --name-only # unstaged changes
246
+ git diff --name-only --cached # staged changes
247
+ ```
248
+
249
+ 2. **Identify project modules** (scan project root):
250
+ - find all projects with build config files (pom.xml / build.gradle / package.json / go.mod / Cargo.toml etc.)
251
+ - extract module names (e.g. settlement-center, travel-sharing-sugar)
252
+ - build the file-path-prefix → module-name mapping
253
+
254
+ 3. **Determine affected modules**:
255
+ - determine the owning module by the changed file's path prefix
256
+ - when changes span multiple modules, update all affected modules
257
+
258
+ 4. **Filter changed files**:
259
+ - keep only source files under the project language's source dirs (java/py/go/js/ts etc.)
260
+ - exclude test/, docs/, target/, node_modules/, __pycache__/ etc.
261
+
262
+ 5. **Analyze change content**:
263
+ - read the changed files; extract new/modified core logic
264
+ - determine which doc sections need updates
265
+
266
+ 6. **Compare with existing docs and generate a change list**:
267
+ - read the affected .md docs
268
+ - diff the code changes against the doc descriptions
269
+ - identify content that needs updating
270
+
271
+ 7. **Show the change list and wait for confirmation**:
272
+ - same display format as rebuild
273
+ - apply changes after the user chooses
274
+
275
+ 8. **Sync-update the indexes**:
276
+ - sync module index files (e.g. `03-processes/index.md`)
277
+ - update the `docs/wiki/main/index.md` global index
278
+
279
+ **Module identification rules (模块识别规则)**:
280
+
281
+ | File path pattern | Module | Docs to update |
282
+ |-------------|---------|---------|
283
+ | `settlement-center/**` | settlement-center | invoicing, settlement processes, interface docs |
284
+ | `travel-sharing-sugar/**` | travel-sharing-sugar | invoicing, reconciliation/settlement processes, interface docs |
285
+ | `apply-trip/**` | apply-trip | application, approval processes |
286
+ | `bff-service/**` | bff-service | aggregation interfaces, frontend adaptation |
287
+ | others | determined by the dir of the build config file | corresponding module docs |
288
+
289
+ **Specified-module update**:
290
+ - `/code-analysis update` → auto-detect changes for all modules
291
+ - `/code-analysis update settlement-center` → analyze only the settlement-center module's changes
292
+
293
+ **update self-check list (update 完成自检清单, all must pass before finishing):**
294
+
295
+ | # | Check | Verification |
296
+ |---|--------|----------|
297
+ | 1 | changed files correctly identified | git diff shows the expected changed files |
298
+ | 2 | affected modules determined | correctly mapped to modules by path prefix |
299
+ | 3 | filtered changed files correct | only source files under the project language's source dirs (java/py/go/js etc.) |
300
+ | 4 | docs of changed modules updated | modification time of the .md files updated |
301
+ | 5 | module index synced | summary/update time in the index file updated |
302
+ | 6 | main/index.md global index synced | update time of the global index updated |
303
+
304
+ **When self-check fails**: re-execute failed items → re-check → loop at most 3 times → if still failing, report to the user
305
+
306
+ ---
307
+
308
+ ## Core principles (核心原则)
309
+
310
+ **When the target directory or md file does not exist, you must read the source code and related materials in detail and provide complete process, design thinking, and architecture info.**
311
+
312
+ ---
313
+
314
+ ## Analysis methods (分析方法)
315
+
316
+ ### 1. Document analysis (文档分析)
317
+ - identify module-related docs (interface docs, PRD, requirements docs)
318
+ - extract business functions, processes, interface definitions
319
+ - identify business rules and constraints
320
+ - **do not present as code comments; extract key business logic**
321
+
322
+ ### 2. Code analysis (代码分析, core)
323
+ When the target md does not exist, you must read the source code in detail:
324
+
325
+ #### 2.1 Key file list (关键文件清单)
326
+
327
+ | File type | Read priority | Extract |
328
+ |-----------|------------|----------|
329
+ | **Controller / Handler / View / Component** | P0 | interface paths, request/response structure, entry methods |
330
+ | **Service / Business Logic** | P0 | core business logic, process orchestration, state handling |
331
+ | **Handler / Request Processor** | P0 | request handling flow, param validation, exception handling |
332
+ | **Entity / Model / Domain** | P1 | aggregate roots, domain model, state machine |
333
+ | **Gateway / Client / Adapter** | P1 | external call wrapping, interface definitions |
334
+ | **Config / Settings** | P2 | business config, routing rules |
335
+
336
+ #### 2.2 Source-reading depth (源码阅读深度)
337
+
338
+ **Must extract:**
339
+ 1. **Process nodes**: input→processing→output; mark key decision points
340
+ 2. **Call chains**: inter-method call relationships; mark data transforms
341
+ 3. **State transitions**: state enum definitions, state change conditions
342
+ 4. **Exception handling**: exception scenarios, handling strategies
343
+ 5. **Config dependencies**: config center (Apollo/Nacos/Consul), feature flags, routing rules
344
+
345
+ **Forbidden:**
346
+ - do not paste code
347
+ - do not translate comments
348
+ - do not pile up technical details
349
+
350
+ #### 2.3 Design-thinking extraction (设计思路提取)
351
+
352
+ Extract design patterns and use cases from source:
353
+
354
+ | Pattern | Recognition | Extract |
355
+ |----------|----------|----------|
356
+ | **Adapter** | Adapter, Client | vendor integration, multi-channel switching |
357
+ | **Strategy** | Strategy, Handler | differentiated handling, product-line differences |
358
+ | **Template method** | Base, abstract | common flow + subclass implementation |
359
+ | **Factory** | Factory, Builder | complex object construction |
360
+ | **Observer** | Listener, Event | state-change notification |
361
+
362
+ ### 3. Cross-validation (交叉验证)
363
+ - compare doc descriptions against code implementation
364
+ - ensure docs and code stay consistent
365
+ - supplement implementation details not covered by docs
366
+
367
+ ---
368
+
369
+ ## Processing flow (处理流程)
370
+
371
+ **Whether the target md exists or not, you must read the source code in detail:**
372
+
373
+ ```
374
+ 1. check whether md files exist in the target directory
375
+ 2. scan the module source directory structure
376
+ 3. identify key code components (Controller/Handler/Service/Model etc.)
377
+ 4. read source code in detail (P0→P1→P2 priority)
378
+ 5. extract: process nodes, call chains, state transitions, design patterns
379
+ 6. combine related docs (docx/pdf) to supplement background
380
+ 7. generate/update the complete md docs
381
+ ```
382
+
383
+ **Core principles:**
384
+ - **md missing** → generate complete docs from source
385
+ - **md exists** → read source in detail, compare with existing docs, fix or supplement
386
+ - **forbidden** → overwrite existing md without reading source
387
+ - **forbidden** → only scan directories without reading actual code
388
+
389
+ ---
390
+
391
+ ## Output standards (输出规范)
392
+
393
+ ### Module overview (模块概述)
394
+ Describe the module's position and core functions at the start of the report.
395
+
396
+ **Module overview must include:**
397
+
398
+ | Content | Description | Example |
399
+ |------|------|------|
400
+ | **Module positioning** | the module's role and responsibility in the system | "The settlement center is the enterprise's core accounting module, responsible for..." |
401
+ | **Core function list** | main business capabilities (3-5) | 1. reconciliation management 2. invoicing 3. settlement processing |
402
+ | **User roles** | who uses this module | finance staff, administrators, system integrators |
403
+ | **External dependencies** | external systems/services the module depends on | invoice platform, payment system, tax system |
404
+ | **Data boundary** | the module's core business data | bills, invoices, settlement orders, customer accounts |
405
+
406
+ **Core-function identification method:**
407
+ 1. extract business entries from Controller/Handler public methods
408
+ 2. extract orchestration logic from the Service layer
409
+ 3. extract business objects from core Entity/Model
410
+ 4. extract branch logic from business flows (if-else/switch)
411
+ 5. identify async processing flows from message queues/callbacks
412
+
413
+ **Core-function description format:**
414
+ ```markdown
415
+ ## Module overview (模块概述)
416
+
417
+ ### Module positioning (模块定位)
418
+ [one sentence describing the module's position and responsibility in the system]
419
+
420
+ ### Core functions (核心功能)
421
+ | Function | Description | Priority |
422
+ |------|------|--------|
423
+ | [function1] | [one-line description] | P0 |
424
+ | [function2] | [one-line description] | P1 |
425
+
426
+ ### User roles (用户角色)
427
+ - [role1]: [usage scenario]
428
+ - [role2]: [usage scenario]
429
+
430
+ ### External dependencies (外部依赖)
431
+ - [system]: [dependency description]
432
+
433
+ ### Core business data (核心业务数据)
434
+ - [entity1]: [data description]
435
+ - [entity2]: [data description]
436
+ ```
437
+
438
+ ### 1. Architecture diagram (架构框图, required)
439
+ Use an ASCII layered architecture diagram to show the system structure.
440
+
441
+ ### 2. Core domain model table (核心领域模型表)
442
+ Show the domain model, main entities, and relationships in a table.
443
+
444
+ ### 3. Glossary (术语表)
445
+ Key term definitions (term, English, definition).
446
+
447
+ ### 4. Subsystem description table (子系统说明表)
448
+ Each subsystem's responsibility and key components.
449
+
450
+ ### 5. Detailed process design (流程详细设计, required when no md exists)
451
+ When the target md does not exist, must include:
452
+
453
+ #### 5.1 Complete sequence diagram (完整时序图)
454
+ Use Mermaid sequenceDiagram, showing:
455
+ - all participating roles (systems/services)
456
+ - messages between roles
457
+ - synchronous/asynchronous calls
458
+ - error/exception branches
459
+
460
+ #### 5.2 Detailed flow description (详细流程说明)
461
+ - step-by-step description of each process
462
+ - input/output at each step
463
+ - business rules and validations
464
+ - exception handling and fallback
465
+
466
+ ### 6. External API identification (对外API识别)
467
+
468
+ **Recognition rules**: scan entry components (Controller/Handler/View/API Route); identify externally exposed interfaces with paths containing `/open`, `/api`, `/external`, `/corpApi`, etc.
469
+
470
+ **Output requirements**: generate one md file per external API, placed under `04-interfaces/`.
471
+
472
+ **md content template (md 内容模板):**
473
+
474
+ ```markdown
475
+ # {interface name}
476
+
477
+ ## Interface overview (接口概述)
478
+ one sentence describing the interface function.
479
+
480
+ ## Interface info (接口信息)
481
+
482
+ | Item | Value |
483
+ |------|-----|
484
+ | Interface path | /xxx/xxx |
485
+ | Request method | POST/GET |
486
+ | Auth method | Bearer Token / AppKey / none |
487
+ | Service provider | this system / external system |
488
+
489
+ ## Request parameters (请求参数)
490
+
491
+ | Parameter | Type | Required | Description |
492
+ |--------|------|------|------|
493
+
494
+ ## Response parameters (响应参数)
495
+
496
+ | Parameter | Type | Description |
497
+ |--------|------|------|
498
+
499
+ ## Interface logic (接口逻辑)
500
+
501
+ 1. step 1: xxx
502
+ 2. step 2: xxx
503
+
504
+ ## Invocation example (调用示例)
505
+
506
+ | Caller | Scenario |
507
+ |--------|------|
508
+ ```
509
+
510
+ **Interface grouping/naming rules (接口分组命名规则)**:
511
+ - name by business domain, e.g. `用户同步接口.md`, `开票接口.md`, `结算接口.md`
512
+ - one md file can contain multiple related interfaces (e.g. invoice-apply + invoice-callback + invoice-query)
513
+ - use Chinese naming; the `open-xxx.md` format is forbidden
514
+ ---
515
+
516
+ ## Directory structure standard (目录结构规范)
517
+
518
+ ### Global directory (全局目录)
519
+
520
+ ```
521
+ docs/wiki/
522
+ ├── main/ # Wiki global main entry (required)
523
+ │ ├── index.md # global index + knowledge retrieval entry
524
+ │ ├── 架构总览.md # project overall architecture design
525
+ │ ├── 交互流程.md # inter-system interaction flows
526
+ │ ├── 安全设计.md # security architecture and auth mechanisms
527
+ │ ├── 数据流向.md # data flow and storage architecture
528
+ │ └── 系统设计.md # technology selection and design decisions
529
+ └── {module}/ # per-module wiki
530
+ ├── index.md # module index
531
+ ├── 01-architecture/
532
+ ├── 02-requirements/
533
+ ├── 03-processes/
534
+ └── 04-interfaces/
535
+ ```
536
+
537
+ ### main directory positioning (main 目录定位)
538
+
539
+ **main is the main entry of the business system**, with two core responsibilities:
540
+
541
+ | Responsibility | Description |
542
+ |------|------|
543
+ | **Knowledge retrieval entry** | Wiki directory structure, index standards, AI retrieval rules |
544
+ | **Project panorama** | integrate all module docs; generate system-level architecture/process/security/data panorama |
545
+
546
+ **main/index.md content standard (main/index.md 内容规范):**
547
+
548
+ ```markdown
549
+ # {project name} Document Center (文档中心)
550
+
551
+ ## Wiki structure description (Wiki 结构说明)
552
+
553
+ | Directory | Description |
554
+ |------|------|
555
+ | main/ | Wiki main entry; contains the project panorama |
556
+ | {module}/ | per business module docs |
557
+
558
+ **AI retrieval rule (AI 检索规则)**: for system-level questions, read main/ first for the panorama, then locate the specific module.
559
+
560
+ ## Project module index (项目模块索引)
561
+
562
+ | Module | Path | Interfaces |
563
+ |------|------|--------|
564
+ | settlement-center | [../settlement-center/](./settlement-center/) | 5 |
565
+ | ... | ... | ... |
566
+ ```
567
+
568
+ **main directory content requirements (main 目录内容要求):**
569
+ - `index.md` = knowledge retrieval entry (module index + quick navigation)
570
+ - `架构总览.md` = project overall architecture (overview diagram, tech stack, module split)
571
+ - `交互流程.md` = inter-system interaction (module call relationships, sequence diagrams)
572
+ - `安全设计.md` = security architecture (authentication, authorization, data security)
573
+ - `数据流向.md` = data architecture (data flow, storage, cache)
574
+ - `系统设计.md` = technical decisions (selection, high availability, disaster recovery)
575
+
576
+ ### Module directory structure (模块目录结构)
577
+
578
+ After each analysis, create under `{project root}/wiki/{module}/`:
579
+
580
+ ```
581
+ wiki/{module}/
582
+ ├── 01-architecture/ # architecture docs
583
+ │ ├── 架构总览.md # module overview + architecture diagram + domain model + tech stack
584
+ │ ├── 模块结构.md # module split + subsystem description + key classes
585
+ │ ├── 术语表.md # key term definitions
586
+ │ └── 依赖关系.md # internal/external module dependencies
587
+ ├── 02-requirements/ # requirements docs
588
+ │ ├── 需求总览.md # functional requirements + P0/P1/P2 priorities
589
+ │ └── 缺陷记录.md # defect records
590
+ ├── 03-processes/ # process docs
591
+ │ ├── 流程总览.md # process overview + relationship diagram
592
+ │ └── {business-function}.md # per business process (e.g. reconciliation, invoicing)
593
+ ├── 04-interfaces/ # interface docs
594
+ │ ├── 索引.md # interface doc index
595
+ │ └── {function-module}.md # external APIs named by function module (e.g. flight.md, hotel.md, settlement.md)
596
+ └── 05-plan/ # plan docs
597
+ └── {Chinese-task-name}.md
598
+ ```
599
+
600
+ **File naming rules (文件名规则)**: do not generate README.md; files use Chinese names.
601
+
602
+ ---
603
+
604
+ ## Business process doc requirements (业务流程文档要求)
605
+
606
+ For each business process (e.g. reconciliation, settlement, invoicing), include:
607
+
608
+ ### Required content (必须内容)
609
+ 1. **Process overview (流程概述)**: one sentence describing the process purpose
610
+ 2. **CRUD operation steps (CRUD 操作步骤, core! must describe each operation in detail)**:
611
+ - **Create (新增)**: trigger condition, input params, business validation, save logic, result feedback
612
+ - **Read (查询)**: query conditions, returned data, pagination/no pagination, permission control
613
+ - **Update (修改)**: trigger condition, modification scope (partial/full), pre-update validation, version control, result feedback
614
+ - **Delete (删除)**: delete type (logical/physical), delete conditions, delete impact, permission control
615
+ 3. **Sequence diagram (时序图)**: use Mermaid sequenceDiagram to show interaction
616
+ 4. **Interface list (接口清单)**: list related interfaces in a table (path, name, function)
617
+ 5. **Key node descriptions (关键节点说明)**: describe each node in a table
618
+ 6. **Business rules (业务规则)**: batching logic, merge rules, state transitions, etc.
619
+
620
+ ### CRUD operation step template (CRUD 操作步骤模板)
621
+
622
+ **For each business object, must answer the following questions:**
623
+
624
+ | Operation | Questions that must be answered |
625
+ |------|---------------|
626
+ | **Create (新增)** | 1. Who can create? (role) 2. What triggers creation? 3. Which params are required? 4. What validation before creation? 5. What results after creation? 6. What follow-up actions (message/callback/state change)? |
627
+ | **Read (查询)** | 1. Who can query? (role) 2. Which query conditions supported? 3. What is the result structure? 4. Paginated? 5. Permission control? 6. Query performance requirements? |
628
+ | **Update (修改)** | 1. Who can update? (role) 2. Which fields can be modified? 3. What validation before update? 4. Version control needed (optimistic lock)? 5. What data synced after update? 6. Does it trigger downstream processes? |
629
+ | **Delete (删除)** | 1. Who can delete? (role) 2. Logical or physical delete? 3. What are the delete conditions? 4. What checks before delete (downstream dependencies)? 5. How is data handled after delete? 6. Audit logs needed? |
630
+
631
+ ### Business rule description requirements (业务规则描述要求)
632
+
633
+ **Every business rule must include:**
634
+
635
+ | Element | Description | Example |
636
+ |------|------|------|
637
+ | Rule name | an immediately recognizable name | "attendance rule priority" |
638
+ | Rule content | concrete logic description | "only one rule can take effect in the same time period" |
639
+ | Trigger condition | when this rule triggers | "when rule time ranges overlap" |
640
+ | Constraint scope | which operations the rule applies to | "adding rules, modifying rule time ranges" |
641
+ | Violation handling | what happens when violated | "show a prompt; saving not allowed" |
642
+
643
+ ### Forbidden content (禁止内容)
644
+ - **No code pasting**: no ```java / ```python3 / ```js code blocks
645
+ - **No request/response examples**: no JSON examples
646
+ - **Be concise**: extract key business logic; do not pile up details
647
+
648
+ ### Parameter description format (参数说明格式)
649
+ Use a table to stay concise:
650
+
651
+ | Parameter | Type | Required | Description |
652
+ |------|------|------|------|
653
+ | batchNo | String | Y | batch number |
654
+
655
+ ---
656
+
657
+ ## File write rules (文件写入规则)
658
+
659
+ **Core principle: first identify the original file's format features, then decide the write strategy**
660
+
661
+ ### Format-feature recognition (格式特征识别, mandatory)
662
+ Before overwriting/updating any file, must first identify and record the original file's **format features**:
663
+
664
+ | Format type | Example | Handling |
665
+ |----------|------|----------|
666
+ | Wiki link syntax | `[[/api/logs]]`, `[[POST /api/logs]]` | **must preserve**; do not delete or replace |
667
+ | Special markers | `<!-- -->`, ```` ```code ```` | keep as-is |
668
+ | Comment syntax | `<!-- comment -->` | keep as-is |
669
+ | Custom template markers | `${}`, `{{}}` | keep as-is |
670
+
671
+ ### Write strategy (写入策略)
672
+ 1. auto-create the directory when it does not exist
673
+ 2. **before overwrite**: must identify and preserve the original file's format features
674
+ 3. **when appending/merging**: update only the changed parts; preserve the original format features
675
+ 4. also update the `docs/wiki/main/index.md` global index
676
+
677
+ ### Overwrite risk control (覆盖风险控制)
678
+ - if the original file contains `[[` link syntax, the rewrite must preserve the `[[...]]` format
679
+ - when unsure whether to preserve a format feature, **be conservative: preserve it**
680
+ - do not "clean up" format features as a side effect of overwriting
681
+
682
+ ### main index file standard (main 索引文件规范)
683
+
684
+ **main/index.md** is the global aggregation entry, structured as follows:
685
+
686
+ ```markdown
687
+ # Wiki Global Index (Wiki 全局索引)
688
+
689
+ ## Document directory (文档目录)
690
+
691
+ | Directory | Description |
692
+ |------|------|
693
+ | [01-architecture](./01-architecture/) | architecture docs |
694
+ | [02-requirements](./02-requirements/) | requirements docs |
695
+ | [03-processes](./03-processes/) | process docs |
696
+ | [04-interfaces](./04-interfaces/) | interface docs |
697
+
698
+ ---
699
+
700
+ ## Quick navigation (快速导航)
701
+
702
+ | Doc | Keywords | Summary |
703
+ |------|--------|------|
704
+ | [架构总览](./01-architecture/架构总览.md) | Wiki architecture, module index, doc standards | global architecture, module list and doc standards of the Wiki doc system |
705
+ | [需求总览](./02-requirements/需求总览.md) | functional modules, business processes | functional requirements overview of the Wiki doc system |
706
+ | [流程总览](./03-processes/流程总览.md) | doc access, sequence diagrams | core process description of the Wiki doc system |
707
+ | [接口总览](./04-interfaces/接口总览.md) | interface stats, module distribution | interface stats overview of the Wiki doc system |
708
+
709
+ ---
710
+
711
+ ## Module list (模块列表)
712
+
713
+ | Module | Path | Interface count |
714
+ |------|------|--------|
715
+ | settlement-center | [../settlement-center/](./settlement-center/) | 5 |
716
+ | ... | ... | ... |
717
+
718
+ ---
719
+
720
+ ## Module quick navigation (模块快速导航)
721
+
722
+ | Module | Keywords | Summary |
723
+ |------|--------|------|
724
+ | settlement-center | settlement, invoicing, reconciliation | enterprise settlement center supporting settlement, invoicing, reconciliation |
725
+ | ... | ... | ... |
726
+ ```
727
+
728
+ ### Sync-update mechanism (同步更新机制)
729
+ On every wiki change, must sync-update:
730
+
731
+ | Change type | Index files to update |
732
+ |----------|---------------|
733
+ | new module | create `{module}/index.md` + update `main/index.md` |
734
+ | new subdirectory | create `{directory}/index.md` |
735
+ | new doc | update the `index.md` of its directory |
736
+ | major doc content change | update the summary column of the directory's `index.md` |
737
+
738
+ ### Index file scan requirements (索引文件扫描要求)
739
+ **When updating wiki, must scan all files in the target directory**, including:
740
+ - Markdown files (.md)
741
+ - Word docs (.docx)
742
+ - Excel files (.xlsx)
743
+ - PDF files (.pdf)
744
+ - other doc formats
745
+
746
+ **Scan rules**:
747
+ 1. scan all files under `{module}/{directory}/` (not limited to md)
748
+ 2. for each file extract: file name, file type, brief description
749
+ 3. update the extracted info into that directory's `index.md`
750
+ 4. sync-update parent directories and `main/index.md`
751
+
752
+ ### External doc conversion requirements (外部文档转换要求)
753
+ **When external docs (.docx/.xlsx/.pdf) are found, must handle them**:
754
+
755
+ | Doc type | Handling |
756
+ |----------|----------|
757
+ | .docx | convert to md with pandoc; extract useful info to supplement existing md |
758
+ | .xlsx | extract key data; generate an md description doc |
759
+ | .pdf | extract text content; generate an md description doc |
760
+
761
+ **Handling rules**:
762
+ 1. when a .docx is found, extract content with `pandoc input.docx -t markdown`
763
+ 2. **do not generate a same-named .md file**; instead supplement useful info into existing md docs
764
+ 3. keep the original .docx as the archive and change basis
765
+ 4. when updating index.md, link to the original .docx (marked as archived)
766
+
767
+ ### Cross-document impact analysis (跨文档影响分析)
768
+ **When adding or updating a doc, must analyze its impact on other docs**:
769
+
770
+ | New/changed doc | Files to sync-update |
771
+ |--------------|------------------|
772
+ | 04-interfaces/ | 01-architecture/依赖关系.md (external dependency section) |
773
+ | 04-interfaces/ | 02-requirements/需求总览.md (external interface section) |
774
+ | 04-interfaces/ | 03-processes/related process.md (sequence diagram/description) |
775
+ | 03-processes/ | 02-requirements/需求总览.md (process description) |
776
+ | 03-processes/ | 01-architecture/模块结构.md (involved modules) |
777
+
778
+ **Sync-update rules**:
779
+ 1. analyze the new doc's core content (interfaces, processes, rules)
780
+ 2. identify affected target docs
781
+ 3. add relevant sections to target docs or update existing content
782
+ 4. keep cross-doc references consistent
783
+
784
+ ## Directory index file standard (目录索引文件规范)
785
+
786
+ **Every directory must contain an index.md index file**, so docs can be located quickly as they grow.
787
+
788
+ ### index.md level definitions (index.md 层级定义)
789
+
790
+ | Level | Path | Content |
791
+ |------|------|------|
792
+ | Level 1 | `main/index.md` | global index: module list + quick navigation + doc structure |
793
+ | Level 2 | `{module}/index.md` | module index: module overview + doc list |
794
+ | Level 3 | `{module}/{01-04}/index.md` | directory index: doc list + keywords |
795
+
796
+ ### Index file content requirements (索引文件内容要求)
797
+ - document list table: doc name, description, keywords
798
+ - module index: module positioning, core functions, tech stack
799
+ - update time
800
+
801
+ ### Index file template (索引文件模板)
802
+
803
+ **Module root `{module}/index.md`:**
804
+ ```markdown
805
+ # {module name} Document Index (文档索引)
806
+
807
+ ## Module overview (模块概述)
808
+
809
+ **{module name}** is {module positioning}.
810
+
811
+ **Core functions (核心功能)**: [function1], [function2], [function3]
812
+
813
+ **Tech stack (技术栈)**: [tech1] + [tech2] + [tech3]
814
+ ```
815
+
816
+ **Subdirectory `{module}/{01-04}/index.md`:**
817
+ ```markdown
818
+ # {directory name} Document Index (文档索引)
819
+
820
+ ## Document list (文档列表)
821
+
822
+ | Doc | Description | Keywords |
823
+ |------|------|--------|
824
+ | [架构总览](./架构总览.md) | API gateway technical architecture | API gateway, Nacos, HMAC signing |
825
+ | [模块结构](./模块结构.md) | controller/service details | Controller, Service, DAO |
826
+ ```
827
+
828
+ ### Keyword extraction rules (关键字提取规则)
829
+ - 3-5 core technical or business words the doc covers
830
+ - comma-separated
831
+ - example: 打卡、日结、HMAC签名、限流
832
+
833
+ ### Summary writing rules (摘要编写规则)
834
+ - one sentence describing the doc's core content (≤30 chars)
835
+ - do not start with "本文" (this doc), "本章节" (this section)
836
+ - example: 考勤系统API网关技术架构、打卡数据接收处理
837
+
838
+ ### Index file generation timing (索引文件生成时机)
839
+ - when creating a new directory, **immediately** generate its index.md
840
+ - when adding a new doc to an existing directory, **immediately** update that directory's index.md
841
+ - after module analysis completes, generate index files at all levels
842
+ - **forbidden**: empty directories without index.md
843
+
844
+ ---
845
+
846
+ ## File output directory rules (文件输出目录规则)
847
+
848
+ ### Directory priority rules (目录优先级规则)
849
+
850
+ **All plan and wiki production files must be written to the `wiki/` directory under the project root**:
851
+
852
+ | Priority | Directory | Condition |
853
+ |--------|------|------|
854
+ | **1 (preferred)** | `{project root}/wiki/` | `wiki/` exists under the project root |
855
+ | **2 (fallback)** | `{project root}/docs/wiki/` | used when `wiki/` does not exist |
856
+
857
+ ### Decision logic (判断逻辑)
858
+
859
+ ```
860
+ 1. check whether a `wiki/` directory exists under the project root
861
+ 2. if yes → write all plan and wiki files to `wiki/`
862
+ 3. if no → write all plan and wiki files to `docs/wiki/`
863
+ ```
864
+
865
+ ### Directory structure (目录结构)
866
+
867
+ When using the `wiki/` directory:
868
+
869
+ ```
870
+ {project root}/wiki/
871
+ ├── main/ # Wiki global main entry
872
+ │ ├── index.md # global index
873
+ │ ├── 架构总览.md
874
+ │ ├── 交互流程.md
875
+ │ ├── 安全设计.md
876
+ │ ├── 数据流向.md
877
+ │ ├── 系统设计.md
878
+ │ ├── 需求总览.md
879
+ │ ├── 流程总览.md
880
+ │ └── 接口总览.md
881
+ └── {module}/ # per-module wiki
882
+ ├── index.md # module index
883
+ ├── 01-architecture/
884
+ ├── 02-requirements/
885
+ ├── 03-processes/
886
+ ├── 04-interfaces/
887
+ └── 05-plan/ # plan docs
888
+ └── {Chinese-task-name}.md
889
+ ```
890
+
891
+ ### plan directory (plan 目录)
892
+
893
+ - **Path**: `wiki/{module}/05-plan/`
894
+ - **Content**: task plan files of the module
895
+ - **Naming**: `{Chinese-task-name}.md`, e.g. `分批合并服务费聚合.md`
896
+
897
+ ### Execution requirements (执行要求)
898
+
899
+ - **mandatory**: when generating plan or wiki, must first determine directory existence
900
+ - **auto-create when missing**: use `mkdir -p` to create the required directory structure
901
+ - **keep consistency**: use only one directory structure per project (either `wiki/` or `docs/wiki/`)
902
+ ---
903
+
904
+ ## Sub-agent task support (子代理任务支持)
905
+
906
+ When dispatching sub-agents to analyze multiple modules in parallel, the following standards apply.
907
+
908
+ ### Core principle (核心原则)
909
+
910
+ **Sub-agent "returns success" ≠ actually done**. The main agent must force-verify the output files.
911
+
912
+ ### Main-agent responsibilities (主 agent 职责)
913
+
914
+ #### 1. Task split list (任务拆分清单)
915
+
916
+ Each sub-agent task must specify an explicit output-file list:
917
+
918
+ ```
919
+ Dispatch example:
920
+ - Sub-agent task 1: analyze the auth module
921
+ output files:
922
+ - wiki/auth/01-architecture/index.md
923
+ - wiki/auth/02-requirements/index.md
924
+ - wiki/auth/03-processes/index.md
925
+ - wiki/auth/04-interfaces/index.md
926
+
927
+ - Sub-agent task 2: analyze the sessionlog module
928
+ output files:
929
+ - wiki/sessionlog/01-architecture/index.md
930
+ - wiki/sessionlog/02-requirements/index.md
931
+ ...
932
+ ```
933
+
934
+ #### 2. Status tracking file (状态跟踪文件)
935
+
936
+ The main agent creates a task status file before dispatching:
937
+
938
+ ```bash
939
+ # create the task status file
940
+ cat > .claude/subagent-tasks.json << 'EOF'
941
+ {
942
+ "tasks": [
943
+ {"id": 1, "module": "auth", "status": "pending", "files": ["wiki/auth/01-architecture/index.md", ...]},
944
+ {"id": 2, "module": "sessionlog", "status": "pending", "files": ["wiki/sessionlog/01-architecture/index.md", ...]}
945
+ ],
946
+ "created_at": "2026-07-10T10:00:00Z"
947
+ }
948
+ EOF
949
+ ```
950
+
951
+ #### 3. Forced verification loop (强制验证循环)
952
+
953
+ After a sub-agent returns, the main agent must verify:
954
+
955
+ ```
956
+ for each task in subagent-tasks.json:
957
+ if task.status == "completed" and task.verified != true:
958
+ for each file in task.files:
959
+ if not exists(file):
960
+ # file missing → mark failed, wait for retry
961
+ task.status = "failed"
962
+ task.retry_count += 1
963
+ else if file is empty (lines < 5):
964
+ # file content empty → mark failed
965
+ task.status = "failed"
966
+ task.retry_count += 1
967
+ else:
968
+ task.verified = true
969
+
970
+ if task.status != "failed":
971
+ task.status = "verified"
972
+ ```
973
+
974
+ ### Sub-agent execution standards (子代理执行规范)
975
+
976
+ **Each sub-agent task must, on completion:**
977
+
978
+ 1. **File-existence self-check**
979
+ ```bash
980
+ # verify each output file
981
+ for f in wiki/auth/01-architecture/index.md wiki/auth/02-requirements/index.md; do
982
+ if [ ! -f "$f" ]; then
983
+ echo "ERROR: $f not found"
984
+ exit 1
985
+ fi
986
+ done
987
+ ```
988
+
989
+ 2. **Non-empty content verification**
990
+ ```bash
991
+ # confirm file line count > 5 (not an empty file with only a title)
992
+ for f in wiki/auth/01-architecture/index.md; do
993
+ lines=$(wc -l < "$f")
994
+ if [ "$lines" -lt 5 ]; then
995
+ echo "ERROR: $f is too short ($lines lines)"
996
+ exit 1
997
+ fi
998
+ done
999
+ ```
1000
+
1001
+ 3. **Status update**
1002
+ ```bash
1003
+ # update the status file after completion
1004
+ cat > .claude/subagent-tasks.json << 'EOF'
1005
+ {
1006
+ "tasks": [
1007
+ {"id": 1, "module": "auth", "status": "completed", "files": [...], "verified": false}
1008
+ ]
1009
+ }
1010
+ EOF
1011
+ ```
1012
+
1013
+ **Forbidden:**
1014
+ - returning only "done" without writing the status
1015
+ - creating empty files or files containing only a title
1016
+ - reporting success without verifying file existence
1017
+
1018
+ ### Verification failure handling (验证失败处理)
1019
+
1020
+ | Failures | Handling |
1021
+ |---------|---------|
1022
+ | 1-2 times | re-dispatch the same sub-agent + explain the failure reason + pass the previous output as reference |
1023
+ | 3 times | the main agent takes over the task and executes directly |
1024
+
1025
+ ### Main-agent verification script example (主 agent 验证脚本示例)
1026
+
1027
+ ```bash
1028
+ #!/bin/bash
1029
+ # verify-subagent-results.sh
1030
+
1031
+ TASK_FILE=".claude/subagent-tasks.json"
1032
+
1033
+ for task in $(jq -r '.tasks[]' "$TASK_FILE"); do
1034
+ id=$(echo "$task" | jq -r '.id')
1035
+ module=$(echo "$task" | jq -r '.module')
1036
+ status=$(echo "$task" | jq -r '.status')
1037
+
1038
+ if [ "$status" != "completed" ]; then
1039
+ continue
1040
+ fi
1041
+
1042
+ # verify each file
1043
+ files=$(echo "$task" | jq -r '.files[]')
1044
+ all_passed=true
1045
+
1046
+ for f in $files; do
1047
+ if [ ! -f "$f" ]; then
1048
+ echo "MISSING: $f"
1049
+ all_passed=false
1050
+ elif [ "$(wc -l < "$f")" -lt 5 ]; then
1051
+ echo "EMPTY: $f (lines: $(wc -l < "$f"))"
1052
+ all_passed=false
1053
+ fi
1054
+ done
1055
+
1056
+ if $all_passed; then
1057
+ echo "VERIFIED: module=$module id=$id"
1058
+ # update status to verified
1059
+ else
1060
+ echo "FAILED: module=$module id=$id"
1061
+ # update status to failed, trigger retry
1062
+ fi
1063
+ done
1064
+ ```
1065
+
1066
+ ### Sub-agent task execution checklist (子代理任务执行检查清单)
1067
+
1068
+ After a sub-agent task completes, must confirm before returning:
1069
+
1070
+ - [ ] all output files created (`ls` verification)
1071
+ - [ ] every file has > 5 lines (content non-empty)
1072
+ - [ ] status file updated (`.claude/subagent-tasks.json`)
1073
+ - [ ] status = "completed" in the status file
1074
+
1075
+ ---
1076
+
1077
+ ## Content quality constraints (内容质量约束)
1078
+
1079
+ Prevent the hollow-out problem of "analyzing 1000 files but producing only empty skeletons".
1080
+
1081
+ ### Content density requirements (内容密度要求, mandatory)
1082
+
1083
+ | Doc type | Minimum content lines | Description |
1084
+ |---------|-------------|------|
1085
+ | 架构总览.md | 150 | includes architecture diagram, domain model, tech-stack details |
1086
+ | 模块结构.md | 100 | subsystem description, key class list |
1087
+ | 需求总览.md | 80 | function list, priorities, acceptance criteria |
1088
+ | 流程总览.md | 100 | process overview, main process description |
1089
+ | {business-function}.md | 150 | each CRUD item at least 20 lines of detailed description |
1090
+
1091
+ **Content line definition**: actual text lines after excluding blank lines, pure-title lines (`#`, `##`), and separators (`---`).
1092
+
1093
+ **Verification (验证方式):**
1094
+ ```bash
1095
+ # check content lines (excluding blank and pure-title lines)
1096
+ actual_lines=$(grep -v '^$' "$f" | grep -v '^#' | grep -v '^---$' | wc -l)
1097
+ if [ "$actual_lines" -lt 150 ]; then
1098
+ echo "content insufficient: $f (actual: $actual_lines lines, required: 150)"
1099
+ exit 1
1100
+ fi
1101
+ ```
1102
+
1103
+ ### Core content extraction requirements (核心内容提取要求, mandatory)
1104
+
1105
+ Each `架构总览.md` **must include** the following 5 key sections, none missing:
1106
+
1107
+ #### 1. Architecture layers diagram (架构分层图)
1108
+ ```
1109
+ ### 架构分层
1110
+ [required: use ASCII or Mermaid to show the module's interaction with external systems]
1111
+ ```
1112
+ - must include the module's position in the system
1113
+ - must include interaction with external dependencies
1114
+
1115
+ #### 2. Key class list (关键类清单)
1116
+ ```
1117
+ ## 关键类
1118
+ | Class | Responsibility | Key methods |
1119
+ |------|------|---------|
1120
+ ```
1121
+ - must list at least 5 key classes
1122
+ - each class must describe responsibility and key methods
1123
+
1124
+ #### 3. Domain model (领域模型)
1125
+ ```
1126
+ ## 领域模型
1127
+ ### 实体说明
1128
+ ### 值对象说明
1129
+ ### 聚合根说明
1130
+ ```
1131
+ - must include at least 3 core entity descriptions
1132
+ - must include entity relationships
1133
+
1134
+ #### 4. Interface list (接口清单)
1135
+ ```
1136
+ ## 接口清单
1137
+ | Interface | Path | Method | Function |
1138
+ |------|------|------|------|
1139
+ ```
1140
+ - must list at least 3 interfaces
1141
+ - each interface must include path, method name, function description
1142
+
1143
+ #### 5. State machine definition (状态机定义, if state transitions exist)
1144
+ ```
1145
+ ## 状态机定义
1146
+ | State | Enum value | Trigger condition | Convertible states |
1147
+ |------|--------|----------|------------|
1148
+ ```
1149
+
1150
+ ### Source-analysis depth requirements (源码分析深度要求, mandatory)
1151
+
1152
+ When analyzing each module, **must execute the following 4 steps**:
1153
+
1154
+ #### Step 1: count key file counts (统计关键文件数量)
1155
+ ```bash
1156
+ # record key file counts
1157
+ controller_count=$(find src -name "*Controller.java" | wc -l)
1158
+ service_count=$(find src -name "*Service.java" | wc -l)
1159
+ entity_count=$(find src -name "*.java" -path "*/entity/*" | wc -l)
1160
+ echo "Controller: $controller_count, Service: $service_count, Entity: $entity_count"
1161
+ ```
1162
+
1163
+ #### Step 2: list all Controller interfaces
1164
+ - every public method of every Controller must be identified
1165
+ - record: path, method name, params, return value
1166
+ - **no interface may be missed**
1167
+
1168
+ #### Step 3: identify core business logic
1169
+ - every core method of each Service (over 10 lines) must be extracted
1170
+ - describe business logic rather than technical implementation
1171
+ - explain input, processing, output
1172
+
1173
+ #### Step 4: generate the complete interface list
1174
+ - list all interfaces by Controller
1175
+ - include: path, method, params, response structure
1176
+ - mark which are external APIs
1177
+
1178
+ ### Content quality verification script (内容质量验证脚本)
1179
+
1180
+ ```bash
1181
+ #!/bin/bash
1182
+ # verify-content-quality.sh
1183
+
1184
+ check_content_density() {
1185
+ local file="$1"
1186
+ local min_lines="$2"
1187
+
1188
+ # actual content lines after excluding blank, pure-title, and separator lines
1189
+ actual=$(grep -v '^$' "$file" | grep -v '^#' | grep -v '^---$' | wc -l)
1190
+
1191
+ if [ "$actual" -lt "$min_lines" ]; then
1192
+ echo "FAIL: $file (content lines: $actual, required: $min_lines)"
1193
+ return 1
1194
+ fi
1195
+ echo "PASS: $file (content lines: $actual)"
1196
+ return 0
1197
+ }
1198
+
1199
+ check_required_sections() {
1200
+ local file="$1"
1201
+ local required=("架构分层" "关键类" "领域模型" "接口清单")
1202
+
1203
+ for section in "${required[@]}"; do
1204
+ if ! grep -q "## $section" "$file" && ! grep -q "### $section" "$file"; then
1205
+ echo "MISSING: $file lacks '## $section' or '### $section'"
1206
+ return 1
1207
+ fi
1208
+ done
1209
+ echo "PASS: $file contains all key sections"
1210
+ return 0
1211
+ }
1212
+
1213
+ # verify content density of each doc
1214
+ check_content_density "wiki/auth/01-architecture/架构总览.md" 150
1215
+ check_content_density "wiki/auth/02-requirements/需求总览.md" 80
1216
+ check_content_density "wiki/auth/03-processes/流程总览.md" 100
1217
+
1218
+ # check key-section completeness
1219
+ check_required_sections "wiki/auth/01-architecture/架构总览.md"
1220
+ ```
1221
+
1222
+ ### rebuild/update self-check list (rebuild/update 完成自检清单, enhanced)
1223
+
1224
+ | # | Check | Verification | Pass standard |
1225
+ |---|--------|----------|----------|
1226
+ | 1-9 | (original checks) | ... | ... |
1227
+ | 10 | content lines met | `grep -v '^$' file.md \| wc -l` | architecture≥150, requirements≥80, process≥100 |
1228
+ | 11 | key sections present | grep "## 架构分层" etc. | must include the 5 key sections |
1229
+ | 12 | key class list complete | count of identified classes | Controller/Service/Entity at least 3 each |
1230
+ | 13 | interface list complete | total interface count | external interfaces ≥3 |
1231
+ | 14 | no pure-template content | manual sampling | not an empty doc with only a skeleton |
1232
+ | 15 | every interface has a description | check the interface-list table | not a path without a function description |
1233
+
1234
+ **When self-check fails**: supplement content for failed items → re-check → loop at most 3 times → if still failing, report the specific missing items to the user
1235
+
1236
+ ### Hollow-out prevention principles (空洞化防范原则)
1237
+
1238
+ | Problem | Prevention |
1239
+ |------|---------|
1240
+ | quickly generating empty skeletons | require minimum content-line counts |
1241
+ | filling titles only, no content | require key sections to contain concrete content |
1242
+ | missing interfaces/classes | require listing and cross-checking counts |
1243
+ | copy-paste templates | require key classes/interfaces to be extracted from source |