@polka-codes/runner 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
@@ -32748,7 +32748,7 @@ var {
32748
32748
  Help
32749
32749
  } = import__.default;
32750
32750
  // package.json
32751
- var version = "0.8.16";
32751
+ var version = "0.8.17";
32752
32752
 
32753
32753
  // src/runner.ts
32754
32754
  import { execSync } from "node:child_process";
@@ -42065,41 +42065,41 @@ var editFile = async (fileContent, operations) => {
42065
42065
  return updatedContent;
42066
42066
  };
42067
42067
  async function applyEditOperation(fileContent, operation, originalLines) {
42068
- const { before_text, after_text, new_text, before_text_line_start, after_text_line_start } = operation;
42069
- if (before_text === START_OF_FILE && after_text === END_OF_FILE) {
42068
+ const { start_anchor, end_anchor, new_text, start_anchor_line_start, end_anchor_line_start } = operation;
42069
+ if (start_anchor === START_OF_FILE && end_anchor === END_OF_FILE) {
42070
42070
  return new_text;
42071
42071
  }
42072
- if (before_text === START_OF_FILE) {
42073
- if (!after_text) {
42072
+ if (start_anchor === START_OF_FILE) {
42073
+ if (!end_anchor) {
42074
42074
  return new_text + fileContent;
42075
42075
  }
42076
- const afterIndex = findTextWithHint(fileContent, after_text, after_text_line_start, originalLines);
42076
+ const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
42077
42077
  return new_text + fileContent.slice(afterIndex);
42078
42078
  }
42079
- if (after_text === END_OF_FILE) {
42080
- if (!before_text) {
42079
+ if (end_anchor === END_OF_FILE) {
42080
+ if (!start_anchor) {
42081
42081
  return fileContent + new_text;
42082
42082
  }
42083
- const beforeIndex = findTextWithHint(fileContent, before_text, before_text_line_start, originalLines);
42084
- const beforeEndIndex = beforeIndex + before_text.length;
42083
+ const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
42084
+ const beforeEndIndex = beforeIndex + start_anchor.length;
42085
42085
  return fileContent.slice(0, beforeEndIndex) + new_text;
42086
42086
  }
42087
- if (before_text && after_text) {
42088
- const beforeIndex = findTextWithHint(fileContent, before_text, before_text_line_start, originalLines);
42089
- const beforeEndIndex = beforeIndex + before_text.length;
42090
- const afterIndex = findTextWithHint(fileContent, after_text, after_text_line_start, originalLines, beforeEndIndex);
42087
+ if (start_anchor && end_anchor) {
42088
+ const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
42089
+ const beforeEndIndex = beforeIndex + start_anchor.length;
42090
+ const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines, beforeEndIndex);
42091
42091
  return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(afterIndex);
42092
42092
  }
42093
- if (before_text) {
42094
- const beforeIndex = findTextWithHint(fileContent, before_text, before_text_line_start, originalLines);
42095
- const beforeEndIndex = beforeIndex + before_text.length;
42093
+ if (start_anchor) {
42094
+ const beforeIndex = findTextWithHint(fileContent, start_anchor, start_anchor_line_start, originalLines);
42095
+ const beforeEndIndex = beforeIndex + start_anchor.length;
42096
42096
  return fileContent.slice(0, beforeEndIndex) + new_text + fileContent.slice(beforeEndIndex);
42097
42097
  }
42098
- if (after_text) {
42099
- const afterIndex = findTextWithHint(fileContent, after_text, after_text_line_start, originalLines);
42098
+ if (end_anchor) {
42099
+ const afterIndex = findTextWithHint(fileContent, end_anchor, end_anchor_line_start, originalLines);
42100
42100
  return fileContent.slice(0, afterIndex) + new_text + fileContent.slice(afterIndex);
42101
42101
  }
42102
- throw new Error("Either before_text or after_text must be specified");
42102
+ throw new Error("Either start_anchor or end_anchor must be specified");
42103
42103
  }
42104
42104
  function findTextWithHint(content, searchText, lineHint, originalLines, startIndex = 0) {
42105
42105
  if (lineHint && lineHint > 0 && lineHint <= originalLines.length) {
@@ -43320,37 +43320,37 @@ var toolInfo13 = {
43320
43320
  },
43321
43321
  {
43322
43322
  name: "operations",
43323
- description: "Edit operation with before_text, after_text, new_text, and optional line range hints",
43323
+ description: "Edit operation with start_anchor, end_anchor, new_text, and optional line range hints",
43324
43324
  required: true,
43325
43325
  allowMultiple: true,
43326
43326
  children: [
43327
43327
  {
43328
- name: "before_text",
43328
+ name: "start_anchor",
43329
43329
  description: `Text to find as the start anchor (use ${START_OF_FILE} for file start)`,
43330
43330
  required: false,
43331
43331
  usageValue: "Text before the edit location"
43332
43332
  },
43333
43333
  {
43334
- name: "after_text",
43334
+ name: "end_anchor",
43335
43335
  description: `Text to find as the end anchor (use ${END_OF_FILE} for file end)`,
43336
43336
  required: false,
43337
43337
  usageValue: "Text after the edit location"
43338
43338
  },
43339
43339
  {
43340
43340
  name: "new_text",
43341
- description: "Text to replace the content between before_text and after_text",
43341
+ description: "Text to replace the content between start_anchor and end_anchor",
43342
43342
  required: true,
43343
43343
  usageValue: "New text content"
43344
43344
  },
43345
43345
  {
43346
- name: "before_text_line_start",
43347
- description: "Optional line number hint for before_text location (1-based)",
43346
+ name: "start_anchor_line_start",
43347
+ description: "Optional line number hint for start_anchor location (1-based)",
43348
43348
  required: false,
43349
43349
  usageValue: "10"
43350
43350
  },
43351
43351
  {
43352
- name: "after_text_line_start",
43353
- description: "Optional line number hint for after_text location (1-based)",
43352
+ name: "end_anchor_line_start",
43353
+ description: "Optional line number hint for end_anchor location (1-based)",
43354
43354
  required: false,
43355
43355
  usageValue: "20"
43356
43356
  }
@@ -43369,8 +43369,8 @@ var toolInfo13 = {
43369
43369
  {
43370
43370
  name: "operations",
43371
43371
  value: {
43372
- before_text: "function oldFunction() {",
43373
- after_text: "}",
43372
+ start_anchor: "function oldFunction() {",
43373
+ end_anchor: "}",
43374
43374
  new_text: `
43375
43375
  return "new implementation";
43376
43376
  `
@@ -43388,8 +43388,8 @@ var toolInfo13 = {
43388
43388
  {
43389
43389
  name: "operations",
43390
43390
  value: {
43391
- before_text: START_OF_FILE,
43392
- after_text: "export",
43391
+ start_anchor: START_OF_FILE,
43392
+ end_anchor: "export",
43393
43393
  new_text: `// File header comment
43394
43394
  `
43395
43395
  }
@@ -43407,13 +43407,13 @@ var toolInfo13 = {
43407
43407
  name: "operations",
43408
43408
  value: [
43409
43409
  {
43410
- before_text: "import React",
43411
- after_text: 'from "react"',
43410
+ start_anchor: "import React",
43411
+ end_anchor: 'from "react"',
43412
43412
  new_text: ", { useState }"
43413
43413
  },
43414
43414
  {
43415
- before_text: "function Component() {",
43416
- after_text: "return (",
43415
+ start_anchor: "function Component() {",
43416
+ end_anchor: "return (",
43417
43417
  new_text: `
43418
43418
  const [state, setState] = useState(false);
43419
43419
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
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",