@aparte/plugin-diff 0.0.0-stage → 1.7.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aparté
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,131 @@
1
- # Temporary Holding Version
1
+ # @aparte/plugin-diff
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A diff view for [aparté](https://github.com/apartejs/aparte): a file change as hunks with old and new line
4
+ numbers, in the reply or beside it, with comments on a line or a range.
5
+
6
+ ```bash
7
+ npm install @aparte/plugin-diff @aparte/core
8
+ ```
9
+
10
+ ## The element
11
+
12
+ `<aparte-diff>` (`AparteDiff`) shows each file under a header with its path and its counts (`+3 −1`), each line
13
+ with its old and new numbers and a `+` or `−`, and the unchanged runs between hunks folded. Importing the
14
+ package defines it.
15
+
16
+ ```html
17
+ <aparte-diff></aparte-diff>
18
+ <script type="module">
19
+ import '@aparte/plugin-diff';
20
+
21
+ const view = document.querySelector('aparte-diff');
22
+ view.diff = { path: 'src/parse.ts', before: oldText, after: newText };
23
+ </script>
24
+ ```
25
+
26
+ `diff` takes three shapes (`AparteDiffInput`):
27
+
28
+ - a unified diff's text, as `git diff` prints it — several files, new, deleted, renamed and binary ones included;
29
+ - a file's two texts, `{ path, before, after }` (`AparteDiffSource`, with `oldPath` for a rename): every
30
+ unchanged line can then be shown, with a "Show 24 unchanged lines" button over each folded run. A side that
31
+ does not exist is `null` — `before: null` for a file created, `after: null` for one deleted — while `''` is a
32
+ file that exists and is empty;
33
+ - a list of files, each either of the above as data (`AparteDiffFile`) or two texts.
34
+
35
+ The lines are coloured by the chat's highlighter when one is installed (`@aparte/plugin-shiki`), in the
36
+ language the path's extension names; without one they are plain text. The code reads left to right in a
37
+ right-to-left page. A screen reader hears each `+` and `−` as "added" and "removed", and each file's counts in
38
+ words.
39
+
40
+ ## Comments on a line
41
+
42
+ With `commentable`, a reader picks a line or a range and writes a comment on it. A click on a line number opens
43
+ a field under the line; Shift+click stretches the selection. From the keyboard, the numbers of a file are one tab
44
+ stop: the arrows move, Shift+arrows stretch, Enter or Space open the field, Escape lets go, Ctrl+Enter sends.
45
+ Without `commentable` nothing is clickable.
46
+
47
+ Sending fires `aparte-diff-comment` with `{ path, side, startLine, endLine, text, code }`
48
+ (`AparteDiffCommentEventDetail`; `side` is `'old'` for a removed line, `'new'` for the rest — `AparteDiffSide`).
49
+ The element keeps nothing: hand the comments back through `comments` (`AparteDiffComment`) and it shows them
50
+ under their lines, with their state.
51
+
52
+ ```ts
53
+ const view = document.querySelector('aparte-diff')!;
54
+ view.commentable = true;
55
+ const review: AparteDiffComment[] = [];
56
+ view.addEventListener('aparte-diff-comment', (event) => {
57
+ review.push({ ...event.detail, id: crypto.randomUUID(), state: 'pending' });
58
+ view.comments = review;
59
+ });
60
+
61
+ // Later, all at once, as one message to the agent:
62
+ sendToAgent(review.map((c) => `${c.path}:${c.startLine}: ${c.text}`).join('\n'));
63
+ view.comments = review.map((c) => ({ ...c, state: 'sent' }));
64
+ ```
65
+
66
+ Cancel the event (`event.preventDefault()`) to keep the field open with its text.
67
+
68
+ ## A tool's result, in the reply
69
+
70
+ `setupDiff` shows an edit tool's result as a diff under the tool's line, opened. The row stays core's — the
71
+ label and summary you gave the tool, its states — and the diff takes the place of the raw Input and Output.
72
+
73
+ ```ts
74
+ import { setupDiff } from '@aparte/plugin-diff';
75
+
76
+ const stop = setupDiff({
77
+ tool: 'edit_file',
78
+ map: (result, input) => ({ path: String(input.path), before: result.before, after: result.after }),
79
+ });
80
+ ```
81
+
82
+ `DiffSetupOptions`: `tool` (a name, a pattern, or a list), `map` (the change from the tool's result and input;
83
+ without it the result must already be a diff), `commentable`, and `open` (`false` keeps it behind the line). The
84
+ config comes second, the global one by default. The call returns the function that takes it off.
85
+
86
+ ## The computation
87
+
88
+ Plain functions with no DOM, in the browser and on a server:
89
+
90
+ ```ts
91
+ import { diffTexts, formatUnifiedDiff, parseUnifiedDiff } from '@aparte/plugin-diff';
92
+
93
+ const before = 'let total = 0;\ntotal += parseInt(amount, 10);\n';
94
+ const after = 'let total = 0;\ntotal += Number(amount);\n';
95
+ const file = diffTexts(before, after, { path: 'src/parse.ts', context: 3 }); // AparteDiffFile
96
+ const text = formatUnifiedDiff(file); // what `git apply` takes
97
+ const files = parseUnifiedDiff(text); // AparteDiffFile[]
98
+ ```
99
+
100
+ `diffTexts` (`DiffTextsOptions`: `context`, `path`, `oldPath`) is a line diff written here — Myers' algorithm, the
101
+ fewest added and removed lines — with no dependency. Lines are compared without their endings, so a file saved
102
+ with Windows line endings reads the same; a last line that gains or loses its newline shows as changed. A side
103
+ given as `null` is a file created (`diffTexts(null, text)`, `added`) or deleted (`diffTexts(text, null)`,
104
+ `deleted`); `''` is an empty file. A large file is first cut at the lines it holds once on each side, in the
105
+ same order (patience anchoring, as `git diff --patience`), and each gap between them is diffed on its own: a
106
+ 200,000-line file changed in a thousand places still gives a thousand small hunks, in well under a second. A
107
+ gap with thousands of changes and little in common is shown as removed then added, which stays a true account of
108
+ the change without being the shortest one.
109
+
110
+ `formatUnifiedDiff` writes what `git apply` takes: git's `new file mode` and `deleted file mode` headers for a
111
+ file created or deleted, `rename from` / `rename to` for a rename. `parseUnifiedDiff` reads a rename only where
112
+ git says one (`rename from` / `rename to`, or a `similarity index`): a plain `diff -u x.c.orig x.c` is a change
113
+ to `x.c`, and `diff -ru old new` keeps its trees' names.
114
+
115
+ An `AparteDiffFile` is `{ path, oldPath?, status?, added, removed, hunks, binary? }` (`AparteDiffFileStatus`:
116
+ `modified`, `added`, `deleted`, `renamed`); each `AparteDiffHunk` has `oldStart`, `oldCount`, `newStart`,
117
+ `newCount`, an optional `section` (the function a hunk is in), and its `lines` (`AparteDiffLine`: `kind` —
118
+ `AparteDiffLineKind`, `context`, `add` or `del` — `text`, `oldLine`, `newLine`, `noNewline`).
119
+
120
+ ## Words and theme
121
+
122
+ Its words are in the ten languages `@aparte/locales` ships, in the chat's language; change one with
123
+ `extendLocale({ diffCommentSubmit: 'Send' })`. The tints are tokens that fall back to core's:
124
+ `--aparte-diff-added-bg` (`--aparte-success-surface`), `--aparte-diff-removed-bg` (`--aparte-error-surface`),
125
+ `--aparte-diff-added-ink`, `--aparte-diff-removed-ink` and `--aparte-diff-selected-bg`.
126
+
127
+ Documentation: [apartejs.dev/components/diff](https://apartejs.dev/components/diff/).
128
+
129
+ ## License
130
+
131
+ MIT
@@ -0,0 +1,140 @@
1
+ import type { AparteDiffComment, AparteDiffInput } from './types.js';
2
+ /** Importable where there is no DOM: the class then extends nothing and is never defined. */
3
+ declare const ElementBase: typeof HTMLElement;
4
+ /**
5
+ * A change, as a reviewer reads it: each file under a header with its path and its counts
6
+ * (`+3 −1`), each line with its old and new numbers and a `+` or `−` (said as a word to a
7
+ * screen reader), the unchanged runs between hunks folded behind "Show 24 unchanged lines".
8
+ * Set `diff` to a unified diff's text, to a file's two texts (`{ path, before, after }`: every
9
+ * unchanged line can then be shown), or to a list of files.
10
+ *
11
+ * With `commentable`, a reader comments on a line or a range: a click on a line number (Shift+click
12
+ * to stretch it), or from the keyboard — the numbers of a file are one tab stop, the arrows move,
13
+ * Shift+arrows stretch, Enter or Space open the field, Escape lets go. Sending it fires
14
+ * `aparte-diff-comment`; keeping the comments and sending them on is the app's, and the ones it
15
+ * hands back through `comments` are shown under their lines with where each stands.
16
+ *
17
+ * The lines are coloured by the chat's highlighter when one is installed (`@aparte/plugin-shiki`),
18
+ * in the language the path's extension names. The code reads left to right in a right-to-left page.
19
+ *
20
+ * @element aparte-diff
21
+ *
22
+ * @attr {boolean} commentable - Let the reader pick a line or a range and write a comment on it. Off by default: without it nothing is clickable.
23
+ *
24
+ * @fires {CustomEvent<AparteDiffCommentEventDetail>} aparte-diff-comment - A comment was written and sent: `{ path, side, startLine, endLine, text, code }`. Bubbles out of the chat; cancel it to keep the field open with its text.
25
+ *
26
+ * @cssprop [--aparte-diff-added-bg=var(--aparte-success-surface)] - The background of an added line.
27
+ * @cssprop [--aparte-diff-removed-bg=var(--aparte-error-surface)] - The background of a removed line.
28
+ * @cssprop [--aparte-diff-added-ink=var(--aparte-success-ink)] - The `+` of an added line, and the count of added lines.
29
+ * @cssprop [--aparte-diff-removed-ink=var(--aparte-error-ink)] - The `−` of a removed line, and the count of removed lines.
30
+ * @cssprop [--aparte-diff-selected-bg=var(--aparte-surface-hover)] - The background of the lines picked for a comment.
31
+ *
32
+ * @example A file's two texts, open to comments
33
+ * ```html
34
+ * <aparte-diff commentable></aparte-diff>
35
+ * <script type="module">
36
+ * import '@aparte/plugin-diff';
37
+ *
38
+ * const diff = document.querySelector('aparte-diff');
39
+ * diff.diff = { path: 'src/parse.ts', before: oldText, after: newText };
40
+ * const comments = [];
41
+ * diff.addEventListener('aparte-diff-comment', (event) => {
42
+ * comments.push({ ...event.detail, state: 'pending' });
43
+ * diff.comments = comments;
44
+ * });
45
+ * </script>
46
+ * ```
47
+ */
48
+ export declare class AparteDiff extends ElementBase {
49
+ static get observedAttributes(): string[];
50
+ private _input;
51
+ private _shown;
52
+ /** Each file's element, as last drawn. */
53
+ private _files;
54
+ private _comments;
55
+ private readonly _id;
56
+ private _generation;
57
+ private _stopConfig;
58
+ private _selection;
59
+ private _form;
60
+ /** Whether the reader opened the field (it then follows the selection through a redraw). */
61
+ private _writing;
62
+ /** Each line row's line. */
63
+ private readonly _lineOf;
64
+ /** The change to show: a unified diff's text, `{ path, before, after }`, or a list of files (`AparteDiffFile` or texts). */
65
+ get diff(): AparteDiffInput | null;
66
+ set diff(value: AparteDiffInput | null);
67
+ /** The comments to show under their lines, with their state. The element only shows them. */
68
+ get comments(): AparteDiffComment[];
69
+ set comments(value: AparteDiffComment[]);
70
+ /** Whether a reader can comment on a line. Reflects the `commentable` attribute. */
71
+ get commentable(): boolean;
72
+ set commentable(value: boolean);
73
+ connectedCallback(): void;
74
+ disconnectedCallback(): void;
75
+ attributeChangedCallback(name: string, previous: string | null, value: string | null): void;
76
+ private get _config();
77
+ private _word;
78
+ private _onConfigChange;
79
+ /** Draw every file again from the state, the reader's selection, field and focus kept. */
80
+ private _render;
81
+ private _renderFile;
82
+ private _message;
83
+ /** The rows of file `index`, its comments under their lines. */
84
+ private _fillLines;
85
+ private _gapRow;
86
+ private _lineRow;
87
+ /** Put the highlighter's colours in a line's code, with its block's classes; `false` when it has none for it. */
88
+ private _colour;
89
+ private _number;
90
+ private _htmlOf;
91
+ /** The comments the app handed back, each under the line it ends on, or at the end of its file when that line is folded. */
92
+ private _placeComments;
93
+ private _commentNode;
94
+ /** "Line 12", "Lines 12–14", "Removed line 5". */
95
+ private _rangeWords;
96
+ /**
97
+ * Colour each file not coloured yet — or, `again`, every file — each side as one text, and
98
+ * put the colours in the lines on screen. A file is coloured only once its highlighter
99
+ * answered: one that failed (still loading its grammars) leaves it plain, to be tried again.
100
+ */
101
+ private _highlight;
102
+ private _paintColours;
103
+ private _linesOf;
104
+ /** The line row of file `index` with the key `key`, if it is drawn. */
105
+ private _rowOf;
106
+ private readonly _onClick;
107
+ private readonly _onKeydown;
108
+ /** A button acts on Space's keyup: the keydown already did. */
109
+ private readonly _onKeyup;
110
+ /** The line rows of the file `row` is in. */
111
+ private _rowsAround;
112
+ private _fileOf;
113
+ /** Move the file's tab stop to `row`'s number, and the focus with it. */
114
+ private _focusRow;
115
+ /** Shift+arrow: the selection runs from where it started (or from `from`) to `to`. */
116
+ private _stretch;
117
+ /** A click (or Enter, Space) on a line number: that line, or the selection stretched to it; then the field. */
118
+ private _pick;
119
+ private _selectedRows;
120
+ private _paintSelection;
121
+ /** What the selection covers: its side, its first and last line there, and those lines' text. */
122
+ private _range;
123
+ /** The field, under the selection's last line, named for what it covers. */
124
+ private _placeForm;
125
+ private _buildForm;
126
+ private _send;
127
+ /** Close the field and drop the selection; the focus goes back to the line it ended on. */
128
+ private _letGo;
129
+ /** Show the unchanged run `gap` of file `index`, and carry on from its first line. */
130
+ private _expand;
131
+ private _focusKey;
132
+ private _restoreFocus;
133
+ }
134
+ declare global {
135
+ interface HTMLElementTagNameMap {
136
+ 'aparte-diff': AparteDiff;
137
+ }
138
+ }
139
+ export {};
140
+ //# sourceMappingURL=aparte-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aparte-diff.d.ts","sourceRoot":"","sources":["../src/aparte-diff.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The line diff, written here: Myers' O(ND) algorithm ("An O(ND) Difference Algorithm and
3
+ * Its Variations", 1986), the one `git diff` and GNU diff start from. It finds the fewest
4
+ * added and removed lines that turn one text into the other, in time proportional to the
5
+ * length of the texts times the number of changes — small for an agent's edit.
6
+ *
7
+ * Three steps keep a large file fast, each said where it bites:
8
+ * - the lines the two texts share at their start and at their end are taken off first, so
9
+ * the search only runs over the part that changed;
10
+ * - a part longer than `ANCHOR_FROM` lines is first cut at the lines that appear once in
11
+ * each text, in the same order (the longest such run: "patience" anchoring, as
12
+ * `git diff --patience` does), and each gap between two of them is diffed on its own. A
13
+ * large file changed all through still gives one small hunk per change, in little time;
14
+ * - in a gap, past `MAX_COST` changes (two texts with little in common there) the search
15
+ * stops, and that gap alone is shown as removed then added: still a true account of the
16
+ * change, no longer the shortest one. The memory the search keeps grows with the square
17
+ * of the changes, which is what the bound is for.
18
+ *
19
+ * No DOM anywhere: `diffTexts` runs on a server as well.
20
+ */
21
+ import type { AparteDiffFile, AparteDiffHunk, AparteDiffLine } from './types.js';
22
+ /** One step of the edit: a line kept, removed from the old text, or added from the new one. */
23
+ export type Edit = 'eq' | 'del' | 'add';
24
+ /**
25
+ * The edit that turns `a` into `b`, one step per line, removals before additions inside a
26
+ * run of changes.
27
+ */
28
+ export declare function diffLines(a: readonly string[], b: readonly string[]): Edit[];
29
+ /** A text's lines, without their endings, and whether its last line ends with one. */
30
+ export declare function splitLines(text: string): {
31
+ lines: string[];
32
+ endsWithNewline: boolean;
33
+ };
34
+ /** What `diffTexts` is told besides the two texts. */
35
+ export interface DiffTextsOptions {
36
+ /** Unchanged lines kept on each side of a change (3, as `git diff`). */
37
+ context?: number;
38
+ /** The file's path, as the diff names it. */
39
+ path?: string;
40
+ /** Its path before, when it was renamed. Not read for a file created or deleted (a `null` side). */
41
+ oldPath?: string;
42
+ }
43
+ /**
44
+ * The diff of two texts, as one file's hunks with their line numbers. Lines are compared
45
+ * without their endings, so a file saved with Windows line endings reads the same; a last
46
+ * line that gains or loses its newline is shown changed, marked `noNewline`.
47
+ *
48
+ * A side that does not exist is `null`: `before: null` is a file created (`added`),
49
+ * `after: null` a file deleted (`deleted`). `''` is a file that exists and is empty, so
50
+ * `diffTexts('', text)` is that file filled in (`modified`). `formatUnifiedDiff` writes each
51
+ * as git does, so the patch applies.
52
+ *
53
+ * @example
54
+ * const file = diffTexts(before, after, { path: 'src/parse.ts' });
55
+ * file.added; // 1
56
+ * file.hunks; // [{ oldStart: 12, oldCount: 7, newStart: 12, newCount: 7, lines: [...] }]
57
+ * diffTexts(null, 'hello\n', { path: 'notes.md' }).status; // 'added'
58
+ */
59
+ export declare function diffTexts(before: string | null, after: string | null, options?: DiffTextsOptions): AparteDiffFile;
60
+ /** The changed lines with `context` unchanged ones around them, two hunks joined when their context touches. */
61
+ export declare function hunksOf(lines: readonly AparteDiffLine[], context: number): AparteDiffHunk[];
62
+ //# sourceMappingURL=compute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../src/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjF,+FAA+F;AAC/F,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;AAkBxC;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,EAAE,CA4C5E;AA6HD,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAMtF;AAED,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC7B,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAE,gBAAqB,GAAG,cAAc,CAwCrH;AAED,gHAAgH;AAChH,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAkB3F"}