pi-hashline-edit-pro 0.16.14 → 0.16.15
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 +1 -1
- package/src/file-kind.ts +1 -16
- package/src/hashline/apply.ts +2 -2
- package/src/hashline/hash.ts +1 -0
- package/src/prompts.ts +2 -2
- package/src/replace.ts +2 -4
package/package.json
CHANGED
package/src/file-kind.ts
CHANGED
|
@@ -31,9 +31,6 @@ export type LFile =
|
|
|
31
31
|
| { kind: "text"; text: string; hadUtf8DecodeErrors?: true }
|
|
32
32
|
| { kind: "binary"; description: string };
|
|
33
33
|
|
|
34
|
-
function hasNull(buffer: Uint8Array): boolean {
|
|
35
|
-
return buffer.includes(0);
|
|
36
|
-
}
|
|
37
34
|
|
|
38
35
|
export async function loadFileKindAndText(
|
|
39
36
|
filePath: string,
|
|
@@ -82,12 +79,7 @@ export async function loadFileKindAndText(
|
|
|
82
79
|
description: detectedMimeType,
|
|
83
80
|
};
|
|
84
81
|
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
kind: "binary",
|
|
88
|
-
description: "null bytes detected",
|
|
89
|
-
};
|
|
90
|
-
}
|
|
82
|
+
|
|
91
83
|
|
|
92
84
|
const decoder = new TextDecoder("utf-8");
|
|
93
85
|
const fatalDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
@@ -121,17 +113,10 @@ export async function loadFileKindAndText(
|
|
|
121
113
|
}
|
|
122
114
|
|
|
123
115
|
const chunk = buffer.subarray(0, chunkBytesRead);
|
|
124
|
-
if (hasNull(chunk)) {
|
|
125
|
-
return {
|
|
126
|
-
kind: "binary",
|
|
127
|
-
description: "null bytes detected",
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
116
|
noteUtf8Err(chunk);
|
|
131
117
|
parts.push(decoder.decode(chunk, { stream: true }));
|
|
132
118
|
position += chunkBytesRead;
|
|
133
119
|
}
|
|
134
|
-
|
|
135
120
|
noteUtf8Err();
|
|
136
121
|
parts.push(decoder.decode());
|
|
137
122
|
|
package/src/hashline/apply.ts
CHANGED
|
@@ -252,7 +252,7 @@ export function fmtBoundaryWarning(params: {
|
|
|
252
252
|
|
|
253
253
|
export function applyEdits(
|
|
254
254
|
content: string,
|
|
255
|
-
edits:
|
|
255
|
+
edits: HEdit[],
|
|
256
256
|
signal?: AbortSignal,
|
|
257
257
|
precomputedHashes?: string[],
|
|
258
258
|
filePath?: string,
|
|
@@ -297,7 +297,7 @@ export function applyEdits(
|
|
|
297
297
|
let autoFixes: AutoFix[] | undefined;
|
|
298
298
|
if (boundaryWarnings.length > 0) {
|
|
299
299
|
autoFixes = [];
|
|
300
|
-
const correctedEdits:
|
|
300
|
+
const correctedEdits: HEdit[] = edits.map(e => ({
|
|
301
301
|
...e,
|
|
302
302
|
content_lines: [...e.content_lines],
|
|
303
303
|
}));
|
package/src/hashline/hash.ts
CHANGED
package/src/prompts.ts
CHANGED
|
@@ -4,7 +4,7 @@ export function loadP(relativePath: string, replacements?: Record<string, string
|
|
|
4
4
|
let content = readFileSync(new URL(relativePath, import.meta.url), "utf-8").trim();
|
|
5
5
|
if (replacements) {
|
|
6
6
|
for (const [key, value] of Object.entries(replacements)) {
|
|
7
|
-
content = content.
|
|
7
|
+
content = content.split(`{{${key}}}`).join(value);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
return content;
|
|
@@ -14,7 +14,7 @@ export function loadGuide(relativePath: string, replacements?: Record<string, st
|
|
|
14
14
|
let content = readFileSync(new URL(relativePath, import.meta.url), "utf-8");
|
|
15
15
|
if (replacements) {
|
|
16
16
|
for (const [key, value] of Object.entries(replacements)) {
|
|
17
|
-
content = content.
|
|
17
|
+
content = content.split(`{{${key}}}`).join(value);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
return content
|
package/src/replace.ts
CHANGED
|
@@ -167,12 +167,10 @@ export async function execPipeline(
|
|
|
167
167
|
|
|
168
168
|
const hashStore = store ?? await loadHashStore();
|
|
169
169
|
|
|
170
|
-
const { normalized: originalNormalized, bom, originalEnding, fileHashes: originalHashes, hadUtf8DecodeErrors } = await readNormFile(
|
|
170
|
+
const { normalized: originalNormalized, bom, originalEnding, fileHashes: originalHashes, hadUtf8DecodeErrors, absolutePath } = await readNormFile(
|
|
171
171
|
path, cwd, signal, accessMode, undefined, MAX_HASH_LINES, hashStore,
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
-
const absolutePath = toCwd(path, cwd);
|
|
175
|
-
const resolvedPath = await resolveTarget(absolutePath);
|
|
176
174
|
const resolved = resEdits(toolEdits);
|
|
177
175
|
const anchorResult = applyEdits(
|
|
178
176
|
originalNormalized,
|
|
@@ -197,7 +195,7 @@ export async function execPipeline(
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
const resultHashes = await lineHashes(result,
|
|
198
|
+
const resultHashes = await lineHashes(result, absolutePath, {
|
|
201
199
|
content: originalNormalized,
|
|
202
200
|
hashes: originalHashes,
|
|
203
201
|
removedHashes,
|