@polka-codes/core 0.0.3 → 0.1.0

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 (65) hide show
  1. package/dist/Agent/AgentBase.d.ts +49 -0
  2. package/dist/Agent/AgentBase.js +158 -0
  3. package/dist/Agent/AgentBase.js.map +1 -0
  4. package/dist/Agent/CoderAgent/__snapshots__/prompts.test.js.snap +432 -0
  5. package/dist/Agent/CoderAgent/index.d.ts +17 -0
  6. package/dist/Agent/CoderAgent/index.js +32 -0
  7. package/dist/Agent/CoderAgent/index.js.map +1 -0
  8. package/dist/Agent/CoderAgent/prompts.d.ts +20 -0
  9. package/dist/Agent/CoderAgent/prompts.js +163 -0
  10. package/dist/Agent/CoderAgent/prompts.js.map +1 -0
  11. package/dist/Agent/CoderAgent/prompts.test.d.ts +1 -0
  12. package/dist/Agent/CoderAgent/prompts.test.js +20 -0
  13. package/dist/Agent/CoderAgent/prompts.test.js.map +1 -0
  14. package/dist/Agent/index.d.ts +2 -0
  15. package/dist/Agent/index.js +3 -0
  16. package/dist/Agent/index.js.map +1 -0
  17. package/dist/Agent/parseAssistantMessage.d.ts +45 -0
  18. package/dist/Agent/parseAssistantMessage.js +103 -0
  19. package/dist/Agent/parseAssistantMessage.js.map +1 -0
  20. package/dist/Agent/parseAssistantMessage.test.d.ts +1 -0
  21. package/dist/Agent/parseAssistantMessage.test.js +172 -0
  22. package/dist/Agent/parseAssistantMessage.test.js.map +1 -0
  23. package/dist/Agent/prompts.d.ts +7 -0
  24. package/dist/Agent/prompts.js +93 -0
  25. package/dist/Agent/prompts.js.map +1 -0
  26. package/dist/AiService/AiServiceBase.d.ts +29 -0
  27. package/dist/AiService/AiServiceBase.js +3 -0
  28. package/dist/AiService/AiServiceBase.js.map +1 -0
  29. package/dist/AiService/AnthropicService.d.ts +11 -0
  30. package/dist/AiService/AnthropicService.js +185 -0
  31. package/dist/AiService/AnthropicService.js.map +1 -0
  32. package/dist/AiService/DeepSeekService.d.ts +11 -0
  33. package/dist/AiService/DeepSeekService.js +64 -0
  34. package/dist/AiService/DeepSeekService.js.map +1 -0
  35. package/dist/AiService/ModelInfo.d.ts +79 -0
  36. package/dist/AiService/ModelInfo.js +67 -0
  37. package/dist/AiService/ModelInfo.js.map +1 -0
  38. package/dist/AiService/OllamaService.d.ts +11 -0
  39. package/dist/AiService/OllamaService.js +47 -0
  40. package/dist/AiService/OllamaService.js.map +1 -0
  41. package/dist/AiService/index.d.ts +12 -0
  42. package/dist/AiService/index.js +20 -0
  43. package/dist/AiService/index.js.map +1 -0
  44. package/dist/AiService/utils.d.ts +4 -0
  45. package/dist/AiService/utils.js +187 -0
  46. package/dist/AiService/utils.js.map +1 -0
  47. package/dist/AiService/utils.test.d.ts +1 -0
  48. package/dist/AiService/utils.test.js +275 -0
  49. package/dist/AiService/utils.test.js.map +1 -0
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.js +5 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/logger.d.ts +5 -0
  54. package/dist/logger.js +25 -0
  55. package/dist/logger.js.map +1 -0
  56. package/dist/tools/index.d.ts +3 -0
  57. package/dist/tools/index.js +4 -0
  58. package/dist/tools/index.js.map +1 -0
  59. package/dist/tools/tools.d.ts +200 -0
  60. package/dist/tools/tools.js +329 -0
  61. package/dist/tools/tools.js.map +1 -0
  62. package/dist/tools/types.d.ts +49 -0
  63. package/dist/tools/types.js +9 -0
  64. package/dist/tools/types.js.map +1 -0
  65. package/package.json +9 -6
