legacyver 3.1.0 → 3.4.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 +1 -1
- package/legacyver-docs/auth.md +71 -0
- package/legacyver-docs/hash.md +37 -0
- package/package.json +3 -2
- package/src/api/auth.js +32 -45
- package/src/cli/commands/analyze.js +20 -1
- package/src/cli/commands/init.js +34 -4
- package/src/cli/commands/login.js +1 -1
- package/src/cli/commands/providers.js +20 -23
- package/src/cli/ui.js +19 -9
- package/src/db/config.js +39 -14
- package/src/db/index.js +69 -88
- package/src/llm/providers/groq.js +4 -2
- package/src/llm/validator.js +2 -2
- package/src/utils/config.js +1 -1
- package/legacyver-docs/bin/legacyver.md +0 -107
- package/legacyver-docs/src/api/auth.md +0 -47
- package/legacyver-docs/src/cache/hash.md +0 -24
- package/legacyver-docs/src/cache/index.md +0 -112
- package/legacyver-docs/src/cli/commands/analyze.md +0 -58
- package/legacyver-docs/src/cli/commands/cache.md +0 -21
- package/legacyver-docs/src/cli/commands/init.md +0 -42
- package/legacyver-docs/src/cli/commands/login.md +0 -70
- package/legacyver-docs/src/cli/commands/logout.md +0 -26
- package/legacyver-docs/src/cli/commands/providers.md +0 -23
- package/legacyver-docs/src/cli/commands/push.md +0 -48
- package/legacyver-docs/src/cli/commands/version.md +0 -26
- package/legacyver-docs/src/cli/ui.md +0 -112
- package/legacyver-docs/src/crawler/filters.md +0 -54
- package/legacyver-docs/src/crawler/index.md +0 -54
- package/legacyver-docs/src/crawler/manifest.md +0 -22
- package/legacyver-docs/src/crawler/walk.md +0 -29
- package/legacyver-docs/src/db/config.md +0 -13
- package/legacyver-docs/src/db/index.md +0 -86
- package/legacyver-docs/src/llm/chunker.md +0 -28
- package/legacyver-docs/src/llm/cost-estimator.md +0 -62
- package/legacyver-docs/src/llm/free-model.md +0 -40
- package/legacyver-docs/src/llm/index.md +0 -29
- package/legacyver-docs/src/llm/prompts.md +0 -150
- package/legacyver-docs/src/llm/providers/gemini.md +0 -51
- package/legacyver-docs/src/llm/providers/groq.md +0 -76
- package/legacyver-docs/src/llm/providers/kimi.md +0 -48
- package/legacyver-docs/src/llm/providers/ollama.md +0 -50
- package/legacyver-docs/src/llm/providers/openrouter.md +0 -55
- package/legacyver-docs/src/llm/queue.md +0 -41
- package/legacyver-docs/src/llm/re-prompter.md +0 -33
- package/legacyver-docs/src/llm/validator.md +0 -34
- package/legacyver-docs/src/parser/ast/generic.md +0 -34
- package/legacyver-docs/src/parser/ast/go.md +0 -59
- package/legacyver-docs/src/parser/ast/java.md +0 -58
- package/legacyver-docs/src/parser/ast/javascript.md +0 -71
- package/legacyver-docs/src/parser/ast/laravel/blade.md +0 -45
- package/legacyver-docs/src/parser/ast/laravel/classifier.md +0 -29
- package/legacyver-docs/src/parser/ast/laravel/controller.md +0 -57
- package/legacyver-docs/src/parser/ast/laravel/index.md +0 -27
- package/legacyver-docs/src/parser/ast/laravel/model.md +0 -34
- package/legacyver-docs/src/parser/ast/laravel/provider.md +0 -31
- package/legacyver-docs/src/parser/ast/laravel/routes.md +0 -31
- package/legacyver-docs/src/parser/ast/php.md +0 -127
- package/legacyver-docs/src/parser/ast/python.md +0 -62
- package/legacyver-docs/src/parser/ast/typescript.md +0 -22
- package/legacyver-docs/src/parser/body-extractor.md +0 -34
- package/legacyver-docs/src/parser/call-graph.md +0 -45
- package/legacyver-docs/src/parser/complexity-scorer.md +0 -25
- package/legacyver-docs/src/parser/index.md +0 -59
- package/legacyver-docs/src/parser/pattern-detector.md +0 -28
- package/legacyver-docs/src/parser/pkg-builder.md +0 -34
- package/legacyver-docs/src/renderer/html.md +0 -36
- package/legacyver-docs/src/renderer/index.md +0 -26
- package/legacyver-docs/src/renderer/json.md +0 -25
- package/legacyver-docs/src/renderer/markdown.md +0 -77
- package/legacyver-docs/src/utils/config.md +0 -62
- package/legacyver-docs/src/utils/errors.md +0 -53
- package/legacyver-docs/src/utils/logger.md +0 -48
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
The `body-extractor` module exports a single function, `extractBodySnippet`, which extracts a body snippet from a given source text based on line start and end positions.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### extractBodySnippet
|
|
6
|
-
Extracts a body snippet from source text given line start/end positions.
|
|
7
|
-
|
|
8
|
-
| Param | Type | Description |
|
|
9
|
-
| --- | --- | --- |
|
|
10
|
-
| sourceText | string | The source text to extract the body snippet from. |
|
|
11
|
-
| lineStart | number | The 1-indexed line number to start the body snippet from. |
|
|
12
|
-
| lineEnd | number | The 1-indexed line number to end the body snippet at. |
|
|
13
|
-
| complexityScore | number | The complexity score of the function (not used in the function). |
|
|
14
|
-
|
|
15
|
-
Returns:
|
|
16
|
-
| Type | Description |
|
|
17
|
-
| --- | --- |
|
|
18
|
-
| { bodySnippet: string|null, bodySnippetTruncated: boolean } | An object containing the extracted body snippet and a boolean indicating whether the snippet was truncated. |
|
|
19
|
-
|
|
20
|
-
## Dependencies
|
|
21
|
-
* `MAX_BODY_LINES` (a constant)
|
|
22
|
-
|
|
23
|
-
## Usage Example
|
|
24
|
-
```javascript
|
|
25
|
-
const sourceText = 'function foo() {\n console.log("Hello World!");\n console.log("This is a test.");\n}';
|
|
26
|
-
const lineStart = 1;
|
|
27
|
-
const lineEnd = 2;
|
|
28
|
-
const complexityScore = 5;
|
|
29
|
-
|
|
30
|
-
const result = extractBodySnippet(sourceText, lineStart, lineEnd, complexityScore);
|
|
31
|
-
console.log(result.bodySnippet);
|
|
32
|
-
console.log(result.bodySnippetTruncated);
|
|
33
|
-
```
|
|
34
|
-
Note: The usage example is not explicitly shown in the code, but it can be inferred based on the function signature and the logic of the function.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This module exports a function `buildCallGraph` that constructs a cross-file call graph by resolving import paths.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
|
|
6
|
-
### buildCallGraph
|
|
7
|
-
Builds a cross-file call graph by resolving import paths.
|
|
8
|
-
|
|
9
|
-
| Param | Type | Description |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| allFacts | array | An array of facts containing relative paths and import information |
|
|
12
|
-
|
|
13
|
-
| Return Value | Type | Description |
|
|
14
|
-
| --- | --- | --- |
|
|
15
|
-
| allFacts | array | The input array with call graph information added |
|
|
16
|
-
|
|
17
|
-
### resolveImport
|
|
18
|
-
Resolves an import path by searching for matching files in the file map.
|
|
19
|
-
|
|
20
|
-
| Param | Type | Description |
|
|
21
|
-
| --- | --- | --- |
|
|
22
|
-
| modulePath | string | The import path to resolve |
|
|
23
|
-
| fromPath | string | The path from which to resolve the import |
|
|
24
|
-
| fileMap | Map | A map of file paths to facts |
|
|
25
|
-
|
|
26
|
-
| Return Value | Type | Description |
|
|
27
|
-
| --- | --- | --- |
|
|
28
|
-
| resolved | string | The resolved import path, or null if not found |
|
|
29
|
-
|
|
30
|
-
## Dependencies
|
|
31
|
-
* `Map`
|
|
32
|
-
* `set`
|
|
33
|
-
* `of`
|
|
34
|
-
* `resolveImport`
|
|
35
|
-
* `includes`
|
|
36
|
-
* `push`
|
|
37
|
-
* `get`
|
|
38
|
-
|
|
39
|
-
## Usage Example
|
|
40
|
-
```javascript
|
|
41
|
-
const allFacts = [...]; // array of facts
|
|
42
|
-
const callGraph = buildCallGraph(allFacts);
|
|
43
|
-
console.log(callGraph);
|
|
44
|
-
```
|
|
45
|
-
Note: A clear usage example is not visible in the code, so this section is empty.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
The `scoreComplexity` function scores a function's complexity based on its body text using heuristics.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### scoreComplexity
|
|
6
|
-
Scores a function's complexity based on its body text.
|
|
7
|
-
|
|
8
|
-
| Parameter | Type | Description |
|
|
9
|
-
| --- | --- | --- |
|
|
10
|
-
| bodyText | string | Raw source of the function body |
|
|
11
|
-
|
|
12
|
-
| Return Value | Type | Description |
|
|
13
|
-
| --- | --- | --- |
|
|
14
|
-
| { complexityScore: number, complexityClass: string, detectedPatterns: string[] } | object | Complexity score, class, and detected patterns |
|
|
15
|
-
|
|
16
|
-
## Dependencies
|
|
17
|
-
* `./pattern-detector` (imported as `DOMAIN_PATTERNS`)
|
|
18
|
-
|
|
19
|
-
## Usage Example
|
|
20
|
-
The code snippet below demonstrates how to use the `scoreComplexity` function:
|
|
21
|
-
```javascript
|
|
22
|
-
const complexityScore = scoreComplexity('function example() { /* code */ }');
|
|
23
|
-
console.log(complexityScore);
|
|
24
|
-
```
|
|
25
|
-
Note: This example is not directly visible in the code, but it can be inferred based on the function's signature and usage.
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This module exports two functions, `parseFile` and `parseFiles`, which are used to parse files and assemble a Package (PKG) respectively.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
|
|
6
|
-
### parseFile
|
|
7
|
-
Dispatch parsing to the appropriate language parser.
|
|
8
|
-
|
|
9
|
-
#### Description
|
|
10
|
-
This function takes a `fileManifest` object and a `meta` object as input, and returns a `FileFacts` object.
|
|
11
|
-
|
|
12
|
-
#### Parameters
|
|
13
|
-
| Name | Type | Description |
|
|
14
|
-
| --- | --- | --- |
|
|
15
|
-
| fileManifest | `import('../crawler/index').FileManifest` | File metadata |
|
|
16
|
-
| meta | `Object` | Project metadata (includes framework) |
|
|
17
|
-
|
|
18
|
-
#### Return Value
|
|
19
|
-
`FileFacts` object
|
|
20
|
-
|
|
21
|
-
#### Body Logic
|
|
22
|
-
The function first tries to read the file using `readFileSync`. If successful, it dispatches parsing to the appropriate language parser using the `PARSERS` object. If the language is not supported, it falls back to the generic parser. The parsed facts are then enriched with Laravel-specific information if the language is PHP and the framework is Laravel.
|
|
23
|
-
|
|
24
|
-
### parseFiles
|
|
25
|
-
Parse all files and assemble the PKG.
|
|
26
|
-
|
|
27
|
-
#### Description
|
|
28
|
-
This function takes an array of `fileManifest` objects, a `meta` object, and a `config` object as input, and returns a `PKG` object.
|
|
29
|
-
|
|
30
|
-
#### Parameters
|
|
31
|
-
| Name | Type | Description |
|
|
32
|
-
| --- | --- | --- |
|
|
33
|
-
| files | `import('../crawler/index').FileManifest[]` | Array of file metadata |
|
|
34
|
-
| meta | `Object` | Project metadata |
|
|
35
|
-
| config | `Object` | Configuration object |
|
|
36
|
-
|
|
37
|
-
#### Return Value
|
|
38
|
-
`PKG` object
|
|
39
|
-
|
|
40
|
-
#### Body Logic
|
|
41
|
-
The function iterates over the array of file metadata, parses each file using `parseFile`, and collects the parsed facts in an array. It then builds a call graph using the `buildCallGraph` function and assembles the PKG using the `buildPKG` function.
|
|
42
|
-
|
|
43
|
-
## Dependencies
|
|
44
|
-
|
|
45
|
-
* `path`
|
|
46
|
-
* `fs`
|
|
47
|
-
* `../utils/logger`
|
|
48
|
-
* `./ast/laravel/index`
|
|
49
|
-
* `./call-graph`
|
|
50
|
-
* `./pkg-builder`
|
|
51
|
-
|
|
52
|
-
## Usage Example
|
|
53
|
-
```javascript
|
|
54
|
-
const files = [...]; // array of file metadata
|
|
55
|
-
const meta = {...}; // project metadata
|
|
56
|
-
const config = {...}; // configuration object
|
|
57
|
-
|
|
58
|
-
const pkg = await parseFiles(files, meta, config);
|
|
59
|
-
```
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This module provides a domain pattern detector that scans function body text for known patterns. It exports two functions: `detectPatterns` and `PATTERNS`.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### detectPatterns
|
|
6
|
-
#### Description
|
|
7
|
-
Scans the provided `bodyText` for known patterns and returns an array of matching pattern names.
|
|
8
|
-
|
|
9
|
-
#### Parameters
|
|
10
|
-
| Name | Type | Description |
|
|
11
|
-
| --- | --- | --- |
|
|
12
|
-
| bodyText | string | The text to scan for patterns |
|
|
13
|
-
|
|
14
|
-
#### Return Value
|
|
15
|
-
An array of pattern names that match the provided `bodyText`
|
|
16
|
-
|
|
17
|
-
### PATTERNS
|
|
18
|
-
#### Description
|
|
19
|
-
An array of objects containing pattern definitions.
|
|
20
|
-
|
|
21
|
-
## Dependencies
|
|
22
|
-
* None
|
|
23
|
-
|
|
24
|
-
## Usage Example
|
|
25
|
-
```javascript
|
|
26
|
-
const patterns = detectPatterns('/* */');
|
|
27
|
-
console.log(patterns); // Output: ['arithmetic']
|
|
28
|
-
```
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
The `buildPKG` function assembles all FileFacts into a Project Knowledge Graph (PKG) based on the provided `allFacts` and `meta` objects.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### buildPKG
|
|
6
|
-
#### Description
|
|
7
|
-
Assemble all FileFacts into a Project Knowledge Graph (PKG).
|
|
8
|
-
|
|
9
|
-
#### Parameters
|
|
10
|
-
| Name | Type | Description |
|
|
11
|
-
| --- | --- | --- |
|
|
12
|
-
| allFacts | Array | An array of FileFacts objects. |
|
|
13
|
-
| meta | Object | An object containing metadata about the project. |
|
|
14
|
-
|
|
15
|
-
#### Return Value
|
|
16
|
-
An object containing the following properties:
|
|
17
|
-
* `meta`: An object containing the original `meta` object with an additional `totalFiles` property set to the length of `allFacts`.
|
|
18
|
-
* `files`: An object where each key is a file path and the value is the corresponding FileFacts object.
|
|
19
|
-
* `entryPoints`: An array of file paths that are not called by any other file.
|
|
20
|
-
* `graph`: An object where each key is a file path and the value is an array of files that the file calls.
|
|
21
|
-
* `laravelMeta`: An object containing aggregated metadata for Laravel projects, including route maps, relationships, provider bindings, and model names.
|
|
22
|
-
|
|
23
|
-
## Dependencies
|
|
24
|
-
* `module.exports`
|
|
25
|
-
|
|
26
|
-
## Usage Example
|
|
27
|
-
The `buildPKG` function can be used to assemble a Project Knowledge Graph from an array of FileFacts objects and a metadata object. For example:
|
|
28
|
-
```javascript
|
|
29
|
-
const allFacts = [...]; // array of FileFacts objects
|
|
30
|
-
const meta = { ... }; // metadata object
|
|
31
|
-
const pkg = buildPKG(allFacts, meta);
|
|
32
|
-
console.log(pkg);
|
|
33
|
-
```
|
|
34
|
-
Note that this example assumes that the `buildPKG` function is exported as a module and can be imported and used in a separate script.
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
The `render` function generates a single self-contained HTML file with lunr.js search functionality for documentation fragments.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### render
|
|
6
|
-
* Description: Generates a single HTML file with lunr.js search functionality for documentation fragments.
|
|
7
|
-
* Parameters:
|
|
8
|
-
+ `fragments`: An array of documentation fragments.
|
|
9
|
-
+ `pkg`: The package metadata.
|
|
10
|
-
+ `outputDir`: The directory to output the HTML file.
|
|
11
|
-
+ `config`: The configuration object (not used in the code).
|
|
12
|
-
* Return Value: None (writes the HTML file to disk)
|
|
13
|
-
* Calls:
|
|
14
|
-
+ `mkdirSync`
|
|
15
|
-
+ `map`
|
|
16
|
-
+ `replace`
|
|
17
|
-
+ `join`
|
|
18
|
-
+ `marked`
|
|
19
|
-
+ `stringify`
|
|
20
|
-
+ `lunr`
|
|
21
|
-
+ `field`
|
|
22
|
-
+ `forEach`
|
|
23
|
-
+ `add`
|
|
24
|
-
+ `getElementById`
|
|
25
|
-
+ `addEventListener`
|
|
26
|
-
+ `trim`
|
|
27
|
-
+ `search`
|
|
28
|
-
+ `writeFileSync`
|
|
29
|
-
|
|
30
|
-
## Dependencies
|
|
31
|
-
* `fs`: `writeFileSync`, `mkdirSync`
|
|
32
|
-
* `path`: `path`
|
|
33
|
-
* `marked`: `marked`
|
|
34
|
-
|
|
35
|
-
## Usage Example
|
|
36
|
-
The `render` function can be used to generate a single HTML file with lunr.js search functionality for documentation fragments. The function takes an array of fragments, package metadata, output directory, and configuration object as input. It generates the HTML file and writes it to the output directory. The HTML file includes a search bar and displays the documentation fragments in a list. When a search query is entered, the function uses lunr.js to search the documentation fragments and displays the results.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
The `render` function is a renderer dispatcher that takes in fragments, a package object, an output directory, and a configuration object, and renders the fragments in the specified format.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### render
|
|
6
|
-
| Parameter | Type | Description |
|
|
7
|
-
| --- | --- | --- |
|
|
8
|
-
| fragments | | The fragments to be rendered |
|
|
9
|
-
| pkg | | The package object |
|
|
10
|
-
| outputDir | | The directory where the rendered output will be written |
|
|
11
|
-
| config | | The configuration object |
|
|
12
|
-
|
|
13
|
-
Returns: `Promise<void>`
|
|
14
|
-
|
|
15
|
-
## Dependencies
|
|
16
|
-
* `fs: mkdirSync`
|
|
17
|
-
* `../utils/errors: RenderError`
|
|
18
|
-
|
|
19
|
-
## Usage Example
|
|
20
|
-
Based on the code, it appears that the `render` function can be used to render fragments in different formats (HTML, JSON, or Markdown) by passing the desired format in the `config.format` property. For example:
|
|
21
|
-
```javascript
|
|
22
|
-
const render = require('./renderer');
|
|
23
|
-
const config = { format: 'html' };
|
|
24
|
-
render(fragments, pkg, outputDir, config);
|
|
25
|
-
```
|
|
26
|
-
Note: The usage example is based on the detected pattern in the code, where the `config.format` property is used to determine the rendering format.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
The `render` function is a JSON renderer that enriches the `pkg` object with LLM (Large Language Model) descriptions from the provided `fragments`. It writes the enriched `pkg` object to a JSON file in the specified `outputDir`.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### render
|
|
6
|
-
#### Description
|
|
7
|
-
Enriches the `pkg` object with LLM descriptions from the provided `fragments` and writes the enriched object to a JSON file.
|
|
8
|
-
|
|
9
|
-
#### Parameters
|
|
10
|
-
| Name | Type | Description |
|
|
11
|
-
| --- | --- | --- |
|
|
12
|
-
| fragments | array | An array of objects containing LLM descriptions |
|
|
13
|
-
| pkg | object | The package object to be enriched |
|
|
14
|
-
| outputDir | string | The directory where the enriched JSON file will be written |
|
|
15
|
-
| config | object | (not used in the code) |
|
|
16
|
-
|
|
17
|
-
#### Return Value
|
|
18
|
-
None
|
|
19
|
-
|
|
20
|
-
## Dependencies
|
|
21
|
-
* `fs: writeFileSync, mkdirSync`
|
|
22
|
-
* `path: path`
|
|
23
|
-
|
|
24
|
-
## Usage Example
|
|
25
|
-
Since the code does not provide a clear usage example, there is no example to document.
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This module exports a single function, `render`, which generates Markdown files for a project's documentation. It takes four parameters: `fragments`, `pkg`, `outputDir`, and `config`.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
|
|
6
|
-
### render
|
|
7
|
-
#### Description
|
|
8
|
-
Generates Markdown files for a project's documentation.
|
|
9
|
-
|
|
10
|
-
#### Parameters
|
|
11
|
-
| Name | Type | Description |
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| fragments | array | An array of objects containing file metadata. |
|
|
14
|
-
| pkg | object | An object containing project metadata. |
|
|
15
|
-
| outputDir | string | The directory where the generated Markdown files will be written. |
|
|
16
|
-
| config | object | An object containing configuration settings (not used in this function). |
|
|
17
|
-
|
|
18
|
-
#### Return Value
|
|
19
|
-
None (async)
|
|
20
|
-
|
|
21
|
-
#### Detected Patterns
|
|
22
|
-
* Arithmetic operations
|
|
23
|
-
|
|
24
|
-
#### Body
|
|
25
|
-
The function creates a directory for the output files, then iterates over the `fragments` array. For each fragment, it creates a Markdown file with the fragment's content and adds a line to the `summaryLines` array. Finally, it writes the `summaryLines` array to a file named `SUMMARY.md` and writes the result of calling `buildIndexMd` to a file named `index.md`.
|
|
26
|
-
|
|
27
|
-
### buildIndexMd
|
|
28
|
-
#### Description
|
|
29
|
-
Generates the content of the `index.md` file.
|
|
30
|
-
|
|
31
|
-
#### Parameters
|
|
32
|
-
| Name | Type | Description |
|
|
33
|
-
| --- | --- | --- |
|
|
34
|
-
| pkg | object | An object containing project metadata. |
|
|
35
|
-
| fragments | array | An array of objects containing file metadata. |
|
|
36
|
-
|
|
37
|
-
#### Return Value
|
|
38
|
-
A string containing the Markdown content of the `index.md` file.
|
|
39
|
-
|
|
40
|
-
#### Detected Patterns
|
|
41
|
-
* Arithmetic operations
|
|
42
|
-
|
|
43
|
-
#### Body
|
|
44
|
-
The function creates an array of lines to be written to the `index.md` file. It adds lines for the project's metadata, a file tree, a Mermaid dependency graph, and Laravel-specific sections (if present). The function returns the joined lines as a string.
|
|
45
|
-
|
|
46
|
-
### sanitizeMermaid
|
|
47
|
-
#### Description
|
|
48
|
-
Sanitizes a string for use in a Mermaid graph.
|
|
49
|
-
|
|
50
|
-
#### Parameters
|
|
51
|
-
| Name | Type | Description |
|
|
52
|
-
| --- | --- | --- |
|
|
53
|
-
| str | string | The string to be sanitized. |
|
|
54
|
-
|
|
55
|
-
#### Return Value
|
|
56
|
-
The sanitized string.
|
|
57
|
-
|
|
58
|
-
#### Detected Patterns
|
|
59
|
-
* Arithmetic operations
|
|
60
|
-
|
|
61
|
-
#### Body
|
|
62
|
-
The function replaces non-alphanumeric characters with underscores, removes leading underscores, and truncates the string to 40 characters. If the string is empty, it returns the string "node".
|
|
63
|
-
|
|
64
|
-
## Dependencies
|
|
65
|
-
* `fs`: `writeFileSync`, `mkdirSync`, `existsSync`
|
|
66
|
-
* `path`: `path`
|
|
67
|
-
|
|
68
|
-
## Usage Example
|
|
69
|
-
```javascript
|
|
70
|
-
const render = require('./markdown');
|
|
71
|
-
const fragments = [...]; // array of file metadata objects
|
|
72
|
-
const pkg = {...}; // project metadata object
|
|
73
|
-
const outputDir = './docs';
|
|
74
|
-
render(fragments, pkg, outputDir).then(() => {
|
|
75
|
-
console.log('Documentation generated successfully!');
|
|
76
|
-
});
|
|
77
|
-
```
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This module provides utility functions for managing session data and configuration in a CLI application.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
|
|
6
|
-
### loadSession()
|
|
7
|
-
Loads the session data from the session file.
|
|
8
|
-
|
|
9
|
-
| Param | Type | Description |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| None | | |
|
|
12
|
-
|
|
13
|
-
| Return Value | Type | Description |
|
|
14
|
-
| --- | --- | --- |
|
|
15
|
-
| Object | | The loaded session data, or an empty object if the file is missing or malformed. |
|
|
16
|
-
|
|
17
|
-
### saveSession(data)
|
|
18
|
-
Saves the session data to the session file.
|
|
19
|
-
|
|
20
|
-
| Param | Type | Description |
|
|
21
|
-
| --- | --- | --- |
|
|
22
|
-
| data | Object | The session data to save. |
|
|
23
|
-
|
|
24
|
-
| Return Value | Type | Description |
|
|
25
|
-
| --- | --- | --- |
|
|
26
|
-
| None | | |
|
|
27
|
-
|
|
28
|
-
### clearSession()
|
|
29
|
-
Deletes the session file.
|
|
30
|
-
|
|
31
|
-
| Param | Type | Description |
|
|
32
|
-
| --- | --- | --- |
|
|
33
|
-
| None | | |
|
|
34
|
-
|
|
35
|
-
| Return Value | Type | Description |
|
|
36
|
-
| --- | --- | --- |
|
|
37
|
-
| None | | |
|
|
38
|
-
|
|
39
|
-
### loadConfig(cliFlags)
|
|
40
|
-
Loads the configuration from a file and merges it with CLI flags.
|
|
41
|
-
|
|
42
|
-
| Param | Type | Description |
|
|
43
|
-
| --- | --- | --- |
|
|
44
|
-
| cliFlags | Object | The CLI flags to merge with the configuration. |
|
|
45
|
-
|
|
46
|
-
| Return Value | Type | Description |
|
|
47
|
-
| --- | --- | --- |
|
|
48
|
-
| Object | | The merged configuration. |
|
|
49
|
-
|
|
50
|
-
## Dependencies
|
|
51
|
-
|
|
52
|
-
* cosmiconfig: for loading configuration from files
|
|
53
|
-
* fs: for file system operations
|
|
54
|
-
* path: for working with file paths
|
|
55
|
-
* os: for accessing the user's home directory
|
|
56
|
-
|
|
57
|
-
## Usage Example
|
|
58
|
-
```javascript
|
|
59
|
-
const config = loadConfig({ provider: 'groq' });
|
|
60
|
-
console.log(config);
|
|
61
|
-
```
|
|
62
|
-
Note: This example assumes that the `loadConfig` function is exported and can be imported in another module. The actual usage will depend on how this module is used in the application.
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This module exports custom error classes for Legacyver, providing a structured way to handle and report errors.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
### LegacyverError
|
|
6
|
-
* Description: Base class for all Legacyver errors.
|
|
7
|
-
* Parameters:
|
|
8
|
-
| Name | Type | Description |
|
|
9
|
-
| --- | --- | --- |
|
|
10
|
-
| message | string | The error message. |
|
|
11
|
-
| code | string | The error code (optional, defaults to 'LEGACYVER_ERROR'). |
|
|
12
|
-
* Return Value: An instance of LegacyverError.
|
|
13
|
-
|
|
14
|
-
### NoApiKeyError
|
|
15
|
-
* Description: Error thrown when no API key is found for a provider.
|
|
16
|
-
* Parameters:
|
|
17
|
-
| Name | Type | Description |
|
|
18
|
-
| --- | --- | --- |
|
|
19
|
-
| provider | string | The provider for which no API key was found. |
|
|
20
|
-
* Return Value: An instance of NoApiKeyError.
|
|
21
|
-
|
|
22
|
-
### RateLimitError
|
|
23
|
-
* Description: Error thrown when the rate limit is exceeded for a provider.
|
|
24
|
-
* Parameters:
|
|
25
|
-
| Name | Type | Description |
|
|
26
|
-
| --- | --- | --- |
|
|
27
|
-
| provider | string | The provider for which the rate limit was exceeded. |
|
|
28
|
-
| retryAfter | number | The number of milliseconds to wait before retrying (optional, defaults to 1000). |
|
|
29
|
-
* Return Value: An instance of RateLimitError.
|
|
30
|
-
|
|
31
|
-
### ParseError
|
|
32
|
-
* Description: Error thrown when a file fails to parse.
|
|
33
|
-
* Parameters:
|
|
34
|
-
| Name | Type | Description |
|
|
35
|
-
| --- | --- | --- |
|
|
36
|
-
| filePath | string | The path to the file that failed to parse. |
|
|
37
|
-
| originalError | Error | The original error that occurred during parsing (optional). |
|
|
38
|
-
* Return Value: An instance of ParseError.
|
|
39
|
-
|
|
40
|
-
### RenderError
|
|
41
|
-
* Description: Error thrown when a renderer fails.
|
|
42
|
-
* Parameters:
|
|
43
|
-
| Name | Type | Description |
|
|
44
|
-
| --- | --- | --- |
|
|
45
|
-
| format | string | The format for which the renderer failed. |
|
|
46
|
-
| originalError | Error | The original error that occurred during rendering (optional). |
|
|
47
|
-
* Return Value: An instance of RenderError.
|
|
48
|
-
|
|
49
|
-
## Dependencies
|
|
50
|
-
* `Error` (built-in JavaScript class)
|
|
51
|
-
|
|
52
|
-
## Usage Example
|
|
53
|
-
No clear pattern is visible in the code, so no usage example is provided.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
This module provides a logging utility with customizable log levels and colorized output. It allows users to set the log level and determine whether the log should be displayed based on the current log level.
|
|
3
|
-
|
|
4
|
-
## Functions
|
|
5
|
-
|
|
6
|
-
### setLevel(level)
|
|
7
|
-
Sets the current log level.
|
|
8
|
-
|
|
9
|
-
| Param | Type | Description |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| level | string | The new log level (one of 'debug', 'info', 'warn', 'error') |
|
|
12
|
-
|
|
13
|
-
### setCI(val)
|
|
14
|
-
Sets whether the log is being run in a Continuous Integration environment.
|
|
15
|
-
|
|
16
|
-
| Param | Type | Description |
|
|
17
|
-
| --- | --- | --- |
|
|
18
|
-
| val | boolean | Whether the log is being run in a CI environment |
|
|
19
|
-
|
|
20
|
-
### shouldLog(level)
|
|
21
|
-
Determines whether a log with the given level should be displayed based on the current log level.
|
|
22
|
-
|
|
23
|
-
| Param | Type | Description |
|
|
24
|
-
| --- | --- | --- |
|
|
25
|
-
| level | string | The log level to check (one of 'debug', 'info', 'warn', 'error') |
|
|
26
|
-
|
|
27
|
-
### debug(...args)
|
|
28
|
-
Logs a message at the debug level.
|
|
29
|
-
|
|
30
|
-
### info(...args)
|
|
31
|
-
Logs a message at the info level.
|
|
32
|
-
|
|
33
|
-
### warn(...args)
|
|
34
|
-
Logs a message at the warn level.
|
|
35
|
-
|
|
36
|
-
### error(...args)
|
|
37
|
-
Logs a message at the error level.
|
|
38
|
-
|
|
39
|
-
## Dependencies
|
|
40
|
-
* `picocolors` (as `pc`)
|
|
41
|
-
|
|
42
|
-
## Usage Example
|
|
43
|
-
Based on the code, it appears that the `debug` function can be used to log a message at the debug level, like this:
|
|
44
|
-
```javascript
|
|
45
|
-
const logger = require('./logger');
|
|
46
|
-
logger.debug('This is a debug message');
|
|
47
|
-
```
|
|
48
|
-
Note that this is just an example based on the code, and the actual usage may vary depending on the context in which this module is used.
|