@polka-codes/runner 0.8.12 → 0.8.14

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 +50 -58
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -32748,7 +32748,7 @@ var {
32748
32748
  Help
32749
32749
  } = import__.default;
32750
32750
  // package.json
32751
- var version = "0.8.12";
32751
+ var version = "0.8.14";
32752
32752
 
32753
32753
  // src/runner.ts
32754
32754
  import { execSync } from "node:child_process";
@@ -42531,11 +42531,11 @@ var delegate_default = {
42531
42531
  // ../core/src/tools/executeCommand.ts
42532
42532
  var toolInfo4 = {
42533
42533
  name: "execute_command",
42534
- description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. After an `execute_command` call, no other tool calls are allowed in the same assistant response.",
42534
+ description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. **IMPORTANT**: After an `execute_command` call, you MUST stop and NOT allowed to make further tool calls in the same message.",
42535
42535
  parameters: [
42536
42536
  {
42537
42537
  name: "command",
42538
- description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.",
42538
+ description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.",
42539
42539
  required: true,
42540
42540
  usageValue: "your-command-here"
42541
42541
  },
@@ -43811,7 +43811,7 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
43811
43811
 
43812
43812
  TOOL USE
43813
43813
 
43814
- You have access to a set of tools that are executed upon the user's approval. You can use one tool per message, and will receive the result of that tool use in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
43814
+ You have access to a set of tools that are executed upon the user's approval. You can use up to 5 tool calls per message, and will receive the results of those tool uses in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
43815
43815
 
43816
43816
  # Tool Use Formatting
43817
43817
 
@@ -43877,18 +43877,16 @@ ${tools.map((tool) => {
43877
43877
 
43878
43878
  1. **Outline Your Thought Process**
43879
43879
  - 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.
43880
-
43881
43880
  2. **Wait for Feedback**
43882
43881
  - 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.
43883
-
43884
43882
  3. **Error Handling**
43885
43883
  - If a tool fails or produces an unexpected result, analyze the error, decide on an alternative approach or tool, and proceed carefully.
43886
-
43887
43884
  4. **Avoid Repetition**
43888
43885
  - Do not quote or repeat previous commands or prompts verbatim. Move the conversation forward by focusing on the latest required action.
43889
-
43890
43886
  5. **No Unnecessary Re-invocations**
43891
- - Only invoke the same tool again if a genuine need arises (e.g., different parameters or updated context).`;
43887
+ - Only invoke the same tool again if a genuine need arises (e.g., different parameters or updated context).
43888
+ 6. **Tool Call Limit**
43889
+ - Do not make more than 5 tool calls in a single message.`;
43892
43890
  };
43893
43891
  var agentsPrompt = (agents, name) => `
43894
43892
  ====
@@ -54238,14 +54236,8 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
54238
54236
 
54239
54237
  // ../cli-shared/src/utils/searchFiles.ts
54240
54238
  import { spawn } from "node:child_process";
54241
-
54242
- // ../../node_modules/@vscode/ripgrep/lib/index.js
54243
- var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/@vscode/ripgrep/lib";
54244
- var path = __require("path");
54245
- var $rgPath = path.join(__dirname, `../bin/rg${process.platform === "win32" ? ".exe" : ""}`);
54246
-
54247
- // ../cli-shared/src/utils/searchFiles.ts
54248
- async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
54239
+ import { rgPath } from "@vscode/ripgrep";
54240
+ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
54249
54241
  const args = [
54250
54242
  "--line-number",
54251
54243
  "--context=5",
@@ -54266,10 +54258,10 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
54266
54258
  args.push("--glob", `!${pattern}`);
54267
54259
  }
54268
54260
  }
54269
- args.push(regex, path2);
54261
+ args.push(regex, path);
54270
54262
  return new Promise((resolve2, reject) => {
54271
54263
  const results = [];
54272
- const rg = spawn($rgPath, args, {
54264
+ const rg = spawn(rgPath, args, {
54273
54265
  cwd,
54274
54266
  stdio: ["ignore", "pipe", "pipe"]
54275
54267
  });
@@ -54295,28 +54287,28 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
54295
54287
  var getProvider = (agentName, config2, options = {}) => {
54296
54288
  const ig = import_ignore2.default().add(options.excludeFiles ?? []);
54297
54289
  const provider2 = {
54298
- readFile: async (path2) => {
54299
- if (ig.ignores(path2)) {
54300
- throw new Error(`Not allow to access file ${path2}`);
54290
+ readFile: async (path) => {
54291
+ if (ig.ignores(path)) {
54292
+ throw new Error(`Not allow to access file ${path}`);
54301
54293
  }
54302
54294
  try {
54303
- return await readFile(path2, "utf8");
54295
+ return await readFile(path, "utf8");
54304
54296
  } catch (_e2) {
54305
54297
  return;
54306
54298
  }
54307
54299
  },
54308
- writeFile: async (path2, content) => {
54309
- if (ig.ignores(path2)) {
54310
- throw new Error(`Not allow to access file ${path2}`);
54300
+ writeFile: async (path, content) => {
54301
+ if (ig.ignores(path)) {
54302
+ throw new Error(`Not allow to access file ${path}`);
54311
54303
  }
54312
- await mkdir(dirname(path2), { recursive: true });
54313
- return await writeFile(path2, content, "utf8");
54304
+ await mkdir(dirname(path), { recursive: true });
54305
+ return await writeFile(path, content, "utf8");
54314
54306
  },
54315
- removeFile: async (path2) => {
54316
- if (ig.ignores(path2)) {
54317
- throw new Error(`Not allow to access file ${path2}`);
54307
+ removeFile: async (path) => {
54308
+ if (ig.ignores(path)) {
54309
+ throw new Error(`Not allow to access file ${path}`);
54318
54310
  }
54319
- return await unlink(path2);
54311
+ return await unlink(path);
54320
54312
  },
54321
54313
  renameFile: async (sourcePath, targetPath) => {
54322
54314
  if (ig.ignores(sourcePath) || ig.ignores(targetPath)) {
@@ -54324,11 +54316,11 @@ var getProvider = (agentName, config2, options = {}) => {
54324
54316
  }
54325
54317
  return await rename(sourcePath, targetPath);
54326
54318
  },
54327
- listFiles: async (path2, recursive, maxCount) => {
54328
- return await listFiles(path2, recursive, maxCount, process.cwd(), options.excludeFiles);
54319
+ listFiles: async (path, recursive, maxCount) => {
54320
+ return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
54329
54321
  },
54330
- searchFiles: async (path2, regex, filePattern) => {
54331
- return await searchFiles(path2, regex, filePattern, process.cwd(), options.excludeFiles);
54322
+ searchFiles: async (path, regex, filePattern) => {
54323
+ return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
54332
54324
  },
54333
54325
  executeCommand: (command, needApprove) => {
54334
54326
  return new Promise((resolve2, reject) => {
@@ -54747,8 +54739,8 @@ function getErrorMap3() {
54747
54739
  return overrideErrorMap3;
54748
54740
  }
54749
54741
  var makeIssue3 = (params) => {
54750
- const { data, path: path2, errorMaps, issueData } = params;
54751
- const fullPath = [...path2, ...issueData.path || []];
54742
+ const { data, path, errorMaps, issueData } = params;
54743
+ const fullPath = [...path, ...issueData.path || []];
54752
54744
  const fullIssue = {
54753
54745
  ...issueData,
54754
54746
  path: fullPath
@@ -54876,11 +54868,11 @@ var _ZodEnum_cache3;
54876
54868
  var _ZodNativeEnum_cache3;
54877
54869
 
54878
54870
  class ParseInputLazyPath3 {
54879
- constructor(parent, value, path2, key2) {
54871
+ constructor(parent, value, path, key2) {
54880
54872
  this._cachedPath = [];
54881
54873
  this.parent = parent;
54882
54874
  this.data = value;
54883
- this._path = path2;
54875
+ this._path = path;
54884
54876
  this._key = key2;
54885
54877
  }
54886
54878
  get path() {
@@ -58753,9 +58745,9 @@ class Runner {
58753
58745
  `).filter((line) => line.trim().length > 0);
58754
58746
  for (const line of lines2) {
58755
58747
  const statusCode = line.substring(0, 2);
58756
- const path2 = line.substring(3);
58748
+ const path = line.substring(3);
58757
58749
  if (statusCode.startsWith("R")) {
58758
- const parts = path2.split(" -> ");
58750
+ const parts = path.split(" -> ");
58759
58751
  if (parts.length === 2) {
58760
58752
  const [oldPath, newPath] = parts;
58761
58753
  changes.push({
@@ -58767,50 +58759,50 @@ class Runner {
58767
58759
  }
58768
58760
  }
58769
58761
  if (statusCode === "??") {
58770
- changes.push({ status: "added", path: path2 });
58762
+ changes.push({ status: "added", path });
58771
58763
  } else if (statusCode.includes("A")) {
58772
- changes.push({ status: "added", path: path2 });
58764
+ changes.push({ status: "added", path });
58773
58765
  } else if (statusCode.includes("M")) {
58774
- changes.push({ status: "modified", path: path2 });
58766
+ changes.push({ status: "modified", path });
58775
58767
  } else if (statusCode.includes("D")) {
58776
- changes.push({ status: "deleted", path: path2 });
58768
+ changes.push({ status: "deleted", path });
58777
58769
  }
58778
58770
  }
58779
58771
  return changes;
58780
58772
  }
58781
- async sendFileContent(path2) {
58773
+ async sendFileContent(path) {
58782
58774
  try {
58783
- const stat = await fs3.stat(path2).catch(() => null);
58775
+ const stat = await fs3.stat(path).catch(() => null);
58784
58776
  if (!stat) {
58785
- console.error(`File or directory not found: ${path2}`);
58777
+ console.error(`File or directory not found: ${path}`);
58786
58778
  return;
58787
58779
  }
58788
58780
  if (stat.isDirectory()) {
58789
- const [files] = await listFiles(path2, true, 1000, process.cwd());
58781
+ const [files] = await listFiles(path, true, 1000, process.cwd());
58790
58782
  for (const file of files) {
58791
58783
  await this.sendFileContent(file);
58792
58784
  }
58793
58785
  } else if (stat.isFile()) {
58794
- const content = await fs3.readFile(path2, "utf8");
58786
+ const content = await fs3.readFile(path, "utf8");
58795
58787
  this.wsManager.sendMessage({
58796
58788
  type: "file",
58797
- path: path2,
58789
+ path,
58798
58790
  content
58799
58791
  });
58800
- console.log(`Sent content for file: ${path2}`);
58792
+ console.log(`Sent content for file: ${path}`);
58801
58793
  } else {
58802
- console.error(`Path is not a file or directory: ${path2}`);
58794
+ console.error(`Path is not a file or directory: ${path}`);
58803
58795
  }
58804
58796
  } catch (error) {
58805
- console.error(`Error processing path ${path2}:`, error);
58797
+ console.error(`Error processing path ${path}:`, error);
58806
58798
  }
58807
58799
  }
58808
- sendFileDeleted(path2) {
58800
+ sendFileDeleted(path) {
58809
58801
  this.wsManager.sendMessage({
58810
58802
  type: "file_deleted",
58811
- path: path2
58803
+ path
58812
58804
  });
58813
- console.log(`Sent file_deleted for: ${path2}`);
58805
+ console.log(`Sent file_deleted for: ${path}`);
58814
58806
  }
58815
58807
  }
58816
58808
  async function runRunner(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.8.12",
3
+ "version": "0.8.14",
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"
17
+ "build": "bun build src/index.ts --outdir dist --target node --external=@vscode/ripgrep"
18
18
  },
19
19
  "dependencies": {
20
20
  "@polka-codes/cli-shared": "0.8.10",