@rxap/plugin-llm 20.0.0-dev.1
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/CHANGELOG.md +8 -0
- package/GETSTARTED.md +0 -0
- package/GUIDES.md +0 -0
- package/LICENSE.md +621 -0
- package/README.md +11 -0
- package/generators.json +36 -0
- package/package.json +49 -0
- package/src/generators/documentation/generator.d.ts +4 -0
- package/src/generators/documentation/generator.js +187 -0
- package/src/generators/documentation/generator.js.map +1 -0
- package/src/generators/documentation/index.d.ts +2 -0
- package/src/generators/documentation/index.js +7 -0
- package/src/generators/documentation/index.js.map +1 -0
- package/src/generators/documentation/schema.d.ts +13 -0
- package/src/generators/documentation/schema.json +34 -0
- package/src/generators/documentation/system-prompts/context.xsd +35 -0
- package/src/generators/documentation/system-prompts/exmaple.txt +134 -0
- package/src/generators/documentation/system-prompts/generic.txt +242 -0
- package/src/generators/init/generator.d.ts +4 -0
- package/src/generators/init/generator.js +105 -0
- package/src/generators/init/generator.js.map +1 -0
- package/src/generators/init/index.d.ts +2 -0
- package/src/generators/init/index.js +7 -0
- package/src/generators/init/index.js.map +1 -0
- package/src/generators/init/schema.d.ts +3 -0
- package/src/generators/init/schema.json +8 -0
- package/src/generators/package-description/generator.d.ts +4 -0
- package/src/generators/package-description/generator.js +53 -0
- package/src/generators/package-description/generator.js.map +1 -0
- package/src/generators/package-description/index.d.ts +2 -0
- package/src/generators/package-description/index.js +7 -0
- package/src/generators/package-description/index.js.map +1 -0
- package/src/generators/package-description/schema.d.ts +15 -0
- package/src/generators/package-description/schema.json +37 -0
- package/src/generators/package-description/system-prompts/generic.txt +44 -0
- package/src/index.d.ts +0 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -0
- package/src/lib/__snapshots__/cleanup-js-doc.spec.ts.snap +32 -0
- package/src/lib/add-js-doc.d.ts +2 -0
- package/src/lib/add-js-doc.js +7 -0
- package/src/lib/add-js-doc.js.map +1 -0
- package/src/lib/assert-token-limit.d.ts +2 -0
- package/src/lib/assert-token-limit.js +13 -0
- package/src/lib/assert-token-limit.js.map +1 -0
- package/src/lib/cleanup-js-doc.d.ts +1 -0
- package/src/lib/cleanup-js-doc.js +26 -0
- package/src/lib/cleanup-js-doc.js.map +1 -0
- package/src/lib/clear-all-js-docs.d.ts +2 -0
- package/src/lib/clear-all-js-docs.js +23 -0
- package/src/lib/clear-all-js-docs.js.map +1 -0
- package/src/lib/clear-js-doc.d.ts +2 -0
- package/src/lib/clear-js-doc.js +7 -0
- package/src/lib/clear-js-doc.js.map +1 -0
- package/src/lib/completion.d.ts +11 -0
- package/src/lib/completion.js +49 -0
- package/src/lib/completion.js.map +1 -0
- package/src/lib/compose-context.d.ts +9 -0
- package/src/lib/compose-context.js +35 -0
- package/src/lib/compose-context.js.map +1 -0
- package/src/lib/count-tokens.d.ts +2 -0
- package/src/lib/count-tokens.js +18 -0
- package/src/lib/count-tokens.js.map +1 -0
- package/src/lib/has-js-doc.d.ts +2 -0
- package/src/lib/has-js-doc.js +7 -0
- package/src/lib/has-js-doc.js.map +1 -0
- package/src/lib/model.d.ts +16 -0
- package/src/lib/model.js +19 -0
- package/src/lib/model.js.map +1 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Your task is to generate complete TSDoc documentation for the provided TypeScript source code. The context supplied consists of two parts:
|
|
2
|
+
|
|
3
|
+
1. The source code and all related files (both files referenced by the source code and files that use the source code) are provided as context formatted according to the schema in the context.xsd file below.
|
|
4
|
+
|
|
5
|
+
2. An overview of the available TSDoc block tags is provided in the block-tags.txt file below. You must use these tags in your documentation.
|
|
6
|
+
|
|
7
|
+
Use the following file contents as reference:
|
|
8
|
+
|
|
9
|
+
-------------------- block-tags.txt --------------------
|
|
10
|
+
# @default
|
|
11
|
+
|
|
12
|
+
The @default tag can be used to document the default value for an accessor or property.
|
|
13
|
+
```typescript
|
|
14
|
+
export interface CompilerOptions {
|
|
15
|
+
strict?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @defaultValue `true` if `strict` is `true`, otherwise `false`
|
|
18
|
+
*/
|
|
19
|
+
strictNullChecks?: boolean;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
# @example
|
|
24
|
+
|
|
25
|
+
The example tag indicates that the following text is an example of how to use the function.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
/**
|
|
29
|
+
* Takes the factorial of `n`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // If there are no code blocks, TypeDoc assumes the whole tag
|
|
33
|
+
* // should be a code block. This is not valid TSDoc, but is recognized
|
|
34
|
+
* // by VSCode and enables better TSDoc support.
|
|
35
|
+
* factorial(1)
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* If there is a code block, then both TypeDoc and VSCode will treat
|
|
39
|
+
* text outside of the code block as regular text.
|
|
40
|
+
* ```ts
|
|
41
|
+
* factorial(1)
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function factorial(n: number): number;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# @returns
|
|
48
|
+
|
|
49
|
+
The @returns tag can be used to document the return value of a function. At most one @returns tag should be present in a comment.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
/**
|
|
53
|
+
* @param a - the first number
|
|
54
|
+
* @param b - the second number
|
|
55
|
+
* @returns The sum of `a` and `b`
|
|
56
|
+
*/
|
|
57
|
+
export function sum(a: number, b: number): number;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
# @summary
|
|
61
|
+
|
|
62
|
+
The @summary tag should be used to give a short summary of the commented code. Is only sutable for functions, classes anc class methods
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
/**
|
|
66
|
+
* @summary
|
|
67
|
+
* This description will be used on the **module** page
|
|
68
|
+
*/
|
|
69
|
+
export function forkProcess(): void;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
# @typeParam
|
|
73
|
+
|
|
74
|
+
The @typeParam tag is used to document a type parameter of a function, method, class, interface or type alias.
|
|
75
|
+
The TSDoc standard requires that the @typeParam tag not include types and that the parameter name must be followed by a hyphen to separate it from the description.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
/**
|
|
79
|
+
* @typeParam T - the identity type
|
|
80
|
+
*/
|
|
81
|
+
export function identity<T>(x: T): T {
|
|
82
|
+
return x;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
# @throws
|
|
87
|
+
|
|
88
|
+
The @throws tag can be used to document an exception that can be thrown by a function or method.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
/**
|
|
92
|
+
* @throws {@link UserError} if `max < min`
|
|
93
|
+
*/
|
|
94
|
+
export function rand(min: number, max: number): number;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
# @property
|
|
98
|
+
|
|
99
|
+
The @property tag can be used to add a comment to a child of the current reflection. It is intended for use with the @namespace and @interface tags which might not have convenient places to include comments for each member.
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
/**
|
|
103
|
+
* This will be displayed as an interface
|
|
104
|
+
* @property a comment for a
|
|
105
|
+
* @property b comment for b
|
|
106
|
+
* @interface
|
|
107
|
+
*/
|
|
108
|
+
export type Resolved = Record<"a" | "b" | "c", string>;
|
|
109
|
+
|
|
110
|
+
// will be documented as if you wrote
|
|
111
|
+
|
|
112
|
+
/** This will be displayed as an interface */
|
|
113
|
+
export interface Resolved {
|
|
114
|
+
/** comment for a */
|
|
115
|
+
a: string;
|
|
116
|
+
/** comment for b */
|
|
117
|
+
b: string;
|
|
118
|
+
c: string;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
# @param
|
|
123
|
+
|
|
124
|
+
The @param tag is used to document a parameter of a function or method.
|
|
125
|
+
|
|
126
|
+
The TSDoc standard requires that the @param tag not include types and that the parameter name must be followed by a hyphen to separate it from the description.
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
/**
|
|
130
|
+
* @param a - the first number
|
|
131
|
+
* @param b - the second number
|
|
132
|
+
*/
|
|
133
|
+
export function sum(a: number, b: number) {
|
|
134
|
+
return a + b;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Object Literals
|
|
139
|
+
|
|
140
|
+
If the type of a parameter is an object literal type, a union containing an object literal type, or an intersection containing an object literal type, property names may be separated by `.` to add a comment to a single level of a nested property.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
/**
|
|
144
|
+
* @param options - documentation for the whole parameter
|
|
145
|
+
* @param options.value - documentation for the `value` property
|
|
146
|
+
* @param options.nested.value - NOT supported
|
|
147
|
+
*/
|
|
148
|
+
export function configure(
|
|
149
|
+
options: { value: string; nested: { value: string } } | undefined,
|
|
150
|
+
) {}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Destructured Parameters
|
|
154
|
+
|
|
155
|
+
If your function uses destructured parameters, TypeDoc will attempt to infer the parameter name from your usage of the @param tag. For it to be successful, all parameters must be documented. If TypeDoc fails to infer the name of the destructured parameter, it will be documented as __namedParameters.
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
/**
|
|
159
|
+
* @param options - docs
|
|
160
|
+
*/
|
|
161
|
+
export function configure({ value }: { value: string }) {}
|
|
162
|
+
|
|
163
|
+
// will be documented as if written as
|
|
164
|
+
export function configure(options: { value: string }) {}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
------------------------------------------------------------
|
|
169
|
+
|
|
170
|
+
-------------------- context.xsd --------------------
|
|
171
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
172
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
173
|
+
elementFormDefault="qualified">
|
|
174
|
+
|
|
175
|
+
<!-- Definition of the sourceFileType to capture the 'path' attribute -->
|
|
176
|
+
<xsd:complexType name="sourceFileType">
|
|
177
|
+
<xsd:attribute name="path" type="xsd:string" use="required"/>
|
|
178
|
+
</xsd:complexType>
|
|
179
|
+
|
|
180
|
+
<!-- Root element 'context' -->
|
|
181
|
+
<xsd:element name="context">
|
|
182
|
+
<xsd:complexType>
|
|
183
|
+
<xsd:sequence>
|
|
184
|
+
<!-- 'referenced' element with multiple 'sourceFile' elements -->
|
|
185
|
+
<xsd:element name="referenced" minOccurs="0" maxOccurs="1">
|
|
186
|
+
<xsd:complexType>
|
|
187
|
+
<xsd:sequence>
|
|
188
|
+
<xsd:element name="sourceFile" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
|
|
189
|
+
</xsd:sequence>
|
|
190
|
+
</xsd:complexType>
|
|
191
|
+
</xsd:element>
|
|
192
|
+
|
|
193
|
+
<!-- 'used' element with multiple 'sourceFile' elements -->
|
|
194
|
+
<xsd:element name="used" minOccurs="0" maxOccurs="1">
|
|
195
|
+
<xsd:complexType>
|
|
196
|
+
<xsd:sequence>
|
|
197
|
+
<xsd:element name="sourceFile" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
|
|
198
|
+
</xsd:sequence>
|
|
199
|
+
</xsd:complexType>
|
|
200
|
+
</xsd:element>
|
|
201
|
+
|
|
202
|
+
</xsd:sequence>
|
|
203
|
+
</xsd:complexType>
|
|
204
|
+
</xsd:element>
|
|
205
|
+
|
|
206
|
+
</xsd:schema>
|
|
207
|
+
------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
Instructions:
|
|
210
|
+
- Read the provided source code along with its related files (referenced and using) as structured by the context.xsd.
|
|
211
|
+
- Create the complete TSDoc documentation using only the TSDoc block tags listed above.
|
|
212
|
+
- Output ONLY the TSDoc content, without any additional text or any TypeScript comment syntax (omit /*, */, etc.).
|
|
213
|
+
|
|
214
|
+
Example Output:
|
|
215
|
+
------------------------------------------------------------
|
|
216
|
+
Deletes all properties from an object that are either null or undefined.
|
|
217
|
+
|
|
218
|
+
@template T - The type of the object. It must be an object type.
|
|
219
|
+
|
|
220
|
+
@param obj - The object from which to delete the properties. This object is not modified.
|
|
221
|
+
|
|
222
|
+
@param recursive - Optional. If true, the function will recursively delete null and undefined properties from all nested objects and arrays within the object. If false or omitted, the function will only delete null and undefined properties from the top level of the object.
|
|
223
|
+
|
|
224
|
+
@returns A new object of the same type as the input object, but with all null and undefined properties removed. If the recursive option is true, all nested objects and arrays within the object will also have their null and undefined properties removed.
|
|
225
|
+
|
|
226
|
+
@example
|
|
227
|
+
```typescript
|
|
228
|
+
// returns { a: 1, c: { d: 4 } }
|
|
229
|
+
DeleteEmptyProperties({ a: 1, b: null, c: { d: 4, e: undefined } }, true);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
@example
|
|
233
|
+
```typescript
|
|
234
|
+
// returns { a: 1, c: { d: 4, e: undefined } }
|
|
235
|
+
DeleteEmptyProperties({ a: 1, b: null, c: { d: 4, e: undefined } });
|
|
236
|
+
```
|
|
237
|
+
------------------------------------------------------------
|
|
238
|
+
|
|
239
|
+
Remember:
|
|
240
|
+
- Your output must include only the TSDoc documentation content as shown in the example output, with no surrounding comment syntax.
|
|
241
|
+
- Ensure if a code example is given the code is inclosed in "```typescript" and "```"
|
|
242
|
+
- ONLY OUTPUT THE COMMENT TEXT WITHOUT ANY OTHER RESPONSE LIKE "Based on the source code" etc.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initGenerator = initGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
function initGenerator(tree, options) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
|
+
const packageJsonFilePath = (0, path_1.relative)(tree.root, (0, path_1.join)(__dirname, '..', '..', '..', 'package.json'));
|
|
11
|
+
if (!tree.exists(packageJsonFilePath)) {
|
|
12
|
+
console.error('package.json not found in: ' + packageJsonFilePath);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const { peerDependencies, name: packageName } = JSON.parse(tree.read(packageJsonFilePath, 'utf-8'));
|
|
16
|
+
console.log(`Coerce peer dependencies for package: ${packageName}`);
|
|
17
|
+
if (!peerDependencies || !Object.keys(peerDependencies).length) {
|
|
18
|
+
console.log('No peer dependencies found');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log(`Peer dependencies: ${Object.keys(peerDependencies).join(', ')}`);
|
|
22
|
+
const rootPackageJson = JSON.parse(tree.read('package.json', 'utf-8'));
|
|
23
|
+
let isDevDependency = !!((_a = rootPackageJson.devDependencies) === null || _a === void 0 ? void 0 : _a[packageName]);
|
|
24
|
+
if (isDevDependency &&
|
|
25
|
+
[/^@rxap\/ngx/, /^@rxap\/nest/].some((rx) => rx.test(packageName))) {
|
|
26
|
+
(_b = rootPackageJson.dependencies) !== null && _b !== void 0 ? _b : (rootPackageJson.dependencies = {});
|
|
27
|
+
rootPackageJson.dependencies[packageName] =
|
|
28
|
+
rootPackageJson.devDependencies[packageName];
|
|
29
|
+
delete rootPackageJson.devDependencies[packageName];
|
|
30
|
+
isDevDependency = false;
|
|
31
|
+
tree.write('package.json', JSON.stringify(rootPackageJson, null, 2));
|
|
32
|
+
}
|
|
33
|
+
if (!isDevDependency && [
|
|
34
|
+
/^@rxap\/plugin/,
|
|
35
|
+
/^@rxap\/workspace/,
|
|
36
|
+
/@rxap\/schematic/,
|
|
37
|
+
]) {
|
|
38
|
+
(_c = rootPackageJson.devDependencies) !== null && _c !== void 0 ? _c : (rootPackageJson.devDependencies = {});
|
|
39
|
+
rootPackageJson.devDependencies[packageName] =
|
|
40
|
+
rootPackageJson.dependencies[packageName];
|
|
41
|
+
delete rootPackageJson.dependencies[packageName];
|
|
42
|
+
isDevDependency = true;
|
|
43
|
+
tree.write('package.json', JSON.stringify(rootPackageJson, null, 2));
|
|
44
|
+
}
|
|
45
|
+
const missingPeerDependencies = Object.entries(peerDependencies)
|
|
46
|
+
.filter(([dep]) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
return !((_a = rootPackageJson.dependencies) === null || _a === void 0 ? void 0 : _a[dep]) &&
|
|
49
|
+
!((_b = rootPackageJson.devDependencies) === null || _b === void 0 ? void 0 : _b[dep]);
|
|
50
|
+
})
|
|
51
|
+
.reduce((acc, [dep, version]) => (Object.assign(Object.assign({}, acc), { [dep]: version })), {});
|
|
52
|
+
if (!Object.keys(missingPeerDependencies).length) {
|
|
53
|
+
console.log('No missing peer dependencies');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (isDevDependency) {
|
|
57
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, missingPeerDependencies);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, missingPeerDependencies, {});
|
|
61
|
+
}
|
|
62
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
63
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
64
|
+
for (const peer of Object.keys(missingPeerDependencies)) {
|
|
65
|
+
console.log(`Peer dependency ${peer} added to package.json`);
|
|
66
|
+
const peerPackageJsonFilePath = (0, path_1.join)('node_modules', ...peer.split('/'), 'package.json');
|
|
67
|
+
if (!tree.exists(peerPackageJsonFilePath)) {
|
|
68
|
+
console.log(`Peer dependency ${peer} has no package.json`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const { generators, schematics } = JSON.parse(tree.read(peerPackageJsonFilePath, 'utf-8'));
|
|
72
|
+
if (!generators && !schematics) {
|
|
73
|
+
console.log(`Peer dependency ${peer} has no generators or schematics`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const configFile = generators || schematics;
|
|
77
|
+
if (!tree.exists((0, path_1.join)('node_modules', ...peer.split('/'), configFile))) {
|
|
78
|
+
console.log(`Peer dependency ${peer} has no generators or schematics file`);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const config = JSON.parse(tree.read((0, path_1.join)('node_modules', ...peer.split('/'), configFile), 'utf-8'));
|
|
82
|
+
if (!((_d = config.generators) === null || _d === void 0 ? void 0 : _d.init)) {
|
|
83
|
+
console.log(`Peer dependency ${peer} has no init generator`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const initGeneratorFilePath = config.generators.init.factory;
|
|
87
|
+
const fullInitGeneratorFilePath = (0, path_1.join)('node_modules', ...peer.split('/'), initGeneratorFilePath) + '.js';
|
|
88
|
+
if (!tree.exists(fullInitGeneratorFilePath)) {
|
|
89
|
+
console.log(`Peer dependency ${peer} has no init generator file: ` +
|
|
90
|
+
fullInitGeneratorFilePath);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
94
|
+
const initGenerator = (_e = require((0, path_1.join)('node_modules', ...peer.split('/'), initGeneratorFilePath))) === null || _e === void 0 ? void 0 : _e.default;
|
|
95
|
+
if (typeof initGenerator !== 'function') {
|
|
96
|
+
console.log(`Peer dependency ${peer} has no init generator function`);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
console.log(`Run init generator for peer dependency ${peer}`);
|
|
100
|
+
yield initGenerator(tree, options);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.default = initGenerator;
|
|
105
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/init/generator.ts"],"names":[],"mappings":";;AASA,sCAgIC;;AAzID,uCAKoB;AACpB,+BAAsC;AAGtC,SAAsB,aAAa,CAAC,IAAU,EAAE,OAA4B;;;QAC1E,MAAM,mBAAmB,GAAG,IAAA,eAAQ,EAClC,IAAI,CAAC,IAAI,EACT,IAA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,GAAG,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;YAC9D,MAAM,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;CAAA;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const generator_1 = require("./generator");
|
|
5
|
+
const schematic = (0, devkit_1.convertNxGenerator)(generator_1.default);
|
|
6
|
+
exports.default = schematic;
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/init/index.ts"],"names":[],"mappings":";;AAAA,uCAAgD;AAChD,2CAAoC;AAEpC,MAAM,SAAS,GAAG,IAAA,2BAAkB,EAAC,mBAAS,CAAC,CAAC;AAChD,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageDescriptionGenerator = packageDescriptionGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const workspace_ts_morph_1 = require("@rxap/workspace-ts-morph");
|
|
6
|
+
const workspace_utilities_1 = require("@rxap/workspace-utilities");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const xml2js_1 = require("xml2js");
|
|
10
|
+
const completion_1 = require("../../lib/completion");
|
|
11
|
+
const compose_context_1 = require("../../lib/compose-context");
|
|
12
|
+
const model_1 = require("../../lib/model");
|
|
13
|
+
function projectToContext(project, packageName) {
|
|
14
|
+
const builder = new xml2js_1.Builder();
|
|
15
|
+
const context = { sourceFile: [], package: { _: packageName } };
|
|
16
|
+
for (const sourceFile of project.getSourceFiles()) {
|
|
17
|
+
context.sourceFile.push((0, compose_context_1.sourceFileToContextSourceFile)(sourceFile));
|
|
18
|
+
}
|
|
19
|
+
return builder.buildObject(context).replace(/root>/g, 'context>') + '\n';
|
|
20
|
+
}
|
|
21
|
+
function packageDescriptionGenerator(tree, options) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { model = 'gemini/2.0-flash', apiKey, orgId, projectId, baseUrl, project: projectName } = options;
|
|
24
|
+
if (model && !Object.keys(model_1.tokenLimits).includes(model)) {
|
|
25
|
+
throw new Error(`The model '${model}' is not supported in the documentation generator`);
|
|
26
|
+
}
|
|
27
|
+
const projectConfiguration = (0, workspace_utilities_1.GetProject)(tree, projectName);
|
|
28
|
+
if (!(0, workspace_utilities_1.IsLibraryProject)(projectConfiguration)) {
|
|
29
|
+
console.log(`The project '${projectName}' is not a library project.`.yellow);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!(0, workspace_utilities_1.IsPublishable)(tree, projectConfiguration)) {
|
|
33
|
+
console.log(`The project '${projectName}' is not intended to be published.`.yellow);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if ((0, workspace_utilities_1.GetProjectPackageJson)(tree, projectName).description && !options.overwrite) {
|
|
37
|
+
console.log(`The project '${projectName}' has already a description. User --overwrite to replace the existing description`.yellow);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const systemPrompt = (0, node_fs_1.readFileSync)((0, path_1.join)(__dirname, 'system-prompts', 'generic.txt'), 'utf-8');
|
|
41
|
+
let context = '';
|
|
42
|
+
(0, workspace_ts_morph_1.TsMorphTransform)(tree, (0, workspace_utilities_1.GetProjectSourceRoot)(tree, projectName), (project) => {
|
|
43
|
+
context = projectToContext(project, (0, workspace_utilities_1.GetProjectPackageJson)(tree, projectName).name);
|
|
44
|
+
});
|
|
45
|
+
const description = yield (0, completion_1.completion)(systemPrompt, context, { apiKey, projectId, orgId, baseUrl, model: model });
|
|
46
|
+
console.log('DESCRIPTION'.green + ' ' + description);
|
|
47
|
+
(0, workspace_utilities_1.UpdateProjectPackageJson)(tree, packageJson => {
|
|
48
|
+
packageJson.description = description;
|
|
49
|
+
}, { projectName });
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.default = packageDescriptionGenerator;
|
|
53
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/package-description/generator.ts"],"names":[],"mappings":";;AAqCA,kEA0CC;;AA9ED,iEAGkC;AAClC,mEAOmC;AACnC,qCAAuC;AACvC,+BAA4B;AAE5B,mCAAiC;AACjC,qDAAkD;AAClD,+DAGmC;AACnC,2CAGyB;AAGzB,SAAS,gBAAgB,CAAC,OAAgB,EAAE,WAAmB;IAC7D,MAAM,OAAO,GAAG,IAAI,gBAAO,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,EAAE,UAAU,EAAE,EAAyB,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;IACvF,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QAClD,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAA,+CAA6B,EAAC,UAAU,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;AAC3E,CAAC;AAED,SAAsB,2BAA2B,CAC/C,IAAU,EACV,OAA0C;;QAE1C,MAAM,EAAC,KAAK,GAAG,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEvG,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC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AAC,YAAY,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAc,EAAE,CAAC,CAAC;QAE1H,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG,GAAG,GAAG,WAAW,CAAC,CAAC;QAErD,IAAA,8CAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,EAAE;YAC3C,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;QACxC,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAEtB,CAAC;CAAA;AAED,kBAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const generator_1 = require("./generator");
|
|
5
|
+
const schematic = (0, devkit_1.convertNxGenerator)(generator_1.default);
|
|
6
|
+
exports.default = schematic;
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/package-description/index.ts"],"names":[],"mappings":";;AAAA,uCAAgD;AAChD,2CAAoC;AAEpC,MAAM,SAAS,GAAG,IAAA,2BAAkB,EAAC,mBAAS,CAAC,CAAC;AAChD,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PackageDescriptionGeneratorSchema {
|
|
2
|
+
project: string;
|
|
3
|
+
/** The openai api key */
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
/** The openai organization id */
|
|
6
|
+
orgId?: string;
|
|
7
|
+
/** The openai project id */
|
|
8
|
+
projectId?: string;
|
|
9
|
+
/** The openai base url */
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
/** Set the LLM model to be used */
|
|
12
|
+
model?: string;
|
|
13
|
+
/** Replaces the existing description files */
|
|
14
|
+
overwrite?: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "PackageDescription",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
"apiKey": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "The openai api key"
|
|
13
|
+
},
|
|
14
|
+
"orgId": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The openai organization id"
|
|
17
|
+
},
|
|
18
|
+
"projectId": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The openai project id"
|
|
21
|
+
},
|
|
22
|
+
"baseUrl": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "The openai base url"
|
|
25
|
+
},
|
|
26
|
+
"model": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "Set the LLM model to be used",
|
|
29
|
+
"default": "gemini/2.0-flash"
|
|
30
|
+
},
|
|
31
|
+
"overwrite": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Replaces the existing description files"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": ["project"]
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Your task is to generate a short description for an npm package based on the source code of the package
|
|
2
|
+
|
|
3
|
+
The source code of the npm package is provided as context formatted according to the schema in the context.xsd file below.
|
|
4
|
+
|
|
5
|
+
Use the following file contents as reference:
|
|
6
|
+
|
|
7
|
+
-------------------- context.xsd --------------------
|
|
8
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
9
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
10
|
+
elementFormDefault="qualified">
|
|
11
|
+
|
|
12
|
+
<!-- Definition of the sourceFileType to capture the 'path' attribute -->
|
|
13
|
+
<xsd:complexType name="sourceFileType">
|
|
14
|
+
<xsd:attribute name="path" type="xsd:string" use="required"/>
|
|
15
|
+
</xsd:complexType>
|
|
16
|
+
|
|
17
|
+
<!-- Root element 'context' -->
|
|
18
|
+
<xsd:element name="context">
|
|
19
|
+
<xsd:complexType>
|
|
20
|
+
<xsd:sequence>
|
|
21
|
+
<!-- the name of the npm package -->
|
|
22
|
+
<xsd:element name="package" minOccurs="1" maxOccurs="1"/>
|
|
23
|
+
<!-- multiple 'sourceFile' elements -->
|
|
24
|
+
<xsd:element name="sourceFile" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
|
|
25
|
+
</xsd:sequence>
|
|
26
|
+
</xsd:complexType>
|
|
27
|
+
</xsd:element>
|
|
28
|
+
|
|
29
|
+
</xsd:schema>
|
|
30
|
+
------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
Instructions:
|
|
33
|
+
- Read the provided source code as structured by the context.xsd.
|
|
34
|
+
- Create short one to three sentence description of the npm package
|
|
35
|
+
- Output ONLY the description text without any other text
|
|
36
|
+
|
|
37
|
+
Example Output:
|
|
38
|
+
------------------------------------------------------------
|
|
39
|
+
TypeScript Compiler API wrapper. Provides an easier way to programmatically navigate and manipulate TypeScript and JavaScript code.
|
|
40
|
+
------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
Remember:
|
|
43
|
+
- The goal is to allow an developer to unterstand what this npm package offers
|
|
44
|
+
- ONLY output the description of the npm package
|
package/src/index.d.ts
ADDED
|
File without changes
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/plugin/llm/src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`cleanupJsDoc should remove comment prefix with complex example 1`] = `
|
|
4
|
+
"A map of special characters to their ASCII representation. This map contains a comprehensive set of character mappings including currency symbols, diacritical marks, mathematical symbols, and various language-specific characters from different writing systems (Latin, Cyrillic, Georgian, etc.).
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
\`\`\`typescript
|
|
8
|
+
// Example of some mappings
|
|
9
|
+
{
|
|
10
|
+
"£": "pound",
|
|
11
|
+
"€": "euro",
|
|
12
|
+
"Ä": "A",
|
|
13
|
+
"ß": "ss",
|
|
14
|
+
"Ж": "Zh"
|
|
15
|
+
}
|
|
16
|
+
\`\`\`
|
|
17
|
+
|
|
18
|
+
@default A large JSON object containing character mappings for transliteration"
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`cleanupJsDoc should remove comment prefix with simple example 1`] = `
|
|
22
|
+
"@param string - The string to slugify.
|
|
23
|
+
@param options - Options for slugifying the string.
|
|
24
|
+
@param customMap - A custom map of characters to replace.
|
|
25
|
+
@returns The slugified string.
|
|
26
|
+
|
|
27
|
+
@example
|
|
28
|
+
\`\`\`typescript
|
|
29
|
+
slugify('hello world'); // 'hello-world'
|
|
30
|
+
\`\`\`
|
|
31
|
+
"
|
|
32
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-js-doc.js","sourceRoot":"","sources":["../../../../../../packages/plugin/llm/src/lib/add-js-doc.ts"],"names":[],"mappings":";;AAEA,4BAEC;AAFD,SAAgB,QAAQ,CAAC,IAAmB,EAAE,KAAa;IACzD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertTokenLimit = assertTokenLimit;
|
|
4
|
+
const count_tokens_1 = require("./count-tokens");
|
|
5
|
+
const model_1 = require("./model");
|
|
6
|
+
function assertTokenLimit(model, ...inputs) {
|
|
7
|
+
const sum = inputs.reduce((sum, input) => sum + (0, count_tokens_1.countTokens)(model, input), 0);
|
|
8
|
+
if (sum > model_1.tokenLimits[model][0] * 0.8) {
|
|
9
|
+
throw new Error(`The input has '${sum}' tokens and the model has a limit of ${model_1.tokenLimits[model][0] * 0.8}`);
|
|
10
|
+
}
|
|
11
|
+
return sum;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=assert-token-limit.js.map
|