@polka-codes/cli 0.9.4 → 0.9.6
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 +149 -85
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -39731,7 +39731,7 @@ var {
|
|
|
39731
39731
|
Help
|
|
39732
39732
|
} = import__.default;
|
|
39733
39733
|
// package.json
|
|
39734
|
-
var version = "0.9.
|
|
39734
|
+
var version = "0.9.6";
|
|
39735
39735
|
|
|
39736
39736
|
// ../../node_modules/@inquirer/core/dist/esm/lib/key.js
|
|
39737
39737
|
var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
|
|
@@ -52567,7 +52567,17 @@ var toolInfo7 = {
|
|
|
52567
52567
|
return true;
|
|
52568
52568
|
}
|
|
52569
52569
|
return val;
|
|
52570
|
-
}, 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)" })
|
|
52570
|
+
}, 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)" }),
|
|
52571
|
+
includeIgnored: exports_external.preprocess((val) => {
|
|
52572
|
+
if (typeof val === "string") {
|
|
52573
|
+
const lower = val.toLowerCase();
|
|
52574
|
+
if (lower === "false")
|
|
52575
|
+
return false;
|
|
52576
|
+
if (lower === "true")
|
|
52577
|
+
return true;
|
|
52578
|
+
}
|
|
52579
|
+
return val;
|
|
52580
|
+
}, 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)" })
|
|
52571
52581
|
}).meta({
|
|
52572
52582
|
examples: [
|
|
52573
52583
|
{
|
|
@@ -52588,8 +52598,8 @@ var handler7 = async (provider, args) => {
|
|
|
52588
52598
|
message: "Not possible to list files. Abort."
|
|
52589
52599
|
};
|
|
52590
52600
|
}
|
|
52591
|
-
const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
|
|
52592
|
-
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
|
|
52601
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo7.parameters.parse(args);
|
|
52602
|
+
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
52593
52603
|
return {
|
|
52594
52604
|
type: "Reply" /* Reply */,
|
|
52595
52605
|
message: `<list_files_path>${path}</list_files_path>
|
|
@@ -52618,7 +52628,17 @@ var toolInfo8 = {
|
|
|
52618
52628
|
return [];
|
|
52619
52629
|
const values = Array.isArray(val) ? val : [val];
|
|
52620
52630
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
52621
|
-
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
52631
|
+
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
52632
|
+
includeIgnored: exports_external.preprocess((val) => {
|
|
52633
|
+
if (typeof val === "string") {
|
|
52634
|
+
const lower = val.toLowerCase();
|
|
52635
|
+
if (lower === "false")
|
|
52636
|
+
return false;
|
|
52637
|
+
if (lower === "true")
|
|
52638
|
+
return true;
|
|
52639
|
+
}
|
|
52640
|
+
return val;
|
|
52641
|
+
}, 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)" })
|
|
52622
52642
|
}).meta({
|
|
52623
52643
|
examples: [
|
|
52624
52644
|
{
|
|
@@ -52644,10 +52664,10 @@ var handler8 = async (provider, args) => {
|
|
|
52644
52664
|
message: "Not possible to read file. Abort."
|
|
52645
52665
|
};
|
|
52646
52666
|
}
|
|
52647
|
-
const { path: paths } = toolInfo8.parameters.parse(args);
|
|
52667
|
+
const { path: paths, includeIgnored } = toolInfo8.parameters.parse(args);
|
|
52648
52668
|
const resp = [];
|
|
52649
52669
|
for (const path of paths) {
|
|
52650
|
-
const fileContent = await provider.readFile(path);
|
|
52670
|
+
const fileContent = await provider.readFile(path, includeIgnored);
|
|
52651
52671
|
if (!fileContent) {
|
|
52652
52672
|
resp.push(`<read_file_file_content path="${path}" file_not_found="true" />`);
|
|
52653
52673
|
} else {
|
|
@@ -52655,7 +52675,7 @@ var handler8 = async (provider, args) => {
|
|
|
52655
52675
|
if (isEmpty) {
|
|
52656
52676
|
resp.push(`<read_file_file_content path="${path}" is_empty="true" />`);
|
|
52657
52677
|
} else {
|
|
52658
|
-
resp.push(`<
|
|
52678
|
+
resp.push(`<read_file_file_content path="${path}">${fileContent}</read_file_file_content>`);
|
|
52659
52679
|
}
|
|
52660
52680
|
}
|
|
52661
52681
|
}
|
|
@@ -52955,9 +52975,16 @@ var handler11 = async (provider, args) => {
|
|
|
52955
52975
|
message: "Not possible to replace in file. Abort."
|
|
52956
52976
|
};
|
|
52957
52977
|
}
|
|
52978
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
52979
|
+
if (!parsed.success) {
|
|
52980
|
+
return {
|
|
52981
|
+
type: "Invalid" /* Invalid */,
|
|
52982
|
+
message: `Invalid arguments for replace_in_file: ${parsed.error.message}`
|
|
52983
|
+
};
|
|
52984
|
+
}
|
|
52985
|
+
const { path, diff } = parsed.data;
|
|
52958
52986
|
try {
|
|
52959
|
-
const
|
|
52960
|
-
const fileContent = await provider.readFile(path);
|
|
52987
|
+
const fileContent = await provider.readFile(path, false);
|
|
52961
52988
|
if (fileContent == null) {
|
|
52962
52989
|
return {
|
|
52963
52990
|
type: "Error" /* Error */,
|
|
@@ -53034,8 +53061,15 @@ var handler12 = async (provider, args) => {
|
|
|
53034
53061
|
message: "Not possible to search files. Abort."
|
|
53035
53062
|
};
|
|
53036
53063
|
}
|
|
53064
|
+
const parsed = toolInfo12.parameters.safeParse(args);
|
|
53065
|
+
if (!parsed.success) {
|
|
53066
|
+
return {
|
|
53067
|
+
type: "Invalid" /* Invalid */,
|
|
53068
|
+
message: `Invalid arguments for search_files: ${parsed.error.message}`
|
|
53069
|
+
};
|
|
53070
|
+
}
|
|
53071
|
+
const { path, regex, filePattern } = parsed.data;
|
|
53037
53072
|
try {
|
|
53038
|
-
const { path, regex, filePattern } = toolInfo12.parameters.parse(args);
|
|
53039
53073
|
const files = await provider.searchFiles(path, regex, filePattern ?? "*");
|
|
53040
53074
|
return {
|
|
53041
53075
|
type: "Reply" /* Reply */,
|
|
@@ -53050,8 +53084,8 @@ ${files.join(`
|
|
|
53050
53084
|
};
|
|
53051
53085
|
} catch (error40) {
|
|
53052
53086
|
return {
|
|
53053
|
-
type: "
|
|
53054
|
-
message: `
|
|
53087
|
+
type: "Error" /* Error */,
|
|
53088
|
+
message: `Error searching files: ${error40}`
|
|
53055
53089
|
};
|
|
53056
53090
|
}
|
|
53057
53091
|
};
|
|
@@ -76695,6 +76729,7 @@ ${instance.prompt}`;
|
|
|
76695
76729
|
resetTimeout();
|
|
76696
76730
|
const streamTextOptions = {
|
|
76697
76731
|
model: this.ai,
|
|
76732
|
+
temperature: 0,
|
|
76698
76733
|
messages,
|
|
76699
76734
|
providerOptions: this.config.parameters?.providerOptions,
|
|
76700
76735
|
onChunk: async ({ chunk }) => {
|
|
@@ -76763,6 +76798,14 @@ ${instance.prompt}`;
|
|
|
76763
76798
|
}
|
|
76764
76799
|
this.#messages.push(...respMessages);
|
|
76765
76800
|
if (this.config.toolFormat === "native") {
|
|
76801
|
+
const assistantText = respMessages.map((msg) => {
|
|
76802
|
+
if (typeof msg.content === "string") {
|
|
76803
|
+
return msg.content;
|
|
76804
|
+
}
|
|
76805
|
+
return msg.content.map((part) => part.type === "text" || part.type === "reasoning" ? part.text : "").join("");
|
|
76806
|
+
}).join(`
|
|
76807
|
+
`);
|
|
76808
|
+
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: assistantText });
|
|
76766
76809
|
return respMessages.flatMap((msg) => {
|
|
76767
76810
|
if (msg.role === "assistant") {
|
|
76768
76811
|
const content = msg.content;
|
|
@@ -77428,52 +77471,39 @@ class CoderAgent extends AgentBase {
|
|
|
77428
77471
|
usageMeter: options.usageMeter ?? new UsageMeter
|
|
77429
77472
|
});
|
|
77430
77473
|
}
|
|
77431
|
-
async
|
|
77432
|
-
if (name17 !== attemptCompletion_default.name) {
|
|
77433
|
-
return;
|
|
77434
|
-
}
|
|
77474
|
+
async#runScript(scriptName, shouldReplyWithError) {
|
|
77435
77475
|
const executeCommand = this.config.provider.executeCommand;
|
|
77436
77476
|
if (!executeCommand) {
|
|
77437
77477
|
return;
|
|
77438
77478
|
}
|
|
77439
|
-
const
|
|
77440
|
-
const
|
|
77441
|
-
if (
|
|
77442
|
-
try {
|
|
77443
|
-
await executeCommand(formatCommand, false);
|
|
77444
|
-
} catch (error81) {
|
|
77445
|
-
console.warn(`Failed to format code using command: ${formatCommand}`, error81);
|
|
77446
|
-
}
|
|
77447
|
-
}
|
|
77448
|
-
const check3 = this.config.scripts?.check;
|
|
77449
|
-
const checkCommand = typeof check3 === "string" ? check3 : check3?.command;
|
|
77450
|
-
if (checkCommand) {
|
|
77479
|
+
const script = this.config.scripts?.[scriptName];
|
|
77480
|
+
const command = typeof script === "string" ? script : script?.command;
|
|
77481
|
+
if (command) {
|
|
77451
77482
|
try {
|
|
77452
|
-
const { exitCode, stdout, stderr } = await executeCommand(
|
|
77453
|
-
if (exitCode !== 0) {
|
|
77483
|
+
const { exitCode, stdout, stderr } = await executeCommand(command, false);
|
|
77484
|
+
if (exitCode !== 0 && shouldReplyWithError) {
|
|
77454
77485
|
return {
|
|
77455
77486
|
type: "Reply" /* Reply */,
|
|
77456
|
-
message: responsePrompts.commandResult(
|
|
77487
|
+
message: responsePrompts.commandResult(command, exitCode, stdout, stderr)
|
|
77457
77488
|
};
|
|
77458
77489
|
}
|
|
77459
77490
|
} catch (error81) {
|
|
77460
|
-
console.warn(`Failed to
|
|
77491
|
+
console.warn(`Failed to run ${scriptName} using command: ${command}`, error81);
|
|
77461
77492
|
}
|
|
77462
77493
|
}
|
|
77463
|
-
|
|
77464
|
-
|
|
77465
|
-
if (
|
|
77466
|
-
|
|
77467
|
-
|
|
77468
|
-
|
|
77469
|
-
|
|
77470
|
-
|
|
77471
|
-
|
|
77472
|
-
|
|
77473
|
-
|
|
77474
|
-
|
|
77475
|
-
|
|
77476
|
-
}
|
|
77494
|
+
}
|
|
77495
|
+
async onBeforeInvokeTool(name17, _args) {
|
|
77496
|
+
if (name17 !== attemptCompletion_default.name) {
|
|
77497
|
+
return;
|
|
77498
|
+
}
|
|
77499
|
+
await this.#runScript("format", false);
|
|
77500
|
+
const checkResult = await this.#runScript("check", true);
|
|
77501
|
+
if (checkResult) {
|
|
77502
|
+
return checkResult;
|
|
77503
|
+
}
|
|
77504
|
+
const testResult = await this.#runScript("test", true);
|
|
77505
|
+
if (testResult) {
|
|
77506
|
+
return testResult;
|
|
77477
77507
|
}
|
|
77478
77508
|
}
|
|
77479
77509
|
}
|
|
@@ -77981,10 +78011,18 @@ Example Output:
|
|
|
77981
78011
|
<tool_output>
|
|
77982
78012
|
<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>
|
|
77983
78013
|
<tool_output_pr_description>
|
|
77984
|
-
|
|
78014
|
+
Closes #123
|
|
78015
|
+
|
|
78016
|
+
**Context**:
|
|
78017
|
+
- Implementing changes for issue #123 - Focus on clean code and maintainability
|
|
77985
78018
|
|
|
77986
|
-
|
|
77987
|
-
to use
|
|
78019
|
+
**Summary of Changes**:
|
|
78020
|
+
- Refactored order validation logic to use a new \`validate_and_process\` method.
|
|
78021
|
+
- Removed debug print statements from \`user_service.py\`.
|
|
78022
|
+
|
|
78023
|
+
**Highlights of Changed Code**:
|
|
78024
|
+
- \`order_service.py\`: Replaced direct call to \`process_order\` with \`validate_and_process\`.
|
|
78025
|
+
- \`user_service.py\`: Removed \`print("Debug info")\`.
|
|
77988
78026
|
</tool_output_pr_description>
|
|
77989
78027
|
</tool_output>
|
|
77990
78028
|
|
|
@@ -78285,6 +78323,7 @@ ${output}`,
|
|
|
78285
78323
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
78286
78324
|
const resp = await generateText({
|
|
78287
78325
|
model: ai,
|
|
78326
|
+
temperature: 0,
|
|
78288
78327
|
system: definition.prompt,
|
|
78289
78328
|
messages: [
|
|
78290
78329
|
{
|
|
@@ -86328,21 +86367,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
86328
86367
|
return;
|
|
86329
86368
|
}
|
|
86330
86369
|
const delta = choice.delta;
|
|
86331
|
-
if (delta.content != null) {
|
|
86332
|
-
if (!textStarted) {
|
|
86333
|
-
textId = openrouterResponseId || generateId2();
|
|
86334
|
-
controller.enqueue({
|
|
86335
|
-
type: "text-start",
|
|
86336
|
-
id: textId
|
|
86337
|
-
});
|
|
86338
|
-
textStarted = true;
|
|
86339
|
-
}
|
|
86340
|
-
controller.enqueue({
|
|
86341
|
-
type: "text-delta",
|
|
86342
|
-
delta: delta.content,
|
|
86343
|
-
id: textId || generateId2()
|
|
86344
|
-
});
|
|
86345
|
-
}
|
|
86346
86370
|
const emitReasoningChunk = (chunkText) => {
|
|
86347
86371
|
if (!reasoningStarted) {
|
|
86348
86372
|
reasoningId = openrouterResponseId || generateId2();
|
|
@@ -86358,9 +86382,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
86358
86382
|
id: reasoningId || generateId2()
|
|
86359
86383
|
});
|
|
86360
86384
|
};
|
|
86361
|
-
if (delta.reasoning != null) {
|
|
86362
|
-
emitReasoningChunk(delta.reasoning);
|
|
86363
|
-
}
|
|
86364
86385
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
86365
86386
|
for (const detail of delta.reasoning_details) {
|
|
86366
86387
|
switch (detail.type) {
|
|
@@ -86387,6 +86408,23 @@ var OpenRouterChatLanguageModel = class {
|
|
|
86387
86408
|
}
|
|
86388
86409
|
}
|
|
86389
86410
|
}
|
|
86411
|
+
} else if (delta.reasoning != null) {
|
|
86412
|
+
emitReasoningChunk(delta.reasoning);
|
|
86413
|
+
}
|
|
86414
|
+
if (delta.content != null) {
|
|
86415
|
+
if (!textStarted) {
|
|
86416
|
+
textId = openrouterResponseId || generateId2();
|
|
86417
|
+
controller.enqueue({
|
|
86418
|
+
type: "text-start",
|
|
86419
|
+
id: textId
|
|
86420
|
+
});
|
|
86421
|
+
textStarted = true;
|
|
86422
|
+
}
|
|
86423
|
+
controller.enqueue({
|
|
86424
|
+
type: "text-delta",
|
|
86425
|
+
delta: delta.content,
|
|
86426
|
+
id: textId || generateId2()
|
|
86427
|
+
});
|
|
86390
86428
|
}
|
|
86391
86429
|
if (delta.tool_calls != null) {
|
|
86392
86430
|
for (const toolCallDelta of delta.tool_calls) {
|
|
@@ -86486,7 +86524,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
86486
86524
|
var _a16;
|
|
86487
86525
|
if (finishReason === "tool-calls") {
|
|
86488
86526
|
for (const toolCall of toolCalls) {
|
|
86489
|
-
if (!toolCall.sent) {
|
|
86527
|
+
if (toolCall && !toolCall.sent) {
|
|
86490
86528
|
controller.enqueue({
|
|
86491
86529
|
type: "tool-call",
|
|
86492
86530
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId2(),
|
|
@@ -103830,11 +103868,12 @@ var getModel = (config5, debugLogging = false) => {
|
|
|
103830
103868
|
console.log("<- Stream chunk:", text2.replace(/\n/g, "\\n"));
|
|
103831
103869
|
}
|
|
103832
103870
|
if (TRACING_FILE) {
|
|
103833
|
-
appendFileSync(TRACING_FILE, JSON.stringify({
|
|
103871
|
+
appendFileSync(TRACING_FILE, `${JSON.stringify({
|
|
103834
103872
|
type: "response-chunk",
|
|
103835
103873
|
timestamp: new Date().toISOString(),
|
|
103836
103874
|
chunk: text2
|
|
103837
|
-
}, null, 2)
|
|
103875
|
+
}, null, 2)}
|
|
103876
|
+
`);
|
|
103838
103877
|
}
|
|
103839
103878
|
}
|
|
103840
103879
|
}
|
|
@@ -103851,13 +103890,14 @@ var getModel = (config5, debugLogging = false) => {
|
|
|
103851
103890
|
console.dir(responseBody, { depth: null });
|
|
103852
103891
|
}
|
|
103853
103892
|
if (TRACING_FILE) {
|
|
103854
|
-
appendFileSync(TRACING_FILE, JSON.stringify({
|
|
103893
|
+
appendFileSync(TRACING_FILE, `${JSON.stringify({
|
|
103855
103894
|
type: "response",
|
|
103856
103895
|
timestamp: new Date().toISOString(),
|
|
103857
103896
|
status: res.status,
|
|
103858
103897
|
headers: Object.fromEntries(res.headers.entries()),
|
|
103859
103898
|
body: responseBody
|
|
103860
|
-
}, null, 2)
|
|
103899
|
+
}, null, 2)}
|
|
103900
|
+
`);
|
|
103861
103901
|
}
|
|
103862
103902
|
return new Response(full, {
|
|
103863
103903
|
headers: res.headers,
|
|
@@ -108270,13 +108310,16 @@ async function extendPatterns(basePatterns, dirPath) {
|
|
|
108270
108310
|
function createIgnore(patterns) {
|
|
108271
108311
|
return import_ignore.default().add(patterns);
|
|
108272
108312
|
}
|
|
108273
|
-
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
108274
|
-
let rootPatterns = [...
|
|
108275
|
-
|
|
108276
|
-
|
|
108277
|
-
|
|
108278
|
-
|
|
108279
|
-
|
|
108313
|
+
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles, includeIgnored) {
|
|
108314
|
+
let rootPatterns = [...excludeFiles || []];
|
|
108315
|
+
if (!includeIgnored) {
|
|
108316
|
+
rootPatterns.push(...DEFAULT_IGNORES);
|
|
108317
|
+
try {
|
|
108318
|
+
const rootGitignore = await fs.readFile(join2(cwd, ".gitignore"), "utf8");
|
|
108319
|
+
const lines = rootGitignore.split(/\r?\n/).filter(Boolean);
|
|
108320
|
+
rootPatterns = [...rootPatterns, ...lines];
|
|
108321
|
+
} catch {}
|
|
108322
|
+
}
|
|
108280
108323
|
const results = [];
|
|
108281
108324
|
const processedDirs = new Set;
|
|
108282
108325
|
const queue = [
|
|
@@ -108289,7 +108332,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
108289
108332
|
while (queue.length > 0) {
|
|
108290
108333
|
const { path: currentPath, patterns: parentPatterns, relPath: currentRelPath } = queue.shift();
|
|
108291
108334
|
processedDirs.add(currentRelPath);
|
|
108292
|
-
const mergedPatterns = await extendPatterns(parentPatterns, currentPath);
|
|
108335
|
+
const mergedPatterns = includeIgnored ? parentPatterns : await extendPatterns(parentPatterns, currentPath);
|
|
108293
108336
|
const folderIg = createIgnore(mergedPatterns);
|
|
108294
108337
|
const entries = await fs.readdir(currentPath, { withFileTypes: true });
|
|
108295
108338
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -108385,8 +108428,8 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
108385
108428
|
var getProvider = (_agentName, _config, options = {}) => {
|
|
108386
108429
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
108387
108430
|
const provider2 = {
|
|
108388
|
-
readFile: async (path) => {
|
|
108389
|
-
if (ig.ignores(path)) {
|
|
108431
|
+
readFile: async (path, includeIgnored) => {
|
|
108432
|
+
if (!includeIgnored && ig.ignores(path)) {
|
|
108390
108433
|
throw new Error(`Not allow to access file ${path}`);
|
|
108391
108434
|
}
|
|
108392
108435
|
try {
|
|
@@ -108414,8 +108457,8 @@ var getProvider = (_agentName, _config, options = {}) => {
|
|
|
108414
108457
|
}
|
|
108415
108458
|
return await rename(sourcePath, targetPath);
|
|
108416
108459
|
},
|
|
108417
|
-
listFiles: async (path, recursive, maxCount) => {
|
|
108418
|
-
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
108460
|
+
listFiles: async (path, recursive, maxCount, includeIgnored) => {
|
|
108461
|
+
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles, includeIgnored);
|
|
108419
108462
|
},
|
|
108420
108463
|
executeCommand: (command, _needApprove) => {
|
|
108421
108464
|
return new Promise((resolve3, reject) => {
|
|
@@ -109239,6 +109282,9 @@ function getProviderOptions(provider3, modelId, thinkingBudgetTokens, supportThi
|
|
|
109239
109282
|
};
|
|
109240
109283
|
break;
|
|
109241
109284
|
case "openrouter" /* OpenRouter */:
|
|
109285
|
+
if (modelId.startsWith("anthropic/")) {
|
|
109286
|
+
break;
|
|
109287
|
+
}
|
|
109242
109288
|
providerOptions.openrouter = {
|
|
109243
109289
|
reasoning: {
|
|
109244
109290
|
max_tokens: thinkingBudgetTokens
|
|
@@ -110730,6 +110776,7 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110730
110776
|
} catch (_error) {
|
|
110731
110777
|
console.warn("Warning: Could not retrieve file changes list");
|
|
110732
110778
|
}
|
|
110779
|
+
printChangedFiles(changedFiles, spinner, isJsonOutput);
|
|
110733
110780
|
spinner.text = "Generating review...";
|
|
110734
110781
|
const result = await reviewDiff(sharedAiOptions, {
|
|
110735
110782
|
commitRange: `${defaultBranch}...HEAD`,
|
|
@@ -110755,6 +110802,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110755
110802
|
if (hasStagedChanges) {
|
|
110756
110803
|
spinner.text = "Generating review for staged changes...";
|
|
110757
110804
|
const stagedFiles = changedFiles.filter((file4) => file4.status.includes("staged"));
|
|
110805
|
+
printChangedFiles(stagedFiles, spinner, isJsonOutput);
|
|
110758
110806
|
const result2 = await reviewDiff(sharedAiOptions, {
|
|
110759
110807
|
staged: true,
|
|
110760
110808
|
changedFiles: stagedFiles
|
|
@@ -110770,6 +110818,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110770
110818
|
if (hasUnstagedChanges) {
|
|
110771
110819
|
spinner.text = "Generating review for unstaged changes...";
|
|
110772
110820
|
const unstagedFiles = changedFiles.filter((file4) => file4.status.includes("unstaged") || file4.status.includes("Untracked"));
|
|
110821
|
+
printChangedFiles(unstagedFiles, spinner, isJsonOutput);
|
|
110773
110822
|
const result2 = await reviewDiff(sharedAiOptions, {
|
|
110774
110823
|
staged: false,
|
|
110775
110824
|
changedFiles: unstagedFiles
|
|
@@ -110806,6 +110855,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110806
110855
|
} catch (_error) {
|
|
110807
110856
|
console.warn("Warning: Could not retrieve file changes list");
|
|
110808
110857
|
}
|
|
110858
|
+
printChangedFiles(branchChangedFiles, spinner, isJsonOutput);
|
|
110809
110859
|
spinner.text = `Generating review for changes between '${defaultBranch}' and '${currentBranch}'...`;
|
|
110810
110860
|
const result = await reviewDiff(sharedAiOptions, {
|
|
110811
110861
|
commitRange: `${defaultBranch}...${currentBranch}`,
|
|
@@ -110837,6 +110887,20 @@ ${item.review}
|
|
|
110837
110887
|
}
|
|
110838
110888
|
return formatted;
|
|
110839
110889
|
}
|
|
110890
|
+
function printChangedFiles(changedFiles, spinner, isJsonOutput) {
|
|
110891
|
+
if (changedFiles.length === 0) {
|
|
110892
|
+
return;
|
|
110893
|
+
}
|
|
110894
|
+
spinner.stop();
|
|
110895
|
+
const stream = isJsonOutput ? process.stderr : process.stdout;
|
|
110896
|
+
const log = (message) => stream.write(`${message}
|
|
110897
|
+
`);
|
|
110898
|
+
log("Changed files:");
|
|
110899
|
+
for (const file4 of changedFiles) {
|
|
110900
|
+
log(`- ${file4.status}: ${file4.path}`);
|
|
110901
|
+
}
|
|
110902
|
+
spinner.start();
|
|
110903
|
+
}
|
|
110840
110904
|
|
|
110841
110905
|
// src/commands/task.ts
|
|
110842
110906
|
var readStdin = async (timeoutMs = 30000) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@ai-sdk/provider": "2.0.0-beta.1",
|
|
25
25
|
"@ai-sdk/provider-utils": "3.0.0-beta.5",
|
|
26
26
|
"@inquirer/prompts": "^7.2.3",
|
|
27
|
-
"@openrouter/ai-sdk-provider": "^1.0.0-beta.
|
|
28
|
-
"@polka-codes/cli-shared": "0.9.
|
|
29
|
-
"@polka-codes/core": "0.9.
|
|
27
|
+
"@openrouter/ai-sdk-provider": "^1.0.0-beta.6",
|
|
28
|
+
"@polka-codes/cli-shared": "0.9.4",
|
|
29
|
+
"@polka-codes/core": "0.9.4",
|
|
30
30
|
"ai": "5.0.0-beta.24",
|
|
31
31
|
"commander": "^13.0.0",
|
|
32
32
|
"dotenv": "^16.4.7",
|