@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.
Files changed (2) hide show
  1. package/dist/index.js +36 -36
  2. 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.16";
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 { before_text, after_text, new_text, before_text_line_start, after_text_line_start } = operation;
47778
- if (before_text === START_OF_FILE && after_text === END_OF_FILE) {
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 (before_text === START_OF_FILE) {
47782
- if (!after_text) {
47781
+ if (start_anchor === START_OF_FILE) {
47782
+ if (!end_anchor) {
47783
47783
  return new_text + fileContent;
47784
47784
  }
47785
- const afterIndex = findTextWithHint(fileContent, after_text, after_text_line_start, originalLines);
47785
+ const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
47786
47786
  return new_text + fileContent.slice(afterIndex);
47787
47787
  }
47788
- if (after_text === END_OF_FILE) {
47789
- if (!before_text) {
47788
+ if (end_anchor === END_OF_FILE) {
47789
+ if (!start_anchor) {
47790
47790
  return fileContent + new_text;
47791
47791
  }
47792
- const beforeIndex = findTextWithHint(fileContent, before_text, before_text_line_start, originalLines);
47793
- const beforeEndIndex = beforeIndex + before_text.length;
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 (before_text && after_text) {
47797
- const beforeIndex = findTextWithHint(fileContent, before_text, before_text_line_start, originalLines);
47798
- const beforeEndIndex = beforeIndex + before_text.length;
47799
- const afterIndex = findTextWithHint(fileContent, after_text, after_text_line_start, originalLines, beforeEndIndex);
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 (before_text) {
47803
- const beforeIndex = findTextWithHint(fileContent, before_text, before_text_line_start, originalLines);
47804
- const beforeEndIndex = beforeIndex + before_text.length;
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 (after_text) {
47808
- const afterIndex = findTextWithHint(fileContent, after_text, after_text_line_start, originalLines);
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 before_text or after_text must be specified");
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 before_text, after_text, new_text, and optional line range hints",
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: "before_text",
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: "after_text",
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 before_text and after_text",
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: "before_text_line_start",
49056
- description: "Optional line number hint for before_text location (1-based)",
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: "after_text_line_start",
49062
- description: "Optional line number hint for after_text location (1-based)",
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
- before_text: "function oldFunction() {",
49082
- after_text: "}",
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
- before_text: START_OF_FILE,
49101
- after_text: "export",
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
- before_text: "import React",
49120
- after_text: 'from "react"',
49119
+ start_anchor: "import React",
49120
+ end_anchor: 'from "react"',
49121
49121
  new_text: ", { useState }"
49122
49122
  },
49123
49123
  {
49124
- before_text: "function Component() {",
49125
- after_text: "return (",
49124
+ start_anchor: "function Component() {",
49125
+ end_anchor: "return (",
49126
49126
  new_text: `
49127
49127
  const [state, setState] = useState(false);
49128
49128
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.8.16",
3
+ "version": "0.8.17",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",