@@ -0,0 +1,200 @@
1
+ export declare const executeCommand: {
2
+ readonly name: "execute_command";
3
+ readonly description: "Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory.";
4
+ readonly parameters: [{
5
+ readonly name: "command";
6
+ readonly description: "The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.";
7
+ readonly required: true;
8
+ readonly usageValue: "Your command here";
9
+ }, {
10
+ readonly name: "requires_approval";
11
+ readonly description: "A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.";
12
+ readonly required: false;
13
+ readonly usageValue: "true or false";
14
+ }];
15
+ readonly examples: [{
16
+ readonly description: "Request to execute a command";
17
+ readonly parameters: [{
18
+ readonly name: "command";
19
+ readonly value: "npm run dev";
20
+ }, {
21
+ readonly name: "requires_approval";
22
+ readonly value: "false";
23
+ }];
24
+ }];
25
+ };
26
+ export declare const readFile: {
27
+ readonly name: "read_file";
28
+ readonly description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string.";
29
+ readonly parameters: [{
30
+ readonly name: "path";
31
+ readonly description: "The path of the file to read";
32
+ readonly required: true;
33
+ readonly usageValue: "Comma separated paths here";
34
+ }];
35
+ readonly examples: [{
36
+ readonly description: "Request to read the contents of a file";
37
+ readonly parameters: [{
38
+ readonly name: "path";
39
+ readonly value: "src/main.js";
40
+ }];
41
+ }, {
42
+ readonly description: "Request to read multiple files";
43
+ readonly parameters: [{
44
+ readonly name: "path";
45
+ readonly value: "src/main.js,src/index.js";
46
+ }];
47
+ }];
48
+ };
49
+ export declare const writeToFile: {
50
+ readonly name: "write_to_file";
51
+ readonly description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.";
52
+ readonly parameters: [{
53
+ readonly name: "path";
54
+ readonly description: "The path of the file to write to";
55
+ readonly required: true;
56
+ readonly usageValue: "File path here";
57
+ }, {
58
+ readonly name: "content";
59
+ readonly description: "The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.";
60
+ readonly required: true;
61
+ readonly usageValue: "Your file content here";
62
+ }];
63
+ readonly examples: [{
64
+ readonly description: "Request to write content to a file";
65
+ readonly parameters: [{
66
+ readonly name: "path";
67
+ readonly value: "src/main.js";
68
+ }, {
69
+ readonly name: "content";
70
+ readonly value: "import React from 'react';\n\nfunction App() {\n return (\n <div>\n <h1>Hello, World!</h1>\n </div>\n );\n}\n\nexport default App;\n";
71
+ }];
72
+ }];
73
+ };
74
+ export declare const replaceInFile: {
75
+ readonly name: "replace_in_file";
76
+ readonly description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.";
77
+ readonly parameters: [{
78
+ readonly name: "path";
79
+ readonly description: "The path of the file to modify";
80
+ readonly required: true;
81
+ readonly usageValue: "File path here";
82
+ }, {
83
+ readonly name: "diff";
84
+ readonly description: "One or more SEARCH/REPLACE blocks following this exact format:\n ```\n <<<<<<< SEARCH\n [exact content to find]\n =======\n [new content to replace with]\n >>>>>>> REPLACE\n ```\n Critical rules:\n 1. SEARCH content must match the associated file section to find EXACTLY:\n * Match character-for-character including whitespace, indentation, line endings\n * Include all comments, docstrings, etc.\n 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.\n * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.\n * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.\n * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.\n 3. Keep SEARCH/REPLACE blocks concise:\n * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.\n * Include just the changing lines, and a few surrounding lines if needed for uniqueness.\n * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.\n * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.\n 4. Special operations:\n * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)\n * To delete code: Use empty REPLACE section";
85
+ readonly required: true;
86
+ readonly usageValue: "Search and replace blocks here";
87
+ }];
88
+ readonly examples: [{
89
+ readonly description: "Request to replace sections of content in a file";
90
+ readonly parameters: [{
91
+ readonly name: "path";
92
+ readonly value: "src/main.js";
93
+ }, {
94
+ readonly name: "diff";
95
+ readonly value: "\n<<<<<<< SEARCH\nimport React from 'react';\n=======\nimport React, { useState } from 'react';\n>>>>>>> REPLACE\n\n<<<<<<< SEARCH\nfunction handleSubmit() {\n saveData();\n setLoading(false);\n}\n\n=======\n>>>>>>> REPLACE\n\n<<<<<<< SEARCH\nreturn (\n <div>\n=======\nfunction handleSubmit() {\n saveData();\n setLoading(false);\n}\n\nreturn (\n <div>\n>>>>>>> REPLACE\n";
96
+ }];
97
+ }];
98
+ };
99
+ export declare const searchFiles: {
100
+ readonly name: "search_files";
101
+ readonly description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.";
102
+ readonly parameters: [{
103
+ readonly name: "path";
104
+ readonly description: "The path of the directory to search in (relative to the current working directory). This directory will be recursively searched.";
105
+ readonly required: true;
106
+ readonly usageValue: "Directory path here";
107
+ }, {
108
+ readonly name: "regex";
109
+ readonly description: "The regular expression pattern to search for. Uses Rust regex syntax.";
110
+ readonly required: true;
111
+ readonly usageValue: "Your regex pattern here";
112
+ }, {
113
+ readonly name: "file_pattern";
114
+ readonly description: "Glob pattern to filter files (e.g., \"*.ts\" for TypeScript files). If not provided, it will search all files (*).";
115
+ readonly required: false;
116
+ readonly usageValue: "file pattern here (optional)";
117
+ }];
118
+ readonly examples: [{
119
+ readonly description: "Request to perform a regex search across files";
120
+ readonly parameters: [{
121
+ readonly name: "path";
122
+ readonly value: "src";
123
+ }, {
124
+ readonly name: "regex";
125
+ readonly value: "^src/components/";
126
+ }, {
127
+ readonly name: "file_pattern";
128
+ readonly value: "*.ts";
129
+ }];
130
+ }];
131
+ };
132
+ export declare const listFiles: {
133
+ readonly name: "list_files";
134
+ readonly description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.";
135
+ readonly parameters: [{
136
+ readonly name: "path";
137
+ readonly description: "The path of the directory to list contents for (relative to the current working directory)";
138
+ readonly required: true;
139
+ readonly usageValue: "Directory path here";
140
+ }, {
141
+ readonly name: "depth";
142
+ readonly description: "The depth of the directory to list contents for. Use 0 for the top-level directory only, 1 for the top-level directory and its children, and so on.";
143
+ readonly required: false;
144
+ readonly usageValue: "a number (optional)";
145
+ }];
146
+ readonly examples: [{
147
+ readonly description: "Request to list files";
148
+ readonly parameters: [{
149
+ readonly name: "path";
150
+ readonly value: "src";
151
+ }, {
152
+ readonly name: "recursive";
153
+ readonly value: "true";
154
+ }];
155
+ }];
156
+ };
157
+ export declare const listCodeDefinitionNames: {
158
+ readonly name: "list_code_definition_names";
159
+ readonly description: "Request to list definition names (classes, functions, methods, etc.) used in source code files at the top level of the specified directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.";
160
+ readonly parameters: [{
161
+ readonly name: "path";
162
+ readonly description: "The path of the directory (relative to the current working directory ${cwd.toPosix()}) to list top level source code definitions for.";
163
+ readonly required: true;
164
+ readonly usageValue: "Directory path here";
165
+ }];
166
+ };
167
+ export declare const askFollowupQuestion: {
168
+ readonly name: "ask_followup_question";
169
+ readonly description: "Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.";
170
+ readonly parameters: [{
171
+ readonly name: "question";
172
+ readonly description: "The question to ask the user. This should be a clear, specific question that addresses the information you need.";
173
+ readonly required: true;
174
+ readonly usageValue: "Your question here";
175
+ }];
176
+ readonly examples: [{
177
+ readonly description: "Request to ask a question";
178
+ readonly parameters: [{
179
+ readonly name: "question";
180
+ readonly value: "What is the name of the project?";
181
+ }];
182
+ }];
183
+ };
184
+ export declare const attemptCompletion: {
185
+ readonly name: "attempt_completion";
186
+ readonly description: "After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user.";
187
+ readonly parameters: [{
188
+ readonly name: "result";
189
+ readonly description: "The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.";
190
+ readonly required: true;
191
+ readonly usageValue: "Your final result description here";
192
+ }];
193
+ readonly examples: [{
194
+ readonly description: "Request to present the result of the task";
195
+ readonly parameters: [{
196
+ readonly name: "result";
197
+ readonly value: "Your final result description here";
198
+ }];
199
+ }];
200
+ };
@@ -0,0 +1,329 @@
1
+ // source: https://github.com/cline/cline/blob/f6c19c29a64ca84e9360df7ab2c07d128dcebe64/src/core/prompts/system.ts#L1
2
+ export const executeCommand = {
3
+ name: 'execute_command',
4
+ description: `Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory.`,
5
+ parameters: [
6
+ {
7
+ name: 'command',
8
+ description: 'The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.',
9
+ required: true,
10
+ usageValue: 'Your command here',
11
+ },
12
+ {
13
+ name: 'requires_approval',
14
+ description: `A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.`,
15
+ required: false,
16
+ usageValue: 'true or false',
17
+ },
18
+ ],
19
+ examples: [
20
+ {
21
+ description: 'Request to execute a command',
22
+ parameters: [
23
+ {
24
+ name: 'command',
25
+ value: 'npm run dev',
26
+ },
27
+ {
28
+ name: 'requires_approval',
29
+ value: 'false',
30
+ },
31
+ ],
32
+ },
33
+ ],
34
+ };
35
+ export const readFile = {
36
+ name: 'read_file',
37
+ description: 'Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string.',
38
+ parameters: [
39
+ {
40
+ name: 'path',
41
+ description: 'The path of the file to read',
42
+ required: true,
43
+ usageValue: 'Comma separated paths here',
44
+ },
45
+ ],
46
+ examples: [
47
+ {
48
+ description: 'Request to read the contents of a file',
49
+ parameters: [
50
+ {
51
+ name: 'path',
52
+ value: 'src/main.js',
53
+ },
54
+ ],
55
+ },
56
+ {
57
+ description: 'Request to read multiple files',
58
+ parameters: [
59
+ {
60
+ name: 'path',
61
+ value: 'src/main.js,src/index.js',
62
+ },
63
+ ],
64
+ },
65
+ ],
66
+ };
67
+ export const writeToFile = {
68
+ name: 'write_to_file',
69
+ description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.",
70
+ parameters: [
71
+ {
72
+ name: 'path',
73
+ description: 'The path of the file to write to',
74
+ required: true,
75
+ usageValue: 'File path here',
76
+ },
77
+ {
78
+ name: 'content',
79
+ description: "The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.",
80
+ required: true,
81
+ usageValue: 'Your file content here',
82
+ },
83
+ ],
84
+ examples: [
85
+ {
86
+ description: 'Request to write content to a file',
87
+ parameters: [
88
+ {
89
+ name: 'path',
90
+ value: 'src/main.js',
91
+ },
92
+ {
93
+ name: 'content',
94
+ value: `import React from 'react';
95
+
96
+ function App() {
97
+ return (
98
+ <div>
99
+ <h1>Hello, World!</h1>
100
+ </div>
101
+ );
102
+ }
103
+
104
+ export default App;
105
+ `,
106
+ },
107
+ ],
108
+ },
109
+ ],
110
+ };
111
+ export const replaceInFile = {
112
+ name: 'replace_in_file',
113
+ description: 'Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.',
114
+ parameters: [
115
+ {
116
+ name: 'path',
117
+ description: 'The path of the file to modify',
118
+ required: true,
119
+ usageValue: 'File path here',
120
+ },
121
+ {
122
+ name: 'diff',
123
+ description: `One or more SEARCH/REPLACE blocks following this exact format:
124
+ \`\`\`
125
+ <<<<<<< SEARCH
126
+ [exact content to find]
127
+ =======
128
+ [new content to replace with]
129
+ >>>>>>> REPLACE
130
+ \`\`\`
131
+ Critical rules:
132
+ 1. SEARCH content must match the associated file section to find EXACTLY:
133
+ * Match character-for-character including whitespace, indentation, line endings
134
+ * Include all comments, docstrings, etc.
135
+ 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
136
+ * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
137
+ * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
138
+ * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
139
+ 3. Keep SEARCH/REPLACE blocks concise:
140
+ * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
141
+ * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
142
+ * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
143
+ * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
144
+ 4. Special operations:
145
+ * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
146
+ * To delete code: Use empty REPLACE section`,
147
+ required: true,
148
+ usageValue: 'Search and replace blocks here',
149
+ },
150
+ ],
151
+ examples: [
152
+ {
153
+ description: 'Request to replace sections of content in a file',
154
+ parameters: [
155
+ {
156
+ name: 'path',
157
+ value: 'src/main.js',
158
+ },
159
+ {
160
+ name: 'diff',
161
+ value: `
162
+ <<<<<<< SEARCH
163
+ import React from 'react';
164
+ =======
165
+ import React, { useState } from 'react';
166
+ >>>>>>> REPLACE
167
+
168
+ <<<<<<< SEARCH
169
+ function handleSubmit() {
170
+ saveData();
171
+ setLoading(false);
172
+ }
173
+
174
+ =======
175
+ >>>>>>> REPLACE
176
+
177
+ <<<<<<< SEARCH
178
+ return (
179
+ <div>
180
+ =======
181
+ function handleSubmit() {
182
+ saveData();
183
+ setLoading(false);
184
+ }
185
+
186
+ return (
187
+ <div>
188
+ >>>>>>> REPLACE
189
+ `,
190
+ },
191
+ ],
192
+ },
193
+ ],
194
+ };
195
+ export const searchFiles = {
196
+ name: 'search_files',
197
+ description: 'Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.',
198
+ parameters: [
199
+ {
200
+ name: 'path',
201
+ description: 'The path of the directory to search in (relative to the current working directory). This directory will be recursively searched.',
202
+ required: true,
203
+ usageValue: 'Directory path here',
204
+ },
205
+ {
206
+ name: 'regex',
207
+ description: 'The regular expression pattern to search for. Uses Rust regex syntax.',
208
+ required: true,
209
+ usageValue: 'Your regex pattern here',
210
+ },
211
+ {
212
+ name: 'file_pattern',
213
+ description: 'Glob pattern to filter files (e.g., "*.ts" for TypeScript files). If not provided, it will search all files (*).',
214
+ required: false,
215
+ usageValue: 'file pattern here (optional)',
216
+ },
217
+ ],
218
+ examples: [
219
+ {
220
+ description: 'Request to perform a regex search across files',
221
+ parameters: [
222
+ {
223
+ name: 'path',
224
+ value: 'src',
225
+ },
226
+ {
227
+ name: 'regex',
228
+ value: '^src/components/',
229
+ },
230
+ {
231
+ name: 'file_pattern',
232
+ value: '*.ts',
233
+ },
234
+ ],
235
+ },
236
+ ],
237
+ };
238
+ export const listFiles = {
239
+ name: 'list_files',
240
+ description: 'Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.',
241
+ parameters: [
242
+ {
243
+ name: 'path',
244
+ description: 'The path of the directory to list contents for (relative to the current working directory)',
245
+ required: true,
246
+ usageValue: 'Directory path here',
247
+ },
248
+ {
249
+ name: 'depth',
250
+ description: 'The depth of the directory to list contents for. Use 0 for the top-level directory only, 1 for the top-level directory and its children, and so on.',
251
+ required: false,
252
+ usageValue: 'a number (optional)',
253
+ },
254
+ ],
255
+ examples: [
256
+ {
257
+ description: 'Request to list files',
258
+ parameters: [
259
+ {
260
+ name: 'path',
261
+ value: 'src',
262
+ },
263
+ {
264
+ name: 'recursive',
265
+ value: 'true',
266
+ },
267
+ ],
268
+ },
269
+ ],
270
+ };
271
+ export const listCodeDefinitionNames = {
272
+ name: 'list_code_definition_names',
273
+ description: 'Request to list definition names (classes, functions, methods, etc.) used in source code files at the top level of the specified directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.',
274
+ parameters: [
275
+ {
276
+ name: 'path',
277
+ description: 'The path of the directory (relative to the current working directory ${cwd.toPosix()}) to list top level source code definitions for.',
278
+ required: true,
279
+ usageValue: 'Directory path here',
280
+ },
281
+ ],
282
+ };
283
+ export const askFollowupQuestion = {
284
+ name: 'ask_followup_question',
285
+ description: 'Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.',
286
+ parameters: [
287
+ {
288
+ name: 'question',
289
+ description: 'The question to ask the user. This should be a clear, specific question that addresses the information you need.',
290
+ required: true,
291
+ usageValue: 'Your question here',
292
+ },
293
+ ],
294
+ examples: [
295
+ {
296
+ description: 'Request to ask a question',
297
+ parameters: [
298
+ {
299
+ name: 'question',
300
+ value: 'What is the name of the project?',
301
+ },
302
+ ],
303
+ },
304
+ ],
305
+ };
306
+ export const attemptCompletion = {
307
+ name: 'attempt_completion',
308
+ description: "After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user.",
309
+ parameters: [
310
+ {
311
+ name: 'result',
312
+ description: "The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.",
313
+ required: true,
314
+ usageValue: 'Your final result description here',
315
+ },
316
+ ],
317
+ examples: [
318
+ {
319
+ description: 'Request to present the result of the task',
320
+ parameters: [
321
+ {
322
+ name: 'result',
323
+ value: 'Your final result description here',
324
+ },
325
+ ],
326
+ },
327
+ ],
328
+ };
329
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools/tools.ts"],"names":[],"mappings":"AAAA,qHAAqH;AAIrH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,ucAAuc;IACpd,UAAU,EAAE;QACV;YACE,IAAI,EAAE,SAAS;YACf,WAAW,EACT,4KAA4K;YAC9K,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,mBAAmB;SAChC;QACD;YACE,IAAI,EAAE,mBAAmB;YACzB,WAAW,EAAE,sgBAAsgB;YACnhB,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,eAAe;SAC5B;KACF;IACD,QAAQ,EAAE;QACR;YACE,WAAW,EAAE,8BAA8B;YAC3C,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,aAAa;iBACrB;gBACD;oBACE,IAAI,EAAE,mBAAmB;oBACzB,KAAK,EAAE,OAAO;iBACf;aACF;SACF;KACF;CAC0B,CAAA;AAE7B,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,saAAsa;IACxa,U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EAAE,oCAAoC;SACjD;KACF;IACD,QAAQ,EAAE;QACR;YACE,WAAW,EAAE,2CAA2C;YACxD,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,oCAAoC;iBAC5C;aACF;SACF;KACF;CAC0B,CAAA"}
@@ -0,0 +1,49 @@
1
+ export type ToolParameter = {
2
+ name: string;
3
+ description: string;
4
+ required: boolean;
5
+ usageValue: string;
6
+ };
7
+ export type ToolExample = {
8
+ description: string;
9
+ parameters: {
10
+ name: string;
11
+ value: string;
12
+ }[];
13
+ };
14
+ export type ToolInfo = {
15
+ name: string;
16
+ description: string;
17
+ parameters: ToolParameter[];
18
+ examples?: ToolExample[];
19
+ };
20
+ export declare enum ToolResponseType {
21
+ Reply = "Reply",
22
+ Exit = "Exit",
23
+ Invalid = "Invalid",
24
+ Error = "Error",
25
+ Interrupted = "Interrupted"
26
+ }
27
+ export type ToolResponseReply = {
28
+ type: ToolResponseType.Reply;
29
+ message: string;
30
+ };
31
+ export type ToolResponseExit = {
32
+ type: ToolResponseType.Exit;
33
+ message: string;
34
+ };
35
+ export type ToolResponseInvalid = {
36
+ type: ToolResponseType.Invalid;
37
+ message: string;
38
+ };
39
+ export type ToolResponseError = {
40
+ type: ToolResponseType.Error;
41
+ message: string;
42
+ canRetry?: boolean;
43
+ };
44
+ export type ToolResponseInterrupted = {
45
+ type: ToolResponseType.Interrupted;
46
+ message: string;
47
+ };
48
+ export type ToolResponse = ToolResponseReply | ToolResponseExit | ToolResponseInvalid | ToolResponseError | ToolResponseInterrupted;
49
+ export type ToolHandler = (tool: string, args: Record<string, string>) => Promise<ToolResponse>;
@@ -0,0 +1,9 @@
1
+ export var ToolResponseType;
2
+ (function (ToolResponseType) {
3
+ ToolResponseType["Reply"] = "Reply";
4
+ ToolResponseType["Exit"] = "Exit";
5
+ ToolResponseType["Invalid"] = "Invalid";
6
+ ToolResponseType["Error"] = "Error";
7
+ ToolResponseType["Interrupted"] = "Interrupted";
8
+ })(ToolResponseType || (ToolResponseType = {}));
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,uCAAmB,CAAA;IACnB,mCAAe,CAAA;IACf,+CAA2B,CAAA;AAC7B,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
+ "license": "AGPL-3.0",
4
5
  "type": "module",
5
6
  "exports": {
6
7
  ".": {
@@ -8,9 +9,11 @@
8
9
  "types": "./dist/index.d.ts"
9
10
  }
10
11
  },
11
- "scripts": {
12
- "build": "tsc",
13
- "typecheck": "tsc --noEmit"
14
- },
15
- "files": ["dist"]
12
+ "files": ["dist"],
13
+ "dependencies": {
14
+ "@anthropic-ai/sdk": "^0.33.1",
15
+ "openai": "^4.77.4",
16
+ "pino": "^8.16.2",
17
+ "pino-pretty": "^13.0.0"
18
+ }
16
19
  }