@proteinjs/conversation 1.0.7 → 1.0.9

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 (70) hide show
  1. package/.eslintrc.js +1 -1
  2. package/.prettierignore +4 -0
  3. package/CHANGELOG.md +11 -0
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +28 -40
  6. package/dist/src/CodegenConversation.d.ts +11 -11
  7. package/dist/src/CodegenConversation.js +180 -294
  8. package/dist/src/Conversation.d.ts +49 -52
  9. package/dist/src/Conversation.js +288 -478
  10. package/dist/src/ConversationModule.d.ts +6 -6
  11. package/dist/src/ConversationModule.js +3 -3
  12. package/dist/src/Function.d.ts +4 -4
  13. package/dist/src/Function.js +3 -3
  14. package/dist/src/OpenAi.d.ts +10 -42
  15. package/dist/src/OpenAi.js +305 -495
  16. package/dist/src/Paragraph.d.ts +4 -4
  17. package/dist/src/Paragraph.js +17 -17
  18. package/dist/src/Sentence.d.ts +4 -4
  19. package/dist/src/Sentence.js +21 -21
  20. package/dist/src/code_template/Code.d.ts +15 -15
  21. package/dist/src/code_template/Code.js +73 -167
  22. package/dist/src/code_template/CodeTemplate.d.ts +11 -11
  23. package/dist/src/code_template/CodeTemplate.js +80 -169
  24. package/dist/src/code_template/CodeTemplateModule.d.ts +6 -6
  25. package/dist/src/code_template/CodeTemplateModule.js +26 -28
  26. package/dist/src/code_template/Repo.d.ts +38 -34
  27. package/dist/src/code_template/Repo.js +195 -291
  28. package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts +12 -12
  29. package/dist/src/fs/conversation_fs/ConversationFsModerator.js +108 -110
  30. package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts +11 -11
  31. package/dist/src/fs/conversation_fs/ConversationFsModule.js +97 -204
  32. package/dist/src/fs/conversation_fs/FsFunctions.d.ts +62 -58
  33. package/dist/src/fs/conversation_fs/FsFunctions.js +252 -414
  34. package/dist/src/fs/git/GitModule.d.ts +8 -8
  35. package/dist/src/fs/git/GitModule.js +74 -163
  36. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts +18 -16
  37. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js +58 -158
  38. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts +26 -27
  39. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js +131 -234
  40. package/dist/src/fs/package/PackageFunctions.d.ts +60 -54
  41. package/dist/src/fs/package/PackageFunctions.js +213 -366
  42. package/dist/src/fs/package/PackageModule.d.ts +24 -24
  43. package/dist/src/fs/package/PackageModule.js +170 -292
  44. package/dist/src/history/MessageHistory.d.ts +12 -12
  45. package/dist/src/history/MessageHistory.js +46 -52
  46. package/dist/src/history/MessageModerator.d.ts +2 -2
  47. package/dist/src/history/MessageModerator.js +3 -3
  48. package/dist/src/template/ConversationTemplate.d.ts +8 -8
  49. package/dist/src/template/ConversationTemplate.js +3 -3
  50. package/dist/src/template/ConversationTemplateFunctions.d.ts +35 -33
  51. package/dist/src/template/ConversationTemplateFunctions.js +75 -176
  52. package/dist/src/template/ConversationTemplateModule.d.ts +48 -51
  53. package/dist/src/template/ConversationTemplateModule.js +116 -211
  54. package/dist/src/template/createApp/CreateAppTemplate.d.ts +1 -1
  55. package/dist/src/template/createApp/CreateAppTemplate.js +59 -151
  56. package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts +1 -1
  57. package/dist/src/template/createCode/CreateCodeConversationTemplate.js +67 -183
  58. package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts +1 -1
  59. package/dist/src/template/createPackage/CreatePackageConversationTemplate.js +77 -174
  60. package/dist/src/template/createPackage/tsconfig.json +11 -11
  61. package/dist/test/createKeywordFilesIndex.test.d.ts +1 -1
  62. package/dist/test/createKeywordFilesIndex.test.js +41 -132
  63. package/dist/test/openai/openai.generateList.test.d.ts +1 -1
  64. package/dist/test/openai/openai.generateList.test.js +47 -136
  65. package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts +1 -1
  66. package/dist/test/openai/openai.parseCodeFromMarkdown.test.js +12 -13
  67. package/dist/test/repo/repo.test.d.ts +1 -1
  68. package/dist/test/repo/repo.test.js +38 -127
  69. package/package.json +5 -6
  70. package/LICENSE +0 -21
