claude-code-workflow 6.3.10 → 6.3.12

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 (88) hide show
  1. package/.claude/CLAUDE.md +33 -33
  2. package/.claude/agents/issue-plan-agent.md +18 -5
  3. package/.claude/agents/issue-queue-agent.md +12 -5
  4. package/.claude/commands/issue/discover.md +427 -0
  5. package/.claude/commands/issue/new.md +13 -1
  6. package/.claude/commands/issue/plan.md +48 -32
  7. package/.claude/commands/issue/queue.md +99 -7
  8. package/.claude/skills/software-manual/SKILL.md +184 -0
  9. package/.claude/skills/software-manual/phases/01-requirements-discovery.md +162 -0
  10. package/.claude/skills/software-manual/phases/02-project-exploration.md +101 -0
  11. package/.claude/skills/software-manual/phases/02.5-api-extraction.md +161 -0
  12. package/.claude/skills/software-manual/phases/03-parallel-analysis.md +183 -0
  13. package/.claude/skills/software-manual/phases/03.5-consolidation.md +82 -0
  14. package/.claude/skills/software-manual/phases/04-screenshot-capture.md +89 -0
  15. package/.claude/skills/software-manual/phases/05-html-assembly.md +132 -0
  16. package/.claude/skills/software-manual/phases/06-iterative-refinement.md +259 -0
  17. package/.claude/skills/software-manual/scripts/api-extractor.md +245 -0
  18. package/.claude/skills/software-manual/scripts/assemble_docsify.py +584 -0
  19. package/.claude/skills/software-manual/scripts/bundle-libraries.md +85 -0
  20. package/.claude/skills/software-manual/scripts/extract_apis.py +270 -0
  21. package/.claude/skills/software-manual/scripts/screenshot-helper.md +447 -0
  22. package/.claude/skills/software-manual/scripts/swagger-runner.md +419 -0
  23. package/.claude/skills/software-manual/scripts/typedoc-runner.md +357 -0
  24. package/.claude/skills/software-manual/specs/html-template.md +325 -0
  25. package/.claude/skills/software-manual/specs/quality-standards.md +253 -0
  26. package/.claude/skills/software-manual/specs/writing-style.md +298 -0
  27. package/.claude/skills/software-manual/templates/css/docsify-base.css +984 -0
  28. package/.claude/skills/software-manual/templates/css/wiki-base.css +788 -0
  29. package/.claude/skills/software-manual/templates/css/wiki-dark.css +278 -0
  30. package/.claude/skills/software-manual/templates/docsify-shell.html +466 -0
  31. package/.claude/skills/software-manual/templates/tiddlywiki-shell.html +327 -0
  32. package/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json +219 -0
  33. package/.claude/workflows/cli-templates/schemas/discovery-state-schema.json +125 -0
  34. package/.claude/workflows/cli-templates/schemas/issues-jsonl-schema.json +168 -74
  35. package/.codex/prompts/issue-execute.md +174 -84
  36. package/.codex/prompts/issue-plan.md +106 -0
  37. package/.codex/prompts/issue-queue.md +225 -0
  38. package/ccw/dist/cli.d.ts.map +1 -1
  39. package/ccw/dist/cli.js +1 -0
  40. package/ccw/dist/cli.js.map +1 -1
  41. package/ccw/dist/commands/issue.d.ts.map +1 -1
  42. package/ccw/dist/commands/issue.js +97 -9
  43. package/ccw/dist/commands/issue.js.map +1 -1
  44. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  45. package/ccw/dist/core/dashboard-generator.js +4 -1
  46. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  47. package/ccw/dist/core/data-aggregator.d.ts +32 -0
  48. package/ccw/dist/core/data-aggregator.d.ts.map +1 -1
  49. package/ccw/dist/core/data-aggregator.js +55 -11
  50. package/ccw/dist/core/data-aggregator.js.map +1 -1
  51. package/ccw/dist/core/routes/discovery-routes.d.ts +37 -0
  52. package/ccw/dist/core/routes/discovery-routes.d.ts.map +1 -0
  53. package/ccw/dist/core/routes/discovery-routes.js +514 -0
  54. package/ccw/dist/core/routes/discovery-routes.js.map +1 -0
  55. package/ccw/dist/core/server.d.ts.map +1 -1
  56. package/ccw/dist/core/server.js +9 -1
  57. package/ccw/dist/core/server.js.map +1 -1
  58. package/ccw/dist/tools/codex-lens.d.ts +12 -1
  59. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  60. package/ccw/dist/tools/codex-lens.js +56 -7
  61. package/ccw/dist/tools/codex-lens.js.map +1 -1
  62. package/ccw/src/cli.ts +1 -0
  63. package/ccw/src/commands/issue.ts +108 -10
  64. package/ccw/src/core/dashboard-generator.ts +4 -1
  65. package/ccw/src/core/data-aggregator.ts +94 -11
  66. package/ccw/src/core/routes/discovery-routes.ts +607 -0
  67. package/ccw/src/core/server.ts +9 -1
  68. package/ccw/src/templates/dashboard-css/33-cli-stream-viewer.css +580 -467
  69. package/ccw/src/templates/dashboard-css/34-discovery.css +783 -0
  70. package/ccw/src/templates/dashboard-js/components/cli-stream-viewer.js +532 -461
  71. package/ccw/src/templates/dashboard-js/components/navigation.js +8 -0
  72. package/ccw/src/templates/dashboard-js/components/notifications.js +774 -774
  73. package/ccw/src/templates/dashboard-js/i18n.js +144 -0
  74. package/ccw/src/templates/dashboard-js/views/codexlens-manager.js +13 -3
  75. package/ccw/src/templates/dashboard-js/views/issue-discovery.js +730 -0
  76. package/ccw/src/templates/dashboard-js/views/project-overview.js +153 -0
  77. package/ccw/src/templates/dashboard.html +15 -0
  78. package/ccw/src/tools/claude-cli-tools.ts +388 -388
  79. package/ccw/src/tools/codex-lens.ts +75 -9
  80. package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
  81. package/codex-lens/src/codexlens/config.py +19 -3
  82. package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
  83. package/codex-lens/src/codexlens/search/ranking.py +15 -4
  84. package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-313.pyc +0 -0
  85. package/codex-lens/src/codexlens/semantic/vector_store.py +57 -47
  86. package/codex-lens/src/codexlens/storage/__pycache__/registry.cpython-313.pyc +0 -0
  87. package/codex-lens/src/codexlens/storage/registry.py +114 -101
  88. package/package.json +2 -2
