@polka-codes/cli-shared 0.8.18 → 0.8.19

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 +157 -157
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -36771,13 +36771,13 @@ __export(exports_allTools, {
36771
36771
  writeToFile: () => writeToFile_default,
36772
36772
  updateKnowledge: () => updateKnowledge_default,
36773
36773
  searchFiles: () => searchFiles_default,
36774
+ replaceInFile: () => replaceInFile_default,
36774
36775
  renameFile: () => renameFile_default,
36775
36776
  removeFile: () => removeFile_default,
36776
36777
  readFile: () => readFile_default,
36777
36778
  listFiles: () => listFiles_default,
36778
36779
  handOver: () => handOver_default,
36779
36780
  executeCommand: () => executeCommand_default,
36780
- editFile: () => editFile_default,
36781
36781
  delegate: () => delegate_default,
36782
36782
  attemptCompletion: () => attemptCompletion_default,
36783
36783
  askFollowupQuestion: () => askFollowupQuestion_default
@@ -37408,8 +37408,125 @@ var readFile_default = {
37408
37408
  handler: handler6,
37409
37409
  isAvailable: isAvailable6
37410
37410
  };
37411
- // ../core/src/tools/searchFiles.ts
37411
+ // ../core/src/tools/replaceInFile.ts
37412
37412
  var toolInfo7 = {
37413
+ name: "replace_in_file",
37414
+ 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.",
37415
+ parameters: [
37416
+ {
37417
+ name: "path",
37418
+ description: "The path of the file to modify",
37419
+ required: true,
37420
+ usageValue: "File path here"
37421
+ },
37422
+ {
37423
+ name: "diff",
37424
+ description: `One or more SEARCH/REPLACE blocks following this exact format:
37425
+ \`\`\`
37426
+ <<<<<<< SEARCH
37427
+ [exact content to find]
37428
+ =======
37429
+ [new content to replace with]
37430
+ >>>>>>> REPLACE
37431
+ \`\`\`
37432
+ Critical rules:
37433
+ 1. SEARCH content must match the associated file section to find EXACTLY:
37434
+ * Match character-for-character including whitespace, indentation, line endings
37435
+ * Include all comments, docstrings, etc.
37436
+ 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
37437
+ * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
37438
+ * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
37439
+ * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
37440
+ 3. Keep SEARCH/REPLACE blocks concise:
37441
+ * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
37442
+ * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
37443
+ * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
37444
+ * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
37445
+ 4. Special operations:
37446
+ * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
37447
+ * To delete code: Use empty REPLACE section`,
37448
+ required: true,
37449
+ usageValue: "Search and replace blocks here"
37450
+ }
37451
+ ],
37452
+ examples: [
37453
+ {
37454
+ description: "Request to replace sections of content in a file",
37455
+ parameters: [
37456
+ {
37457
+ name: "path",
37458
+ value: "src/main.js"
37459
+ },
37460
+ {
37461
+ name: "diff",
37462
+ value: `
37463
+ <<<<<<< SEARCH
37464
+ import React from 'react';
37465
+ =======
37466
+ import React, { useState } from 'react';
37467
+ >>>>>>> REPLACE
37468
+
37469
+ <<<<<<< SEARCH
37470
+ function handleSubmit() {
37471
+ saveData();
37472
+ setLoading(false);
37473
+ }
37474
+
37475
+ =======
37476
+ >>>>>>> REPLACE
37477
+
37478
+ <<<<<<< SEARCH
37479
+ return (
37480
+ <div>
37481
+ =======
37482
+ function handleSubmit() {
37483
+ saveData();
37484
+ setLoading(false);
37485
+ }
37486
+
37487
+ return (
37488
+ <div>
37489
+ >>>>>>> REPLACE
37490
+ `
37491
+ }
37492
+ ]
37493
+ }
37494
+ ],
37495
+ permissionLevel: 2 /* Write */
37496
+ };
37497
+ var handler7 = async (provider, args) => {
37498
+ if (!provider.readFile || !provider.writeFile) {
37499
+ return {
37500
+ type: "Error" /* Error */,
37501
+ message: "Not possible to replace in file. Abort."
37502
+ };
37503
+ }
37504
+ const path = getString(args, "path");
37505
+ const diff = getString(args, "diff");
37506
+ const fileContent = await provider.readFile(path);
37507
+ if (fileContent == null) {
37508
+ return {
37509
+ type: "Error" /* Error */,
37510
+ message: `<error><replace_in_file_path>${path}</replace_in_file_path><error_message>File not found</error_message></error>`
37511
+ };
37512
+ }
37513
+ const result = await replaceInFile(fileContent, diff);
37514
+ await provider.writeFile(path, result);
37515
+ return {
37516
+ type: "Reply" /* Reply */,
37517
+ message: `<replace_in_file_path>${path}</replace_in_file_path>`
37518
+ };
37519
+ };
37520
+ var isAvailable7 = (provider) => {
37521
+ return !!provider.readFile && !!provider.writeFile;
37522
+ };
37523
+ var replaceInFile_default = {
37524
+ ...toolInfo7,
37525
+ handler: handler7,
37526
+ isAvailable: isAvailable7
37527
+ };
37528
+ // ../core/src/tools/searchFiles.ts
37529
+ var toolInfo8 = {
37413
37530
  name: "search_files",
37414
37531
  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.",
37415
37532
  parameters: [
@@ -37453,7 +37570,7 @@ var toolInfo7 = {
37453
37570
  ],
37454
37571
  permissionLevel: 1 /* Read */
37455
37572
  };
37456
- var handler7 = async (provider, args) => {
37573
+ var handler8 = async (provider, args) => {
37457
37574
  if (!provider.searchFiles) {
37458
37575
  return {
37459
37576
  type: "Error" /* Error */,
@@ -37476,18 +37593,18 @@ ${files.join(`
37476
37593
  `
37477
37594
  };
37478
37595
  };
37479
- var isAvailable7 = (provider) => {
37596
+ var isAvailable8 = (provider) => {
37480
37597
  return !!provider.searchFiles;
37481
37598
  };
37482
37599
  var searchFiles_default = {
37483
- ...toolInfo7,
37484
- handler: handler7,
37485
- isAvailable: isAvailable7
37600
+ ...toolInfo8,
37601
+ handler: handler8,
37602
+ isAvailable: isAvailable8
37486
37603
  };
37487
37604
  // ../core/src/tools/updateKnowledge.ts
37488
37605
  var import_yaml = __toESM(require_dist(), 1);
37489
37606
  import { join } from "node:path";
37490
- var toolInfo8 = {
37607
+ var toolInfo9 = {
37491
37608
  name: "update_knowledge",
37492
37609
  description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.",
37493
37610
  parameters: [
@@ -37664,7 +37781,7 @@ function deepMerge(target, source) {
37664
37781
  }
37665
37782
  return output;
37666
37783
  }
37667
- var handler8 = async (provider, args) => {
37784
+ var handler9 = async (provider, args) => {
37668
37785
  if (!provider.readFile || !provider.writeFile) {
37669
37786
  return {
37670
37787
  type: "Error" /* Error */,
@@ -37736,16 +37853,16 @@ var handler8 = async (provider, args) => {
37736
37853
  };
37737
37854
  }
37738
37855
  };
37739
- var isAvailable8 = (provider) => {
37856
+ var isAvailable9 = (provider) => {
37740
37857
  return !!provider.readFile && !!provider.writeFile;
37741
37858
  };
37742
37859
  var updateKnowledge_default = {
37743
- ...toolInfo8,
37744
- handler: handler8,
37745
- isAvailable: isAvailable8
37860
+ ...toolInfo9,
37861
+ handler: handler9,
37862
+ isAvailable: isAvailable9
37746
37863
  };
37747
37864
  // ../core/src/tools/writeToFile.ts
37748
- var toolInfo9 = {
37865
+ var toolInfo10 = {
37749
37866
  name: "write_to_file",
37750
37867
  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. Ensure that the output content does not include incorrect escaped character patterns such as `&lt;` and `&gt;`.",
37751
37868
  parameters: [
@@ -37790,7 +37907,7 @@ export default App;
37790
37907
  ],
37791
37908
  permissionLevel: 2 /* Write */
37792
37909
  };
37793
- var handler9 = async (provider, args) => {
37910
+ var handler10 = async (provider, args) => {
37794
37911
  if (!provider.writeFile) {
37795
37912
  return {
37796
37913
  type: "Error" /* Error */,
@@ -37805,16 +37922,16 @@ var handler9 = async (provider, args) => {
37805
37922
  message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
37806
37923
  };
37807
37924
  };
37808
- var isAvailable9 = (provider) => {
37925
+ var isAvailable10 = (provider) => {
37809
37926
  return !!provider.writeFile;
37810
37927
  };
37811
37928
  var writeToFile_default = {
37812
- ...toolInfo9,
37813
- handler: handler9,
37814
- isAvailable: isAvailable9
37929
+ ...toolInfo10,
37930
+ handler: handler10,
37931
+ isAvailable: isAvailable10
37815
37932
  };
37816
37933
  // ../core/src/tools/handOver.ts
37817
- var toolInfo10 = {
37934
+ var toolInfo11 = {
37818
37935
  name: "hand_over",
37819
37936
  description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
37820
37937
  parameters: [
@@ -37868,7 +37985,7 @@ var toolInfo10 = {
37868
37985
  ],
37869
37986
  permissionLevel: 0 /* None */
37870
37987
  };
37871
- var handler10 = async (_provider, args) => {
37988
+ var handler11 = async (_provider, args) => {
37872
37989
  const agentName = getString(args, "agent_name");
37873
37990
  const task = getString(args, "task");
37874
37991
  const context = getString(args, "context", undefined);
@@ -37881,16 +37998,16 @@ var handler10 = async (_provider, args) => {
37881
37998
  files
37882
37999
  };
37883
38000
  };
37884
- var isAvailable10 = (_provider) => {
38001
+ var isAvailable11 = (_provider) => {
37885
38002
  return true;
37886
38003
  };
37887
38004
  var handOver_default = {
37888
- ...toolInfo10,
37889
- handler: handler10,
37890
- isAvailable: isAvailable10
38005
+ ...toolInfo11,
38006
+ handler: handler11,
38007
+ isAvailable: isAvailable11
37891
38008
  };
37892
38009
  // ../core/src/tools/removeFile.ts
37893
- var toolInfo11 = {
38010
+ var toolInfo12 = {
37894
38011
  name: "remove_file",
37895
38012
  description: "Request to remove a file at the specified path.",
37896
38013
  parameters: [
@@ -37914,7 +38031,7 @@ var toolInfo11 = {
37914
38031
  ],
37915
38032
  permissionLevel: 2 /* Write */
37916
38033
  };
37917
- var handler11 = async (provider, args) => {
38034
+ var handler12 = async (provider, args) => {
37918
38035
  if (!provider.removeFile) {
37919
38036
  return {
37920
38037
  type: "Error" /* Error */,
@@ -37928,16 +38045,16 @@ var handler11 = async (provider, args) => {
37928
38045
  message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
37929
38046
  };
37930
38047
  };
37931
- var isAvailable11 = (provider) => {
38048
+ var isAvailable12 = (provider) => {
37932
38049
  return !!provider.removeFile;
37933
38050
  };
37934
38051
  var removeFile_default = {
37935
- ...toolInfo11,
37936
- handler: handler11,
37937
- isAvailable: isAvailable11
38052
+ ...toolInfo12,
38053
+ handler: handler12,
38054
+ isAvailable: isAvailable12
37938
38055
  };
37939
38056
  // ../core/src/tools/renameFile.ts
37940
- var toolInfo12 = {
38057
+ var toolInfo13 = {
37941
38058
  name: "rename_file",
37942
38059
  description: "Request to rename a file from source path to target path.",
37943
38060
  parameters: [
@@ -37971,7 +38088,7 @@ var toolInfo12 = {
37971
38088
  ],
37972
38089
  permissionLevel: 2 /* Write */
37973
38090
  };
37974
- var handler12 = async (provider, args) => {
38091
+ var handler13 = async (provider, args) => {
37975
38092
  if (!provider.renameFile) {
37976
38093
  return {
37977
38094
  type: "Error" /* Error */,
@@ -37986,16 +38103,16 @@ var handler12 = async (provider, args) => {
37986
38103
  message: `<rename_file_path>${targetPath}</rename_file_path><status>Success</status>`
37987
38104
  };
37988
38105
  };
37989
- var isAvailable12 = (provider) => {
38106
+ var isAvailable13 = (provider) => {
37990
38107
  return !!provider.renameFile;
37991
38108
  };
37992
38109
  var renameFile_default = {
37993
- ...toolInfo12,
37994
- handler: handler12,
37995
- isAvailable: isAvailable12
38110
+ ...toolInfo13,
38111
+ handler: handler13,
38112
+ isAvailable: isAvailable13
37996
38113
  };
37997
38114
  // ../core/src/tools/editFile.ts
37998
- var toolInfo13 = {
38115
+ var toolInfo14 = {
37999
38116
  name: "edit_file",
38000
38117
  description: "Request to edit file contents using search/replace operations. Supports multiple edit operations in a single call.",
38001
38118
  parameters: [
@@ -38111,7 +38228,7 @@ var toolInfo13 = {
38111
38228
  ],
38112
38229
  permissionLevel: 2 /* Write */
38113
38230
  };
38114
- var handler13 = async (provider, args) => {
38231
+ var handler14 = async (provider, args) => {
38115
38232
  if (!provider.readFile || !provider.writeFile) {
38116
38233
  return {
38117
38234
  type: "Error" /* Error */,
@@ -38147,127 +38264,10 @@ var handler13 = async (provider, args) => {
38147
38264
  };
38148
38265
  }
38149
38266
  };
38150
- var isAvailable13 = (provider) => {
38151
- return !!provider.readFile && !!provider.writeFile;
38152
- };
38153
- var editFile_default = {
38154
- ...toolInfo13,
38155
- handler: handler13,
38156
- isAvailable: isAvailable13
38157
- };
38158
- // ../core/src/tools/replaceInFile.ts
38159
- var toolInfo14 = {
38160
- name: "replace_in_file",
38161
- 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.",
38162
- parameters: [
38163
- {
38164
- name: "path",
38165
- description: "The path of the file to modify",
38166
- required: true,
38167
- usageValue: "File path here"
38168
- },
38169
- {
38170
- name: "diff",
38171
- description: `One or more SEARCH/REPLACE blocks following this exact format:
38172
- \`\`\`
38173
- <<<<<<< SEARCH
38174
- [exact content to find]
38175
- =======
38176
- [new content to replace with]
38177
- >>>>>>> REPLACE
38178
- \`\`\`
38179
- Critical rules:
38180
- 1. SEARCH content must match the associated file section to find EXACTLY:
38181
- * Match character-for-character including whitespace, indentation, line endings
38182
- * Include all comments, docstrings, etc.
38183
- 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
38184
- * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
38185
- * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
38186
- * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
38187
- 3. Keep SEARCH/REPLACE blocks concise:
38188
- * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
38189
- * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
38190
- * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
38191
- * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
38192
- 4. Special operations:
38193
- * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
38194
- * To delete code: Use empty REPLACE section`,
38195
- required: true,
38196
- usageValue: "Search and replace blocks here"
38197
- }
38198
- ],
38199
- examples: [
38200
- {
38201
- description: "Request to replace sections of content in a file",
38202
- parameters: [
38203
- {
38204
- name: "path",
38205
- value: "src/main.js"
38206
- },
38207
- {
38208
- name: "diff",
38209
- value: `
38210
- <<<<<<< SEARCH
38211
- import React from 'react';
38212
- =======
38213
- import React, { useState } from 'react';
38214
- >>>>>>> REPLACE
38215
-
38216
- <<<<<<< SEARCH
38217
- function handleSubmit() {
38218
- saveData();
38219
- setLoading(false);
38220
- }
38221
-
38222
- =======
38223
- >>>>>>> REPLACE
38224
-
38225
- <<<<<<< SEARCH
38226
- return (
38227
- <div>
38228
- =======
38229
- function handleSubmit() {
38230
- saveData();
38231
- setLoading(false);
38232
- }
38233
-
38234
- return (
38235
- <div>
38236
- >>>>>>> REPLACE
38237
- `
38238
- }
38239
- ]
38240
- }
38241
- ],
38242
- permissionLevel: 2 /* Write */
38243
- };
38244
- var handler14 = async (provider, args) => {
38245
- if (!provider.readFile || !provider.writeFile) {
38246
- return {
38247
- type: "Error" /* Error */,
38248
- message: "Not possible to replace in file. Abort."
38249
- };
38250
- }
38251
- const path = getString(args, "path");
38252
- const diff = getString(args, "diff");
38253
- const fileContent = await provider.readFile(path);
38254
- if (fileContent == null) {
38255
- return {
38256
- type: "Error" /* Error */,
38257
- message: `<error><replace_in_file_path>${path}</replace_in_file_path><error_message>File not found</error_message></error>`
38258
- };
38259
- }
38260
- const result = await replaceInFile(fileContent, diff);
38261
- await provider.writeFile(path, result);
38262
- return {
38263
- type: "Reply" /* Reply */,
38264
- message: `<replace_in_file_path>${path}</replace_in_file_path>`
38265
- };
38266
- };
38267
38267
  var isAvailable14 = (provider) => {
38268
38268
  return !!provider.readFile && !!provider.writeFile;
38269
38269
  };
38270
- var replaceInFile_default = {
38270
+ var editFile_default = {
38271
38271
  ...toolInfo14,
38272
38272
  handler: handler14,
38273
38273
  isAvailable: isAvailable14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.8.18",
3
+ "version": "0.8.19",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",