legacyver 2.1.0 → 2.1.2
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.
- package/.agent/skills/openspec-apply-change/SKILL.md +156 -0
- package/.agent/skills/openspec-archive-change/SKILL.md +114 -0
- package/.agent/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.agent/skills/openspec-continue-change/SKILL.md +118 -0
- package/.agent/skills/openspec-explore/SKILL.md +290 -0
- package/.agent/skills/openspec-ff-change/SKILL.md +101 -0
- package/.agent/skills/openspec-new-change/SKILL.md +74 -0
- package/.agent/skills/openspec-onboard/SKILL.md +529 -0
- package/.agent/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.agent/skills/openspec-verify-change/SKILL.md +168 -0
- package/.agent/workflows/opsx-apply.md +149 -0
- package/.agent/workflows/opsx-archive.md +154 -0
- package/.agent/workflows/opsx-bulk-archive.md +239 -0
- package/.agent/workflows/opsx-continue.md +111 -0
- package/.agent/workflows/opsx-explore.md +171 -0
- package/.agent/workflows/opsx-ff.md +91 -0
- package/.agent/workflows/opsx-new.md +66 -0
- package/.agent/workflows/opsx-onboard.md +522 -0
- package/.agent/workflows/opsx-sync.md +131 -0
- package/.agent/workflows/opsx-verify.md +161 -0
- package/.github/prompts/opsx-apply.prompt.md +149 -0
- package/.github/prompts/opsx-archive.prompt.md +154 -0
- package/.github/prompts/opsx-bulk-archive.prompt.md +239 -0
- package/.github/prompts/opsx-continue.prompt.md +111 -0
- package/.github/prompts/opsx-explore.prompt.md +171 -0
- package/.github/prompts/opsx-ff.prompt.md +91 -0
- package/.github/prompts/opsx-new.prompt.md +66 -0
- package/.github/prompts/opsx-onboard.prompt.md +522 -0
- package/.github/prompts/opsx-sync.prompt.md +131 -0
- package/.github/prompts/opsx-verify.prompt.md +161 -0
- package/.github/skills/openspec-apply-change/SKILL.md +156 -0
- package/.github/skills/openspec-archive-change/SKILL.md +114 -0
- package/.github/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.github/skills/openspec-continue-change/SKILL.md +118 -0
- package/.github/skills/openspec-explore/SKILL.md +290 -0
- package/.github/skills/openspec-ff-change/SKILL.md +101 -0
- package/.github/skills/openspec-new-change/SKILL.md +74 -0
- package/.github/skills/openspec-onboard/SKILL.md +529 -0
- package/.github/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.github/skills/openspec-verify-change/SKILL.md +168 -0
- package/.legacyverignore.example +43 -0
- package/.legacyverrc +7 -0
- package/.opencode/command/opsx-apply.md +149 -0
- package/.opencode/command/opsx-archive.md +154 -0
- package/.opencode/command/opsx-bulk-archive.md +239 -0
- package/.opencode/command/opsx-continue.md +111 -0
- package/.opencode/command/opsx-explore.md +171 -0
- package/.opencode/command/opsx-ff.md +91 -0
- package/.opencode/command/opsx-new.md +66 -0
- package/.opencode/command/opsx-onboard.md +522 -0
- package/.opencode/command/opsx-sync.md +131 -0
- package/.opencode/command/opsx-verify.md +161 -0
- package/.opencode/skills/openspec-apply-change/SKILL.md +156 -0
- package/.opencode/skills/openspec-archive-change/SKILL.md +114 -0
- package/.opencode/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.opencode/skills/openspec-continue-change/SKILL.md +118 -0
- package/.opencode/skills/openspec-explore/SKILL.md +290 -0
- package/.opencode/skills/openspec-ff-change/SKILL.md +101 -0
- package/.opencode/skills/openspec-new-change/SKILL.md +74 -0
- package/.opencode/skills/openspec-onboard/SKILL.md +529 -0
- package/.opencode/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.opencode/skills/openspec-verify-change/SKILL.md +168 -0
- package/LICENSE +1 -1
- package/README.md +128 -83
- package/bin/legacyver.js +48 -25
- package/legacyver-docs/SUMMARY.md +3 -0
- package/legacyver-docs/components.md +57 -0
- package/legacyver-docs/index.md +15 -0
- package/nul +2 -0
- package/package.json +23 -25
- package/src/cache/hash.js +9 -10
- package/src/cache/index.js +43 -65
- package/src/cli/commands/analyze.js +212 -190
- package/src/cli/commands/cache.js +15 -35
- package/src/cli/commands/init.js +63 -107
- package/src/cli/commands/providers.js +56 -81
- package/src/cli/commands/version.js +7 -10
- package/src/cli/ui.js +58 -77
- package/src/crawler/filters.js +41 -40
- package/src/crawler/index.js +52 -36
- package/src/crawler/manifest.js +31 -43
- package/src/crawler/walk.js +32 -38
- package/src/llm/chunker.js +34 -56
- package/src/llm/cost-estimator.js +68 -51
- package/src/llm/free-model.js +67 -0
- package/src/llm/index.js +22 -43
- package/src/llm/prompts.js +45 -33
- package/src/llm/providers/gemini.js +94 -0
- package/src/llm/providers/groq.js +55 -40
- package/src/llm/providers/ollama.js +38 -65
- package/src/llm/providers/openrouter.js +67 -0
- package/src/llm/queue.js +59 -88
- package/src/llm/re-prompter.js +41 -0
- package/src/llm/validator.js +72 -0
- package/src/parser/ast/generic.js +45 -222
- package/src/parser/ast/go.js +86 -205
- package/src/parser/ast/java.js +76 -146
- package/src/parser/ast/javascript.js +173 -241
- package/src/parser/ast/laravel/blade.js +56 -0
- package/src/parser/ast/laravel/classifier.js +30 -0
- package/src/parser/ast/laravel/controller.js +35 -0
- package/src/parser/ast/laravel/index.js +54 -0
- package/src/parser/ast/laravel/model.js +41 -0
- package/src/parser/ast/laravel/provider.js +28 -0
- package/src/parser/ast/laravel/routes.js +45 -0
- package/src/parser/ast/php.js +129 -0
- package/src/parser/ast/python.js +76 -199
- package/src/parser/ast/typescript.js +10 -244
- package/src/parser/body-extractor.js +40 -0
- package/src/parser/call-graph.js +50 -67
- package/src/parser/complexity-scorer.js +59 -0
- package/src/parser/index.js +61 -86
- package/src/parser/pattern-detector.js +71 -0
- package/src/parser/pkg-builder.js +36 -83
- package/src/renderer/html.js +63 -135
- package/src/renderer/index.js +23 -35
- package/src/renderer/json.js +17 -35
- package/src/renderer/markdown.js +83 -117
- package/src/utils/config.js +52 -53
- package/src/utils/errors.js +26 -41
- package/src/utils/logger.js +32 -53
- package/src/cli/flags.js +0 -87
- package/src/llm/providers/anthropic.js +0 -57
- package/src/llm/providers/google.js +0 -65
- package/src/llm/providers/openai.js +0 -52
- package/src/parser/ast/tree-sitter-init.js +0 -80
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: openspec-verify-change
|
|
3
|
+
description: Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: Requires openspec CLI.
|
|
6
|
+
metadata:
|
|
7
|
+
author: openspec
|
|
8
|
+
version: "1.0"
|
|
9
|
+
generatedBy: "1.1.1"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Verify that an implementation matches the change artifacts (specs, tasks, design).
|
|
13
|
+
|
|
14
|
+
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
15
|
+
|
|
16
|
+
**Steps**
|
|
17
|
+
|
|
18
|
+
1. **If no change name provided, prompt for selection**
|
|
19
|
+
|
|
20
|
+
Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
21
|
+
|
|
22
|
+
Show changes that have implementation tasks (tasks artifact exists).
|
|
23
|
+
Include the schema used for each change if available.
|
|
24
|
+
Mark changes with incomplete tasks as "(In Progress)".
|
|
25
|
+
|
|
26
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
27
|
+
|
|
28
|
+
2. **Check status to understand the schema**
|
|
29
|
+
```bash
|
|
30
|
+
openspec status --change "<name>" --json
|
|
31
|
+
```
|
|
32
|
+
Parse the JSON to understand:
|
|
33
|
+
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
34
|
+
- Which artifacts exist for this change
|
|
35
|
+
|
|
36
|
+
3. **Get the change directory and load artifacts**
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
openspec instructions apply --change "<name>" --json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This returns the change directory and context files. Read all available artifacts from `contextFiles`.
|
|
43
|
+
|
|
44
|
+
4. **Initialize verification report structure**
|
|
45
|
+
|
|
46
|
+
Create a report structure with three dimensions:
|
|
47
|
+
- **Completeness**: Track tasks and spec coverage
|
|
48
|
+
- **Correctness**: Track requirement implementation and scenario coverage
|
|
49
|
+
- **Coherence**: Track design adherence and pattern consistency
|
|
50
|
+
|
|
51
|
+
Each dimension can have CRITICAL, WARNING, or SUGGESTION issues.
|
|
52
|
+
|
|
53
|
+
5. **Verify Completeness**
|
|
54
|
+
|
|
55
|
+
**Task Completion**:
|
|
56
|
+
- If tasks.md exists in contextFiles, read it
|
|
57
|
+
- Parse checkboxes: `- [ ]` (incomplete) vs `- [x]` (complete)
|
|
58
|
+
- Count complete vs total tasks
|
|
59
|
+
- If incomplete tasks exist:
|
|
60
|
+
- Add CRITICAL issue for each incomplete task
|
|
61
|
+
- Recommendation: "Complete task: <description>" or "Mark as done if already implemented"
|
|
62
|
+
|
|
63
|
+
**Spec Coverage**:
|
|
64
|
+
- If delta specs exist in `openspec/changes/<name>/specs/`:
|
|
65
|
+
- Extract all requirements (marked with "### Requirement:")
|
|
66
|
+
- For each requirement:
|
|
67
|
+
- Search codebase for keywords related to the requirement
|
|
68
|
+
- Assess if implementation likely exists
|
|
69
|
+
- If requirements appear unimplemented:
|
|
70
|
+
- Add CRITICAL issue: "Requirement not found: <requirement name>"
|
|
71
|
+
- Recommendation: "Implement requirement X: <description>"
|
|
72
|
+
|
|
73
|
+
6. **Verify Correctness**
|
|
74
|
+
|
|
75
|
+
**Requirement Implementation Mapping**:
|
|
76
|
+
- For each requirement from delta specs:
|
|
77
|
+
- Search codebase for implementation evidence
|
|
78
|
+
- If found, note file paths and line ranges
|
|
79
|
+
- Assess if implementation matches requirement intent
|
|
80
|
+
- If divergence detected:
|
|
81
|
+
- Add WARNING: "Implementation may diverge from spec: <details>"
|
|
82
|
+
- Recommendation: "Review <file>:<lines> against requirement X"
|
|
83
|
+
|
|
84
|
+
**Scenario Coverage**:
|
|
85
|
+
- For each scenario in delta specs (marked with "#### Scenario:"):
|
|
86
|
+
- Check if conditions are handled in code
|
|
87
|
+
- Check if tests exist covering the scenario
|
|
88
|
+
- If scenario appears uncovered:
|
|
89
|
+
- Add WARNING: "Scenario not covered: <scenario name>"
|
|
90
|
+
- Recommendation: "Add test or implementation for scenario: <description>"
|
|
91
|
+
|
|
92
|
+
7. **Verify Coherence**
|
|
93
|
+
|
|
94
|
+
**Design Adherence**:
|
|
95
|
+
- If design.md exists in contextFiles:
|
|
96
|
+
- Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:")
|
|
97
|
+
- Verify implementation follows those decisions
|
|
98
|
+
- If contradiction detected:
|
|
99
|
+
- Add WARNING: "Design decision not followed: <decision>"
|
|
100
|
+
- Recommendation: "Update implementation or revise design.md to match reality"
|
|
101
|
+
- If no design.md: Skip design adherence check, note "No design.md to verify against"
|
|
102
|
+
|
|
103
|
+
**Code Pattern Consistency**:
|
|
104
|
+
- Review new code for consistency with project patterns
|
|
105
|
+
- Check file naming, directory structure, coding style
|
|
106
|
+
- If significant deviations found:
|
|
107
|
+
- Add SUGGESTION: "Code pattern deviation: <details>"
|
|
108
|
+
- Recommendation: "Consider following project pattern: <example>"
|
|
109
|
+
|
|
110
|
+
8. **Generate Verification Report**
|
|
111
|
+
|
|
112
|
+
**Summary Scorecard**:
|
|
113
|
+
```
|
|
114
|
+
## Verification Report: <change-name>
|
|
115
|
+
|
|
116
|
+
### Summary
|
|
117
|
+
| Dimension | Status |
|
|
118
|
+
|--------------|------------------|
|
|
119
|
+
| Completeness | X/Y tasks, N reqs|
|
|
120
|
+
| Correctness | M/N reqs covered |
|
|
121
|
+
| Coherence | Followed/Issues |
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Issues by Priority**:
|
|
125
|
+
|
|
126
|
+
1. **CRITICAL** (Must fix before archive):
|
|
127
|
+
- Incomplete tasks
|
|
128
|
+
- Missing requirement implementations
|
|
129
|
+
- Each with specific, actionable recommendation
|
|
130
|
+
|
|
131
|
+
2. **WARNING** (Should fix):
|
|
132
|
+
- Spec/design divergences
|
|
133
|
+
- Missing scenario coverage
|
|
134
|
+
- Each with specific recommendation
|
|
135
|
+
|
|
136
|
+
3. **SUGGESTION** (Nice to fix):
|
|
137
|
+
- Pattern inconsistencies
|
|
138
|
+
- Minor improvements
|
|
139
|
+
- Each with specific recommendation
|
|
140
|
+
|
|
141
|
+
**Final Assessment**:
|
|
142
|
+
- If CRITICAL issues: "X critical issue(s) found. Fix before archiving."
|
|
143
|
+
- If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)."
|
|
144
|
+
- If all clear: "All checks passed. Ready for archive."
|
|
145
|
+
|
|
146
|
+
**Verification Heuristics**
|
|
147
|
+
|
|
148
|
+
- **Completeness**: Focus on objective checklist items (checkboxes, requirements list)
|
|
149
|
+
- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty
|
|
150
|
+
- **Coherence**: Look for glaring inconsistencies, don't nitpick style
|
|
151
|
+
- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL
|
|
152
|
+
- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable
|
|
153
|
+
|
|
154
|
+
**Graceful Degradation**
|
|
155
|
+
|
|
156
|
+
- If only tasks.md exists: verify task completion only, skip spec/design checks
|
|
157
|
+
- If tasks + specs exist: verify completeness and correctness, skip design
|
|
158
|
+
- If full artifacts: verify all three dimensions
|
|
159
|
+
- Always note which checks were skipped and why
|
|
160
|
+
|
|
161
|
+
**Output Format**
|
|
162
|
+
|
|
163
|
+
Use clear markdown with:
|
|
164
|
+
- Table for summary scorecard
|
|
165
|
+
- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION)
|
|
166
|
+
- Code references in format: `file.ts:123`
|
|
167
|
+
- Specific, actionable recommendations
|
|
168
|
+
- No vague suggestions like "consider reviewing"
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Legacyver
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Auto-generate technical documentation for legacy and undocumented codebases using AST parsing + LLMs.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```bash
|
|
6
|
+
npx legacyver analyze ./src
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
No documentation written beforehand. No configuration required. One command.
|
|
10
|
+
|
|
11
|
+
---
|
|
6
12
|
|
|
7
13
|
## Install
|
|
8
14
|
|
|
@@ -10,144 +16,183 @@ Legacyver crawls your source code, extracts structural facts with AST parsers (T
|
|
|
10
16
|
npm install -g legacyver
|
|
11
17
|
```
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
Or use without installing:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx legacyver analyze ./src
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
14
26
|
|
|
15
27
|
## Quick Start
|
|
16
28
|
|
|
29
|
+
**1. Initialize (saves your API key):**
|
|
30
|
+
|
|
17
31
|
```bash
|
|
18
|
-
# 1. Run the setup wizard
|
|
19
32
|
legacyver init
|
|
33
|
+
```
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
legacyver analyze ./src
|
|
35
|
+
**2. Analyze a codebase:**
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
```bash
|
|
38
|
+
legacyver analyze ./src
|
|
26
39
|
```
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
No API key required — just have [Ollama](https://ollama.ai) running:
|
|
41
|
+
**3. View the output:**
|
|
31
42
|
|
|
32
|
-
```
|
|
33
|
-
legacyver
|
|
43
|
+
```
|
|
44
|
+
legacyver-docs/
|
|
45
|
+
index.md ← project overview + dependency graph + route map (Laravel)
|
|
46
|
+
SUMMARY.md ← GitBook/Docusaurus compatible table of contents
|
|
47
|
+
src/
|
|
48
|
+
app.md
|
|
49
|
+
routes/users.md
|
|
50
|
+
...
|
|
34
51
|
```
|
|
35
52
|
|
|
36
|
-
|
|
53
|
+
---
|
|
37
54
|
|
|
38
|
-
|
|
55
|
+
## CLI Commands
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
### `legacyver analyze <dir>`
|
|
41
58
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
| `--
|
|
50
|
-
| `--incremental` |
|
|
51
|
-
| `--
|
|
52
|
-
| `--
|
|
53
|
-
| `--
|
|
54
|
-
| `--
|
|
55
|
-
| `--verbose` | Enable debug
|
|
59
|
+
Run the full documentation pipeline.
|
|
60
|
+
|
|
61
|
+
| Flag | Default | Description |
|
|
62
|
+
|------|---------|-------------|
|
|
63
|
+
| `--out <dir>` | `./legacyver-docs` | Output directory |
|
|
64
|
+
| `--format <fmt>` | `markdown` | Output format: `markdown`, `html`, `json` |
|
|
65
|
+
| `--provider <p>` | `openrouter` | LLM provider: `openrouter`, `ollama` |
|
|
66
|
+
| `--model <id>` | `meta-llama/llama-3.3-70b-instruct:free` | Model ID |
|
|
67
|
+
| `--incremental` | `false` | Skip files unchanged since last run |
|
|
68
|
+
| `--dry-run` | `false` | Estimate cost without calling LLM |
|
|
69
|
+
| `--concurrency <n>` | `3` | Max parallel LLM requests |
|
|
70
|
+
| `--max-file-size <kb>` | `500` | Skip files larger than this |
|
|
71
|
+
| `--no-confirm` | — | Skip cost confirmation prompt |
|
|
72
|
+
| `--verbose` | `false` | Enable debug logging |
|
|
56
73
|
|
|
57
74
|
### `legacyver init`
|
|
58
75
|
|
|
59
|
-
Interactive
|
|
76
|
+
Interactive wizard. Detects existing `.legacyverrc` and warns before overwriting. Saves API key to OS user config.
|
|
60
77
|
|
|
61
78
|
### `legacyver providers`
|
|
62
79
|
|
|
63
|
-
|
|
80
|
+
List all supported providers, API key status, and per-model pricing.
|
|
64
81
|
|
|
65
82
|
### `legacyver cache clear`
|
|
66
83
|
|
|
67
|
-
|
|
84
|
+
Delete the `.legacyver-cache/` directory to force full re-analysis on next run.
|
|
85
|
+
|
|
86
|
+
### `legacyver --version`
|
|
68
87
|
|
|
69
|
-
|
|
88
|
+
Print the installed version.
|
|
70
89
|
|
|
71
|
-
|
|
90
|
+
---
|
|
72
91
|
|
|
73
|
-
|
|
74
|
-
- `.legacyverrc.json`
|
|
75
|
-
- `.legacyverrc.yaml`
|
|
76
|
-
- `legacyver.config.js`
|
|
77
|
-
- `legacyver.config.mjs`
|
|
92
|
+
## `.legacyverrc` Schema
|
|
78
93
|
|
|
79
|
-
|
|
94
|
+
Create a `.legacyverrc` (JSON or YAML) in your project root:
|
|
80
95
|
|
|
81
96
|
```json
|
|
82
97
|
{
|
|
83
|
-
"provider": "
|
|
84
|
-
"model":
|
|
98
|
+
"provider": "openrouter",
|
|
99
|
+
"model": "meta-llama/llama-3.3-70b-instruct:free",
|
|
85
100
|
"format": "markdown",
|
|
86
|
-
"
|
|
87
|
-
"concurrency":
|
|
101
|
+
"out": "./legacyver-docs",
|
|
102
|
+
"concurrency": 3,
|
|
88
103
|
"maxFileSizeKb": 500,
|
|
89
|
-
"incremental":
|
|
90
|
-
"ignore": ["test/**", "**/*.test.*"],
|
|
91
|
-
"languages": ["javascript", "typescript", "python", "java", "go"]
|
|
104
|
+
"incremental": true
|
|
92
105
|
}
|
|
93
106
|
```
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
All fields are optional. CLI flags override file config.
|
|
109
|
+
|
|
110
|
+
Also supported: `legacyver.config.js`, `legacyver.config.yaml`.
|
|
111
|
+
|
|
112
|
+
---
|
|
96
113
|
|
|
97
114
|
## Supported Languages
|
|
98
115
|
|
|
99
|
-
| Language | Extensions |
|
|
100
|
-
|
|
101
|
-
| JavaScript | `.js`, `.jsx`, `.mjs` |
|
|
102
|
-
| TypeScript | `.ts`, `.tsx` |
|
|
103
|
-
| Python | `.py` |
|
|
104
|
-
| Java | `.java` |
|
|
105
|
-
| Go | `.go` |
|
|
116
|
+
| Language | Extensions | Framework Support |
|
|
117
|
+
|----------|-----------|-------------------|
|
|
118
|
+
| JavaScript | `.js`, `.jsx`, `.mjs` | Express (auto-detected) |
|
|
119
|
+
| TypeScript | `.ts`, `.tsx` | — |
|
|
120
|
+
| Python | `.py` | — |
|
|
121
|
+
| Java | `.java` | — |
|
|
122
|
+
| Go | `.go` | — |
|
|
123
|
+
| PHP | `.php`, `.blade.php` | Laravel (auto-detected) |
|
|
106
124
|
|
|
107
|
-
When
|
|
125
|
+
**Laravel extras:** When an `artisan` file is detected, Legacyver automatically extracts:
|
|
126
|
+
- Route Map (Method, URI, Controller, Middleware, Route Name)
|
|
127
|
+
- Model Relationships (as Mermaid `erDiagram`)
|
|
128
|
+
- Service Provider Bindings
|
|
108
129
|
|
|
109
|
-
|
|
130
|
+
---
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|---|---|---|---|---|
|
|
113
|
-
| Anthropic | `claude-haiku-3-5` | $0.00025 | $0.00125 | `ANTHROPIC_API_KEY` |
|
|
114
|
-
| OpenAI | `gpt-4o-mini` | $0.00015 | $0.00060 | `OPENAI_API_KEY` |
|
|
115
|
-
| Google | `gemini-1.5-flash` | $0.000075 | $0.00030 | `GOOGLE_API_KEY` |
|
|
116
|
-
| Groq | `llama-3.1-70b-versatile` | $0.00059 | $0.00079 | `GROQ_API_KEY` |
|
|
117
|
-
| Ollama | `llama3.2` | Free | Free | None (local) |
|
|
132
|
+
## Supported LLM Providers
|
|
118
133
|
|
|
119
|
-
|
|
134
|
+
| Provider | Env Var | Notes |
|
|
135
|
+
|----------|---------|-------|
|
|
136
|
+
| OpenRouter | `OPENROUTER_API_KEY` | Default. Free models available (`:free` suffix). Get a key at [openrouter.ai/keys](https://openrouter.ai/keys) |
|
|
137
|
+
| Ollama | — | Local/offline. Requires Ollama running: `ollama serve` |
|
|
120
138
|
|
|
121
|
-
|
|
139
|
+
**Free usage:** The default model `meta-llama/llama-3.3-70b-instruct:free` is free via OpenRouter (rate-limited). Legacyver automatically caps concurrency to 1 for free models.
|
|
122
140
|
|
|
123
|
-
|
|
141
|
+
---
|
|
124
142
|
|
|
125
|
-
##
|
|
143
|
+
## Ignore Files
|
|
126
144
|
|
|
127
|
-
|
|
145
|
+
Create a `.legacyverignore` in your project root using gitignore syntax:
|
|
128
146
|
|
|
129
|
-
```
|
|
130
|
-
|
|
147
|
+
```
|
|
148
|
+
# .legacyverignore
|
|
149
|
+
dist/
|
|
150
|
+
build/
|
|
151
|
+
coverage/
|
|
152
|
+
*.min.js
|
|
131
153
|
```
|
|
132
154
|
|
|
133
|
-
|
|
155
|
+
See `.legacyverignore.example` for a documented example.
|
|
134
156
|
|
|
135
|
-
|
|
157
|
+
---
|
|
136
158
|
|
|
137
|
-
|
|
159
|
+
## CI/CD Integration
|
|
138
160
|
|
|
139
|
-
```
|
|
140
|
-
|
|
161
|
+
```yaml
|
|
162
|
+
# GitHub Actions example
|
|
163
|
+
- name: Generate docs
|
|
164
|
+
env:
|
|
165
|
+
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
|
166
|
+
run: |
|
|
167
|
+
npx legacyver analyze ./src --no-confirm --incremental --out ./docs
|
|
141
168
|
```
|
|
142
169
|
|
|
143
|
-
|
|
170
|
+
Legacyver detects non-TTY environments and disables spinners/progress bars automatically (plain log output only).
|
|
171
|
+
|
|
172
|
+
---
|
|
144
173
|
|
|
145
174
|
## How It Works
|
|
146
175
|
|
|
147
|
-
1. **
|
|
148
|
-
2. **AST
|
|
149
|
-
3. **
|
|
150
|
-
4. **
|
|
176
|
+
1. **Crawl** — `fast-glob` walks the directory, respects `.legacyverignore`
|
|
177
|
+
2. **Parse** — Regex/heuristic AST extracts facts: function names, params, complexity scores, imports, exports, call patterns
|
|
178
|
+
3. **PKG** — Assembles a Project Knowledge Graph linking all facts
|
|
179
|
+
4. **LLM** — Sends grounded facts + raw source to LLM; system prompt enforces anti-hallucination contract
|
|
180
|
+
5. **Validate** — Post-generation checks: hallucination detection, completeness check (all exports documented)
|
|
181
|
+
6. **Render** — Writes Markdown/HTML/JSON to output directory
|
|
182
|
+
|
|
183
|
+
**Design principle:** The LLM is a _writer_, not an analyst. AST extracts facts; LLM only explains them.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Contributing
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
git clone https://github.com/user/legacyver
|
|
191
|
+
npm install
|
|
192
|
+
npx vitest run
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
151
196
|
|
|
152
197
|
## License
|
|
153
198
|
|
package/bin/legacyver.js
CHANGED
|
@@ -1,33 +1,56 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { registerInitCommand } from '../src/cli/commands/init.js';
|
|
7
|
-
import { registerProvidersCommand } from '../src/cli/commands/providers.js';
|
|
8
|
-
import { registerCacheCommand } from '../src/cli/commands/cache.js';
|
|
9
|
-
import { setVerbose } from '../src/utils/logger.js';
|
|
4
|
+
const { program } = require('commander');
|
|
5
|
+
const { readFileSync } = require('fs');
|
|
6
|
+
const { join } = require('path');
|
|
10
7
|
|
|
11
|
-
const
|
|
12
|
-
const pkg = require('../package.json');
|
|
13
|
-
|
|
14
|
-
const program = new Command();
|
|
8
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
|
|
15
9
|
|
|
16
10
|
program
|
|
17
11
|
.name('legacyver')
|
|
18
|
-
.description('
|
|
19
|
-
.version(pkg.version)
|
|
20
|
-
.option('--verbose', 'Enable verbose debug
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
.description('AI-powered CLI tool to auto-generate technical documentation from legacy/undocumented codebases')
|
|
13
|
+
.version(pkg.version, '-v, --version', 'Output the current version')
|
|
14
|
+
.option('--verbose', 'Enable verbose debug logging');
|
|
15
|
+
|
|
16
|
+
// analyze command
|
|
17
|
+
const analyzeCmd = require('../src/cli/commands/analyze');
|
|
18
|
+
program
|
|
19
|
+
.command('analyze [target]')
|
|
20
|
+
.description('Analyze a directory and generate documentation')
|
|
21
|
+
.option('--out <dir>', 'Output directory', './legacyver-docs')
|
|
22
|
+
.option('--format <fmt>', 'Output format: markdown | html | json', 'markdown')
|
|
23
|
+
.option('--model <model>', 'LLM model to use')
|
|
24
|
+
.option('--provider <provider>', 'LLM provider: openrouter | ollama', 'openrouter')
|
|
25
|
+
.option('--concurrency <n>', 'Concurrent LLM requests (1-10)', '3')
|
|
26
|
+
.option('--dry-run', 'Run AST parsing only, no LLM calls')
|
|
27
|
+
.option('--incremental', 'Only re-analyze changed files')
|
|
28
|
+
.option('--no-confirm', 'Skip cost confirmation prompt')
|
|
29
|
+
.option('--json-summary', 'Output machine-readable JSON summary')
|
|
30
|
+
.option('--max-file-size <kb>', 'Skip files larger than this size in KB', '500')
|
|
31
|
+
.action(analyzeCmd);
|
|
32
|
+
|
|
33
|
+
// init command
|
|
34
|
+
const initCmd = require('../src/cli/commands/init');
|
|
35
|
+
program
|
|
36
|
+
.command('init')
|
|
37
|
+
.description('Interactive setup wizard — saves API key and creates .legacyverrc')
|
|
38
|
+
.action(initCmd);
|
|
39
|
+
|
|
40
|
+
// providers command
|
|
41
|
+
const providersCmd = require('../src/cli/commands/providers');
|
|
42
|
+
program
|
|
43
|
+
.command('providers')
|
|
44
|
+
.description('List supported LLM providers and available models')
|
|
45
|
+
.action(providersCmd);
|
|
46
|
+
|
|
47
|
+
// cache command
|
|
48
|
+
const cacheCmd = require('../src/cli/commands/cache');
|
|
49
|
+
program
|
|
50
|
+
.command('cache')
|
|
51
|
+
.description('Manage the incremental analysis cache')
|
|
52
|
+
.command('clear')
|
|
53
|
+
.description('Delete the .legacyver-cache/ directory')
|
|
54
|
+
.action(cacheCmd);
|
|
32
55
|
|
|
33
56
|
program.parse(process.argv);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
This file contains React components and a utility function for formatting currency amounts.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
|
|
6
|
+
### formatCurrency
|
|
7
|
+
|
|
8
|
+
#### Description
|
|
9
|
+
Formats a given amount as a string in a specified currency.
|
|
10
|
+
|
|
11
|
+
#### Params Table
|
|
12
|
+
|
|
13
|
+
| Name | Type |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `amount` | `number` |
|
|
16
|
+
| `currency` | `string`, defaults to `'USD'` |
|
|
17
|
+
|
|
18
|
+
#### Return Value
|
|
19
|
+
A formatted string representing the currency amount.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
export function formatCurrency(amount: number, currency: string = 'USD'): string {
|
|
23
|
+
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Dependencies
|
|
28
|
+
|
|
29
|
+
* `react`
|
|
30
|
+
* `intl`
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
This file appears to contain UI components, with buttons and cards used for user representation.
|
|
34
|
+
|
|
35
|
+
## Functions
|
|
36
|
+
|
|
37
|
+
### Button
|
|
38
|
+
#### Description
|
|
39
|
+
A button component that can trigger an action.
|
|
40
|
+
#### Params Table
|
|
41
|
+
| Param | Type | Required |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| - | - | No |
|
|
44
|
+
#### Return Value
|
|
45
|
+
N/A
|
|
46
|
+
|
|
47
|
+
### UserCard
|
|
48
|
+
#### Description
|
|
49
|
+
A card component representing a user.
|
|
50
|
+
#### Params Table
|
|
51
|
+
| Param | Type | Required |
|
|
52
|
+
| --- | --- | --- |
|
|
53
|
+
| - | - | Yes |
|
|
54
|
+
|
|
55
|
+
## Dependencies
|
|
56
|
+
* `@ui-component/library` (UI components library)
|
|
57
|
+
* `@utils/typography` (Typography utilities)
|
package/nul
ADDED