@criogaid/pi-hashline-edit 0.7.0 → 0.9.0
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 +76 -220
- package/README.zh-CN.md +166 -0
- package/package.json +2 -1
- package/src/core/AGENTS.md +1 -1
- package/src/core/apply.test.ts +171 -133
- package/src/core/apply.ts +34 -31
- package/src/core/case-fold.test.ts +11 -7
- package/src/core/case-fold.ts +2 -6
- package/src/core/character-set.ts +14 -0
- package/src/core/hash.test.ts +1 -25
- package/src/core/hash.ts +0 -5
- package/src/core/lines.ts +25 -7
- package/src/core/ranges.test.ts +49 -9
- package/src/core/ranges.ts +15 -4
- package/src/core/regex.ts +36 -6
- package/src/core/replace-schema.ts +18 -11
- package/src/core/replace.test.ts +90 -0
- package/src/core/replace.ts +6 -5
- package/src/core/search-analysis.test.ts +9 -0
- package/src/core/search-analysis.ts +35 -31
- package/src/core/search.ts +1 -1
- package/src/core/types.ts +6 -8
- package/src/index.ts +2 -4
- package/src/integration/config-registration.test.ts +18 -10
- package/src/integration/fusion-dispatch.test.ts +41 -22
- package/src/integration/grep-flags.test.ts +6 -13
- package/src/integration/grep-js-completeness.test.ts +41 -31
- package/src/integration/grep-order.test.ts +78 -0
- package/src/integration/grep-path-matrix.test.ts +4 -3
- package/src/integration/grep-regex.test.ts +13 -16
- package/src/integration/grep-rg.test.ts +132 -92
- package/src/integration/grep-scan-budget.test.ts +27 -5
- package/src/integration/large-text.test.ts +4 -5
- package/src/integration/model-budget-lifecycle.test.ts +26 -8
- package/src/integration/mutation-file-types.test.ts +0 -1
- package/src/integration/mutation-file-types.testing.ts +2 -2
- package/src/integration/npm-package.testing.ts +7 -33
- package/src/integration/publication-read-changes.test.ts +60 -28
- package/src/integration/replace-package.testing.ts +4 -1
- package/src/integration/replace-worker-boundary.test.ts +34 -24
- package/src/integration/report-replay.test.ts +3 -3
- package/src/integration/utf8-errors.test.ts +3 -3
- package/src/pi/AGENTS.md +13 -14
- package/src/pi/action-fusion.test.ts +75 -220
- package/src/pi/action-fusion.ts +37 -74
- package/src/pi/anchor-format.test.ts +16 -0
- package/src/pi/anchor-format.ts +7 -3
- package/src/pi/argument-diagnostics.ts +35 -186
- package/src/pi/argument-error.testing.ts +7 -4
- package/src/pi/argument-error.ts +5 -7
- package/src/pi/argument-format.test.ts +25 -38
- package/src/pi/argument-validation.test.ts +446 -420
- package/src/pi/argument-validation.ts +4 -5
- package/src/pi/budgets.ts +5 -7
- package/src/pi/config.test.ts +15 -5
- package/src/pi/config.ts +6 -6
- package/src/pi/diagnostic-buffer.test.ts +2 -3
- package/src/pi/diagnostic-buffer.ts +2 -2
- package/src/pi/edit-tool.ts +175 -121
- package/src/pi/execute.test.ts +170 -227
- package/src/pi/failure-context.test.ts +61 -16
- package/src/pi/failure-context.ts +13 -10
- package/src/pi/failure-path.test.ts +115 -50
- package/src/pi/file-commit.test.ts +30 -46
- package/src/pi/file-commit.ts +11 -40
- package/src/pi/file-revision.ts +25 -0
- package/src/pi/fusion-card-interaction.test.ts +143 -0
- package/src/pi/fusion-card.test.ts +193 -37
- package/src/pi/fusion-card.ts +186 -116
- package/src/pi/grep-candidates.ts +25 -27
- package/src/pi/grep-matrix.test.ts +1 -1
- package/src/pi/grep-order.test.ts +323 -0
- package/src/pi/grep-output.testing.ts +24 -0
- package/src/pi/grep-output.ts +62 -69
- package/src/pi/grep-render.ts +4 -1
- package/src/pi/grep-scope.ts +1 -1
- package/src/pi/grep-search.ts +85 -56
- package/src/pi/grep-tool.ts +17 -48
- package/src/pi/grep.test.ts +271 -170
- package/src/pi/mutation-outcome.testing.ts +2 -3
- package/src/pi/mutation-result.test.ts +26 -19
- package/src/pi/mutation-result.ts +25 -40
- package/src/pi/mutation-runner.ts +9 -17
- package/src/pi/output-budgets.test.ts +27 -18
- package/src/pi/path.ts +3 -1
- package/src/pi/pi.test.ts +7 -6
- package/src/pi/read-tool.ts +32 -80
- package/src/pi/read.test.ts +145 -92
- package/src/pi/regex-worker-contract.ts +5 -23
- package/src/pi/regex-worker.ts +4 -10
- package/src/pi/registration.test.ts +106 -67
- package/src/pi/render.test.ts +239 -109
- package/src/pi/render.ts +42 -22
- package/src/pi/replace-regex.ts +3 -5
- package/src/pi/replace-tool.ts +29 -27
- package/src/pi/replace-worker-contract.ts +3 -12
- package/src/pi/replace.test.ts +144 -226
- package/src/pi/report-cause.ts +23 -19
- package/src/pi/report-failure.testing.ts +2 -2
- package/src/pi/report-schema.ts +60 -45
- package/src/pi/report.test.ts +138 -71
- package/src/pi/report.ts +40 -43
- package/src/pi/result-safety.test.ts +186 -131
- package/src/pi/rg-process.test.ts +36 -10
- package/src/pi/rg-process.ts +9 -3
- package/src/pi/rg-regex.test.ts +17 -0
- package/src/pi/rg-regex.ts +28 -22
- package/src/pi/text-stream.test.ts +35 -36
- package/src/pi/text-stream.ts +14 -14
- package/src/pi/tool-call.testing.ts +17 -7
- package/src/pi/write-tool.ts +9 -11
- package/src/pi/write.test.ts +43 -75
- package/src/testing/regex-translation-corpus.ts +16 -0
- package/src/testing/rg-line-listing.fixture.mjs +1 -1
- package/src/integration/forget-grep.test.ts +0 -148
- package/src/pi/forget-tool.ts +0 -367
- package/src/pi/forget.test.ts +0 -630
- package/src/pi/forget.testing.ts +0 -201
package/src/pi/report-cause.ts
CHANGED
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
* mapping, so it must not import typebox at runtime.
|
|
5
5
|
* External boundaries validate cause data before restoreCause.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
errnoCode,
|
|
9
|
+
errorMessage,
|
|
10
|
+
HashlineError,
|
|
11
|
+
type HashlineErrorOptions,
|
|
12
|
+
} from "../core/errors.ts";
|
|
9
13
|
import { DiagnosticBuffer } from "./diagnostic-buffer.ts";
|
|
10
|
-
import type { Cause } from "./report-schema.ts";
|
|
14
|
+
import type { Cause, ErrorCode } from "./report-schema.ts";
|
|
11
15
|
|
|
12
16
|
class RestoredCause extends Error {
|
|
13
17
|
readonly data: Cause;
|
|
@@ -23,7 +27,7 @@ export function restoreCause(data: Cause | undefined): Error | undefined {
|
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
/** One free-text value within its budget, keeping the opening and the final cause. */
|
|
26
|
-
export function boundedText(text: string, maxBytes
|
|
30
|
+
export function boundedText(text: string, maxBytes: number): string {
|
|
27
31
|
if (Buffer.byteLength(text) <= maxBytes) return text;
|
|
28
32
|
const buffer = new DiagnosticBuffer(maxBytes);
|
|
29
33
|
buffer.append(text);
|
|
@@ -38,31 +42,31 @@ function boundedCause(data: Cause, maxBytes: number): Cause {
|
|
|
38
42
|
...(data.errors ? { errors: data.errors.map((inner) => boundedCause(inner, maxBytes)) } : {}),
|
|
39
43
|
};
|
|
40
44
|
}
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* stays free of typebox: the contract module imports typebox to validate replies,
|
|
45
|
-
* and the worker runs on plain jiti without the host's module mapping.
|
|
45
|
+
/**
|
|
46
|
+
* A failure a regex worker transports: its code ties the facts that code requires.
|
|
47
|
+
* The host still validates every reply (regex-worker-contract.ts) before trusting it.
|
|
46
48
|
*/
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
49
|
+
export type WorkerError = {
|
|
50
|
+
[C in ErrorCode]: {
|
|
51
|
+
readonly code: C;
|
|
52
|
+
readonly message: string;
|
|
53
|
+
readonly cause?: Cause;
|
|
54
|
+
} & Pick<HashlineErrorOptions<C>, "facts">;
|
|
55
|
+
}[ErrorCode];
|
|
56
|
+
type WorkerFailure = { readonly error: WorkerError };
|
|
54
57
|
|
|
55
58
|
/** Transport full failures; the receiving tool applies its model-budget snapshot. */
|
|
56
59
|
export function workerFailure(caught: unknown): WorkerFailure {
|
|
57
60
|
if (caught instanceof HashlineError) {
|
|
58
|
-
// Its constructor enforced the code/facts relationship
|
|
61
|
+
// Its constructor enforced the code/facts relationship; TypeScript cannot carry that link
|
|
62
|
+
// through the generic errorCode.
|
|
59
63
|
return {
|
|
60
64
|
error: {
|
|
61
65
|
code: caught.errorCode,
|
|
62
66
|
message: caught.message,
|
|
63
67
|
...(caught.facts === undefined ? {} : { facts: caught.facts }),
|
|
64
68
|
...(caught.cause === undefined ? {} : { cause: causeOf(caught.cause, Infinity) }),
|
|
65
|
-
},
|
|
69
|
+
} as WorkerError,
|
|
66
70
|
};
|
|
67
71
|
}
|
|
68
72
|
return {
|
|
@@ -77,7 +81,7 @@ export function workerFailure(caught: unknown): WorkerFailure {
|
|
|
77
81
|
/** Preserve underlying failures; visit each native error once to avoid cycles and repeats. */
|
|
78
82
|
export function causeOf(
|
|
79
83
|
error: unknown,
|
|
80
|
-
maxBytes
|
|
84
|
+
maxBytes: number,
|
|
81
85
|
seen = new Set<unknown>(),
|
|
82
86
|
): Cause | undefined {
|
|
83
87
|
if (error === undefined || seen.has(error)) return undefined;
|
|
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
3
3
|
import type { ErrorCode } from "../core/errors.ts";
|
|
4
4
|
import type { Report } from "./report-schema.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { detailsReport } from "./report.ts";
|
|
6
6
|
|
|
7
7
|
/** Assert execution failures through the returned model/TUI report, without changing tool semantics. */
|
|
8
8
|
export async function expectToolFailure(
|
|
@@ -12,7 +12,7 @@ export async function expectToolFailure(
|
|
|
12
12
|
): Promise<Report> {
|
|
13
13
|
const result = await pending;
|
|
14
14
|
assert.equal(result.isError, true);
|
|
15
|
-
const report =
|
|
15
|
+
const report = detailsReport(result.details);
|
|
16
16
|
assert.ok(report);
|
|
17
17
|
assert.equal(report.error, code);
|
|
18
18
|
inspect?.(report);
|
package/src/pi/report-schema.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* failure report is the entire result; a success report follows the tool's
|
|
8
8
|
* content payload (read rows, grep rows). Each field has one
|
|
9
9
|
* owning layer (README "Reports"), so no fact can be stated twice. report.ts
|
|
10
|
-
* omits tool and path from
|
|
10
|
+
* omits the call's tool and path from result text; render.ts uses the full report for the TUI.
|
|
11
11
|
*
|
|
12
12
|
* Types derive from these schemas. src/core imports only types from this module,
|
|
13
13
|
* so engines stay independent of Pi. The worker loads TypeBox at its data boundary.
|
|
@@ -38,21 +38,21 @@ export const CAUSE_SCHEMA = Type.Cyclic(
|
|
|
38
38
|
);
|
|
39
39
|
export type Cause = Static<typeof CAUSE_SCHEMA>;
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const PUBLICATION_SCHEMA = Type.Union([
|
|
42
42
|
Type.Literal("NOT_PUBLISHED"),
|
|
43
43
|
Type.Literal("PUBLISHED"),
|
|
44
44
|
Type.Literal("UNKNOWN"),
|
|
45
45
|
]);
|
|
46
46
|
export type PublicationStatus = Static<typeof PUBLICATION_SCHEMA>;
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const STAGE_SCHEMA = Type.Union([
|
|
49
49
|
Type.Literal("prepare"),
|
|
50
50
|
Type.Literal("commit"),
|
|
51
51
|
Type.Literal("post_process"),
|
|
52
52
|
]);
|
|
53
53
|
export type MutationStage = Static<typeof STAGE_SCHEMA>;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
const FRESHNESS_SCHEMA = Type.Union([
|
|
56
56
|
Type.Literal("unchanged"),
|
|
57
57
|
Type.Literal("changed"),
|
|
58
58
|
Type.Literal("missing"),
|
|
@@ -61,7 +61,7 @@ export const FRESHNESS_SCHEMA = Type.Union([
|
|
|
61
61
|
export type Freshness = Static<typeof FRESHNESS_SCHEMA>;
|
|
62
62
|
|
|
63
63
|
/** A then_run command's final status; `skipped` never started, `cancelled` may have. */
|
|
64
|
-
|
|
64
|
+
const COMMAND_STATUS_SCHEMA = Type.Union([
|
|
65
65
|
Type.Literal("succeeded"),
|
|
66
66
|
Type.Literal("failed"),
|
|
67
67
|
Type.Literal("timeout"),
|
|
@@ -70,16 +70,39 @@ export const COMMAND_STATUS_SCHEMA = Type.Union([
|
|
|
70
70
|
]);
|
|
71
71
|
export type CommandStatus = Static<typeof COMMAND_STATUS_SCHEMA>;
|
|
72
72
|
|
|
73
|
+
/** A then_run command's session tool result, as the TUI renders it. */
|
|
74
|
+
const COMMAND_RESULT_SCHEMA = Type.Object(
|
|
75
|
+
{
|
|
76
|
+
content: Type.Array(
|
|
77
|
+
Type.Union([
|
|
78
|
+
Type.Object(
|
|
79
|
+
{
|
|
80
|
+
type: Type.Literal("text"),
|
|
81
|
+
text: Type.String(),
|
|
82
|
+
textSignature: opt(Type.String()),
|
|
83
|
+
},
|
|
84
|
+
{ additionalProperties: false },
|
|
85
|
+
),
|
|
86
|
+
Type.Object(
|
|
87
|
+
{ type: Type.Literal("image"), data: Type.String(), mimeType: Type.String() },
|
|
88
|
+
{ additionalProperties: false },
|
|
89
|
+
),
|
|
90
|
+
]),
|
|
91
|
+
),
|
|
92
|
+
details: opt(Type.Unknown()),
|
|
93
|
+
},
|
|
94
|
+
{ additionalProperties: false },
|
|
95
|
+
);
|
|
96
|
+
export type CommandResult = Static<typeof COMMAND_RESULT_SCHEMA>;
|
|
97
|
+
|
|
73
98
|
/** Fusion updates cross RPC and transcript boundaries before a final tool report exists. */
|
|
74
99
|
export const ACTION_FUSION_PROGRESS_SCHEMA = Type.Object(
|
|
75
100
|
{
|
|
76
101
|
toolCallId: Type.String(),
|
|
77
|
-
path: Type.String(),
|
|
78
102
|
commandText: Type.String(),
|
|
79
103
|
command: Type.Union([COMMAND_STATUS_SCHEMA, Type.Literal("waiting"), Type.Literal("running")]),
|
|
80
|
-
publication: PUBLICATION_SCHEMA,
|
|
81
104
|
freshness: FRESHNESS_SCHEMA,
|
|
82
|
-
|
|
105
|
+
result: opt(COMMAND_RESULT_SCHEMA),
|
|
83
106
|
mutationCompleted: Type.Boolean(),
|
|
84
107
|
timing: opt(
|
|
85
108
|
Type.Object(
|
|
@@ -98,7 +121,7 @@ export type ActionFusionProgress = Static<typeof ACTION_FUSION_PROGRESS_SCHEMA>;
|
|
|
98
121
|
const ANCHOR_FAILURE_SCHEMA = Type.Object(
|
|
99
122
|
{
|
|
100
123
|
field: Type.String(),
|
|
101
|
-
|
|
124
|
+
action: Type.String(),
|
|
102
125
|
cited: Type.String(),
|
|
103
126
|
result: Type.Union([
|
|
104
127
|
Type.Literal("shifted"),
|
|
@@ -108,17 +131,18 @@ const ANCHOR_FAILURE_SCHEMA = Type.Object(
|
|
|
108
131
|
search: opt(Type.Union([Type.Literal("local window"), Type.Literal("full file")])),
|
|
109
132
|
candidate: opt(Type.String()),
|
|
110
133
|
content: opt(Type.String()),
|
|
111
|
-
contentOmitted: opt(Type.String()),
|
|
112
134
|
candidates: opt(Type.Array(Type.String())),
|
|
113
135
|
omittedCandidates: opt(Type.Integer({ minimum: 1 })),
|
|
114
136
|
observed: opt(Type.String()),
|
|
115
|
-
|
|
137
|
+
omitted: opt(
|
|
138
|
+
Type.String({ description: "Why content (shifted) or observed (unresolved) is absent." }),
|
|
139
|
+
),
|
|
116
140
|
},
|
|
117
141
|
{ additionalProperties: false },
|
|
118
142
|
);
|
|
119
143
|
export type AnchorFailureFact = Static<typeof ANCHOR_FAILURE_SCHEMA>;
|
|
120
144
|
|
|
121
|
-
|
|
145
|
+
const ARGUMENT_ISSUE_SCHEMA = Type.Object(
|
|
122
146
|
{
|
|
123
147
|
field: Type.String({
|
|
124
148
|
description: "Path of the field in Pi's prepared arguments; `$` for none.",
|
|
@@ -134,9 +158,9 @@ export type ArgumentIssue = Static<typeof ARGUMENT_ISSUE_SCHEMA>;
|
|
|
134
158
|
|
|
135
159
|
/**
|
|
136
160
|
* Every fact a report can carry beside the envelope, in output order: failure
|
|
137
|
-
* facts first, then each tool's outcome, freshness, the command
|
|
161
|
+
* facts first, then each tool's outcome, freshness, and the command.
|
|
138
162
|
*/
|
|
139
|
-
|
|
163
|
+
const FACT_FIELDS = {
|
|
140
164
|
// Argument rejection (argument-error.ts).
|
|
141
165
|
issues: Type.Array(ARGUMENT_ISSUE_SCHEMA),
|
|
142
166
|
omittedIssues: count("Issues omitted from the byte budget."),
|
|
@@ -163,7 +187,7 @@ export const FACT_FIELDS = {
|
|
|
163
187
|
offset: Type.Integer({ minimum: 0 }),
|
|
164
188
|
timeoutMs: Type.Integer({ minimum: 1 }),
|
|
165
189
|
exitCode: Type.Union([Type.Integer(), Type.Null()]),
|
|
166
|
-
// read outcome.
|
|
190
|
+
// read outcome; `outputLimit` below is shared with grep.
|
|
167
191
|
pagination: Type.Object(
|
|
168
192
|
{
|
|
169
193
|
start: Type.Integer(),
|
|
@@ -173,7 +197,6 @@ export const FACT_FIELDS = {
|
|
|
173
197
|
},
|
|
174
198
|
{ additionalProperties: false },
|
|
175
199
|
),
|
|
176
|
-
truncatedAt: Type.String({ description: "The byte budget that stopped the output." }),
|
|
177
200
|
lineTooLong: Type.Object(
|
|
178
201
|
{ line: Type.Integer(), limit: Type.String() },
|
|
179
202
|
{ additionalProperties: false },
|
|
@@ -190,12 +213,15 @@ export const FACT_FIELDS = {
|
|
|
190
213
|
description:
|
|
191
214
|
"Bytes of files read when every file was a candidate; later files were not searched.",
|
|
192
215
|
}),
|
|
193
|
-
outputLimit: Type.String({ description: "
|
|
216
|
+
outputLimit: Type.String({ description: "The output byte budget that cut the result." }),
|
|
194
217
|
linePreviewLimit: Type.Integer({ description: "UTF-16 units kept in a cut line preview." }),
|
|
195
218
|
invalidUtf8: Type.Array(Type.String(), {
|
|
196
219
|
description: "Files shown as plain previews; their rows are not edit anchors.",
|
|
197
220
|
}),
|
|
198
221
|
diagnostics: Type.String({ description: "Search diagnostics; results cover confirmed matches." }),
|
|
222
|
+
literalPipe: Type.Literal(true, {
|
|
223
|
+
description: "A literal pattern contains |, which matches only the | character.",
|
|
224
|
+
}),
|
|
199
225
|
// Mutation outcome.
|
|
200
226
|
created: Type.Literal(true),
|
|
201
227
|
// Commit-layer observation after publication.
|
|
@@ -207,14 +233,6 @@ export const FACT_FIELDS = {
|
|
|
207
233
|
{ additionalProperties: false },
|
|
208
234
|
),
|
|
209
235
|
progressError: CAUSE_SCHEMA,
|
|
210
|
-
// forget.
|
|
211
|
-
forgotten: Type.Array(Type.String()),
|
|
212
|
-
notForgettable: Type.Array(Type.String(), {
|
|
213
|
-
description: "Named ids that are not tagged results of the previous response.",
|
|
214
|
-
}),
|
|
215
|
-
resultId: Type.String({ description: "Id to pass to forget." }),
|
|
216
|
-
forgetScope: Type.String(),
|
|
217
|
-
contentForgotten: Type.Literal(true),
|
|
218
236
|
} satisfies TProperties;
|
|
219
237
|
|
|
220
238
|
type FactName = keyof typeof FACT_FIELDS;
|
|
@@ -240,10 +258,6 @@ function facts<const R extends readonly FactName[], const O extends readonly Fac
|
|
|
240
258
|
const NONE = facts([]);
|
|
241
259
|
const MATCHED = ["matched", "omittedMatched"] as const;
|
|
242
260
|
|
|
243
|
-
/** Text shared by forget's failure and partial success: a later response cannot forget them either. */
|
|
244
|
-
const NOT_FORGETTABLE_NEXT =
|
|
245
|
-
"Do not call forget again for the notForgettable ids; those results stay in context.";
|
|
246
|
-
|
|
247
261
|
/**
|
|
248
262
|
* Each error code: its facts and its recovery. `next.default` is the code's
|
|
249
263
|
* recovery; other keys are the only alternatives a throw site may select.
|
|
@@ -287,7 +301,10 @@ export const ERROR_DEFINITIONS = {
|
|
|
287
301
|
},
|
|
288
302
|
OVERLAPPING_EDITS: {
|
|
289
303
|
facts: facts([], MATCHED),
|
|
290
|
-
next: {
|
|
304
|
+
next: {
|
|
305
|
+
default:
|
|
306
|
+
"Merge overlapping edits into one edit per range, and insertions at one position into one insertion.",
|
|
307
|
+
},
|
|
291
308
|
},
|
|
292
309
|
NO_MATCH: {
|
|
293
310
|
facts: facts(["rule"]),
|
|
@@ -307,7 +324,10 @@ export const ERROR_DEFINITIONS = {
|
|
|
307
324
|
},
|
|
308
325
|
TARGET_EXISTS: {
|
|
309
326
|
facts: NONE,
|
|
310
|
-
next: {
|
|
327
|
+
next: {
|
|
328
|
+
default:
|
|
329
|
+
'Check the path and read the existing file. Use mode "overwrite" only if replacing that file is intended.',
|
|
330
|
+
},
|
|
311
331
|
},
|
|
312
332
|
NOT_REGULAR_FILE: { facts: NONE },
|
|
313
333
|
MULTIPLE_HARD_LINKS: { facts: NONE },
|
|
@@ -327,10 +347,6 @@ export const ERROR_DEFINITIONS = {
|
|
|
327
347
|
UNSUPPORTED_PATH: {
|
|
328
348
|
facts: NONE,
|
|
329
349
|
},
|
|
330
|
-
NOT_FORGETTABLE: {
|
|
331
|
-
facts: facts(["notForgettable"]),
|
|
332
|
-
next: { default: NOT_FORGETTABLE_NEXT },
|
|
333
|
-
},
|
|
334
350
|
UNCLASSIFIED: { facts: NONE },
|
|
335
351
|
} as const satisfies Record<
|
|
336
352
|
string,
|
|
@@ -376,16 +392,18 @@ export const OUTCOME_NEXT = [
|
|
|
376
392
|
"lineTooLong",
|
|
377
393
|
"Inspect the line in chunks with bash, or use replace for a known literal or regex change; a smaller limit cannot split a line.",
|
|
378
394
|
],
|
|
379
|
-
["pagination", "
|
|
380
|
-
["matchLimit", "
|
|
395
|
+
["pagination", "If you need more lines, set offset to pagination.nextOffset."],
|
|
396
|
+
["matchLimit", "If you need more matches, raise limit to include rows after the last one shown."],
|
|
397
|
+
[
|
|
398
|
+
"literalPipe",
|
|
399
|
+
"If you meant alternatives, pass them as a pattern array. Otherwise, keep literal matching.",
|
|
400
|
+
],
|
|
381
401
|
[
|
|
382
402
|
"scanLimit",
|
|
383
403
|
"Narrow path or glob, or add text every match must contain, to search the remaining files.",
|
|
384
404
|
],
|
|
385
405
|
["outputLimit", "Narrow path, glob, or pattern to see the omitted output."],
|
|
386
406
|
["linePreviewLimit", "Read the full line before rewriting it from a partial preview."],
|
|
387
|
-
["notForgettable", NOT_FORGETTABLE_NEXT],
|
|
388
|
-
["contentForgotten", "Rerun the call to see it again."],
|
|
389
407
|
] as const satisfies readonly (readonly [FactName, string])[];
|
|
390
408
|
|
|
391
409
|
/** The report envelope and facts, in output order; `next` is always last. */
|
|
@@ -405,7 +423,7 @@ export const REPORT_SCHEMA = Type.Object({
|
|
|
405
423
|
type ReportFields = Omit<Static<typeof REPORT_SCHEMA>, "error"> & { error?: ErrorCode };
|
|
406
424
|
|
|
407
425
|
const SUCCESS_DEFINITIONS = {
|
|
408
|
-
read: facts([], ["pagination", "
|
|
426
|
+
read: facts([], ["pagination", "outputLimit", "lineTooLong"]),
|
|
409
427
|
grep: facts(
|
|
410
428
|
[],
|
|
411
429
|
[
|
|
@@ -418,15 +436,12 @@ const SUCCESS_DEFINITIONS = {
|
|
|
418
436
|
"linePreviewLimit",
|
|
419
437
|
"invalidUtf8",
|
|
420
438
|
"diagnostics",
|
|
421
|
-
"
|
|
422
|
-
"contentForgotten",
|
|
439
|
+
"literalPipe",
|
|
423
440
|
],
|
|
424
441
|
),
|
|
425
442
|
edit: facts([]),
|
|
426
443
|
replace: facts([], ["matches"]),
|
|
427
444
|
write: facts([], ["created"]),
|
|
428
|
-
forget: facts(["forgotten"], ["notForgettable"]),
|
|
429
|
-
codemode: facts([], ["resultId", "forgetScope", "contentForgotten"]),
|
|
430
445
|
} as const;
|
|
431
446
|
export type ReportTool = keyof typeof SUCCESS_DEFINITIONS;
|
|
432
447
|
/** Tools whose reports carry publication, freshness, and the then_run outcome. */
|
|
@@ -476,7 +491,7 @@ const SUCCESS_SCHEMAS = Object.entries(SUCCESS_DEFINITIONS).map(([tool, schema])
|
|
|
476
491
|
{ additionalProperties: false },
|
|
477
492
|
),
|
|
478
493
|
);
|
|
479
|
-
/** Closed records after call
|
|
494
|
+
/** Closed records after the originating call supplies the tool; failure facts remain code-specific. */
|
|
480
495
|
export const WIRE_REPORT_SCHEMA = Type.Union([...FAILURE_SCHEMAS, ...SUCCESS_SCHEMAS]);
|
|
481
496
|
|
|
482
497
|
// Static counterparts of the per-tool and per-code wire schemas above, built from the same fields.
|