@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,94 @@
|
|
|
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
|
+
import { HL_FILE_HASH_SEP, HL_FILE_PREFIX } from "./format.js";
|
|
8
|
+
/** Lines of context shown either side of a hash mismatch. */
|
|
9
|
+
export const MISMATCH_CONTEXT = 2;
|
|
10
|
+
/** Optional patch envelope start marker; silently consumed when present. */
|
|
11
|
+
export const BEGIN_PATCH_MARKER = "*** Begin Patch";
|
|
12
|
+
/** Optional patch envelope end marker; terminates parsing when encountered. */
|
|
13
|
+
export const END_PATCH_MARKER = "*** End Patch";
|
|
14
|
+
/**
|
|
15
|
+
* Recovery sentinel emitted by an agent loop when a contaminated tool-call
|
|
16
|
+
* stream is truncated mid-call. Behaves like {@link END_PATCH_MARKER} for
|
|
17
|
+
* parsing — terminates the line loop — and does not surface a warning.
|
|
18
|
+
*/
|
|
19
|
+
export const ABORT_MARKER = "*** Abort";
|
|
20
|
+
/** Warning text appended when two consecutive hunks target the exact same concrete range. */
|
|
21
|
+
export const REPLACE_PAIR_COALESCED_WARNING = "Detected two identical-range hashline hunks; kept only the second hunk. Issue ONE `replace N..M:` hunk per range — payload is the final desired content, never both old and new.";
|
|
22
|
+
/** Warning text appended when an empty bodyless hunk is followed by an overlapping concrete hunk. */
|
|
23
|
+
export 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 — payload is the final desired content, never both old and new.";
|
|
24
|
+
/** Warning text appended when bare body rows are auto-converted to literal rows. */
|
|
25
|
+
export 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.";
|
|
26
|
+
/** Error text emitted when a hunk body contains a unified-diff-style `-` row. */
|
|
27
|
+
export const MINUS_ROW_REJECTED = "`-` rows are not valid; hashline ranges already name the lines being changed. To insert a literal line starting with `-`, write `+-…`.";
|
|
28
|
+
/** Error text emitted when a replace hunk has no body. */
|
|
29
|
+
export const EMPTY_REPLACE = "`replace N..M:` needs at least one `+TEXT` body row. To delete lines, use `delete N..M`.";
|
|
30
|
+
/** Error text emitted when a `replace block N:` hunk has no body. */
|
|
31
|
+
export 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.";
|
|
32
|
+
/**
|
|
33
|
+
* Error text emitted when a `replace block N:` anchor cannot be resolved to a
|
|
34
|
+
* syntactic block (unrecognized language, blank/out-of-range line, no node
|
|
35
|
+
* begins on line N such as a lone closing delimiter, or the resolved block has
|
|
36
|
+
* a syntax error). Names the offending line and steers back to an explicit
|
|
37
|
+
* `replace N..M:` range.
|
|
38
|
+
*/
|
|
39
|
+
export function blockUnresolvedMessage(line) {
|
|
40
|
+
return (`\`replace block ${line}:\` could not resolve a syntactic block beginning on line ${line}. ` +
|
|
41
|
+
`The language may be unsupported, the line may be blank or a closing delimiter, or the block may not parse. ` +
|
|
42
|
+
`Use \`replace ${line}..M:\` with the block's explicit end line instead.`);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error text emitted when a `replace block N:` edit reaches a code path that
|
|
46
|
+
* has no {@link BlockResolver} wired in. In chances-cli this means the native
|
|
47
|
+
* tree-sitter addon is absent (capability-gated, task 02) — steer to an
|
|
48
|
+
* explicit `replace N..M:` range, which never needs native.
|
|
49
|
+
*/
|
|
50
|
+
export const BLOCK_RESOLVER_UNAVAILABLE = "`replace block N:` is not available here (the tree-sitter block resolver is unavailable — the native addon may be a slim build). Use `replace N..M:` with an explicit range.";
|
|
51
|
+
/**
|
|
52
|
+
* Internal invariant error: `applyEdits` received an unresolved `replace block
|
|
53
|
+
* N:` edit. Block edits must be expanded by `resolveBlockEdits` before reaching
|
|
54
|
+
* the applier; hitting this is a wiring bug, not authored-input error.
|
|
55
|
+
*/
|
|
56
|
+
export const UNRESOLVED_BLOCK_INTERNAL = "internal error: unresolved `replace block` edit reached the applier (resolveBlockEdits was not run).";
|
|
57
|
+
/** Error text emitted when a delete hunk receives a body row. */
|
|
58
|
+
export const DELETE_TAKES_NO_BODY = "`delete N..M` does not take body rows. Remove the body, or use `replace N..M:`.";
|
|
59
|
+
/** Error text emitted when a `delete block N` hunk receives a body row. */
|
|
60
|
+
export 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.";
|
|
61
|
+
/** Error text emitted when an insert hunk has no body. */
|
|
62
|
+
export const EMPTY_INSERT = "`insert` needs at least one `+TEXT` body row.";
|
|
63
|
+
/** Warning text emitted by `Recovery` when an external write fits a cached snapshot. */
|
|
64
|
+
export const RECOVERY_EXTERNAL_WARNING = "Recovered from a stale file hash using a previous read snapshot (file changed externally between read and edit).";
|
|
65
|
+
/** Warning text emitted by `Recovery` when a prior in-session edit advanced the hash. */
|
|
66
|
+
export 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).";
|
|
67
|
+
/**
|
|
68
|
+
* Warning text emitted by `Recovery` when the session-chain replay
|
|
69
|
+
* fast-path was taken. Distinct from {@link RECOVERY_SESSION_CHAIN_WARNING}
|
|
70
|
+
* because replay is the less-certain mode: the structured-patch 3-way
|
|
71
|
+
* merge refused, the anchor-content gate passed, but a coincidental
|
|
72
|
+
* insert+delete pair earlier in the chain could still leave an anchor's
|
|
73
|
+
* line number pointing at a duplicated row. Surface the hedge so the
|
|
74
|
+
* model verifies before continuing.
|
|
75
|
+
*/
|
|
76
|
+
export const RECOVERY_SESSION_REPLAY_WARNING = "Recovered by replaying your edits onto the current file content — your previous edit in this session changed line(s) you re-targeted with a stale hash. Verify the diff matches your intent before continuing.";
|
|
77
|
+
/**
|
|
78
|
+
* Warning emitted when an `insert head:` / `insert tail:` edit is applied to an
|
|
79
|
+
* existing file whose snapshot tag is stale (the file drifted since the read).
|
|
80
|
+
* Head/tail insert position is content-independent — "start"/"end" cannot move
|
|
81
|
+
* with drift — so this is non-fatal: the edit applies onto the live content and
|
|
82
|
+
* we surface the drift instead of hard-failing (unlike an anchored mismatch).
|
|
83
|
+
*/
|
|
84
|
+
export 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 — but re-read if the drift was unexpected.";
|
|
85
|
+
/**
|
|
86
|
+
* Error text emitted when a hashline section omits the mandatory snapshot tag.
|
|
87
|
+
* The tag is REQUIRED on every section, enforced identically by the apply path
|
|
88
|
+
* ({@link Patcher.prepare}) and the preview/diff path, so both surfaces reuse
|
|
89
|
+
* this single builder to stay in lockstep.
|
|
90
|
+
*/
|
|
91
|
+
export function missingSnapshotTagMessage(sectionPath) {
|
|
92
|
+
return `Missing hashline snapshot tag for edit to ${sectionPath}; use \`${HL_FILE_PREFIX}${sectionPath}${HL_FILE_HASH_SEP}tag\` from your latest read/search output. To create a new file, use the write tool.`;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/hashline/messages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/D,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAEpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AAExC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,8BAA8B,GACzC,kLAAkL,CAAC;AAErL,qGAAqG;AACrG,MAAM,CAAC,MAAM,sCAAsC,GACjD,6NAA6N,CAAC;AAEhO,oFAAoF;AACpF,MAAM,CAAC,MAAM,4BAA4B,GACvC,wIAAwI,CAAC;AAE3I,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAC7B,wIAAwI,CAAC;AAE3I,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GACxB,0FAA0F,CAAC;AAE7F,qEAAqE;AACrE,MAAM,CAAC,MAAM,WAAW,GACtB,2HAA2H,CAAC;AAE9H;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,CACL,mBAAmB,IAAI,6DAA6D,IAAI,IAAI;QAC5F,6GAA6G;QAC7G,iBAAiB,IAAI,oDAAoD,CAC1E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,8KAA8K,CAAC;AAEjL;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,sGAAsG,CAAC;AAEzG,iEAAiE;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAC/B,iFAAiF,CAAC;AAEpF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GACrC,4GAA4G,CAAC;AAE/G,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,+CAA+C,CAAC;AAE5E,wFAAwF;AACxF,MAAM,CAAC,MAAM,yBAAyB,GACpC,kHAAkH,CAAC;AAErH,yFAAyF;AACzF,MAAM,CAAC,MAAM,8BAA8B,GACzC,oIAAoI,CAAC;AAEvI;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,gNAAgN,CAAC;AAEnN;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GACjC,6QAA6Q,CAAC;AAEhR;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAC3D,OAAO,6CAA6C,WAAW,WAAW,cAAc,GAAG,WAAW,GAAG,gBAAgB,sFAAsF,CAAC;AAClN,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Format the required-shape diagnostic shown when a line reference is malformed. */
|
|
2
|
+
export declare function formatFullAnchorRequirement(raw?: string): string;
|
|
3
|
+
/** Parse a decorated bare line-number anchor like `42`, `*42:foo`, ` > 7`. */
|
|
4
|
+
export declare function parseTag(ref: string): {
|
|
5
|
+
line: number;
|
|
6
|
+
};
|
|
7
|
+
export interface MismatchDetails {
|
|
8
|
+
path?: string;
|
|
9
|
+
expectedFileHash: string;
|
|
10
|
+
actualFileHash: string;
|
|
11
|
+
fileLines: string[];
|
|
12
|
+
anchorLines?: readonly number[];
|
|
13
|
+
/**
|
|
14
|
+
* `true` when the section's expected hash resolved to a recorded snapshot
|
|
15
|
+
* (file content drifted since that snapshot), `false` when no snapshot
|
|
16
|
+
* was ever recorded for the hash (likely fabricated or carried over from
|
|
17
|
+
* a prior session). Drives a more actionable rejection message; defaults
|
|
18
|
+
* to `true` for backward compatibility with direct callers.
|
|
19
|
+
*/
|
|
20
|
+
hashRecognized?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Raised when a hashline section's snapshot tag doesn't match the live file's
|
|
24
|
+
* content (and recovery, if configured, declined the merge). Carries the
|
|
25
|
+
* file lines plus anchored lines so renderers can produce a richer
|
|
26
|
+
* diagnostic via {@link MismatchError.displayMessage}.
|
|
27
|
+
*/
|
|
28
|
+
export declare class MismatchError extends Error {
|
|
29
|
+
readonly path: string | undefined;
|
|
30
|
+
readonly expectedFileHash: string;
|
|
31
|
+
readonly actualFileHash: string;
|
|
32
|
+
readonly fileLines: string[];
|
|
33
|
+
readonly anchorLines: readonly number[];
|
|
34
|
+
readonly hashRecognized: boolean;
|
|
35
|
+
constructor(details: MismatchDetails);
|
|
36
|
+
get displayMessage(): string;
|
|
37
|
+
static rejectionHeader(details: MismatchDetails): string[];
|
|
38
|
+
static formatDisplayMessage(details: MismatchDetails): string;
|
|
39
|
+
static formatMessage(details: MismatchDetails): string;
|
|
40
|
+
}
|
|
41
|
+
/** Throws when the line reference is out of bounds for the given file. */
|
|
42
|
+
export declare function validateLineRef(ref: {
|
|
43
|
+
line: number;
|
|
44
|
+
}, fileLines: string[]): void;
|
|
45
|
+
//# sourceMappingURL=mismatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mismatch.d.ts","sourceRoot":"","sources":["../../src/hashline/mismatch.ts"],"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 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error type raised when a section's snapshot tag does not match the live file
|
|
3
|
+
* content and recovery is unavailable / has failed. Ported from oh-my-pi
|
|
4
|
+
* `packages/hashline/src/mismatch.ts`.
|
|
5
|
+
*
|
|
6
|
+
* Carries enough context to render a useful diagnostic: the anchored lines
|
|
7
|
+
* plus a couple of lines of surrounding context (the cheapest "did you mean"
|
|
8
|
+
* lever, 7.9 [5.2]). The {@link MismatchError} formats this into a message at
|
|
9
|
+
* construction time.
|
|
10
|
+
*/
|
|
11
|
+
import { formatNumberedLine, HL_FILE_HASH_EXAMPLES, HL_FILE_HASH_SEP, HL_FILE_PREFIX } from "./format.js";
|
|
12
|
+
import { MISMATCH_CONTEXT } from "./messages.js";
|
|
13
|
+
const LINE_REF_RE = /^\s*[>+\-*]*\s*(\d+)(?::.*)?\s*$/;
|
|
14
|
+
/** Format the required-shape diagnostic shown when a line reference is malformed. */
|
|
15
|
+
export function formatFullAnchorRequirement(raw) {
|
|
16
|
+
const received = raw === undefined ? "" : ` Received ${JSON.stringify(raw)}.`;
|
|
17
|
+
return (`a bare line number from read/search output plus the section header content-hash tag ` +
|
|
18
|
+
`(for example ${HL_FILE_PREFIX}src/foo.ts${HL_FILE_HASH_SEP}${HL_FILE_HASH_EXAMPLES[0]} and line "160")${received}`);
|
|
19
|
+
}
|
|
20
|
+
/** Parse a decorated bare line-number anchor like `42`, `*42:foo`, ` > 7`. */
|
|
21
|
+
export function parseTag(ref) {
|
|
22
|
+
const match = ref.match(LINE_REF_RE);
|
|
23
|
+
if (!match) {
|
|
24
|
+
throw new Error(`Invalid line reference. Expected ${formatFullAnchorRequirement(ref)}.`);
|
|
25
|
+
}
|
|
26
|
+
const line = Number.parseInt(match[1] ?? "", 10);
|
|
27
|
+
if (line < 1)
|
|
28
|
+
throw new Error(`Line number must be >= 1, got ${line} in "${ref}".`);
|
|
29
|
+
return { line };
|
|
30
|
+
}
|
|
31
|
+
function getMismatchDisplayLines(anchorLines, fileLines) {
|
|
32
|
+
const displayLines = new Set();
|
|
33
|
+
for (const line of anchorLines) {
|
|
34
|
+
if (line < 1 || line > fileLines.length)
|
|
35
|
+
continue;
|
|
36
|
+
const lo = Math.max(1, line - MISMATCH_CONTEXT);
|
|
37
|
+
const hi = Math.min(fileLines.length, line + MISMATCH_CONTEXT);
|
|
38
|
+
for (let lineNum = lo; lineNum <= hi; lineNum++)
|
|
39
|
+
displayLines.add(lineNum);
|
|
40
|
+
}
|
|
41
|
+
return [...displayLines].sort((a, b) => a - b);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Raised when a hashline section's snapshot tag doesn't match the live file's
|
|
45
|
+
* content (and recovery, if configured, declined the merge). Carries the
|
|
46
|
+
* file lines plus anchored lines so renderers can produce a richer
|
|
47
|
+
* diagnostic via {@link MismatchError.displayMessage}.
|
|
48
|
+
*/
|
|
49
|
+
export class MismatchError extends Error {
|
|
50
|
+
path;
|
|
51
|
+
expectedFileHash;
|
|
52
|
+
actualFileHash;
|
|
53
|
+
fileLines;
|
|
54
|
+
anchorLines;
|
|
55
|
+
hashRecognized;
|
|
56
|
+
constructor(details) {
|
|
57
|
+
super(MismatchError.formatMessage(details));
|
|
58
|
+
this.name = "MismatchError";
|
|
59
|
+
this.path = details.path;
|
|
60
|
+
this.expectedFileHash = details.expectedFileHash;
|
|
61
|
+
this.actualFileHash = details.actualFileHash;
|
|
62
|
+
this.fileLines = details.fileLines;
|
|
63
|
+
this.anchorLines = details.anchorLines ?? [];
|
|
64
|
+
this.hashRecognized = details.hashRecognized ?? true;
|
|
65
|
+
}
|
|
66
|
+
get displayMessage() {
|
|
67
|
+
return MismatchError.formatDisplayMessage({
|
|
68
|
+
path: this.path,
|
|
69
|
+
expectedFileHash: this.expectedFileHash,
|
|
70
|
+
actualFileHash: this.actualFileHash,
|
|
71
|
+
fileLines: this.fileLines,
|
|
72
|
+
anchorLines: this.anchorLines,
|
|
73
|
+
hashRecognized: this.hashRecognized,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
static rejectionHeader(details) {
|
|
77
|
+
const pathText = details.path ? ` for ${details.path}` : "";
|
|
78
|
+
const hashRecognized = details.hashRecognized ?? true;
|
|
79
|
+
if (!hashRecognized) {
|
|
80
|
+
return [
|
|
81
|
+
`Edit rejected${pathText}: hash ${HL_FILE_HASH_SEP}${details.expectedFileHash} is not from this session.`,
|
|
82
|
+
`The current file hashes to ${HL_FILE_HASH_SEP}${details.actualFileHash}. Re-read the file with \`read\` to copy a current ${HL_FILE_PREFIX}path${HL_FILE_HASH_SEP}tag header — never invent the tag and never reuse one from a prior session.`,
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
return [
|
|
86
|
+
`Edit rejected${pathText}: file changed between read and edit.`,
|
|
87
|
+
`Section is bound to ${HL_FILE_HASH_SEP}${details.expectedFileHash}, but the current file hashes to ${HL_FILE_HASH_SEP}${details.actualFileHash}. If a prior edit in this session modified this file, copy the ${HL_FILE_PREFIX}path${HL_FILE_HASH_SEP}newhash header from that edit's response; otherwise re-read the file with \`read\` to refresh the tag before retrying.`,
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
static formatDisplayMessage(details) {
|
|
91
|
+
return MismatchError.formatMessage(details);
|
|
92
|
+
}
|
|
93
|
+
static formatMessage(details) {
|
|
94
|
+
const anchorSet = new Set(details.anchorLines ?? []);
|
|
95
|
+
const lines = MismatchError.rejectionHeader(details);
|
|
96
|
+
const displayLines = getMismatchDisplayLines(details.anchorLines ?? [], details.fileLines);
|
|
97
|
+
if (displayLines.length === 0)
|
|
98
|
+
return lines.join("\n");
|
|
99
|
+
lines.push("");
|
|
100
|
+
let previous = -1;
|
|
101
|
+
for (const lineNum of displayLines) {
|
|
102
|
+
if (previous !== -1 && lineNum > previous + 1)
|
|
103
|
+
lines.push("...");
|
|
104
|
+
previous = lineNum;
|
|
105
|
+
const text = details.fileLines[lineNum - 1] ?? "";
|
|
106
|
+
const marker = anchorSet.has(lineNum) ? "*" : " ";
|
|
107
|
+
lines.push(`${marker}${formatNumberedLine(lineNum, text)}`);
|
|
108
|
+
}
|
|
109
|
+
return lines.join("\n");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Throws when the line reference is out of bounds for the given file. */
|
|
113
|
+
export function validateLineRef(ref, fileLines) {
|
|
114
|
+
if (ref.line < 1 || ref.line > fileLines.length) {
|
|
115
|
+
throw new Error(`Line ${ref.line} does not exist (file has ${fileLines.length} lines)`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=mismatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mismatch.js","sourceRoot":"","sources":["../../src/hashline/mismatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,qFAAqF;AACrF,MAAM,UAAU,2BAA2B,CAAC,GAAY;IACtD,MAAM,QAAQ,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;IAC9E,OAAO,CACL,sFAAsF;QACtF,gBAAgB,cAAc,aAAa,gBAAgB,GAAG,qBAAqB,CAAC,CAAC,CAAC,mBAAmB,QAAQ,EAAE,CACpH,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,oCAAoC,2BAA2B,CAAC,GAAG,CAAC,GA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C,CAAC;QAC9D,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,0EAA0E;AAC1E,MAAM,UAAU,eAAe,CAAC,GAAqB,EAAE,SAAmB;IACxE,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,6BAA6B,SAAS,CAAC,MAAM,SAAS,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal text-shape normalization: line-ending detection / round-trip and
|
|
3
|
+
* BOM stripping. The patcher uses these to canonicalize text to LF before
|
|
4
|
+
* applying edits and to restore the original shape on write-back. Ported
|
|
5
|
+
* verbatim from oh-my-pi `packages/hashline/src/normalize.ts`.
|
|
6
|
+
*/
|
|
7
|
+
export type LineEnding = "\r\n" | "\n";
|
|
8
|
+
/** Detect the first line ending style in `content`. Defaults to LF when neither is present. */
|
|
9
|
+
export declare function detectLineEnding(content: string): LineEnding;
|
|
10
|
+
/** Normalize every line ending to LF. */
|
|
11
|
+
export declare function normalizeToLF(text: string): string;
|
|
12
|
+
/** Re-encode LF text with the requested line ending. */
|
|
13
|
+
export declare function restoreLineEndings(text: string, ending: LineEnding): string;
|
|
14
|
+
export interface BomResult {
|
|
15
|
+
/** Either the empty string or the BOM sequence (currently UTF-8 BOM). */
|
|
16
|
+
bom: string;
|
|
17
|
+
/** Text with any leading BOM removed. */
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
20
|
+
/** Strip a UTF-8 BOM if present and return both the BOM and the trailing text. */
|
|
21
|
+
export declare function stripBom(content: string): BomResult;
|
|
22
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/hashline/normalize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;AAKvC,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAM5D;AAED,yCAAyC;AACzC,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAE3E;AAED,MAAM,WAAW,SAAS;IACxB,yEAAyE;IACzE,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEnD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal text-shape normalization: line-ending detection / round-trip and
|
|
3
|
+
* BOM stripping. The patcher uses these to canonicalize text to LF before
|
|
4
|
+
* applying edits and to restore the original shape on write-back. Ported
|
|
5
|
+
* verbatim from oh-my-pi `packages/hashline/src/normalize.ts`.
|
|
6
|
+
*/
|
|
7
|
+
/** UTF-8 byte-order mark (U+FEFF). Built from a code point so the source stays ASCII. */
|
|
8
|
+
const BOM = String.fromCharCode(0xfeff);
|
|
9
|
+
/** Detect the first line ending style in `content`. Defaults to LF when neither is present. */
|
|
10
|
+
export function detectLineEnding(content) {
|
|
11
|
+
const crlfIdx = content.indexOf("\r\n");
|
|
12
|
+
const lfIdx = content.indexOf("\n");
|
|
13
|
+
if (lfIdx === -1)
|
|
14
|
+
return "\n";
|
|
15
|
+
if (crlfIdx === -1)
|
|
16
|
+
return "\n";
|
|
17
|
+
return crlfIdx < lfIdx ? "\r\n" : "\n";
|
|
18
|
+
}
|
|
19
|
+
/** Normalize every line ending to LF. */
|
|
20
|
+
export function normalizeToLF(text) {
|
|
21
|
+
return text.replace(/\r\n?/g, "\n");
|
|
22
|
+
}
|
|
23
|
+
/** Re-encode LF text with the requested line ending. */
|
|
24
|
+
export function restoreLineEndings(text, ending) {
|
|
25
|
+
return ending === "\r\n" ? text.replace(/\n/g, "\r\n") : text;
|
|
26
|
+
}
|
|
27
|
+
/** Strip a UTF-8 BOM if present and return both the BOM and the trailing text. */
|
|
28
|
+
export function stripBom(content) {
|
|
29
|
+
return content.startsWith(BOM) ? { bom: BOM, text: content.slice(1) } : { bom: "", text: content };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/hashline/normalize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,yFAAyF;AACzF,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAExC,+FAA+F;AAC/F,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,OAAO,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,MAAkB;IACjE,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AASD,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Token } from "./tokenizer.js";
|
|
2
|
+
import type { Edit } from "./types.js";
|
|
3
|
+
export declare class Executor {
|
|
4
|
+
#private;
|
|
5
|
+
feed(token: Token): void;
|
|
6
|
+
end(): {
|
|
7
|
+
edits: Edit[];
|
|
8
|
+
warnings: string[];
|
|
9
|
+
};
|
|
10
|
+
endStreaming(): {
|
|
11
|
+
edits: Edit[];
|
|
12
|
+
warnings: string[];
|
|
13
|
+
};
|
|
14
|
+
reset(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function parsePatch(diff: string): {
|
|
17
|
+
edits: Edit[];
|
|
18
|
+
warnings: string[];
|
|
19
|
+
};
|
|
20
|
+
export declare function parsePatchStreaming(diff: string): {
|
|
21
|
+
edits: Edit[];
|
|
22
|
+
warnings: string[];
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/hashline/parser.ts"],"names":[],"mappings":"AAcA,OAAO,EAAmD,KAAK,KAAK,EAAa,MAAM,gBAAgB,CAAC;AACxG,OAAO,KAAK,EAAkB,IAAI,EAAE,MAAM,YAAY,CAAC;AA4EvD,qBAAa,QAAQ;;IAkBnB,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IA2CxB,GAAG,IAAI;QAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE;IAO5C,YAAY,IAAI;QAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE;IAUrD,KAAK,IAAI,IAAI;CAuId;AAOD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAK9E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAMvF"}
|