pi-readseek 0.4.9 → 0.4.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/README.md +0 -4
- package/package.json +2 -2
- package/src/edit-diff.ts +0 -2
- package/src/edit.ts +1 -1
- package/src/grep.ts +2 -2
- package/src/map-cache.ts +1 -1
- package/src/path-utils.ts +4 -4
- package/src/read.ts +1 -1
- package/src/write.ts +4 -8
package/README.md
CHANGED
|
@@ -53,7 +53,3 @@ information.
|
|
|
53
53
|
|
|
54
54
|
The upstream `@jarkkojs/readseek` packages are licensed separately as
|
|
55
55
|
`Apache-2.0 AND LGPL-2.1-or-later`.
|
|
56
|
-
|
|
57
|
-
`readseek` is originally derived from the source code of
|
|
58
|
-
[`pi-hashline-readmap`](https://github.com/coctostan/pi-hashline-readmap).
|
|
59
|
-
The relevant copyrights have been retained in [LICENSE](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-readseek",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"description": "Pi extension for readseek-backed hash-anchored read/edit/grep, structural code maps, structural search, and file exploration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=20.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@jarkkojs/readseek": "^0.4.
|
|
42
|
+
"@jarkkojs/readseek": "^0.4.13",
|
|
43
43
|
"diff": "^8.0.3",
|
|
44
44
|
"ignore": "^7.0.5",
|
|
45
45
|
"picomatch": "^4.0.4",
|
package/src/edit-diff.ts
CHANGED
|
@@ -37,11 +37,9 @@ export function stripBom(content: string): { bom: string; text: string } {
|
|
|
37
37
|
* These cause line-count mismatches between normalizeToLF and external tools (ripgrep, wc).
|
|
38
38
|
*/
|
|
39
39
|
export function hasBareCarriageReturn(content: string): boolean {
|
|
40
|
-
// Remove all \r\n first, then check if any \r remains
|
|
41
40
|
return content.replace(/\r\n/g, "").includes("\r");
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
|
|
45
43
|
const SINGLE_QUOTES_RE = /[\u2018\u2019\u201A\u201B]/g;
|
|
46
44
|
const DOUBLE_QUOTES_RE = /[\u201C\u201D\u201E\u201F]/g;
|
|
47
45
|
const UNICODE_SPACES_RE = /[\u00A0\u2002-\u200A\u202F\u205F\u3000]/g;
|
package/src/edit.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
|
|
1
|
+
import { readFile as fsReadFile, writeFile as fsWriteFile } from "node:fs/promises";
|
|
2
2
|
|
|
3
3
|
import { createPatch } from "diff";
|
|
4
4
|
import { withFileMutationQueue, type ExtensionAPI, type EditToolDetails, type ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
|
package/src/grep.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readFile as fsReadFile, stat as fsStat } from "fs/promises";
|
|
2
|
-
import path from "path";
|
|
1
|
+
import { readFile as fsReadFile, stat as fsStat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
import type { ExtensionAPI, ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { createGrepTool } from "@earendil-works/pi-coding-agent";
|
package/src/map-cache.ts
CHANGED
|
@@ -29,7 +29,7 @@ function getMapCacheState(): MapCacheGlobalState {
|
|
|
29
29
|
globalObject[MAP_CACHE_STATE_KEY] = state;
|
|
30
30
|
return state;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
// Move an existing entry to the most-recently-used position (Map insertion-order tail).
|
|
33
33
|
function touchMapEntry<K, V>(map: Map<K, V>, key: K, value: V): void {
|
|
34
34
|
map.delete(key);
|
|
35
35
|
map.set(key, value);
|
package/src/path-utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isAbsolute, resolve as resolvePath } from "path";
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { isAbsolute, resolve as resolvePath } from "node:path";
|
|
3
3
|
|
|
4
4
|
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
|
|
5
5
|
|
|
@@ -13,8 +13,8 @@ function normalizeAtPrefix(filePath: string): string {
|
|
|
13
13
|
|
|
14
14
|
function expandPath(filePath: string): string {
|
|
15
15
|
const normalized = normalizeUnicodeSpaces(normalizeAtPrefix(filePath));
|
|
16
|
-
if (normalized === "~") return
|
|
17
|
-
if (normalized.startsWith("~/")) return
|
|
16
|
+
if (normalized === "~") return homedir();
|
|
17
|
+
if (normalized.startsWith("~/")) return homedir() + normalized.slice(1);
|
|
18
18
|
return normalized;
|
|
19
19
|
}
|
|
20
20
|
|
package/src/read.ts
CHANGED
package/src/write.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
1
|
+
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
2
|
import { dirname, relative } from "node:path";
|
|
4
3
|
|
|
5
4
|
import { withFileMutationQueue, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
@@ -93,10 +92,8 @@ export interface WriteResult extends WriteDiffFields {
|
|
|
93
92
|
};
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
|
|
97
95
|
async function readPreviousTextForDiff(filePath: string): Promise<string> {
|
|
98
96
|
try {
|
|
99
|
-
if (!existsSync(filePath)) return "";
|
|
100
97
|
const previous = await readFile(filePath);
|
|
101
98
|
if (looksLikeBinary(previous)) return "";
|
|
102
99
|
return previous.toString("utf-8");
|
|
@@ -226,24 +223,23 @@ export async function executeWrite(opts: {
|
|
|
226
223
|
};
|
|
227
224
|
}
|
|
228
225
|
const previousContent = await readPreviousTextForDiff(filePath);
|
|
229
|
-
const existedBeforeWrite =
|
|
226
|
+
const existedBeforeWrite = await access(filePath).then(() => true, () => false);
|
|
230
227
|
|
|
231
228
|
// Create parent directories
|
|
232
229
|
try {
|
|
233
|
-
|
|
230
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
234
231
|
} catch (err: any) {
|
|
235
232
|
err.__phase = "mkdir";
|
|
236
233
|
throw err;
|
|
237
234
|
}
|
|
238
235
|
// Write file
|
|
239
236
|
try {
|
|
240
|
-
|
|
237
|
+
await writeFile(filePath, content, "utf-8");
|
|
241
238
|
} catch (err: any) {
|
|
242
239
|
err.__phase = "write";
|
|
243
240
|
throw err;
|
|
244
241
|
}
|
|
245
242
|
|
|
246
|
-
|
|
247
243
|
// Binary detection
|
|
248
244
|
if (looksLikeBinary(Buffer.from(content, "utf-8"))) {
|
|
249
245
|
warnings.push("File content appears to be binary.");
|