@@ -1,121 +1,119 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConversationFsModerator = exports.ConversationFsFactory = void 0;
4
4
  /* eslint-disable no-empty */
5
- var util_1 = require('@proteinjs/util');
5
+ var util_1 = require("@proteinjs/util");
6
6
  var ConversationFsFactory = /** @class */ (function () {
7
- function ConversationFsFactory(params) {
8
- this.params = Object.assign({ maxFiles: 3, logLevel: 'info' }, params);
9
- this.logger = new util_1.Logger(this.constructor.name, this.params.logLevel);
10
- }
11
- ConversationFsFactory.prototype.merge = function (existingFs, updates) {
12
- var _loop_1 = function (filePath) {
13
- // if the file already exists in the fs
14
- if (existingFs.fileContentMap[filePath]) {
15
- this_1.logger.debug('Updating existing file: '.concat(filePath));
16
- existingFs.fileContentMap[filePath] = updates[filePath];
17
- var oldIndex = existingFs.order.findIndex(function (item) {
18
- return item == filePath;
19
- });
20
- existingFs.order.splice(oldIndex, 1);
21
- existingFs.order.push(filePath);
22
- return 'continue';
23
- }
24
- // if we have less than the max number of files in the fs
25
- if (Object.keys(existingFs.fileContentMap).length < this_1.params.maxFiles) {
26
- this_1.logger.debug('Adding new file (under limit): '.concat(filePath));
27
- existingFs.fileContentMap[filePath] = updates[filePath];
28
- existingFs.order.push(filePath);
29
- return 'continue';
30
- } else {
31
- this_1.logger.debug('Adding new file (over limit): '.concat(filePath));
32
- var removedFilePath = existingFs.order.splice(0, 1)[0];
33
- delete existingFs.fileContentMap[removedFilePath];
34
- existingFs.fileContentMap[filePath] = updates[filePath];
35
- existingFs.order.push(filePath);
36
- }
37
- };
38
- var this_1 = this;
39
- for (var _i = 0, _a = Object.keys(updates); _i < _a.length; _i++) {
40
- var filePath = _a[_i];
41
- _loop_1(filePath);
7
+ function ConversationFsFactory(params) {
8
+ this.params = Object.assign({ maxFiles: 3, logLevel: 'info' }, params);
9
+ this.logger = new util_1.Logger(this.constructor.name, this.params.logLevel);
42
10
  }
43
- return existingFs;
44
- };
45
- return ConversationFsFactory;
46
- })();
11
+ ConversationFsFactory.prototype.merge = function (existingFs, updates) {
12
+ var _loop_1 = function (filePath) {
13
+ // if the file already exists in the fs
14
+ if (existingFs.fileContentMap[filePath]) {
15
+ this_1.logger.debug("Updating existing file: ".concat(filePath));
16
+ existingFs.fileContentMap[filePath] = updates[filePath];
17
+ var oldIndex = existingFs.order.findIndex(function (item) { return item == filePath; });
18
+ existingFs.order.splice(oldIndex, 1);
19
+ existingFs.order.push(filePath);
20
+ return "continue";
21
+ }
22
+ // if we have less than the max number of files in the fs
23
+ if (Object.keys(existingFs.fileContentMap).length < this_1.params.maxFiles) {
24
+ this_1.logger.debug("Adding new file (under limit): ".concat(filePath));
25
+ existingFs.fileContentMap[filePath] = updates[filePath];
26
+ existingFs.order.push(filePath);
27
+ return "continue";
28
+ }
29
+ else {
30
+ this_1.logger.debug("Adding new file (over limit): ".concat(filePath));
31
+ var removedFilePath = existingFs.order.splice(0, 1)[0];
32
+ delete existingFs.fileContentMap[removedFilePath];
33
+ existingFs.fileContentMap[filePath] = updates[filePath];
34
+ existingFs.order.push(filePath);
35
+ }
36
+ };
37
+ var this_1 = this;
38
+ for (var _i = 0, _a = Object.keys(updates); _i < _a.length; _i++) {
39
+ var filePath = _a[_i];
40
+ _loop_1(filePath);
41
+ }
42
+ return existingFs;
43
+ };
44
+ return ConversationFsFactory;
45
+ }());
47
46
  exports.ConversationFsFactory = ConversationFsFactory;
