legacyver 3.0.0 → 3.1.0
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/bin/legacyver.js +6 -8
- package/legacyver-docs/OrderController.md +79 -79
- package/legacyver-docs/SUMMARY.md +2 -2
- package/legacyver-docs/bin/legacyver.md +107 -0
- package/legacyver-docs/index.md +15 -15
- package/legacyver-docs/src/api/auth.md +47 -0
- package/legacyver-docs/src/cache/hash.md +24 -0
- package/legacyver-docs/src/cache/index.md +112 -0
- package/legacyver-docs/src/cli/commands/analyze.md +58 -0
- package/legacyver-docs/src/cli/commands/cache.md +21 -0
- package/legacyver-docs/src/cli/commands/init.md +42 -0
- package/legacyver-docs/src/cli/commands/login.md +70 -0
- package/legacyver-docs/src/cli/commands/logout.md +26 -0
- package/legacyver-docs/src/cli/commands/providers.md +23 -0
- package/legacyver-docs/src/cli/commands/push.md +48 -0
- package/legacyver-docs/src/cli/commands/version.md +26 -0
- package/legacyver-docs/src/cli/ui.md +112 -0
- package/legacyver-docs/src/crawler/filters.md +54 -0
- package/legacyver-docs/src/crawler/index.md +54 -0
- package/legacyver-docs/src/crawler/manifest.md +22 -0
- package/legacyver-docs/src/crawler/walk.md +29 -0
- package/legacyver-docs/src/db/config.md +13 -0
- package/legacyver-docs/src/db/index.md +86 -0
- package/legacyver-docs/src/llm/chunker.md +28 -0
- package/legacyver-docs/src/llm/cost-estimator.md +62 -0
- package/legacyver-docs/src/llm/free-model.md +40 -0
- package/legacyver-docs/src/llm/index.md +29 -0
- package/legacyver-docs/src/llm/prompts.md +150 -0
- package/legacyver-docs/src/llm/providers/gemini.md +51 -0
- package/legacyver-docs/src/llm/providers/groq.md +76 -0
- package/legacyver-docs/src/llm/providers/kimi.md +48 -0
- package/legacyver-docs/src/llm/providers/ollama.md +50 -0
- package/legacyver-docs/src/llm/providers/openrouter.md +55 -0
- package/legacyver-docs/src/llm/queue.md +41 -0
- package/legacyver-docs/src/llm/re-prompter.md +33 -0
- package/legacyver-docs/src/llm/validator.md +34 -0
- package/legacyver-docs/src/parser/ast/generic.md +34 -0
- package/legacyver-docs/src/parser/ast/go.md +59 -0
- package/legacyver-docs/src/parser/ast/java.md +58 -0
- package/legacyver-docs/src/parser/ast/javascript.md +71 -0
- package/legacyver-docs/src/parser/ast/laravel/blade.md +45 -0
- package/legacyver-docs/src/parser/ast/laravel/classifier.md +29 -0
- package/legacyver-docs/src/parser/ast/laravel/controller.md +57 -0
- package/legacyver-docs/src/parser/ast/laravel/index.md +27 -0
- package/legacyver-docs/src/parser/ast/laravel/model.md +34 -0
- package/legacyver-docs/src/parser/ast/laravel/provider.md +31 -0
- package/legacyver-docs/src/parser/ast/laravel/routes.md +31 -0
- package/legacyver-docs/src/parser/ast/php.md +127 -0
- package/legacyver-docs/src/parser/ast/python.md +62 -0
- package/legacyver-docs/src/parser/ast/typescript.md +22 -0
- package/legacyver-docs/src/parser/body-extractor.md +34 -0
- package/legacyver-docs/src/parser/call-graph.md +45 -0
- package/legacyver-docs/src/parser/complexity-scorer.md +25 -0
- package/legacyver-docs/src/parser/index.md +59 -0
- package/legacyver-docs/src/parser/pattern-detector.md +28 -0
- package/legacyver-docs/src/parser/pkg-builder.md +34 -0
- package/legacyver-docs/src/renderer/html.md +36 -0
- package/legacyver-docs/src/renderer/index.md +26 -0
- package/legacyver-docs/src/renderer/json.md +25 -0
- package/legacyver-docs/src/renderer/markdown.md +77 -0
- package/legacyver-docs/src/utils/config.md +62 -0
- package/legacyver-docs/src/utils/errors.md +53 -0
- package/legacyver-docs/src/utils/logger.md +48 -0
- package/package.json +50 -51
- package/src/cli/commands/analyze.js +5 -5
- package/src/cli/commands/init.js +4 -4
- package/src/cli/commands/providers.js +3 -3
- package/src/llm/cost-estimator.js +2 -2
- package/src/llm/free-model.js +2 -2
- package/src/llm/index.js +2 -2
- package/src/llm/providers/openrouter.js +5 -2
- package/src/llm/validator.js +41 -2
- package/src/utils/config.js +1 -1
package/bin/legacyver.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
require('dotenv').config();
|
|
5
|
-
|
|
6
4
|
const { program } = require('commander');
|
|
7
5
|
const { readFileSync } = require('fs');
|
|
8
6
|
const { join } = require('path');
|
|
@@ -20,16 +18,16 @@ const analyzeCmd = require('../src/cli/commands/analyze');
|
|
|
20
18
|
program
|
|
21
19
|
.command('analyze [target]')
|
|
22
20
|
.description('Analyze a directory and generate documentation')
|
|
23
|
-
.option('--out <dir>', 'Output directory
|
|
24
|
-
.option('--format <fmt>', 'Output format: markdown | html | json
|
|
21
|
+
.option('--out <dir>', 'Output directory (default: ./legacyver-docs)')
|
|
22
|
+
.option('--format <fmt>', 'Output format: markdown | html | json (default: markdown)')
|
|
25
23
|
.option('--model <model>', 'LLM model to use')
|
|
26
|
-
.option('--provider <provider>', 'LLM provider: groq | ollama
|
|
27
|
-
.option('--concurrency <n>', 'Concurrent LLM requests
|
|
24
|
+
.option('--provider <provider>', 'LLM provider: openrouter | groq | gemini | kimi | ollama (default: openrouter)')
|
|
25
|
+
.option('--concurrency <n>', 'Concurrent LLM requests 1-10 (default: 3)')
|
|
28
26
|
.option('--dry-run', 'Run AST parsing only, no LLM calls')
|
|
29
27
|
.option('--incremental', 'Only re-analyze changed files')
|
|
30
|
-
.option('--no-confirm', 'Skip cost confirmation prompt')
|
|
28
|
+
.option('--no-confirm', 'Skip cost confirmation prompt')
|
|
31
29
|
.option('--json-summary', 'Output machine-readable JSON summary')
|
|
32
|
-
.option('--max-file-size <kb>', 'Skip files larger than this size in KB
|
|
30
|
+
.option('--max-file-size <kb>', 'Skip files larger than this size in KB (default: 500)')
|
|
33
31
|
.action(analyzeCmd);
|
|
34
32
|
|
|
35
33
|
// init command
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This is the `OrderController` class, responsible for handling CRUD (Create, Read, Update, Delete) operations on orders. It provides a RESTful API interface to interact with the order data.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
|
|
6
|
-
### index
|
|
7
|
-
#### Description
|
|
8
|
-
Returns a paginated list of orders.
|
|
9
|
-
#### Parameters
|
|
10
|
-
| Parameter | Type | Required |
|
|
11
|
-
| --- | --- | --- |
|
|
12
|
-
| `paginate` | int | - |
|
|
13
|
-
| `response` | object | - |
|
|
14
|
-
| `json` | function | - |
|
|
15
|
-
|
|
16
|
-
#### Return Value
|
|
17
|
-
A `JsonResponse` containing the paginated list of orders.
|
|
18
|
-
|
|
19
|
-
### store
|
|
20
|
-
#### Description
|
|
21
|
-
Creates a new order and returns its details.
|
|
22
|
-
#### Parameters
|
|
23
|
-
| Parameter | Type | Required |
|
|
24
|
-
| --- | --- | --- |
|
|
25
|
-
| `$request:StoreOrderRequest` | object | Yes |
|
|
26
|
-
|
|
27
|
-
#### Return Value
|
|
28
|
-
A `JsonResponse` with the created order data and HTTP status code 201.
|
|
29
|
-
|
|
30
|
-
### show
|
|
31
|
-
#### Description
|
|
32
|
-
Returns a single order by its ID.
|
|
33
|
-
#### Parameters
|
|
34
|
-
| Parameter | Type | Required |
|
|
35
|
-
| --- | --- | --- |
|
|
36
|
-
| `$id:int` | int | Yes |
|
|
37
|
-
|
|
38
|
-
#### Return Value
|
|
39
|
-
A `JsonResponse` containing the order details.
|
|
40
|
-
|
|
41
|
-
### update
|
|
42
|
-
#### Description
|
|
43
|
-
Updates an existing order.
|
|
44
|
-
#### Parameters
|
|
45
|
-
| Parameter | Type | Required |
|
|
46
|
-
| --- | --- | --- |
|
|
47
|
-
| `$request:UpdateOrderRequest` | object | Yes |
|
|
48
|
-
| `$id:int` | int | Yes |
|
|
49
|
-
|
|
50
|
-
#### Return Value
|
|
51
|
-
A `JsonResponse` with the updated order data.
|
|
52
|
-
|
|
53
|
-
### destroy
|
|
54
|
-
#### Description
|
|
55
|
-
Deletes an existing order.
|
|
56
|
-
#### Parameters
|
|
57
|
-
| Parameter | Type | Required |
|
|
58
|
-
| --- | --- | --- |
|
|
59
|
-
| `$id:int` | int | Yes |
|
|
60
|
-
|
|
61
|
-
#### Return Value
|
|
62
|
-
A `JsonResponse` with HTTP status code 204.
|
|
63
|
-
|
|
64
|
-
## Dependencies
|
|
65
|
-
|
|
66
|
-
* `App\Models\Order`
|
|
67
|
-
* `App\Models\User`
|
|
68
|
-
* `App\Http\Requests\StoreOrderRequest`
|
|
69
|
-
* `App\Http\Requests\UpdateOrderRequest`
|
|
70
|
-
* `App\Services\OrderService`
|
|
71
|
-
* `Illuminate\Http\JsonResponse`
|
|
72
|
-
|
|
73
|
-
## Usage Example
|
|
74
|
-
```php
|
|
75
|
-
$orderController = new OrderController();
|
|
76
|
-
$orders = $orderController->index(); // returns paginated list of orders
|
|
77
|
-
|
|
78
|
-
$order = $orderController->store(new StoreOrderRequest(['name' => 'New Order'])); // creates and returns order details
|
|
79
|
-
```
|
|
1
|
+
## Overview
|
|
2
|
+
This is the `OrderController` class, responsible for handling CRUD (Create, Read, Update, Delete) operations on orders. It provides a RESTful API interface to interact with the order data.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
|
|
6
|
+
### index
|
|
7
|
+
#### Description
|
|
8
|
+
Returns a paginated list of orders.
|
|
9
|
+
#### Parameters
|
|
10
|
+
| Parameter | Type | Required |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `paginate` | int | - |
|
|
13
|
+
| `response` | object | - |
|
|
14
|
+
| `json` | function | - |
|
|
15
|
+
|
|
16
|
+
#### Return Value
|
|
17
|
+
A `JsonResponse` containing the paginated list of orders.
|
|
18
|
+
|
|
19
|
+
### store
|
|
20
|
+
#### Description
|
|
21
|
+
Creates a new order and returns its details.
|
|
22
|
+
#### Parameters
|
|
23
|
+
| Parameter | Type | Required |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `$request:StoreOrderRequest` | object | Yes |
|
|
26
|
+
|
|
27
|
+
#### Return Value
|
|
28
|
+
A `JsonResponse` with the created order data and HTTP status code 201.
|
|
29
|
+
|
|
30
|
+
### show
|
|
31
|
+
#### Description
|
|
32
|
+
Returns a single order by its ID.
|
|
33
|
+
#### Parameters
|
|
34
|
+
| Parameter | Type | Required |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `$id:int` | int | Yes |
|
|
37
|
+
|
|
38
|
+
#### Return Value
|
|
39
|
+
A `JsonResponse` containing the order details.
|
|
40
|
+
|
|
41
|
+
### update
|
|
42
|
+
#### Description
|
|
43
|
+
Updates an existing order.
|
|
44
|
+
#### Parameters
|
|
45
|
+
| Parameter | Type | Required |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| `$request:UpdateOrderRequest` | object | Yes |
|
|
48
|
+
| `$id:int` | int | Yes |
|
|
49
|
+
|
|
50
|
+
#### Return Value
|
|
51
|
+
A `JsonResponse` with the updated order data.
|
|
52
|
+
|
|
53
|
+
### destroy
|
|
54
|
+
#### Description
|
|
55
|
+
Deletes an existing order.
|
|
56
|
+
#### Parameters
|
|
57
|
+
| Parameter | Type | Required |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `$id:int` | int | Yes |
|
|
60
|
+
|
|
61
|
+
#### Return Value
|
|
62
|
+
A `JsonResponse` with HTTP status code 204.
|
|
63
|
+
|
|
64
|
+
## Dependencies
|
|
65
|
+
|
|
66
|
+
* `App\Models\Order`
|
|
67
|
+
* `App\Models\User`
|
|
68
|
+
* `App\Http\Requests\StoreOrderRequest`
|
|
69
|
+
* `App\Http\Requests\UpdateOrderRequest`
|
|
70
|
+
* `App\Services\OrderService`
|
|
71
|
+
* `Illuminate\Http\JsonResponse`
|
|
72
|
+
|
|
73
|
+
## Usage Example
|
|
74
|
+
```php
|
|
75
|
+
$orderController = new OrderController();
|
|
76
|
+
$orders = $orderController->index(); // returns paginated list of orders
|
|
77
|
+
|
|
78
|
+
$order = $orderController->store(new StoreOrderRequest(['name' => 'New Order'])); // creates and returns order details
|
|
79
|
+
```
|
|
80
80
|
Note: The usage example is just a demonstration and should be replaced with actual usage scenarios.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Summary
|
|
2
|
-
|
|
1
|
+
# Summary
|
|
2
|
+
|
|
3
3
|
* [OrderController.php](OrderController.md)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
The `legacyver` CLI tool is an AI-powered tool for auto-generating technical documentation from legacy/undocumented codebases. It provides various commands for analysis, initialization, provider management, caching, login, logout, and pushing documentation to the cloud.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
### `analyzeCmd`
|
|
6
|
+
#### Description
|
|
7
|
+
Analyze a directory and generate documentation.
|
|
8
|
+
|
|
9
|
+
#### Parameters
|
|
10
|
+
| Name | Type | Description |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `target` | string | The directory to analyze. |
|
|
13
|
+
| `--out <dir>` | string | Output directory (default: `./legacyver-docs`). |
|
|
14
|
+
| `--format <fmt>` | string | Output format: `markdown`, `html`, or `json` (default: `markdown`). |
|
|
15
|
+
| `--model <model>` | string | LLM model to use. |
|
|
16
|
+
| `--provider <provider>` | string | LLM provider: `groq` or `ollama` (default: `groq`). |
|
|
17
|
+
| `--concurrency <n>` | number | Concurrent LLM requests (1-10) (default: `3`). |
|
|
18
|
+
| `--dry-run` | boolean | Run AST parsing only, no LLM calls. |
|
|
19
|
+
| `--incremental` | boolean | Only re-analyze changed files. |
|
|
20
|
+
| `--no-confirm` | boolean | Skip cost confirmation prompt. |
|
|
21
|
+
| `--json-summary` | boolean | Output machine-readable JSON summary. |
|
|
22
|
+
| `--max-file-size <kb>` | number | Skip files larger than this size in KB (default: `500`). |
|
|
23
|
+
|
|
24
|
+
#### Return Value
|
|
25
|
+
None
|
|
26
|
+
|
|
27
|
+
### `initCmd`
|
|
28
|
+
#### Description
|
|
29
|
+
Interactive setup wizard — saves API key and creates `.legacyverrc`.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
None
|
|
33
|
+
|
|
34
|
+
#### Return Value
|
|
35
|
+
None
|
|
36
|
+
|
|
37
|
+
### `providersCmd`
|
|
38
|
+
#### Description
|
|
39
|
+
List supported LLM providers and available models.
|
|
40
|
+
|
|
41
|
+
#### Parameters
|
|
42
|
+
None
|
|
43
|
+
|
|
44
|
+
#### Return Value
|
|
45
|
+
None
|
|
46
|
+
|
|
47
|
+
### `cacheCmd`
|
|
48
|
+
#### Description
|
|
49
|
+
Manage the incremental analysis cache.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
None
|
|
53
|
+
|
|
54
|
+
#### Return Value
|
|
55
|
+
None
|
|
56
|
+
|
|
57
|
+
### `loginCmd`
|
|
58
|
+
#### Description
|
|
59
|
+
Log in to sync generated docs to the cloud.
|
|
60
|
+
|
|
61
|
+
#### Parameters
|
|
62
|
+
None
|
|
63
|
+
|
|
64
|
+
#### Return Value
|
|
65
|
+
None
|
|
66
|
+
|
|
67
|
+
### `logoutCmd`
|
|
68
|
+
#### Description
|
|
69
|
+
Log out and stop syncing docs to the cloud.
|
|
70
|
+
|
|
71
|
+
#### Parameters
|
|
72
|
+
None
|
|
73
|
+
|
|
74
|
+
#### Return Value
|
|
75
|
+
None
|
|
76
|
+
|
|
77
|
+
### `pushCmd`
|
|
78
|
+
#### Description
|
|
79
|
+
Manually push generated docs to the cloud database.
|
|
80
|
+
|
|
81
|
+
#### Parameters
|
|
82
|
+
| Name | Type | Description |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| `target` | string | The directory to push from. |
|
|
85
|
+
| `--out <dir>` | string | Docs output directory to read from (default: `./legacyver-docs`). |
|
|
86
|
+
|
|
87
|
+
#### Return Value
|
|
88
|
+
None
|
|
89
|
+
|
|
90
|
+
## Dependencies
|
|
91
|
+
* `commander`
|
|
92
|
+
* `fs`
|
|
93
|
+
* `path`
|
|
94
|
+
* `dotenv`
|
|
95
|
+
* `../src/cli/commands/analyze`
|
|
96
|
+
* `../src/cli/commands/init`
|
|
97
|
+
* `../src/cli/commands/providers`
|
|
98
|
+
* `../src/cli/commands/cache`
|
|
99
|
+
* `../src/cli/commands/login`
|
|
100
|
+
* `../src/cli/commands/logout`
|
|
101
|
+
* `../src/cli/commands/push`
|
|
102
|
+
|
|
103
|
+
## Usage Example
|
|
104
|
+
```bash
|
|
105
|
+
legacyver analyze my-project --out docs --format markdown
|
|
106
|
+
```
|
|
107
|
+
This command analyzes the `my-project` directory, generates documentation in Markdown format, and outputs it to the `docs` directory.
|
package/legacyver-docs/index.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# Controllers — Documentation
|
|
2
|
-
|
|
3
|
-
**Primary language:** php
|
|
4
|
-
**Total files:** 1
|
|
5
|
-
**Analyzed at:** 2026-02-22T03:45:37.186Z
|
|
6
|
-
|
|
7
|
-
## Files
|
|
8
|
-
|
|
9
|
-
- [OrderController.php](OrderController.md)
|
|
10
|
-
|
|
11
|
-
## Dependency Graph
|
|
12
|
-
|
|
13
|
-
```mermaid
|
|
14
|
-
graph TD
|
|
15
|
-
```
|
|
1
|
+
# Controllers — Documentation
|
|
2
|
+
|
|
3
|
+
**Primary language:** php
|
|
4
|
+
**Total files:** 1
|
|
5
|
+
**Analyzed at:** 2026-02-22T03:45:37.186Z
|
|
6
|
+
|
|
7
|
+
## Files
|
|
8
|
+
|
|
9
|
+
- [OrderController.php](OrderController.md)
|
|
10
|
+
|
|
11
|
+
## Dependency Graph
|
|
12
|
+
|
|
13
|
+
```mermaid
|
|
14
|
+
graph TD
|
|
15
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
This module provides two functions for managing CLI session tokens: `validateToken` and `revokeToken`. These functions interact with a PostgreSQL database to validate and revoke tokens.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
|
|
6
|
+
### validateToken
|
|
7
|
+
Validates a CLI session token against app.user_sessions.
|
|
8
|
+
|
|
9
|
+
* **Description**: Returns user info if valid, null if expired/revoked/not found.
|
|
10
|
+
* **Params**:
|
|
11
|
+
+ `token`: raw token from ~/.legacyver/session.json (string)
|
|
12
|
+
+ `opts`: optional overrides for testing (object)
|
|
13
|
+
- `pool`: pg Pool instance (object)
|
|
14
|
+
* **Return Value**: Promise<{userId: string, username: string, email: string} | null>
|
|
15
|
+
|
|
16
|
+
### revokeToken
|
|
17
|
+
Revoke a CLI session token (logout).
|
|
18
|
+
|
|
19
|
+
* **Description**: Revoke a CLI session token.
|
|
20
|
+
* **Params**:
|
|
21
|
+
+ `token`: raw token (string)
|
|
22
|
+
+ `opts`: optional overrides for testing (object)
|
|
23
|
+
- `pool`: pg Pool instance (object)
|
|
24
|
+
* **Return Value**: None
|
|
25
|
+
|
|
26
|
+
## Dependencies
|
|
27
|
+
* `crypto`: crypto module
|
|
28
|
+
* `pg`: pg module
|
|
29
|
+
* `../db/config`: dbConfig module
|
|
30
|
+
|
|
31
|
+
## Usage Example
|
|
32
|
+
```javascript
|
|
33
|
+
const { validateToken, revokeToken } = require('./auth');
|
|
34
|
+
|
|
35
|
+
// Validate a token
|
|
36
|
+
const token = 'your_token_here';
|
|
37
|
+
const opts = { pool: your_pool_instance };
|
|
38
|
+
validateToken(token, opts).then((userInfo) => {
|
|
39
|
+
console.log(userInfo);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Revoke a token
|
|
43
|
+
const token = 'your_token_here';
|
|
44
|
+
revokeToken(token, opts).then(() => {
|
|
45
|
+
console.log('Token revoked');
|
|
46
|
+
});
|
|
47
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
This module provides a function to compute the SHA-256 hash of a file.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
### computeHash
|
|
6
|
+
Computes the SHA-256 hash of a file.
|
|
7
|
+
|
|
8
|
+
| Parameter | Type | Description |
|
|
9
|
+
| --- | --- | --- |
|
|
10
|
+
| filePath | string | Path to the file to compute the hash for |
|
|
11
|
+
|
|
12
|
+
| Return Value | Type | Description |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| string | The SHA-256 hash as a hex string prefixed with 'sha256:' |
|
|
15
|
+
|
|
16
|
+
## Dependencies
|
|
17
|
+
* crypto: createHash
|
|
18
|
+
* fs: readFileSync
|
|
19
|
+
|
|
20
|
+
## Usage Example
|
|
21
|
+
```javascript
|
|
22
|
+
const { computeHash } = require('./hash');
|
|
23
|
+
console.log(computeHash('path/to/file.txt'));
|
|
24
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
This module provides functions for managing a cache of file hashes in a `.legacyver-cache` directory. It includes functions for loading and saving the cache, separating files into cache hits and misses, removing entries for files that no longer exist on disk, and auto-adding the cache directory to `.gitignore`.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
|
|
6
|
+
### loadCache
|
|
7
|
+
Load cache from `.legacyver-cache/hashes.json`.
|
|
8
|
+
|
|
9
|
+
* **Params:**
|
|
10
|
+
+ `cacheDir`: string
|
|
11
|
+
* **Returns:** Object
|
|
12
|
+
+ map of relativePath -> { hash, docFile, generatedAt }
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
function loadCache(cacheDir) {
|
|
16
|
+
const cachePath = path.join(cacheDir, CACHE_FILE);
|
|
17
|
+
if (!existsSync(cachePath)) return {};
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(readFileSync(cachePath, 'utf8'));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
logger.warn(`Could not read cache: ${e.message}`);
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### saveCache
|
|
28
|
+
Save cache to `.legacyver-cache/hashes.json`.
|
|
29
|
+
|
|
30
|
+
* **Params:**
|
|
31
|
+
+ `cacheDir`: string
|
|
32
|
+
+ `map`: Object
|
|
33
|
+
* **Returns:** None
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
function saveCache(cacheDir, map) {
|
|
37
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
38
|
+
const cachePath = path.join(cacheDir, CACHE_FILE);
|
|
39
|
+
writeFileSync(cachePath, JSON.stringify(map, null, 2), 'utf8');
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### getCacheHits
|
|
44
|
+
Separate files into cache hits and misses.
|
|
45
|
+
|
|
46
|
+
* **Params:**
|
|
47
|
+
+ `manifest`: Array of FileManifest[]
|
|
48
|
+
+ `cacheMap`: Object
|
|
49
|
+
* **Returns:** { hits: Array, misses: Array }
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
function getCacheHits(manifest, cacheMap) {
|
|
53
|
+
const hits = [];
|
|
54
|
+
const misses = [];
|
|
55
|
+
for (const file of manifest) {
|
|
56
|
+
const cached = cacheMap[file.relativePath];
|
|
57
|
+
if (cached && cached.hash === file.hash) {
|
|
58
|
+
hits.push(file);
|
|
59
|
+
} else {
|
|
60
|
+
misses.push(file);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { hits, misses };
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### purgeDeleted
|
|
68
|
+
Remove entries for files that no longer exist on disk.
|
|
69
|
+
|
|
70
|
+
* **Params:**
|
|
71
|
+
+ `cacheMap`: Object (mutated in place)
|
|
72
|
+
+ `currentPaths`: string[]
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
function purgeDeleted(cacheMap, currentPaths) {
|
|
76
|
+
const current = new Set(currentPaths);
|
|
77
|
+
for (const key of Object.keys(cacheMap)) {
|
|
78
|
+
if (!current.has(key)) {
|
|
79
|
+
delete cacheMap[key];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### autoAddToGitignore
|
|
86
|
+
Auto-add `.legacyver-cache/` to `.gitignore` if it exists in `projectRoot`.
|
|
87
|
+
|
|
88
|
+
* **Params:**
|
|
89
|
+
+ `projectRoot`: string
|
|
90
|
+
* **Patterns:**
|
|
91
|
+
+ arithmetic (used for appending to `.gitignore`)
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
function autoAddToGitignore(projectRoot) {
|
|
95
|
+
const gitignorePath = path.join(projectRoot, '.gitignore');
|
|
96
|
+
if (!existsSync(gitignorePath)) return;
|
|
97
|
+
const content = readFileSync(gitignorePath, 'utf8');
|
|
98
|
+
if (!content.includes('.legacyver-cache')) {
|
|
99
|
+
appendFileSync(gitignorePath, '\n.legacyver-cache/\n');
|
|
100
|
+
logger.info('Added.legacyver-cache/ to.gitignore');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Dependencies
|
|
106
|
+
|
|
107
|
+
* `fs`: readFileSync, writeFileSync, mkdirSync, existsSync, appendFileSync
|
|
108
|
+
* `path`: path
|
|
109
|
+
* `../utils/logger`: logger
|
|
110
|
+
|
|
111
|
+
## Usage Example
|
|
112
|
+
No clear pattern is visible in the code.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
The `analyzeCommand` function is the main entry point for the `analyze` CLI command. It takes a `target` directory and `flags` object as input, and performs a series of tasks to analyze the files in the target directory.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
### analyzeCommand
|
|
6
|
+
#### Description
|
|
7
|
+
Analyzes the files in the target directory using a series of stages, including crawling, incremental caching, AST parsing, dry run estimation, free model policy application, cost gate checking, and LLM engine execution.
|
|
8
|
+
|
|
9
|
+
#### Parameters
|
|
10
|
+
| Name | Type | Description |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| target | string | The target directory to analyze |
|
|
13
|
+
| flags | object | The CLI flags object |
|
|
14
|
+
|
|
15
|
+
#### Return Value
|
|
16
|
+
No return value
|
|
17
|
+
|
|
18
|
+
#### Dependencies
|
|
19
|
+
* `loadConfig`
|
|
20
|
+
* `crawl`
|
|
21
|
+
* `parseFiles`
|
|
22
|
+
* `estimateCost`
|
|
23
|
+
* `applyFreeModelPolicy`
|
|
24
|
+
* `createProvider`
|
|
25
|
+
* `validateFragment`
|
|
26
|
+
* `reprompt`
|
|
27
|
+
* `createQueue`
|
|
28
|
+
* `buildChunks`
|
|
29
|
+
|
|
30
|
+
## Dependencies
|
|
31
|
+
* `path`
|
|
32
|
+
* `loadConfig`
|
|
33
|
+
* `createSpinner`
|
|
34
|
+
* `createProgressBar`
|
|
35
|
+
* `confirmPrompt`
|
|
36
|
+
* `printSummary`
|
|
37
|
+
* `logger`
|
|
38
|
+
* `picocolors`
|
|
39
|
+
* `NoApiKeyError`
|
|
40
|
+
* `crawl`
|
|
41
|
+
* `cache`
|
|
42
|
+
* `parseFiles`
|
|
43
|
+
* `estimateCost`
|
|
44
|
+
* `buildChunks`
|
|
45
|
+
* `applyFreeModelPolicy`
|
|
46
|
+
* `createProvider`
|
|
47
|
+
* `validateFragment`
|
|
48
|
+
* `reprompt`
|
|
49
|
+
* `createQueue`
|
|
50
|
+
* `pushToDatabase`
|
|
51
|
+
* `loadSession`
|
|
52
|
+
|
|
53
|
+
## Usage Example
|
|
54
|
+
The `analyzeCommand` function can be used by running the `analyze` CLI command with the `--target` option followed by the target directory, and any desired flags. For example:
|
|
55
|
+
```bash
|
|
56
|
+
legacyver analyze --target /path/to/directory --provider groq --model my-model
|
|
57
|
+
```
|
|
58
|
+
This will perform the analysis on the files in the specified directory using the Groq provider and my-model model.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
This module exports a single asynchronous function, `cacheClearCommand`, which clears the cache directory.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
### cacheClearCommand
|
|
6
|
+
Clears the cache directory.
|
|
7
|
+
|
|
8
|
+
| Parameter | Type | Description |
|
|
9
|
+
| --- | --- | --- |
|
|
10
|
+
| None | | |
|
|
11
|
+
|
|
12
|
+
Return Value:
|
|
13
|
+
No return value.
|
|
14
|
+
|
|
15
|
+
## Dependencies
|
|
16
|
+
* `fs`: `existsSync`, `rmSync`
|
|
17
|
+
* `path`: `join`
|
|
18
|
+
* `picocolors`: `pc`
|
|
19
|
+
|
|
20
|
+
## Usage Example
|
|
21
|
+
The function clears the cache directory located at `.legacyver-cache/` in the current working directory. If the directory exists, it is deleted recursively with force. If the directory does not exist, a message indicating that no cache directory was found is logged.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
The `initCommand` function is the main entry point for the Legacyver setup wizard, responsible for guiding the user through the setup process and creating a configuration file.
|
|
3
|
+
|
|
4
|
+
## Functions
|
|
5
|
+
### ask
|
|
6
|
+
#### Description
|
|
7
|
+
Asks a question to the user and returns a promise that resolves with the user's response.
|
|
8
|
+
|
|
9
|
+
#### Parameters
|
|
10
|
+
| Name | Type | Description |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `rl` | `readline.Interface` | The readline interface to use for asking the question. |
|
|
13
|
+
| `question` | `string` | The question to ask the user. |
|
|
14
|
+
|
|
15
|
+
#### Return Value
|
|
16
|
+
A promise that resolves with the user's response.
|
|
17
|
+
|
|
18
|
+
### initCommand
|
|
19
|
+
#### Description
|
|
20
|
+
The main entry point for the Legacyver setup wizard, responsible for guiding the user through the setup process and creating a configuration file.
|
|
21
|
+
|
|
22
|
+
#### Parameters
|
|
23
|
+
None
|
|
24
|
+
|
|
25
|
+
#### Return Value
|
|
26
|
+
None
|
|
27
|
+
|
|
28
|
+
## Dependencies
|
|
29
|
+
* `fs`: `existsSync`, `writeFileSync`
|
|
30
|
+
* `path`: `join`
|
|
31
|
+
* `readline`: `readline.createInterface`
|
|
32
|
+
* `picocolors`: `pc`
|
|
33
|
+
|
|
34
|
+
## Usage Example
|
|
35
|
+
The `initCommand` function can be used as a standalone command to guide the user through the setup process and create a configuration file. For example:
|
|
36
|
+
```javascript
|
|
37
|
+
const initCommand = require('./init');
|
|
38
|
+
initCommand().then(() => {
|
|
39
|
+
console.log('Setup complete!');
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
Note: This example assumes that the `initCommand` function is exported from the `init.js` file.
|