@polka-codes/core 0.4.5 → 0.4.7

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 (2) hide show
  1. package/dist/index.js +121 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8310,12 +8310,8 @@ var capabilities = (toolNamePrefix) => `
8310
8310
 
8311
8311
  CAPABILITIES
8312
8312
 
8313
- - You have access to a range of tools to aid you in your work. These tools help you effectively accomplish a wide range of tasks, such as writing code, making edits or improvements to existing files, understanding the current state of a project, performing system operations, and much more.
8314
- - When the user initially gives you a task, a recursive list of all filepaths in the current working directory will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further.
8315
- - You can use ${toolNamePrefix}search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
8316
- - You can use the ${toolNamePrefix}list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
8317
- \t- For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use ${toolNamePrefix}list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then ${toolNamePrefix}read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the ${toolNamePrefix}replace_in_file tool to implement changes. If you refactored code that could affect other parts of the codebase, you could use ${toolNamePrefix}search_files to ensure you update other files as needed.
8318
- - You can use the ${toolNamePrefix}execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.`;
8313
+ - You have access to a range of tools to aid you in your work. These tools help you effectively accomplish a wide range of tasks.
8314
+ - When the user initially gives you a task, a recursive list of all filepaths in the current working directory will be included in context. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further.`;
8319
8315
  var systemInformation = (info) => `
8320
8316
  ====
8321
8317
 
@@ -8380,7 +8376,7 @@ ${joined}`;
8380
8376
  };
8381
8377
  var responsePrompts = {
8382
8378
  errorInvokeTool: (tool, error) => `An error occurred while invoking the tool "${tool}": ${error}`,
8383
- requireUseTool: "Error: You must use a tool before proceeding",
8379
+ requireUseTool: "Error: You must use a tool before proceeding. Making sure the tool is invoked using xml tags.",
8384
8380
  toolResults: (tool, result) => `<tool_response>
8385
8381
  <tool_name>${tool}</tool_name>
8386
8382
  <tool_result>
@@ -8392,6 +8388,7 @@ ${result}
8392
8388
  // src/Agent/AgentBase.ts
8393
8389
  var TaskEventKind;
