@xynogen/pix-edit 0.2.8 → 0.2.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-edit",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Pi tool \u2014 precise text replacement edit with diff rendering",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@xynogen/pix-pretty": "^1.30.0",
42
+ "@xynogen/pix-pretty": "^1.31.0",
43
43
  "@xynogen/pix-runtime": "^0.13.0"
44
44
  },
45
45
  "peerDependencies": {
package/src/edit.ts CHANGED
@@ -146,7 +146,8 @@ const editSchema = Type.Object(
146
146
  {
147
147
  oldText: Type.String({
148
148
  minLength: 1,
149
- description: "Exact source text. Include enough context to match once.",
149
+ description:
150
+ "Fallback only after a hash-anchor edit fails. Exact current source text; must match once.",
150
151
  }),
151
152
  newText: Type.String({ description: "Replacement text. Empty string deletes." }),
152
153
  },
@@ -157,7 +158,7 @@ const editSchema = Type.Object(
157
158
  ],
158
159
  {
159
160
  description:
160
- "Use only hash edits or only exact-text edits in this array. Never mix formats.",
161
+ "Try hash-anchor edits first. Use exact-text edits only after a hash-anchor edit fails. Never mix formats.",
161
162
  },
162
163
  ),
163
164
  },
@@ -368,10 +369,12 @@ export function registerEditTool(
368
369
  ...origEdit,
369
370
  name: "edit",
370
371
  description:
371
- "Edit using one format per call: hash anchors {op,pos,end?,lines} or exact text {oldText,newText}. Exact oldText must match once. All edits target the original file and must not overlap. Hash ops: replace, insert_before, insert_after. Empty lines or newText delete. Insertions may touch range boundaries, not interiors. Same-gap inserts follow input order. Use write for empty files or complete rewrites.",
372
+ "Try hash anchors {op,pos,end?,lines} from read first. Only after a hash-anchor edit fails, use exact text {oldText,newText} from current source; oldText must match once. Never mix formats. All edits target the original file and must not overlap. Hash ops: replace, insert_before, insert_after. Empty lines or newText delete. Insertions may touch range boundaries, not interiors. Same-gap inserts follow input order. Use write for empty files or complete rewrites.",
372
373
  parameters: editSchema,
373
- promptSnippet: "Edit with hash anchors or exact text",
374
- promptGuidelines: [],
374
+ promptSnippet: "Edit with hash anchors first; exact text only after failure",
375
+ promptGuidelines: [
376
+ "For edit, try hash anchors from read first. Only if the hash-anchor edit fails, fall back to oldText/newText. If the file changed, read the affected region again before using current source text; never guess anchors or overwrite unseen changes.",
377
+ ],
375
378
  prepareArguments: prepareHashArguments,
376
379
  constrainedSampling: { type: "json_schema", strict: "prefer" },
377
380
  renderShell: "self",
package/src/extension.ts CHANGED
@@ -8,7 +8,7 @@ import { Text } from "@earendil-works/pi-tui";
8
8
  import { CursorStore, fffState } from "@xynogen/pix-pretty/fff";
9
9
  import { attachResizeListener, trackInvalidator } from "@xynogen/pix-pretty/resize";
10
10
  import type { PiPrettyApi, ToolFactory } from "@xynogen/pix-pretty/types";
11
- import { shortPath, viewportTextConstructor } from "@xynogen/pix-pretty/utils";
11
+ import { linkedShortPath, viewportTextConstructor } from "@xynogen/pix-pretty/utils";
12
12
  import { initHashline } from "@xynogen/pix-runtime/hashline";
13
13
  import { once } from "@xynogen/pix-runtime/once";
14
14
  import { homeDir } from "@xynogen/pix-runtime/paths";
@@ -32,7 +32,7 @@ export default async function pixEditExtension(pi: ExtensionAPI): Promise<void>
32
32
  createEditTool,
33
33
  {
34
34
  cwd,
35
- sp: (p: string) => shortPath(cwd, home, p),
35
+ sp: (p: string) => linkedShortPath(cwd, home, p),
36
36
  TextComponent: viewportTextConstructor(Text),
37
37
  fffState,
38
38
  cursorStore: new CursorStore(),