@whybebabo/dsh-file-review-tab 0.0.0-stage → 0.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.
@@ -0,0 +1,66 @@
1
+ /** `file-review` namespace dictionaries. */
2
+ /** Dictionary namespace owned by this plugin. */
3
+ export declare const NS = "file-review";
4
+ /** English dictionary (the key-set source of truth). */
5
+ export declare const en: {
6
+ 'produced.summary': string;
7
+ 'produced.editedOne': string;
8
+ 'produced.edited': string;
9
+ 'produced.added': string;
10
+ 'produced.deletedStat': string;
11
+ 'produced.previewHint': string;
12
+ 'produced.expandAria': string;
13
+ 'produced.collapse': string;
14
+ 'produced.collapseAria': string;
15
+ 'produced.all': string;
16
+ 'produced.viewDiff': string;
17
+ 'produced.openReview': string;
18
+ 'produced.moreOne': string;
19
+ 'produced.more': string;
20
+ 'produced.open': string;
21
+ 'produced.review': string;
22
+ 'produced.reviewAll': string;
23
+ 'produced.undo': string;
24
+ 'produced.redo': string;
25
+ 'produced.undoing': string;
26
+ 'produced.redoing': string;
27
+ 'produced.toggleUnavailable': string;
28
+ 'produced.undoSuccess': string;
29
+ 'produced.redoSuccess': string;
30
+ 'produced.undoPartial': string;
31
+ 'produced.redoPartial': string;
32
+ 'produced.undoPartialDescription': string;
33
+ 'produced.redoPartialDescription': string;
34
+ 'produced.skippedFiles': string;
35
+ 'produced.undoError': string;
36
+ 'produced.redoError': string;
37
+ 'produced.noticeClose': string;
38
+ 'produced.noticeDismiss': string;
39
+ 'produced.deleted': string;
40
+ 'produced.deletedOne': string;
41
+ 'produced.deletedAll': string;
42
+ 'review.title': string;
43
+ 'review.fileOne': string;
44
+ 'review.files': string;
45
+ 'review.close': string;
46
+ 'review.resize': string;
47
+ 'review.resizeHint': string;
48
+ 'review.openInEditor': string;
49
+ 'review.copy': string;
50
+ 'review.copied': string;
51
+ 'review.showUnchanged': string;
52
+ 'review.hideUnchanged': string;
53
+ 'review.stats': string;
54
+ 'review.unavailable': string;
55
+ 'diff.created': string;
56
+ 'diff.deleted': string;
57
+ 'diff.unchanged': string;
58
+ 'diff.truncated': string;
59
+ 'diff.loading': string;
60
+ 'diff.missing': string;
61
+ };
62
+ /** Union of this namespace's dictionary keys. */
63
+ export type DeliverablesKey = keyof typeof en;
64
+ /** Simplified Chinese dictionary. */
65
+ export declare const zh: Record<DeliverablesKey, string>;
66
+ //# sourceMappingURL=chat-locales.d.ts.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Chat → sidebar deep-link channel.
3
+ *
4
+ * The chat turn-tail row knows which paths (and which turn) the user wants to
5
+ * inspect, but better-sidebar's native right Sidebar mints its own tab ids and
6
+ * does not refresh an already-open tab's `meta` (dsh-better-sidebar #632 /
7
+ * 0.19.1 adapter behaviour). Passing a `path` seed is also unsafe there: the
8
+ * native surface routes path-bearing opens to the file editor, so the review
9
+ * tab would never mount.
10
+ *
11
+ * The channel therefore carries the seed inside this plugin: the chat row
12
+ * publishes it and then opens the tab by type; the tab body subscribes and
13
+ * replays whatever arrived, whether it mounted just now or was already open.
14
+ * Sessions are keyed separately, and each publish gets a monotonic nonce so a
15
+ * replay can never be mistaken for a fresh link.
16
+ */
17
+ /** One chat-issued review target inside a session. */
18
+ export interface FileReviewSeed {
19
+ readonly paths: readonly string[];
20
+ /** Turn anchor: expand only this turn's rows for the given paths. */
21
+ readonly turn?: number;
22
+ /** Monotonic publish id; a new value means a new link to replay. */
23
+ readonly nonce: number;
24
+ }
25
+ type SeedListener = (sessionId: string, seed: FileReviewSeed) => void;
26
+ type InvalidationListener = (sessionId: string) => void;
27
+ /** Publish a deep link for one session and return the stored seed. */
28
+ export declare function publishFileReviewSeed(sessionId: string, paths: readonly string[], turn?: number): FileReviewSeed;
29
+ /** The most recent seed for a session, if the tab has not consumed it yet. */
30
+ export declare function currentFileReviewSeed(sessionId: string): FileReviewSeed | undefined;
31
+ /** Observe every publish; the caller filters by session. */
32
+ export declare function subscribeFileReviewSeed(listener: SeedListener): () => void;
33
+ /** Notify every mounted review surface that one session's disk state changed. */
34
+ export declare function publishFileReviewInvalidation(sessionId: string): void;
35
+ /** Observe disk-state invalidations issued by this plugin's review surfaces. */
36
+ export declare function subscribeFileReviewInvalidation(listener: InvalidationListener): () => void;
37
+ export {};
38
+ //# sourceMappingURL=deep-link.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Literal deletion-path extraction from terminal command text (unknown-safe).
3
+ *
4
+ * dsh has no dedicated delete-file tool: agents delete through the Bash/Pwsh
5
+ * terminals, whose `tool/call` arguments carry the raw command line in
6
+ * `command`. There is no filesystem snapshot to consult, so this parser is deliberately
7
+ * conservative — it only reports paths that appear VERBATIM as arguments of a
8
+ * known deletion command:
9
+ *
10
+ * - command substitution (`$(…)`, backticks) or process substitution anywhere
11
+ * in a segment disqualifies that whole segment;
12
+ * - glob characters (`* ? [`) or variable expansion (`$`) in an argument
13
+ * disqualify that argument (the affected set cannot be enumerated post
14
+ * hoc);
15
+ * - shell separators (`&&`, `||`, `|`, `;`, newline) split the line so
16
+ * `rm a && rm b` reports both while `echo rm x` reports nothing.
17
+ *
18
+ * A reported path is display-only vocabulary: the file is gone, so it carries
19
+ * no diff hunks and no undo. Directories deleted with `rm -r` surface as the
20
+ * directory path itself.
21
+ */
22
+ /**
23
+ * Deletion paths named literally by one terminal command line, in argument
24
+ * order, deduplicated. `undefined`/non-string titles and non-terminal views
25
+ * report nothing.
26
+ */
27
+ export declare function deletedPathsFromCommand(command: string): readonly string[];
28
+ //# sourceMappingURL=deleted-paths.d.ts.map
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Line pairing and hunk building shared by every comparison this plugin draws.
3
+ *
4
+ * The sidebar review tab and the chat hover preview both render dsh's own native
5
+ * FileDiff markup, so pairing, numbering, hunk trimming and counting live here
6
+ * once. Counts come from the same pairing the viewer draws with, which is what
7
+ * keeps a "+N" badge from ever disagreeing with the lines on screen.
8
+ *
9
+ * Recorded changes arrive as full before/after snapshots, while dsh's own diff
10
+ * service delivers pre-trimmed hunks. {@link toNativeHunks} bridges the two by
11
+ * trimming context the same way, so a one-line edit in a long file renders as one
12
+ * small hunk instead of the whole file.
13
+ */
14
+ import type { ProducedFileDiff } from '../change-types.ts';
15
+ /** How one drawn line relates to the two sides of the comparison. */
16
+ export type DiffLineKind = 'context' | 'del' | 'add';
17
+ /** One line of a comparison, already numbered against both sides. */
18
+ export interface DiffLine {
19
+ readonly kind: DiffLineKind;
20
+ readonly oldNumber: number | null;
21
+ readonly newNumber: number | null;
22
+ readonly text: string;
23
+ }
24
+ /** Added and removed line totals. */
25
+ export interface DiffStats {
26
+ readonly added: number;
27
+ readonly removed: number;
28
+ }
29
+ /** Optional native note shown above a comparison. */
30
+ export type DiffNote = 'created' | 'deleted' | 'unchanged' | undefined;
31
+ /**
32
+ * One comparison in the shape dsh's own FileDiff renders: a header coordinate
33
+ * pair plus `+`/`-`/` ` prefixed lines.
34
+ */
35
+ export interface NativeDiffHunk {
36
+ readonly oldStart: number;
37
+ readonly oldLines: number;
38
+ readonly newStart: number;
39
+ readonly newLines: number;
40
+ readonly lines: readonly string[];
41
+ }
42
+ /** Whether a comparison touches only one side, which forces the unified view. */
43
+ export declare function isOneSided(hunks: readonly NativeDiffHunk[]): boolean;
44
+ /** Pair one recorded before/after snapshot into numbered lines. */
45
+ export declare function pairLines(diff: ProducedFileDiff): DiffLine[];
46
+ /** Count added and removed lines using the viewer's exact line-diff algorithm. */
47
+ export declare function summarizeDiffs(diffs: readonly ProducedFileDiff[]): DiffStats;
48
+ /**
49
+ * Derive the comparison note from the recorded change rather than hunk count alone.
50
+ *
51
+ * The creation note comes from the explicit `created` flag, never from
52
+ * `oldText === null`. Null old text means the prior content is unavailable, and
53
+ * that is also what `mutation-call.ts` synthesizes when a result carries no
54
+ * `meta.diffs` for a `write` overwrite, a `str_replace_editor insert` or an
55
+ * `edit` with an empty `old_string` — all edits to files that already existed.
56
+ * Inferring creation from null labeled those "created in this turn".
57
+ *
58
+ * Creation is a FILE-level fact, so ANY authoritative creation record for the
59
+ * path carries it. `diffs` holds one file's hunks in settlement order, and a
60
+ * file created and then edited in the same turn keeps its creation hunk
61
+ * alongside the later ordinary ones; requiring `every` hunk to be flagged lost
62
+ * the note precisely there. Only the explicitly flagged hunks count, so a
63
+ * file whose prior content is merely unknown stays unlabeled.
64
+ */
65
+ export declare function diffNote(diffs: readonly ProducedFileDiff[], hunks: readonly NativeDiffHunk[], deleted?: boolean): DiffNote;
66
+ /**
67
+ * The message a comparison with nothing to draw shows. A file removed by a
68
+ * command has no content left, which is a different fact from a change whose
69
+ * two sides could not be reconstructed — so it keeps its own explanation
70
+ * instead of the generic one.
71
+ * @param deleted - whether the change removed the file.
72
+ * @param deletedHint - copy for a command-deleted file.
73
+ * @param missing - copy for a change that cannot be reconstructed.
74
+ * @returns the copy to show.
75
+ */
76
+ export declare function missingMessage(deleted: boolean, deletedHint: string, missing: string): string;
77
+ /**
78
+ * Convert recorded comparisons into dsh's served hunk shape.
79
+ * @param diffs - the recorded before/after snapshots for one file.
80
+ * @param contextLines - unchanged lines kept on each side of a change.
81
+ * @returns the hunks to render, in order.
82
+ */
83
+ export declare function toNativeHunks(diffs: readonly ProducedFileDiff[], contextLines?: number): NativeDiffHunk[];
84
+ /** Serialize recorded hunks as one plain-text unified diff. */
85
+ export declare function nativeDiffText(hunks: readonly NativeDiffHunk[]): string;
86
+ //# sourceMappingURL=diff-hunks.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Split one side of a diff into content lines without manufacturing a final
3
+ * empty line for a trailing line terminator.
4
+ * @param text - One diff side's text.
5
+ * @returns Content lines without the terminating newline.
6
+ */
7
+ export declare function diffContentLines(text: string): string[];
8
+ //# sourceMappingURL=diff-text.d.ts.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * File-review-tab plugin, browser half: TWO coexisting surfaces over the same
3
+ * produced-file vocabulary —
4
+ *
5
+ * 1. the chat turn-tail row (the original dsh-file-review card: "Edited N
6
+ * files · +M -K / Undo / Review"), registered into the
7
+ * 'conversation.chat.turnTail' list at order -2. This slot was a
8
+ * first-claim-wins chain through DSH 0.1.5 and is an additive list from
9
+ * 0.1.6-alpha.2, so entries coexist instead of electing: the row declares an
10
+ * `id` and renders null for a turn it does not claim (see ProducedFiles); and
11
+ * 2. the 'file-review' better-sidebar tab (per-session change list + inline
12
+ * red/green diffs + per-turn/per-file undo).
13
+ *
14
+ * The Host half's undo/redo capability reaches both surfaces through the
15
+ * package's Typert remote contribution, mounted here exactly like
16
+ * dsh-file-review did. Every registration is wrapped in ctx.effect so fiber
17
+ * disposal (HMR / plugin disable) unregisters cleanly.
18
+ */
19
+ import type { Context } from '@deepseek-ai/cordis';
20
+ import { type DeliverablesKey } from './chat-locales.ts';
21
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
22
+ interface LocaleNamespaceMap {
23
+ /** Turn-tail row copy (the chat-side surface). */
24
+ 'file-review': DeliverablesKey;
25
+ }
26
+ }
27
+ /**
28
+ * Required services: the sidebar registry, session snapshots, locale, remote,
29
+ * and the slot registry (turn-tail chain). The conversation Definition
30
+ * registry is deliberately NOT a static inject: its service name moved across
31
+ * dsh releases (<= 0.1.1: root `conversationEvents`; 0.1.2-alpha.1+:
32
+ * `uiConversation.events`), so a hard inject on either name leaves the whole
33
+ * plugin forever "pending" on the other version and fails web boot (issue
34
+ * #6). It is resolved dynamically in apply() instead.
35
+ */
36
+ export declare const inject: string[];
37
+ /**
38
+ * Client plugin body: attach locale, mount the Typert remote, register the
39
+ * chat turn-tail row AND the sidebar tab.
40
+ * @param ctx - client root context.
41
+ */
42
+ export declare function apply(ctx: Context): void;
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Minimal zh/en copy for the file-review sidebar tab. Follows the DSH i18n
3
+ * system: the client apply attaches the locale service (`ctx.locale`,
4
+ * provided by `@deepseek-ai/dsh-client-locale`) through {@link attachLocale},
5
+ * and `t()` resolves the active locale from it. Without an attached service
6
+ * (standalone/test compositions) the browser language is used. Mirrors the
7
+ * dsh-better-sidebar locales pattern.
8
+ */
9
+ /** The dictionary namespace this plugin owns in the DSH locale registry. */
10
+ export declare const LOCALE_NS = "fileReviewTab";
11
+ /** The zh dictionary (the key-set source of truth). */
12
+ export declare const zh: {
13
+ readonly tabTitle: "文件审查";
14
+ readonly empty: "本会话暂无文件改动";
15
+ readonly sessionUnavailable: "会话不可用";
16
+ readonly remoteUnavailable: "文件审查服务不可用";
17
+ readonly turn: "第 {n} 轮";
18
+ readonly turnLive: "进行中";
19
+ readonly files: "{count} 个文件";
20
+ readonly filesOne: "1 个文件";
21
+ readonly undo: "撤销";
22
+ readonly redo: "重新应用";
23
+ readonly undoing: "正在撤销…";
24
+ readonly redoing: "正在重新应用…";
25
+ readonly undoTurn: "撤销本轮";
26
+ readonly redoTurn: "重新应用本轮";
27
+ readonly toggleUnavailable: "没有可安全还原的文件";
28
+ readonly stateUndone: "已撤销";
29
+ readonly stateConflict: "内容冲突";
30
+ readonly stateUnsupported: "不可还原";
31
+ readonly stateError: "错误";
32
+ readonly deleted: "已删除";
33
+ readonly deletedHint: "该文件在本轮中被终端命令删除,内容已不存在,无法查看差异或撤销。";
34
+ readonly archived: "已归档 {n} 轮";
35
+ readonly archivedExpand: "展开已归档轮次";
36
+ readonly archivedCollapse: "收起已归档轮次";
37
+ readonly loadMore: "加载更多(还有 {n} 轮)";
38
+ readonly undoSuccess: "已成功撤销更改";
39
+ readonly redoSuccess: "已成功重新应用更改";
40
+ readonly undoPartial: "部分文件未能撤销";
41
+ readonly redoPartial: "部分文件未能重新应用";
42
+ readonly toggleError: "操作失败";
43
+ readonly openInEditor: "在编辑器中打开";
44
+ readonly open: "打开 {name}";
45
+ readonly copy: "复制差异";
46
+ readonly copied: "已复制";
47
+ readonly showUnchanged: "显示 {count} 行未更改内容";
48
+ readonly hideUnchanged: "隐藏 {count} 行未更改内容";
49
+ readonly stats: "新增 {added} 行,删除 {removed} 行";
50
+ readonly unavailable: "无法为此更改还原可审查的差异。";
51
+ readonly refresh: "刷新状态";
52
+ readonly refreshAria: "重新检查每个文件的撤销状态";
53
+ readonly selectFile: "选择要查看的文件";
54
+ readonly split: "切换为左右对比";
55
+ readonly unified: "切换为单栏对比";
56
+ readonly splitAria: "左右对比";
57
+ readonly wrap: "开启自动换行";
58
+ readonly nowrap: "关闭自动换行";
59
+ readonly wrapAria: "自动换行";
60
+ readonly diffLoading: "正在读取改动…";
61
+ readonly diffMissing: "这轮改动的内容已不可用";
62
+ readonly diffCreated: "本轮新建的文件";
63
+ readonly diffDeleted: "本轮删除的文件";
64
+ readonly diffUnchanged: "两侧内容相同";
65
+ readonly diffTruncated: "只显示前 {count} 行";
66
+ };
67
+ /** Union of this namespace's dictionary keys. */
68
+ export type CopyKey = keyof typeof zh;
69
+ /** The en dictionary. */
70
+ export declare const en: Record<CopyKey, string>;
71
+ /** Attach (or detach, with undefined) the DSH locale service. */
72
+ export declare function attachLocale(service: {
73
+ getSnapshot(): {
74
+ active: string;
75
+ };
76
+ } | undefined): void;
77
+ /** Translate a copy key; `{name}` placeholders interpolate from `params`. */
78
+ export declare function t(key: CopyKey, params?: Record<string, string | number>): string;
79
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Shared file-mutation facts for dsh 0.1.5.
3
+ *
4
+ * The Conversation Definition contract no longer hands matches a pre-rendered
5
+ * wire view, so both the chat turn-tail row and the sidebar tab derive a
6
+ * mutation from the same two sources the dsh 0.1.5 tooling uses:
7
+ *
8
+ * - `tool/call` arguments identify the mutated path and the intended hunks
9
+ * (`write` / `edit` / `str_replace_editor`), or the terminal command whose
10
+ * literal rm-family arguments name deleted paths (`bash` / `pwsh`);
11
+ * - `tool/result` `meta.diffs` carries the applied contextual hunks that
12
+ * dsh-tool-fs attaches on settlement (no line numbers in 0.1.5).
13
+ *
14
+ * Unknown tools and malformed arguments yield null, keeping the vocabulary
15
+ * conservative: a call only produces review data when its shape is known.
16
+ */
17
+ import type { ProducedFileDiff } from '../change-types.ts';
18
+ /** One mutation call's parsed intent, captured at `tool/call` time. */
19
+ export interface CallIntent {
20
+ /** The single path the call mutates; null for a deletion-only terminal call. */
21
+ readonly path: string | null;
22
+ /** Call-argument-derived hunks, used when the result carries no meta diff. */
23
+ readonly diffs: readonly ProducedFileDiff[];
24
+ /** Literal paths a terminal call deletes. */
25
+ readonly deletions: readonly string[];
26
+ }
27
+ /**
28
+ * The call-argument-derived mutation intent for one write/edit/str_replace_editor
29
+ * or terminal call. Unknown tools and malformed arguments return null.
30
+ */
31
+ export declare function callIntent(name: string, argsRaw: unknown): CallIntent | null;
32
+ /** Validate the tool-private result metadata's contextual diff hunks. */
33
+ export declare function appliedDiffs(meta: unknown): readonly ProducedFileDiff[] | null;
34
+ //# sourceMappingURL=mutation-call.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { ProducedFileDiff } from '../change-types.ts';
2
+ /**
3
+ * Line-level hunks for one file mutation, or a single whole-file entry when the
4
+ * file was created (`before === null`, mirroring the write tool's null-content
5
+ * card). Returns [] only when an existing file's content is unchanged: a
6
+ * `before === null` mutation always changed the filesystem, even when `after`
7
+ * is empty, because the file came into existence.
8
+ */
9
+ export declare function diffsFromBeforeAfter(path: string, before: string | null, after: string): readonly ProducedFileDiff[];
10
+ //# sourceMappingURL=recorded-diffs.d.ts.map
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Session-wide produced-file derivation from a finalized ConversationSnapshot.
3
+ *
4
+ * dsh 0.1.5 removed the pre-rendered `callView` from `ToolResultNode`; the
5
+ * mutation facts now live in the call head (`call.name` + `call.argsRaw`) and
6
+ * the tool-private result metadata (`meta.diffs`). This module folds those
7
+ * into per-turn file changes for the sidebar tab, walking the settled tool
8
+ * nodes and, recursively, their Code Mode (`run_code`) sub-calls. Turn
9
+ * attribution still rides the Chat snapshot's `turnEnds` / live counters.
10
+ *
11
+ * Client-only and model-free: the vocabulary is the mutation tools' own call
12
+ * arguments and result metadata, never the closing prose.
13
+ */
14
+ import type { ConversationSnapshot } from '@deepseek-ai/dsh-client-ui-conversation/client';
15
+ import type { ProducedFileDiff, RecordedMutation } from '../change-types.ts';
16
+ /** One changed file inside one turn, hunks appended in settlement order. */
17
+ export interface SessionFileChange {
18
+ readonly path: string;
19
+ readonly diffs: readonly ProducedFileDiff[];
20
+ /** Terminal commands deleted this path in this turn (display-only). */
21
+ readonly deleted?: true;
22
+ }
23
+ /** One turn's produced files, in first-seen order. */
24
+ export interface TurnFileChanges {
25
+ readonly turn: number;
26
+ /** Whether the owning turn is still running (its change set may grow). */
27
+ readonly live: boolean;
28
+ readonly files: readonly SessionFileChange[];
29
+ }
30
+ /** Derive per-turn produced-file changes for one session snapshot. */
31
+ export declare function deriveSessionChanges(snapshot: ConversationSnapshot | null): TurnFileChanges[];
32
+ /**
33
+ * One Code Mode (`run_code`) root visible in the snapshot, with the turn it
34
+ * settles into. The snapshot now carries settled `subCalls` with their own
35
+ * call heads and result metadata, so those are the primary source; this root
36
+ * list only feeds the Host recorder fallback for roots whose nested facts did
37
+ * not survive into the snapshot.
38
+ */
39
+ export interface SessionRoot {
40
+ readonly turn: number;
41
+ readonly live: boolean;
42
+ readonly rootCallId: string;
43
+ }
44
+ /** Every `run_code` tool-result node whose nested changes are not in the snapshot. */
45
+ export declare function deriveSessionRoots(snapshot: ConversationSnapshot): SessionRoot[];
46
+ /**
47
+ * Merge Host-recorded Code Mode mutations into the snapshot-derived turns:
48
+ * hunks rebuilt from the full before/after are appended to the owning turn's
49
+ * file groups (same-path entries stay one row, hunks appended in dispatch
50
+ * order), so the tab's diff rendering, status inspection and undo all work on
51
+ * programmatic edits exactly like model-direct ones. All inputs are immutable;
52
+ * the result is a fresh array only when a recorded mutation matched a visible
53
+ * root.
54
+ */
55
+ export declare function mergeRecordedTurns(turns: readonly TurnFileChanges[], roots: readonly SessionRoot[], recorded: readonly RecordedMutation[]): readonly TurnFileChanges[];
56
+ /** Count distinct changed paths across every turn (the sidebar badge count). */
57
+ export declare function countChangedFiles(turns: readonly TurnFileChanges[]): number;
58
+ /**
59
+ * Turns that stay in the review tab's MAIN list: the newest
60
+ * {@link ARCHIVE_KEEP_TURNS} turns plus every live (still-running) turn.
61
+ * Older completed turns auto-archive to the tab's bottom section (issue #5:
62
+ * long sessions accumulate dozens of diff groups and weigh the page down).
63
+ */
64
+ export declare const ARCHIVE_KEEP_TURNS = 5;
65
+ /** Archived turns render this many groups per loaded page once the section opens. */
66
+ export declare const ARCHIVE_PAGE_TURNS = 10;
67
+ /** Split turns into the main list and the auto-archived tail (both newest-first). */
68
+ export declare function splitArchivedTurns(turns: readonly TurnFileChanges[], keep?: number): {
69
+ main: readonly TurnFileChanges[];
70
+ archived: readonly TurnFileChanges[];
71
+ };
72
+ /** Trailing path segment, the part that identifies the file at a glance. */
73
+ export declare function basename(path: string): string;
74
+ /** Resolve a (possibly relative) tool path against the session cwd. */
75
+ export declare function resolveSessionPath(cwd: string | undefined, path: string): string;
76
+ //# sourceMappingURL=session-changes.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Cross-release ConversationSnapshot compatibility.
3
+ *
4
+ * dsh 0.1.1-rc.2 (and earlier 0.1.0/0.1.1 line): the chat projection is
5
+ * mirrored to TOP-LEVEL legacy fields — `nodes`, `turnTimings`, `turnEnds`,
6
+ * `partial`, `runningCalls` — on `ConversationSnapshot` itself.
7
+ *
8
+ * dsh 0.1.2-alpha.1: those top-level fields are gone; the same slice moved
9
+ * into `views.get('chat').legacy` (ChatSnapshot.legacy: LegacyConversationSlice).
10
+ *
11
+ * Every consumer takes this normalized view, so the plugin works unchanged on
12
+ * both releases. Old snapshots take the zero-cost top-level path; new ones
13
+ * resolve the chat view once per call.
14
+ */
15
+ /** The legacy slice shape shared by both releases (Map identity included). */
16
+ export interface NormalizedConversationSnapshot {
17
+ readonly nodes: readonly unknown[];
18
+ readonly turnEnds: ReadonlyMap<number, number>;
19
+ readonly partial: {
20
+ readonly turn?: number;
21
+ } | null;
22
+ readonly runningCalls: readonly {
23
+ readonly turn?: number;
24
+ }[];
25
+ }
26
+ /**
27
+ * Normalize either release's ConversationSnapshot into the legacy slice.
28
+ * Returns undefined for non-objects (defensive; the legacy contract returns
29
+ * null instead of a snapshot when unbound).
30
+ */
31
+ export declare function normalizeSnapshot(snapshot: unknown): NormalizedConversationSnapshot | undefined;
32
+ //# sourceMappingURL=snapshot-compat.d.ts.map
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Turn-scoped produced-file definition and readers.
3
+ *
4
+ * dsh 0.1.5 moved the Chat turn-tail slot and its owner currency into
5
+ * `@deepseek-ai/dsh-client-ui-chat`, and the Conversation Definition contract
6
+ * no longer hands each match a pre-rendered wire view. The mutation facts are
7
+ * therefore derived the same way dsh 0.1.5's own ui-deliverables does it: from
8
+ * the `tool/call` arguments, plus the tool-private `meta.diffs` attached to a
9
+ * `tool/result` (dsh-tool-fs publishes the result-time contextual diff there).
10
+ * The Definition still publishes a richer `deliverables` Turn value than the
11
+ * built-in row — the hunks ride along so the turn-tail card can show +M −K and
12
+ * offer undo/redo through this plugin's Host service.
13
+ *
14
+ * Client-only and model-free: the vocabulary is the mutation tools' own call
15
+ * arguments and result metadata, never the closing prose.
16
+ */
17
+ import type { ConversationNodeDefinition } from '@deepseek-ai/dsh-client-ui-conversation/client';
18
+ import type { MarkdownFileMentions } from '@deepseek-ai/dsh-client-ui-primitives';
19
+ import type { TurnTailOwnerProps } from '@deepseek-ai/dsh-client-ui-chat/client';
20
+ import type { ProducedFileDiff, ProducedFileReview } from '../change-types.ts';
21
+ import { callIntent } from './mutation-call.ts';
22
+ export type { ProducedFileDiff, ProducedFileReview } from '../change-types.ts';
23
+ interface ProducedPath {
24
+ readonly seq: number;
25
+ readonly path: string;
26
+ readonly diffs: readonly ProducedFileDiff[];
27
+ /** Terminal commands deleted this path in the same Turn (display-only). */
28
+ readonly deleted?: true;
29
+ }
30
+ /** Immutable produced-file facts published against one Turn. */
31
+ export interface DeliverablesTurnData {
32
+ readonly produced: readonly ProducedPath[];
33
+ }
34
+ declare module '@deepseek-ai/dsh-client-ui-conversation/client' {
35
+ interface ConversationTurnDataMap {
36
+ /** Successful mutation paths (and their hunks) accumulated in this Turn. */
37
+ deliverables: DeliverablesTurnData;
38
+ }
39
+ }
40
+ interface DeliverablesState extends DeliverablesTurnData {
41
+ readonly turn: number;
42
+ readonly calls: ReadonlyMap<string, ReturnType<typeof callIntent>>;
43
+ }
44
+ /**
45
+ * Files and review hunks available at one closing Assistant boundary.
46
+ * @param data - engine-published Deliverables data for one Turn.
47
+ * @param seq - closing Assistant seq; later Tool settlements are excluded.
48
+ * @returns Produced files in first-seen order with same-path hunks appended in settlement order.
49
+ */
50
+ export declare function reviewsForClosing(data: Readonly<DeliverablesTurnData> | undefined, seq?: number): readonly ProducedFileReview[];
51
+ /**
52
+ * Files produced by one Turn data value.
53
+ *
54
+ * A mutation is recognized by its tool call intent, not by a result view: a
55
+ * write/edit/str_replace_editor call mutates one path, and a successful
56
+ * terminal call's literal rm-family arguments name deleted paths. Reads
57
+ * contribute nothing (looking at a file does not produce it); failed calls
58
+ * contribute nothing. Paths keep first-seen order and appear once.
59
+ * @param data - engine-published Deliverables data for one Turn.
60
+ * @param seq - closing Assistant seq; later Tool settlements are excluded.
61
+ * @returns Produced paths in first-seen order; empty when the turn wrote nothing.
62
+ */
63
+ export declare function producedForClosing(data: Readonly<DeliverablesTurnData> | undefined, seq?: number): readonly string[];
64
+ /**
65
+ * Claim the turn-tail chain only when its closing turn produced files.
66
+ * @param owner - Turn-tail owner currency for the closing assistant.
67
+ * @returns Produced-file reviews as the component's match, or null to decline before mount.
68
+ */
69
+ export declare function selectProducedFiles(owner: TurnTailOwnerProps): readonly ProducedFileReview[] | null;
70
+ /** Turn-local successful mutation accumulator; it publishes no view Node. */
71
+ export declare const deliverablesDefinition: ConversationNodeDefinition<DeliverablesState>;
72
+ /**
73
+ * Trailing path segment, the part that identifies the file at a glance.
74
+ * @param path - Slash- or backslash-separated path.
75
+ * @returns The final segment, or the whole string when separator-free.
76
+ */
77
+ export declare function basename(path: string): string;
78
+ /**
79
+ * File-mention vocabulary over one turn's produced paths, for the closing
80
+ * message's prose: an inline-code token opens the file it names. A token
81
+ * resolves by exact path, or by being exactly the basename of exactly one
82
+ * produced path — a basename two paths share stays inert rather than
83
+ * guessing, so a mention link can never open the wrong file or 404.
84
+ * @param paths - The turn's produced paths (tool order, already deduped).
85
+ * @param openFile - The chat view's file opener.
86
+ * @param label - Localizes the accessible open-label for a resolved path.
87
+ * @returns The resolver MarkdownText consumes; the full path rides `title`,
88
+ * the same disambiguator the row's chips carry.
89
+ */
90
+ export declare function producedFileMentions(paths: readonly string[], openFile: (path: string) => void, label: (path: string) => string): MarkdownFileMentions;
91
+ //# sourceMappingURL=turn-deliverables.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** Host-side, workspace-contained undo / redo service for produced text diffs. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import type { Agent } from '@deepseek-ai/dsh-agent';
4
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
5
+ import type { FileReviewAction, FileReviewChange, FileReviewRequest, FileReviewResult, RecordedMutation, RecordedRequest, RecordedResult } from './change-types.ts';
6
+ /** Apply a complete file's hunk sequence in memory, or report a strict mismatch. */
7
+ export declare function transformFile(text: string, file: FileReviewChange, action: FileReviewAction): string | null;
8
+ /** Host service published as the `fileReview` Remote namespace. */
9
+ export declare class FileReviewService extends TypertRemoteService {
10
+ /** Per-agent record of Code Mode (`run_code`) file mutations, dispatch order. */
11
+ private readonly recordLog;
12
+ constructor(ctx: Context);
13
+ /** Append one nested (Code Mode) file mutation for the receiving agent. */
14
+ recordMutation(agent: Agent, mutation: RecordedMutation): void;
15
+ /** Return the recorded mutations for the requested `run_code` roots. */
16
+ recorded(agent: Agent, request: RecordedRequest): Promise<RecordedResult>;
17
+ /** Inspect current disk state without changing files. */
18
+ status(agent: Agent, request: FileReviewRequest): Promise<FileReviewResult>;
19
+ /** Toggle every independently safe file while the receiving Agent is idle. */
20
+ apply(agent: Agent, request: FileReviewRequest): Promise<FileReviewResult>;
21
+ }
22
+ //# sourceMappingURL=file-review-service.d.ts.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File-review-tab plugin, node half. Registers the response-format guidance
3
+ * that lets the browser half recognize final-response file references. The
4
+ * browser half ships via exports["./client"], discovered through the
5
+ * package.json dsh.client declaration.
6
+ */
7
+ import type { Context } from '@deepseek-ai/cordis';
8
+ export type * from './change-types.ts';
9
+ export { FileReviewService, transformFile } from './file-review-service.ts';
10
+ /** Services required for the model guidance paired with the browser renderer. */
11
+ export declare const inject: string[];
12
+ /**
13
+ * Register model guidance for the file-reference renderer shipped by this package,
14
+ * and the Code Mode (`run_code`) mutation recorder that backs the browser-side
15
+ * review tab.
16
+ *
17
+ * Nested dispatch results carry no wire views — the diff cards only ride
18
+ * model-direct tool/call frames — so reviewing programmatic file edits needs a
19
+ * second source: this listener snapshots the full `before`/`after` content of
20
+ * every nested file mutation (`edit`/`write` — recognized by result shape, not
21
+ * tool name) into the `fileReview` service, which the browser half later turns
22
+ * into line-level hunks and merges into the owning `run_code` turn.
23
+ * @param ctx - host context carrying the system-prompt registry and tool waterfall.
24
+ */
25
+ export declare function apply(ctx: Context): void;
26
+ //# sourceMappingURL=index.d.ts.map