@polka-codes/cli 0.8.16 → 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 +36 -36
- 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 {
|
|
@@ -47774,41 +47774,41 @@ var editFile = async (fileContent, operations) => {
|
|
|
47774
47774
|
return updatedContent;
|
|
47775
47775
|
};
|
|
47776
47776
|
async function applyEditOperation(fileContent, operation, originalLines) {
|
|
47777
|
-
const {
|
|
47778
|
-
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) {
|
|
47779
47779
|
return new_text;
|
|
47780
47780
|
}
|
|
47781
|
-
if (
|
|
47782
|
-
if (!
|
|
47781
|
+
if (start_anchor === START_OF_FILE) {
|
|
47782
|
+
if (!end_anchor) {
|
|
47783
47783
|
return new_text + fileContent;
|
|
47784
47784
|
}
|
|
47785
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
47785
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
|
|
47786
47786
|
return new_text + fileContent.slice(afterIndex);
|
|
47787
47787
|
}
|
|
47788
|
-
if (
|
|
47789
|
-
if (!
|
|
47788
|
+
if (end_anchor === END_OF_FILE) {
|
|
47789
|
+
if (!start_anchor) {
|
|
47790
47790
|
return fileContent + new_text;
|
|
47791
47791
|
}
|
|
47792
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
47793
|
-
const beforeEndIndex = beforeIndex +
|
|
47792
|
+
const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
|
|
47793
|
+
const beforeEndIndex = beforeIndex + start_anchor.length;
|
|
47794
47794
|
return fileContent.slice(0, beforeEndIndex) + new_text;
|
|
47795
47795
|
}
|
|
47796
|
-
if (
|
|
47797
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
47798
|
-
const beforeEndIndex = beforeIndex +
|
|
47799
|
-
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);
|
|
47800
47800
|
return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(afterIndex);
|
|
47801
47801
|
}
|
|
47802
|
-
if (
|
|
47803
|
-
const beforeIndex = findTextWithHint(fileContent,
|
|
47804
|
-
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;
|
|
47805
47805
|
return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(beforeEndIndex);
|
|
47806
47806
|
}
|
|
47807
|
-
if (
|
|
47808
|
-
const afterIndex = findTextWithHint(fileContent,
|
|
47807
|
+
if (end_anchor) {
|
|
47808
|
+
const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
|
|
47809
47809
|
return fileContent.slice(0, afterIndex) + new_text + fileContent.slice(afterIndex);
|
|
47810
47810
|
}
|
|
47811
|
-
throw new Error("Either
|
|
47811
|
+
throw new Error("Either start_anchor or end_anchor must be specified");
|
|
47812
47812
|
}
|
|
47813
47813
|
function findTextWithHint(content, searchText, lineHint, originalLines, startIndex = 0) {
|
|
47814
47814
|
if (lineHint && lineHint > 0 && lineHint <= originalLines.length) {
|
|
@@ -49029,37 +49029,37 @@ var toolInfo13 = {
|
|
|
49029
49029
|
},
|
|
49030
49030
|
{
|
|
49031
49031
|
name: "operations",
|
|
49032
|
-
description: "Edit operation with
|
|
49032
|
+
description: "Edit operation with start_anchor, end_anchor, new_text, and optional line range hints",
|
|
49033
49033
|
required: true,
|
|
49034
49034
|
allowMultiple: true,
|
|
49035
49035
|
children: [
|
|
49036
49036
|
{
|
|
49037
|
-
name: "
|
|
49037
|
+
name: "start_anchor",
|
|
49038
49038
|
description: `Text to find as the start anchor (use ${START_OF_FILE} for file start)`,
|
|
49039
49039
|
required: false,
|
|
49040
49040
|
usageValue: "Text before the edit location"
|
|
49041
49041
|
},
|
|
49042
49042
|
{
|
|
49043
|
-
name: "
|
|
49043
|
+
name: "end_anchor",
|
|
49044
49044
|
description: `Text to find as the end anchor (use ${END_OF_FILE} for file end)`,
|
|
49045
49045
|
required: false,
|
|
49046
49046
|
usageValue: "Text after the edit location"
|
|
49047
49047
|
},
|
|
49048
49048
|
{
|
|
49049
49049
|
name: "new_text",
|
|
49050
|
-
description: "Text to replace the content between
|
|
49050
|
+
description: "Text to replace the content between start_anchor and end_anchor",
|
|
49051
49051
|
required: true,
|
|
49052
49052
|
usageValue: "New text content"
|
|
49053
49053
|
},
|
|
49054
49054
|
{
|
|
49055
|
-
name: "
|
|
49056
|
-
description: "Optional line number hint for
|
|
49055
|
+
name: "start_anchor_line_start",
|
|
49056
|
+
description: "Optional line number hint for start_anchor location (1-based)",
|
|
49057
49057
|
required: false,
|
|
49058
49058
|
usageValue: "10"
|
|
49059
49059
|
},
|
|
49060
49060
|
{
|
|
49061
|
-
name: "
|
|
49062
|
-
description: "Optional line number hint for
|
|
49061
|
+
name: "end_anchor_line_start",
|
|
49062
|
+
description: "Optional line number hint for end_anchor location (1-based)",
|
|
49063
49063
|
required: false,
|
|
49064
49064
|
usageValue: "20"
|
|
49065
49065
|
}
|
|
@@ -49078,8 +49078,8 @@ var toolInfo13 = {
|
|
|
49078
49078
|
{
|
|
49079
49079
|
name: "operations",
|
|
49080
49080
|
value: {
|
|
49081
|
-
|
|
49082
|
-
|
|
49081
|
+
start_anchor: "function oldFunction() {",
|
|
49082
|
+
end_anchor: "}",
|
|
49083
49083
|
new_text: `
|
|
49084
49084
|
return "new implementation";
|
|
49085
49085
|
`
|
|
@@ -49097,8 +49097,8 @@ var toolInfo13 = {
|
|
|
49097
49097
|
{
|
|
49098
49098
|
name: "operations",
|
|
49099
49099
|
value: {
|
|
49100
|
-
|
|
49101
|
-
|
|
49100
|
+
start_anchor: START_OF_FILE,
|
|
49101
|
+
end_anchor: "export",
|
|
49102
49102
|
new_text: `// File header comment
|
|
49103
49103
|
`
|
|
49104
49104
|
}
|
|
@@ -49116,13 +49116,13 @@ var toolInfo13 = {
|
|
|
49116
49116
|
name: "operations",
|
|
49117
49117
|
value: [
|
|
49118
49118
|
{
|
|
49119
|
-
|
|
49120
|
-
|
|
49119
|
+
start_anchor: "import React",
|
|
49120
|
+
end_anchor: 'from "react"',
|
|
49121
49121
|
new_text: ", { useState }"
|
|
49122
49122
|
},
|
|
49123
49123
|
{
|
|
49124
|
-
|
|
49125
|
-
|
|
49124
|
+
start_anchor: "function Component() {",
|
|
49125
|
+
end_anchor: "return (",
|
|
49126
49126
|
new_text: `
|
|
49127
49127
|
const [state, setState] = useState(false);
|
|
49128
49128
|
`
|