@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,308 +1,212 @@
|
|
|
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 __rest =
|
|
126
|
-
(this && this.__rest) ||
|
|
127
|
-
function (s, e) {
|
|
37
|
+
};
|
|
38
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
128
39
|
var t = {};
|
|
129
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
40
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
41
|
+
t[p] = s[p];
|
|
42
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
43
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
44
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
45
|
+
t[p[i]] = s[p[i]];
|
|
46
|
+
}
|
|
134
47
|
return t;
|
|
135
|
-
|
|
136
|
-
var __importDefault =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
141
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
142
53
|
exports.RepoFactory = exports.Repo = void 0;
|
|
143
|
-
var util_1 = require(
|
|
144
|
-
var util_node_1 = require(
|
|
145
|
-
var promises_1 = __importDefault(require(
|
|
146
|
-
var path_1 = __importDefault(require(
|
|
54
|
+
var util_1 = require("@proteinjs/util");
|
|
55
|
+
var util_node_1 = require("@proteinjs/util-node");
|
|
56
|
+
var promises_1 = __importDefault(require("fs/promises"));
|
|
57
|
+
var path_1 = __importDefault(require("path"));
|
|
147
58
|
var Repo = /** @class */ (function () {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
Repo.prototype.packages = function () {
|
|
153
|
-
return this.params.packages;
|
|
154
|
-
};
|
|
155
|
-
Repo.prototype.slimPackages = function () {
|
|
156
|
-
return this.params.slimPackages;
|
|
157
|
-
};
|
|
158
|
-
Repo.prototype.tsFiles = function () {
|
|
159
|
-
return this.params.tsFiles;
|
|
160
|
-
};
|
|
161
|
-
Repo.prototype.keywordFilesIndex = function () {
|
|
162
|
-
return this.params.keywordFilesIndex;
|
|
163
|
-
};
|
|
164
|
-
Repo.prototype.searchFiles = function (params) {
|
|
165
|
-
this.logger.info('Searching for file, keyword: '.concat(params.keyword));
|
|
166
|
-
var filePaths = this.keywordFilesIndex()[params.keyword];
|
|
167
|
-
return filePaths || [];
|
|
168
|
-
};
|
|
169
|
-
Repo.prototype.getDeclarations = function (params) {
|
|
170
|
-
var queriedDeclarations = {};
|
|
171
|
-
for (var _i = 0, _a = params.tsFilePaths; _i < _a.length; _i++) {
|
|
172
|
-
var tsFilePath = _a[_i];
|
|
173
|
-
queriedDeclarations[tsFilePath] = this.params.tsFiles[tsFilePath].declaration;
|
|
174
|
-
this.logger.info('Accessed declaration: '.concat(tsFilePath));
|
|
59
|
+
function Repo(params) {
|
|
60
|
+
this.logger = new util_1.Logger(this.constructor.name);
|
|
61
|
+
this.params = params;
|
|
175
62
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
63
|
+
Repo.prototype.packages = function () {
|
|
64
|
+
return this.params.packages;
|
|
65
|
+
};
|
|
66
|
+
Repo.prototype.slimPackages = function () {
|
|
67
|
+
return this.params.slimPackages;
|
|
68
|
+
};
|
|
69
|
+
Repo.prototype.tsFiles = function () {
|
|
70
|
+
return this.params.tsFiles;
|
|
71
|
+
};
|
|
72
|
+
Repo.prototype.keywordFilesIndex = function () {
|
|
73
|
+
return this.params.keywordFilesIndex;
|
|
74
|
+
};
|
|
75
|
+
Repo.prototype.searchFiles = function (params) {
|
|
76
|
+
this.logger.info("Searching for file, keyword: ".concat(params.keyword));
|
|
77
|
+
var filePaths = this.keywordFilesIndex()[params.keyword];
|
|
78
|
+
return filePaths || [];
|
|
79
|
+
};
|
|
80
|
+
Repo.prototype.getDeclarations = function (params) {
|
|
81
|
+
var queriedDeclarations = {};
|
|
82
|
+
for (var _i = 0, _a = params.tsFilePaths; _i < _a.length; _i++) {
|
|
83
|
+
var tsFilePath = _a[_i];
|
|
84
|
+
queriedDeclarations[tsFilePath] = this.params.tsFiles[tsFilePath].declaration;
|
|
85
|
+
this.logger.info("Accessed declaration: ".concat(tsFilePath));
|
|
86
|
+
}
|
|
87
|
+
return queriedDeclarations;
|
|
88
|
+
};
|
|
89
|
+
return Repo;
|
|
90
|
+
}());
|
|
180
91
|
exports.Repo = Repo;
|
|
181
92
|
var RepoFactory = /** @class */ (function () {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
function traverse(dir) {
|
|
93
|
+
function RepoFactory() {
|
|
94
|
+
}
|
|
95
|
+
RepoFactory.createRepo = function (dir) {
|
|
186
96
|
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
97
|
+
function traverse(dir) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var childrenNames, hasPackageJson, packageContent, packageJSON, _i, childrenNames_1, dirent, childPath;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0: return [4 /*yield*/, promises_1.default.readdir(dir, { withFileTypes: true })];
|
|
103
|
+
case 1:
|
|
104
|
+
childrenNames = _a.sent();
|
|
105
|
+
hasPackageJson = childrenNames.some(function (dirent) { return dirent.name === 'package.json'; });
|
|
106
|
+
if (!hasPackageJson) return [3 /*break*/, 3];
|
|
107
|
+
return [4 /*yield*/, promises_1.default.readFile(path_1.default.join(dir, 'package.json'), 'utf-8')];
|
|
108
|
+
case 2:
|
|
109
|
+
packageContent = _a.sent();
|
|
110
|
+
packageJSON = JSON.parse(packageContent);
|
|
111
|
+
repoParams.packages[packageJSON.name] = {
|
|
112
|
+
packageJSON: packageJSON,
|
|
113
|
+
dirPath: dir,
|
|
114
|
+
fileDescriptors: [],
|
|
115
|
+
tsFiles: {},
|
|
116
|
+
};
|
|
117
|
+
_a.label = 3;
|
|
118
|
+
case 3:
|
|
119
|
+
_i = 0, childrenNames_1 = childrenNames;
|
|
120
|
+
_a.label = 4;
|
|
121
|
+
case 4:
|
|
122
|
+
if (!(_i < childrenNames_1.length)) return [3 /*break*/, 7];
|
|
123
|
+
dirent = childrenNames_1[_i];
|
|
124
|
+
if (!dirent.isDirectory()) {
|
|
125
|
+
return [3 /*break*/, 6];
|
|
126
|
+
}
|
|
127
|
+
// Exclude directories 'node_modules' and 'dist' right at the beginning
|
|
128
|
+
if (dirent.name.includes('node_modules') || dirent.name.includes('dist')) {
|
|
129
|
+
return [3 /*break*/, 6];
|
|
130
|
+
}
|
|
131
|
+
childPath = path_1.default.join(dir, dirent.name);
|
|
132
|
+
return [4 /*yield*/, traverse(childPath)];
|
|
133
|
+
case 5:
|
|
134
|
+
_a.sent();
|
|
135
|
+
_a.label = 6;
|
|
136
|
+
case 6:
|
|
137
|
+
_i++;
|
|
138
|
+
return [3 /*break*/, 4];
|
|
139
|
+
case 7: return [2 /*return*/];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
196
142
|
});
|
|
197
|
-
if (!hasPackageJson) return [3 /*break*/, 3];
|
|
198
|
-
return [4 /*yield*/, promises_1.default.readFile(path_1.default.join(dir, 'package.json'), 'utf-8')];
|
|
199
|
-
case 2:
|
|
200
|
-
packageContent = _a.sent();
|
|
201
|
-
packageJSON = JSON.parse(packageContent);
|
|
202
|
-
repoParams.packages[packageJSON.name] = {
|
|
203
|
-
packageJSON: packageJSON,
|
|
204
|
-
dirPath: dir,
|
|
205
|
-
fileDescriptors: [],
|
|
206
|
-
tsFiles: {},
|
|
207
|
-
};
|
|
208
|
-
_a.label = 3;
|
|
209
|
-
case 3:
|
|
210
|
-
(_i = 0), (childrenNames_1 = childrenNames);
|
|
211
|
-
_a.label = 4;
|
|
212
|
-
case 4:
|
|
213
|
-
if (!(_i < childrenNames_1.length)) return [3 /*break*/, 7];
|
|
214
|
-
dirent = childrenNames_1[_i];
|
|
215
|
-
if (!dirent.isDirectory()) {
|
|
216
|
-
return [3 /*break*/, 6];
|
|
217
|
-
}
|
|
218
|
-
// Exclude directories 'node_modules' and 'dist' right at the beginning
|
|
219
|
-
if (dirent.name.includes('node_modules') || dirent.name.includes('dist')) {
|
|
220
|
-
return [3 /*break*/, 6];
|
|
221
|
-
}
|
|
222
|
-
childPath = path_1.default.join(dir, dirent.name);
|
|
223
|
-
return [4 /*yield*/, traverse(childPath)];
|
|
224
|
-
case 5:
|
|
225
|
-
_a.sent();
|
|
226
|
-
_a.label = 6;
|
|
227
|
-
case 6:
|
|
228
|
-
_i++;
|
|
229
|
-
return [3 /*break*/, 4];
|
|
230
|
-
case 7:
|
|
231
|
-
return [2 /*return*/];
|
|
232
143
|
}
|
|
233
|
-
|
|
144
|
+
var repoParams;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0:
|
|
148
|
+
this.LOGGER.info("Creating repo for dir: ".concat(dir));
|
|
149
|
+
repoParams = { packages: {}, slimPackages: {}, tsFiles: {}, keywordFilesIndex: {} };
|
|
150
|
+
return [4 /*yield*/, traverse(dir)];
|
|
151
|
+
case 1:
|
|
152
|
+
_a.sent();
|
|
153
|
+
return [4 /*yield*/, RepoFactory.loadFiles(repoParams)];
|
|
154
|
+
case 2:
|
|
155
|
+
_a.sent();
|
|
156
|
+
Object.keys(repoParams.packages).forEach(function (packageName) {
|
|
157
|
+
var _a = repoParams.packages[packageName], packageJSON = _a.packageJSON, tsFiles = _a.tsFiles, slimPackage = __rest(_a, ["packageJSON", "tsFiles"]);
|
|
158
|
+
repoParams.slimPackages[packageName] = slimPackage;
|
|
159
|
+
});
|
|
160
|
+
this.LOGGER.info("Created repo for dir: ".concat(dir));
|
|
161
|
+
return [2 /*return*/, new Repo(repoParams)];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
234
164
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
165
|
+
};
|
|
166
|
+
RepoFactory.loadFiles = function (repoParams) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var _i, _a, packageName, dirPath, _b, _c, _d, _e, _f, fileDescriptor, typescriptDeclaration, tsFile;
|
|
169
|
+
var _g;
|
|
170
|
+
return __generator(this, function (_h) {
|
|
171
|
+
switch (_h.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
_i = 0, _a = Object.keys(repoParams.packages);
|
|
174
|
+
_h.label = 1;
|
|
175
|
+
case 1:
|
|
176
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
177
|
+
packageName = _a[_i];
|
|
178
|
+
this.LOGGER.info("Loading files for package: ".concat(packageName));
|
|
179
|
+
dirPath = repoParams.packages[packageName].dirPath;
|
|
180
|
+
if (!dirPath) return [3 /*break*/, 3];
|
|
181
|
+
_c = (_b = (_g = repoParams.packages[packageName].fileDescriptors).push).apply;
|
|
182
|
+
_d = [_g];
|
|
183
|
+
return [4 /*yield*/, util_node_1.Fs.getFilesInDirectory(dirPath, ['node_modules', 'dist'])];
|
|
184
|
+
case 2:
|
|
185
|
+
_c.apply(_b, _d.concat([(_h.sent())]));
|
|
186
|
+
for (_e = 0, _f = repoParams.packages[packageName].fileDescriptors; _e < _f.length; _e++) {
|
|
187
|
+
fileDescriptor = _f[_e];
|
|
188
|
+
typescriptDeclaration = util_node_1.PackageUtil.generateTypescriptDeclarations({
|
|
189
|
+
tsFilePaths: [fileDescriptor.path],
|
|
190
|
+
})[fileDescriptor.path];
|
|
191
|
+
tsFile = Object.assign({ declaration: typescriptDeclaration }, fileDescriptor);
|
|
192
|
+
repoParams.packages[packageName].tsFiles[fileDescriptor.path] = tsFile;
|
|
193
|
+
repoParams.tsFiles[fileDescriptor.path] = tsFile;
|
|
194
|
+
if (!repoParams.keywordFilesIndex[fileDescriptor.nameWithoutExtension]) {
|
|
195
|
+
repoParams.keywordFilesIndex[fileDescriptor.nameWithoutExtension] = [];
|
|
196
|
+
}
|
|
197
|
+
repoParams.keywordFilesIndex[fileDescriptor.nameWithoutExtension].push(fileDescriptor.path);
|
|
198
|
+
}
|
|
199
|
+
_h.label = 3;
|
|
200
|
+
case 3:
|
|
201
|
+
_i++;
|
|
202
|
+
return [3 /*break*/, 1];
|
|
203
|
+
case 4: return [2 /*return*/];
|
|
204
|
+
}
|
|
254
205
|
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
};
|
|
261
|
-
RepoFactory.loadFiles = function (repoParams) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
-
var _i, _a, packageName, dirPath, _b, _c, _d, _e, _f, fileDescriptor, typescriptDeclaration, tsFile;
|
|
264
|
-
var _g;
|
|
265
|
-
return __generator(this, function (_h) {
|
|
266
|
-
switch (_h.label) {
|
|
267
|
-
case 0:
|
|
268
|
-
(_i = 0), (_a = Object.keys(repoParams.packages));
|
|
269
|
-
_h.label = 1;
|
|
270
|
-
case 1:
|
|
271
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
272
|
-
packageName = _a[_i];
|
|
273
|
-
this.LOGGER.info('Loading files for package: '.concat(packageName));
|
|
274
|
-
dirPath = repoParams.packages[packageName].dirPath;
|
|
275
|
-
if (!dirPath) return [3 /*break*/, 3];
|
|
276
|
-
_c = (_b = (_g = repoParams.packages[packageName].fileDescriptors).push).apply;
|
|
277
|
-
_d = [_g];
|
|
278
|
-
return [4 /*yield*/, util_node_1.Fs.getFilesInDirectory(dirPath, ['node_modules', 'dist'])];
|
|
279
|
-
case 2:
|
|
280
|
-
_c.apply(_b, _d.concat([_h.sent()]));
|
|
281
|
-
for (_e = 0, _f = repoParams.packages[packageName].fileDescriptors; _e < _f.length; _e++) {
|
|
282
|
-
fileDescriptor = _f[_e];
|
|
283
|
-
typescriptDeclaration = util_node_1.PackageUtil.generateTypescriptDeclarations({
|
|
284
|
-
tsFilePaths: [fileDescriptor.path],
|
|
285
|
-
})[fileDescriptor.path];
|
|
286
|
-
tsFile = Object.assign({ declaration: typescriptDeclaration }, fileDescriptor);
|
|
287
|
-
repoParams.packages[packageName].tsFiles[fileDescriptor.path] = tsFile;
|
|
288
|
-
repoParams.tsFiles[fileDescriptor.path] = tsFile;
|
|
289
|
-
if (!repoParams.keywordFilesIndex[fileDescriptor.nameWithoutExtension]) {
|
|
290
|
-
repoParams.keywordFilesIndex[fileDescriptor.nameWithoutExtension] = [];
|
|
291
|
-
}
|
|
292
|
-
repoParams.keywordFilesIndex[fileDescriptor.nameWithoutExtension].push(fileDescriptor.path);
|
|
293
|
-
}
|
|
294
|
-
_h.label = 3;
|
|
295
|
-
case 3:
|
|
296
|
-
_i++;
|
|
297
|
-
return [3 /*break*/, 1];
|
|
298
|
-
case 4:
|
|
299
|
-
return [2 /*return*/];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
RepoFactory.LOGGER = new util_1.Logger('RepoFactory');
|
|
305
|
-
return RepoFactory;
|
|
306
|
-
})();
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
RepoFactory.LOGGER = new util_1.Logger('RepoFactory');
|
|
209
|
+
return RepoFactory;
|
|
210
|
+
}());
|
|
307
211
|
exports.RepoFactory = RepoFactory;
|
|
308
|
-
//# sourceMappingURL=Repo.js.map
|
|
212
|
+
//# sourceMappingURL=Repo.js.map
|
|
@@ -3,22 +3,22 @@ import { FileContentMap } from '@proteinjs/util-node';
|
|
|
3
3
|
import { ChatCompletionMessageParam } from 'openai/resources/chat';
|
|
4
4
|
import { MessageModerator } from '../../history/MessageModerator';
|
|
5
5
|
export interface ConversationFs {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
fileContentMap: FileContentMap;
|
|
7
|
+
order: string[];
|
|
8
8
|
}
|
|
9
9
|
export interface ConversationFsFactoryParams {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
maxFiles: number;
|
|
11
|
+
logLevel: LogLevel;
|
|
12
12
|
}
|
|
13
13
|
export declare class ConversationFsFactory {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
private logger;
|
|
15
|
+
private params;
|
|
16
|
+
constructor(params?: Partial<ConversationFsFactoryParams>);
|
|
17
|
+
merge(existingFs: ConversationFs, updates: FileContentMap): ConversationFs;
|
|
18
18
|
}
|
|
19
19
|
export declare class ConversationFsModerator implements MessageModerator {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
private logLevel;
|
|
21
|
+
constructor(logLevel?: LogLevel);
|
|
22
|
+
observe(messages: ChatCompletionMessageParam[]): ChatCompletionMessageParam[];
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=ConversationFsModerator.d.ts.map
|
|
24
|
+
//# sourceMappingURL=ConversationFsModerator.d.ts.map
|