@polka-codes/runner 0.9.4 → 0.9.5
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 +53 -20
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -21008,7 +21008,7 @@ var {
|
|
|
21008
21008
|
Help
|
|
21009
21009
|
} = import__.default;
|
|
21010
21010
|
// package.json
|
|
21011
|
-
var version = "0.9.
|
|
21011
|
+
var version = "0.9.5";
|
|
21012
21012
|
|
|
21013
21013
|
// src/runner.ts
|
|
21014
21014
|
import { execSync } from "node:child_process";
|
|
@@ -32488,7 +32488,17 @@ var toolInfo7 = {
|
|
|
32488
32488
|
return true;
|
|
32489
32489
|
}
|
|
32490
32490
|
return val;
|
|
32491
|
-
}, exports_external.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" })
|
|
32491
|
+
}, exports_external.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" }),
|
|
32492
|
+
includeIgnored: exports_external.preprocess((val) => {
|
|
32493
|
+
if (typeof val === "string") {
|
|
32494
|
+
const lower = val.toLowerCase();
|
|
32495
|
+
if (lower === "false")
|
|
32496
|
+
return false;
|
|
32497
|
+
if (lower === "true")
|
|
32498
|
+
return true;
|
|
32499
|
+
}
|
|
32500
|
+
return val;
|
|
32501
|
+
}, exports_external.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
32492
32502
|
}).meta({
|
|
32493
32503
|
examples: [
|
|
32494
32504
|
{
|
|
@@ -32509,8 +32519,8 @@ var handler7 = async (provider, args) => {
|
|
|
32509
32519
|
message: "Not possible to list files. Abort."
|
|
32510
32520
|
};
|
|
32511
32521
|
}
|
|
32512
|
-
const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
|
|
32513
|
-
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
|
|
32522
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo7.parameters.parse(args);
|
|
32523
|
+
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
32514
32524
|
return {
|
|
32515
32525
|
type: "Reply" /* Reply */,
|
|
32516
32526
|
message: `<list_files_path>${path}</list_files_path>
|
|
@@ -32539,7 +32549,17 @@ var toolInfo8 = {
|
|
|
32539
32549
|
return [];
|
|
32540
32550
|
const values = Array.isArray(val) ? val : [val];
|
|
32541
32551
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32542
|
-
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
32552
|
+
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
32553
|
+
includeIgnored: exports_external.preprocess((val) => {
|
|
32554
|
+
if (typeof val === "string") {
|
|
32555
|
+
const lower = val.toLowerCase();
|
|
32556
|
+
if (lower === "false")
|
|
32557
|
+
return false;
|
|
32558
|
+
if (lower === "true")
|
|
32559
|
+
return true;
|
|
32560
|
+
}
|
|
32561
|
+
return val;
|
|
32562
|
+
}, exports_external.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
32543
32563
|
}).meta({
|
|
32544
32564
|
examples: [
|
|
32545
32565
|
{
|
|
@@ -32565,10 +32585,10 @@ var handler8 = async (provider, args) => {
|
|
|
32565
32585
|
message: "Not possible to read file. Abort."
|
|
32566
32586
|
};
|
|
32567
32587
|
}
|
|
32568
|
-
const { path: paths } = toolInfo8.parameters.parse(args);
|
|
32588
|
+
const { path: paths, includeIgnored } = toolInfo8.parameters.parse(args);
|
|
32569
32589
|
const resp = [];
|
|
32570
32590
|
for (const path of paths) {
|
|
32571
|
-
const fileContent = await provider.readFile(path);
|
|
32591
|
+
const fileContent = await provider.readFile(path, includeIgnored);
|
|
32572
32592
|
if (!fileContent) {
|
|
32573
32593
|
resp.push(`<read_file_file_content path="${path}" file_not_found="true" />`);
|
|
32574
32594
|
} else {
|
|
@@ -32878,7 +32898,7 @@ var handler11 = async (provider, args) => {
|
|
|
32878
32898
|
}
|
|
32879
32899
|
try {
|
|
32880
32900
|
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
32881
|
-
const fileContent = await provider.readFile(path);
|
|
32901
|
+
const fileContent = await provider.readFile(path, false);
|
|
32882
32902
|
if (fileContent == null) {
|
|
32883
32903
|
return {
|
|
32884
32904
|
type: "Error" /* Error */,
|
|
@@ -56323,6 +56343,7 @@ ${instance.prompt}`;
|
|
|
56323
56343
|
resetTimeout();
|
|
56324
56344
|
const streamTextOptions = {
|
|
56325
56345
|
model: this.ai,
|
|
56346
|
+
temperature: 0,
|
|
56326
56347
|
messages,
|
|
56327
56348
|
providerOptions: this.config.parameters?.providerOptions,
|
|
56328
56349
|
onChunk: async ({ chunk }) => {
|
|
@@ -56391,6 +56412,14 @@ ${instance.prompt}`;
|
|
|
56391
56412
|
}
|
|
56392
56413
|
this.#messages.push(...respMessages);
|
|
56393
56414
|
if (this.config.toolFormat === "native") {
|
|
56415
|
+
const assistantText = respMessages.map((msg) => {
|
|
56416
|
+
if (typeof msg.content === "string") {
|
|
56417
|
+
return msg.content;
|
|
56418
|
+
}
|
|
56419
|
+
return msg.content.map((part) => part.type === "text" || part.type === "reasoning" ? part.text : "").join("");
|
|
56420
|
+
}).join(`
|
|
56421
|
+
`);
|
|
56422
|
+
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: assistantText });
|
|
56394
56423
|
return respMessages.flatMap((msg) => {
|
|
56395
56424
|
if (msg.role === "assistant") {
|
|
56396
56425
|
const content = msg.content;
|
|
@@ -57472,6 +57501,7 @@ ${output}`,
|
|
|
57472
57501
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
57473
57502
|
const resp = await generateText({
|
|
57474
57503
|
model: ai,
|
|
57504
|
+
temperature: 0,
|
|
57475
57505
|
system: definition.prompt,
|
|
57476
57506
|
messages: [
|
|
57477
57507
|
{
|
|
@@ -62819,13 +62849,16 @@ async function extendPatterns(basePatterns, dirPath) {
|
|
|
62819
62849
|
function createIgnore(patterns) {
|
|
62820
62850
|
return import_ignore.default().add(patterns);
|
|
62821
62851
|
}
|
|
62822
|
-
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
62823
|
-
let rootPatterns = [...
|
|
62824
|
-
|
|
62825
|
-
|
|
62826
|
-
|
|
62827
|
-
|
|
62828
|
-
|
|
62852
|
+
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles, includeIgnored) {
|
|
62853
|
+
let rootPatterns = [...excludeFiles || []];
|
|
62854
|
+
if (!includeIgnored) {
|
|
62855
|
+
rootPatterns.push(...DEFAULT_IGNORES);
|
|
62856
|
+
try {
|
|
62857
|
+
const rootGitignore = await fs.readFile(join2(cwd, ".gitignore"), "utf8");
|
|
62858
|
+
const lines = rootGitignore.split(/\r?\n/).filter(Boolean);
|
|
62859
|
+
rootPatterns = [...rootPatterns, ...lines];
|
|
62860
|
+
} catch {}
|
|
62861
|
+
}
|
|
62829
62862
|
const results = [];
|
|
62830
62863
|
const processedDirs = new Set;
|
|
62831
62864
|
const queue = [
|
|
@@ -62838,7 +62871,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
62838
62871
|
while (queue.length > 0) {
|
|
62839
62872
|
const { path: currentPath, patterns: parentPatterns, relPath: currentRelPath } = queue.shift();
|
|
62840
62873
|
processedDirs.add(currentRelPath);
|
|
62841
|
-
const mergedPatterns = await extendPatterns(parentPatterns, currentPath);
|
|
62874
|
+
const mergedPatterns = includeIgnored ? parentPatterns : await extendPatterns(parentPatterns, currentPath);
|
|
62842
62875
|
const folderIg = createIgnore(mergedPatterns);
|
|
62843
62876
|
const entries = await fs.readdir(currentPath, { withFileTypes: true });
|
|
62844
62877
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -62934,8 +62967,8 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
62934
62967
|
var getProvider = (_agentName, _config, options = {}) => {
|
|
62935
62968
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
62936
62969
|
const provider2 = {
|
|
62937
|
-
readFile: async (path) => {
|
|
62938
|
-
if (ig.ignores(path)) {
|
|
62970
|
+
readFile: async (path, includeIgnored) => {
|
|
62971
|
+
if (!includeIgnored && ig.ignores(path)) {
|
|
62939
62972
|
throw new Error(`Not allow to access file ${path}`);
|
|
62940
62973
|
}
|
|
62941
62974
|
try {
|
|
@@ -62963,8 +62996,8 @@ var getProvider = (_agentName, _config, options = {}) => {
|
|
|
62963
62996
|
}
|
|
62964
62997
|
return await rename(sourcePath, targetPath);
|
|
62965
62998
|
},
|
|
62966
|
-
listFiles: async (path, recursive, maxCount) => {
|
|
62967
|
-
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
62999
|
+
listFiles: async (path, recursive, maxCount, includeIgnored) => {
|
|
63000
|
+
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles, includeIgnored);
|
|
62968
63001
|
},
|
|
62969
63002
|
executeCommand: (command, _needApprove) => {
|
|
62970
63003
|
return new Promise((resolve3, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/runner",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"build": "bun build src/index.ts --outdir dist --target node"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@polka-codes/cli-shared": "0.9.
|
|
21
|
-
"@polka-codes/core": "0.9.
|
|
20
|
+
"@polka-codes/cli-shared": "0.9.4",
|
|
21
|
+
"@polka-codes/core": "0.9.4",
|
|
22
22
|
"commander": "^13.0.0",
|
|
23
23
|
"dotenv": "^16.4.7",
|
|
24
24
|
"ignore": "^7.0.3",
|