@chances-ai/engine 28.0.0 → 30.0.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/dist/agents/index.js +1 -1
- package/dist/ai/adapters/ai-sdk-stream.js +15 -0
- package/dist/ai/adapters/ai-sdk-stream.js.map +1 -1
- package/dist/ai/adapters/ai-sdk.js +1 -1
- package/dist/ai/adapters/ai-sdk.js.map +1 -1
- package/dist/ai/setup.d.ts +1 -1
- package/dist/ai/setup.js +1 -1
- package/dist/ai/types.d.ts +13 -1
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/core/engine.d.ts +17 -3
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +49 -3
- package/dist/core/engine.js.map +1 -1
- package/dist/core/task-tool.d.ts +1 -1
- package/dist/core/task-tool.js +1 -1
- package/dist/core/workspace-query.d.ts +1 -1
- package/dist/core/workspace-query.js +1 -1
- package/dist/hashline/apply.d.ts +9 -0
- package/dist/hashline/apply.d.ts.map +1 -0
- package/dist/hashline/apply.js +523 -0
- package/dist/hashline/apply.js.map +1 -0
- package/dist/hashline/block.d.ts +25 -0
- package/dist/hashline/block.d.ts.map +1 -0
- package/dist/hashline/block.js +71 -0
- package/dist/hashline/block.js.map +1 -0
- package/dist/hashline/format.d.ts +106 -0
- package/dist/hashline/format.d.ts.map +1 -0
- package/dist/hashline/format.js +191 -0
- package/dist/hashline/format.js.map +1 -0
- package/dist/hashline/fs.d.ts +87 -0
- package/dist/hashline/fs.d.ts.map +1 -0
- package/dist/hashline/fs.js +123 -0
- package/dist/hashline/fs.js.map +1 -0
- package/dist/hashline/index.d.ts +27 -0
- package/dist/hashline/index.d.ts.map +1 -0
- package/dist/hashline/index.js +27 -0
- package/dist/hashline/index.js.map +1 -0
- package/dist/hashline/input.d.ts +101 -0
- package/dist/hashline/input.d.ts.map +1 -0
- package/dist/hashline/input.js +378 -0
- package/dist/hashline/input.js.map +1 -0
- package/dist/hashline/messages.d.ts +87 -0
- package/dist/hashline/messages.d.ts.map +1 -0
- package/dist/hashline/messages.js +94 -0
- package/dist/hashline/messages.js.map +1 -0
- package/dist/hashline/mismatch.d.ts +45 -0
- package/dist/hashline/mismatch.d.ts.map +1 -0
- package/dist/hashline/mismatch.js +118 -0
- package/dist/hashline/mismatch.js.map +1 -0
- package/dist/hashline/normalize.d.ts +22 -0
- package/dist/hashline/normalize.d.ts.map +1 -0
- package/dist/hashline/normalize.js +31 -0
- package/dist/hashline/normalize.js.map +1 -0
- package/dist/hashline/parser.d.ts +24 -0
- package/dist/hashline/parser.d.ts.map +1 -0
- package/dist/hashline/parser.js +295 -0
- package/dist/hashline/parser.js.map +1 -0
- package/dist/hashline/patcher.d.ts +111 -0
- package/dist/hashline/patcher.d.ts.map +1 -0
- package/dist/hashline/patcher.js +332 -0
- package/dist/hashline/patcher.js.map +1 -0
- package/dist/hashline/recovery.d.ts +41 -0
- package/dist/hashline/recovery.d.ts.map +1 -0
- package/dist/hashline/recovery.js +175 -0
- package/dist/hashline/recovery.js.map +1 -0
- package/dist/hashline/snapshots.d.ts +62 -0
- package/dist/hashline/snapshots.d.ts.map +1 -0
- package/dist/hashline/snapshots.js +127 -0
- package/dist/hashline/snapshots.js.map +1 -0
- package/dist/hashline/tokenizer.d.ts +66 -0
- package/dist/hashline/tokenizer.d.ts.map +1 -0
- package/dist/hashline/tokenizer.js +408 -0
- package/dist/hashline/tokenizer.js.map +1 -0
- package/dist/hashline/types.d.ts +117 -0
- package/dist/hashline/types.d.ts.map +1 -0
- package/dist/hashline/types.js +13 -0
- package/dist/hashline/types.js.map +1 -0
- package/dist/local-vault/index.d.ts +1 -1
- package/dist/local-vault/index.js +1 -1
- package/dist/lsp/index.d.ts +1 -1
- package/dist/lsp/index.js +1 -1
- package/dist/lsp/types.d.ts +2 -2
- package/dist/mcp/host.d.ts +3 -3
- package/dist/mcp/load-mcp-host.d.ts +4 -4
- package/dist/mcp/load-mcp-host.js +4 -4
- package/dist/mcp/oauth/provider.d.ts.map +1 -1
- package/dist/mcp/oauth/provider.js +10 -1
- package/dist/mcp/oauth/provider.js.map +1 -1
- package/dist/plugin-api/index.d.ts +10 -2
- package/dist/plugin-api/index.d.ts.map +1 -1
- package/dist/plugin-api/index.js +15 -0
- package/dist/plugin-api/index.js.map +1 -1
- package/dist/tools/approval.d.ts +1 -1
- package/dist/tools/approval.js +1 -1
- package/dist/tools/builtins/_hashline-fs.d.ts +16 -0
- package/dist/tools/builtins/_hashline-fs.d.ts.map +1 -0
- package/dist/tools/builtins/_hashline-fs.js +62 -0
- package/dist/tools/builtins/_hashline-fs.js.map +1 -0
- package/dist/tools/builtins/_image.d.ts +26 -0
- package/dist/tools/builtins/_image.d.ts.map +1 -0
- package/dist/tools/builtins/_image.js +76 -0
- package/dist/tools/builtins/_image.js.map +1 -0
- package/dist/tools/builtins/_login-shell.d.ts +17 -0
- package/dist/tools/builtins/_login-shell.d.ts.map +1 -0
- package/dist/tools/builtins/_login-shell.js +66 -0
- package/dist/tools/builtins/_login-shell.js.map +1 -0
- package/dist/tools/builtins/_notebook.d.ts +15 -0
- package/dist/tools/builtins/_notebook.d.ts.map +1 -0
- package/dist/tools/builtins/_notebook.js +81 -0
- package/dist/tools/builtins/_notebook.js.map +1 -0
- package/dist/tools/builtins/_pdf.d.ts +19 -0
- package/dist/tools/builtins/_pdf.d.ts.map +1 -0
- package/dist/tools/builtins/_pdf.js +42 -0
- package/dist/tools/builtins/_pdf.js.map +1 -0
- package/dist/tools/builtins/_shared.d.ts +11 -0
- package/dist/tools/builtins/_shared.d.ts.map +1 -1
- package/dist/tools/builtins/_shared.js +40 -1
- package/dist/tools/builtins/_shared.js.map +1 -1
- package/dist/tools/builtins/ast-edit.d.ts +18 -0
- package/dist/tools/builtins/ast-edit.d.ts.map +1 -0
- package/dist/tools/builtins/ast-edit.js +109 -0
- package/dist/tools/builtins/ast-edit.js.map +1 -0
- package/dist/tools/builtins/ast-grep.d.ts +6 -0
- package/dist/tools/builtins/ast-grep.d.ts.map +1 -0
- package/dist/tools/builtins/ast-grep.js +67 -0
- package/dist/tools/builtins/ast-grep.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +13 -2
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +112 -31
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/lsp.js +1 -1
- package/dist/tools/builtins/pty.d.ts +1 -1
- package/dist/tools/builtins/read.d.ts.map +1 -1
- package/dist/tools/builtins/read.js +187 -11
- package/dist/tools/builtins/read.js.map +1 -1
- package/dist/tools/builtins.d.ts.map +1 -1
- package/dist/tools/builtins.js +4 -0
- package/dist/tools/builtins.js.map +1 -1
- package/dist/tools/file-lock.d.ts +8 -0
- package/dist/tools/file-lock.d.ts.map +1 -1
- package/dist/tools/file-lock.js +22 -0
- package/dist/tools/file-lock.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.d.ts +27 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ApplyResult, BlockResolver, Edit, SplitOptions } from "./types.js";
|
|
2
|
+
interface RawSection {
|
|
3
|
+
path: string;
|
|
4
|
+
fileHash?: string;
|
|
5
|
+
diff: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns true when the input contains at least one line that the tokenizer
|
|
9
|
+
* recognizes as a hashline op. Used by streaming previews to decide whether
|
|
10
|
+
* the partial input is worth treating as a hashline patch yet.
|
|
11
|
+
*/
|
|
12
|
+
export declare function containsRecognizableHashlineOperations(input: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Snapshot of one section in a parsed {@link Patch}: a target file plus the
|
|
15
|
+
* lazily-parsed list of edits that should land on it. Constructed by
|
|
16
|
+
* {@link Patch.parse}; consumers usually iterate `patch.sections` rather
|
|
17
|
+
* than build these directly.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PatchSection {
|
|
20
|
+
#private;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
readonly fileHash: string | undefined;
|
|
23
|
+
readonly diff: string;
|
|
24
|
+
constructor(raw: RawSection);
|
|
25
|
+
/**
|
|
26
|
+
* Parse this section's diff body. Cached: subsequent calls return the
|
|
27
|
+
* same `{ edits, warnings }` object so callers can safely call this from
|
|
28
|
+
* multiple paths (preflight, apply, diff-preview).
|
|
29
|
+
*/
|
|
30
|
+
parse(): {
|
|
31
|
+
edits: Edit[];
|
|
32
|
+
warnings: readonly string[];
|
|
33
|
+
};
|
|
34
|
+
/** Parsed edits for this section. */
|
|
35
|
+
get edits(): readonly Edit[];
|
|
36
|
+
/** Warnings emitted during parsing of this section. */
|
|
37
|
+
get warnings(): readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* True when at least one edit anchors to concrete file content. Pure
|
|
40
|
+
* `insert head:` / `insert tail:` literal inserts do not count: those are
|
|
41
|
+
* safe to apply to files that don't yet exist.
|
|
42
|
+
*/
|
|
43
|
+
get hasAnchorScopedEdit(): boolean;
|
|
44
|
+
/** Anchor lines touched by this section, sorted ascending and deduplicated. */
|
|
45
|
+
collectAnchorLines(): readonly number[];
|
|
46
|
+
/**
|
|
47
|
+
* Apply this section's edits to `text` and return the post-edit result.
|
|
48
|
+
* Pure: does no I/O, does not validate the section snapshot tag. The
|
|
49
|
+
* {@link Patcher} owns tag validation and recovery; reach for this
|
|
50
|
+
* method directly when you've already validated the file content and
|
|
51
|
+
* just want the result.
|
|
52
|
+
*
|
|
53
|
+
* `blockResolver` resolves any `replace block N:` edits against `text`; an
|
|
54
|
+
* unresolvable block throws (this is the final, authoritative preview path).
|
|
55
|
+
*/
|
|
56
|
+
applyTo(text: string, blockResolver?: BlockResolver): ApplyResult;
|
|
57
|
+
/**
|
|
58
|
+
* Streaming-tolerant counterpart to {@link applyTo}. Uses
|
|
59
|
+
* {@link parsePatchStreaming} so a trailing in-flight op (no payload yet,
|
|
60
|
+
* or a per-token parse error mid-stream) does not throw or emit a phantom
|
|
61
|
+
* empty-payload edit. Intended for incremental diff previews; the writer
|
|
62
|
+
* path should always use {@link applyTo}.
|
|
63
|
+
*
|
|
64
|
+
* `blockResolver` resolves any `replace block N:` edits against `text`; an
|
|
65
|
+
* unresolvable block is silently dropped so a half-written file does not
|
|
66
|
+
* throw mid-stream.
|
|
67
|
+
*/
|
|
68
|
+
applyPartialTo(text: string, blockResolver?: BlockResolver): ApplyResult;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A parsed hashline patch — zero or more {@link PatchSection}s, each rooted
|
|
72
|
+
* at a `¶PATH#HASH` header. Construct via {@link Patch.parse}.
|
|
73
|
+
*
|
|
74
|
+
* `Patch` is pure data: parsing is line-anchored and does not look at the
|
|
75
|
+
* filesystem. To apply a patch, hand it to {@link Patcher.apply}.
|
|
76
|
+
*/
|
|
77
|
+
export declare class Patch {
|
|
78
|
+
readonly sections: readonly PatchSection[];
|
|
79
|
+
private constructor();
|
|
80
|
+
/**
|
|
81
|
+
* Parse `input` into a {@link Patch}. `options.cwd` resolves absolute
|
|
82
|
+
* paths inside headers to cwd-relative form; `options.path` provides a
|
|
83
|
+
* fallback when the input lacks a header but contains hashline ops
|
|
84
|
+
* (useful for streaming previews).
|
|
85
|
+
*
|
|
86
|
+
* Consecutive sections targeting the same path are merged into a single
|
|
87
|
+
* section with concatenated diff bodies. Anchors authored against the
|
|
88
|
+
* same file snapshot must be applied as one batch; otherwise the first
|
|
89
|
+
* sub-edit shifts line numbers out from under the second's anchors and
|
|
90
|
+
* validation fails.
|
|
91
|
+
*/
|
|
92
|
+
static parse(input: string, options?: SplitOptions): Patch;
|
|
93
|
+
/**
|
|
94
|
+
* Parse `input` and return only the first section. Throws if the input
|
|
95
|
+
* has zero sections. Convenience for the single-section case where the
|
|
96
|
+
* caller already knows the patch is one hunk.
|
|
97
|
+
*/
|
|
98
|
+
static parseSingle(input: string, options?: SplitOptions): PatchSection;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/hashline/input.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgEjF,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AA+CD;;;;GAIG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAK7E;AAyED;;;;;GAKG;AACH,qBAAa,YAAY;;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAGV,GAAG,EAAE,UAAU;IAM3B;;;;OAIG;IACH,KAAK,IAAI;QAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE;IAKvD,qCAAqC;IACrC,IAAI,KAAK,IAAI,SAAS,IAAI,EAAE,CAE3B;IAED,uDAAuD;IACvD,IAAI,QAAQ,IAAI,SAAS,MAAM,EAAE,CAEhC;IAED;;;;OAIG;IACH,IAAI,mBAAmB,IAAI,OAAO,CAOjC;IAED,+EAA+E;IAC/E,kBAAkB,IAAI,SAAS,MAAM,EAAE;IAkBvC;;;;;;;;;OASG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,WAAW;IAYjE;;;;;;;;;;OAUG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,WAAW;CASzE;AAED;;;;;;GAMG;AACH,qBAAa,KAAK;IAChB,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAE3C,OAAO;IAIP;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK;IAK9D;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,YAAY;CAM5E"}
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Top-level patch parser. Splits an authored hashline input into a list of
|
|
3
|
+
* {@link PatchSection}s, each rooted at a `¶PATH#HASH` header, then exposes
|
|
4
|
+
* a {@link Patch} class that gives lazy access to the parsed edits per
|
|
5
|
+
* section. Ported from oh-my-pi `packages/hashline/src/input.ts`.
|
|
6
|
+
*
|
|
7
|
+
* The splitter is purely lexical — it doesn't know whether a section's path
|
|
8
|
+
* actually exists. That's the patcher's job.
|
|
9
|
+
*/
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
import { applyEdits } from "./apply.js";
|
|
12
|
+
import { resolveBlockEdits } from "./block.js";
|
|
13
|
+
import { HL_FILE_HASH_LENGTH, HL_FILE_HASH_SEP, HL_FILE_PREFIX } from "./format.js";
|
|
14
|
+
import { parsePatch, parsePatchStreaming } from "./parser.js";
|
|
15
|
+
import { Tokenizer } from "./tokenizer.js";
|
|
16
|
+
/** UTF-8 BOM (U+FEFF). Built from a code point so the source stays ASCII. */
|
|
17
|
+
const BOM = String.fromCharCode(0xfeff);
|
|
18
|
+
// Pure classification — single shared tokenizer is safe.
|
|
19
|
+
const TOKENIZER = new Tokenizer();
|
|
20
|
+
function unquoteHashlinePath(pathText) {
|
|
21
|
+
if (pathText.length < 2)
|
|
22
|
+
return pathText;
|
|
23
|
+
const first = pathText[0];
|
|
24
|
+
const last = pathText[pathText.length - 1];
|
|
25
|
+
if ((first === '"' || first === "'") && first === last)
|
|
26
|
+
return pathText.slice(1, -1);
|
|
27
|
+
return pathText;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Strip apply_patch-style noise that models reflexively prepend to the
|
|
31
|
+
* path. Examples observed in benchmark traces:
|
|
32
|
+
*
|
|
33
|
+
* `Update File:foo.ts`, `Update:foo.ts`, `UpdateFile:foo.ts`,
|
|
34
|
+
* `Update/File:foo.ts`, `Update-file:foo.ts`, `Update(File):foo.ts`,
|
|
35
|
+
* `Update<File:foo.ts`, `Add File:foo.ts`, `Delete File:foo.ts`,
|
|
36
|
+
* `Move to:foo.ts`, `***foo.ts`, `***Update File:foo.ts`.
|
|
37
|
+
*
|
|
38
|
+
* We strip a leading `***` (the model duplicating the header sigil) and a
|
|
39
|
+
* leading `(Update|Add|Delete|Move)[<separator>]*(File|to)?[<separator>]*:`
|
|
40
|
+
* keyword block, case-insensitive. The remaining text is the real path.
|
|
41
|
+
*/
|
|
42
|
+
const APPLY_PATCH_PATH_NOISE_RE = /^\*{0,3}\s*(?:(?:update|add|delete|move)[^A-Za-z0-9]*(?:file|to)?[^A-Za-z0-9]*:)?\s*\*{0,3}\s*/i;
|
|
43
|
+
function stripApplyPatchPathNoise(pathText) {
|
|
44
|
+
return pathText.replace(APPLY_PATCH_PATH_NOISE_RE, "");
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Best-effort recovery for `¶`-prefixed lines the strict tokenizer
|
|
48
|
+
* rejects. Strips apply_patch keyword noise (`Update File:`, `Update:`,
|
|
49
|
+
* etc.) and an extra leading `***` (some models emit a hybrid `¶***foo.ts`
|
|
50
|
+
* shape), then expects `PATH(#HASH)?` with no embedded whitespace.
|
|
51
|
+
* Returns `null` when no clean path can be salvaged.
|
|
52
|
+
*/
|
|
53
|
+
function tryParseRecoveryHeader(line, cwd) {
|
|
54
|
+
if (!line.startsWith(HL_FILE_PREFIX))
|
|
55
|
+
return null;
|
|
56
|
+
const body = stripApplyPatchPathNoise(line.slice(HL_FILE_PREFIX.length).trim());
|
|
57
|
+
if (body.length === 0)
|
|
58
|
+
return null;
|
|
59
|
+
const match = new RegExp(`^(\\S+?)(?:#([0-9A-Fa-f]{${HL_FILE_HASH_LENGTH}}))?\\s*$`).exec(body);
|
|
60
|
+
if (match === null)
|
|
61
|
+
return null;
|
|
62
|
+
const parsedPath = normalizeHashlinePath(match[1] ?? "", cwd);
|
|
63
|
+
if (parsedPath.length === 0)
|
|
64
|
+
return null;
|
|
65
|
+
return match[2] !== undefined
|
|
66
|
+
? { path: parsedPath, fileHash: match[2].toUpperCase(), diff: "" }
|
|
67
|
+
: { path: parsedPath, diff: "" };
|
|
68
|
+
}
|
|
69
|
+
function normalizeHashlinePath(rawPath, cwd) {
|
|
70
|
+
const unquoted = stripApplyPatchPathNoise(unquoteHashlinePath(rawPath.trim()));
|
|
71
|
+
if (!cwd || !path.isAbsolute(unquoted))
|
|
72
|
+
return unquoted;
|
|
73
|
+
const relative = path.relative(path.resolve(cwd), path.resolve(unquoted));
|
|
74
|
+
const isWithinCwd = relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
75
|
+
return isWithinCwd ? relative || "." : unquoted;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parse a `¶PATH[#hash]` header line. Returns `null` for lines that do
|
|
79
|
+
* not start with `¶`. Throws the strict "Input header must be …" error
|
|
80
|
+
* when a `¶`-prefixed line fails the strict shape (so malformed paths
|
|
81
|
+
* surface immediately instead of being silently re-classified as payload).
|
|
82
|
+
*/
|
|
83
|
+
function parseHashlineHeaderLine(line, cwd) {
|
|
84
|
+
const trimmed = line.trimEnd();
|
|
85
|
+
if (!trimmed.startsWith(HL_FILE_PREFIX))
|
|
86
|
+
return null;
|
|
87
|
+
const token = TOKENIZER.tokenize(trimmed);
|
|
88
|
+
if (token.kind !== "header") {
|
|
89
|
+
// Recovery: try to extract a path from the raw line after stripping
|
|
90
|
+
// apply_patch noise. This handles `*** Update File:foo.ts#CB5` and
|
|
91
|
+
// the half-dozen variants models actually emit.
|
|
92
|
+
const recovered = tryParseRecoveryHeader(trimmed, cwd);
|
|
93
|
+
if (recovered !== null)
|
|
94
|
+
return recovered;
|
|
95
|
+
throw new Error(`Input header must be ${HL_FILE_PREFIX}PATH or ${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}TAG with a ${HL_FILE_HASH_LENGTH}-hex content-hash tag; got ${JSON.stringify(trimmed)}.`);
|
|
96
|
+
}
|
|
97
|
+
const parsedPath = normalizeHashlinePath(token.path, cwd);
|
|
98
|
+
if (parsedPath.length === 0) {
|
|
99
|
+
throw new Error(`Input header "${HL_FILE_PREFIX}" is empty; provide a file path.`);
|
|
100
|
+
}
|
|
101
|
+
return token.fileHash !== undefined
|
|
102
|
+
? { path: parsedPath, fileHash: token.fileHash, diff: "" }
|
|
103
|
+
: { path: parsedPath, diff: "" };
|
|
104
|
+
}
|
|
105
|
+
function stripLeadingBlankLines(input) {
|
|
106
|
+
const stripped = input.startsWith(BOM) ? input.slice(1) : input;
|
|
107
|
+
const lines = stripped.split("\n");
|
|
108
|
+
while (lines.length > 0) {
|
|
109
|
+
const head = lines[0].replace(/\r$/, "");
|
|
110
|
+
if (head.trim().length === 0 || TOKENIZER.tokenize(head).kind === "envelope-begin") {
|
|
111
|
+
lines.shift();
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
return lines.join("\n");
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns true when the input contains at least one line that the tokenizer
|
|
120
|
+
* recognizes as a hashline op. Used by streaming previews to decide whether
|
|
121
|
+
* the partial input is worth treating as a hashline patch yet.
|
|
122
|
+
*/
|
|
123
|
+
export function containsRecognizableHashlineOperations(input) {
|
|
124
|
+
for (const line of input.split(/\r?\n/)) {
|
|
125
|
+
if (TOKENIZER.isOp(line))
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
function normalizeFallbackInput(input, options) {
|
|
131
|
+
const stripped = input.startsWith(BOM) ? input.slice(1) : input;
|
|
132
|
+
const hasExplicitHeader = stripped
|
|
133
|
+
.split(/\r?\n/)
|
|
134
|
+
.some((rawLine) => parseHashlineHeaderLine(rawLine, options.cwd) !== null);
|
|
135
|
+
if (hasExplicitHeader)
|
|
136
|
+
return input;
|
|
137
|
+
if (!options.path || !containsRecognizableHashlineOperations(input))
|
|
138
|
+
return input;
|
|
139
|
+
const fallbackPath = normalizeHashlinePath(options.path, options.cwd);
|
|
140
|
+
if (fallbackPath.length === 0)
|
|
141
|
+
return input;
|
|
142
|
+
return `${HL_FILE_PREFIX}${fallbackPath}\n${input}`;
|
|
143
|
+
}
|
|
144
|
+
function splitRawSections(input, options = {}) {
|
|
145
|
+
const stripped = stripLeadingBlankLines(normalizeFallbackInput(input, options));
|
|
146
|
+
const lines = stripped.split(/\r?\n/);
|
|
147
|
+
const firstLine = lines[0] ?? "";
|
|
148
|
+
if (parseHashlineHeaderLine(firstLine, options.cwd) === null) {
|
|
149
|
+
// Catch unified-diff hunk-header contamination on the first line so
|
|
150
|
+
// the model sees a focused error.
|
|
151
|
+
const firstTrimmed = firstLine.trimEnd();
|
|
152
|
+
if (/^@@\s+[-+]?\d+,\d+\s+[-+]?\d+,\d+\s+@@/.test(firstTrimmed)) {
|
|
153
|
+
throw new Error("unified-diff hunk header (`@@ -N,M +N,M @@`) is not valid in hashline. " +
|
|
154
|
+
"File sections start with `¶path#HASH`; use `replace`, `delete`, or `insert` ops.");
|
|
155
|
+
}
|
|
156
|
+
const preview = JSON.stringify(firstLine.slice(0, 120));
|
|
157
|
+
throw new Error(`input must begin with "${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}HASH" on the first non-blank line for anchored edits; got: ${preview}. ` +
|
|
158
|
+
`Example: "${HL_FILE_PREFIX}src/foo.ts${HL_FILE_HASH_SEP}0A3" then edit ops.`);
|
|
159
|
+
}
|
|
160
|
+
const sections = [];
|
|
161
|
+
let current;
|
|
162
|
+
let currentLines = [];
|
|
163
|
+
const flush = () => {
|
|
164
|
+
if (!current)
|
|
165
|
+
return;
|
|
166
|
+
const hasOps = currentLines.some((line) => line.trim().length > 0);
|
|
167
|
+
if (hasOps)
|
|
168
|
+
sections.push({ ...current, diff: currentLines.join("\n") });
|
|
169
|
+
currentLines = [];
|
|
170
|
+
};
|
|
171
|
+
for (const line of lines) {
|
|
172
|
+
const trimmed = line.trimEnd();
|
|
173
|
+
const token = TOKENIZER.tokenize(line);
|
|
174
|
+
if (token.kind === "envelope-end" || token.kind === "abort")
|
|
175
|
+
break;
|
|
176
|
+
if (token.kind === "envelope-begin")
|
|
177
|
+
continue;
|
|
178
|
+
// Route every `¶`-prefixed line through parseHashlineHeaderLine so
|
|
179
|
+
// malformed headers still raise the strict "Input header must be …"
|
|
180
|
+
// diagnostic (the tokenizer alone would silently classify them as
|
|
181
|
+
// payload).
|
|
182
|
+
if (trimmed.startsWith(HL_FILE_PREFIX)) {
|
|
183
|
+
const header = parseHashlineHeaderLine(line, options.cwd);
|
|
184
|
+
if (header !== null) {
|
|
185
|
+
flush();
|
|
186
|
+
current = header;
|
|
187
|
+
currentLines = [];
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
currentLines.push(line);
|
|
192
|
+
}
|
|
193
|
+
flush();
|
|
194
|
+
return sections;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Snapshot of one section in a parsed {@link Patch}: a target file plus the
|
|
198
|
+
* lazily-parsed list of edits that should land on it. Constructed by
|
|
199
|
+
* {@link Patch.parse}; consumers usually iterate `patch.sections` rather
|
|
200
|
+
* than build these directly.
|
|
201
|
+
*/
|
|
202
|
+
export class PatchSection {
|
|
203
|
+
path;
|
|
204
|
+
fileHash;
|
|
205
|
+
diff;
|
|
206
|
+
#parsed;
|
|
207
|
+
constructor(raw) {
|
|
208
|
+
this.path = raw.path;
|
|
209
|
+
this.fileHash = raw.fileHash;
|
|
210
|
+
this.diff = raw.diff;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Parse this section's diff body. Cached: subsequent calls return the
|
|
214
|
+
* same `{ edits, warnings }` object so callers can safely call this from
|
|
215
|
+
* multiple paths (preflight, apply, diff-preview).
|
|
216
|
+
*/
|
|
217
|
+
parse() {
|
|
218
|
+
this.#parsed ??= parsePatch(this.diff);
|
|
219
|
+
return this.#parsed;
|
|
220
|
+
}
|
|
221
|
+
/** Parsed edits for this section. */
|
|
222
|
+
get edits() {
|
|
223
|
+
return this.parse().edits;
|
|
224
|
+
}
|
|
225
|
+
/** Warnings emitted during parsing of this section. */
|
|
226
|
+
get warnings() {
|
|
227
|
+
return this.parse().warnings;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* True when at least one edit anchors to concrete file content. Pure
|
|
231
|
+
* `insert head:` / `insert tail:` literal inserts do not count: those are
|
|
232
|
+
* safe to apply to files that don't yet exist.
|
|
233
|
+
*/
|
|
234
|
+
get hasAnchorScopedEdit() {
|
|
235
|
+
return this.edits.some((edit) => {
|
|
236
|
+
if (edit.kind === "delete")
|
|
237
|
+
return true;
|
|
238
|
+
// A `replace block N:` edit is anchored to concrete content on line N.
|
|
239
|
+
if (edit.kind === "block")
|
|
240
|
+
return true;
|
|
241
|
+
return edit.cursor.kind === "before_anchor" || edit.cursor.kind === "after_anchor";
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
/** Anchor lines touched by this section, sorted ascending and deduplicated. */
|
|
245
|
+
collectAnchorLines() {
|
|
246
|
+
const lines = new Set();
|
|
247
|
+
for (const edit of this.edits) {
|
|
248
|
+
if (edit.kind === "delete") {
|
|
249
|
+
lines.add(edit.anchor.line);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (edit.kind === "block") {
|
|
253
|
+
lines.add(edit.anchor.line);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (edit.cursor.kind === "before_anchor" || edit.cursor.kind === "after_anchor") {
|
|
257
|
+
lines.add(edit.cursor.anchor.line);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return [...lines].sort((a, b) => a - b);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Apply this section's edits to `text` and return the post-edit result.
|
|
264
|
+
* Pure: does no I/O, does not validate the section snapshot tag. The
|
|
265
|
+
* {@link Patcher} owns tag validation and recovery; reach for this
|
|
266
|
+
* method directly when you've already validated the file content and
|
|
267
|
+
* just want the result.
|
|
268
|
+
*
|
|
269
|
+
* `blockResolver` resolves any `replace block N:` edits against `text`; an
|
|
270
|
+
* unresolvable block throws (this is the final, authoritative preview path).
|
|
271
|
+
*/
|
|
272
|
+
applyTo(text, blockResolver) {
|
|
273
|
+
const { edits, warnings } = this.parse();
|
|
274
|
+
const resolved = resolveBlockEdits(edits, text, this.path, blockResolver, { onUnresolved: "throw" });
|
|
275
|
+
const result = applyEdits(text, resolved);
|
|
276
|
+
// Preserve parse warnings so consumers don't need to call `parse()`
|
|
277
|
+
// separately.
|
|
278
|
+
const merged = warnings.length === 0 ? result.warnings : [...warnings, ...(result.warnings ?? [])];
|
|
279
|
+
return merged && merged.length > 0
|
|
280
|
+
? { ...result, warnings: merged }
|
|
281
|
+
: { text: result.text, firstChangedLine: result.firstChangedLine };
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Streaming-tolerant counterpart to {@link applyTo}. Uses
|
|
285
|
+
* {@link parsePatchStreaming} so a trailing in-flight op (no payload yet,
|
|
286
|
+
* or a per-token parse error mid-stream) does not throw or emit a phantom
|
|
287
|
+
* empty-payload edit. Intended for incremental diff previews; the writer
|
|
288
|
+
* path should always use {@link applyTo}.
|
|
289
|
+
*
|
|
290
|
+
* `blockResolver` resolves any `replace block N:` edits against `text`; an
|
|
291
|
+
* unresolvable block is silently dropped so a half-written file does not
|
|
292
|
+
* throw mid-stream.
|
|
293
|
+
*/
|
|
294
|
+
applyPartialTo(text, blockResolver) {
|
|
295
|
+
const { edits, warnings } = parsePatchStreaming(this.diff);
|
|
296
|
+
const resolved = resolveBlockEdits(edits, text, this.path, blockResolver, { onUnresolved: "drop" });
|
|
297
|
+
const result = applyEdits(text, resolved);
|
|
298
|
+
const merged = warnings.length === 0 ? result.warnings : [...warnings, ...(result.warnings ?? [])];
|
|
299
|
+
return merged && merged.length > 0
|
|
300
|
+
? { ...result, warnings: merged }
|
|
301
|
+
: { text: result.text, firstChangedLine: result.firstChangedLine };
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* A parsed hashline patch — zero or more {@link PatchSection}s, each rooted
|
|
306
|
+
* at a `¶PATH#HASH` header. Construct via {@link Patch.parse}.
|
|
307
|
+
*
|
|
308
|
+
* `Patch` is pure data: parsing is line-anchored and does not look at the
|
|
309
|
+
* filesystem. To apply a patch, hand it to {@link Patcher.apply}.
|
|
310
|
+
*/
|
|
311
|
+
export class Patch {
|
|
312
|
+
sections;
|
|
313
|
+
constructor(sections) {
|
|
314
|
+
this.sections = sections;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Parse `input` into a {@link Patch}. `options.cwd` resolves absolute
|
|
318
|
+
* paths inside headers to cwd-relative form; `options.path` provides a
|
|
319
|
+
* fallback when the input lacks a header but contains hashline ops
|
|
320
|
+
* (useful for streaming previews).
|
|
321
|
+
*
|
|
322
|
+
* Consecutive sections targeting the same path are merged into a single
|
|
323
|
+
* section with concatenated diff bodies. Anchors authored against the
|
|
324
|
+
* same file snapshot must be applied as one batch; otherwise the first
|
|
325
|
+
* sub-edit shifts line numbers out from under the second's anchors and
|
|
326
|
+
* validation fails.
|
|
327
|
+
*/
|
|
328
|
+
static parse(input, options = {}) {
|
|
329
|
+
const raw = mergeSamePathSections(splitRawSections(input, options));
|
|
330
|
+
return new Patch(raw.map((section) => new PatchSection(section)));
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Parse `input` and return only the first section. Throws if the input
|
|
334
|
+
* has zero sections. Convenience for the single-section case where the
|
|
335
|
+
* caller already knows the patch is one hunk.
|
|
336
|
+
*/
|
|
337
|
+
static parseSingle(input, options = {}) {
|
|
338
|
+
const patch = Patch.parse(input, options);
|
|
339
|
+
const first = patch.sections[0];
|
|
340
|
+
if (!first)
|
|
341
|
+
throw new Error("Patch input did not produce any sections.");
|
|
342
|
+
return first;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Collapse consecutive or interleaved sections targeting the same path into a
|
|
347
|
+
* single section with concatenated diffs. Anchors authored against the same
|
|
348
|
+
* file snapshot must be applied as one batch; otherwise the first sub-edit
|
|
349
|
+
* shifts line numbers out from under the second's anchors and validation
|
|
350
|
+
* fails. Path order is preserved by first occurrence.
|
|
351
|
+
*/
|
|
352
|
+
function mergeSamePathSections(sections) {
|
|
353
|
+
const byPath = new Map();
|
|
354
|
+
for (const section of sections) {
|
|
355
|
+
const existing = byPath.get(section.path);
|
|
356
|
+
if (existing) {
|
|
357
|
+
if (existing.fileHash !== undefined &&
|
|
358
|
+
section.fileHash !== undefined &&
|
|
359
|
+
existing.fileHash !== section.fileHash) {
|
|
360
|
+
throw new Error(`Conflicting hashline snapshot tags for ${section.path}: #${existing.fileHash} and #${section.fileHash}. Re-read the file and retry with one current header.`);
|
|
361
|
+
}
|
|
362
|
+
if (existing.fileHash === undefined && section.fileHash !== undefined)
|
|
363
|
+
existing.fileHash = section.fileHash;
|
|
364
|
+
existing.diffs.push(section.diff);
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
byPath.set(section.path, {
|
|
368
|
+
...(section.fileHash !== undefined ? { fileHash: section.fileHash } : {}),
|
|
369
|
+
diffs: [section.diff],
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return Array.from(byPath, ([sectionPath, entry]) => ({
|
|
373
|
+
path: sectionPath,
|
|
374
|
+
...(entry.fileHash !== undefined ? { fileHash: entry.fileHash } : {}),
|
|
375
|
+
diff: entry.diffs.join("\n"),
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/hashline/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,6EAA6E;AAC7E,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAExC,yDAAyD;AACzD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;AAElC,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrF,OAAO,QAAQ,CAA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,IAAI,CAAC;KAC7B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized error and warning text emitted by the hashline parser, applier,
|
|
3
|
+
* and patcher. Consolidating these as named constants makes them easy to
|
|
4
|
+
* audit and keeps wording stable across the rendering paths that surface
|
|
5
|
+
* them. Ported from oh-my-pi `packages/hashline/src/messages.ts`.
|
|
6
|
+
*/
|
|
7
|
+
/** Lines of context shown either side of a hash mismatch. */
|
|
8
|
+
export declare const MISMATCH_CONTEXT = 2;
|
|
9
|
+
/** Optional patch envelope start marker; silently consumed when present. */
|
|
10
|
+
export declare const BEGIN_PATCH_MARKER = "*** Begin Patch";
|
|
11
|
+
/** Optional patch envelope end marker; terminates parsing when encountered. */
|
|
12
|
+
export declare const END_PATCH_MARKER = "*** End Patch";
|
|
13
|
+
/**
|
|
14
|
+
* Recovery sentinel emitted by an agent loop when a contaminated tool-call
|
|
15
|
+
* stream is truncated mid-call. Behaves like {@link END_PATCH_MARKER} for
|
|
16
|
+
* parsing — terminates the line loop — and does not surface a warning.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ABORT_MARKER = "*** Abort";
|
|
19
|
+
/** Warning text appended when two consecutive hunks target the exact same concrete range. */
|
|
20
|
+
export declare const REPLACE_PAIR_COALESCED_WARNING = "Detected two identical-range hashline hunks; kept only the second hunk. Issue ONE `replace N..M:` hunk per range \u2014 payload is the final desired content, never both old and new.";
|
|
21
|
+
/** Warning text appended when an empty bodyless hunk is followed by an overlapping concrete hunk. */
|
|
22
|
+
export declare const REPLACE_PAIR_COALESCED_OVERLAP_WARNING = "Detected an overlapping bare hashline hunk immediately followed by a concrete hunk; dropped the earlier bare hunk. Issue ONE `replace N..M:` hunk per range \u2014 payload is the final desired content, never both old and new.";
|
|
23
|
+
/** Warning text appended when bare body rows are auto-converted to literal rows. */
|
|
24
|
+
export declare const BARE_BODY_AUTO_PIPED_WARNING = "Auto-prefixed bare body row(s) with `+`. Body rows must be `+TEXT` literal lines; pasting raw code as payload is not a portable shape.";
|
|
25
|
+
/** Error text emitted when a hunk body contains a unified-diff-style `-` row. */
|
|
26
|
+
export declare const MINUS_ROW_REJECTED = "`-` rows are not valid; hashline ranges already name the lines being changed. To insert a literal line starting with `-`, write `+-\u2026`.";
|
|
27
|
+
/** Error text emitted when a replace hunk has no body. */
|
|
28
|
+
export declare const EMPTY_REPLACE = "`replace N..M:` needs at least one `+TEXT` body row. To delete lines, use `delete N..M`.";
|
|
29
|
+
/** Error text emitted when a `replace block N:` hunk has no body. */
|
|
30
|
+
export declare const EMPTY_BLOCK = "`replace block N:` needs at least one `+TEXT` body row. To delete a block, use `delete N..M` with the block's line range.";
|
|
31
|
+
/**
|
|
32
|
+
* Error text emitted when a `replace block N:` anchor cannot be resolved to a
|
|
33
|
+
* syntactic block (unrecognized language, blank/out-of-range line, no node
|
|
34
|
+
* begins on line N such as a lone closing delimiter, or the resolved block has
|
|
35
|
+
* a syntax error). Names the offending line and steers back to an explicit
|
|
36
|
+
* `replace N..M:` range.
|
|
37
|
+
*/
|
|
38
|
+
export declare function blockUnresolvedMessage(line: number): string;
|
|
39
|
+
/**
|
|
40
|
+
* Error text emitted when a `replace block N:` edit reaches a code path that
|
|
41
|
+
* has no {@link BlockResolver} wired in. In chances-cli this means the native
|
|
42
|
+
* tree-sitter addon is absent (capability-gated, task 02) — steer to an
|
|
43
|
+
* explicit `replace N..M:` range, which never needs native.
|
|
44
|
+
*/
|
|
45
|
+
export declare const BLOCK_RESOLVER_UNAVAILABLE = "`replace block N:` is not available here (the tree-sitter block resolver is unavailable \u2014 the native addon may be a slim build). Use `replace N..M:` with an explicit range.";
|
|
46
|
+
/**
|
|
47
|
+
* Internal invariant error: `applyEdits` received an unresolved `replace block
|
|
48
|
+
* N:` edit. Block edits must be expanded by `resolveBlockEdits` before reaching
|
|
49
|
+
* the applier; hitting this is a wiring bug, not authored-input error.
|
|
50
|
+
*/
|
|
51
|
+
export declare const UNRESOLVED_BLOCK_INTERNAL = "internal error: unresolved `replace block` edit reached the applier (resolveBlockEdits was not run).";
|
|
52
|
+
/** Error text emitted when a delete hunk receives a body row. */
|
|
53
|
+
export declare const DELETE_TAKES_NO_BODY = "`delete N..M` does not take body rows. Remove the body, or use `replace N..M:`.";
|
|
54
|
+
/** Error text emitted when a `delete block N` hunk receives a body row. */
|
|
55
|
+
export declare const DELETE_BLOCK_TAKES_NO_BODY = "`delete block N` does not take body rows. Remove the body, or use `replace block N:` to replace the block.";
|
|
56
|
+
/** Error text emitted when an insert hunk has no body. */
|
|
57
|
+
export declare const EMPTY_INSERT = "`insert` needs at least one `+TEXT` body row.";
|
|
58
|
+
/** Warning text emitted by `Recovery` when an external write fits a cached snapshot. */
|
|
59
|
+
export declare const RECOVERY_EXTERNAL_WARNING = "Recovered from a stale file hash using a previous read snapshot (file changed externally between read and edit).";
|
|
60
|
+
/** Warning text emitted by `Recovery` when a prior in-session edit advanced the hash. */
|
|
61
|
+
export declare const RECOVERY_SESSION_CHAIN_WARNING = "Recovered from a stale file hash using an earlier in-session snapshot (the file hash advanced after a prior edit in this session).";
|
|
62
|
+
/**
|
|
63
|
+
* Warning text emitted by `Recovery` when the session-chain replay
|
|
64
|
+
* fast-path was taken. Distinct from {@link RECOVERY_SESSION_CHAIN_WARNING}
|
|
65
|
+
* because replay is the less-certain mode: the structured-patch 3-way
|
|
66
|
+
* merge refused, the anchor-content gate passed, but a coincidental
|
|
67
|
+
* insert+delete pair earlier in the chain could still leave an anchor's
|
|
68
|
+
* line number pointing at a duplicated row. Surface the hedge so the
|
|
69
|
+
* model verifies before continuing.
|
|
70
|
+
*/
|
|
71
|
+
export declare const RECOVERY_SESSION_REPLAY_WARNING = "Recovered by replaying your edits onto the current file content \u2014 your previous edit in this session changed line(s) you re-targeted with a stale hash. Verify the diff matches your intent before continuing.";
|
|
72
|
+
/**
|
|
73
|
+
* Warning emitted when an `insert head:` / `insert tail:` edit is applied to an
|
|
74
|
+
* existing file whose snapshot tag is stale (the file drifted since the read).
|
|
75
|
+
* Head/tail insert position is content-independent — "start"/"end" cannot move
|
|
76
|
+
* with drift — so this is non-fatal: the edit applies onto the live content and
|
|
77
|
+
* we surface the drift instead of hard-failing (unlike an anchored mismatch).
|
|
78
|
+
*/
|
|
79
|
+
export declare const HEADTAIL_DRIFT_WARNING = "Applied an `insert head:`/`insert tail:` edit onto the current file content even though the snapshot tag was stale (the file changed since your read). Head/tail position is content-independent, so the insert was not rejected \u2014 but re-read if the drift was unexpected.";
|
|
80
|
+
/**
|
|
81
|
+
* Error text emitted when a hashline section omits the mandatory snapshot tag.
|
|
82
|
+
* The tag is REQUIRED on every section, enforced identically by the apply path
|
|
83
|
+
* ({@link Patcher.prepare}) and the preview/diff path, so both surfaces reuse
|
|
84
|
+
* this single builder to stay in lockstep.
|
|
85
|
+
*/
|
|
86
|
+
export declare function missingSnapshotTagMessage(sectionPath: string): string;
|
|
87
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/hashline/messages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAEpD,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,YAAY,cAAc,CAAC;AAExC,6FAA6F;AAC7F,eAAO,MAAM,8BAA8B,0LACyI,CAAC;AAErL,qGAAqG;AACrG,eAAO,MAAM,sCAAsC,qOAC4K,CAAC;AAEhO,oFAAoF;AACpF,eAAO,MAAM,4BAA4B,2IACiG,CAAC;AAE3I,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,gJAC2G,CAAC;AAE3I,0DAA0D;AAC1D,eAAO,MAAM,aAAa,6FACkE,CAAC;AAE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