@whybebabo/dsh-file-review-tab 0.0.0-stage → 0.7.1
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 +22 -0
- package/README.md +134 -2
- package/cordis.patch.yml +6 -0
- package/lib/client.js +8386 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +373 -0
- package/lib/remote.js +8 -0
- package/lib/typert-descriptors.js +136 -0
- package/lib/typert.host.js +22 -0
- package/lib/types/change-types.d.ts +117 -0
- package/lib/types/client/FileReviewTab.d.ts +20 -0
- package/lib/types/client/NativeDiff.d.ts +52 -0
- package/lib/types/client/ProducedFiles.d.ts +40 -0
- package/lib/types/client/chat-locales.d.ts +66 -0
- package/lib/types/client/deep-link.d.ts +83 -0
- package/lib/types/client/deleted-paths.d.ts +28 -0
- package/lib/types/client/diff-hunks.d.ts +86 -0
- package/lib/types/client/diff-text.d.ts +8 -0
- package/lib/types/client/index.d.ts +43 -0
- package/lib/types/client/locales.d.ts +79 -0
- package/lib/types/client/mutation-call.d.ts +34 -0
- package/lib/types/client/recorded-diffs.d.ts +10 -0
- package/lib/types/client/recorded-fetch.d.ts +30 -0
- package/lib/types/client/session-changes.d.ts +110 -0
- package/lib/types/client/snapshot-compat.d.ts +32 -0
- package/lib/types/client/turn-deliverables.d.ts +91 -0
- package/lib/types/file-review-service.d.ts +22 -0
- package/lib/types/index.d.ts +26 -0
- package/lib/types/mutation-order.d.ts +111 -0
- package/lib/types/remote.d.ts +26 -0
- package/lib/types/typert-descriptors.d.ts +13 -0
- package/lib/types/typert.host.d.ts +5 -0
- package/package.json +141 -6
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
* Event sequence the pending deletion happened at. A deletion is an event, so
|
|
24
|
+
* a cross-channel write with a LATER sequence proves the path was recreated
|
|
25
|
+
* and clears the flag. Absent when the snapshot omitted the sequence, in which
|
|
26
|
+
* case the deletion is kept (the conservative reading).
|
|
27
|
+
*/
|
|
28
|
+
readonly deletedSeq?: number | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** One turn's produced files, in first-seen order. */
|
|
31
|
+
export interface TurnFileChanges {
|
|
32
|
+
readonly turn: number;
|
|
33
|
+
/** Whether the owning turn is still running (its change set may grow). */
|
|
34
|
+
readonly live: boolean;
|
|
35
|
+
readonly files: readonly SessionFileChange[];
|
|
36
|
+
}
|
|
37
|
+
/** Derive per-turn produced-file changes for one session snapshot. */
|
|
38
|
+
export declare function deriveSessionChanges(snapshot: ConversationSnapshot | null): TurnFileChanges[];
|
|
39
|
+
/**
|
|
40
|
+
* One Code Mode (`run_code`) root visible in the snapshot, with the turn it
|
|
41
|
+
* settles into. The snapshot now carries settled `subCalls` with their own
|
|
42
|
+
* call heads and result metadata, so those are the primary source; this root
|
|
43
|
+
* list only feeds the Host recorder fallback for roots whose nested facts did
|
|
44
|
+
* not survive into the snapshot.
|
|
45
|
+
*/
|
|
46
|
+
export interface SessionRoot {
|
|
47
|
+
readonly turn: number;
|
|
48
|
+
readonly live: boolean;
|
|
49
|
+
readonly rootCallId: string;
|
|
50
|
+
/**
|
|
51
|
+
* The root node's event sequence, or undefined when the snapshot omitted it.
|
|
52
|
+
* A recorded mutation is a nested dispatch of this root, so this is the
|
|
53
|
+
* sequence its changes are ordered by — it is what lets a `run_code` edit be
|
|
54
|
+
* merged into the right position among the turn's model-direct edits. When it
|
|
55
|
+
* is unknown the merge keeps array order rather than guessing.
|
|
56
|
+
*/
|
|
57
|
+
readonly seq: number | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* How many nested dispatches of this root have SETTLED so far.
|
|
60
|
+
*
|
|
61
|
+
* The Host recorder keeps appending mutations under the SAME `rootCallId`
|
|
62
|
+
* while a long `run_code` runs, so a call-id-only dependency would never
|
|
63
|
+
* re-arm the client's `recorded` fetch: the tab would show only the mutations
|
|
64
|
+
* that landed before its first fetch. A nested dispatch settles exactly when
|
|
65
|
+
* the recorder sees it, so this count grows with the recorded data and gives
|
|
66
|
+
* the fetch a dependency that tracks it.
|
|
67
|
+
*/
|
|
68
|
+
readonly progress: number;
|
|
69
|
+
}
|
|
70
|
+
/** Every `run_code` tool-result node whose nested changes are not in the snapshot. */
|
|
71
|
+
export declare function deriveSessionRoots(snapshot: ConversationSnapshot): SessionRoot[];
|
|
72
|
+
/**
|
|
73
|
+
* Merge Host-recorded Code Mode mutations into the snapshot-derived turns:
|
|
74
|
+
* hunks rebuilt from the full before/after are inserted into the owning turn's
|
|
75
|
+
* file groups at the position their EVENT SEQUENCE puts them (same-path entries
|
|
76
|
+
* stay one row), so the tab's diff rendering, status inspection and undo all
|
|
77
|
+
* work on programmatic edits exactly like model-direct ones.
|
|
78
|
+
*
|
|
79
|
+
* Ordering is by sequence rather than "snapshot first, recorded after": the two
|
|
80
|
+
* sources are separate channels merged asynchronously, so appending recorded
|
|
81
|
+
* mutations could invert them. A `run_code` insert at the top of a file followed
|
|
82
|
+
* by a model-direct edit near its end must replay in that order — reversed, the
|
|
83
|
+
* rear edit's line anchors describe text the front insert already shifted, and
|
|
84
|
+
* BOTH undo and redo fail on a file that was perfectly reviewable.
|
|
85
|
+
*
|
|
86
|
+
* All inputs are immutable; the result is a fresh array only when a recorded
|
|
87
|
+
* mutation matched a visible root.
|
|
88
|
+
*/
|
|
89
|
+
export declare function mergeRecordedTurns(turns: readonly TurnFileChanges[], roots: readonly SessionRoot[], recorded: readonly RecordedMutation[]): readonly TurnFileChanges[];
|
|
90
|
+
/** Count distinct changed paths across every turn (the sidebar badge count). */
|
|
91
|
+
export declare function countChangedFiles(turns: readonly TurnFileChanges[]): number;
|
|
92
|
+
/**
|
|
93
|
+
* Turns that stay in the review tab's MAIN list: the newest
|
|
94
|
+
* {@link ARCHIVE_KEEP_TURNS} turns plus every live (still-running) turn.
|
|
95
|
+
* Older completed turns auto-archive to the tab's bottom section (issue #5:
|
|
96
|
+
* long sessions accumulate dozens of diff groups and weigh the page down).
|
|
97
|
+
*/
|
|
98
|
+
export declare const ARCHIVE_KEEP_TURNS = 5;
|
|
99
|
+
/** Archived turns render this many groups per loaded page once the section opens. */
|
|
100
|
+
export declare const ARCHIVE_PAGE_TURNS = 10;
|
|
101
|
+
/** Split turns into the main list and the auto-archived tail (both newest-first). */
|
|
102
|
+
export declare function splitArchivedTurns(turns: readonly TurnFileChanges[], keep?: number): {
|
|
103
|
+
main: readonly TurnFileChanges[];
|
|
104
|
+
archived: readonly TurnFileChanges[];
|
|
105
|
+
};
|
|
106
|
+
/** Trailing path segment, the part that identifies the file at a glance. */
|
|
107
|
+
export declare function basename(path: string): string;
|
|
108
|
+
/** Resolve a (possibly relative) tool path against the session cwd. */
|
|
109
|
+
export declare function resolveSessionPath(cwd: string | undefined, path: string): string;
|
|
110
|
+
//# 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
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutation grouping: the coordinate space each recorded hunk is anchored in.
|
|
3
|
+
*
|
|
4
|
+
* One file is often mutated several times in a single turn (`edit`, then
|
|
5
|
+
* `write`, then a Code Mode dispatch), and the review surfaces concatenate every
|
|
6
|
+
* mutation's hunks into ONE list per path. Those hunks do NOT share a coordinate
|
|
7
|
+
* space: mutation 1's `oldStart` is a line number in the text as it existed
|
|
8
|
+
* before mutation 1, mutation 2's is a line number in the text mutation 1 left
|
|
9
|
+
* behind, and so on. Replaying them as one flat list therefore applies hunks
|
|
10
|
+
* against coordinates that no longer exist.
|
|
11
|
+
*
|
|
12
|
+
* A group is the set of hunks one settlement produced (one tool result's
|
|
13
|
+
* `meta.diffs`, or one Code Mode `before`/`after` pair). Two rules follow:
|
|
14
|
+
*
|
|
15
|
+
* - settlements replay in settlement order going forward (redo) and in reverse
|
|
16
|
+
* order going back (undo), because each one is anchored in the text the
|
|
17
|
+
* previous one produced;
|
|
18
|
+
* - inside ONE settlement the hunks are anchored in the same text, so a hunk
|
|
19
|
+
* that changes the line count shifts every anchor still waiting behind it —
|
|
20
|
+
* they must be applied back-to-front.
|
|
21
|
+
*
|
|
22
|
+
* `mutation` is optional so a payload produced before this field existed
|
|
23
|
+
* degrades to a single group, which for the overwhelmingly common
|
|
24
|
+
* one-mutation payload is exactly the correct answer.
|
|
25
|
+
*/
|
|
26
|
+
import type { ProducedFileDiff } from './change-types.ts';
|
|
27
|
+
/**
|
|
28
|
+
* Append one settlement's hunks, stamping them with the coordinate space they
|
|
29
|
+
* were recorded in and the event sequence that orders them.
|
|
30
|
+
*
|
|
31
|
+
* The stamp is the accumulator's current length, which is strictly increasing
|
|
32
|
+
* per path, so two settlements can never share one — that uniqueness is what
|
|
33
|
+
* lets {@link mutationGroups} split a path's hunks back into settlements.
|
|
34
|
+
*
|
|
35
|
+
* `seq` is the ordering key: the conversation node's sequence for a
|
|
36
|
+
* snapshot-derived settlement, or the owning `run_code` root's sequence for a
|
|
37
|
+
* Host-recorded one. It is recorded separately from `mutation` because the two
|
|
38
|
+
* answer different questions — a chain of nested dispatches produces several
|
|
39
|
+
* distinct settlements that all share one node sequence.
|
|
40
|
+
*
|
|
41
|
+
* @param target - The path's accumulated hunks, mutated in place.
|
|
42
|
+
* @param diffs - One settlement's hunks, all anchored in the same text.
|
|
43
|
+
* @param seq - Event sequence that orders this settlement, when known.
|
|
44
|
+
*/
|
|
45
|
+
export declare function appendMutation(target: ProducedFileDiff[], diffs: readonly ProducedFileDiff[], seq?: number | undefined): void;
|
|
46
|
+
/**
|
|
47
|
+
* Order settlements by their recorded event sequence, so undo/redo walk the
|
|
48
|
+
* file's history in the order it actually happened.
|
|
49
|
+
*
|
|
50
|
+
* This is what keeps a `run_code` mutation and a model-direct edit to the same
|
|
51
|
+
* file from being applied out of order: the two arrive through different
|
|
52
|
+
* channels (the conversation snapshot vs. the Host recorder) and are merged
|
|
53
|
+
* asynchronously, so the array order is a merge artifact rather than history.
|
|
54
|
+
*
|
|
55
|
+
* Only when EVERY entry carries a sequence is the order provable. A partially
|
|
56
|
+
* stamped list keeps its incoming order, which is the conservative choice —
|
|
57
|
+
* guessing at the position of an unstamped settlement could silently corrupt a
|
|
58
|
+
* file. The sort is stable, so entries sharing one sequence (a single
|
|
59
|
+
* `run_code` root's nested dispatch chain) keep their dispatch order.
|
|
60
|
+
*
|
|
61
|
+
* @param entries - Settlements or events carrying an optional `seq`.
|
|
62
|
+
* @returns A new array in ascending event order, or the same order when unprovable.
|
|
63
|
+
*/
|
|
64
|
+
export declare function orderBySequence<T extends {
|
|
65
|
+
readonly seq: number | undefined;
|
|
66
|
+
}>(entries: readonly T[]): T[];
|
|
67
|
+
/** One settlement recovered from a path's accumulated hunks. */
|
|
68
|
+
export interface Settlement {
|
|
69
|
+
readonly seq: number | undefined;
|
|
70
|
+
readonly diffs: readonly ProducedFileDiff[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Recover the settlements one path's flat hunk list was built from.
|
|
74
|
+
* @param diffs - One path's accumulated hunks.
|
|
75
|
+
* @returns One entry per coordinate space, in the order they were appended.
|
|
76
|
+
*/
|
|
77
|
+
export declare function settlementsOf(diffs: readonly ProducedFileDiff[]): Settlement[];
|
|
78
|
+
/**
|
|
79
|
+
* Re-stamp a settlement list back into one flat hunk list, in event order.
|
|
80
|
+
*
|
|
81
|
+
* Stamps are reassigned rather than preserved because they encode POSITION
|
|
82
|
+
* (`mutation` is the append offset), and reordering invalidates the old values;
|
|
83
|
+
* leaving them stale would make {@link mutationGroups} split the same
|
|
84
|
+
* coordinate space into several groups.
|
|
85
|
+
*
|
|
86
|
+
* @param settlements - Settlements, in any order.
|
|
87
|
+
* @returns The flat hunk list, ordered by `seq` with fresh stamps.
|
|
88
|
+
*/
|
|
89
|
+
export declare function flattenSettlements(settlements: readonly Settlement[]): ProducedFileDiff[];
|
|
90
|
+
/**
|
|
91
|
+
* Split one path's hunks into contiguous same-coordinate groups, in settlement
|
|
92
|
+
* order. Hunks that carry no `mutation` form a single group.
|
|
93
|
+
* @param diffs - One path's accumulated hunks, in settlement order.
|
|
94
|
+
* @returns The groups, in settlement order.
|
|
95
|
+
*/
|
|
96
|
+
export declare function mutationGroups(diffs: readonly ProducedFileDiff[]): readonly (readonly ProducedFileDiff[])[];
|
|
97
|
+
/**
|
|
98
|
+
* The order one settlement's hunks must be applied in: back-to-front by the
|
|
99
|
+
* anchor of the direction being applied, because a hunk that changes the line
|
|
100
|
+
* count would otherwise shift the anchors of the hunks behind it. This is what
|
|
101
|
+
* makes a multi-hunk redo land on the coordinates the hunks recorded instead of
|
|
102
|
+
* the ones left over after the first hunk moved them.
|
|
103
|
+
*
|
|
104
|
+
* Hunks without a line anchor are content-matched and so coordinate-free; they
|
|
105
|
+
* sort after the anchored ones, where they cannot invalidate a pending anchor.
|
|
106
|
+
* @param group - One settlement's hunks.
|
|
107
|
+
* @param action - Direction being applied.
|
|
108
|
+
* @returns The hunks in application order (descending anchor).
|
|
109
|
+
*/
|
|
110
|
+
export declare function hunksForApply(group: readonly ProducedFileDiff[], action: 'undo' | 'redo'): readonly ProducedFileDiff[];
|
|
111
|
+
//# sourceMappingURL=mutation-order.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Browser Typert contribution for the Host file-review service. */
|
|
2
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
3
|
+
import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
|
|
4
|
+
import type { FileReviewRequest, FileReviewResult, RecordedRequest, RecordedResult } from './change-types.ts';
|
|
5
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
6
|
+
interface TypertRemoteNamespaceMap {
|
|
7
|
+
fileReview: {
|
|
8
|
+
status: (agentId: SessionId, request: FileReviewRequest) => Promise<RemoteResult<FileReviewResult>>;
|
|
9
|
+
apply: (agentId: SessionId, request: FileReviewRequest) => Promise<RemoteResult<FileReviewResult>>;
|
|
10
|
+
recorded: (agentId: SessionId, request: RecordedRequest) => Promise<RemoteResult<RecordedResult>>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface TypertRemoteMap {
|
|
14
|
+
'fileReview/status': (agentId: SessionId, request: FileReviewRequest) => Promise<RemoteResult<FileReviewResult>>;
|
|
15
|
+
'fileReview/apply': (agentId: SessionId, request: FileReviewRequest) => Promise<RemoteResult<FileReviewResult>>;
|
|
16
|
+
'fileReview/recorded': (agentId: SessionId, request: RecordedRequest) => Promise<RemoteResult<RecordedResult>>;
|
|
17
|
+
}
|
|
18
|
+
interface TypertRemoteScopeMap {
|
|
19
|
+
'agent:fileReview/status': (request: FileReviewRequest) => Promise<RemoteResult<FileReviewResult>>;
|
|
20
|
+
'agent:fileReview/apply': (request: FileReviewRequest) => Promise<RemoteResult<FileReviewResult>>;
|
|
21
|
+
'agent:fileReview/recorded': (request: RecordedRequest) => Promise<RemoteResult<RecordedResult>>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const TYPERT_REMOTE: TypertRemoteContribution;
|
|
25
|
+
export default TYPERT_REMOTE;
|
|
26
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Strict Typert codecs shared by the Host and browser contribution artifacts. */
|
|
2
|
+
import type { InvocationDescriptor } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
|
+
/**
|
|
4
|
+
* This package's npm name, which the Typert host face is keyed by.
|
|
5
|
+
*
|
|
6
|
+
* `typert-loader` rejects a host manifest whose `package` differs from the
|
|
7
|
+
* package that exports it ("the manifest must be owned by the package that
|
|
8
|
+
* exports it"), and the registry rejects a duplicate `package` registration —
|
|
9
|
+
* so this string has to be the real published name, not a display label.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PACKAGE_NAME = "@whybebabo/dsh-file-review-tab";
|
|
12
|
+
export declare const FILE_REVIEW_INVOCATIONS: readonly InvocationDescriptor[];
|
|
13
|
+
//# sourceMappingURL=typert-descriptors.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Host Typert contribution discovered through the package's `./typert` export. */
|
|
2
|
+
import type { TypertContribution } from '@deepseek-ai/dsh-typert-registry/types';
|
|
3
|
+
export declare const TYPERT: TypertContribution;
|
|
4
|
+
export default TYPERT;
|
|
5
|
+
//# sourceMappingURL=typert.host.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,141 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@whybebabo/dsh-file-review-tab",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@whybebabo/dsh-file-review-tab",
|
|
3
|
+
"description": "Review agent-produced file changes (line-level red/green diff + undo) both as a chat turn-tail row and as a dsh-better-sidebar tab; a port of left0ver's dsh-file-review.",
|
|
4
|
+
"version": "0.7.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"deepseek-harness",
|
|
10
|
+
"dsh-plugin",
|
|
11
|
+
"diff",
|
|
12
|
+
"code-review",
|
|
13
|
+
"sidebar"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/whybebabo/dsh-file-review-tab.git"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "lib/index.js",
|
|
22
|
+
"types": "lib/types/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./lib/types/index.d.ts",
|
|
26
|
+
"default": "./lib/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./client": {
|
|
29
|
+
"types": "./lib/types/client/index.d.ts",
|
|
30
|
+
"default": "./lib/client.js"
|
|
31
|
+
},
|
|
32
|
+
"./typert": {
|
|
33
|
+
"types": "./lib/types/typert.host.d.ts",
|
|
34
|
+
"default": "./lib/typert.host.js"
|
|
35
|
+
},
|
|
36
|
+
"./remote": {
|
|
37
|
+
"types": "./lib/types/remote.d.ts",
|
|
38
|
+
"default": "./lib/remote.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"lib/index.js",
|
|
44
|
+
"lib/client.js",
|
|
45
|
+
"lib/client.js.map",
|
|
46
|
+
"lib/typert.host.js",
|
|
47
|
+
"lib/remote.js",
|
|
48
|
+
"lib/typert-descriptors.js",
|
|
49
|
+
"lib/types/**/*.d.ts",
|
|
50
|
+
"cordis.patch.yml",
|
|
51
|
+
"README.md"
|
|
52
|
+
],
|
|
53
|
+
"dsh": {
|
|
54
|
+
"bundle": {
|
|
55
|
+
"patch": "./cordis.patch.yml"
|
|
56
|
+
},
|
|
57
|
+
"client": {
|
|
58
|
+
"inject": [
|
|
59
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
60
|
+
"@deepseek-ai/dsh-api-session-controller",
|
|
61
|
+
"@deepseek-ai/dsh-client-locale",
|
|
62
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
63
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
64
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
65
|
+
"dsh-better-sidebar"
|
|
66
|
+
],
|
|
67
|
+
"external": [
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-primitives"
|
|
69
|
+
],
|
|
70
|
+
"platform": "web"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build:types": "tsc --emitDeclarationOnly --outDir lib/types",
|
|
75
|
+
"build": "npm run build:types && tsdown",
|
|
76
|
+
"typecheck": "tsc --noEmit",
|
|
77
|
+
"pretest": "npm run build",
|
|
78
|
+
"test": "node test/typert-descriptors.mjs && node test/slot-registration.mjs && node test/host-apply.mjs && node test/undo-redo.mjs && node test/interleaved-mutations.mjs && node test/review-invalidation.mjs && node test/deep-link.mjs && node test/diff-hunks.mjs && node test/mutation-order.mjs && node test/deleted-paths.mjs && node test/client-bundle.mjs && node test/card-render.mjs && node test/tab-render.mjs && node test/diff-render.mjs"
|
|
79
|
+
},
|
|
80
|
+
"pnpm": {
|
|
81
|
+
"ignoredBuiltDependencies": [
|
|
82
|
+
"node-pty"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"diff": "^9.0.0",
|
|
87
|
+
"zod": "^4.4.3"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
91
|
+
"@deepseek-ai/dsh-agent": "^0.2.0-rc.2",
|
|
92
|
+
"@deepseek-ai/dsh-api-remotes": "^0.2.0-rc.2",
|
|
93
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.2.0-rc.2",
|
|
94
|
+
"@deepseek-ai/dsh-atomic-write": "^0.2.0-rc.2",
|
|
95
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.0-rc.2",
|
|
96
|
+
"@deepseek-ai/dsh-client-ui-chat": "^0.2.0-rc.2",
|
|
97
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.0-rc.2",
|
|
98
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.0-rc.2",
|
|
99
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.0-rc.2",
|
|
100
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.0-rc.2",
|
|
101
|
+
"@deepseek-ai/dsh-session": "^0.2.0-rc.2",
|
|
102
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.2",
|
|
103
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.0-rc.2",
|
|
104
|
+
"@deepseek-ai/dsh-typert-registry": "^0.2.0-rc.2",
|
|
105
|
+
"dsh-better-sidebar": ">=0.19.1",
|
|
106
|
+
"react": "^18.2.0"
|
|
107
|
+
},
|
|
108
|
+
"peerDependenciesMeta": {
|
|
109
|
+
"dsh-better-sidebar": {
|
|
110
|
+
"optional": true
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"devDependencies": {
|
|
114
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
115
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
116
|
+
"@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
|
|
117
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
|
|
118
|
+
"@deepseek-ai/dsh-api-session-controller": "0.2.0-rc.2",
|
|
119
|
+
"@deepseek-ai/dsh-atomic-write": "0.2.0-rc.2",
|
|
120
|
+
"@deepseek-ai/dsh-client-locale": "0.2.0-rc.2",
|
|
121
|
+
"@deepseek-ai/dsh-client-store": "0.2.0-rc.2",
|
|
122
|
+
"@deepseek-ai/dsh-client-ui-chat": "0.2.0-rc.2",
|
|
123
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.0-rc.2",
|
|
124
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.2",
|
|
125
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
|
|
126
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
|
|
127
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
128
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
129
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
|
|
130
|
+
"@deepseek-ai/dsh-typert-registry": "0.2.0-rc.2",
|
|
131
|
+
"@types/node": "^24.0.0",
|
|
132
|
+
"@types/react": "~18.3.1",
|
|
133
|
+
"@types/react-dom": "~18.3.0",
|
|
134
|
+
"dsh-better-sidebar": "0.24.1",
|
|
135
|
+
"lightningcss": "^1.32.0",
|
|
136
|
+
"react": "^18.2.0",
|
|
137
|
+
"react-dom": "^18.2.0",
|
|
138
|
+
"tsdown": "^0.22.14",
|
|
139
|
+
"typescript": "^5.9.0"
|
|
140
|
+
}
|
|
141
|
+
}
|