@polka-codes/runner 0.8.13 → 0.8.15
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 +63 -53
- 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.15";
|
|
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() {
|
|
@@ -58677,12 +58671,21 @@ class Runner {
|
|
|
58677
58671
|
if (resp.type === "Reply" /* Reply */) {
|
|
58678
58672
|
return responsePrompts.toolResults(request.tool, resp.message);
|
|
58679
58673
|
}
|
|
58680
|
-
return
|
|
58674
|
+
return {
|
|
58675
|
+
type: "error",
|
|
58676
|
+
message: responsePrompts.errorInvokeTool(request.tool, `Unexpected tool response: ${JSON.stringify(resp)}`)
|
|
58677
|
+
};
|
|
58681
58678
|
}
|
|
58682
|
-
return
|
|
58679
|
+
return {
|
|
58680
|
+
type: "error",
|
|
58681
|
+
message: responsePrompts.errorInvokeTool(request.tool, "Tool not available")
|
|
58682
|
+
};
|
|
58683
58683
|
} catch (toolError) {
|
|
58684
58684
|
console.error(`Error executing tool ${request.tool}:`, toolError);
|
|
58685
|
-
return
|
|
58685
|
+
return {
|
|
58686
|
+
type: "error",
|
|
58687
|
+
message: responsePrompts.errorInvokeTool(request.tool, toolError)
|
|
58688
|
+
};
|
|
58686
58689
|
}
|
|
58687
58690
|
};
|
|
58688
58691
|
const respMsg = await fn();
|
|
@@ -58699,6 +58702,13 @@ class Runner {
|
|
|
58699
58702
|
index: request.index
|
|
58700
58703
|
});
|
|
58701
58704
|
return;
|
|
58705
|
+
} else if (respMsg.type === "error") {
|
|
58706
|
+
responses.push({
|
|
58707
|
+
index: request.index,
|
|
58708
|
+
tool: request.tool,
|
|
58709
|
+
response: respMsg.message
|
|
58710
|
+
});
|
|
58711
|
+
break;
|
|
58702
58712
|
}
|
|
58703
58713
|
}
|
|
58704
58714
|
this.wsManager.sendMessage({
|
|
@@ -58751,9 +58761,9 @@ class Runner {
|
|
|
58751
58761
|
`).filter((line) => line.trim().length > 0);
|
|
58752
58762
|
for (const line of lines2) {
|
|
58753
58763
|
const statusCode = line.substring(0, 2);
|
|
58754
|
-
const
|
|
58764
|
+
const path = line.substring(3);
|
|
58755
58765
|
if (statusCode.startsWith("R")) {
|
|
58756
|
-
const parts =
|
|
58766
|
+
const parts = path.split(" -> ");
|
|
58757
58767
|
if (parts.length === 2) {
|
|
58758
58768
|
const [oldPath, newPath] = parts;
|
|
58759
58769
|
changes.push({
|
|
@@ -58765,50 +58775,50 @@ class Runner {
|
|
|
58765
58775
|
}
|
|
58766
58776
|
}
|
|
58767
58777
|
if (statusCode === "??") {
|
|
58768
|
-
changes.push({ status: "added", path
|
|
58778
|
+
changes.push({ status: "added", path });
|
|
58769
58779
|
} else if (statusCode.includes("A")) {
|
|
58770
|
-
changes.push({ status: "added", path
|
|
58780
|
+
changes.push({ status: "added", path });
|
|
58771
58781
|
} else if (statusCode.includes("M")) {
|
|
58772
|
-
changes.push({ status: "modified", path
|
|
58782
|
+
changes.push({ status: "modified", path });
|
|
58773
58783
|
} else if (statusCode.includes("D")) {
|
|
58774
|
-
changes.push({ status: "deleted", path
|
|
58784
|
+
changes.push({ status: "deleted", path });
|
|
58775
58785
|
}
|
|
58776
58786
|
}
|
|
58777
58787
|
return changes;
|
|
58778
58788
|
}
|
|
58779
|
-
async sendFileContent(
|
|
58789
|
+
async sendFileContent(path) {
|
|
58780
58790
|
try {
|
|
58781
|
-
const stat = await fs3.stat(
|
|
58791
|
+
const stat = await fs3.stat(path).catch(() => null);
|
|
58782
58792
|
if (!stat) {
|
|
58783
|
-
console.error(`File or directory not found: ${
|
|
58793
|
+
console.error(`File or directory not found: ${path}`);
|
|
58784
58794
|
return;
|
|
58785
58795
|
}
|
|
58786
58796
|
if (stat.isDirectory()) {
|
|
58787
|
-
const [files] = await listFiles(
|
|
58797
|
+
const [files] = await listFiles(path, true, 1000, process.cwd());
|
|
58788
58798
|
for (const file of files) {
|
|
58789
58799
|
await this.sendFileContent(file);
|
|
58790
58800
|
}
|
|
58791
58801
|
} else if (stat.isFile()) {
|
|
58792
|
-
const content = await fs3.readFile(
|
|
58802
|
+
const content = await fs3.readFile(path, "utf8");
|
|
58793
58803
|
this.wsManager.sendMessage({
|
|
58794
58804
|
type: "file",
|
|
58795
|
-
path
|
|
58805
|
+
path,
|
|
58796
58806
|
content
|
|
58797
58807
|
});
|
|
58798
|
-
console.log(`Sent content for file: ${
|
|
58808
|
+
console.log(`Sent content for file: ${path}`);
|
|
58799
58809
|
} else {
|
|
58800
|
-
console.error(`Path is not a file or directory: ${
|
|
58810
|
+
console.error(`Path is not a file or directory: ${path}`);
|
|
58801
58811
|
}
|
|
58802
58812
|
} catch (error) {
|
|
58803
|
-
console.error(`Error processing path ${
|
|
58813
|
+
console.error(`Error processing path ${path}:`, error);
|
|
58804
58814
|
}
|
|
58805
58815
|
}
|
|
58806
|
-
sendFileDeleted(
|
|
58816
|
+
sendFileDeleted(path) {
|
|
58807
58817
|
this.wsManager.sendMessage({
|
|
58808
58818
|
type: "file_deleted",
|
|
58809
|
-
path
|
|
58819
|
+
path
|
|
58810
58820
|
});
|
|
58811
|
-
console.log(`Sent file_deleted for: ${
|
|
58821
|
+
console.log(`Sent file_deleted for: ${path}`);
|
|
58812
58822
|
}
|
|
58813
58823
|
}
|
|
58814
58824
|
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.15",
|
|
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",
|