@proteinjs/conversation 1.0.7 → 1.0.8
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/.eslintrc.js +1 -1
- package/.prettierignore +4 -0
- package/CHANGELOG.md +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -40
- package/dist/src/CodegenConversation.d.ts +11 -11
- package/dist/src/CodegenConversation.js +180 -294
- package/dist/src/Conversation.d.ts +49 -52
- package/dist/src/Conversation.js +288 -478
- package/dist/src/ConversationModule.d.ts +6 -6
- package/dist/src/ConversationModule.js +3 -3
- package/dist/src/Function.d.ts +4 -4
- package/dist/src/Function.js +3 -3
- package/dist/src/OpenAi.d.ts +10 -42
- package/dist/src/OpenAi.js +305 -495
- package/dist/src/Paragraph.d.ts +4 -4
- package/dist/src/Paragraph.js +17 -17
- package/dist/src/Sentence.d.ts +4 -4
- package/dist/src/Sentence.js +21 -21
- package/dist/src/code_template/Code.d.ts +15 -15
- package/dist/src/code_template/Code.js +73 -167
- package/dist/src/code_template/CodeTemplate.d.ts +11 -11
- package/dist/src/code_template/CodeTemplate.js +80 -169
- package/dist/src/code_template/CodeTemplateModule.d.ts +6 -6
- package/dist/src/code_template/CodeTemplateModule.js +26 -28
- package/dist/src/code_template/Repo.d.ts +38 -34
- package/dist/src/code_template/Repo.js +195 -291
- package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts +12 -12
- package/dist/src/fs/conversation_fs/ConversationFsModerator.js +108 -110
- package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts +11 -11
- package/dist/src/fs/conversation_fs/ConversationFsModule.js +97 -204
- package/dist/src/fs/conversation_fs/FsFunctions.d.ts +62 -58
- package/dist/src/fs/conversation_fs/FsFunctions.js +252 -414
- package/dist/src/fs/git/GitModule.d.ts +8 -8
- package/dist/src/fs/git/GitModule.js +74 -163
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts +18 -16
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js +58 -158
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts +26 -27
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js +131 -234
- package/dist/src/fs/package/PackageFunctions.d.ts +60 -54
- package/dist/src/fs/package/PackageFunctions.js +213 -366
- package/dist/src/fs/package/PackageModule.d.ts +24 -24
- package/dist/src/fs/package/PackageModule.js +170 -292
- package/dist/src/history/MessageHistory.d.ts +12 -12
- package/dist/src/history/MessageHistory.js +46 -52
- package/dist/src/history/MessageModerator.d.ts +2 -2
- package/dist/src/history/MessageModerator.js +3 -3
- package/dist/src/template/ConversationTemplate.d.ts +8 -8
- package/dist/src/template/ConversationTemplate.js +3 -3
- package/dist/src/template/ConversationTemplateFunctions.d.ts +35 -33
- package/dist/src/template/ConversationTemplateFunctions.js +75 -176
- package/dist/src/template/ConversationTemplateModule.d.ts +48 -51
- package/dist/src/template/ConversationTemplateModule.js +116 -211
- package/dist/src/template/createApp/CreateAppTemplate.d.ts +1 -1
- package/dist/src/template/createApp/CreateAppTemplate.js +59 -151
- package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts +1 -1
- package/dist/src/template/createCode/CreateCodeConversationTemplate.js +67 -183
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts +1 -1
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.js +77 -174
- package/dist/src/template/createPackage/tsconfig.json +11 -11
- package/dist/test/createKeywordFilesIndex.test.d.ts +1 -1
- package/dist/test/createKeywordFilesIndex.test.js +41 -132
- package/dist/test/openai/openai.generateList.test.d.ts +1 -1
- package/dist/test/openai/openai.generateList.test.js +47 -136
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts +1 -1
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.js +12 -13
- package/dist/test/repo/repo.test.d.ts +1 -1
- package/dist/test/repo/repo.test.js +38 -127
- package/package.json +2 -2
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { ConversationModule, ConversationModuleFactory } from '../../ConversationModule';
|
|
2
2
|
import { Function } from '../../Function';
|
|
3
3
|
export type Library = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
fileName: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
packageName: string;
|
|
7
7
|
};
|
|
8
8
|
export type LibraryImport = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
importStatements: string[];
|
|
10
|
+
typescriptDeclaration: string;
|
|
11
11
|
};
|
|
12
12
|
export declare class PackageModule implements ConversationModule {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
private repoPath;
|
|
14
|
+
constructor(repoPath: string);
|
|
15
|
+
getName(): string;
|
|
16
|
+
getSystemMessages(): string[];
|
|
17
|
+
getFunctions(): Function[];
|
|
18
|
+
getMessageModerators(): never[];
|
|
19
|
+
/**
|
|
20
|
+
* @param keyword either the package name or some substring
|
|
21
|
+
* @return string[] of file paths
|
|
22
|
+
*/
|
|
23
|
+
searchPackages(keyword: string): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Search packages in repo for file names that include keyword
|
|
26
|
+
* @param keyword substring of file name to search for
|
|
27
|
+
* @returns all libraries in the repo matching the keyword
|
|
28
|
+
*/
|
|
29
|
+
searchLibraries(keyword: string): Promise<Library[]>;
|
|
30
30
|
}
|
|
31
31
|
export declare class PackageModuleFactory implements ConversationModuleFactory {
|
|
32
|
-
|
|
32
|
+
createModule(repoPath: string): Promise<PackageModule>;
|
|
33
33
|
}
|
|
34
|
-
//# sourceMappingURL=PackageModule.d.ts.map
|
|
34
|
+
//# sourceMappingURL=PackageModule.d.ts.map
|
|
@@ -1,304 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter =
|
|
3
|
-
|
|
4
|
-
function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) {
|
|
6
|
-
return value instanceof P
|
|
7
|
-
? value
|
|
8
|
-
: new P(function (resolve) {
|
|
9
|
-
resolve(value);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
reject(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function rejected(value) {
|
|
21
|
-
try {
|
|
22
|
-
step(generator['throw'](value));
|
|
23
|
-
} catch (e) {
|
|
24
|
-
reject(e);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function step(result) {
|
|
28
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
29
|
-
}
|
|
30
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
9
|
});
|
|
32
|
-
|
|
33
|
-
var __generator =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
label: 0,
|
|
38
|
-
sent: function () {
|
|
39
|
-
if (t[0] & 1) throw t[1];
|
|
40
|
-
return t[1];
|
|
41
|
-
},
|
|
42
|
-
trys: [],
|
|
43
|
-
ops: [],
|
|
44
|
-
},
|
|
45
|
-
f,
|
|
46
|
-
y,
|
|
47
|
-
t,
|
|
48
|
-
g;
|
|
49
|
-
return (
|
|
50
|
-
(g = { next: verb(0), throw: verb(1), return: verb(2) }),
|
|
51
|
-
typeof Symbol === 'function' &&
|
|
52
|
-
(g[Symbol.iterator] = function () {
|
|
53
|
-
return this;
|
|
54
|
-
}),
|
|
55
|
-
g
|
|
56
|
-
);
|
|
57
|
-
function verb(n) {
|
|
58
|
-
return function (v) {
|
|
59
|
-
return step([n, v]);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
62
15
|
function step(op) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
_.label++;
|
|
84
|
-
y = op[1];
|
|
85
|
-
op = [0];
|
|
86
|
-
continue;
|
|
87
|
-
case 7:
|
|
88
|
-
op = _.ops.pop();
|
|
89
|
-
_.trys.pop();
|
|
90
|
-
continue;
|
|
91
|
-
default:
|
|
92
|
-
if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) {
|
|
93
|
-
_ = 0;
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
97
|
-
_.label = op[1];
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
101
|
-
_.label = t[1];
|
|
102
|
-
t = op;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
if (t && _.label < t[2]) {
|
|
106
|
-
_.label = t[2];
|
|
107
|
-
_.ops.push(op);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
if (t[2]) _.ops.pop();
|
|
111
|
-
_.trys.pop();
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
op = body.call(thisArg, _);
|
|
115
|
-
} catch (e) {
|
|
116
|
-
op = [6, e];
|
|
117
|
-
y = 0;
|
|
118
|
-
} finally {
|
|
119
|
-
f = t = 0;
|
|
120
|
-
}
|
|
121
|
-
if (op[0] & 5) throw op[1];
|
|
122
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
123
36
|
}
|
|
124
|
-
|
|
125
|
-
var __spreadArray =
|
|
126
|
-
|
|
127
|
-
function (to, from, pack) {
|
|
128
|
-
if (pack || arguments.length === 2)
|
|
129
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
130
40
|
if (ar || !(i in from)) {
|
|
131
|
-
|
|
132
|
-
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
133
43
|
}
|
|
134
|
-
|
|
44
|
+
}
|
|
135
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
136
|
-
|
|
137
|
-
var __importDefault =
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
143
51
|
exports.PackageModuleFactory = exports.PackageModule = void 0;
|
|
144
|
-
var util_node_1 = require(
|
|
145
|
-
var PackageFunctions_1 = require(
|
|
146
|
-
var path_1 = __importDefault(require(
|
|
52
|
+
var util_node_1 = require("@proteinjs/util-node");
|
|
53
|
+
var PackageFunctions_1 = require("./PackageFunctions");
|
|
54
|
+
var path_1 = __importDefault(require("path"));
|
|
147
55
|
var PackageModule = /** @class */ (function () {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
util_node_1.Fs.getFilePathsMatchingGlob(path_1.default.join(packageDirectory, 'src'), '**/*.ts', [
|
|
261
|
-
'**/node_modules/**',
|
|
262
|
-
'**/dist/**',
|
|
263
|
-
]),
|
|
264
|
-
];
|
|
265
|
-
case 4:
|
|
266
|
-
srcFilePaths = _c.sent();
|
|
267
|
-
for (_b = 0, srcFilePaths_1 = srcFilePaths; _b < srcFilePaths_1.length; _b++) {
|
|
268
|
-
srcFilePath = srcFilePaths_1[_b];
|
|
269
|
-
fileNameWithExtension = path_1.default.basename(srcFilePath);
|
|
270
|
-
if (fileNameWithExtension.includes(keyword)) {
|
|
271
|
-
fileName = path_1.default.basename(srcFilePath, path_1.default.extname(srcFilePath));
|
|
272
|
-
matchingLibraries.push({
|
|
273
|
-
fileName: fileName,
|
|
274
|
-
filePath: srcFilePath,
|
|
275
|
-
packageName: packageJson.name,
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
_c.label = 5;
|
|
280
|
-
case 5:
|
|
281
|
-
_i++;
|
|
282
|
-
return [3 /*break*/, 3];
|
|
283
|
-
case 6:
|
|
284
|
-
return [2 /*return*/, matchingLibraries];
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
return PackageModule;
|
|
290
|
-
})();
|
|
56
|
+
function PackageModule(repoPath) {
|
|
57
|
+
this.repoPath = repoPath;
|
|
58
|
+
}
|
|
59
|
+
PackageModule.prototype.getName = function () {
|
|
60
|
+
return 'Package';
|
|
61
|
+
};
|
|
62
|
+
PackageModule.prototype.getSystemMessages = function () {
|
|
63
|
+
return [
|
|
64
|
+
"When generating code, prefer importing code from local packages",
|
|
65
|
+
"Use the ".concat(PackageFunctions_1.searchPackagesFunctionName, " function on every package you plan to install to derermine if the package is in the local repo; if it is, calculate the relative path from the cwd package to the package being installed, use that path as the version when installing the package"),
|
|
66
|
+
// `When generating code, use the searchFiles function to find all file paths to index.ts files; these are the local apis we have access to`,
|
|
67
|
+
// `When generating import statements, use the searchFiles function to find all file paths to package.json files; if importing from a local package, make sure you import via its package if it is not a local file to the package we're generating code in`,
|
|
68
|
+
"When generating import statements from another package, do not use relative paths",
|
|
69
|
+
];
|
|
70
|
+
};
|
|
71
|
+
PackageModule.prototype.getFunctions = function () {
|
|
72
|
+
return __spreadArray(__spreadArray([], PackageFunctions_1.packageFunctions, true), [(0, PackageFunctions_1.searchPackagesFunction)(this), (0, PackageFunctions_1.searchLibrariesFunction)(this)], false);
|
|
73
|
+
};
|
|
74
|
+
PackageModule.prototype.getMessageModerators = function () {
|
|
75
|
+
return [];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @param keyword either the package name or some substring
|
|
79
|
+
* @return string[] of file paths
|
|
80
|
+
*/
|
|
81
|
+
PackageModule.prototype.searchPackages = function (keyword) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var matchingPackageJsonPaths, packageJsonFilePaths, packageJsonFileMap, _i, _a, packageJsonFilePath, packageJson;
|
|
84
|
+
return __generator(this, function (_b) {
|
|
85
|
+
switch (_b.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
matchingPackageJsonPaths = [];
|
|
88
|
+
return [4 /*yield*/, util_node_1.Fs.getFilePathsMatchingGlob(this.repoPath, '**/package.json', [
|
|
89
|
+
'**/node_modules/**',
|
|
90
|
+
'**/dist/**',
|
|
91
|
+
])];
|
|
92
|
+
case 1:
|
|
93
|
+
packageJsonFilePaths = _b.sent();
|
|
94
|
+
return [4 /*yield*/, util_node_1.Fs.readFiles(packageJsonFilePaths)];
|
|
95
|
+
case 2:
|
|
96
|
+
packageJsonFileMap = _b.sent();
|
|
97
|
+
for (_i = 0, _a = Object.keys(packageJsonFileMap); _i < _a.length; _i++) {
|
|
98
|
+
packageJsonFilePath = _a[_i];
|
|
99
|
+
packageJson = JSON.parse(packageJsonFileMap[packageJsonFilePath]);
|
|
100
|
+
if (packageJson.name.toLowerCase().includes(keyword.toLocaleLowerCase())) {
|
|
101
|
+
matchingPackageJsonPaths.push(packageJsonFilePath);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return [2 /*return*/, matchingPackageJsonPaths];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Search packages in repo for file names that include keyword
|
|
111
|
+
* @param keyword substring of file name to search for
|
|
112
|
+
* @returns all libraries in the repo matching the keyword
|
|
113
|
+
*/
|
|
114
|
+
PackageModule.prototype.searchLibraries = function (keyword) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
var matchingLibraries, packageJsonFilePaths, packageJsonFileMap, _i, _a, packageJsonFilePath, packageJson, packageJsonFilePathParts, packageDirectory, srcFilePaths, _b, srcFilePaths_1, srcFilePath, fileNameWithExtension, fileName;
|
|
117
|
+
return __generator(this, function (_c) {
|
|
118
|
+
switch (_c.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
matchingLibraries = [];
|
|
121
|
+
return [4 /*yield*/, util_node_1.Fs.getFilePathsMatchingGlob(this.repoPath, '**/package.json', [
|
|
122
|
+
'**/node_modules/**',
|
|
123
|
+
'**/dist/**',
|
|
124
|
+
])];
|
|
125
|
+
case 1:
|
|
126
|
+
packageJsonFilePaths = _c.sent();
|
|
127
|
+
return [4 /*yield*/, util_node_1.Fs.readFiles(packageJsonFilePaths)];
|
|
128
|
+
case 2:
|
|
129
|
+
packageJsonFileMap = _c.sent();
|
|
130
|
+
_i = 0, _a = Object.keys(packageJsonFileMap);
|
|
131
|
+
_c.label = 3;
|
|
132
|
+
case 3:
|
|
133
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
134
|
+
packageJsonFilePath = _a[_i];
|
|
135
|
+
packageJson = JSON.parse(packageJsonFileMap[packageJsonFilePath]);
|
|
136
|
+
packageJsonFilePathParts = packageJsonFilePath.split(path_1.default.sep);
|
|
137
|
+
packageJsonFilePathParts.pop();
|
|
138
|
+
packageDirectory = packageJsonFilePathParts.join(path_1.default.sep);
|
|
139
|
+
return [4 /*yield*/, util_node_1.Fs.getFilePathsMatchingGlob(path_1.default.join(packageDirectory, 'src'), '**/*.ts', [
|
|
140
|
+
'**/node_modules/**',
|
|
141
|
+
'**/dist/**',
|
|
142
|
+
])];
|
|
143
|
+
case 4:
|
|
144
|
+
srcFilePaths = _c.sent();
|
|
145
|
+
for (_b = 0, srcFilePaths_1 = srcFilePaths; _b < srcFilePaths_1.length; _b++) {
|
|
146
|
+
srcFilePath = srcFilePaths_1[_b];
|
|
147
|
+
fileNameWithExtension = path_1.default.basename(srcFilePath);
|
|
148
|
+
if (fileNameWithExtension.includes(keyword)) {
|
|
149
|
+
fileName = path_1.default.basename(srcFilePath, path_1.default.extname(srcFilePath));
|
|
150
|
+
matchingLibraries.push({
|
|
151
|
+
fileName: fileName,
|
|
152
|
+
filePath: srcFilePath,
|
|
153
|
+
packageName: packageJson.name,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
_c.label = 5;
|
|
158
|
+
case 5:
|
|
159
|
+
_i++;
|
|
160
|
+
return [3 /*break*/, 3];
|
|
161
|
+
case 6: return [2 /*return*/, matchingLibraries];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
return PackageModule;
|
|
167
|
+
}());
|
|
291
168
|
exports.PackageModule = PackageModule;
|
|
292
169
|
var PackageModuleFactory = /** @class */ (function () {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
170
|
+
function PackageModuleFactory() {
|
|
171
|
+
}
|
|
172
|
+
PackageModuleFactory.prototype.createModule = function (repoPath) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
return [2 /*return*/, new PackageModule(repoPath)];
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
return PackageModuleFactory;
|
|
180
|
+
}());
|
|
303
181
|
exports.PackageModuleFactory = PackageModuleFactory;
|
|
304
|
-
//# sourceMappingURL=PackageModule.js.map
|
|
182
|
+
//# sourceMappingURL=PackageModule.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ChatCompletionMessageParam } from 'openai/resources/chat';
|
|
2
2
|
export interface MessageHistoryParams {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
enforceMessageLimit?: boolean;
|
|
4
|
+
maxMessages: number;
|
|
5
5
|
}
|
|
6
6
|
export declare class MessageHistory {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
private logger;
|
|
8
|
+
private messages;
|
|
9
|
+
private params;
|
|
10
|
+
constructor(params?: Partial<MessageHistoryParams>);
|
|
11
|
+
getMessages(): ChatCompletionMessageParam[];
|
|
12
|
+
toString(): string;
|
|
13
|
+
setMessages(messages: ChatCompletionMessageParam[]): MessageHistory;
|
|
14
|
+
push(messages: ChatCompletionMessageParam[]): MessageHistory;
|
|
15
|
+
prune(): void;
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=MessageHistory.d.ts.map
|
|
17
|
+
//# sourceMappingURL=MessageHistory.d.ts.map
|