@polka-codes/cli 0.8.19 → 0.8.21

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 +151 -259
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -38447,7 +38447,7 @@ var {
38447
38447
  Help
38448
38448
  } = import__.default;
38449
38449
  // package.json
38450
- var version = "0.8.19";
38450
+ var version = "0.8.21";
38451
38451
 
38452
38452
  // ../core/src/AiService/AiServiceBase.ts
38453
38453
  class AiServiceBase {
@@ -47758,39 +47758,6 @@ __export(exports_allTools, {
47758
47758
  askFollowupQuestion: () => askFollowupQuestion_default
47759
47759
  });
47760
47760
 
47761
- // ../core/src/tools/utils/editFile.ts
47762
- var START_OF_FILE = "<<<START_OF_FILE>>>";
47763
- var END_OF_FILE = "<<<END_OF_FILE>>>";
47764
- var editFile = async (fileContent, operations) => {
47765
- if (!operations || operations.length === 0) {
47766
- throw new Error("At least one edit operation is required");
47767
- }
47768
- let updatedContent = fileContent;
47769
- for (const operation of operations) {
47770
- updatedContent = await applyEditOperation(updatedContent, operation);
47771
- }
47772
- return updatedContent;
47773
- };
47774
- async function applyEditOperation(fileContent, operation) {
47775
- const { search, replace } = operation;
47776
- if (search === START_OF_FILE && replace === END_OF_FILE) {
47777
- throw new Error("Cannot search for START_OF_FILE and replace with END_OF_FILE");
47778
- }
47779
- if (search === END_OF_FILE && replace === START_OF_FILE) {
47780
- throw new Error("Cannot search for END_OF_FILE and replace with START_OF_FILE");
47781
- }
47782
- if (search === START_OF_FILE) {
47783
- return replace + fileContent;
47784
- }
47785
- if (search === END_OF_FILE) {
47786
- return fileContent + replace;
47787
- }
47788
- const index = fileContent.indexOf(search);
47789
- if (index === -1) {
47790
- throw new Error(`Could not find text: ${search}`);
47791
- }
47792
- return fileContent.slice(0, index) + replace + fileContent.slice(index + search.length);
47793
- }
47794
47761
  // ../core/src/tools/utils/getArg.ts
47795
47762
  var getString = (args, name, defaultValue) => {
47796
47763
  if (typeof args !== "object" || Array.isArray(args)) {
@@ -47884,7 +47851,7 @@ var getArray = (args, name, defaultValue) => {
47884
47851
  };
47885
47852
  // ../core/src/tools/utils/replaceInFile.ts
47886
47853
  var replaceInFile = async (fileContent, diff) => {
47887
- const blockPattern = /<<<<<+ SEARCH\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+ REPLACE/g;
47854
+ const blockPattern = /<<<<<+ SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+ REPLACE/g;
47888
47855
  const blocks = [];
47889
47856
  for (let match = blockPattern.exec(diff);match !== null; match = blockPattern.exec(diff)) {
47890
47857
  blocks.push({ search: match[1], replace: match[2] });
@@ -48397,29 +48364,29 @@ var toolInfo7 = {
48397
48364
  {
48398
48365
  name: "diff",
48399
48366
  description: `One or more SEARCH/REPLACE blocks following this exact format:
48400
- \`\`\`
48401
- <<<<<<< SEARCH
48402
- [exact content to find]
48403
- =======
48404
- [new content to replace with]
48405
- >>>>>>> REPLACE
48406
- \`\`\`
48407
- Critical rules:
48408
- 1. SEARCH content must match the associated file section to find EXACTLY:
48409
- * Match character-for-character including whitespace, indentation, line endings
48410
- * Include all comments, docstrings, etc.
48411
- 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
48412
- * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
48413
- * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
48414
- * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
48415
- 3. Keep SEARCH/REPLACE blocks concise:
48416
- * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
48417
- * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
48418
- * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
48419
- * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
48420
- 4. Special operations:
48421
- * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
48422
- * To delete code: Use empty REPLACE section`,
48367
+ \`\`\`
48368
+ <<<<<<< SEARCH
48369
+ [exact content to find]
48370
+ =======
48371
+ [new content to replace with]
48372
+ >>>>>>> REPLACE
48373
+ \`\`\`
48374
+ Critical rules:
48375
+ 1. SEARCH content must match the associated file section to find EXACTLY:
48376
+ * Match character-for-character including whitespace, indentation, line endings
48377
+ * Include all comments, docstrings, etc.
48378
+ 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
48379
+ * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
48380
+ * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
48381
+ * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
48382
+ 3. Keep SEARCH/REPLACE blocks concise:
48383
+ * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
48384
+ * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
48385
+ * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
48386
+ * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
48387
+ 4. Special operations:
48388
+ * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
48389
+ * To delete code: Use empty REPLACE section`,
48423
48390
  required: true,
48424
48391
  usageValue: "Search and replace blocks here"
48425
48392
  }
@@ -48462,6 +48429,73 @@ function handleSubmit() {
48462
48429
  return (
48463
48430
  <div>
48464
48431
  >>>>>>> REPLACE
48432
+ `
48433
+ }
48434
+ ]
48435
+ },
48436
+ {
48437
+ description: "Request to perform a simple, single-line replacement",
48438
+ parameters: [
48439
+ {
48440
+ name: "path",
48441
+ value: "src/config.js"
48442
+ },
48443
+ {
48444
+ name: "diff",
48445
+ value: `
48446
+ <<<<<<< SEARCH
48447
+ const API_URL = 'https://api.example.com';
48448
+ =======
48449
+ const API_URL = 'https://api.staging.example.com';
48450
+ >>>>>>> REPLACE
48451
+ `
48452
+ }
48453
+ ]
48454
+ },
48455
+ {
48456
+ description: "Request to add a new function to a file",
48457
+ parameters: [
48458
+ {
48459
+ name: "path",
48460
+ value: "src/utils.js"
48461
+ },
48462
+ {
48463
+ name: "diff",
48464
+ value: `
48465
+ <<<<<<< SEARCH
48466
+ function helperA() {
48467
+ // ...
48468
+ }
48469
+ =======
48470
+ function helperA() {
48471
+ // ...
48472
+ }
48473
+
48474
+ function newHelper() {
48475
+ // implementation
48476
+ }
48477
+ >>>>>>> REPLACE
48478
+ `
48479
+ }
48480
+ ]
48481
+ },
48482
+ {
48483
+ description: "Request to delete a block of code from a file",
48484
+ parameters: [
48485
+ {
48486
+ name: "path",
48487
+ value: "src/app.js"
48488
+ },
48489
+ {
48490
+ name: "diff",
48491
+ value: `
48492
+ <<<<<<< SEARCH
48493
+ function oldFeature() {
48494
+ // This is no longer needed
48495
+ }
48496
+
48497
+ =======
48498
+ >>>>>>> REPLACE
48465
48499
  `
48466
48500
  }
48467
48501
  ]
@@ -49086,167 +49120,6 @@ var renameFile_default = {
49086
49120
  handler: handler13,
49087
49121
  isAvailable: isAvailable13
49088
49122
  };
49089
- // ../core/src/tools/editFile.ts
49090
- var toolInfo14 = {
49091
- name: "edit_file",
49092
- description: "Request to edit file contents using search/replace operations. Supports multiple edit operations in a single call.",
49093
- parameters: [
49094
- {
49095
- name: "path",
49096
- description: "The path of the file to edit",
49097
- required: true,
49098
- usageValue: "File path here"
49099
- },
49100
- {
49101
- name: "operations",
49102
- description: "Edit operation with search and replace parameters",
49103
- required: true,
49104
- allowMultiple: true,
49105
- children: [
49106
- {
49107
- name: "search",
49108
- description: `Text to search for and replace (use ${START_OF_FILE} to insert at file start, ${END_OF_FILE} to insert at file end)`,
49109
- required: true,
49110
- usageValue: "Text to find and replace"
49111
- },
49112
- {
49113
- name: "replace",
49114
- description: "Text to replace the search text with",
49115
- required: true,
49116
- usageValue: "Replacement text"
49117
- }
49118
- ],
49119
- usageValue: "operations here"
49120
- }
49121
- ],
49122
- examples: [
49123
- {
49124
- description: "Replace specific text",
49125
- parameters: [
49126
- {
49127
- name: "path",
49128
- value: "src/main.ts"
49129
- },
49130
- {
49131
- name: "operations",
49132
- value: {
49133
- search: `function oldFunction() {
49134
- return 42;
49135
- }`,
49136
- replace: `function newFunction() {
49137
- return "new implementation";
49138
- }`
49139
- }
49140
- }
49141
- ]
49142
- },
49143
- {
49144
- description: "Insert at start of file",
49145
- parameters: [
49146
- {
49147
- name: "path",
49148
- value: "src/header.ts"
49149
- },
49150
- {
49151
- name: "operations",
49152
- value: {
49153
- search: START_OF_FILE,
49154
- replace: `// File header comment
49155
- `
49156
- }
49157
- }
49158
- ]
49159
- },
49160
- {
49161
- description: "Multiple operations in one call",
49162
- parameters: [
49163
- {
49164
- name: "path",
49165
- value: "src/utils.ts"
49166
- },
49167
- {
49168
- name: "operations",
49169
- value: [
49170
- {
49171
- search: 'import React from "react"',
49172
- replace: 'import React, { useState } from "react"'
49173
- },
49174
- {
49175
- search: `function Component() {
49176
- return (`,
49177
- replace: `function Component() {
49178
- const [state, setState] = useState(false);
49179
- return (`
49180
- }
49181
- ]
49182
- }
49183
- ]
49184
- },
49185
- {
49186
- description: "Append content at end of file",
49187
- parameters: [
49188
- {
49189
- name: "path",
49190
- value: "src/footer.ts"
49191
- },
49192
- {
49193
- name: "operations",
49194
- value: {
49195
- search: END_OF_FILE,
49196
- replace: `
49197
- // End of file appended comment
49198
- `
49199
- }
49200
- }
49201
- ]
49202
- }
49203
- ],
49204
- permissionLevel: 2 /* Write */
49205
- };
49206
- var handler14 = async (provider, args) => {
49207
- if (!provider.readFile || !provider.writeFile) {
49208
- return {
49209
- type: "Error" /* Error */,
49210
- message: "Not possible to edit file. Abort."
49211
- };
49212
- }
49213
- const path = getString(args, "path");
49214
- const operations = getArray(args, "operations");
49215
- if (!operations || operations.length === 0) {
49216
- return {
49217
- type: "Error" /* Error */,
49218
- message: `<error><edit_file_path>${path}</edit_file_path><error_message>At least one edit operation is required</error_message></error>`
49219
- };
49220
- }
49221
- const fileContent = await provider.readFile(path);
49222
- if (fileContent == null) {
49223
- return {
49224
- type: "Error" /* Error */,
49225
- message: `<error><edit_file_path>${path}</edit_file_path><error_message>File not found</error_message></error>`
49226
- };
49227
- }
49228
- try {
49229
- const result = await editFile(fileContent, operations);
49230
- await provider.writeFile(path, result);
49231
- return {
49232
- type: "Reply" /* Reply */,
49233
- message: `<edit_file_path>${path}</edit_file_path>`
49234
- };
49235
- } catch (error) {
49236
- return {
49237
- type: "Error" /* Error */,
49238
- message: `<error><edit_file_path>${path}</edit_file_path><error_message>${error instanceof Error ? error.message : String(error)}</error_message></error>`
49239
- };
49240
- }
49241
- };
49242
- var isAvailable14 = (provider) => {
49243
- return !!provider.readFile && !!provider.writeFile;
49244
- };
49245
- var editFile_default = {
49246
- ...toolInfo14,
49247
- handler: handler14,
49248
- isAvailable: isAvailable14
49249
- };
49250
49123
  // ../core/src/getAvailableTools.ts
49251
49124
  var getAvailableTools = ({
49252
49125
  provider: provider2,
@@ -49471,6 +49344,8 @@ Tool use is formatted using XML-style tags. The tool name is enclosed in opening
49471
49344
  ...
49472
49345
  </${toolNamePrefix}tool_name>
49473
49346
 
49347
+ **It is crucial that all tags are correctly nested and closed.**
49348
+
49474
49349
  ## Array Parameters
49475
49350
 
49476
49351
  To create an array of values for a parameter, repeat the parameter tag multiple times:
@@ -49505,7 +49380,7 @@ You can also combine array parameters with nested objects:
49505
49380
  </${parameterPrefix}key>
49506
49381
  </${toolNamePrefix}example_tool>
49507
49382
 
49508
- Always adhere to this format for the tool use to ensure proper parsing and execution.
49383
+ Always adhere to this format, ensuring every opening tag has a matching closing tag, to ensure proper parsing and execution.
49509
49384
 
49510
49385
  NEVER surround tool use with triple backticks (\`\`\`).
49511
49386
 
@@ -49523,18 +49398,14 @@ ${tools.map((tool) => {
49523
49398
  }).join("")}
49524
49399
  # Tool Use Guidelines
49525
49400
 
49526
- 1. **Outline Your Thought Process**
49527
- - Before using a tool, wrap your reasoning inside \`<thinking>\` tags. Be concise—just enough to clarify your plan and the rationale behind selecting a specific tool.
49528
- 2. **Wait for Feedback**
49401
+ 1. **Wait for Feedback**
49529
49402
  - After using a tool, wait for the user's response indicating success/failure or any output logs. Do not assume the result of a tool without explicit confirmation.
49530
- 3. **Error Handling**
49403
+ 2. **Error Handling**
49531
49404
  - If a tool fails or produces an unexpected result, analyze the error, decide on an alternative approach or tool, and proceed carefully.
49532
- 4. **Avoid Repetition**
49405
+ 3. **Avoid Repetition**
49533
49406
  - Do not quote or repeat previous commands or prompts verbatim. Move the conversation forward by focusing on the latest required action.
49534
- 5. **No Unnecessary Re-invocations**
49535
- - Only invoke the same tool again if a genuine need arises (e.g., different parameters or updated context).
49536
- 6. **Tool Call Limit**
49537
- - Do not make more than 5 tool calls in a single message.`;
49407
+ 4. **Tool Call Limit**
49408
+ - It is **STRIGHTLY FORBIDDEN** to make more than 5 tool calls in a single message.`;
49538
49409
  };
49539
49410
  var agentsPrompt = (agents, name) => `
49540
49411
  ====
@@ -49848,8 +49719,8 @@ ${instance.prompt}`;
49848
49719
  }
49849
49720
  async#invokeTool(name, args) {
49850
49721
  try {
49851
- const handler15 = this.handlers[name]?.handler;
49852
- if (!handler15) {
49722
+ const handler14 = this.handlers[name]?.handler;
49723
+ if (!handler14) {
49853
49724
  return {
49854
49725
  type: "Error" /* Error */,
49855
49726
  message: responsePrompts.errorInvokeTool(name, "Tool not found"),
@@ -49868,7 +49739,7 @@ ${instance.prompt}`;
49868
49739
  if (resp) {
49869
49740
  return resp;
49870
49741
  }
49871
- return await handler15(this.config.provider, args);
49742
+ return await handler14(this.config.provider, args);
49872
49743
  } catch (error) {
49873
49744
  return {
49874
49745
  type: "Error" /* Error */,
@@ -50207,7 +50078,7 @@ var editingFilesPrompt = (toolNamePrefix) => `
50207
50078
 
50208
50079
  EDITING FILES
50209
50080
 
50210
- You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full overwrite) and **${toolNamePrefix}edit_file** (targeted anchor-based edits). Choose the smallest safe operation for every change.
50081
+ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full overwrite) and **${toolNamePrefix}replace_in_file** (targeted anchor-based edits). Choose the smallest safe operation for every change.
50211
50082
 
50212
50083
  # ${toolNamePrefix}write_to_file
50213
50084
 
@@ -50219,16 +50090,16 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
50219
50090
 
50220
50091
  - Initial file creation, such as when scaffolding a new project.
50221
50092
  - Overwriting large boilerplate files where you want to replace the entire content at once.
50222
- - When the complexity or number of changes would make ${toolNamePrefix}edit_file unwieldy or error-prone.
50093
+ - When the complexity or number of changes would make ${toolNamePrefix}replace_in_file unwieldy or error-prone.
50223
50094
  - When you need to completely restructure a file's content or change its fundamental organization.
50224
50095
 
50225
50096
  ## Important Considerations
50226
50097
 
50227
50098
  - Using ${toolNamePrefix}write_to_file requires providing the file's complete final content.
50228
- - If you only need to make small changes to an existing file, consider using ${toolNamePrefix}edit_file instead to avoid unnecessarily rewriting the entire file.
50099
+ - If you only need to make small changes to an existing file, consider using ${toolNamePrefix}replace_in_file instead to avoid unnecessarily rewriting the entire file.
50229
50100
  - While ${toolNamePrefix}write_to_file should not be your default choice, don't hesitate to use it when the situation truly calls for it.
50230
50101
 
50231
- # ${toolNamePrefix}edit_file
50102
+ # ${toolNamePrefix}replace_in_file
50232
50103
 
50233
50104
  ## Purpose
50234
50105
 
@@ -50247,10 +50118,10 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
50247
50118
 
50248
50119
  # Choosing the Appropriate Tool
50249
50120
 
50250
- - **Default to ${toolNamePrefix}edit_file** for most changes. It keeps diffs small and reduces risk.
50121
+ - **Default to ${toolNamePrefix}replace_in_file** for most changes. It keeps diffs small and reduces risk.
50251
50122
  - **Use ${toolNamePrefix}write_to_file** when:
50252
50123
  - Creating new files
50253
- - The changes are so extensive that using ${toolNamePrefix}edit_file would be more complex or risky
50124
+ - The changes are so extensive that using ${toolNamePrefix}replace_in_file would be more complex or risky
50254
50125
  - You need to completely reorganize or restructure a file
50255
50126
  - The file is relatively small and the changes affect most of its content
50256
50127
  - You're generating boilerplate or template files
@@ -50258,9 +50129,9 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
50258
50129
  # Workflow Tips
50259
50130
 
50260
50131
  1. Before editing, assess the scope of your changes and decide which tool to use.
50261
- 2. For targeted edits, apply ${toolNamePrefix}edit_file with carefully crafted before/after text anchors. If you need multiple changes, you can stack multiple operations within a single ${toolNamePrefix}edit_file call.
50132
+ 2. For targeted edits, apply ${toolNamePrefix}replace_in_file with carefully crafted before/after text anchors. If you need multiple changes, you can stack multiple operations within a single ${toolNamePrefix}replace_in_file call.
50262
50133
  3. For major overhauls or initial file creation, rely on ${toolNamePrefix}write_to_file.
50263
- 4. Once the file has been edited with either ${toolNamePrefix}write_to_file or ${toolNamePrefix}edit_file, the system will provide you with the final state of the modified file. Use this updated content as the reference point for any subsequent operations, since it reflects any auto-formatting or user-applied changes.
50134
+ 4. Once the file has been edited with either ${toolNamePrefix}write_to_file or ${toolNamePrefix}replace_in_file, the system will provide you with the final state of the modified file. Use this updated content as the reference point for any subsequent operations, since it reflects any auto-formatting or user-applied changes.
50264
50135
 
50265
50136
  Picking the right tool keeps edits minimal, safe, and easy to review.
50266
50137
  `;
@@ -50274,10 +50145,10 @@ RULES
50274
50145
  For text files (e.g. README.md), append a footer with the same notice.
50275
50146
  - Never describe what changed inside code comments; comments must focus on purpose or usage only.
50276
50147
  - Before using ${toolNamePrefix}execute_command, consider SYSTEM INFORMATION to ensure commands suit the user's OS. If a command must run in a subdirectory, prepend a single \`cd childDir &&\` segment.
50277
- - Use ${toolNamePrefix}search_files for broad analysis, then ${toolNamePrefix}read_file to inspect context, and finally ${toolNamePrefix}edit_file or ${toolNamePrefix}write_to_file to modify.
50278
- - Prefer ${toolNamePrefix}edit_file for focused edits; choose ${toolNamePrefix}write_to_file for new files or complete rewrites.
50148
+ - Use ${toolNamePrefix}search_files for broad analysis, then ${toolNamePrefix}read_file to inspect context, and finally ${toolNamePrefix}replace_in_file or ${toolNamePrefix}write_to_file to modify.
50149
+ - Prefer ${toolNamePrefix}replace_in_file for focused edits; choose ${toolNamePrefix}write_to_file for new files or complete rewrites.
50279
50150
  - When creating a new file, look for existing files with similar content or patterns; if found, read them and use their structure or conventions as a reference.
50280
- - Use before/after text anchors in ${toolNamePrefix}edit_file to target changes. If multiple operations are needed, list them in file order.
50151
+ - Use before/after text anchors in ${toolNamePrefix}replace_in_file to target changes. If multiple operations are needed, list them in file order.
50281
50152
  - Do not guess unseen content. Read existing files first unless creating new ones.
50282
50153
  - Follow existing style, lint, and naming conventions. Ensure all changes compile and pass tests where applicable.
50283
50154
  - ALWAYS wait for the user's confirmation after each tool call before starting the next step.
@@ -59772,15 +59643,15 @@ function useKeypress(userHandler) {
59772
59643
  signal.current = userHandler;
59773
59644
  useEffect((rl) => {
59774
59645
  let ignore = false;
59775
- const handler15 = withUpdates((_input, event) => {
59646
+ const handler14 = withUpdates((_input, event) => {
59776
59647
  if (ignore)
59777
59648
  return;
59778
59649
  signal.current(event, rl);
59779
59650
  });
59780
- rl.input.on("keypress", handler15);
59651
+ rl.input.on("keypress", handler14);
59781
59652
  return () => {
59782
59653
  ignore = true;
59783
- rl.input.removeListener("keypress", handler15);
59654
+ rl.input.removeListener("keypress", handler14);
59784
59655
  };
59785
59656
  }, []);
59786
59657
  }
@@ -59962,16 +59833,16 @@ class Emitter {
59962
59833
 
59963
59834
  class SignalExitBase {
59964
59835
  }
59965
- var signalExitWrap = (handler15) => {
59836
+ var signalExitWrap = (handler14) => {
59966
59837
  return {
59967
59838
  onExit(cb, opts) {
59968
- return handler15.onExit(cb, opts);
59839
+ return handler14.onExit(cb, opts);
59969
59840
  },
59970
59841
  load() {
59971
- return handler15.load();
59842
+ return handler14.load();
59972
59843
  },
59973
59844
  unload() {
59974
- return handler15.unload();
59845
+ return handler14.unload();
59975
59846
  }
59976
59847
  };
59977
59848
  };
@@ -60579,6 +60450,24 @@ ${theme.style.description(selectedChoice.description)}` : ``;
60579
60450
  return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
60580
60451
  ${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes3.default.cursorHide}`;
60581
60452
  });
60453
+ // ../cli-shared/src/utils/checkRipgrep.ts
60454
+ import { spawnSync } from "node:child_process";
60455
+ var rgAvailability = {
60456
+ isAvailable: null
60457
+ };
60458
+ function checkRipgrep() {
60459
+ if (rgAvailability.isAvailable !== null) {
60460
+ return rgAvailability.isAvailable;
60461
+ }
60462
+ const rg = spawnSync("rg", ["--version"]);
60463
+ if (rg.error || rg.status !== 0) {
60464
+ rgAvailability.isAvailable = false;
60465
+ return false;
60466
+ }
60467
+ rgAvailability.isAvailable = true;
60468
+ return true;
60469
+ }
60470
+
60582
60471
  // ../cli-shared/src/utils/listFiles.ts
60583
60472
  var import_ignore = __toESM(require_ignore(), 1);
60584
60473
  import { promises as fs2 } from "node:fs";
@@ -60676,7 +60565,6 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
60676
60565
 
60677
60566
  // ../cli-shared/src/utils/searchFiles.ts
60678
60567
  import { spawn } from "node:child_process";
60679
- import { rgPath } from "@vscode/ripgrep";
60680
60568
  async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
60681
60569
  const args = [
60682
60570
  "--line-number",
@@ -60701,7 +60589,7 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
60701
60589
  args.push(regex, path);
60702
60590
  return new Promise((resolve2, reject) => {
60703
60591
  const results = [];
60704
- const rg = spawn(rgPath, args, {
60592
+ const rg = spawn("rg", args, {
60705
60593
  cwd,
60706
60594
  stdio: ["ignore", "pipe", "pipe"]
60707
60595
  });
@@ -60759,9 +60647,6 @@ var getProvider = (agentName, config2, options = {}) => {
60759
60647
  listFiles: async (path, recursive, maxCount) => {
60760
60648
  return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
60761
60649
  },
60762
- searchFiles: async (path, regex, filePattern) => {
60763
- return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
60764
- },
60765
60650
  executeCommand: (command, needApprove) => {
60766
60651
  return new Promise((resolve2, reject) => {
60767
60652
  options.command?.onStarted(command);
@@ -60817,6 +60702,13 @@ var getProvider = (agentName, config2, options = {}) => {
60817
60702
  return;
60818
60703
  }
60819
60704
  };
60705
+ if (checkRipgrep()) {
60706
+ provider2.searchFiles = async (path, regex, filePattern) => {
60707
+ return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
60708
+ };
60709
+ } else {
60710
+ console.error("Error: ripgrep (rg) is not installed. Search file tool is disabled. Please install it from https://github.com/BurntSushi/ripgrep#installation");
60711
+ }
60820
60712
  return provider2;
60821
60713
  };
60822
60714
  // ../../node_modules/chalk/source/vendor/ansi-styles/index.js
@@ -61858,7 +61750,7 @@ var runChat = async (opts, command) => {
61858
61750
  };
61859
61751
 
61860
61752
  // src/commands/commit.ts
61861
- import { execSync, spawnSync } from "node:child_process";
61753
+ import { execSync, spawnSync as spawnSync2 } from "node:child_process";
61862
61754
 
61863
61755
  // ../../node_modules/ora/index.js
61864
61756
  import process10 from "node:process";
@@ -62515,7 +62407,7 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
62515
62407
  Commit message:
62516
62408
  ${result.response}`);
62517
62409
  try {
62518
- spawnSync("git", ["commit", "-m", result.response], { stdio: "inherit" });
62410
+ spawnSync2("git", ["commit", "-m", result.response], { stdio: "inherit" });
62519
62411
  } catch {
62520
62412
  console.error("Error: Commit failed");
62521
62413
  process.exit(1);
@@ -66631,7 +66523,7 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
66631
66523
  });
66632
66524
 
66633
66525
  // src/commands/pr.ts
66634
- import { execSync as execSync2, spawnSync as spawnSync2 } from "node:child_process";
66526
+ import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
66635
66527
  var prCommand = new Command("pr").description("Create a GitHub pull request").argument("[message]", "Optional context for the commit message generation").action(async (message, _options, command) => {
66636
66528
  const options = command.parent?.opts() ?? {};
66637
66529
  const { providerConfig, config: config3 } = parseOptions(options);
@@ -66691,7 +66583,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
66691
66583
  console.log("Title:", prDetails.response.title);
66692
66584
  console.log(prDetails.response.description);
66693
66585
  await new Promise((resolve2) => setTimeout(resolve2, 10));
66694
- spawnSync2("gh", ["pr", "create", "--title", prDetails.response.title.trim(), "--body", prDetails.response.description.trim()], {
66586
+ spawnSync3("gh", ["pr", "create", "--title", prDetails.response.title.trim(), "--body", prDetails.response.description.trim()], {
66695
66587
  stdio: "inherit"
66696
66588
  });
66697
66589
  usage.printUsage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.8.19",
3
+ "version": "0.8.21",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  }
15
15
  },
16
16
  "scripts": {
17
- "build": "bun build src/index.ts --outdir dist --target node --external=@vscode/ripgrep"
17
+ "build": "bun build src/index.ts --outdir dist --target node"
18
18
  },
19
19
  "dependencies": {
20
20
  "@inquirer/prompts": "^7.2.3",