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.
Files changed (74) hide show
  1. package/bin/legacyver.js +1 -1
  2. package/legacyver-docs/auth.md +71 -0
  3. package/legacyver-docs/hash.md +37 -0
  4. package/package.json +3 -2
  5. package/src/api/auth.js +32 -45
  6. package/src/cli/commands/analyze.js +20 -1
  7. package/src/cli/commands/init.js +34 -4
  8. package/src/cli/commands/login.js +1 -1
  9. package/src/cli/commands/providers.js +20 -23
  10. package/src/cli/ui.js +19 -9
  11. package/src/db/config.js +39 -14
  12. package/src/db/index.js +69 -88
  13. package/src/llm/providers/groq.js +4 -2
  14. package/src/llm/validator.js +2 -2
  15. package/src/utils/config.js +1 -1
  16. package/legacyver-docs/bin/legacyver.md +0 -107
  17. package/legacyver-docs/src/api/auth.md +0 -47
  18. package/legacyver-docs/src/cache/hash.md +0 -24
  19. package/legacyver-docs/src/cache/index.md +0 -112
  20. package/legacyver-docs/src/cli/commands/analyze.md +0 -58
  21. package/legacyver-docs/src/cli/commands/cache.md +0 -21
  22. package/legacyver-docs/src/cli/commands/init.md +0 -42
  23. package/legacyver-docs/src/cli/commands/login.md +0 -70
  24. package/legacyver-docs/src/cli/commands/logout.md +0 -26
  25. package/legacyver-docs/src/cli/commands/providers.md +0 -23
  26. package/legacyver-docs/src/cli/commands/push.md +0 -48
  27. package/legacyver-docs/src/cli/commands/version.md +0 -26
  28. package/legacyver-docs/src/cli/ui.md +0 -112
  29. package/legacyver-docs/src/crawler/filters.md +0 -54
  30. package/legacyver-docs/src/crawler/index.md +0 -54
  31. package/legacyver-docs/src/crawler/manifest.md +0 -22
  32. package/legacyver-docs/src/crawler/walk.md +0 -29
  33. package/legacyver-docs/src/db/config.md +0 -13
  34. package/legacyver-docs/src/db/index.md +0 -86
  35. package/legacyver-docs/src/llm/chunker.md +0 -28
  36. package/legacyver-docs/src/llm/cost-estimator.md +0 -62
  37. package/legacyver-docs/src/llm/free-model.md +0 -40
  38. package/legacyver-docs/src/llm/index.md +0 -29
  39. package/legacyver-docs/src/llm/prompts.md +0 -150
  40. package/legacyver-docs/src/llm/providers/gemini.md +0 -51
  41. package/legacyver-docs/src/llm/providers/groq.md +0 -76
  42. package/legacyver-docs/src/llm/providers/kimi.md +0 -48
  43. package/legacyver-docs/src/llm/providers/ollama.md +0 -50
  44. package/legacyver-docs/src/llm/providers/openrouter.md +0 -55
  45. package/legacyver-docs/src/llm/queue.md +0 -41
  46. package/legacyver-docs/src/llm/re-prompter.md +0 -33
  47. package/legacyver-docs/src/llm/validator.md +0 -34
  48. package/legacyver-docs/src/parser/ast/generic.md +0 -34
  49. package/legacyver-docs/src/parser/ast/go.md +0 -59
  50. package/legacyver-docs/src/parser/ast/java.md +0 -58
  51. package/legacyver-docs/src/parser/ast/javascript.md +0 -71
  52. package/legacyver-docs/src/parser/ast/laravel/blade.md +0 -45
  53. package/legacyver-docs/src/parser/ast/laravel/classifier.md +0 -29
  54. package/legacyver-docs/src/parser/ast/laravel/controller.md +0 -57
  55. package/legacyver-docs/src/parser/ast/laravel/index.md +0 -27
  56. package/legacyver-docs/src/parser/ast/laravel/model.md +0 -34
  57. package/legacyver-docs/src/parser/ast/laravel/provider.md +0 -31
  58. package/legacyver-docs/src/parser/ast/laravel/routes.md +0 -31
  59. package/legacyver-docs/src/parser/ast/php.md +0 -127
  60. package/legacyver-docs/src/parser/ast/python.md +0 -62
  61. package/legacyver-docs/src/parser/ast/typescript.md +0 -22
  62. package/legacyver-docs/src/parser/body-extractor.md +0 -34
  63. package/legacyver-docs/src/parser/call-graph.md +0 -45
  64. package/legacyver-docs/src/parser/complexity-scorer.md +0 -25
  65. package/legacyver-docs/src/parser/index.md +0 -59
  66. package/legacyver-docs/src/parser/pattern-detector.md +0 -28
  67. package/legacyver-docs/src/parser/pkg-builder.md +0 -34
  68. package/legacyver-docs/src/renderer/html.md +0 -36
  69. package/legacyver-docs/src/renderer/index.md +0 -26
  70. package/legacyver-docs/src/renderer/json.md +0 -25
  71. package/legacyver-docs/src/renderer/markdown.md +0 -77
  72. package/legacyver-docs/src/utils/config.md +0 -62
  73. package/legacyver-docs/src/utils/errors.md +0 -53
  74. package/legacyver-docs/src/utils/logger.md +0 -48
