@criogaid/pi-hashline-edit 0.1.0 → 0.1.2

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.
@@ -32,15 +32,14 @@ import {
32
32
  import { Type, type Static } from "typebox";
33
33
  import { Text } from "@earendil-works/pi-tui";
34
34
  import { readFile } from "node:fs/promises";
35
- import { hashFileLines, splitLines } from "../core/index.ts";
35
+ import { decodeEditableText, splitLines } from "../core/index.ts";
36
36
  import { ACTION_FUSION_GUIDELINES, createActionFusionExecutor, createThenRunSchema, type ThenRunInput } from "./action-fusion.ts";
37
- import { commitFile, FileMutationError, type PublicationStatus } from "./file-commit.ts";
37
+ import { byteRevision, commitFile, FileMutationError, type MutationVersions, type PublicationStatus } from "./file-commit.ts";
38
38
  import { getState } from "./state.ts";
39
39
  import { canonicalPath } from "./read-tool.ts";
40
- import { formatDiffCounts, publishDiffCounts, renderDiffPreview, type DiffCounts } from "./render.ts";
40
+ import { formatDiffCounts, renderMutationResult, type DiffCounts } from "./render.ts";
41
+ import { finalizeMutationResult, formatMutationAnchors } from "./mutation-result.ts";
41
42
 
42
- /** Cap on updated-anchor lines returned inline (bounds token cost for large spans). */
43
- const MAX_ANCHOR_LINES = 40;
44
43
  /** Default safety cap on match count (errors before writing if exceeded). */
45
44
  const DEFAULT_MAX_MATCHES = 2000;
46
45
  /** Valid JavaScript regular-expression flag characters (ES2023+, incl. hasIndices `d`). */
@@ -118,12 +117,10 @@ function changedSpan(oldLines: readonly string[], newLines: readonly string[]):
118
117
 
119
118
  /** Format fresh `LINE#HASH│content` anchors for a contiguous span of the new file, capped. */
120
119
  function formatSpanAnchors(newLines: readonly string[], span: { start: number; end: number }, hashLen: number): string {
121
- const hashes = hashFileLines(newLines, hashLen);
122
- const rows: string[] = [];
123
- for (let i = span.start; i <= span.end; i++) rows.push(`${i + 1}#${hashes[i]}│${newLines[i]}`);
124
- const shown = rows.length > MAX_ANCHOR_LINES ? rows.slice(0, MAX_ANCHOR_LINES) : rows;
125
- const more = rows.length > MAX_ANCHOR_LINES ? `\n… (${rows.length - MAX_ANCHOR_LINES} more; re-read for full anchors)` : "";
126
- return `\nUpdated anchors (changed region):\n${shown.join("\n")}${more}`;
120
+ function* indices() {
121
+ for (let i = span.start; i <= span.end; i++) yield i;
122
+ }
123
+ return formatMutationAnchors(newLines, indices(), hashLen, "Updated anchors (changed region):");
127
124
  }
128
125
 
129
126
  /** Truncate a string for one-line display, folding newlines into a marker. */
@@ -168,29 +165,8 @@ export function makeReplaceTool(cwd: string, fusion?: ReturnType<typeof createAc
168
165
  return text;
169
166
  },
170
167
 
171
- renderResult(result: any, { isPartial, expanded }: any, theme: any, context: any) {
172
- if (isPartial && result.details?.actionFusion?.publication !== "PUBLISHED") return new Text(theme.fg("warning", "Replacing…"), 0, 0);
173
- const content = result.content?.[0];
174
- if (context.isError) {
175
- const t = content?.type === "text" ? content.text.split("\n")[0] : "Error";
176
- return new Text(theme.fg("error", t), 0, 0);
177
- }
178
- const diff: string | undefined = result.details?.diff;
179
- // refresh the call header's +N -N in place — never invalidate from
180
- // inside a renderer (re-enters updateDisplay, diff renders twice)
181
- publishDiffCounts(diff, context, (counts) => {
182
- context.state?.callText?.setText(replaceHeader(context.args, theme, counts));
183
- });
184
- if (!diff) {
185
- // No net diff: show only the summary line — content.text also carries
186
- // `Updated anchors` (hashline) for the model.
187
- const summary = content?.type === "text" ? content.text.split("\n")[0] : "Replaced";
188
- return new Text(theme.fg("success", summary), 0, 0);
189
- }
190
- // details.diff is pi-format (+N/-N/<space>N content); renderDiff handles
191
- // semantic colors plus intra-line change highlighting
192
- const rendered = renderDiffPreview(diff, expanded, theme);
193
- return new Text(rendered, 0, 0);
168
+ renderResult(result: any, options: any, theme: any, context: any) {
169
+ return renderMutationResult(result, options, theme, context, "Replacing…", "Replaced", replaceHeader);
194
170
  },
195
171
 
196
172
  async execute(toolCallId: string, params: ReplaceParams & { then_run?: ThenRunInput }, signal: AbortSignal | undefined, onUpdate: any, ctx: any) {
@@ -199,9 +175,15 @@ export function makeReplaceTool(cwd: string, fusion?: ReturnType<typeof createAc
199
175
  const state = getState();
200
176
  const path = mutationParams.path;
201
177
  const absolutePath = canonicalPath(cwd, path);
202
- const mutate = () => withFileMutationQueue(absolutePath, () => runReplace(absolutePath, path, mutationParams, state.config.hashLen, signal));
203
- if (!fusion) return mutate();
204
- return fusion({ toolCallId, absolutePath, thenRun: then_run, mutate, signal, ctx, onUpdate });
178
+ let mutationAnchors = "";
179
+ const mutate = () => withFileMutationQueue(absolutePath, () => runReplace(absolutePath, path, mutationParams, state.config.hashLen, signal, (anchors) => { mutationAnchors = anchors; }));
180
+ const finalizeMutation = (result: any, publishAnchors: boolean) => ({
181
+ ...result,
182
+ content: result.content.map((block: any, index: number) => index === 0 && block.type === "text"
183
+ ? { ...block, text: `${block.text}${publishAnchors ? mutationAnchors : ""}` } : block),
184
+ });
185
+ if (!fusion) return finalizeMutationResult(await mutate(), finalizeMutation);
186
+ return fusion({ toolCallId, absolutePath, thenRun: then_run, mutate, finalizeMutation, signal, ctx, onUpdate });
205
187
  },
206
188
  };
207
189
  }
@@ -212,6 +194,7 @@ async function runReplace(
212
194
  params: ReplaceParams,
213
195
  hashLen: number,
214
196
  signal: AbortSignal | undefined,
197
+ onAnchors: (anchors: string) => void,
215
198
  ) {
216
199
  const { find, replace } = params;
217
200
  const isRegex = params.regex === true;
@@ -220,8 +203,11 @@ async function runReplace(
220
203
  if (find === "") throw new Error(`Replace ${displayPath}: \`find\` is empty.`);
221
204
 
222
205
  let currentText: string;
206
+ let baseRevision: string;
223
207
  try {
224
- currentText = (await readFile(absPath)).toString("utf-8");
208
+ const currentBytes = await readFile(absPath);
209
+ baseRevision = byteRevision(currentBytes);
210
+ currentText = decodeEditableText(currentBytes);
225
211
  } catch (e) {
226
212
  const msg = e instanceof Error ? e.message : String(e);
227
213
  throw new Error(`Error reading ${displayPath}: ${msg}`);
@@ -253,8 +239,6 @@ async function runReplace(
253
239
  throw new Error(`Replace ${displayPath}: no matches for ${shown}.`);
254
240
  }
255
241
 
256
- // Literal mode uses a function replacement so `$` in `replace` stays literal;
257
- // regex mode passes the string so $1/$& etc. expand.
258
242
  // Literal mode uses a function replacement so `$` in `replace` stays literal;
259
243
  // regex mode passes the string so $1/$& etc. expand.
260
244
  const newText = isRegex ? currentText.replace(regex, replace) : currentText.replace(regex, () => replace);
@@ -264,20 +248,23 @@ async function runReplace(
264
248
  if (signal?.aborted) throw new Error(`Replace ${displayPath} aborted before write.`);
265
249
 
266
250
  let publication: PublicationStatus = "NOT_PUBLISHED";
251
+ let versions: MutationVersions = { baseRevision, publishedRevision: baseRevision, observedRevision: baseRevision };
267
252
  if (changed) {
268
253
  try {
269
- publication = (await commitFile(absPath, newText, { mode: "overwrite", signal })).publication;
254
+ const commit = await commitFile(absPath, newText, { mode: "overwrite", expectedRevision: baseRevision, signal });
255
+ publication = commit.publication;
256
+ versions = commit;
270
257
  } catch (e) {
271
258
  if (e instanceof FileMutationError) throw e;
272
259
  throw new FileMutationError("commit", "UNKNOWN", `Error writing ${displayPath}: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
273
260
  }
274
261
  }
275
262
 
276
- let details: EditToolDetails & { publication: PublicationStatus };
263
+ let details: EditToolDetails & MutationVersions & { publication: PublicationStatus; revision: string };
277
264
  let anchors: string;
278
265
  let note: string;
279
266
  try {
280
- // diff、anchors 和结果文本属于发布后的后处理;失败时保留 publication。
267
+ // Diff, anchors, and summary generation happens after publication; preserve its state on failure.
281
268
  const oldLf = currentText.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
282
269
  const newLf = newText.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
283
270
  const { diff, firstChangedLine } = generateDiffString(oldLf, newLf);
@@ -286,6 +273,8 @@ async function runReplace(
286
273
  patch: generateUnifiedPatch(displayPath, oldLf, newLf),
287
274
  firstChangedLine,
288
275
  publication,
276
+ ...versions,
277
+ revision: versions.publishedRevision,
289
278
  };
290
279
  const oldLines = splitLines(currentText);
291
280
  const newLines = splitLines(newText);
@@ -293,11 +282,12 @@ async function runReplace(
293
282
  anchors = span ? formatSpanAnchors(newLines, span, hashLen) : "";
294
283
  const matchWord = `match${count !== 1 ? "es" : ""}`;
295
284
  note = changed ? `${count} ${matchWord}` : `${count} ${matchWord}, no net change`;
285
+ onAnchors(anchors);
296
286
  } catch (error) {
297
287
  throw new FileMutationError("post_process", publication, `file was published but replace result generation failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
298
288
  }
299
289
  return {
300
- content: [{ type: "text" as const, text: `Replaced ${displayPath} (${note}).${anchors}` }],
290
+ content: [{ type: "text" as const, text: `Replaced ${displayPath} (${note}).` }],
301
291
  details,
302
292
  };
303
293
  }
@@ -0,0 +1,169 @@
1
+ import { computeLineHash } from "../core/hash.ts";
2
+ import type { AgentToolResult } from "@earendil-works/pi-agent-core";
3
+ import assert from "node:assert/strict";
4
+ import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import { test } from "node:test";
8
+ import { createActionFusionExecutor } from "./action-fusion.ts";
9
+ import { makeReplaceTool } from "./replace-tool.ts";
10
+ import { makeWriteOverride } from "./write-tool.ts";
11
+ import { makeEditOverride } from "./edit-tool.ts";
12
+ import { FileMutationError } from "./file-commit.ts";
13
+ import { finalizeMutationResult } from "./mutation-result.ts";
14
+
15
+ const text = (result: any) => result.content.map((block: any) => block.text ?? "").join("\n");
16
+
17
+ test("replace withholds anchors in progress and after commands change or remove the file", async () => {
18
+ const dir = await mkdtemp(join(tmpdir(), "hashline-result-"));
19
+ try {
20
+ for (const state of ["changed", "missing", "unknown"] as const) {
21
+ for (const fails of [false, true]) {
22
+ const path = join(dir, `${state}-${fails}.txt`);
23
+ await writeFile(path, "before\n");
24
+ const updates: any[] = [];
25
+ const fusion = createActionFusionExecutor(async (_id, _input, _signal, _ctx, onUpdate) => {
26
+ if (state === "changed") await writeFile(path, "command output\n");
27
+ else {
28
+ await rm(path);
29
+ if (state === "unknown") await mkdir(path);
30
+ }
31
+ onUpdate?.({ content: [{ type: "text", text: "progress" }], details: undefined });
32
+ if (fails) throw new Error("command failed");
33
+ return "done";
34
+ });
35
+ const result = await makeReplaceTool(dir, fusion).execute("replace", {
36
+ path, find: "before", replace: "after", then_run: { command: "check" },
37
+ }, undefined, (update: any) => updates.push(update), { cwd: dir });
38
+ assert.equal(result.details.actionFusion.freshness, state);
39
+ assert.equal(result.details.publication, "PUBLISHED");
40
+ assert.doesNotMatch(text(result), /Updated anchors|\d+#[0-9A-Z]+│/);
41
+ assert.match(text(result), /Re-read/);
42
+ for (const update of updates) assert.doesNotMatch(text(update), /Updated anchors|\d+#[0-9A-Z]+│/);
43
+ }
44
+ }
45
+ } finally {
46
+ await rm(dir, { recursive: true, force: true });
47
+ }
48
+ });
49
+
50
+ test("progress callback failures preserve publication and do not prevent the command", async () => {
51
+ const dir = await mkdtemp(join(tmpdir(), "hashline-progress-"));
52
+ try {
53
+ for (const callback of ["reporter", "update"]) {
54
+ let commands = 0;
55
+ const fail = () => { throw new Error("display unavailable"); };
56
+ const fusion = createActionFusionExecutor(async () => { commands++; return "done"; }, callback === "reporter" ? fail : undefined);
57
+ const path = join(dir, callback);
58
+ const result = await makeWriteOverride(dir, fusion).execute("write", {
59
+ path, content: "saved\n", then_run: { command: "check" },
60
+ }, undefined, callback === "update" ? fail : undefined, { cwd: dir });
61
+ assert.equal(commands, 1);
62
+ assert.equal(await readFile(path, "utf8"), "saved\n");
63
+ assert.equal(result.details.actionFusion.publication, "PUBLISHED");
64
+ assert.equal(result.details.actionFusion.command, "succeeded");
65
+ assert.match(text(result), /display unavailable/);
66
+ }
67
+ const fusion = createActionFusionExecutor(undefined, () => { throw new Error("display unavailable"); });
68
+ await assert.rejects(fusion({
69
+ toolCallId: "failed", absolutePath: join(dir, "failed"), thenRun: { command: "check" },
70
+ mutate: async () => { throw new FileMutationError("post_process", "PUBLISHED", "original failure"); },
71
+ signal: undefined, ctx: { cwd: dir } as any,
72
+ }), (error: any) => error.publication === "PUBLISHED" && /original failure/.test(error.message));
73
+ } finally {
74
+ await rm(dir, { recursive: true, force: true });
75
+ }
76
+ });
77
+
78
+ test("standalone and Fusion finalizers suppress anchors unless commit observations agree", async () => {
79
+ const dir = await mkdtemp(join(tmpdir(), "hashline-finalizer-"));
80
+ try {
81
+ for (const observedRevision of ["published", "external", undefined]) {
82
+ const mutation = { content: [{ type: "text" as const, text: "saved" }], details: { publication: "PUBLISHED" as const, publishedRevision: "published", observedRevision } };
83
+ const finalize = (result: AgentToolResult<typeof mutation.details>, expose: boolean) => ({ ...result, content: [{ type: "text" as const, text: `saved${expose ? " ANCHOR" : ""}` }] });
84
+ const standalone = finalizeMutationResult(mutation, finalize);
85
+ const fused = await createActionFusionExecutor()({ toolCallId: "no-command", absolutePath: join(dir, "file"), thenRun: undefined, mutate: async () => mutation, finalizeMutation: finalize, signal: undefined, ctx: { cwd: dir } as any });
86
+ for (const result of [standalone, fused]) {
87
+ assert.equal(text(result).includes("ANCHOR"), observedRevision === "published");
88
+ assert.equal(result.details.publication, "PUBLISHED");
89
+ if (observedRevision !== "published") assert.match(text(result), /Re-read/);
90
+ }
91
+ assert.throws(() => finalizeMutationResult(mutation, () => { throw new Error("formatting failed"); }),
92
+ (error: any) => error instanceof FileMutationError && error.publication === "PUBLISHED" && /publication=PUBLISHED/.test(error.message));
93
+ }
94
+ } finally {
95
+ await rm(dir, { recursive: true, force: true });
96
+ }
97
+ });
98
+
99
+ test("mutation anchor output and aggregate anchor diagnostics have byte budgets", async () => {
100
+ const dir = await mkdtemp(join(tmpdir(), "hashline-budget-"));
101
+ try {
102
+ const path = join(dir, "long.txt");
103
+ const long = "界".repeat(100000);
104
+ for (const name of ["edit", "replace"]) {
105
+ await writeFile(path, "before\n");
106
+ const tool = name === "edit" ? makeEditOverride(dir) : makeReplaceTool(dir);
107
+ const args = name === "edit" ? { edits: [{ op: "append", body: [long] }] } : { find: "before", replace: long };
108
+ const result = await tool.execute(name, { path, ...args }, undefined, undefined, { cwd: dir });
109
+ const output = text(result);
110
+ assert.ok(Buffer.byteLength(output) < 17 * 1024);
111
+ assert.match(output, /omitted|truncated/i);
112
+ assert.doesNotMatch(output, /\d+#[0-9A-Z]+│界/);
113
+ assert.ok((await readFile(path, "utf8")).includes(long));
114
+ }
115
+ await writeFile(path, "current\n");
116
+ await assert.rejects(makeEditOverride(dir).execute("errors", {
117
+ path, edits: Array.from({ length: 1000 }, () => ({ op: "delete", anchor: "1#XXXX" })),
118
+ }, undefined, undefined, { cwd: dir }), (error: Error) => {
119
+ assert.ok(Buffer.byteLength(error.message) <= 16 * 1024);
120
+ assert.match(error.message, /omitted|truncated/i);
121
+ return true;
122
+ });
123
+ } finally {
124
+ await rm(dir, { recursive: true, force: true });
125
+ }
126
+ });
127
+
128
+ test("every mutation entry rejects unpaired surrogates without running then_run", async () => {
129
+ const dir = await mkdtemp(join(tmpdir(), "hashline-unicode-"));
130
+ try {
131
+ let commands = 0;
132
+ const fusion = createActionFusionExecutor(async () => { commands++; return "done"; });
133
+ const path = join(dir, "file.txt");
134
+ await writeFile(path, "original\n");
135
+ for (const [tool, args] of [
136
+ [makeEditOverride(dir, fusion), { edits: [{ op: "append", body: ["\ud800"] }] }],
137
+ [makeReplaceTool(dir, fusion), { find: "original", replace: "\udfff" }],
138
+ [makeWriteOverride(dir, fusion), { content: "\ud800" }],
139
+ ] as const) {
140
+ await assert.rejects(tool.execute("unicode", { path, ...args, then_run: { command: "check" } }, undefined, undefined, { cwd: dir }),
141
+ (error: any) => error.publication === "NOT_PUBLISHED" && /INVALID_UNICODE/.test(error.message));
142
+ assert.equal(await readFile(path, "utf8"), "original\n");
143
+ }
144
+ assert.equal(commands, 0);
145
+ } finally {
146
+ await rm(dir, { recursive: true, force: true });
147
+ }
148
+ });
149
+
150
+ test("ambiguous recovery bounds candidate lists and never claims content identity", async () => {
151
+ const dir = await mkdtemp(join(tmpdir(), "hashline-candidates-"));
152
+ try {
153
+ const path = join(dir, "file.txt");
154
+ const lines = Array.from({ length: 100 }, () => "same");
155
+ lines[49] = "different";
156
+ await writeFile(path, lines.join("\n"));
157
+ await assert.rejects(makeEditOverride(dir).execute("ambiguous", {
158
+ path, edits: Array.from({ length: 1000 }, () => ({ op: "delete", anchor: `50#${computeLineHash(50, "same")}` })),
159
+ }, undefined, undefined, { cwd: dir }), (error: Error) => {
160
+ assert.ok(Buffer.byteLength(error.message) <= 16 * 1024);
161
+ assert.match(error.message, /ambiguous checksum matches/);
162
+ assert.match(error.message, /candidates omitted/);
163
+ assert.doesNotMatch(error.message, /same content/);
164
+ return true;
165
+ });
166
+ } finally {
167
+ await rm(dir, { recursive: true, force: true });
168
+ }
169
+ });
@@ -5,6 +5,7 @@ import { ACTION_FUSION_GUIDELINES, createActionFusionExecutor, createThenRunSche
5
5
  import { commitFile, FileMutationError, type CommitMode } from "./file-commit.ts";
6
6
  import { canonicalPath } from "./read-tool.ts";
7
7
  import { computeLineHash, splitLines } from "../core/index.ts";
8
+ import { finalizeMutationResult } from "./mutation-result.ts";
8
9
 
9
10
  function createWriteSchema(actionFusion: boolean) {
10
11
  return Type.Object({
@@ -45,6 +46,7 @@ export function makeWriteOverride(cwd: string, fusion?: ReturnType<typeof create
45
46
  async execute(toolCallId: string, params: WriteParams, signal: AbortSignal | undefined, onUpdate: any, ctx: any) {
46
47
  const { then_run, ...mutationParams } = params;
47
48
  if (!fusion && then_run !== undefined) throw new Error("then_run is unavailable because hashlineEdit.actionFusion is disabled");
49
+ if (mutationParams.content.includes("\0")) throw new Error("UNSUPPORTED_TEXT: NUL bytes are not editable.");
48
50
  const absolutePath = canonicalPath(cwd, mutationParams.path);
49
51
  const hashLen = getState().config.hashLen;
50
52
  let mutationAnchors = "";
@@ -59,7 +61,15 @@ export function makeWriteOverride(cwd: string, fusion?: ReturnType<typeof create
59
61
  mutationAnchors = formatAnchors(mutationParams.content, hashLen);
60
62
  return {
61
63
  content: [{ type: "text" as const, text: `${result.created ? "Created" : "Wrote"} ${mutationParams.path}.\nRevision: ${result.revision}` }],
62
- details: { path: mutationParams.path, revision: result.revision, created: result.created, publication: result.publication },
64
+ details: {
65
+ path: mutationParams.path,
66
+ revision: result.publishedRevision,
67
+ baseRevision: result.baseRevision,
68
+ publishedRevision: result.publishedRevision,
69
+ observedRevision: result.observedRevision,
70
+ created: result.created,
71
+ publication: result.publication,
72
+ },
63
73
  };
64
74
  } catch (error) {
65
75
  throw new FileMutationError("post_process", "PUBLISHED", `file was published but write result generation failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
@@ -76,7 +86,7 @@ export function makeWriteOverride(cwd: string, fusion?: ReturnType<typeof create
76
86
  }],
77
87
  };
78
88
  };
79
- if (!fusion) return finalizeMutation(await mutate(), true);
89
+ if (!fusion) return finalizeMutationResult(await mutate(), finalizeMutation);
80
90
  return fusion({ toolCallId, absolutePath, thenRun: then_run, mutate, finalizeMutation, signal, ctx, onUpdate });
81
91
  },
82
92
  };
@@ -98,7 +98,7 @@ test("write omits pre-command anchors when then_run changes the target", async (
98
98
  const text = result.content.map((block: any) => block.text).join("\n");
99
99
  assert.match(text, /Mutation revision:/);
100
100
  assert.match(text, /Pre-command anchors are omitted/);
101
- assert.match(text, /mutation revision may not describe the final file/i);
101
+ assert.match(text, /published revision may not describe the final file/i);
102
102
  assert.doesNotMatch(text, /Fresh anchors:|\b1#[0-9A-Z]+\b/);
103
103
  assert.equal(result.details.actionFusion.freshness, "changed");
104
104
  assert.deepEqual(write.renderResult(result, { isPartial: false }, {}, { isError: false }).render(100), []);
@@ -124,3 +124,9 @@ test("write omits anchors when a failed then_run changed the target", async () =
124
124
  assert.match(text, /Pre-command anchors are omitted/);
125
125
  assert.doesNotMatch(text, /Fresh anchors:/);
126
126
  }));
127
+
128
+ test("write rejects NUL content", async () => withTemp(async (dir) => {
129
+ const write = makeWriteOverride(dir);
130
+ await assert.rejects(write.execute("nul", { path: "nul.txt", content: "a\0b" }, undefined, undefined, context(dir)), /UNSUPPORTED_TEXT/);
131
+ await assert.rejects(readFile(join(dir, "nul.txt")), /ENOENT/);
132
+ }));