@@ -0,0 +1,132 @@
1
+ # Phase 5: HTML Assembly
2
+
3
+ 使用 `universal-executor` 子 Agent 生成最终 HTML,避免主 Agent 内存溢出。
4
+
5
+ ## 核心原则
6
+
7
+ **主 Agent 负责编排,子 Agent 负责繁重计算。**
8
+
9
+ ## 执行流程
10
+
11
+ ```javascript
12
+ const config = JSON.parse(Read(`${workDir}/manual-config.json`));
13
+
14
+ // 委托给 universal-executor 执行 HTML 组装
15
+ const result = Task({
16
+ subagent_type: 'universal-executor',
17
+ run_in_background: false,
18
+ prompt: buildAssemblyPrompt(config, workDir)
19
+ });
20
+
21
+ const buildResult = JSON.parse(result);
22
+ ```
23
+
24
+ ## Prompt 构建
25
+
26
+ ```javascript
27
+ function buildAssemblyPrompt(config, workDir) {
28
+ return `
29
+ [ROLE] HTML Assembler
30
+
31
+ [TASK]
32
+ 生成 TiddlyWiki 风格的交互式 HTML 手册(使用成熟库,无外部 CDN 依赖)
33
+
34
+ [INPUT]
35
+ - 模板: .claude/skills/software-manual/templates/tiddlywiki-shell.html
36
+ - CSS: .claude/skills/software-manual/templates/css/wiki-base.css, wiki-dark.css
37
+ - 配置: ${workDir}/manual-config.json
38
+ - 章节: ${workDir}/sections/section-*.md
39
+ - Agent 结果: ${workDir}/agent-results.json (含 tag 信息)
40
+ - 截图: ${workDir}/screenshots/
41
+
42
+ [LIBRARIES TO EMBED]
43
+ 1. marked.js (v14+) - Markdown 转 HTML
44
+ - 从 https://unpkg.com/marked/marked.min.js 获取内容内嵌
45
+ 2. highlight.js (v11+) - 代码语法高亮
46
+ - 核心 + 常用语言包 (js, ts, python, bash, json, yaml, html, css)
47
+ - 使用 github-dark 主题
48
+
49
+ [STEPS]
50
+ 1. 读取 HTML 模板和 CSS
51
+ 2. 内嵌 marked.js 和 highlight.js 代码
52
+ 3. 读取 agent-results.json 提取各章节 tag
53
+ 4. 动态生成 {{TAG_BUTTONS_HTML}} (基于实际使用的 tags)
54
+ 5. 逐个读取 section-*.md,使用 marked 转换为 HTML
55
+ 6. 为代码块添加 data-language 属性和语法高亮
56
+ 7. 处理 <!-- SCREENSHOT: id="..." --> 标记,嵌入 Base64 图片
57
+ 8. 生成目录、搜索索引
58
+ 9. 组装最终 HTML,写入 ${workDir}/${config.software.name}-使用手册.html
59
+
60
+ [CONTENT FORMATTING]
61
+ - 代码块: 深色背景 + 语言标签 + 语法高亮
62
+ - 表格: 蓝色表头 + 边框 + 悬停效果
63
+ - 内联代码: 红色高亮
64
+ - 列表: 有序/无序样式增强
65
+ - 左侧导航: 固定侧边栏 + TOC
66
+
67
+ [RETURN JSON]
68
+ {
69
+ "status": "completed",
70
+ "output_file": "${config.software.name}-使用手册.html",
71
+ "file_size": "<size>",
72
+ "sections_count": <n>,
73
+ "tags_generated": [],
74
+ "screenshots_embedded": <n>
75
+ }
76
+ `;
77
+ }
78
+ ```
79
+
80
+ ## Agent 职责
81
+
82
+ 1. **读取模板** → HTML + CSS
83
+ 2. **转换章节** → Markdown → HTML tiddlers
84
+ 3. **嵌入截图** → Base64 编码
85
+ 4. **生成索引** → 搜索数据
86
+ 5. **组装输出** → 单文件 HTML
87
+
88
+ ## Markdown 转换规则
89
+
90
+ Agent 内部实现:
91
+
92
+ ```
93
+ # H1 → <h1>
94
+ ## H2 → <h2>
95
+ ### H3 → <h3>
96
+ ```code``` → <pre><code>
97
+ **bold** → <strong>
98
+ *italic* → <em>
99
+ [text](url) → <a href>
100
+ - item → <li>
101
+ <!-- SCREENSHOT: id="xxx" --> → <figure><img src="data:..."></figure>
102
+ ```
103
+
104
+ ## Tiddler 结构
105
+
106
+ ```html
107
+ <article class="tiddler" id="tiddler-{name}" data-tags="..." data-difficulty="...">
108
+ <header class="tiddler-header">
109
+ <h2><button class="collapse-toggle">▼</button> {title}</h2>
110
+ <div class="tiddler-meta">{badges}</div>
111
+ </header>
112
+ <div class="tiddler-content">{html}</div>
113
+ </article>
114
+ ```
115
+
116
+ ## 输出
117
+
118
+ - `{软件名}-使用手册.html` - 最终 HTML
119
+ - `build-report.json` - 构建报告
120
+
121
+ ## 质量门禁
122
+
123
+ - [ ] HTML 渲染正确
124
+ - [ ] 搜索功能可用
125
+ - [ ] 折叠/展开正常
126
+ - [ ] 主题切换持久化
127
+ - [ ] 截图显示正确
128
+ - [ ] 文件大小 < 10MB
129
+
130
+ ## 下一阶段
131
+
132
+ → [Phase 6: Iterative Refinement](06-iterative-refinement.md)
@@ -0,0 +1,259 @@
1
+ # Phase 6: Iterative Refinement
2
+
3
+ Preview, collect feedback, and iterate until quality meets standards.
4
+
5
+ ## Objective
6
+
7
+ - Preview generated HTML in browser
8
+ - Collect user feedback
9
+ - Address issues iteratively
10
+ - Finalize documentation
11
+
12
+ ## Execution Steps
13
+
14
+ ### Step 1: Preview HTML
15
+
16
+ ```javascript
17
+ const buildReport = JSON.parse(Read(`${workDir}/build-report.json`));
18
+ const outputFile = `${workDir}/${buildReport.output}`;
19
+
20
+ // Open in default browser for preview
21
+ Bash({ command: `start "${outputFile}"` }); // Windows
22
+ // Bash({ command: `open "${outputFile}"` }); // macOS
23
+
24
+ // Report to user
25
+ console.log(`
26
+ 📖 Manual Preview
27
+
28
+ File: ${buildReport.output}
29
+ Size: ${buildReport.size_human}
30
+ Sections: ${buildReport.sections}
31
+ Screenshots: ${buildReport.screenshots}
32
+
33
+ Please review the manual in your browser.
34
+ `);
35
+ ```
36
+
37
+ ### Step 2: Collect Feedback
38
+
39
+ ```javascript
40
+ const feedback = await AskUserQuestion({
41
+ questions: [
42
+ {
43
+ question: "How does the manual look overall?",
44
+ header: "Overall",
45
+ options: [
46
+ { label: "Looks great!", description: "Ready to finalize" },
47
+ { label: "Minor issues", description: "Small tweaks needed" },
48
+ { label: "Major issues", description: "Significant changes required" },
49
+ { label: "Missing content", description: "Need to add more sections" }
50
+ ],
51
+ multiSelect: false
52
+ },
53
+ {
54
+ question: "Which aspects need improvement? (Select all that apply)",
55
+ header: "Improvements",
56
+ options: [
57
+ { label: "Content accuracy", description: "Fix incorrect information" },
58
+ { label: "More examples", description: "Add more code examples" },
59
+ { label: "Better screenshots", description: "Retake or add screenshots" },
60
+ { label: "Styling/Layout", description: "Improve visual appearance" }
61
+ ],
62
+ multiSelect: true
63
+ }
64
+ ]
65
+ });
66
+ ```
67
+
68
+ ### Step 3: Address Feedback
69
+
70
+ Based on feedback, take appropriate action:
71
+
72
+ #### Minor Issues
73
+
74
+ ```javascript
75
+ if (feedback.overall === "Minor issues") {
76
+ // Prompt for specific changes
77
+ const details = await AskUserQuestion({
78
+ questions: [{
79
+ question: "What specific changes are needed?",
80
+ header: "Details",
81
+ options: [
82
+ { label: "Typo fixes", description: "Fix spelling/grammar" },
83
+ { label: "Reorder sections", description: "Change section order" },
84
+ { label: "Update content", description: "Modify existing text" },
85
+ { label: "Custom changes", description: "I'll describe the changes" }
86
+ ],
87
+ multiSelect: true
88
+ }]
89
+ });
90
+
91
+ // Apply changes based on user input
92
+ applyMinorChanges(details);
93
+ }
94
+ ```
95
+
96
+ #### Major Issues
97
+
98
+ ```javascript
99
+ if (feedback.overall === "Major issues") {
100
+ // Return to relevant phase
101
+ console.log(`
102
+ Major issues require returning to an earlier phase:
103
+
104
+ - Content issues → Phase 3 (Parallel Analysis)
105
+ - Screenshot issues → Phase 4 (Screenshot Capture)
106
+ - Structure issues → Phase 2 (Project Exploration)
107
+
108
+ Which phase should we return to?
109
+ `);
110
+
111
+ const phase = await selectPhase();
112
+ return { action: 'restart', from_phase: phase };
113
+ }
114
+ ```
115
+
116
+ #### Missing Content
117
+
118
+ ```javascript
119
+ if (feedback.overall === "Missing content") {
120
+ // Identify missing sections
121
+ const missing = await AskUserQuestion({
122
+ questions: [{
123
+ question: "What content is missing?",
124
+ header: "Missing",
125
+ options: [
126
+ { label: "API endpoints", description: "More API documentation" },
127
+ { label: "UI features", description: "Additional UI guides" },
128
+ { label: "Examples", description: "More code examples" },
129
+ { label: "Troubleshooting", description: "More FAQ items" }
130
+ ],
131
+ multiSelect: true
132
+ }]
133
+ });
134
+
135
+ // Run additional agent(s) for missing content
136
+ await runSupplementaryAgents(missing);
137
+ }
138
+ ```
139
+
140
+ ### Step 4: Save Iteration
141
+
142
+ ```javascript
143
+ // Save current version before changes
144
+ const iterationNum = getNextIterationNumber(workDir);
145
+ const iterationDir = `${workDir}/iterations`;
146
+
147
+ // Copy current version
148
+ Bash({ command: `copy "${outputFile}" "${iterationDir}\\v${iterationNum}.html"` });
149
+
150
+ // Log iteration
151
+ const iterationLog = {
152
+ version: iterationNum,
153
+ timestamp: new Date().toISOString(),
154
+ feedback: feedback,
155
+ changes: appliedChanges
156
+ };
157
+
158
+ Write(`${iterationDir}/iteration-${iterationNum}.json`, JSON.stringify(iterationLog, null, 2));
159
+ ```
160
+
161
+ ### Step 5: Regenerate if Needed
162
+
163
+ ```javascript
164
+ if (changesApplied) {
165
+ // Re-run HTML assembly with updated sections
166
+ await runPhase('05-html-assembly');
167
+
168
+ // Open updated preview
169
+ Bash({ command: `start "${outputFile}"` });
170
+ }
171
+ ```
172
+
173
+ ### Step 6: Finalize
174
+
175
+ When user approves:
176
+
177
+ ```javascript
178
+ if (feedback.overall === "Looks great!") {
179
+ // Final quality check
180
+ const finalReport = {
181
+ ...buildReport,
182
+ iterations: iterationNum,
183
+ finalized_at: new Date().toISOString(),
184
+ quality_score: calculateFinalQuality()
185
+ };
186
+
187
+ Write(`${workDir}/final-report.json`, JSON.stringify(finalReport, null, 2));
188
+
189
+ // Suggest final location
190
+ console.log(`
191
+ ✅ Manual Finalized!
192
+
193
+ Output: ${buildReport.output}
194
+ Size: ${buildReport.size_human}
195
+ Quality: ${finalReport.quality_score}%
196
+ Iterations: ${iterationNum}
197
+
198
+ Suggested actions:
199
+ 1. Copy to project root: copy "${outputFile}" "docs/"
200
+ 2. Add to version control
201
+ 3. Publish to documentation site
202
+ `);
203
+
204
+ return { status: 'completed', output: outputFile };
205
+ }
206
+ ```
207
+
208
+ ## Iteration History
209
+
210
+ Each iteration is logged:
211
+
212
+ ```
213
+ iterations/
214
+ ├── v1.html # First version
215
+ ├── iteration-1.json # Feedback and changes
216
+ ├── v2.html # After first iteration
217
+ ├── iteration-2.json # Feedback and changes
218
+ └── ...
219
+ ```
220
+
221
+ ## Quality Metrics
222
+
223
+ Track improvement across iterations:
224
+
225
+ ```javascript
226
+ const qualityMetrics = {
227
+ content_completeness: 0, // All sections present
228
+ screenshot_coverage: 0, // Screenshots for all UI
229
+ example_diversity: 0, // Different difficulty levels
230
+ search_accuracy: 0, // Search returns relevant results
231
+ user_satisfaction: 0 // Based on feedback
232
+ };
233
+ ```
234
+
235
+ ## Exit Conditions
236
+
237
+ The refinement phase ends when:
238
+ 1. User explicitly approves ("Looks great!")
239
+ 2. Maximum iterations reached (configurable, default: 5)
240
+ 3. Quality score exceeds threshold (default: 90%)
241
+
242
+ ## Output
243
+
244
+ - **Final HTML**: `{软件名}-使用手册.html`
245
+ - **Final Report**: `final-report.json`
246
+ - **Iteration History**: `iterations/`
247
+
248
+ ## Completion
249
+
250
+ When finalized, the skill is complete. Final output location:
251
+
252
+ ```
253
+ .workflow/.scratchpad/manual-{timestamp}/
254
+ ├── {软件名}-使用手册.html ← Final deliverable
255
+ ├── final-report.json
256
+ └── iterations/
257
+ ```
258
+
259
+ Consider copying to a permanent location like `docs/` or project root.
@@ -0,0 +1,245 @@
1
+ # API 文档提取脚本
2
+
3
+ 根据项目类型自动提取 API 文档,支持 FastAPI、Next.js、Python 模块。
4
+
5
+ ## 支持的技术栈
6
+
7
+ | 类型 | 技术栈 | 工具 | 输出格式 |
8
+ |------|--------|------|----------|
9
+ | Backend | FastAPI | openapi-to-md | Markdown |
10
+ | Frontend | Next.js/TypeScript | TypeDoc | Markdown |
11
+ | Python Module | Python | pdoc | Markdown/HTML |
12
+
13
+ ## 使用方法
14
+
15
+ ### 1. FastAPI Backend (OpenAPI)
16
+
17
+ ```bash
18
+ # 提取 OpenAPI JSON
19
+ cd D:/dongdiankaifa9/backend
20
+ python -c "
21
+ from app.main import app
22
+ import json
23
+ print(json.dumps(app.openapi(), indent=2))
24
+ " > api-docs/openapi.json
25
+
26
+ # 转换为 Markdown (使用 widdershins)
27
+ npx widdershins api-docs/openapi.json -o api-docs/API_REFERENCE.md --language_tabs 'python:Python' 'javascript:JavaScript' 'bash:cURL'
28
+ ```
29
+
30
+ **备选方案 (无需启动服务)**:
31
+ ```python
32
+ # scripts/extract_fastapi_openapi.py
33
+ import sys
34
+ sys.path.insert(0, 'D:/dongdiankaifa9/backend')
35
+
36
+ from app.main import app
37
+ import json
38
+
39
+ openapi_schema = app.openapi()
40
+ with open('api-docs/openapi.json', 'w', encoding='utf-8') as f:
41
+ json.dump(openapi_schema, f, indent=2, ensure_ascii=False)
42
+
43
+ print(f"Extracted {len(openapi_schema.get('paths', {}))} endpoints")
44
+ ```
45
+
46
+ ### 2. Next.js Frontend (TypeDoc)
47
+
48
+ ```bash
49
+ cd D:/dongdiankaifa9/frontend
50
+
51
+ # 安装 TypeDoc
52
+ npm install --save-dev typedoc typedoc-plugin-markdown
53
+
54
+ # 生成文档
55
+ npx typedoc --plugin typedoc-plugin-markdown \
56
+ --out api-docs \
57
+ --entryPoints "./lib" "./hooks" "./components" \
58
+ --entryPointStrategy expand \
59
+ --exclude "**/node_modules/**" \
60
+ --exclude "**/*.test.*" \
61
+ --readme none
62
+ ```
63
+
64
+ **typedoc.json 配置**:
65
+ ```json
66
+ {
67
+ "$schema": "https://typedoc.org/schema.json",
68
+ "entryPoints": ["./lib", "./hooks", "./components"],
69
+ "entryPointStrategy": "expand",
70
+ "out": "api-docs",
71
+ "plugin": ["typedoc-plugin-markdown"],
72
+ "exclude": ["**/node_modules/**", "**/*.test.*", "**/*.spec.*"],
73
+ "excludePrivate": true,
74
+ "excludeInternal": true,
75
+ "readme": "none",
76
+ "name": "Frontend API Reference"
77
+ }
78
+ ```
79
+
80
+ ### 3. Python Module (pdoc)
81
+
82
+ ```bash
83
+ # 安装 pdoc
84
+ pip install pdoc
85
+
86
+ # hydro_generator_module
87
+ cd D:/dongdiankaifa9
88
+ pdoc hydro_generator_module \
89
+ --output-dir api-docs/hydro_generator \
90
+ --format markdown \
91
+ --no-show-source
92
+
93
+ # multiphysics_network
94
+ pdoc multiphysics_network \
95
+ --output-dir api-docs/multiphysics \
96
+ --format markdown \
97
+ --no-show-source
98
+ ```
99
+
100
+ **备选: Sphinx (更强大)**:
101
+ ```bash
102
+ # 安装 Sphinx
103
+ pip install sphinx sphinx-markdown-builder
104
+
105
+ # 生成 API 文档
106
+ sphinx-apidoc -o docs/source hydro_generator_module
107
+ cd docs && make markdown
108
+ ```
109
+
110
+ ## 集成脚本
111
+
112
+ ```python
113
+ #!/usr/bin/env python3
114
+ # scripts/extract_all_apis.py
115
+
116
+ import subprocess
117
+ import sys
118
+ from pathlib import Path
119
+
120
+ PROJECTS = {
121
+ 'backend': {
122
+ 'path': 'D:/dongdiankaifa9/backend',
123
+ 'type': 'fastapi',
124
+ 'output': 'api-docs/backend'
125
+ },
126
+ 'frontend': {
127
+ 'path': 'D:/dongdiankaifa9/frontend',
128
+ 'type': 'typescript',
129
+ 'output': 'api-docs/frontend'
130
+ },
131
+ 'hydro_generator_module': {
132
+ 'path': 'D:/dongdiankaifa9/hydro_generator_module',
133
+ 'type': 'python',
134
+ 'output': 'api-docs/hydro_generator'
135
+ },
136
+ 'multiphysics_network': {
137
+ 'path': 'D:/dongdiankaifa9/multiphysics_network',
138
+ 'type': 'python',
139
+ 'output': 'api-docs/multiphysics'
140
+ }
141
+ }
142
+
143
+ def extract_fastapi(config):
144
+ """提取 FastAPI OpenAPI 文档"""
145
+ path = Path(config['path'])
146
+ sys.path.insert(0, str(path))
147
+
148
+ try:
149
+ from app.main import app
150
+ import json
151
+
152
+ output_dir = Path(config['output'])
153
+ output_dir.mkdir(parents=True, exist_ok=True)
154
+
155
+ # 导出 OpenAPI JSON
156
+ with open(output_dir / 'openapi.json', 'w', encoding='utf-8') as f:
157
+ json.dump(app.openapi(), f, indent=2, ensure_ascii=False)
158
+
159
+ print(f"✓ FastAPI: {len(app.openapi().get('paths', {}))} endpoints")
160
+ return True
161
+ except Exception as e:
162
+ print(f"✗ FastAPI error: {e}")
163
+ return False
164
+
165
+ def extract_typescript(config):
166
+ """提取 TypeScript 文档"""
167
+ try:
168
+ subprocess.run([
169
+ 'npx', 'typedoc',
170
+ '--plugin', 'typedoc-plugin-markdown',
171
+ '--out', config['output'],
172
+ '--entryPoints', './lib', './hooks',
173
+ '--entryPointStrategy', 'expand'
174
+ ], cwd=config['path'], check=True)
175
+ print(f"✓ TypeDoc: {config['path']}")
176
+ return True
177
+ except Exception as e:
178
+ print(f"✗ TypeDoc error: {e}")
179
+ return False
180
+
181
+ def extract_python(config):
182
+ """提取 Python 模块文档"""
183
+ try:
184
+ module_name = Path(config['path']).name
185
+ subprocess.run([
186
+ 'pdoc', module_name,
187
+ '--output-dir', config['output'],
188
+ '--format', 'markdown'
189
+ ], cwd=Path(config['path']).parent, check=True)
190
+ print(f"✓ pdoc: {module_name}")
191
+ return True
192
+ except Exception as e:
193
+ print(f"✗ pdoc error: {e}")
194
+ return False
195
+
196
+ EXTRACTORS = {
197
+ 'fastapi': extract_fastapi,
198
+ 'typescript': extract_typescript,
199
+ 'python': extract_python
200
+ }
201
+
202
+ if __name__ == '__main__':
203
+ for name, config in PROJECTS.items():
204
+ print(f"\n[{name}]")
205
+ extractor = EXTRACTORS.get(config['type'])
206
+ if extractor:
207
+ extractor(config)
208
+ ```
209
+
210
+ ## Phase 3 集成
211
+
212
+ 在 `api-reference` Agent 提示词中添加:
213
+
214
+ ```
215
+ [PRE-EXTRACTION]
216
+ 运行 API 提取脚本获取结构化文档:
217
+ - python scripts/extract_all_apis.py
218
+
219
+ [INPUT FILES]
220
+ - api-docs/backend/openapi.json (FastAPI endpoints)
221
+ - api-docs/frontend/*.md (TypeDoc output)
222
+ - api-docs/hydro_generator/*.md (pdoc output)
223
+ - api-docs/multiphysics/*.md (pdoc output)
224
+ ```
225
+
226
+ ## 输出结构
227
+
228
+ ```
229
+ api-docs/
230
+ ├── backend/
231
+ │ ├── openapi.json # Raw OpenAPI spec
232
+ │ └── API_REFERENCE.md # Converted Markdown
233
+ ├── frontend/
234
+ │ ├── modules.md
235
+ │ ├── functions.md
236
+ │ └── classes/
237
+ ├── hydro_generator/
238
+ │ ├── assembler.md
239
+ │ ├── blueprint.md
240
+ │ └── builders/
241
+ └── multiphysics/
242
+ ├── analysis_domain.md
243
+ ├── builders.md
244
+ └── compilers.md
245
+ ```