@polka-codes/cli-shared 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 +52 -19
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -27185,7 +27185,17 @@ var toolInfo7 = {
|
|
|
27185
27185
|
return true;
|
|
27186
27186
|
}
|
|
27187
27187
|
return val;
|
|
27188
|
-
}, 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)" })
|
|
27188
|
+
}, 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)" }),
|
|
27189
|
+
includeIgnored: exports_external.preprocess((val) => {
|
|
27190
|
+
if (typeof val === "string") {
|
|
27191
|
+
const lower = val.toLowerCase();
|
|
27192
|
+
if (lower === "false")
|
|
27193
|
+
return false;
|
|
27194
|
+
if (lower === "true")
|
|
27195
|
+
return true;
|
|
27196
|
+
}
|
|
27197
|
+
return val;
|
|
27198
|
+
}, 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)" })
|
|
27189
27199
|
}).meta({
|
|
27190
27200
|
examples: [
|
|
27191
27201
|
{
|
|
@@ -27206,8 +27216,8 @@ var handler7 = async (provider, args) => {
|
|
|
27206
27216
|
message: "Not possible to list files. Abort."
|
|
27207
27217
|
};
|
|
27208
27218
|
}
|
|
27209
|
-
const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
|
|
27210
|
-
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
|
|
27219
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo7.parameters.parse(args);
|
|
27220
|
+
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
27211
27221
|
return {
|
|
27212
27222
|
type: "Reply" /* Reply */,
|
|
27213
27223
|
message: `<list_files_path>${path}</list_files_path>
|
|
@@ -27236,7 +27246,17 @@ var toolInfo8 = {
|
|
|
27236
27246
|
return [];
|
|
27237
27247
|
const values = Array.isArray(val) ? val : [val];
|
|
27238
27248
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
27239
|
-
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
27249
|
+
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
27250
|
+
includeIgnored: exports_external.preprocess((val) => {
|
|
27251
|
+
if (typeof val === "string") {
|
|
27252
|
+
const lower = val.toLowerCase();
|
|
27253
|
+
if (lower === "false")
|
|
27254
|
+
return false;
|
|
27255
|
+
if (lower === "true")
|
|
27256
|
+
return true;
|
|
27257
|
+
}
|
|
27258
|
+
return val;
|
|
27259
|
+
}, 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)" })
|
|
27240
27260
|
}).meta({
|
|
27241
27261
|
examples: [
|
|
27242
27262
|
{
|
|
@@ -27262,10 +27282,10 @@ var handler8 = async (provider, args) => {
|
|
|
27262
27282
|
message: "Not possible to read file. Abort."
|
|
27263
27283
|
};
|
|
27264
27284
|
}
|
|
27265
|
-
const { path: paths } = toolInfo8.parameters.parse(args);
|
|
27285
|
+
const { path: paths, includeIgnored } = toolInfo8.parameters.parse(args);
|
|
27266
27286
|
const resp = [];
|
|
27267
27287
|
for (const path of paths) {
|
|
27268
|
-
const fileContent = await provider.readFile(path);
|
|
27288
|
+
const fileContent = await provider.readFile(path, includeIgnored);
|
|
27269
27289
|
if (!fileContent) {
|
|
27270
27290
|
resp.push(`<read_file_file_content path="${path}" file_not_found="true" />`);
|
|
27271
27291
|
} else {
|
|
@@ -27575,7 +27595,7 @@ var handler11 = async (provider, args) => {
|
|
|
27575
27595
|
}
|
|
27576
27596
|
try {
|
|
27577
27597
|
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
27578
|
-
const fileContent = await provider.readFile(path);
|
|
27598
|
+
const fileContent = await provider.readFile(path, false);
|
|
27579
27599
|
if (fileContent == null) {
|
|
27580
27600
|
return {
|
|
27581
27601
|
type: "Error" /* Error */,
|
|
@@ -51020,6 +51040,7 @@ ${instance.prompt}`;
|
|
|
51020
51040
|
resetTimeout();
|
|
51021
51041
|
const streamTextOptions = {
|
|
51022
51042
|
model: this.ai,
|
|
51043
|
+
temperature: 0,
|
|
51023
51044
|
messages,
|
|
51024
51045
|
providerOptions: this.config.parameters?.providerOptions,
|
|
51025
51046
|
onChunk: async ({ chunk }) => {
|
|
@@ -51088,6 +51109,14 @@ ${instance.prompt}`;
|
|
|
51088
51109
|
}
|
|
51089
51110
|
this.#messages.push(...respMessages);
|
|
51090
51111
|
if (this.config.toolFormat === "native") {
|
|
51112
|
+
const assistantText = respMessages.map((msg) => {
|
|
51113
|
+
if (typeof msg.content === "string") {
|
|
51114
|
+
return msg.content;
|
|
51115
|
+
}
|
|
51116
|
+
return msg.content.map((part) => part.type === "text" || part.type === "reasoning" ? part.text : "").join("");
|
|
51117
|
+
}).join(`
|
|
51118
|
+
`);
|
|
51119
|
+
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: assistantText });
|
|
51091
51120
|
return respMessages.flatMap((msg) => {
|
|
51092
51121
|
if (msg.role === "assistant") {
|
|
51093
51122
|
const content = msg.content;
|
|
@@ -52169,6 +52198,7 @@ ${output}`,
|
|
|
52169
52198
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
52170
52199
|
const resp = await generateText({
|
|
52171
52200
|
model: ai,
|
|
52201
|
+
temperature: 0,
|
|
52172
52202
|
system: definition.prompt,
|
|
52173
52203
|
messages: [
|
|
52174
52204
|
{
|
|
@@ -57530,13 +57560,16 @@ async function extendPatterns(basePatterns, dirPath) {
|
|
|
57530
57560
|
function createIgnore(patterns) {
|
|
57531
57561
|
return import_ignore.default().add(patterns);
|
|
57532
57562
|
}
|
|
57533
|
-
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
57534
|
-
let rootPatterns = [...
|
|
57535
|
-
|
|
57536
|
-
|
|
57537
|
-
|
|
57538
|
-
|
|
57539
|
-
|
|
57563
|
+
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles, includeIgnored) {
|
|
57564
|
+
let rootPatterns = [...excludeFiles || []];
|
|
57565
|
+
if (!includeIgnored) {
|
|
57566
|
+
rootPatterns.push(...DEFAULT_IGNORES);
|
|
57567
|
+
try {
|
|
57568
|
+
const rootGitignore = await fs.readFile(join2(cwd, ".gitignore"), "utf8");
|
|
57569
|
+
const lines = rootGitignore.split(/\r?\n/).filter(Boolean);
|
|
57570
|
+
rootPatterns = [...rootPatterns, ...lines];
|
|
57571
|
+
} catch {}
|
|
57572
|
+
}
|
|
57540
57573
|
const results = [];
|
|
57541
57574
|
const processedDirs = new Set;
|
|
57542
57575
|
const queue = [
|
|
@@ -57549,7 +57582,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
57549
57582
|
while (queue.length > 0) {
|
|
57550
57583
|
const { path: currentPath, patterns: parentPatterns, relPath: currentRelPath } = queue.shift();
|
|
57551
57584
|
processedDirs.add(currentRelPath);
|
|
57552
|
-
const mergedPatterns = await extendPatterns(parentPatterns, currentPath);
|
|
57585
|
+
const mergedPatterns = includeIgnored ? parentPatterns : await extendPatterns(parentPatterns, currentPath);
|
|
57553
57586
|
const folderIg = createIgnore(mergedPatterns);
|
|
57554
57587
|
const entries = await fs.readdir(currentPath, { withFileTypes: true });
|
|
57555
57588
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -57645,8 +57678,8 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
57645
57678
|
var getProvider = (_agentName, _config, options = {}) => {
|
|
57646
57679
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
57647
57680
|
const provider2 = {
|
|
57648
|
-
readFile: async (path) => {
|
|
57649
|
-
if (ig.ignores(path)) {
|
|
57681
|
+
readFile: async (path, includeIgnored) => {
|
|
57682
|
+
if (!includeIgnored && ig.ignores(path)) {
|
|
57650
57683
|
throw new Error(`Not allow to access file ${path}`);
|
|
57651
57684
|
}
|
|
57652
57685
|
try {
|
|
@@ -57674,8 +57707,8 @@ var getProvider = (_agentName, _config, options = {}) => {
|
|
|
57674
57707
|
}
|
|
57675
57708
|
return await rename(sourcePath, targetPath);
|
|
57676
57709
|
},
|
|
57677
|
-
listFiles: async (path, recursive, maxCount) => {
|
|
57678
|
-
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
57710
|
+
listFiles: async (path, recursive, maxCount, includeIgnored) => {
|
|
57711
|
+
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles, includeIgnored);
|
|
57679
57712
|
},
|
|
57680
57713
|
executeCommand: (command, _needApprove) => {
|
|
57681
57714
|
return new Promise((resolve3, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli-shared",
|
|
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,7 +17,7 @@
|
|
|
17
17
|
"build": "bun build src/index.ts --outdir dist --target node"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@polka-codes/core": "0.9.
|
|
20
|
+
"@polka-codes/core": "0.9.4",
|
|
21
21
|
"ignore": "^7.0.3",
|
|
22
22
|
"lodash": "^4.17.21",
|
|
23
23
|
"yaml": "^2.7.0",
|