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.
This commit is contained in:
catlog22
2026-03-05 18:30:56 +08:00
parent 0bfae3fd1a
commit fb4f6e718e
62 changed files with 7500 additions and 68 deletions

View File

@@ -264,9 +264,15 @@ AskUserQuestion({
│ └── test-report.md ← tester output
├── explorations/ ← explorer cache
│ └── cache-index.json
└── wisdom/ ← Knowledge base
├── ui-patterns.md
── state-management.md
└── wisdom/ ← Session knowledge base
├── contributions/ ← Worker contributions (write-only for workers)
── principles/ ← Core principles
│ └── general-ux.md
├── patterns/ ← Solution patterns
│ ├── ui-feedback.md
│ └── state-management.md
└── anti-patterns/ ← Issues to avoid
└── common-ux-pitfalls.md
```
## Error Handling

View File

@@ -22,6 +22,13 @@ Design feedback mechanisms (loading/error/success states) and state management p
| React | useState, useRef | onClick, onChange |
| Vue | ref, reactive | @click, @change |
### Wisdom Input
1. Read `<session>/wisdom/patterns/ui-feedback.md` for established feedback design patterns
2. Read `<session>/wisdom/patterns/state-management.md` for state handling patterns
3. Read `<session>/wisdom/principles/general-ux.md` for UX design principles
4. Apply patterns when designing solutions for identified issues
### Complex Design (use CLI)
For complex multi-component solutions:
@@ -166,6 +173,13 @@ const handleUpload = async (event: React.FormEvent) => {
```
2. Write guide to `<session>/artifacts/design-guide.md`
### Wisdom Contribution
If novel design patterns created:
1. Write new patterns to `<session>/wisdom/contributions/designer-pattern-<timestamp>.md`
2. Format: Problem context, solution design, implementation hints, trade-offs
3. Share state via team_msg:
```
team_msg(operation="log", session_id=<session-id>, from="designer",

View File

@@ -14,6 +14,13 @@ Diagnose root causes of UI issues: state management problems, event binding fail
1. Load scan report from `<session>/artifacts/scan-report.md`
2. Load scanner state via `team_msg(operation="get_state", session_id=<session-id>, role="scanner")`
### Wisdom Input
1. Read `<session>/wisdom/patterns/ui-feedback.md` and `<session>/wisdom/patterns/state-management.md` if available
2. Use patterns to identify root causes of UI interaction issues
3. Reference `<session>/wisdom/anti-patterns/common-ux-pitfalls.md` for common causes
3. Assess issue complexity:
| Complexity | Criteria | Strategy |
@@ -82,6 +89,13 @@ For each issue from scan report:
```
2. Write report to `<session>/artifacts/diagnosis.md`
### Wisdom Contribution
If new root cause patterns discovered:
1. Write diagnosis patterns to `<session>/wisdom/contributions/diagnoser-patterns-<timestamp>.md`
2. Format: Symptom, root cause, detection method, fix approach
3. Share state via team_msg:
```
team_msg(operation="log", session_id=<session-id>, from="diagnoser",

View File

@@ -15,6 +15,12 @@ Explore codebase for UI component patterns, state management conventions, and fr
1. Parse exploration request from task description
2. Determine file patterns based on framework:
### Wisdom Input
1. Read `<session>/wisdom/patterns/ui-feedback.md` and `<session>/wisdom/patterns/state-management.md` if available
2. Use known patterns as reference when exploring codebase for component structures
3. Check `<session>/wisdom/anti-patterns/common-ux-pitfalls.md` to identify problematic patterns during exploration
| Framework | Patterns |
|-----------|----------|
| React | `**/*.tsx`, `**/*.jsx`, `**/use*.ts`, `**/store*.ts` |
@@ -80,6 +86,18 @@ For each dimension, collect:
2. Cache results to `<session>/explorations/cache-index.json`
3. Write summary to `<session>/explorations/exploration-summary.md`
### Wisdom Contribution
If new component patterns or framework conventions discovered:
1. Write pattern summaries to `<session>/wisdom/contributions/explorer-patterns-<timestamp>.md`
2. Format:
- Pattern Name: Descriptive name
- Framework: React/Vue/etc.
- Use Case: When to apply this pattern
- Code Example: Representative snippet
- Adoption: How widely used in codebase
4. Share state via team_msg:
```
team_msg(operation="log", session_id=<session-id>, from="explorer",

View File

@@ -15,7 +15,12 @@ Generate executable fix code with proper state management, event handling, and U
1. Extract session path from task description
2. Read design guide: `<session>/artifacts/design-guide.md`
3. Extract implementation tasks from design guide
4. Load framework conventions from wisdom files (if available)
4. **Wisdom Input**:
- Read `<session>/wisdom/patterns/state-management.md` for state handling patterns
- Read `<session>/wisdom/patterns/ui-feedback.md` for UI feedback implementation patterns
- Read `<session>/wisdom/principles/general-ux.md` for implementation principles
- Load framework-specific conventions if available
- Apply these patterns and principles when generating code to ensure consistency and quality
5. **For inner loop**: Load context_accumulator from prior IMPL tasks
### Context Accumulator (Inner Loop)
@@ -123,3 +128,37 @@ team_msg(operation="log", session_id=<session-id>, from="implementer",
validation_passed: true
})
```
### Wisdom Contribution
If reusable code patterns or snippets created:
1. Write code snippets to `<session>/wisdom/contributions/implementer-snippets-<timestamp>.md`
2. Format: Use case, code snippet with comments, framework compatibility notes
Example contribution format:
```markdown
# Implementer Snippets - <timestamp>
## Loading State Pattern (React)
### Use Case
Async operations requiring loading indicator
### Code Snippet
```tsx
const [isLoading, setIsLoading] = useState(false);
const handleAsyncAction = async () => {
setIsLoading(true);
try {
await performAction();
} finally {
setIsLoading(false);
}
};
```
### Framework Compatibility
- React 16.8+ (hooks)
- Next.js compatible
```

View File

@@ -32,6 +32,12 @@ Scan UI components to identify interaction issues: unresponsive buttons, missing
- React: `**/*.tsx`, `**/*.jsx`, `**/use*.ts`
- Vue: `**/*.vue`, `**/composables/*.ts`
### Wisdom Input
1. Read `<session>/wisdom/anti-patterns/common-ux-pitfalls.md` if available
2. Use anti-patterns to identify known UX issues during scanning
3. Check `<session>/wisdom/patterns/ui-feedback.md` for expected feedback patterns
### Complex Analysis (use CLI)
For large projects with many components:
@@ -103,3 +109,9 @@ For each component file:
scanned_files: <count>
})
```
### Wisdom Contribution
If novel UX issues discovered that aren't in anti-patterns:
1. Write findings to `<session>/wisdom/contributions/scanner-issues-<timestamp>.md`
2. Format: Issue description, detection criteria, affected components

View File

@@ -29,6 +29,12 @@ Generate and run tests to verify fixes (loading states, error handling, state up
3. Load test strategy from design guide
### Wisdom Input
1. Read `<session>/wisdom/anti-patterns/common-ux-pitfalls.md` for common issues to test
2. Read `<session>/wisdom/patterns/ui-feedback.md` for expected feedback behaviors to verify
3. Use wisdom to design comprehensive test cases covering known edge cases
## Phase 3: Test Generation & Execution
### Test Generation
@@ -96,6 +102,12 @@ Iterative test-fix cycle (max 5 iterations):
## Phase 4: Test Report
### Wisdom Contribution
If new edge cases or test patterns discovered:
1. Write test findings to `<session>/wisdom/contributions/tester-edge-cases-<timestamp>.md`
2. Format: Edge case description, test scenario, expected behavior, actual behavior
Generate test report:
```markdown

View File

@@ -114,6 +114,23 @@ For callback/check/resume: load `commands/monitor.md` and execute handler, then
```
3. TeamCreate(team_name="ux-improve")
4. Initialize meta.json with pipeline config:
### Wisdom Initialization
After creating session directory, initialize wisdom from skill's permanent knowledge base:
1. Copy `.claude/skills/team-ux-improve/wisdom/` contents to `<session>/wisdom/`
2. Create `<session>/wisdom/contributions/` directory if not exists
3. This provides workers with initial patterns, principles, and anti-patterns
Example:
```bash
# Copy permanent wisdom to session
cp -r .claude/skills/team-ux-improve/wisdom/* <session>/wisdom/
mkdir -p <session>/wisdom/contributions/
```
5. Initialize meta.json with pipeline config:
```
team_msg(operation="log", session_id=<session-id>, from="coordinator",
type="state_update",
@@ -182,6 +199,32 @@ Execute built-in Phase 1 (task discovery) -> role-spec Phase 2-4 -> built-in Pha
- artifacts/design-guide.md
- artifacts/fixes/
- artifacts/test-report.md
### Wisdom Consolidation
Before pipeline completion, handle knowledge contributions:
1. Check if `<session>/wisdom/contributions/` has any files
2. If contributions exist:
- Summarize contributions for user review
- Use AskUserQuestion to ask if user wants to merge valuable contributions back to permanent wisdom
- If approved, copy selected contributions to `.claude/skills/team-ux-improve/wisdom/` (classify into patterns/, anti-patterns/, etc.)
Example interaction:
```
AskUserQuestion({
questions: [{
question: "Workers contributed new knowledge during this session. Merge to permanent wisdom?",
header: "Knowledge",
options: [
{ label: "Merge All", description: "Add all contributions to permanent wisdom" },
{ label: "Review First", description: "Show contributions before deciding" },
{ label: "Skip", description: "Keep contributions in session only" }
]
}]
})
```
3. **Completion Action** (interactive mode):
```

View File

@@ -0,0 +1,17 @@
# Common UX Pitfalls
## Interaction Issues
- Buttons without loading states during async operations
- Missing error handling with user feedback
- State changes without visual updates
- Double-click vulnerabilities
## State Issues
- Stale data after mutations
- Race conditions in async operations
- Missing rollback for failed optimistic updates
## Feedback Issues
- Silent failures without user notification
- Generic error messages without actionable guidance
- Missing confirmation for destructive actions

View File

@@ -0,0 +1,14 @@
# State Management Patterns
## Local Component State
- Use for UI-only state (open/closed, hover, focus)
- Keep close to where it's used
## Shared State
- Lift state to lowest common ancestor
- Use context or state management library for deep trees
## Async State
- Track loading, error, and success states
- Handle race conditions with request cancellation
- Implement retry logic with exponential backoff

View File

@@ -0,0 +1,16 @@
# UI Feedback Patterns
## Loading States
- Use skeleton loaders for content areas
- Disable buttons during async operations
- Show progress indicators for long operations
## Error Handling
- Display errors inline when possible
- Provide actionable error messages
- Allow retry for transient failures
## Success Feedback
- Toast notifications for non-critical successes
- Inline confirmation for critical actions
- Auto-dismiss non-critical notifications

View File

@@ -0,0 +1,16 @@
# General UX Principles
## Feedback & Responsiveness
- Every user action should have immediate visual feedback
- Loading states must be shown for operations >200ms
- Success/error states should be clearly communicated
## State Management
- UI state should reflect the underlying data state
- Optimistic updates should have rollback mechanisms
- State changes should be atomic and predictable
## Accessibility
- Interactive elements must be keyboard accessible
- Color should not be the only indicator of state
- Focus states must be visible