@polka-codes/runner 0.8.13 → 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 +44 -50
  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.13";
32751
+ var version = "0.8.14";
32752
32752
 
32753
32753
  // src/runner.ts
32754
32754
  import { execSync } from "node:child_process";
@@ -54236,14 +54236,8 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
54236
54236
 
54237
54237
  // ../cli-shared/src/utils/searchFiles.ts
54238
54238
  import { spawn } from "node:child_process";
54239
-
54240
- // ../../node_modules/@vscode/ripgrep/lib/index.js
54241
- var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/@vscode/ripgrep/lib";
54242
- var path = __require("path");
54243
- var $rgPath = path.join(__dirname, `../bin/rg${process.platform === "win32" ? ".exe" : ""}`);
54244
-
54245
- // ../cli-shared/src/utils/searchFiles.ts
54246
- async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
54239
+ import { rgPath } from "@vscode/ripgrep";
54240
+ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
54247
54241
  const args = [
54248
54242
  "--line-number",
54249
54243
  "--context=5",
@@ -54264,10 +54258,10 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
54264
54258
  args.push("--glob", `!${pattern}`);
54265
54259
  }
54266
54260
  }
54267
- args.push(regex, path2);
54261
+ args.push(regex, path);
54268
54262
  return new Promise((resolve2, reject) => {
54269
54263
  const results = [];
54270
- const rg = spawn($rgPath, args, {
54264
+ const rg = spawn(rgPath, args, {
54271
54265
  cwd,
54272
54266
  stdio: ["ignore", "pipe", "pipe"]
54273
54267
  });
@@ -54293,28 +54287,28 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
54293
54287
  var getProvider = (agentName, config2, options = {}) => {
54294
54288
  const ig = import_ignore2.default().add(options.excludeFiles ?? []);
54295
54289
  const provider2 = {
54296
- readFile: async (path2) => {
54297
- if (ig.ignores(path2)) {
54298
- 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}`);
54299
54293
  }
54300
54294
  try {
54301
- return await readFile(path2, "utf8");
54295
+ return await readFile(path, "utf8");
54302
54296
  } catch (_e2) {
54303
54297
  return;
54304
54298
  }
54305
54299
  },
54306
- writeFile: async (path2, content) => {
54307
- if (ig.ignores(path2)) {
54308
- 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}`);
54309
54303
  }
54310
- await mkdir(dirname(path2), { recursive: true });
54311
- return await writeFile(path2, content, "utf8");
54304
+ await mkdir(dirname(path), { recursive: true });
54305
+ return await writeFile(path, content, "utf8");
54312
54306
  },
54313
- removeFile: async (path2) => {
54314
- if (ig.ignores(path2)) {
54315
- 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}`);
54316
54310
  }
54317
- return await unlink(path2);
54311
+ return await unlink(path);
54318
54312
  },
54319
54313
  renameFile: async (sourcePath, targetPath) => {
54320
54314
  if (ig.ignores(sourcePath) || ig.ignores(targetPath)) {
@@ -54322,11 +54316,11 @@ var getProvider = (agentName, config2, options = {}) => {
54322
54316
  }
54323
54317
  return await rename(sourcePath, targetPath);
54324
54318
  },
54325
- listFiles: async (path2, recursive, maxCount) => {
54326
- 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);
54327
54321
  },
54328
- searchFiles: async (path2, regex, filePattern) => {
54329
- 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);
54330
54324
  },
54331
54325
  executeCommand: (command, needApprove) => {
54332
54326
  return new Promise((resolve2, reject) => {
@@ -54745,8 +54739,8 @@ function getErrorMap3() {
54745
54739
  return overrideErrorMap3;
54746
54740
  }
54747
54741
  var makeIssue3 = (params) => {
54748
- const { data, path: path2, errorMaps, issueData } = params;
54749
- const fullPath = [...path2, ...issueData.path || []];
54742
+ const { data, path, errorMaps, issueData } = params;
54743
+ const fullPath = [...path, ...issueData.path || []];
54750
54744
  const fullIssue = {
54751
54745
  ...issueData,
54752
54746
  path: fullPath
@@ -54874,11 +54868,11 @@ var _ZodEnum_cache3;
54874
54868
  var _ZodNativeEnum_cache3;
54875
54869
 
54876
54870
  class ParseInputLazyPath3 {
54877
- constructor(parent, value, path2, key2) {
54871
+ constructor(parent, value, path, key2) {
54878
54872
  this._cachedPath = [];
54879
54873
  this.parent = parent;
54880
54874
  this.data = value;
54881
- this._path = path2;
54875
+ this._path = path;
54882
54876
  this._key = key2;
54883
54877
  }
54884
54878
  get path() {
@@ -58751,9 +58745,9 @@ class Runner {
58751
58745
  `).filter((line) => line.trim().length > 0);
58752
58746
  for (const line of lines2) {
58753
58747
  const statusCode = line.substring(0, 2);
58754
- const path2 = line.substring(3);
58748
+ const path = line.substring(3);
58755
58749
  if (statusCode.startsWith("R")) {
58756
- const parts = path2.split(" -> ");
58750
+ const parts = path.split(" -> ");
58757
58751
  if (parts.length === 2) {
58758
58752
  const [oldPath, newPath] = parts;
58759
58753
  changes.push({
@@ -58765,50 +58759,50 @@ class Runner {
58765
58759
  }
58766
58760
  }
58767
58761
  if (statusCode === "??") {
58768
- changes.push({ status: "added", path: path2 });
58762
+ changes.push({ status: "added", path });
58769
58763
  } else if (statusCode.includes("A")) {
58770
- changes.push({ status: "added", path: path2 });
58764
+ changes.push({ status: "added", path });
58771
58765
  } else if (statusCode.includes("M")) {
58772
- changes.push({ status: "modified", path: path2 });
58766
+ changes.push({ status: "modified", path });
58773
58767
  } else if (statusCode.includes("D")) {
58774
- changes.push({ status: "deleted", path: path2 });
58768
+ changes.push({ status: "deleted", path });
58775
58769
  }
58776
58770
  }
58777
58771
  return changes;
58778
58772
  }
58779
- async sendFileContent(path2) {
58773
+ async sendFileContent(path) {
58780
58774
  try {
58781
- const stat = await fs3.stat(path2).catch(() => null);
58775
+ const stat = await fs3.stat(path).catch(() => null);
58782
58776
  if (!stat) {
58783
- console.error(`File or directory not found: ${path2}`);
58777
+ console.error(`File or directory not found: ${path}`);
58784
58778
  return;
58785
58779
  }
58786
58780
  if (stat.isDirectory()) {
58787
- const [files] = await listFiles(path2, true, 1000, process.cwd());
58781
+ const [files] = await listFiles(path, true, 1000, process.cwd());
58788
58782
  for (const file of files) {
58789
58783
  await this.sendFileContent(file);
58790
58784
  }
58791
58785
  } else if (stat.isFile()) {
58792
- const content = await fs3.readFile(path2, "utf8");
58786
+ const content = await fs3.readFile(path, "utf8");
58793
58787
  this.wsManager.sendMessage({
58794
58788
  type: "file",
58795
- path: path2,
58789
+ path,
58796
58790
  content
58797
58791
  });
58798
- console.log(`Sent content for file: ${path2}`);
58792
+ console.log(`Sent content for file: ${path}`);
58799
58793
  } else {
58800
- console.error(`Path is not a file or directory: ${path2}`);
58794
+ console.error(`Path is not a file or directory: ${path}`);
58801
58795
  }
58802
58796
  } catch (error) {
58803
- console.error(`Error processing path ${path2}:`, error);
58797
+ console.error(`Error processing path ${path}:`, error);
58804
58798
  }
58805
58799
  }
58806
- sendFileDeleted(path2) {
58800
+ sendFileDeleted(path) {
58807
58801
  this.wsManager.sendMessage({
58808
58802
  type: "file_deleted",
58809
- path: path2
58803
+ path
58810
58804
  });
58811
- console.log(`Sent file_deleted for: ${path2}`);
58805
+ console.log(`Sent file_deleted for: ${path}`);
58812
58806
  }
58813
58807
  }
58814
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.13",
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",