@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.
Files changed (134) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/index.d.ts +12 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/src/CodegenConversation.d.ts +13 -0
  7. package/dist/src/CodegenConversation.d.ts.map +1 -0
  8. package/dist/src/CodegenConversation.js +128 -57
  9. package/dist/src/CodegenConversation.js.map +1 -0
  10. package/dist/src/Conversation.d.ts +60 -0
  11. package/dist/src/Conversation.d.ts.map +1 -0
  12. package/dist/src/Conversation.js +202 -102
  13. package/dist/src/Conversation.js.map +1 -0
  14. package/dist/src/ConversationModule.d.ts +12 -0
  15. package/dist/src/ConversationModule.d.ts.map +1 -0
  16. package/dist/src/ConversationModule.js +1 -0
  17. package/dist/src/ConversationModule.js.map +1 -0
  18. package/dist/src/Function.d.ts +7 -0
  19. package/dist/src/Function.d.ts.map +1 -0
  20. package/dist/src/Function.js +1 -0
  21. package/dist/src/Function.js.map +1 -0
  22. package/dist/src/OpenAi.d.ts +18 -0
  23. package/dist/src/OpenAi.d.ts.map +1 -0
  24. package/dist/src/OpenAi.js +265 -169
  25. package/dist/src/OpenAi.js.map +1 -0
  26. package/dist/src/Paragraph.d.ts +7 -0
  27. package/dist/src/Paragraph.d.ts.map +1 -0
  28. package/dist/src/Paragraph.js +9 -7
  29. package/dist/src/Paragraph.js.map +1 -0
  30. package/dist/src/Sentence.d.ts +6 -0
  31. package/dist/src/Sentence.d.ts.map +1 -0
  32. package/dist/src/Sentence.js +10 -8
  33. package/dist/src/Sentence.js.map +1 -0
  34. package/dist/src/code_template/Code.d.ts +24 -0
  35. package/dist/src/code_template/Code.d.ts.map +1 -0
  36. package/dist/src/code_template/Code.js +57 -22
  37. package/dist/src/code_template/Code.js.map +1 -0
  38. package/dist/src/code_template/CodeTemplate.d.ts +18 -0
  39. package/dist/src/code_template/CodeTemplate.d.ts.map +1 -0
  40. package/dist/src/code_template/CodeTemplate.js +68 -20
  41. package/dist/src/code_template/CodeTemplate.js.map +1 -0
  42. package/dist/src/code_template/CodeTemplateModule.d.ts +11 -0
  43. package/dist/src/code_template/CodeTemplateModule.d.ts.map +1 -0
  44. package/dist/src/code_template/CodeTemplateModule.js +20 -16
  45. package/dist/src/code_template/CodeTemplateModule.js.map +1 -0
  46. package/dist/src/code_template/Repo.d.ts +50 -0
  47. package/dist/src/code_template/Repo.d.ts.map +1 -0
  48. package/dist/src/code_template/Repo.js +161 -80
  49. package/dist/src/code_template/Repo.js.map +1 -0
  50. package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts +24 -0
  51. package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts.map +1 -0
  52. package/dist/src/fs/conversation_fs/ConversationFsModerator.js +45 -36
  53. package/dist/src/fs/conversation_fs/ConversationFsModerator.js.map +1 -0
  54. package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts +18 -0
  55. package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts.map +1 -0
  56. package/dist/src/fs/conversation_fs/ConversationFsModule.js +84 -41
  57. package/dist/src/fs/conversation_fs/ConversationFsModule.js.map +1 -0
  58. package/dist/src/fs/conversation_fs/FsFunctions.d.ts +82 -0
  59. package/dist/src/fs/conversation_fs/FsFunctions.d.ts.map +1 -0
  60. package/dist/src/fs/conversation_fs/FsFunctions.js +105 -30
  61. package/dist/src/fs/conversation_fs/FsFunctions.js.map +1 -0
  62. package/dist/src/fs/git/GitModule.d.ts +14 -0
  63. package/dist/src/fs/git/GitModule.d.ts.map +1 -0
  64. package/dist/src/fs/git/GitModule.js +65 -24
  65. package/dist/src/fs/git/GitModule.js.map +1 -0
  66. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts +23 -0
  67. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts.map +1 -0
  68. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js +35 -5
  69. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js.map +1 -0
  70. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts +34 -0
  71. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts.map +1 -0
  72. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js +107 -50
  73. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js.map +1 -0
  74. package/dist/src/fs/package/PackageFunctions.d.ts +79 -0
  75. package/dist/src/fs/package/PackageFunctions.d.ts.map +1 -0
  76. package/dist/src/fs/package/PackageFunctions.js +78 -16
  77. package/dist/src/fs/package/PackageFunctions.js.map +1 -0
  78. package/dist/src/fs/package/PackageModule.d.ts +34 -0
  79. package/dist/src/fs/package/PackageModule.d.ts.map +1 -0
  80. package/dist/src/fs/package/PackageModule.js +135 -62
  81. package/dist/src/fs/package/PackageModule.js.map +1 -0
  82. package/dist/src/history/MessageHistory.d.ts +17 -0
  83. package/dist/src/history/MessageHistory.d.ts.map +1 -0
  84. package/dist/src/history/MessageHistory.js +25 -22
  85. package/dist/src/history/MessageHistory.js.map +1 -0
  86. package/dist/src/history/MessageModerator.d.ts +5 -0
  87. package/dist/src/history/MessageModerator.d.ts.map +1 -0
  88. package/dist/src/history/MessageModerator.js +1 -0
  89. package/dist/src/history/MessageModerator.js.map +1 -0
  90. package/dist/src/template/ConversationTemplate.d.ts +12 -0
  91. package/dist/src/template/ConversationTemplate.d.ts.map +1 -0
  92. package/dist/src/template/ConversationTemplate.js +1 -0
  93. package/dist/src/template/ConversationTemplate.js.map +1 -0
  94. package/dist/src/template/ConversationTemplateFunctions.d.ts +44 -0
  95. package/dist/src/template/ConversationTemplateFunctions.d.ts.map +1 -0
  96. package/dist/src/template/ConversationTemplateFunctions.js +39 -4
  97. package/dist/src/template/ConversationTemplateFunctions.js.map +1 -0
  98. package/dist/src/template/ConversationTemplateModule.d.ts +65 -0
  99. package/dist/src/template/ConversationTemplateModule.d.ts.map +1 -0
  100. package/dist/src/template/ConversationTemplateModule.js +92 -47
  101. package/dist/src/template/ConversationTemplateModule.js.map +1 -0
  102. package/dist/src/template/createApp/CreateAppTemplate.d.ts +3 -0
  103. package/dist/src/template/createApp/CreateAppTemplate.d.ts.map +1 -0
  104. package/dist/src/template/createApp/CreateAppTemplate.js +44 -14
  105. package/dist/src/template/createApp/CreateAppTemplate.js.map +1 -0
  106. package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts +3 -0
  107. package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts.map +1 -0
  108. package/dist/src/template/createCode/CreateCodeConversationTemplate.js +56 -26
  109. package/dist/src/template/createCode/CreateCodeConversationTemplate.js.map +1 -0
  110. package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts +3 -0
  111. package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts.map +1 -0
  112. package/dist/src/template/createPackage/CreatePackageConversationTemplate.js +63 -26
  113. package/dist/src/template/createPackage/CreatePackageConversationTemplate.js.map +1 -0
  114. package/dist/test/createKeywordFilesIndex.test.d.ts +2 -0
  115. package/dist/test/createKeywordFilesIndex.test.d.ts.map +1 -0
  116. package/dist/test/createKeywordFilesIndex.test.js +37 -6
  117. package/dist/test/createKeywordFilesIndex.test.js.map +1 -0
  118. package/dist/test/openai/openai.generateList.test.d.ts +2 -0
  119. package/dist/test/openai/openai.generateList.test.d.ts.map +1 -0
  120. package/dist/test/openai/openai.generateList.test.js +43 -5
  121. package/dist/test/openai/openai.generateList.test.js.map +1 -0
  122. package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts +2 -0
  123. package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts.map +1 -0
  124. package/dist/test/openai/openai.parseCodeFromMarkdown.test.js +11 -10
  125. package/dist/test/openai/openai.parseCodeFromMarkdown.test.js.map +1 -0
  126. package/dist/test/repo/repo.test.d.ts +2 -0
  127. package/dist/test/repo/repo.test.d.ts.map +1 -0
  128. package/dist/test/repo/repo.test.js +33 -4
  129. package/dist/test/repo/repo.test.js.map +1 -0
  130. package/package.json +4 -3
  131. package/tsconfig.json +20 -106
  132. package/dist/jest.config.js +0 -10
  133. package/dist/src/template/createPackage/jest.config.js +0 -10
  134. 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