48
47
  var ConversationFsModerator = /** @class */ (function () {
49
- function ConversationFsModerator(logLevel) {
50
- this.logLevel = 'info';
51
- if (logLevel) {
52
- this.logLevel = logLevel;
48
+ function ConversationFsModerator(logLevel) {
49
+ this.logLevel = 'info';
50
+ if (logLevel) {
51
+ this.logLevel = logLevel;
52
+ }
53
53
  }
54
- }
55
- ConversationFsModerator.prototype.observe = function (messages) {
56
- var conversationFileSystemMessageIndex = -1;
57
- var conversationFileSystem;
58
- var readFilesFunctionCallMessageIndexes = [];
59
- var writeFilesFunctionCallMessageIndexes = [];
60
- var readFilesConsolidatedOutput = {}; // newest version of file wins
61
- for (var i = 0; i < messages.length; i++) {
62
- var message = messages[i];
63
- if (message.role == 'system' && message.content) {
64
- var parsedContent = void 0;
65
- try {
66
- parsedContent = JSON.parse(message.content);
67
- } catch (error) {}
68
- if (!parsedContent || !parsedContent['fileSystem']) {
69
- continue;
54
+ ConversationFsModerator.prototype.observe = function (messages) {
55
+ var conversationFileSystemMessageIndex = -1;
56
+ var conversationFileSystem;
57
+ var readFilesFunctionCallMessageIndexes = [];
58
+ var writeFilesFunctionCallMessageIndexes = [];
59
+ var readFilesConsolidatedOutput = {}; // newest version of file wins
60
+ for (var i = 0; i < messages.length; i++) {
61
+ var message = messages[i];
62
+ if (message.role == 'system' && message.content) {
63
+ var parsedContent = void 0;
64
+ try {
65
+ parsedContent = JSON.parse(message.content);
66
+ }
67
+ catch (error) { }
68
+ if (!parsedContent || !parsedContent['fileSystem']) {
69
+ continue;
70
+ }
71
+ conversationFileSystem = parsedContent['fileSystem'];
72
+ conversationFileSystemMessageIndex = i;
73
+ continue;
74
+ }
75
+ if (message.role == 'function' && message.name == 'readFiles' && message.content) {
76
+ var parsedContent = void 0;
77
+ try {
78
+ parsedContent = JSON.parse(message.content);
79
+ }
80
+ catch (error) { }
81
+ if (!parsedContent) {
82
+ continue;
83
+ }
84
+ for (var _i = 0, _a = Object.keys(parsedContent); _i < _a.length; _i++) {
85
+ var filePath = _a[_i];
86
+ readFilesConsolidatedOutput[filePath] = parsedContent[filePath];
87
+ }
88
+ readFilesFunctionCallMessageIndexes.push(i);
89
+ }
90
+ if (message.role == 'function' && message.name == 'writeFiles') {
91
+ writeFilesFunctionCallMessageIndexes.push(i);
92
+ }
70
93
  }
71
- conversationFileSystem = parsedContent['fileSystem'];
72
- conversationFileSystemMessageIndex = i;
73
- continue;
74
- }
75
- if (message.role == 'function' && message.name == 'readFiles' && message.content) {
76
- var parsedContent = void 0;
77
- try {
78
- parsedContent = JSON.parse(message.content);
79
- } catch (error) {}
80
- if (!parsedContent) {
81
- continue;
94
+ if (conversationFileSystem) {
95
+ conversationFileSystem = new ConversationFsFactory({ logLevel: this.logLevel }).merge(conversationFileSystem, readFilesConsolidatedOutput);
96
+ var content = JSON.stringify({ fileSystem: conversationFileSystem });
97
+ messages[conversationFileSystemMessageIndex].content = content;
82
98
  }
83
- for (var _i = 0, _a = Object.keys(parsedContent); _i < _a.length; _i++) {
84
- var filePath = _a[_i];
85
- readFilesConsolidatedOutput[filePath] = parsedContent[filePath];
99
+ else {
100
+ conversationFileSystem = {
101
+ fileContentMap: readFilesConsolidatedOutput,
102
+ order: Object.keys(readFilesConsolidatedOutput),
103
+ };
104
+ messages.push({
105
+ role: 'system',
106
+ content: "Whenever you make a call to readFiles, the file content will be loaded into the { fileSystem } object in the message history. Do not respond with fileSystem's content in a message.",
107
+ });
108
+ var content = JSON.stringify({ fileSystem: conversationFileSystem });
109
+ messages.push({ role: 'system', content: content });
86
110
  }
87
- readFilesFunctionCallMessageIndexes.push(i);
88
- }
89
- if (message.role == 'function' && message.name == 'writeFiles') {
90
- writeFilesFunctionCallMessageIndexes.push(i);
91
- }
92
- }
93
- if (conversationFileSystem) {
94
- conversationFileSystem = new ConversationFsFactory({ logLevel: this.logLevel }).merge(
95
- conversationFileSystem,
96
- readFilesConsolidatedOutput
97
- );
98
- var content = JSON.stringify({ fileSystem: conversationFileSystem });
99
- messages[conversationFileSystemMessageIndex].content = content;
100
- } else {
101
- conversationFileSystem = {
102
- fileContentMap: readFilesConsolidatedOutput,
103
- order: Object.keys(readFilesConsolidatedOutput),
104
- };
105
- messages.push({
106
- role: 'system',
107
- content:
108
- "Whenever you make a call to readFiles, the file content will be loaded into the { fileSystem } object in the message history. Do not respond with fileSystem's content in a message.",
109
- });
110
- var content = JSON.stringify({ fileSystem: conversationFileSystem });
111
- messages.push({ role: 'system', content: content });
112
- }
113
- var moderatedMessages = messages.filter(function (message, i) {
114
- return !readFilesFunctionCallMessageIndexes.includes(i) && !writeFilesFunctionCallMessageIndexes.includes(i);
115
- });
116
- return moderatedMessages;
117
- };
118
- return ConversationFsModerator;
119
- })();
111
+ var moderatedMessages = messages.filter(function (message, i) {
112
+ return !readFilesFunctionCallMessageIndexes.includes(i) && !writeFilesFunctionCallMessageIndexes.includes(i);
113
+ });
114
+ return moderatedMessages;
115
+ };
116
+ return ConversationFsModerator;
117
+ }());
120
118
  exports.ConversationFsModerator = ConversationFsModerator;
121
- //# sourceMappingURL=ConversationFsModerator.js.map
119
+ //# sourceMappingURL=ConversationFsModerator.js.map
@@ -2,17 +2,17 @@ import { ConversationModule, ConversationModuleFactory } from '../../Conversatio
2
2
  import { Function } from '../../Function';
3
3
  import { ConversationFsModerator } from './ConversationFsModerator';
4
4
  export declare class ConversationFsModule implements ConversationModule {
5
- private repoPath;
6
- private recentlyAccessedFilePaths;
7
- constructor(repoPath: string);
8
- getName(): string;
9
- getSystemMessages(): string[];
10
- getFunctions(): Function[];
11
- getMessageModerators(): ConversationFsModerator[];
12
- pushRecentlyAccessedFilePath(filePaths: string[]): void;
13
- getRecentlyAccessedFilePaths(): string[];
5
+ private repoPath;
6
+ private recentlyAccessedFilePaths;
7
+ constructor(repoPath: string);
8
+ getName(): string;
9
+ getSystemMessages(): string[];
10
+ getFunctions(): Function[];
11
+ getMessageModerators(): ConversationFsModerator[];
12
+ pushRecentlyAccessedFilePath(filePaths: string[]): void;
13
+ getRecentlyAccessedFilePaths(): string[];
14
14
  }
15
15
  export declare class ConversationFsModuleFactory implements ConversationModuleFactory {
16
- createModule(repoPath: string): Promise<ConversationFsModule>;
16
+ createModule(repoPath: string): Promise<ConversationFsModule>;
17
17
  }
18
- //# sourceMappingURL=ConversationFsModule.d.ts.map
18
+ //# sourceMappingURL=ConversationFsModule.d.ts.map
@@ -1,216 +1,109 @@
1
- 'use strict';
2
- var __awaiter =
3
- (this && this.__awaiter) ||
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
- function fulfilled(value) {
14
- try {
15
- step(generator.next(value));
16
- } catch (e) {
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
- (this && this.__generator) ||
35
- function (thisArg, body) {
36
- var _ = {
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
- if (f) throw new TypeError('Generator is already executing.');
64
- while ((g && ((g = 0), op[0] && (_ = 0)), _))
65
- try {
66
- if (
67
- ((f = 1),
68
- y &&
69
- (t = op[0] & 2 ? y['return'] : op[0] ? y['throw'] || ((t = y['return']) && t.call(y), 0) : y.next) &&
70
- !(t = t.call(y, op[1])).done)
71
- )
72
- return t;
73
- if (((y = 0), t)) op = [op[0] & 2, t.value];
74
- switch (op[0]) {
75
- case 0:
76
- case 1:
77
- t = op;
78
- break;
79
- case 4:
80
- _.label++;
81
- return { value: op[1], done: false };
82
- case 5:
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
- (this && this.__spreadArray) ||
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
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
132
- ar[i] = from[i];
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
- Object.defineProperty(exports, '__esModule', { value: true });
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
138
48
  exports.ConversationFsModuleFactory = exports.ConversationFsModule = void 0;
139
- var KeywordToFilesIndexFunctions_1 = require('../keyword_to_files_index/KeywordToFilesIndexFunctions');
140
- var PackageFunctions_1 = require('../package/PackageFunctions');
141
- var ConversationFsModerator_1 = require('./ConversationFsModerator');
142
- var FsFunctions_1 = require('./FsFunctions');
49
+ var KeywordToFilesIndexFunctions_1 = require("../keyword_to_files_index/KeywordToFilesIndexFunctions");
50
+ var PackageFunctions_1 = require("../package/PackageFunctions");
51
+ var ConversationFsModerator_1 = require("./ConversationFsModerator");
52
+ var FsFunctions_1 = require("./FsFunctions");
143
53
  var ConversationFsModule = /** @class */ (function () {
144
- function ConversationFsModule(repoPath) {
145
- this.recentlyAccessedFilePaths = [];
146
- this.repoPath = repoPath;
147
- }
148
- ConversationFsModule.prototype.getName = function () {
149
- return 'Conversation Fs';
150
- };
151
- ConversationFsModule.prototype.getSystemMessages = function () {
152
- return [
153
- 'Assume the current working directory is: '.concat(this.repoPath, ' unless specified by the user'),
154
- 'Pre-pend the current working directory as the base path to file paths when performing file operations, unless specified otherwise by the user',
155
- "If the user asks to change the cwd, do not create a new folder, just fail if it's not a valid path",
156
- 'If the user wants to work in a package, use the '.concat(
157
- PackageFunctions_1.searchPackagesFunctionName,
158
- ' function and take the directory from the package.json file path and make that the cwd'
159
- ),
160
- 'You have access to code in a local repo, you can read and write code to and from the file system with the '
161
- .concat(FsFunctions_1.readFilesFunctionName, ' function and the ')
162
- .concat(FsFunctions_1.writeFilesFunctionName, ' function'),
163
- 'Before writing to a file that already exists, read the file first and make your changes to its contents',
164
- 'When reading/writing a file in a specified package, join the package directory with the relative path to form the file path',
165
- 'When searching for source files, do not look in the dist or node_modules directories',
166
- "If you don't know a file path, don't try to guess it, use the ".concat(
167
- KeywordToFilesIndexFunctions_1.searchFilesFunctionName,
168
- ' function to find it'
169
- ),
170
- 'When searching for something (ie. a file to work with/in), unless more context is specified, use the '
171
- .concat(PackageFunctions_1.searchLibrariesFunctionName, ' function first, then fall back to functions: ')
172
- .concat(PackageFunctions_1.searchPackagesFunctionName, ', ')
173
- .concat(KeywordToFilesIndexFunctions_1.searchFilesFunctionName),
174
- "After finding a file to work with, assume the user's following question pertains to that file and use ".concat(
175
- FsFunctions_1.readFilesFunctionName,
176
- ' to read the file if needed'
177
- ),
178
- ];
179
- };
180
- ConversationFsModule.prototype.getFunctions = function () {
181
- return __spreadArray(
182
- [
183
- (0, FsFunctions_1.readFilesFunction)(this),
184
- (0, FsFunctions_1.writeFilesFunction)(this),
185
- (0, FsFunctions_1.getRecentlyAccessedFilePathsFunction)(this),
186
- ],
187
- FsFunctions_1.fsFunctions,
188
- true
189
- );
190
- };
191
- ConversationFsModule.prototype.getMessageModerators = function () {
192
- return [new ConversationFsModerator_1.ConversationFsModerator()];
193
- };
194
- ConversationFsModule.prototype.pushRecentlyAccessedFilePath = function (filePaths) {
195
- var _a;
196
- (_a = this.recentlyAccessedFilePaths).push.apply(_a, filePaths);
197
- };
198
- ConversationFsModule.prototype.getRecentlyAccessedFilePaths = function () {
199
- return this.recentlyAccessedFilePaths;
200
- };
201
- return ConversationFsModule;
202
- })();
54
+ function ConversationFsModule(repoPath) {
55
+ this.recentlyAccessedFilePaths = [];
56
+ this.repoPath = repoPath;
57
+ }
58
+ ConversationFsModule.prototype.getName = function () {
59
+ return 'Conversation Fs';
60
+ };
61
+ ConversationFsModule.prototype.getSystemMessages = function () {
62
+ return [
63
+ "Assume the current working directory is: ".concat(this.repoPath, " unless specified by the user"),
64
+ "Pre-pend the current working directory as the base path to file paths when performing file operations, unless specified otherwise by the user",
65
+ "If the user asks to change the cwd, do not create a new folder, just fail if it's not a valid path",
66
+ "If the user wants to work in a package, use the ".concat(PackageFunctions_1.searchPackagesFunctionName, " function and take the directory from the package.json file path and make that the cwd"),
67
+ "You have access to code in a local repo, you can read and write code to and from the file system with the ".concat(FsFunctions_1.readFilesFunctionName, " function and the ").concat(FsFunctions_1.writeFilesFunctionName, " function"),
68
+ "Before writing to a file that already exists, read the file first and make your changes to its contents",
69
+ "When reading/writing a file in a specified package, join the package directory with the relative path to form the file path",
70
+ "When searching for source files, do not look in the dist or node_modules directories",
71
+ "If you don't know a file path, don't try to guess it, use the ".concat(KeywordToFilesIndexFunctions_1.searchFilesFunctionName, " function to find it"),
72
+ "When searching for something (ie. a file to work with/in), unless more context is specified, use the ".concat(PackageFunctions_1.searchLibrariesFunctionName, " function first, then fall back to functions: ").concat(PackageFunctions_1.searchPackagesFunctionName, ", ").concat(KeywordToFilesIndexFunctions_1.searchFilesFunctionName),
73
+ "After finding a file to work with, assume the user's following question pertains to that file and use ".concat(FsFunctions_1.readFilesFunctionName, " to read the file if needed"),
74
+ ];
75
+ };
76
+ ConversationFsModule.prototype.getFunctions = function () {
77
+ return __spreadArray([
78
+ (0, FsFunctions_1.readFilesFunction)(this),
79
+ (0, FsFunctions_1.writeFilesFunction)(this),
80
+ (0, FsFunctions_1.getRecentlyAccessedFilePathsFunction)(this)
81
+ ], FsFunctions_1.fsFunctions, true);
82
+ };
83
+ ConversationFsModule.prototype.getMessageModerators = function () {
84
+ return [new ConversationFsModerator_1.ConversationFsModerator()];
85
+ };
86
+ ConversationFsModule.prototype.pushRecentlyAccessedFilePath = function (filePaths) {
87
+ var _a;
88
+ (_a = this.recentlyAccessedFilePaths).push.apply(_a, filePaths);
89
+ };
90
+ ConversationFsModule.prototype.getRecentlyAccessedFilePaths = function () {
91
+ return this.recentlyAccessedFilePaths;
92
+ };
93
+ return ConversationFsModule;
94
+ }());
203
95
  exports.ConversationFsModule = ConversationFsModule;
204
96
  var ConversationFsModuleFactory = /** @class */ (function () {
205
- function ConversationFsModuleFactory() {}
206
- ConversationFsModuleFactory.prototype.createModule = function (repoPath) {
207
- return __awaiter(this, void 0, void 0, function () {
208
- return __generator(this, function (_a) {
209
- return [2 /*return*/, new ConversationFsModule(repoPath)];
210
- });
211
- });
212
- };
213
- return ConversationFsModuleFactory;
214
- })();
97
+ function ConversationFsModuleFactory() {
98
+ }
99
+ ConversationFsModuleFactory.prototype.createModule = function (repoPath) {
100
+ return __awaiter(this, void 0, void 0, function () {
101
+ return __generator(this, function (_a) {
102
+ return [2 /*return*/, new ConversationFsModule(repoPath)];
103
+ });
104
+ });
105
+ };
106
+ return ConversationFsModuleFactory;
107
+ }());
215
108
  exports.ConversationFsModuleFactory = ConversationFsModuleFactory;
216
- //# sourceMappingURL=ConversationFsModule.js.map
109
+ //# sourceMappingURL=ConversationFsModule.js.map