Skip to content

Commit fb4f6e7

Browse files
author
catlog22
committed
feat: Implement DeepWiki documentation generation tools
- Added `__init__.py` in `codexlens/tools` for documentation generation. - Created `deepwiki_generator.py` to handle symbol extraction and markdown generation. - Introduced `MockMarkdownGenerator` for testing purposes. - Implemented `DeepWikiGenerator` class for managing documentation generation and file processing. - Added unit tests for `DeepWikiStore` to ensure proper functionality and error handling. - Created tests for DeepWiki TypeScript types matching.
1 parent 0bfae3f commit fb4f6e7

62 files changed

Lines changed: 7503 additions & 71 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/commands/workflow/analyze-with-file.md

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,32 @@ Session: ${sessionFolder}
238238
239239
## MANDATORY FIRST STEPS
240240
1. Run: ccw tool exec get_modules_by_depth '{}'
241-
2. Execute relevant searches based on topic keywords
242-
3. Read: .workflow/project-tech.json (if exists)
241+
2. Read: .workflow/project-tech.json (if exists)
242+
243+
## Layered Exploration (MUST follow all 3 layers)
244+
245+
### Layer 1 — Module Discovery (Breadth)
246+
- Search codebase by topic keywords, identify ALL relevant files
247+
- Map module boundaries and entry points
248+
- Output: relevant_files[] with file role annotations
249+
250+
### Layer 2 — Structure Tracing (Depth)
251+
- For top 3-5 key files from Layer 1: trace call chains (2-3 levels deep)
252+
- Identify data flow paths and dependency relationships
253+
- Output: call_chains[], data_flows[]
254+
255+
### Layer 3 — Code Anchor Extraction (Detail)
256+
- For each key finding: extract the actual code snippet (20-50 lines) with file:line reference
257+
- Annotate WHY this code matters to the analysis topic
258+
- Output: code_anchors[] — these are CRITICAL for subsequent analysis quality
243259
244260
## Exploration Focus
245261
${dimensions.map(d => `- ${d}: Identify relevant code patterns and structures`).join('\n')}
246262
247263
## Output
248264
Write findings to: ${sessionFolder}/exploration-codebase.json
249265
250-
Schema: {relevant_files, patterns, key_findings, questions_for_user, _metadata}
266+
Schema: {relevant_files, patterns, key_findings, code_anchors: [{file, lines, snippet, significance}], call_chains: [{entry, chain, files}], questions_for_user, _metadata}
251267
`
252268
})
253269
```
@@ -268,16 +284,29 @@ Session: ${sessionFolder}
268284
269285
## MANDATORY FIRST STEPS
270286
1. Run: ccw tool exec get_modules_by_depth '{}'
271-
2. Execute searches focused on ${perspective.focus}
272-
3. Read: .workflow/project-tech.json (if exists)
287+
2. Read: .workflow/project-tech.json (if exists)
288+
289+
## Layered Exploration (${perspective.name} angle, MUST follow all 3 layers)
290+
291+
### Layer 1 — Module Discovery
292+
- Search codebase focused on ${perspective.focus}
293+
- Identify ALL relevant files for this perspective
294+
295+
### Layer 2 — Structure Tracing
296+
- For top 3-5 key files: trace call chains (2-3 levels deep)
297+
- Map data flows relevant to ${perspective.focus}
298+
299+
### Layer 3 — Code Anchor Extraction
300+
- For each key finding: extract actual code snippet (20-50 lines) with file:line
301+
- Annotate significance for ${perspective.name} analysis
273302
274303
## Exploration Focus (${perspective.name} angle)
275304
${perspective.exploration_tasks.map(t => `- ${t}`).join('\n')}
276305
277306
## Output
278307
Write findings to: ${sessionFolder}/explorations/${perspective.name}.json
279308
280-
Schema: {relevant_files, patterns, key_findings, perspective_insights, _metadata}
309+
Schema: {relevant_files, patterns, key_findings, code_anchors: [{file, lines, snippet, significance}], call_chains: [{entry, chain, files}], perspective_insights, _metadata}
281310
`
282311
})
283312
})
@@ -301,11 +330,14 @@ PRIOR EXPLORATION CONTEXT:
301330
- Key files: ${explorationResults.relevant_files.slice(0,5).map(f => f.path).join(', ')}
302331
- Patterns found: ${explorationResults.patterns.slice(0,3).join(', ')}
303332
- Key findings: ${explorationResults.key_findings.slice(0,3).join(', ')}
333+
- Code anchors (actual code snippets):
334+
${(explorationResults.code_anchors || []).slice(0,5).map(a => ` [${a.file}:${a.lines}] ${a.significance}\n \`\`\`\n ${a.snippet}\n \`\`\``).join('\n')}
335+
- Call chains: ${(explorationResults.call_chains || []).slice(0,3).map(c => `${c.entry}${c.chain.join('')}`).join('; ')}
304336
305337
TASK:
306-
• Build on exploration findings above
307-
• Analyze common patterns and anti-patterns
308-
• Highlight potential issues or opportunities
338+
• Build on exploration findings above — reference specific code anchors in analysis
339+
• Analyze common patterns and anti-patterns with code evidence
340+
• Highlight potential issues or opportunities with file:line references
309341
• Generate discussion points for user clarification
310342
311343
MODE: analysis
@@ -324,7 +356,10 @@ const explorationContext = `
324356
PRIOR EXPLORATION CONTEXT:
325357
- Key files: ${explorationResults.relevant_files.slice(0,5).map(f => f.path).join(', ')}
326358
- Patterns found: ${explorationResults.patterns.slice(0,3).join(', ')}
327-
- Key findings: ${explorationResults.key_findings.slice(0,3).join(', ')}`
359+
- Key findings: ${explorationResults.key_findings.slice(0,3).join(', ')}
360+
- Code anchors:
361+
${(explorationResults.code_anchors || []).slice(0,5).map(a => ` [${a.file}:${a.lines}] ${a.significance}`).join('\n')}
362+
- Call chains: ${(explorationResults.call_chains || []).slice(0,3).map(c => `${c.entry}${c.chain.join('')}`).join('; ')}`
328363

329364
// Launch parallel CLI calls based on selected perspectives (max 4)
330365
selectedPerspectives.forEach(perspective => {
@@ -368,6 +403,8 @@ CONSTRAINTS: ${perspective.constraints}
368403
- `dimensions[]`: Analysis dimensions
369404
- `sources[]`: {type, file/summary}
370405
- `key_findings[]`: Main insights
406+
- `code_anchors[]`: {file, lines, snippet, significance}
407+
- `call_chains[]`: {entry, chain, files}
371408
- `discussion_points[]`: Questions for user
372409
- `open_questions[]`: Unresolved questions
373410

@@ -378,7 +415,9 @@ CONSTRAINTS: ${perspective.constraints}
378415
- `dimensions[]`: Analysis dimensions
379416
- `perspectives[]`: [{name, tool, findings, insights, questions}]
380417
- `synthesis`: {convergent_themes, conflicting_views, unique_contributions}
381-
- `aggregated_findings[]`: Main insights across perspectives
418+
- `key_findings[]`: Main insights across perspectives
419+
- `code_anchors[]`: {file, lines, snippet, significance, perspective}
420+
- `call_chains[]`: {entry, chain, files, perspective}
382421
- `discussion_points[]`: Questions for user
383422
- `open_questions[]`: Unresolved questions
384423

@@ -423,9 +462,14 @@ CONSTRAINTS: ${perspective.constraints}
423462
- If direction changed, record a full Decision Record
424463

425464
**Agree, Deepen**:
426-
- Continue analysis in current direction
427-
- Use CLI for deeper exploration
428-
- **📌 Record**: Which assumptions were confirmed, specific angles for deeper exploration
465+
- AskUserQuestion for deepen direction (single-select):
466+
- **代码细节**: Read specific files, trace call chains deeper → cli-explore-agent with targeted file list
467+
- **边界条件**: Analyze error handling, edge cases, failure paths → Gemini CLI focused on error paths
468+
- **替代方案**: Compare different implementation approaches → Gemini CLI comparative analysis
469+
- **性能/安全**: Analyze hot paths, complexity, or security vectors → cli-explore-agent + domain prompt
470+
- Launch new cli-explore-agent or CLI call with **narrower scope + deeper depth requirement**
471+
- Merge new code_anchors and call_chains into existing exploration results
472+
- **📌 Record**: Which assumptions were confirmed, specific angles for deeper exploration, deepen direction chosen
429473

430474
**Adjust Direction**:
431475
- AskUserQuestion for adjusted focus (code details / architecture / best practices)
@@ -471,7 +515,10 @@ CONSTRAINTS: ${perspective.constraints}
471515

472516
| User Choice | Action | Tool | Description |
473517
|-------------|--------|------|-------------|
474-
| Deepen | Continue current direction | Gemini CLI | Deeper analysis in same focus |
518+
| Deepen → 代码细节 | Read files, trace call chains | cli-explore-agent | Targeted deep-dive into specific files |
519+
| Deepen → 边界条件 | Analyze error/edge cases | Gemini CLI | Focus on failure paths and edge cases |
520+
| Deepen → 替代方案 | Compare approaches | Gemini CLI | Comparative analysis |
521+
| Deepen → 性能/安全 | Analyze hot paths/vectors | cli-explore-agent | Domain-specific deep analysis |
475522
| Adjust | Change analysis angle | Selected CLI | New exploration with adjusted scope |
476523
| Questions | Answer specific questions | CLI or analysis | Address user inquiries |
477524
| Complete | Exit discussion loop | - | Proceed to synthesis |
@@ -629,7 +676,8 @@ DO NOT reference any analyze-with-file phase instructions beyond this point.
629676
- `completed`: Completion timestamp
630677
- `total_rounds`: Number of discussion rounds
631678
- `summary`: Executive summary
632-
- `key_conclusions[]`: {point, evidence, confidence}
679+
- `key_conclusions[]`: {point, evidence, confidence, code_anchor_refs[]}
680+
- `code_anchors[]`: {file, lines, snippet, significance}
633681
- `recommendations[]`: {action, rationale, priority}
634682
- `open_questions[]`: Unresolved questions
635683
- `follow_up_suggestions[]`: {type, summary}

.claude/skills/spec-generator/README.md

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,74 @@ Structured specification document generator producing a complete document chain
1717
spec-generator/
1818
|- SKILL.md # Entry point: metadata + architecture + flow
1919
|- phases/
20-
| |- 01-discovery.md # Seed analysis + codebase exploration
21-
| |- 02-product-brief.md # Multi-CLI product brief generation
22-
| |- 03-requirements.md # PRD with MoSCoW priorities
23-
| |- 04-architecture.md # Architecture decisions + review
20+
| |- 01-discovery.md # Seed analysis + codebase exploration + spec type selection
21+
| |- 01-5-requirement-clarification.md # Interactive requirement expansion
22+
| |- 02-product-brief.md # Multi-CLI product brief + glossary generation
23+
| |- 03-requirements.md # PRD with MoSCoW priorities + RFC 2119 constraints
24+
| |- 04-architecture.md # Architecture + state machine + config model + observability
2425
| |- 05-epics-stories.md # Epic/Story decomposition
25-
| |- 06-readiness-check.md # Quality validation + handoff
26+
| |- 06-readiness-check.md # Quality validation + handoff + iterate option
27+
| |- 06-5-auto-fix.md # Auto-fix loop for readiness issues (max 2 iterations)
2628
|- specs/
2729
| |- document-standards.md # Format, frontmatter, naming rules
28-
| |- quality-gates.md # Per-phase quality criteria
30+
| |- quality-gates.md # Per-phase quality criteria + iteration tracking
31+
| |- glossary-template.json # Terminology glossary schema
2932
|- templates/
30-
| |- product-brief.md # Product brief template
33+
| |- product-brief.md # Product brief template (+ Concepts & Non-Goals)
3134
| |- requirements-prd.md # PRD template
32-
| |- architecture-doc.md # Architecture document template
33-
| |- epics-template.md # Epic/Story template
35+
| |- architecture-doc.md # Architecture template (+ state machine, config, observability)
36+
| |- epics-template.md # Epic/Story template (+ versioning)
37+
| |- profiles/ # Spec type specialization profiles
38+
| |- service-profile.md # Service spec: lifecycle, observability, trust
39+
| |- api-profile.md # API spec: endpoints, auth, rate limiting
40+
| |- library-profile.md # Library spec: public API, examples, compatibility
3441
|- README.md # This file
3542
```
3643