- const util_node_1 = require("@proteinjs/util-node");
14
- class Code {
15
- constructor(args) {
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
- if (this.args.imports)
21
- this.addImports(this.args.imports, this.args.conversation);
22
- return yield this.args.conversation.generateCode(this.args.description, 'gpt-4');
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 => d.sourceFilePath)),
60
+ this.declarationMessage(imports.map(function (d) { return d.sourceFilePath; })),
28
61
  this.importMessage(imports),
29
62
  ]);
30
- }
31
- declarationMessage(tsFilePaths) {
32
- const declarationMap = util_node_1.PackageUtil.generateTypescriptDeclarations({ tsFilePaths, includeDependencyDeclarations: true });
33
- const declarations = Object.values(declarationMap).join('\n');
34
- return `Assume the following code exists in other files:\n${declarations}`;
35
- }
36
- importMessage(imports) {
37
- const importStatements = imports.map(i => `import { ${i.moduleNames.join(', ')} } from '${i.importPathFromGeneratedFile}'`);
38
- return `Add the following imports:\n${importStatements}`;
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
- const util_1 = require("@proteinjs/util");
14
- const util_node_1 = require("@proteinjs/util-node");
15
- class CodeTemplate {
16
- constructor(templateArgs) {
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
- yield util_node_1.PackageUtil.installPackages(this.resolvePackages());
23
- for (let sourceFile of this.sourceFiles()) {
24
- const filePath = util_node_1.Fs.baseContainedJoin(this.templateArgs.srcPath, sourceFile.relativePath);
25
- this.logger.info(`Generating source file: ${filePath}`);
26
- const code = yield sourceFile.code.generate();
27
- yield util_node_1.Fs.writeFiles([{ path: filePath, content: code }]);
28
- this.logger.info(`Generated source file: ${filePath}`);
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
- const packages = this.templateArgs.replacePackages ? [] : this.dependencyPackages();
77
+ };
78
+ CodeTemplate.prototype.resolvePackages = function () {
79
+ var packages = this.templateArgs.replacePackages ? [] : this.dependencyPackages();
34
80
  if (this.templateArgs.additionalPackages)
35
- packages.push(...this.templateArgs.additionalPackages);
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
- class CodeTemplateModule {
5
- getName() {
6
- return 'Code Template';
4
+ var CodeTemplateModule = /** @class */ (function () {
5
+ function CodeTemplateModule() {
7
6
  }
8
- getSystemMessages() {
7
+ CodeTemplateModule.prototype.getName = function () {
8
+ return 'Code Template';
9
+ };
10
+ CodeTemplateModule.prototype.getSystemMessages = function () {
9
11
  return [
10
- `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`,
11
- `Once we have gotten the values for all parameters, respond with '${CodeTemplateModule.CODE_RESPONSE}' followed by the code to instantiate/call the function/class/object with the user's responses for parameter values`,
12
- `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`,
13
- `Make sure you ask for a srcPath and pass that in to the Template base class constructor arg`,
14
- `Surround generated code (not including imports) with a self-executing, anonymous async function like this (async function() =>{})()`,
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"}