@@ -1,40 +0,0 @@
1
- ## Overview
2
- The `applyFreeModelPolicy` function applies free model policies to a given configuration object. It checks if the model ID ends with `:free` and adjusts the configuration accordingly.
3
-
4
- ## Functions
5
- ### applyFreeModelPolicy
6
- #### Description
7
- Applies free model policies to a given configuration object.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | config | Object | The configuration object to apply free model policies to |
13
-
14
- #### Return Value
15
- The mutated configuration object
16
-
17
- #### Complex Logic
18
- The function checks if the provider is one of Ollama, Groq, Gemini, or Kimi, and if so, sets `isFreeModel` and `skipCostEstimation` to `true`. It then checks the provider-specific rate limits and caps concurrency accordingly. If the model ID does not end with `:free`, it sets `isFreeModel` to `false`. Otherwise, it sets `isFreeModel` to `true` and caps concurrency to 2.
19
-
20
- #### Detected Patterns
21
- * Arithmetic operations (e.g. `parseInt`, `parseInt(config.concurrency) || 1`)
22
- * Conditional statements (e.g. `if (provider === 'ollama' || provider === 'groq' || provider === 'gemini' || provider === 'kimi')`)
23
- * String manipulation (e.g. `provider.toLowerCase()`, `model.endsWith(':free')`)
24
-
25
- ## Dependencies
26
- * `../utils/logger`
27
- * `picocolors`
28
-
29
- ## Usage Example
30
- ```javascript
31
- const config = {
32
- provider: 'groq',
33
- model: 'meta-llama/llama-3.3-70b-instruct:free',
34
- concurrency: 5
35
- };
36
-
37
- const updatedConfig = applyFreeModelPolicy(config);
38
- console.log(updatedConfig);
39
- ```
40
- Note: This example is a simplified representation of the usage and may not cover all possible scenarios.
@@ -1,29 +0,0 @@
1
- ## Overview
2
- This module exports a `createProvider` function that returns an instance of a provider based on the provided configuration.
3
-
4
- ## Functions
5
- ### createProvider
6
- #### Description
7
- Returns an instance of a provider based on the provided configuration.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | config | Object | The configuration object |
13
-
14
- #### Return Value
15
- An instance of `OpenRouterProvider`, `OllamaProvider`, `GroqProvider`, `GeminiProvider`, or `KimiProvider`
16
-
17
- ## Dependencies
18
- * `./providers/openrouter: OpenRouterProvider`
19
- * `./providers/ollama: OllamaProvider`
20
- * `./providers/groq: GroqProvider`
21
- * `./providers/gemini: GeminiProvider`
22
- * `./providers/kimi: KimiProvider`
23
-
24
- ## Usage Example
25
- Based on the code, it appears that the `createProvider` function can be used as follows:
26
- ```javascript
27
- const provider = createProvider({ provider: 'openrouter' });
28
- ```
29
- This would return an instance of `OpenRouterProvider` with the provided configuration.
@@ -1,150 +0,0 @@
1
- ## Overview
2
- This module exports two functions: `buildUserMessage` and `SYSTEM_PROMPT`. The `buildUserMessage` function generates a user message for a single file, while `SYSTEM_PROMPT` contains the instructions for generating documentation.
3
-
4
- ## Functions
5
-
6
- ### stripEmpty
7
- #### Description
8
- Removes null/undefined values and empty arrays from an object (shallow).
9
-
10
- #### Parameters
11
- | Name | Type | Description |
12
- | --- | --- | --- |
13
- | obj | Object | The object to strip |
14
-
15
- #### Return Value
16
- The stripped object
17
-
18
- #### Body
19
- ```javascript
20
- function stripEmpty(obj) {
21
- const result = {};
22
- for (const [k, v] of Object.entries(obj)) {
23
- if (v === null || v === undefined) continue;
24
- if (Array.isArray(v) && v.length === 0) continue;
25
- result[k] = v;
26
- }
27
- return result;
28
- }
29
- ```
30
- The function iterates over the object's entries using `Object.entries()`. If a value is null or undefined, it skips to the next iteration. If a value is an empty array, it also skips to the next iteration. Otherwise, it adds the key-value pair to the result object.
31
-
32
- ### slimFacts
33
- #### Description
34
- Builds a slim version of FileFacts for the prompt — remove noise, keep signal.
35
-
36
- #### Parameters
37
- | Name | Type | Description |
38
- | --- | --- | --- |
39
- | fileFacts | Object | The FileFacts object to slim |
40
-
41
- #### Return Value
42
- The slimmed FileFacts object
43
-
44
- #### Body
45
- ```javascript
46
- function slimFacts(fileFacts) {
47
- const slim = {
48
- file: fileFacts.relativePath,
49
- lang: fileFacts.language,
50
- lines: fileFacts.linesOfCode,
51
- };
52
-
53
- // Functions — only include useful fields
54
- if (fileFacts.functions && fileFacts.functions.length > 0) {
55
- slim.functions = fileFacts.functions.map(fn => {
56
- const entry = { name: fn.name };
57
- if (fn.params && fn.params.length > 0) {
58
- entry.params = fn.params.map(p => p.type ? `${p.name}:${p.type}` : p.name);
59
- }
60
- if (fn.returnType) entry.returns = fn.returnType;
61
- if (fn.isExported) entry.exported = true;
62
- if (fn.isAsync) entry.async = true;
63
- if (fn.complexityClass && fn.complexityClass !== 'simple') {
64
- entry.complexity = fn.complexityClass;
65
- }
66
- if (fn.detectedPatterns && fn.detectedPatterns.length > 0) {
67
- entry.patterns = fn.detectedPatterns;
68
- }
69
- if (fn.bodySnippet) entry.body = fn.bodySnippet;
70
- if (fn.calls && fn.calls.length > 0) entry.calls = fn.calls;
71
- return entry;
72
- });
73
- }
74
-
75
- // Classes
76
- if (fileFacts.classes && fileFacts.classes.length > 0) {
77
- slim.classes = fileFacts.classes.map(c => {
78
- const entry = { name: c.name };
79
- if (c.superClass) entry.extends = c.superClass;
80
- if (c.methods && c.methods.length > 0) entry.methods = c.methods.map(m => m.name || m);
81
- return entry;
82
- });
83
- }
84
-
85
- // Imports — compact
86
- if (fileFacts.imports && fileFacts.imports.length > 0) {
87
- slim.imports = fileFacts.imports.map(i => {
88
- if (i.specifiers && i.specifiers.length > 0) {
89
- return `${i.module}: ${i.specifiers.join(', ')}`;
90
- }
91
- return i.module;
92
- });
93
- }
94
-
95
- // Exports
96
- if (fileFacts.exports && fileFacts.exports.length > 0) {
97
- slim.exports = fileFacts.exports;
98
- }
99
-
100
- return slim;
101
- }
102
- ```
103
- The function creates a slim version of the FileFacts object by removing unnecessary fields and transforming others. It iterates over the functions, classes, imports, and exports of the FileFacts object and creates a new object with only the necessary fields.
104
-
105
- ### buildUserMessage
106
- #### Description
107
- Build the user message for a single file.
108
-
109
- #### Parameters
110
- | Name | Type | Description |
111
- | --- | --- | --- |
112
- | fileFacts | Object | The FileFacts object |
113
- | rawSource | string | The raw source code |
114
-
115
- #### Return Value
116
- The user message as a string
117
-
118
- #### Body
119
- ```javascript
120
- function buildUserMessage(fileFacts, rawSource) {
121
- const slim = slimFacts(fileFacts);
122
-
123
- // Truncate source to ~150 lines to keep prompt small
124
- const lines = rawSource.split('\n');
125
- let source = rawSource;
126
- if (lines.length > 150) {
127
- source = lines.slice(0, 150).join('\n') + '\n// ... truncated';
128
- }
129
-
130
- return `STRUCTURE:
131
- ${JSON.stringify(slim)}
132
-
133
- CODE:
134
- ${source}
135
-
136
- Generate documentation following the system instructions.`;
137
- }
138
- ```
139
- The function calls `slimFacts` to create a slim version of the FileFacts object. It then truncates the source code to ~150 lines and returns a string containing the slimmed FileFacts object and the truncated source code.
140
-
141
- ## Dependencies
142
- * `Object.entries`
143
- * `Array.isArray`
144
- * `JSON.stringify`
145
- * `split`
146
- * `slice`
147
- * `join`
148
-
149
- ## Usage Example
150
- No clear pattern is visible in the code.
@@ -1,51 +0,0 @@
1
- ## Overview
2
- The GeminiProvider class is a language model provider that interacts with the Gemini API to generate content. It handles API key management, model selection, and error handling.
3
-
4
- ## Functions
5
-
6
- ### constructor(config)
7
- Initializes a new instance of the GeminiProvider class.
8
-
9
- | Parameter | Type | Description |
10
- | --- | --- | --- |
11
- | config | object | Configuration object containing API key and model settings |
12
-
13
- #### Returns
14
- None
15
-
16
- #### Throws
17
- NoApiKeyError if no API key is provided
18
-
19
- ### complete(chunk)
20
- Generates content using the Gemini API.
21
-
22
- | Parameter | Type | Description |
23
- | --- | --- | --- |
24
- | chunk | object | Chunk object containing system prompt and user message |
25
-
26
- #### Returns
27
- Object containing generated content and usage metadata
28
-
29
- ### estimateCost()
30
- Estimates the cost of using the GeminiProvider. Currently, it always returns 0.
31
-
32
- | Parameter | Type | Description |
33
- | --- | --- | --- |
34
- | None | | |
35
-
36
- #### Returns
37
- Number representing the estimated cost
38
-
39
- ## Dependencies
40
-
41
- * `../../utils/errors: NoApiKeyError`
42
- * `../../utils/errors: RateLimitError`
43
-
44
- ## Usage Example
45
- ```javascript
46
- const GeminiProvider = require('./gemini');
47
- const provider = new GeminiProvider({ geminiApiKey: 'YOUR_API_KEY' });
48
- provider.complete({ systemPrompt: 'Hello', userMessage: 'World' })
49
- .then((result) => console.log(result.content))
50
- .catch((error) => console.error(error.message));
51
- ```
@@ -1,76 +0,0 @@
1
- ## Overview
2
- The GroqProvider class is a provider for the Groq API, allowing users to interact with the API for text completion and estimation of costs.
3
-
4
- ## Functions
5
- ### GroqProvider
6
- #### Description
7
- The GroqProvider class is a constructor that initializes the provider with a configuration object.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | config | object | The configuration object containing the provider's settings. |
13
-
14
- #### Return Value
15
- None
16
-
17
- #### Parameters Table
18
- | Name | Type | Description |
19
- | --- | --- | --- |
20
- | config | object | The configuration object containing the provider's settings. |
21
-
22
- #### Return Value
23
- None
24
-
25
- ### complete
26
- #### Description
27
- The complete method sends a request to the Groq API to complete a text based on a system prompt and user message.
28
-
29
- #### Parameters
30
- | Name | Type | Description |
31
- | --- | --- | --- |
32
- | chunk | object | The object containing the system prompt and user message. |
33
-
34
- #### Return Value
35
- An object containing the completed text and tokens used.
36
-
37
- #### Parameters Table
38
- | Name | Type | Description |
39
- | --- | --- | --- |
40
- | chunk | object | The object containing the system prompt and user message. |
41
-
42
- #### Return Value
43
- An object containing the completed text and tokens used.
44
-
45
- ### estimateCost
46
- #### Description
47
- The estimateCost method returns an estimate of the cost of using the Groq API.
48
-
49
- #### Parameters
50
- None
51
-
52
- #### Return Value
53
- The estimated cost of using the Groq API.
54
-
55
- #### Parameters Table
56
- None
57
-
58
- #### Return Value
59
- The estimated cost of using the Groq API.
60
-
61
- ## Dependencies
62
- * `../../utils/errors: NoApiKeyError`
63
- * `../../utils/errors: RateLimitError`
64
-
65
- ## Usage Example
66
- ```javascript
67
- const GroqProvider = require('./groq');
68
- const provider = new GroqProvider({ groqApiKey: 'your_api_key' });
69
- const chunk = { systemPrompt: 'Hello, how are you?', userMessage: 'I am good, thanks.' };
70
- provider.complete(chunk).then((result) => {
71
- console.log(result.content);
72
- console.log(result.tokensUsed);
73
- }).catch((error) => {
74
- console.error(error);
75
- });
76
- ```
@@ -1,48 +0,0 @@
1
- ## Overview
2
- The KimiProvider class is a language model provider that interacts with the Kimi API to generate text completions. It handles authentication, rate limiting, and error handling.
3
-
4
- ## Functions
5
- ### constructor(config)
6
- #### Description
7
- Initializes a new instance of the KimiProvider class.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | config | object | Configuration object containing API key and model settings |
13
-
14
- #### Return Value
15
- None
16
-
17
- ### complete(chunk)
18
- #### Description
19
- Generates a text completion using the Kimi API.
20
-
21
- #### Parameters
22
- | Name | Type | Description |
23
- | --- | --- | --- |
24
- | chunk | object | Object containing system prompt and user message |
25
-
26
- #### Return Value
27
- Object containing generated content and tokens used
28
-
29
- ### estimateCost()
30
- #### Description
31
- Estimates the cost of using the Kimi API. (Note: This function always returns 0, indicating that the cost is unknown or not applicable.)
32
-
33
- #### Parameters
34
- None
35
-
36
- #### Return Value
37
- Number (always 0)
38
-
39
- ## Dependencies
40
- * `../../utils/errors: NoApiKeyError`
41
- * `../../utils/errors: RateLimitError`
42
-
43
- ## Usage Example
44
- ```javascript
45
- const kimiProvider = new KimiProvider({ kimiApiKey: 'YOUR_API_KEY' });
46
- const completion = await kimiProvider.complete({ systemPrompt: 'Hello, ', userMessage: 'world!' });
47
- console.log(completion.content); // Output: 'Hello, world!'
48
- ```
@@ -1,50 +0,0 @@
1
- ## Overview
2
- The OllamaProvider class is a JavaScript module that provides a provider for the Ollama large language model. It allows for completing text prompts and estimating the cost of using the model.
3
-
4
- ## Functions
5
- ### constructor(config)
6
- #### Description
7
- Initializes a new instance of the OllamaProvider class.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | config | object | Configuration object with a `model` property |
13
-
14
- #### Return Value
15
- None
16
-
17
- ### complete(chunk)
18
- #### Description
19
- Completes a text prompt using the Ollama model.
20
-
21
- #### Parameters
22
- | Name | Type | Description |
23
- | --- | --- | --- |
24
- | chunk | object | Object with `systemPrompt` and `userMessage` properties |
25
-
26
- #### Return Value
27
- Object with `content` and `tokensUsed` properties
28
-
29
- ### estimateCost()
30
- #### Description
31
- Estimates the cost of using the Ollama model. (Note: this function always returns 0)
32
-
33
- #### Parameters
34
- None
35
-
36
- #### Return Value
37
- Number (always 0)
38
-
39
- ## Dependencies
40
- * `../../utils/logger: logger`
41
-
42
- ## Usage Example
43
- Based on the code, a usage example can be inferred:
44
- ```javascript
45
- const OllamaProvider = require('./ollama');
46
- const provider = new OllamaProvider({ model: 'llama3.2' });
47
- provider.complete({ systemPrompt: 'Hello, ', userMessage: 'world!' })
48
- .then((result) => console.log(result.content))
49
- .catch((error) => console.error(error));
50
- ```
@@ -1,55 +0,0 @@
1
- ## Overview
2
- The OpenRouterProvider class is a provider for the OpenRouter API, allowing for completion of text based on a given prompt.
3
-
4
- ## Functions
5
- ### constructor(config)
6
- #### Description
7
- Initializes a new instance of the OpenRouterProvider class.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | config | object | Configuration object |
13
-
14
- #### Return Value
15
- None
16
-
17
- #### Throws
18
- * NoApiKeyError if no API key is provided
19
-
20
- ### complete(chunk)
21
- #### Description
22
- Completes a text based on a given prompt using the OpenRouter API.
23
-
24
- #### Parameters
25
- | Name | Type | Description |
26
- | --- | --- | --- |
27
- | chunk | object | Object containing system prompt and user message |
28
-
29
- #### Return Value
30
- Object containing completed content and tokens used
31
-
32
- ### estimateCost(inputTokens, outputTokens)
33
- #### Description
34
- Estimates the cost of completing a text based on input and output tokens.
35
-
36
- #### Parameters
37
- | Name | Type | Description |
38
- | --- | --- | --- |
39
- | inputTokens | number | Number of input tokens |
40
- | outputTokens | number | Number of output tokens |
41
-
42
- #### Return Value
43
- Number representing estimated cost (0 if using free model)
44
-
45
- ## Dependencies
46
- *../../utils/errors: NoApiKeyError, RateLimitError
47
- *../../utils/logger: logger
48
-
49
- ## Usage Example
50
- ```javascript
51
- const provider = new OpenRouterProvider({ apiKey: 'YOUR_API_KEY' });
52
- const chunk = { systemPrompt: 'Hello, world!', userMessage: 'How are you?' };
53
- const result = await provider.complete(chunk);
54
- console.log(result.content);
55
- ```
@@ -1,41 +0,0 @@
1
- ## Overview
2
- The `createQueue` function processes chunks through an LLM provider with concurrency and retry, returning an array of DocFragment objects.
3
-
4
- ## Functions
5
- ### createQueue
6
- #### Description
7
- Process chunks through the LLM provider with concurrency and retry.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | chunks | Array | The chunks to process |
13
- | provider | Object | The LLM provider |
14
- | config | Object | The configuration object |
15
- | callbacks | Object | The callbacks object with `onProgress` and `onError` properties |
16
-
17
- #### Return Value
18
- Promise<Array> DocFragment[]
19
-
20
- #### Body Logic
21
- The function uses `pLimit` to limit concurrency and `pRetry` to retry failed attempts. It maps over the chunks, processing each one with the `limit` function. If the provider's `complete` method fails, it waits for the retry-after period before retrying. If all retries fail, it logs an error and pushes a failed DocFragment to the result array.
22
-
23
- ## Dependencies
24
- * `p-limit: pLimit`
25
- * `p-retry: pRetry`
26
- * `../utils/logger: logger`
27
-
28
- ## Usage Example
29
- ```javascript
30
- const createQueue = require('./queue');
31
- const provider = require('./provider');
32
- const config = require('./config');
33
- const callbacks = {
34
- onProgress: () => console.log('Progress'),
35
- onError: (error, chunk) => console.error(`Error processing ${chunk.relativePath}: ${error.message}`)
36
- };
37
-
38
- const chunks = [...]; // array of chunks to process
39
- const result = await createQueue(chunks, provider, config, callbacks);
40
- console.log(result); // array of DocFragment objects
41
- ```
@@ -1,33 +0,0 @@
1
- ## Overview
2
- The `reprompt` function re-prompt the LLM for missing exports in a file based on the provided `fragment`, `fileFacts`, `provider`, and `config`.
3
-
4
- ## Functions
5
- ### reprompt
6
- #### Description
7
- Re-prompt the LLM for missing exports.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | fragment | Object | The file fragment to re-prompt. |
13
- | fileFacts | Object | The file facts containing exported symbols. |
14
- | provider | Object | The provider to complete the re-prompt. |
15
- | config | Object | The configuration for the re-prompt. |
16
-
17
- #### Return Value
18
- A Promise that resolves to the updated fragment or null if no missing exports are found.
19
-
20
- ## Dependencies
21
- * `./prompts`: SYSTEM_PROMPT
22
- * `../utils/logger`: logger
23
-
24
- ## Usage Example
25
- The `reprompt` function can be used to re-prompt the LLM for missing exports in a file. For example:
26
- ```javascript
27
- const fragment = { content: '...' };
28
- const fileFacts = { exports: ['sym1', 'sym2'] };
29
- const provider = { complete: async () => {... } };
30
- const config = {... };
31
-
32
- const updatedFragment = await reprompt(fragment, fileFacts, provider, config);
33
- ```
@@ -1,34 +0,0 @@
1
- ## Overview
2
- The `validateFragment` function is a post-generation quality validator that checks for hallucinations and completeness in LLM output. It takes a fragment object and file facts as input and returns an object with hallucinations, missing exports, and a passed status.
3
-
4
- ## Functions
5
- ### validateFragment
6
- #### Description
7
- Validates a fragment of code by checking for hallucinations and completeness.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | fragment | Object | The fragment to be validated, containing `relativePath` and `content` properties. |
13
- | fileFacts | Object | The file facts object containing information about the file, such as functions, classes, imports, and exports. |
14
-
15
- #### Return Value
16
- An object with the following properties:
17
- | Name | Type | Description |
18
- | --- | --- | --- |
19
- | hallucinations | string[] | An array of suspected hallucinations. |
20
- | missingExports | string[] | An array of exported symbols not mentioned in the LLM output. |
21
- | passed | boolean | A boolean indicating whether the validation passed (true) or failed (false). |
22
-
23
- ## Dependencies
24
- * `../utils/logger: logger`
25
-
26
- ## Usage Example
27
- The `validateFragment` function can be used to validate a fragment of code by calling it with a fragment object and file facts as arguments. For example:
28
- ```javascript
29
- const fragment = { relativePath: 'path/to/file.js', content: '...' };
30
- const fileFacts = { functions: [...], classes: [...], imports: [...], exports: [...] };
31
- const result = validateFragment(fragment, fileFacts);
32
- console.log(result);
33
- ```
34
- Note that this example is not a direct usage example from the code, but rather a hypothetical example to illustrate how the function can be used.
@@ -1,34 +0,0 @@
1
- ## Overview
2
- The `parse` function is a generic regex-based fallback parser for unsupported languages. It takes in `sourceText`, `relativePath`, and `language` as parameters and returns an object containing parsed data.
3
-
4
- ## Functions
5
- ### parse
6
- #### Description
7
- Parses the source code and extracts function, import, and class definitions.
8
-
9
- #### Parameters
10
- | Name | Type | Description |
11
- | --- | --- | --- |
12
- | sourceText | string | The source code to parse. |
13
- | relativePath | string | The relative path of the source code. |
14
- | language | string | The language of the source code (optional). |
15
-
16
- #### Return Value
17
- An object containing the following properties:
18
- * `relativePath`: The relative path of the source code.
19
- * `language`: The language of the source code (or 'unknown' if not specified).
20
- * `linesOfCode`: The number of lines in the source code.
21
- * `functions`: An array of function definitions.
22
- * `classes`: An array of class definitions.
23
- * `imports`: An array of import statements.
24
- * `exports`: An array of exported function names.
25
- * `callsTo`: An array of called functions (not populated in this implementation).
26
- * `calledBy`: An array of functions that call other functions (not populated in this implementation).
27
- * `hash`: A hash value (not populated in this implementation).
28
- * `parserType`: The type of parser used (in this case, 'generic').
29
-
30
- ## Dependencies
31
- * `../../utils/logger`: The logger utility.
32
-
33
- ## Usage Example
34
- No clear usage example is visible in the code. The `parse` function is exported as a module, but there is no example of how to use it.