@proteinjs/conversation 1.0.1 → 1.0.3
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 +16 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/src/CodegenConversation.d.ts +13 -0
- package/dist/src/CodegenConversation.d.ts.map +1 -0
- package/dist/src/CodegenConversation.js +128 -57
- package/dist/src/CodegenConversation.js.map +1 -0
- package/dist/src/Conversation.d.ts +60 -0
- package/dist/src/Conversation.d.ts.map +1 -0
- package/dist/src/Conversation.js +202 -102
- package/dist/src/Conversation.js.map +1 -0
- package/dist/src/ConversationModule.d.ts +12 -0
- package/dist/src/ConversationModule.d.ts.map +1 -0
- package/dist/src/ConversationModule.js +1 -0
- package/dist/src/ConversationModule.js.map +1 -0
- package/dist/src/Function.d.ts +7 -0
- package/dist/src/Function.d.ts.map +1 -0
- package/dist/src/Function.js +1 -0
- package/dist/src/Function.js.map +1 -0
- package/dist/src/OpenAi.d.ts +18 -0
- package/dist/src/OpenAi.d.ts.map +1 -0
- package/dist/src/OpenAi.js +265 -169
- package/dist/src/OpenAi.js.map +1 -0
- package/dist/src/Paragraph.d.ts +7 -0
- package/dist/src/Paragraph.d.ts.map +1 -0
- package/dist/src/Paragraph.js +9 -7
- package/dist/src/Paragraph.js.map +1 -0
- package/dist/src/Sentence.d.ts +6 -0
- package/dist/src/Sentence.d.ts.map +1 -0
- package/dist/src/Sentence.js +10 -8
- package/dist/src/Sentence.js.map +1 -0
- package/dist/src/code_template/Code.d.ts +24 -0
- package/dist/src/code_template/Code.d.ts.map +1 -0
- package/dist/src/code_template/Code.js +57 -22
- package/dist/src/code_template/Code.js.map +1 -0
- package/dist/src/code_template/CodeTemplate.d.ts +18 -0
- package/dist/src/code_template/CodeTemplate.d.ts.map +1 -0
- package/dist/src/code_template/CodeTemplate.js +68 -20
- package/dist/src/code_template/CodeTemplate.js.map +1 -0
- package/dist/src/code_template/CodeTemplateModule.d.ts +11 -0
- package/dist/src/code_template/CodeTemplateModule.d.ts.map +1 -0
- package/dist/src/code_template/CodeTemplateModule.js +20 -16
- package/dist/src/code_template/CodeTemplateModule.js.map +1 -0
- package/dist/src/code_template/Repo.d.ts +50 -0
- package/dist/src/code_template/Repo.d.ts.map +1 -0
- package/dist/src/code_template/Repo.js +161 -80
- package/dist/src/code_template/Repo.js.map +1 -0
- package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts +24 -0
- package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts.map +1 -0
- package/dist/src/fs/conversation_fs/ConversationFsModerator.js +45 -36
- package/dist/src/fs/conversation_fs/ConversationFsModerator.js.map +1 -0
- package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts +18 -0
- package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts.map +1 -0
- package/dist/src/fs/conversation_fs/ConversationFsModule.js +84 -41
- package/dist/src/fs/conversation_fs/ConversationFsModule.js.map +1 -0
- package/dist/src/fs/conversation_fs/FsFunctions.d.ts +82 -0
- package/dist/src/fs/conversation_fs/FsFunctions.d.ts.map +1 -0
- package/dist/src/fs/conversation_fs/FsFunctions.js +105 -30
- package/dist/src/fs/conversation_fs/FsFunctions.js.map +1 -0
- package/dist/src/fs/git/GitModule.d.ts +14 -0
- package/dist/src/fs/git/GitModule.d.ts.map +1 -0
- package/dist/src/fs/git/GitModule.js +65 -24
- package/dist/src/fs/git/GitModule.js.map +1 -0
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts +23 -0
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts.map +1 -0
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js +35 -5
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js.map +1 -0
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts +34 -0
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts.map +1 -0
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js +107 -50
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js.map +1 -0
- package/dist/src/fs/package/PackageFunctions.d.ts +79 -0
- package/dist/src/fs/package/PackageFunctions.d.ts.map +1 -0
- package/dist/src/fs/package/PackageFunctions.js +78 -16
- package/dist/src/fs/package/PackageFunctions.js.map +1 -0
- package/dist/src/fs/package/PackageModule.d.ts +34 -0
- package/dist/src/fs/package/PackageModule.d.ts.map +1 -0
- package/dist/src/fs/package/PackageModule.js +135 -62
- package/dist/src/fs/package/PackageModule.js.map +1 -0
- package/dist/src/history/MessageHistory.d.ts +17 -0
- package/dist/src/history/MessageHistory.d.ts.map +1 -0
- package/dist/src/history/MessageHistory.js +25 -22
- package/dist/src/history/MessageHistory.js.map +1 -0
- package/dist/src/history/MessageModerator.d.ts +5 -0
- package/dist/src/history/MessageModerator.d.ts.map +1 -0
- package/dist/src/history/MessageModerator.js +1 -0
- package/dist/src/history/MessageModerator.js.map +1 -0
- package/dist/src/template/ConversationTemplate.d.ts +12 -0
- package/dist/src/template/ConversationTemplate.d.ts.map +1 -0
- package/dist/src/template/ConversationTemplate.js +1 -0
- package/dist/src/template/ConversationTemplate.js.map +1 -0
- package/dist/src/template/ConversationTemplateFunctions.d.ts +44 -0
- package/dist/src/template/ConversationTemplateFunctions.d.ts.map +1 -0
- package/dist/src/template/ConversationTemplateFunctions.js +39 -4
- package/dist/src/template/ConversationTemplateFunctions.js.map +1 -0
- package/dist/src/template/ConversationTemplateModule.d.ts +65 -0
- package/dist/src/template/ConversationTemplateModule.d.ts.map +1 -0
- package/dist/src/template/ConversationTemplateModule.js +92 -47
- package/dist/src/template/ConversationTemplateModule.js.map +1 -0
- package/dist/src/template/createApp/CreateAppTemplate.d.ts +3 -0
- package/dist/src/template/createApp/CreateAppTemplate.d.ts.map +1 -0
- package/dist/src/template/createApp/CreateAppTemplate.js +44 -14
- package/dist/src/template/createApp/CreateAppTemplate.js.map +1 -0
- package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts +3 -0
- package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts.map +1 -0
- package/dist/src/template/createCode/CreateCodeConversationTemplate.js +56 -26
- package/dist/src/template/createCode/CreateCodeConversationTemplate.js.map +1 -0
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts +3 -0
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts.map +1 -0
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.js +63 -26
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.js.map +1 -0
- package/dist/test/createKeywordFilesIndex.test.d.ts +2 -0
- package/dist/test/createKeywordFilesIndex.test.d.ts.map +1 -0
- package/dist/test/createKeywordFilesIndex.test.js +37 -6
- package/dist/test/createKeywordFilesIndex.test.js.map +1 -0
- package/dist/test/openai/openai.generateList.test.d.ts +2 -0
- package/dist/test/openai/openai.generateList.test.d.ts.map +1 -0
- package/dist/test/openai/openai.generateList.test.js +43 -5
- package/dist/test/openai/openai.generateList.test.js.map +1 -0
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts +2 -0
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts.map +1 -0
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.js +11 -10
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.js.map +1 -0
- package/dist/test/repo/repo.test.d.ts +2 -0
- package/dist/test/repo/repo.test.d.ts.map +1 -0
- package/dist/test/repo/repo.test.js +33 -4
- package/dist/test/repo/repo.test.js.map +1 -0
- package/package.json +4 -3
- package/tsconfig.json +20 -106
- package/dist/jest.config.js +0 -10
- package/dist/src/template/createPackage/jest.config.js +0 -10
- package/dist/test/setup.js +0 -1
|
@@ -8,34 +8,69 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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]); }; }
|
|
15
|
+
function step(op) {
|
|
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 };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
11
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
39
|
exports.Code = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
var util_node_1 = require("@proteinjs/util-node");
|
|
41
|
+
var Code = /** @class */ (function () {
|
|
42
|
+
function Code(args) {
|
|
16
43
|
this.args = args;
|
|
17
44
|
}
|
|
18
|
-
generate() {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
45
|
+
Code.prototype.generate = function () {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
if (this.args.imports)
|
|
51
|
+
this.addImports(this.args.imports, this.args.conversation);
|
|
52
|
+
return [4 /*yield*/, this.args.conversation.generateCode(this.args.description, 'gpt-4')];
|
|
53
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
23
56
|
});
|
|
24
|
-
}
|
|
25
|
-
addImports(imports, conversation) {
|
|
57
|
+
};
|
|
58
|
+
Code.prototype.addImports = function (imports, conversation) {
|
|
26
59
|
conversation.addSystemMessagesToHistory([
|
|
27
|
-
this.declarationMessage(imports.map(d
|
|
60
|
+
this.declarationMessage(imports.map(function (d) { return d.sourceFilePath; })),
|
|
28
61
|
this.importMessage(imports),
|
|
29
62
|
]);
|
|
30
|
-
}
|
|
31
|
-
declarationMessage(tsFilePaths) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
importMessage(imports) {
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
63
|
+
};
|
|
64
|
+
Code.prototype.declarationMessage = function (tsFilePaths) {
|
|
65
|
+
var declarationMap = util_node_1.PackageUtil.generateTypescriptDeclarations({ tsFilePaths: tsFilePaths, includeDependencyDeclarations: true });
|
|
66
|
+
var declarations = Object.values(declarationMap).join('\n');
|
|
67
|
+
return "Assume the following code exists in other files:\n".concat(declarations);
|
|
68
|
+
};
|
|
69
|
+
Code.prototype.importMessage = function (imports) {
|
|
70
|
+
var importStatements = imports.map(function (i) { return "import { ".concat(i.moduleNames.join(', '), " } from '").concat(i.importPathFromGeneratedFile, "'"); });
|
|
71
|
+
return "Add the following imports:\n".concat(importStatements);
|
|
72
|
+
};
|
|
73
|
+
return Code;
|
|
74
|
+
}());
|
|
41
75
|
exports.Code = Code;
|
|
76
|
+
//# sourceMappingURL=Code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Code.js","sourceRoot":"","sources":["../../../src/code_template/Code.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAmD;AAqBnD;IAGE,cAAY,IAAc;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEK,uBAAQ,GAAd;;;;;wBACE,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO;4BACnB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;wBAEpD,qBAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,EAAA;4BAAhF,sBAAO,SAAyE,EAAC;;;;KACpF;IAEO,yBAAU,GAAlB,UAAmB,OAAiB,EAAE,YAA0B;QAC9D,YAAY,CAAC,0BAA0B,CAAC;YACtC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,cAAc,EAAhB,CAAgB,CAAC,CAAC;YAC3D,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC;IAEO,iCAAkB,GAA1B,UAA2B,WAAqB;QAC9C,IAAM,cAAc,GAAG,uBAAW,CAAC,8BAA8B,CAAC,EAAE,WAAW,aAAA,EAAE,6BAA6B,EAAE,IAAI,EAAE,CAAC,CAAC;QACxH,IAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,OAAO,4DAAqD,YAAY,CAAE,CAAC;IAC7E,CAAC;IAEO,4BAAa,GAArB,UAAsB,OAAmC;QACvD,IAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,mBAAY,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAY,CAAC,CAAC,2BAA2B,MAAG,EAAhF,CAAgF,CAAC,CAAC;QAC5H,OAAO,sCAA+B,gBAAgB,CAAE,CAAC;IAC3D,CAAC;IACH,WAAC;AAAD,CAAC,AA/BD,IA+BC;AA/BY,oBAAI"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Logger } from '@proteinjs/util';
|
|
2
|
+
import { Package } from '@proteinjs/util-node';
|
|
3
|
+
import { SourceFile } from './Code';
|
|
4
|
+
export type TemplateArgs = {
|
|
5
|
+
srcPath: string;
|
|
6
|
+
additionalPackages?: Package[];
|
|
7
|
+
replacePackages?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare abstract class CodeTemplate {
|
|
10
|
+
protected logger: Logger;
|
|
11
|
+
protected templateArgs: TemplateArgs;
|
|
12
|
+
constructor(templateArgs: TemplateArgs);
|
|
13
|
+
abstract dependencyPackages(): Package[];
|
|
14
|
+
abstract sourceFiles(): SourceFile[];
|
|
15
|
+
generate(): Promise<void>;
|
|
16
|
+
private resolvePackages;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=CodeTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeTemplate.d.ts","sourceRoot":"","sources":["../../../src/code_template/CodeTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAmB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAA;AAED,8BAAsB,YAAY;IAChC,SAAS,CAAC,MAAM,SAAqC;IACrD,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;gBAEzB,YAAY,EAAE,YAAY;IAItC,QAAQ,CAAC,kBAAkB,IAAI,OAAO,EAAE;IACxC,QAAQ,CAAC,WAAW,IAAI,UAAU,EAAE;IAE9B,QAAQ;IAWd,OAAO,CAAC,eAAe;CAMxB"}
|
|
@@ -8,32 +8,80 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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]); }; }
|
|
15
|
+
function step(op) {
|
|
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 };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
11
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
39
|
exports.CodeTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
var util_1 = require("@proteinjs/util");
|
|
41
|
+
var util_node_1 = require("@proteinjs/util-node");
|
|
42
|
+
var CodeTemplate = /** @class */ (function () {
|
|
43
|
+
function CodeTemplate(templateArgs) {
|
|
17
44
|
this.logger = new util_1.Logger(this.constructor.name);
|
|
18
45
|
this.templateArgs = templateArgs;
|
|
19
46
|
}
|
|
20
|
-
generate() {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
CodeTemplate.prototype.generate = function () {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var _i, _a, sourceFile, filePath, code;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
52
|
+
case 0: return [4 /*yield*/, util_node_1.PackageUtil.installPackages(this.resolvePackages())];
|
|
53
|
+
case 1:
|
|
54
|
+
_b.sent();
|
|
55
|
+
_i = 0, _a = this.sourceFiles();
|
|
56
|
+
_b.label = 2;
|
|
57
|
+
case 2:
|
|
58
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
59
|
+
sourceFile = _a[_i];
|
|
60
|
+
filePath = util_node_1.Fs.baseContainedJoin(this.templateArgs.srcPath, sourceFile.relativePath);
|
|
61
|
+
this.logger.info("Generating source file: ".concat(filePath));
|
|
62
|
+
return [4 /*yield*/, sourceFile.code.generate()];
|
|
63
|
+
case 3:
|
|
64
|
+
code = _b.sent();
|
|
65
|
+
return [4 /*yield*/, util_node_1.Fs.writeFiles([{ path: filePath, content: code }])];
|
|
66
|
+
case 4:
|
|
67
|
+
_b.sent();
|
|
68
|
+
this.logger.info("Generated source file: ".concat(filePath));
|
|
69
|
+
_b.label = 5;
|
|
70
|
+
case 5:
|
|
71
|
+
_i++;
|
|
72
|
+
return [3 /*break*/, 2];
|
|
73
|
+
case 6: return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
30
76
|
});
|
|
31
|
-
}
|
|
32
|
-
resolvePackages() {
|
|
33
|
-
|
|
77
|
+
};
|
|
78
|
+
CodeTemplate.prototype.resolvePackages = function () {
|
|
79
|
+
var packages = this.templateArgs.replacePackages ? [] : this.dependencyPackages();
|
|
34
80
|
if (this.templateArgs.additionalPackages)
|
|
35
|
-
packages.push(
|
|
81
|
+
packages.push.apply(packages, this.templateArgs.additionalPackages);
|
|
36
82
|
return packages;
|
|
37
|
-
}
|
|
38
|
-
|
|
83
|
+
};
|
|
84
|
+
return CodeTemplate;
|
|
85
|
+
}());
|
|
39
86
|
exports.CodeTemplate = CodeTemplate;
|
|
87
|
+
//# sourceMappingURL=CodeTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeTemplate.js","sourceRoot":"","sources":["../../../src/code_template/CodeTemplate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAyC;AACzC,kDAAgE;AAShE;IAIE,sBAAY,YAA0B;QAH5B,WAAM,GAAG,IAAI,aAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAInD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAKK,+BAAQ,GAAd;;;;;4BACE,qBAAM,uBAAW,CAAC,eAAe,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,EAAA;;wBAAzD,SAAyD,CAAC;8BACjB,EAAlB,KAAA,IAAI,CAAC,WAAW,EAAE;;;6BAAlB,CAAA,cAAkB,CAAA;wBAAhC,UAAU;wBACX,QAAQ,GAAG,cAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;wBAC1F,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAA2B,QAAQ,CAAE,CAAC,CAAC;wBAC3C,qBAAM,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAA;;wBAAvC,IAAI,GAAG,SAAgC;wBAC7C,qBAAM,cAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAA;;wBAAxD,SAAwD,CAAC;wBACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iCAA0B,QAAQ,CAAE,CAAC,CAAC;;;wBALlC,IAAkB,CAAA;;;;;;KAO1C;IAEO,sCAAe,GAAvB;QACE,IAAM,QAAQ,GAAc,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC/F,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB;YACtC,QAAQ,CAAC,IAAI,OAAb,QAAQ,EAAS,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE;QACzD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACH,mBAAC;AAAD,CAAC,AA5BD,IA4BC;AA5BqB,oCAAY"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConversationModule } from '../ConversationModule';
|
|
2
|
+
import { Function } from '../Function';
|
|
3
|
+
import { MessageModerator } from '../history/MessageModerator';
|
|
4
|
+
export declare class CodeTemplateModule implements ConversationModule {
|
|
5
|
+
private static CODE_RESPONSE;
|
|
6
|
+
getName(): string;
|
|
7
|
+
getSystemMessages(): string[];
|
|
8
|
+
getFunctions(): Function[];
|
|
9
|
+
getMessageModerators(): MessageModerator[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=CodeTemplateModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeTemplateModule.d.ts","sourceRoot":"","sources":["../../../src/code_template/CodeTemplateModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,qBAAa,kBAAmB,YAAW,kBAAkB;IAC3D,OAAO,CAAC,MAAM,CAAC,aAAa,CAA2B;IAEvD,OAAO,IAAI,MAAM;IAIjB,iBAAiB,IAAI,MAAM,EAAE;IAS7B,YAAY,IAAI,QAAQ,EAAE;IAG1B,oBAAoB,IAAI,gBAAgB,EAAE;CAG3C"}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CodeTemplateModule = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return 'Code Template';
|
|
4
|
+
var CodeTemplateModule = /** @class */ (function () {
|
|
5
|
+
function CodeTemplateModule() {
|
|
7
6
|
}
|
|
8
|
-
|
|
7
|
+
CodeTemplateModule.prototype.getName = function () {
|
|
8
|
+
return 'Code Template';
|
|
9
|
+
};
|
|
10
|
+
CodeTemplateModule.prototype.getSystemMessages = function () {
|
|
9
11
|
return [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
"If they want to create a function/class/object using an API we are familiar with, we will ask the user for the required information to fill in all mandatory parameters and ask them if they want to provide optional parameter values",
|
|
13
|
+
"Once we have gotten the values for all parameters, respond with '".concat(CodeTemplateModule.CODE_RESPONSE, "' followed by the code to instantiate/call the function/class/object with the user's responses for parameter values"),
|
|
14
|
+
"If you're generating a call to a class that extends Template, require that the user provide Template's constructor parameters as well and combine them into the parameters passed into the base class you're instantiating",
|
|
15
|
+
"Make sure you ask for a srcPath and pass that in to the Template base class constructor arg",
|
|
16
|
+
"Surround generated code (not including imports) with a self-executing, anonymous async function like this (async function() =>{})()",
|
|
15
17
|
];
|
|
16
|
-
}
|
|
17
|
-
getFunctions() {
|
|
18
|
+
};
|
|
19
|
+
CodeTemplateModule.prototype.getFunctions = function () {
|
|
18
20
|
return [];
|
|
19
|
-
}
|
|
20
|
-
getMessageModerators() {
|
|
21
|
+
};
|
|
22
|
+
CodeTemplateModule.prototype.getMessageModerators = function () {
|
|
21
23
|
return [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
+
};
|
|
25
|
+
CodeTemplateModule.CODE_RESPONSE = 'Code with user input:';
|
|
26
|
+
return CodeTemplateModule;
|
|
27
|
+
}());
|
|
24
28
|
exports.CodeTemplateModule = CodeTemplateModule;
|
|
25
|
-
CodeTemplateModule.CODE_RESPONSE = 'Code with user input:';
|
|
26
29
|
// if (response.includes(CodegenConversation.CODE_RESPONSE))
|
|
27
30
|
// await this.generateCode(response, conversation);
|
|
28
31
|
// private async generateCode(message: string, conversation: Conversation) {
|
|
@@ -44,3 +47,4 @@ CodeTemplateModule.CODE_RESPONSE = 'Code with user input:';
|
|
|
44
47
|
// console.info(`Ran command: ${commandLog}`);
|
|
45
48
|
// console.info(`Generated code from template: ${codePath}`);
|
|
46
49
|
// }
|
|
50
|
+
//# sourceMappingURL=CodeTemplateModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeTemplateModule.js","sourceRoot":"","sources":["../../../src/code_template/CodeTemplateModule.ts"],"names":[],"mappings":";;;AAIA;IAAA;IAsBA,CAAC;IAnBC,oCAAO,GAAP;QACE,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,8CAAiB,GAAjB;QACE,OAAO;YACL,wOAAwO;YACxO,2EAAoE,kBAAkB,CAAC,aAAa,wHAAqH;YACzN,4NAA4N;YAC5N,6FAA6F;YAC7F,qIAAqI;SACtI,CAAC;IACJ,CAAC;IACD,yCAAY,GAAZ;QACE,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,iDAAoB,GAApB;QACE,OAAO,EAAE,CAAC;IACZ,CAAC;IApBc,gCAAa,GAAG,uBAAuB,CAAC;IAqBzD,yBAAC;CAAA,AAtBD,IAsBC;AAtBY,gDAAkB;AAwB/B,4DAA4D;AAC5D,2DAA2D;AAE3D,4EAA4E;AAC5E,wDAAwD;AACxD,kCAAkC;AAClC,8KAA8K;AAC9K,yFAAyF;AACzF,kBAAkB;AAClB,8EAA8E;AAC9E,uEAAuE;AACvE,mCAAmC;AACnC,wCAAwC;AACxC,4CAA4C;AAC5C,4BAA4B;AAC5B,6BAA6B;AAC7B,uDAAuD;AACvD,oDAAoD;AACpD,uGAAuG;AACvG,gDAAgD;AAChD,+DAA+D;AAC/D,IAAI"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FileDescriptor } from '@proteinjs/util-node';
|
|
2
|
+
export interface TsFile extends FileDescriptor {
|
|
3
|
+
declaration: string;
|
|
4
|
+
}
|
|
5
|
+
export interface PackageInfo {
|
|
6
|
+
packageJSON: any;
|
|
7
|
+
dirPath: string;
|
|
8
|
+
tsFiles: {
|
|
9
|
+
[tsFilePath: string]: TsFile;
|
|
10
|
+
};
|
|
11
|
+
fileDescriptors: FileDescriptor[];
|
|
12
|
+
}
|
|
13
|
+
export type SlimPackageInfo = Omit<PackageInfo, 'packageJSON' | 'tsFiles'>;
|
|
14
|
+
export type RepoParams = {
|
|
15
|
+
packages: Record<string, PackageInfo>;
|
|
16
|
+
slimPackages: Record<string, SlimPackageInfo>;
|
|
17
|
+
tsFiles: {
|
|
18
|
+
[tsFilePath: string]: TsFile;
|
|
19
|
+
};
|
|
20
|
+
keywordFilesIndex: {
|
|
21
|
+
[keyword: string]: string[]; /** file paths */
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare class Repo {
|
|
25
|
+
private logger;
|
|
26
|
+
params: RepoParams;
|
|
27
|
+
constructor(params: RepoParams);
|
|
28
|
+
packages(): Record<string, PackageInfo>;
|
|
29
|
+
slimPackages(): Record<string, SlimPackageInfo>;
|
|
30
|
+
tsFiles(): {
|
|
31
|
+
[tsFilePath: string]: TsFile;
|
|
32
|
+
};
|
|
33
|
+
keywordFilesIndex(): {
|
|
34
|
+
[keyword: string]: string[];
|
|
35
|
+
};
|
|
36
|
+
searchFiles(params: {
|
|
37
|
+
keyword: string;
|
|
38
|
+
}): string[];
|
|
39
|
+
getDeclarations(params: {
|
|
40
|
+
tsFilePaths: string[];
|
|
41
|
+
}): {
|
|
42
|
+
[tsFilePath: string]: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare class RepoFactory {
|
|
46
|
+
private static LOGGER;
|
|
47
|
+
static createRepo(dir: string): Promise<Repo>;
|
|
48
|
+
private static loadFiles;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=Repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repo.d.ts","sourceRoot":"","sources":["../../../src/code_template/Repo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAmB,MAAM,sBAAsB,CAAC;AAIvE,MAAM,WAAW,MAAO,SAAQ,cAAc;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,GAAG,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC1C,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,aAAa,GAAC,SAAS,CAAC,CAAC;AAEzE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC9C,OAAO,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC1C,iBAAiB,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA,CAAC,iBAAiB;KAAE,CAAC;CACtE,CAAA;AAED,qBAAa,IAAI;IACf,OAAO,CAAC,MAAM,CAAqC;IACnD,MAAM,EAAE,UAAU,CAAC;gBAEP,MAAM,EAAE,UAAU;IAI9B,QAAQ;IAIR,YAAY;IAIZ,OAAO;;;IAIP,iBAAiB;;;IAIjB,WAAW,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAMvC,eAAe,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE;;;CAQlD;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,MAAM,CAA6B;WAE9B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;mBA2CrC,SAAS;CA4C/B"}
|