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

@@ -181,6 +181,125 @@ erDiagram
| Scalability | {target} | {how measured} | [ADR-{NNN}](ADR-{NNN}-{slug}.md) |
| Reliability | {target} | {how measured} | [ADR-{NNN}](ADR-{NNN}-{slug}.md) |
## State Machine
{For each core entity with a lifecycle (e.g., Order, Session, Task):}
### {Entity} Lifecycle
```
{ASCII state diagram showing all states, transitions, triggers, and error paths}
┌──────────┐
│ Created │
└─────┬────┘
│ start()
┌──────────┐ error ┌──────────┐
│ Running │ ──────────▶ │ Failed │
└─────┬────┘ └──────────┘
│ complete()
┌──────────┐
│ Completed │
└──────────┘
```
| From State | Event | To State | Side Effects | Error Handling |
|-----------|-------|----------|-------------|----------------|
| {from} | {event} | {to} | {side_effects} | {error_behavior} |
## Configuration Model
### Required Configuration
| Field | Type | Default | Constraint | Description |
|-------|------|---------|------------|-------------|
| {field_name} | {string/number/boolean/enum} | {default_value} | {validation rule} | {description} |
### Optional Configuration
| Field | Type | Default | Constraint | Description |
|-------|------|---------|------------|-------------|
| {field_name} | {type} | {default} | {constraint} | {description} |
### Environment Variables
| Variable | Maps To | Required |
|----------|---------|----------|
| {ENV_VAR} | {config_field} | {yes/no} |
## Error Handling
### Error Classification
| Category | Severity | Retry | Example |
|----------|----------|-------|---------|
| Transient | Low | Yes, with backoff | Network timeout, rate limit |
| Permanent | High | No | Invalid configuration, auth failure |
| Degraded | Medium | Partial | Dependency unavailable, fallback active |
### Per-Component Error Strategy
| Component | Error Scenario | Behavior | Recovery |
|-----------|---------------|----------|----------|
| {component} | {scenario} | {MUST/SHOULD behavior} | {recovery strategy} |
## Observability
### Metrics
| Metric Name | Type | Labels | Description |
|-------------|------|--------|-------------|
| {metric_name} | {counter/gauge/histogram} | {label1, label2} | {what it measures} |
### Logging
| Event | Level | Fields | Description |
|-------|-------|--------|-------------|
| {event_name} | {INFO/WARN/ERROR} | {structured fields} | {when logged} |
### Health Checks
| Check | Endpoint | Interval | Failure Action |
|-------|----------|----------|----------------|
| {check_name} | {/health/xxx} | {duration} | {action on failure} |
## Trust & Safety
### Trust Levels
| Level | Description | Approval Required | Allowed Operations |
|-------|-------------|-------------------|-------------------|
| High Trust | {description} | None | {operations} |
| Standard | {description} | {approval type} | {operations} |
| Low Trust | {description} | {approval type} | {operations} |
### Security Controls
{Detailed security controls beyond the basic auth covered in Security Architecture}
## Implementation Guidance
### Key Decisions for Implementers
| Decision | Options | Recommendation | Rationale |
|----------|---------|---------------|-----------|
| {decision_area} | {option_1, option_2} | {recommended} | {why} |
### Implementation Order
1. {component/module 1}: {why first}
2. {component/module 2}: {depends on #1}
### Testing Strategy
| Layer | Scope | Tools | Coverage Target |
|-------|-------|-------|-----------------|
| Unit | {scope} | {tools} | {target} |
| Integration | {scope} | {tools} | {target} |
| E2E | {scope} | {tools} | {target} |
## Risks & Mitigations
| Risk | Impact | Probability | Mitigation |

View File

@@ -101,6 +101,19 @@ graph LR
|------|---------------|------------|
| {risk description} | [EPIC-{NNN}](EPIC-{NNN}-{slug}.md) | {mitigation} |
## Versioning & Changelog
### Version Strategy
- **Versioning Scheme**: {semver/calver/custom}
- **Breaking Change Definition**: {what constitutes a breaking change}
- **Deprecation Policy**: {how deprecated features are handled}
### Changelog
| Version | Date | Type | Description |
|---------|------|------|-------------|
| {version} | {date} | {Added/Changed/Fixed/Removed} | {description} |
## Open Questions
- [ ] {question about scope or implementation 1}

View File

@@ -30,6 +30,15 @@ dependencies:
{executive_summary - 2-3 sentences capturing the essence of the product/feature}
## Concepts & Terminology
| Term | Definition | Aliases |
|------|-----------|---------|
| {term_1} | {definition} | {comma-separated aliases if any} |
| {term_2} | {definition} | |
{Note: All documents in this specification MUST use these terms consistently.}
## Vision
{vision_statement - clear, aspirational 1-3 sentence statement of what success looks like}
@@ -70,6 +79,15 @@ dependencies:
- {explicitly excluded item 1}
- {explicitly excluded item 2}
### Non-Goals
{Explicit list of things this project will NOT do, with rationale for each:}
| Non-Goal | Rationale |
|----------|-----------|
| {non_goal_1} | {why this is explicitly excluded} |
| {non_goal_2} | {why this is explicitly excluded} |
### Assumptions
- {key assumption 1}
- {key assumption 2}
@@ -130,4 +148,6 @@ dependencies:
| `{product_name}` | Seed analysis | Product/feature name |
| `{executive_summary}` | CLI synthesis | 2-3 sentence summary |
| `{vision_statement}` | CLI product perspective | Aspirational vision |
| `{term_1}`, `{term_2}` | CLI synthesis | Domain terms with definitions and optional aliases |
| `{non_goal_1}`, `{non_goal_2}` | CLI synthesis | Explicit exclusions with rationale |
| All `{...}` fields | CLI analysis outputs | Filled from multi-perspective analysis |

View File

@@ -0,0 +1,27 @@
# API Spec Profile
Defines additional required sections for API-type specifications.
## Required Sections (in addition to base template)
### In Architecture Document
- **Endpoint Definition**: MUST list all endpoints with method, path, auth, request/response schema
- **Authentication Model**: MUST define auth mechanism (OAuth2/JWT/API Key), token lifecycle
- **Rate Limiting**: MUST define rate limits per tier/endpoint, throttling behavior
- **Error Codes**: MUST define error response format, standard error codes with descriptions
- **API Versioning**: MUST define versioning strategy (URL/header/query), deprecation policy
- **Pagination**: SHOULD define pagination strategy for list endpoints
- **Idempotency**: SHOULD define idempotency requirements for write operations
### In Requirements Document
- **Endpoint Acceptance Criteria**: Each requirement SHOULD map to specific endpoints
- **SLA Definitions**: MUST define response time, availability targets per endpoint tier
### Quality Gate Additions
| Check | Criteria | Severity |
|-------|----------|----------|
| Endpoints documented | All endpoints with method + path | Error |
| Auth model defined | Authentication mechanism specified | Error |
| Error codes defined | Standard error format + codes | Warning |
| Rate limits defined | Per-endpoint or per-tier limits | Warning |
| API versioning strategy | Versioning approach specified | Warning |

View File

@@ -0,0 +1,25 @@
# Library Spec Profile
Defines additional required sections for library/SDK-type specifications.
## Required Sections (in addition to base template)
### In Architecture Document
- **Public API Surface**: MUST define all public interfaces with signatures, parameters, return types
- **Usage Examples**: MUST provide >= 3 code examples showing common usage patterns
- **Compatibility Matrix**: MUST define supported language versions, runtime environments
- **Dependency Policy**: MUST define transitive dependency policy, version constraints
- **Extension Points**: SHOULD define plugin/extension mechanisms if applicable
- **Bundle Size**: SHOULD define target bundle size and tree-shaking strategy
### In Requirements Document
- **API Ergonomics**: Requirements SHOULD address developer experience and API consistency
- **Error Reporting**: MUST define error types, messages, and recovery hints for consumers
### Quality Gate Additions
| Check | Criteria | Severity |
|-------|----------|----------|
| Public API documented | All public interfaces with types | Error |
| Usage examples | >= 3 working examples | Warning |
| Compatibility matrix | Supported environments listed | Warning |
| Dependency policy | Transitive deps strategy defined | Info |

View File

@@ -0,0 +1,28 @@
# Service Spec Profile
Defines additional required sections for service-type specifications.
## Required Sections (in addition to base template)
### In Architecture Document
- **Concepts & Terminology**: MUST define all domain terms with consistent aliases
- **State Machine**: MUST include ASCII state diagram for each entity with a lifecycle
- **Configuration Model**: MUST define all configurable fields with types, defaults, constraints
- **Error Handling**: MUST define per-component error classification and recovery strategies
- **Observability**: MUST define >= 3 metrics, structured log format, health check endpoints
- **Trust & Safety**: SHOULD define trust levels and approval matrix
- **Graceful Shutdown**: MUST describe shutdown sequence and cleanup procedures
- **Implementation Guidance**: SHOULD provide implementation order and key decisions
### In Requirements Document
- **Behavioral Constraints**: MUST use RFC 2119 keywords (MUST/SHOULD/MAY) for all requirements
- **Data Model**: MUST define core entities with field-level detail (type, constraint, relation)
### Quality Gate Additions
| Check | Criteria | Severity |
|-------|----------|----------|
| State machine present | >= 1 lifecycle state diagram | Error |
| Configuration model | All config fields documented | Warning |
| Observability metrics | >= 3 metrics defined | Warning |
| Error handling defined | Per-component strategy | Warning |
| RFC keywords used | Behavioral requirements use MUST/SHOULD/MAY | Warning |