pi-hashline-edit-pro 0.9.5 → 0.9.6
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/LICENSE +1 -1
- package/package.json +1 -1
- package/prompts/replace-guidelines.md +2 -2
- package/src/hashline/resolve.ts +2 -2
- package/src/replace.ts +2 -2
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
- Use `replace` with HASH anchors for all file changes; batch every change to one file into a single `replace` call.
|
|
2
|
-
- After a successful `replace`, the
|
|
3
|
-
- On `[E_STALE_ANCHOR]`,
|
|
2
|
+
- After a successful `replace`, the response text is empty (warnings only). Call `read` to get fresh anchors for follow-up edits.
|
|
3
|
+
- On `[E_STALE_ANCHOR]`, call `read` to get fresh anchors, copy the 3-character HASH from each line into `old_range`, and retry.
|
package/src/hashline/resolve.ts
CHANGED
|
@@ -134,7 +134,7 @@ function assertEditItem(edit: Record<string, unknown>, index: number): void {
|
|
|
134
134
|
const unknownKeys = Object.keys(edit).filter((key) => !ITEM_KEYS.has(key));
|
|
135
135
|
if (unknownKeys.length > 0) {
|
|
136
136
|
throw new Error(
|
|
137
|
-
`[E_BAD_SHAPE] Edit ${index} contains unknown or unsupported fields: ${unknownKeys.join(", ")}.`,
|
|
137
|
+
`[E_BAD_SHAPE] Edit ${index} contains unknown or unsupported fields: ${unknownKeys.join(", ")}. Each edit takes only { old_range, new_lines }.`,
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -144,7 +144,7 @@ function assertEditItem(edit: Record<string, unknown>, index: number): void {
|
|
|
144
144
|
);
|
|
145
145
|
}
|
|
146
146
|
if (!("new_lines" in edit)) {
|
|
147
|
-
throw new Error(`[E_BAD_SHAPE] Edit ${index} requires a "new_lines" field.`);
|
|
147
|
+
throw new Error(`[E_BAD_SHAPE] Edit ${index} requires a "new_lines" field. Provide the replacement lines (use [] to delete).`);
|
|
148
148
|
}
|
|
149
149
|
if ("new_lines" in edit && !isStringArray(edit.new_lines)) {
|
|
150
150
|
throw new Error(`[E_BAD_SHAPE] Edit ${index} field "new_lines" must be a string array.`);
|
package/src/replace.ts
CHANGED
|
@@ -118,7 +118,7 @@ export function assertReplaceRequest(
|
|
|
118
118
|
);
|
|
119
119
|
if (unknownRootKeys.length > 0) {
|
|
120
120
|
throw new Error(
|
|
121
|
-
`[E_BAD_SHAPE] Edit request contains unknown or unsupported fields: ${unknownRootKeys.join(", ")}.`,
|
|
121
|
+
`[E_BAD_SHAPE] Edit request contains unknown or unsupported fields: ${unknownRootKeys.join(", ")}. Use only { path, edits }; each edit is { old_range: ["<START>", "<END>"], new_lines: [...] }.`,
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -127,7 +127,7 @@ export function assertReplaceRequest(
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
if (hasOwn(request, "edits") && !Array.isArray(request.edits)) {
|
|
130
|
-
throw new Error('[E_BAD_SHAPE] Edit request requires an "edits" array when provided.');
|
|
130
|
+
throw new Error('[E_BAD_SHAPE] Edit request requires an "edits" array when provided. Each edit is { old_range: ["<START>", "<END>"], new_lines: [...] }.');
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
}
|