8394
8390
  ((TaskEventKind2) => {
8391
+ TaskEventKind2["StartTask"] = "StartTask";
8395
8392
  TaskEventKind2["StartRequest"] = "StartRequest";
8396
8393
  TaskEventKind2["EndRequest"] = "EndRequest";
8397
8394
  TaskEventKind2["Usage"] = "Usage";
@@ -8451,6 +8448,7 @@ ${agents}`;
8451
8448
  text += `
8452
8449
  <context>${context}</context>`;
8453
8450
  }
8451
+ callback({ kind: "StartTask" /* StartTask */, info: taskInfo, systemPrompt: this.config.systemPrompt });
8454
8452
  return await this.#processLoop(text, taskInfo, callback);
8455
8453
  }
8456
8454
  async#processLoop(userMessage, taskInfo, callback) {
@@ -8596,6 +8594,12 @@ class MockProvider {
8596
8594
  async writeFile(path, content) {
8597
8595
  return;
8598
8596
  }
8597
+ async removeFile(path) {
8598
+ return;
8599
+ }
8600
+ async renameFile(sourcePath, targetPath) {
8601
+ return;
8602
+ }
8599
8603
  async listFiles(path, recursive, maxCount) {
8600
8604
  return [["mock-file.txt"], false];
8601
8605
  }
@@ -8621,6 +8625,8 @@ __export(exports_allTools, {
8621
8625
  writeToFile: () => writeToFile_default,
8622
8626
  searchFiles: () => searchFiles_default,
8623
8627
  replaceInFile: () => replaceInFile_default,
8628
+ renameFile: () => renameFile_default,
8629
+ removeFile: () => removeFile_default,
8624
8630
  readFile: () => readFile_default,
8625
8631
  listFiles: () => listFiles_default,
8626
8632
  listCodeDefinitionNames: () => listCodeDefinitionNames_default,
@@ -8704,7 +8710,7 @@ var getStringArray = (args, name, defaultValue) => {
8704
8710
  if (ret === "") {
8705
8711
  return [];
8706
8712
  }
8707
- return ret.split(",");
8713
+ return ret.split(",").map((s) => s.trim());
8708
8714
  };
8709
8715
  var getBoolean = (args, name, defaultValue) => {
8710
8716
  const ret = args[name];
@@ -9336,7 +9342,7 @@ var handler9 = async (provider, args) => {
9336
9342
  await provider.writeFile(path, content);
9337
9343
  return {
9338
9344
  type: "Reply" /* Reply */,
9339
- message: `<write_file_path>${path}</write_file_path><status>Success</status>`
9345
+ message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
9340
9346
  };
9341
9347
  };
9342
9348
  var isAvailable9 = (provider) => {
@@ -9373,7 +9379,7 @@ var toolInfo10 = {
9373
9379
  {
9374
9380
  name: "files",
9375
9381
  description: "The files relevant to the task",
9376
- required: true,
9382
+ required: false,
9377
9383
  usageValue: "Relevant files"
9378
9384
  }
9379
9385
  ],
@@ -9422,6 +9428,109 @@ var handOver_default = {
9422
9428
  handler: handler10,
9423
9429
  isAvailable: isAvailable10
9424
9430
  };
9431
+ // src/tools/removeFile.ts
9432
+ var toolInfo11 = {
9433
+ name: "remove_file",
9434
+ description: "Request to remove a file at the specified path.",
9435
+ parameters: [
9436
+ {
9437
+ name: "path",
9438
+ description: "The path of the file to remove",
9439
+ required: true,
9440
+ usageValue: "File path here"
9441
+ }
9442
+ ],
9443
+ examples: [
9444
+ {
9445
+ description: "Request to remove a file",
9446
+ parameters: [
9447
+ {
9448
+ name: "path",
9449
+ value: "src/main.js"
9450
+ }
9451
+ ]
9452
+ }
9453
+ ]
9454
+ };
9455
+ var handler11 = async (provider, args) => {
9456
+ if (!provider.removeFile) {
9457
+ return {
9458
+ type: "Error" /* Error */,
9459
+ message: "Not possible to remove file. Abort."
9460
+ };
9461
+ }
9462
+ const path = getString(args, "path");
9463
+ await provider.removeFile(path);
9464
+ return {
9465
+ type: "Reply" /* Reply */,
9466
+ message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
9467
+ };
9468
+ };
9469
+ var isAvailable11 = (provider) => {
9470
+ return !!provider.removeFile;
9471
+ };
9472
+ var removeFile_default = {
9473
+ ...toolInfo11,
9474
+ handler: handler11,
9475
+ isAvailable: isAvailable11
9476
+ };
9477
+ // src/tools/renameFile.ts
9478
+ var toolInfo12 = {
9479
+ name: "rename_file",
9480
+ description: "Request to rename a file from source path to target path.",
9481
+ parameters: [
9482
+ {
9483
+ name: "sourcePath",
9484
+ description: "The current path of the file",
9485
+ required: true,
9486
+ usageValue: "Source file path here"
9487
+ },
9488
+ {
9489
+ name: "targetPath",
9490
+ description: "The new path for the file",
9491
+ required: true,
9492
+ usageValue: "Target file path here"
9493
+ }
9494
+ ],
9495
+ examples: [
9496
+ {
9497
+ description: "Request to rename a file",
9498
+ parameters: [
9499
+ {
9500
+ name: "sourcePath",
9501
+ value: "src/old-name.js"
9502
+ },
9503
+ {
9504
+ name: "targetPath",
9505
+ value: "src/new-name.js"
9506
+ }
9507
+ ]
9508
+ }
9509
+ ]
9510
+ };
9511
+ var handler12 = async (provider, args) => {
9512
+ if (!provider.renameFile) {
9513
+ return {
9514
+ type: "Error" /* Error */,
9515
+ message: "Not possible to rename file. Abort."
9516
+ };
9517
+ }
9518
+ const sourcePath = getString(args, "sourcePath");
9519
+ const targetPath = getString(args, "targetPath");
9520
+ await provider.renameFile(sourcePath, targetPath);
9521
+ return {
9522
+ type: "Reply" /* Reply */,
9523
+ message: `<rename_file_path>${targetPath}</rename_file_path><status>Success</status>`
9524
+ };
9525
+ };
9526
+ var isAvailable12 = (provider) => {
9527
+ return !!provider.renameFile;
9528
+ };
9529
+ var renameFile_default = {
9530
+ ...toolInfo12,
9531
+ handler: handler12,
9532
+ isAvailable: isAvailable12
9533
+ };
9425
9534
  // src/Agent/CoderAgent/prompts.ts
9426
9535
  var basePrompt = "You are a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.";
9427
9536
  var editingFilesPrompt = (toolNamePrefix) => `
@@ -9899,6 +10008,8 @@ export {
9899
10008
  writeToFile_default as writeToFile,
9900
10009
  searchFiles_default as searchFiles,
9901
10010
  replaceInFile_default as replaceInFile,
10011
+ renameFile_default as renameFile,
10012
+ removeFile_default as removeFile,
9902
10013
  readFile_default as readFile,
9903
10014
  openAiModelInfoSaneDefaults,
9904
10015
  makeTool,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "license": "AGPL-3.0",
5
5
  "type": "module",
6
6
  "exports": {