@polka-codes/cli 0.8.15 → 0.8.17
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 +86 -99
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38447,7 +38447,7 @@ var {
|
|
|
38447
38447
|
Help
|
|
38448
38448
|
} = import__.default;
|
|
38449
38449
|
// package.json
|
|
38450
|
-
var version = "0.8.
|
|
38450
|
+
var version = "0.8.17";
|
|
38451
38451
|
|
|
38452
38452
|
// ../core/src/AiService/AiServiceBase.ts
|
|
38453
38453
|
class AiServiceBase {
|
|
@@ -41845,8 +41845,32 @@ Anthropic.Beta = Beta;
|
|
|
41845
41845
|
// ../core/src/AiService/ModelInfo.ts
|
|
41846
41846
|
var anthropicDefaultModelId = "claude-3-7-sonnet-20250219";
|
|
41847
41847
|
var anthropicModels = {
|
|
41848
|
+
"claude-opus-4-20250514": {
|
|
41849
|
+
maxTokens: 32000,
|
|
41850
|
+
contextWindow: 200000,
|
|
41851
|
+
supportsImages: true,
|
|
41852
|
+
supportsComputerUse: true,
|
|
41853
|
+
supportsPromptCache: true,
|
|
41854
|
+
inputPrice: 15,
|
|
41855
|
+
outputPrice: 75,
|
|
41856
|
+
cacheWritesPrice: 18.75,
|
|
41857
|
+
cacheReadsPrice: 1.5,
|
|
41858
|
+
reasoning: true
|
|
41859
|
+
},
|
|
41860
|
+
"claude-sonnet-4-20250514": {
|
|
41861
|
+
maxTokens: 64000,
|
|
41862
|
+
contextWindow: 200000,
|
|
41863
|
+
supportsImages: true,
|
|
41864
|
+
supportsComputerUse: true,
|
|
41865
|
+
supportsPromptCache: true,
|
|
41866
|
+
inputPrice: 3,
|
|
41867
|
+
outputPrice: 15,
|
|
41868
|
+
cacheWritesPrice: 3.75,
|
|
41869
|
+
cacheReadsPrice: 0.3,
|
|
41870
|
+
reasoning: true
|
|
41871
|
+
},
|
|
41848
41872
|
"claude-3-7-sonnet-20250219": {
|
|
41849
|
-
maxTokens:
|
|
41873
|
+
maxTokens: 64000,
|
|
41850
41874
|
contextWindow: 200000,
|
|
41851
41875
|
supportsImages: true,
|
|
41852
41876
|
supportsComputerUse: true,
|
|
@@ -41967,6 +41991,7 @@ class AnthropicService extends AiServiceBase {
|
|
|
41967
41991
|
temperature = undefined;
|
|
41968
41992
|
}
|
|
41969
41993
|
switch (modelId) {
|
|
41994
|
+
case "claude-sonnet-4-20250514":
|
|
41970
41995
|
case "claude-3-7-sonnet-20250219":
|
|
41971
41996
|
case "claude-3-5-sonnet-20241022":
|
|
41972
41997
|
case "claude-3-5-haiku-20241022":
|
|
@@ -47499,70 +47524,31 @@ class OpenRouterService extends AiServiceBase {
|
|
|
47499
47524
|
...convertToOpenAiMessages(messages)
|
|
47500
47525
|
];
|
|
47501
47526
|
const cacheControl = this.#options.enableCache ? { type: "ephemeral" } : undefined;
|
|
47502
|
-
|
|
47503
|
-
|
|
47504
|
-
|
|
47505
|
-
|
|
47506
|
-
|
|
47507
|
-
|
|
47508
|
-
|
|
47509
|
-
|
|
47510
|
-
case "anthropic/claude-3.5-sonnet-20240620":
|
|
47511
|
-
case "anthropic/claude-3.5-sonnet-20240620:beta":
|
|
47512
|
-
case "anthropic/claude-3-5-haiku":
|
|
47513
|
-
case "anthropic/claude-3-5-haiku:beta":
|
|
47514
|
-
case "anthropic/claude-3-5-haiku-20241022":
|
|
47515
|
-
case "anthropic/claude-3-5-haiku-20241022:beta":
|
|
47516
|
-
case "anthropic/claude-3-haiku":
|
|
47517
|
-
case "anthropic/claude-3-haiku:beta":
|
|
47518
|
-
case "anthropic/claude-3-opus":
|
|
47519
|
-
case "anthropic/claude-3-opus:beta": {
|
|
47520
|
-
openAiMessages[0] = {
|
|
47521
|
-
role: "system",
|
|
47522
|
-
content: [
|
|
47523
|
-
{
|
|
47524
|
-
type: "text",
|
|
47525
|
-
text: systemPrompt,
|
|
47526
|
-
cache_control: cacheControl
|
|
47527
|
-
}
|
|
47528
|
-
]
|
|
47529
|
-
};
|
|
47530
|
-
const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
|
|
47531
|
-
for (const msg of lastTwoUserMessages) {
|
|
47532
|
-
if (typeof msg.content === "string") {
|
|
47533
|
-
msg.content = [{ type: "text", text: msg.content }];
|
|
47527
|
+
if (this.model.id.startsWith("anthropic/claude")) {
|
|
47528
|
+
openAiMessages[0] = {
|
|
47529
|
+
role: "system",
|
|
47530
|
+
content: [
|
|
47531
|
+
{
|
|
47532
|
+
type: "text",
|
|
47533
|
+
text: systemPrompt,
|
|
47534
|
+
cache_control: cacheControl
|
|
47534
47535
|
}
|
|
47535
|
-
|
|
47536
|
-
|
|
47537
|
-
|
|
47538
|
-
|
|
47539
|
-
|
|
47540
|
-
|
|
47541
|
-
|
|
47536
|
+
]
|
|
47537
|
+
};
|
|
47538
|
+
const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2);
|
|
47539
|
+
for (const msg of lastTwoUserMessages) {
|
|
47540
|
+
if (typeof msg.content === "string") {
|
|
47541
|
+
msg.content = [{ type: "text", text: msg.content }];
|
|
47542
|
+
}
|
|
47543
|
+
if (Array.isArray(msg.content)) {
|
|
47544
|
+
let lastTextPart = msg.content.filter((part) => part.type === "text").pop();
|
|
47545
|
+
if (!lastTextPart) {
|
|
47546
|
+
lastTextPart = { type: "text", text: "..." };
|
|
47547
|
+
msg.content.push(lastTextPart);
|
|
47542
47548
|
}
|
|
47549
|
+
lastTextPart.cache_control = cacheControl;
|
|
47543
47550
|
}
|
|
47544
|
-
break;
|
|
47545
47551
|
}
|
|
47546
|
-
default:
|
|
47547
|
-
break;
|
|
47548
|
-
}
|
|
47549
|
-
let maxTokens;
|
|
47550
|
-
switch (this.model.id) {
|
|
47551
|
-
case "anthropic/claude-3.7-sonnet:thinking":
|
|
47552
|
-
case "anthropic/claude-3.7-sonnet":
|
|
47553
|
-
case "anthropic/claude-3.7-sonnet:beta":
|
|
47554
|
-
case "anthropic/claude-3-7-sonnet":
|
|
47555
|
-
case "anthropic/claude-3-7-sonnet:beta":
|
|
47556
|
-
case "anthropic/claude-3.5-sonnet":
|
|
47557
|
-
case "anthropic/claude-3.5-sonnet:beta":
|
|
47558
|
-
case "anthropic/claude-3.5-sonnet-20240620":
|
|
47559
|
-
case "anthropic/claude-3.5-sonnet-20240620:beta":
|
|
47560
|
-
case "anthropic/claude-3-5-haiku":
|
|
47561
|
-
case "anthropic/claude-3-5-haiku:beta":
|
|
47562
|
-
case "anthropic/claude-3-5-haiku-20241022":
|
|
47563
|
-
case "anthropic/claude-3-5-haiku-20241022:beta":
|
|
47564
|
-
maxTokens = 8192;
|
|
47565
|
-
break;
|
|
47566
47552
|
}
|
|
47567
47553
|
let reasoning = {};
|
|
47568
47554
|
switch (this.model.id) {
|
|
@@ -47570,7 +47556,9 @@ class OpenRouterService extends AiServiceBase {
|
|
|
47570
47556
|
case "anthropic/claude-3.7-sonnet:beta":
|
|
47571
47557
|
case "anthropic/claude-3.7-sonnet:thinking":
|
|
47572
47558
|
case "anthropic/claude-3-7-sonnet":
|
|
47573
|
-
case "anthropic/claude-3-7-sonnet:beta":
|
|
47559
|
+
case "anthropic/claude-3-7-sonnet:beta":
|
|
47560
|
+
case "anthropic/claude-opus-4":
|
|
47561
|
+
case "anthropic/claude-sonnet-4": {
|
|
47574
47562
|
const budget_tokens = this.#options.parameters.thinkingBudgetTokens || 0;
|
|
47575
47563
|
if (budget_tokens > 0) {
|
|
47576
47564
|
reasoning = { max_tokens: budget_tokens };
|
|
@@ -47584,7 +47572,6 @@ class OpenRouterService extends AiServiceBase {
|
|
|
47584
47572
|
}
|
|
47585
47573
|
const stream = await this.#client.chat.completions.create({
|
|
47586
47574
|
model: this.model.id,
|
|
47587
|
-
max_completion_tokens: maxTokens,
|
|
47588
47575
|
messages: openAiMessages,
|
|
47589
47576
|
temperature: 0,
|
|
47590
47577
|
stream: true,
|
|
@@ -47787,41 +47774,41 @@ var editFile = async (fileContent, operations) => {
|
|
|
47787
47774
|
return updatedContent;
|
|
47788
47775
|
};
|
|
47789
47776
|
async function applyEditOperation(fileContent, operation, originalLines) {
|
|
47790
|
-
const {
|
|
47791
|
-
if (
|
|
47777
|
+
const { start_anchor, end_anchor, new_text, start_anchor_line_start, end_anchor_line_start } = operation;
|
|
47778
|
+
if (start_anchor === START_OF_FILE && end_anchor === END_OF_FILE) {
|
|
47792
47779
|
return new_text;
|
|
47793
47780
|
}
|
|
47794
|
-
if (
|
|
47795
|
-
if (!
|
|
47781
|
+
if (start_anchor === START_OF_FILE) {
|
|
47782
|
+
if (!end_anchor) {
|
|
47796
47783
|
return new_text + fileContent;
|
|
47797
47784
|
}
|
|
47798
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
47785
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
|
|
47799
47786
|
return new_text + fileContent.slice(afterIndex);
|
|
47800
47787
|
}
|
|
47801
|
-
if (
|
|
47802
|
-
if (!
|
|
47788
|
+
if (end_anchor === END_OF_FILE) {
|
|
47789
|
+
if (!start_anchor) {
|
|
47803
47790
|
return fileContent + new_text;
|
|
47804
47791
|
}
|
|
47805
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
47806
|
-
const beforeEndIndex = beforeIndex +
|
|
47792
|
+
const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
|
|
47793
|
+
const beforeEndIndex = beforeIndex + start_anchor.length;
|
|
47807
47794
|
return fileContent.slice(0, beforeEndIndex) + new_text;
|
|
47808
47795
|
}
|
|
47809
|
-
if (
|
|
47810
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
47811
|
-
const beforeEndIndex = beforeIndex +
|
|
47812
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
47796
|
+
if (start_anchor && end_anchor) {
|
|
47797
|
+
const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
|
|
47798
|
+
const beforeEndIndex = beforeIndex + start_anchor.length;
|
|
47799
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines, beforeEndIndex);
|
|
47813
47800
|
return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(afterIndex);
|
|
47814
47801
|
}
|
|
47815
|
-
if (
|
|
47816
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
47817
|
-
const beforeEndIndex = beforeIndex +
|
|
47802
|
+
if (start_anchor) {
|
|
47803
|
+
const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
|
|
47804
|
+
const beforeEndIndex = beforeIndex + start_anchor.length;
|
|
47818
47805
|
return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(beforeEndIndex);
|
|
47819
47806
|
}
|
|
47820
|
-
if (
|
|
47821
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
47807
|
+
if (end_anchor) {
|
|
47808
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
|
|
47822
47809
|
return fileContent.slice(0, afterIndex) + new_text + fileContent.slice(afterIndex);
|
|
47823
47810
|
}
|
|
47824
|
-
throw new Error("Either
|
|
47811
|
+
throw new Error("Either start_anchor or end_anchor must be specified");
|
|
47825
47812
|
}
|
|
47826
47813
|
function findTextWithHint(content, searchText, lineHint, originalLines, startIndex = 0) {
|
|
47827
47814
|
if (lineHint && lineHint > 0 && lineHint <= originalLines.length) {
|
|
@@ -49042,37 +49029,37 @@ var toolInfo13 = {
|
|
|
49042
49029
|
},
|
|
49043
49030
|
{
|
|
49044
49031
|
name: "operations",
|
|
49045
|
-
description: "Edit operation with
|
|
49032
|
+
description: "Edit operation with start_anchor, end_anchor, new_text, and optional line range hints",
|
|
49046
49033
|
required: true,
|
|
49047
49034
|
allowMultiple: true,
|
|
49048
49035
|
children: [
|
|
49049
49036
|
{
|
|
49050
|
-
name: "
|
|
49037
|
+
name: "start_anchor",
|
|
49051
49038
|
description: `Text to find as the start anchor (use ${START_OF_FILE} for file start)`,
|
|
49052
49039
|
required: false,
|
|
49053
49040
|
usageValue: "Text before the edit location"
|
|
49054
49041
|
},
|
|
49055
49042
|
{
|
|
49056
|
-
name: "
|
|
49043
|
+
name: "end_anchor",
|
|
49057
49044
|
description: `Text to find as the end anchor (use ${END_OF_FILE} for file end)`,
|
|
49058
49045
|
required: false,
|
|
49059
49046
|
usageValue: "Text after the edit location"
|
|
49060
49047
|
},
|
|
49061
49048
|
{
|
|
49062
49049
|
name: "new_text",
|
|
49063
|
-
description: "Text to replace the content between
|
|
49050
|
+
description: "Text to replace the content between start_anchor and end_anchor",
|
|
49064
49051
|
required: true,
|
|
49065
49052
|
usageValue: "New text content"
|
|
49066
49053
|
},
|
|
49067
49054
|
{
|
|
49068
|
-
name: "
|
|
49069
|
-
description: "Optional line number hint for
|
|
49055
|
+
name: "start_anchor_line_start",
|
|
49056
|
+
description: "Optional line number hint for start_anchor location (1-based)",
|
|
49070
49057
|
required: false,
|
|
49071
49058
|
usageValue: "10"
|
|
49072
49059
|
},
|
|
49073
49060
|
{
|
|
49074
|
-
name: "
|
|
49075
|
-
description: "Optional line number hint for
|
|
49061
|
+
name: "end_anchor_line_start",
|
|
49062
|
+
description: "Optional line number hint for end_anchor location (1-based)",
|
|
49076
49063
|
required: false,
|
|
49077
49064
|
usageValue: "20"
|
|
49078
49065
|
}
|
|
@@ -49091,8 +49078,8 @@ var toolInfo13 = {
|
|
|
49091
49078
|
{
|
|
49092
49079
|
name: "operations",
|
|
49093
49080
|
value: {
|
|
49094
|
-
|
|
49095
|
-
|
|
49081
|
+
start_anchor: "function oldFunction() {",
|
|
49082
|
+
end_anchor: "}",
|
|
49096
49083
|
new_text: `
|
|
49097
49084
|
return "new implementation";
|
|
49098
49085
|
`
|
|
@@ -49110,8 +49097,8 @@ var toolInfo13 = {
|
|
|
49110
49097
|
{
|
|
49111
49098
|
name: "operations",
|
|
49112
49099
|
value: {
|
|
49113
|
-
|
|
49114
|
-
|
|
49100
|
+
start_anchor: START_OF_FILE,
|
|
49101
|
+
end_anchor: "export",
|
|
49115
49102
|
new_text: `// File header comment
|
|
49116
49103
|
`
|
|
49117
49104
|
}
|
|
@@ -49129,13 +49116,13 @@ var toolInfo13 = {
|
|
|
49129
49116
|
name: "operations",
|
|
49130
49117
|
value: [
|
|
49131
49118
|
{
|
|
49132
|
-
|
|
49133
|
-
|
|
49119
|
+
start_anchor: "import React",
|
|
49120
|
+
end_anchor: 'from "react"',
|
|
49134
49121
|
new_text: ", { useState }"
|
|
49135
49122
|
},
|
|
49136
49123
|
{
|
|
49137
|
-
|
|
49138
|
-
|
|
49124
|
+
start_anchor: "function Component() {",
|
|
49125
|
+
end_anchor: "return (",
|
|
49139
49126
|
new_text: `
|
|
49140
49127
|
const [state, setState] = useState(false);
|
|
49141
49128
|
`
|