@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.
- package/dist/index.js +44 -50
- 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.
|
|
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
|
-
|
|
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,
|
|
54261
|
+
args.push(regex, path);
|
|
54268
54262
|
return new Promise((resolve2, reject) => {
|
|
54269
54263
|
const results = [];
|
|
54270
|
-
const rg = spawn(
|
|
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 (
|
|
54297
|
-
if (ig.ignores(
|
|
54298
|
-
throw new Error(`Not allow to access file ${
|
|
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(
|
|
54295
|
+
return await readFile(path, "utf8");
|
|
54302
54296
|
} catch (_e2) {
|
|
54303
54297
|
return;
|
|
54304
54298
|
}
|
|
54305
54299
|
},
|
|
54306
|
-
writeFile: async (
|
|
54307
|
-
if (ig.ignores(
|
|
54308
|
-
throw new Error(`Not allow to access file ${
|
|
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(
|
|
54311
|
-
return await writeFile(
|
|
54304
|
+
await mkdir(dirname(path), { recursive: true });
|
|
54305
|
+
return await writeFile(path, content, "utf8");
|
|
54312
54306
|
},
|
|
54313
|
-
removeFile: async (
|
|
54314
|
-
if (ig.ignores(
|
|
54315
|
-
throw new Error(`Not allow to access file ${
|
|
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(
|
|
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 (
|
|
54326
|
-
return await listFiles(
|
|
54319
|
+
listFiles: async (path, recursive, maxCount) => {
|
|
54320
|
+
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
54327
54321
|
},
|
|
54328
|
-
searchFiles: async (
|
|
54329
|
-
return await searchFiles(
|
|
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
|
|
54749
|
-
const fullPath = [...
|
|
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,
|
|
54871
|
+
constructor(parent, value, path, key2) {
|
|
54878
54872
|
this._cachedPath = [];
|
|
54879
54873
|
this.parent = parent;
|
|
54880
54874
|
this.data = value;
|
|
54881
|
-
this._path =
|
|
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
|
|
58748
|
+
const path = line.substring(3);
|
|
58755
58749
|
if (statusCode.startsWith("R")) {
|
|
58756
|
-
const parts =
|
|
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
|
|
58762
|
+
changes.push({ status: "added", path });
|
|
58769
58763
|
} else if (statusCode.includes("A")) {
|
|
58770
|
-
changes.push({ status: "added", path
|
|
58764
|
+
changes.push({ status: "added", path });
|
|
58771
58765
|
} else if (statusCode.includes("M")) {
|
|
58772
|
-
changes.push({ status: "modified", path
|
|
58766
|
+
changes.push({ status: "modified", path });
|
|
58773
58767
|
} else if (statusCode.includes("D")) {
|
|
58774
|
-
changes.push({ status: "deleted", path
|
|
58768
|
+
changes.push({ status: "deleted", path });
|
|
58775
58769
|
}
|
|
58776
58770
|
}
|
|
58777
58771
|
return changes;
|
|
58778
58772
|
}
|
|
58779
|
-
async sendFileContent(
|
|
58773
|
+
async sendFileContent(path) {
|
|
58780
58774
|
try {
|
|
58781
|
-
const stat = await fs3.stat(
|
|
58775
|
+
const stat = await fs3.stat(path).catch(() => null);
|
|
58782
58776
|
if (!stat) {
|
|
58783
|
-
console.error(`File or directory not found: ${
|
|
58777
|
+
console.error(`File or directory not found: ${path}`);
|
|
58784
58778
|
return;
|
|
58785
58779
|
}
|
|
58786
58780
|
if (stat.isDirectory()) {
|
|
58787
|
-
const [files] = await listFiles(
|
|
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(
|
|
58786
|
+
const content = await fs3.readFile(path, "utf8");
|
|
58793
58787
|
this.wsManager.sendMessage({
|
|
58794
58788
|
type: "file",
|
|
58795
|
-
path
|
|
58789
|
+
path,
|
|
58796
58790
|
content
|
|
58797
58791
|
});
|
|
58798
|
-
console.log(`Sent content for file: ${
|
|
58792
|
+
console.log(`Sent content for file: ${path}`);
|
|
58799
58793
|
} else {
|
|
58800
|
-
console.error(`Path is not a file or directory: ${
|
|
58794
|
+
console.error(`Path is not a file or directory: ${path}`);
|
|
58801
58795
|
}
|
|
58802
58796
|
} catch (error) {
|
|
58803
|
-
console.error(`Error processing path ${
|
|
58797
|
+
console.error(`Error processing path ${path}:`, error);
|
|
58804
58798
|
}
|
|
58805
58799
|
}
|
|
58806
|
-
sendFileDeleted(
|
|
58800
|
+
sendFileDeleted(path) {
|
|
58807
58801
|
this.wsManager.sendMessage({
|
|
58808
58802
|
type: "file_deleted",
|
|
58809
|
-
path
|
|
58803
|
+
path
|
|
58810
58804
|
});
|
|
58811
|
-
console.log(`Sent file_deleted for: ${
|
|
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.
|
|
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",
|