3744
## 6-Phase Pipeline
3845

39-
| Phase | Name | Output | CLI Tools |
40-
|-------|------|--------|-----------|
41-
| 1 | Discovery | spec-config.json | Gemini (analysis) |
42-
| 2 | Product Brief | product-brief.md | Gemini + Codex + Claude (parallel) |
43-
| 3 | Requirements | requirements.md | Gemini (analysis) |
44-
| 4 | Architecture | architecture.md | Gemini + Codex (sequential) |
45-
| 5 | Epics & Stories | epics.md | Gemini (analysis) |
46-
| 6 | Readiness Check | readiness-report.md, spec-summary.md | Gemini (validation) |
46+
| Phase | Name | Output | CLI Tools | Key Features |
47+
|-------|------|--------|-----------|-------------|
48+
| 1 | Discovery | spec-config.json | Gemini (analysis) | Spec type selection |
49+
| 1.5 | Req Expansion | refined-requirements.json | Gemini (analysis) | Multi-round interactive |
50+
| 2 | Product Brief | product-brief.md, glossary.json | Gemini + Codex + Claude (parallel) | Terminology glossary |
51+
| 3 | Requirements | requirements/ | Gemini (analysis) | RFC 2119, data model |
52+
| 4 | Architecture | architecture/ | Gemini + Codex (sequential) | State machine, config, observability |
53+
| 5 | Epics & Stories | epics/ | Gemini (analysis) | Glossary consistency |
54+
| 6 | Readiness Check | readiness-report.md, spec-summary.md | Gemini (validation) | Terminology + scope validation |
55+
| 6.5 | Auto-Fix | Updated phase docs | Gemini (analysis) | Max 2 iterations |
4756

4857
## Runtime Output
4958

5059
```
5160
.workflow/.spec/SPEC-{slug}-{YYYY-MM-DD}/
5261
|- spec-config.json # Session state
5362
|- discovery-context.json # Codebase context (optional)
63+
|- refined-requirements.json # Phase 1.5 (requirement expansion)
64+
|- glossary.json # Phase 2 (terminology)
5465
|- product-brief.md # Phase 2
55-
|- requirements.md # Phase 3
56-
|- architecture.md # Phase 4
57-
|- epics.md # Phase 5
66+
|- requirements/ # Phase 3 (directory)
67+
| |- _index.md
68+
| |- REQ-*.md
69+
| └── NFR-*.md
70+
|- architecture/ # Phase 4 (directory)
71+
| |- _index.md
72+
| └── ADR-*.md
73+
|- epics/ # Phase 5 (directory)
74+
| |- _index.md
75+
| └── EPIC-*.md
5876
|- readiness-report.md # Phase 6
59-
|- spec-summary.md # Phase 6
77+
└── spec-summary.md # Phase 6
6078
```
6179

6280
## Flags
6381

6482
- `-y|--yes`: Auto mode - skip all interactive confirmations
6583
- `-c|--continue`: Resume from last completed phase
6684

85+
Spec type is selected interactively in Phase 1 (defaults to `service` in auto mode)
86+
Available types: `service`, `api`, `library`, `platform`
87+
6788
## Handoff
6889

6990
After Phase 6, choose execution path:
@@ -79,3 +100,6 @@ After Phase 6, choose execution path:
79100
- **Template-driven**: Consistent format via templates + frontmatter
80101
- **Resumable**: spec-config.json tracks completed phases
81102
- **Pure documentation**: No code generation - clean handoff to execution workflows
103+
- **Type-specialized**: Profiles adapt templates to service/api/library/platform requirements
104+
- **Iterative quality**: Phase 6.5 auto-fix repairs issues, max 2 iterations before handoff
105+
- **Terminology-first**: glossary.json ensures consistent terminology across all documents

0 commit comments

Comments
 (0)