@chatcode/chatcode-cli 3.0.4 → 3.0.5-rc.2

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.
Files changed (148) hide show
  1. package/README.i18n.yaml +6 -6
  2. package/README.md +10 -4
  3. package/README.zh.md +10 -4
  4. package/lib/bin.js +23 -9
  5. package/lib/{command-errors-Ca64Lgba.js → command-errors-CsRCh0gk.js} +12 -12
  6. package/lib/{command-trees-CVc4Xu_z.js → command-trees-CD_43rxX.js} +2 -2
  7. package/lib/{component-identity-6aEut5Yt.js → component-identity-DGA2-TeB.js} +3 -3
  8. package/lib/{dump-config-ZzrfvtnX.js → dump-config-D8kXfdTs.js} +1 -1
  9. package/lib/dump-config-DuCc-QB7.js +2 -0
  10. package/lib/{dump-config-schema-BlO-eZ-J.js → dump-config-schema-CtZbroi6.js} +2 -2
  11. package/lib/{extension-events-C7MUpqVE.js → extension-events-D0BjYRqT.js} +21 -21
  12. package/lib/{host-access-CLbyAGT5.js → host-access-DLJjuR07.js} +1 -1
  13. package/lib/{keymap-82JwLLHe.js → keymap-C4cs2IBN.js} +2 -2
  14. package/lib/{plugin-BlQlWIR5.js → plugin-CGtTByud.js} +801 -456
  15. package/lib/{plugin-BZdazFXS.js → plugin-CYw-MBRn.js} +1 -1
  16. package/lib/{profile-boot-B0aEEQIR.js → profile-boot-CffsubnV.js} +7 -7
  17. package/lib/profile-boot.js +1 -1
  18. package/lib/{scenes-BNS0ZFyQ.js → scenes-CbAGK5Uy.js} +3 -3
  19. package/lib/{settings-sections-CXH24cu5.js → settings-sections-DYKDa04e.js} +3 -3
  20. package/lib/{statusBarSettings-BAMzn8fX.js → statusBarSettings-T1m8xad4.js} +3 -3
  21. package/lib/{themes-DXUIvP7m.js → themes-BY2ui1Dv.js} +12 -12
  22. package/lib/tui-compat-command-trees.js +1 -1
  23. package/lib/tui-compat-extensions.js +3 -3
  24. package/lib/tui-compat-plugin-host.js +5 -5
  25. package/lib/tui-compat-scenes.js +1 -1
  26. package/lib/tui-compat-settings-sections.js +1 -1
  27. package/lib/tui-compat-working-activity.js +1 -1
  28. package/lib/tui-compat-workspaces.js +1 -1
  29. package/lib/tui-compat.js +7 -7
  30. package/lib/types/bin.d.ts +9 -0
  31. package/lib/types/tui-compat.d.ts +1 -1
  32. package/lib/types/web-instance-process.d.ts +20 -0
  33. package/lib/{web-instance-DbP7IHPv.js → web-instance-D_Ppi2Zo.js} +176 -14
  34. package/lib/{web-instance-B0jec7cq.js → web-instance-amvCJWnq.js} +1 -1
  35. package/lib/{workspaces-CUJXNU5W.js → workspaces-D5VKbESy.js} +2 -2
  36. package/package.json +30 -31
  37. package/runtime/manifest.json +2 -2
  38. package/runtime/node_modules/@deepseek-ai/dsh-agent-default-model/lib/index.js +7 -3
  39. package/runtime/node_modules/@deepseek-ai/dsh-agent-instructions/lib/index.js +169 -11
  40. package/runtime/node_modules/@deepseek-ai/dsh-agent-instructions/lib/types/files.d.ts +25 -0
  41. package/runtime/node_modules/@deepseek-ai/dsh-agent-instructions/lib/types/rules.d.ts +25 -0
  42. package/runtime/node_modules/@deepseek-ai/dsh-agent-instructions/package.json +5 -2
  43. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +11 -3
  44. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/client/contract/snapshot.d.ts +1 -0
  45. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/client/sessions/assistant-stream.d.ts +2 -0
  46. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/client/sessions/assistant-stream.js +4 -0
  47. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/client/sessions/session.js +10 -3
  48. package/runtime/node_modules/@deepseek-ai/dsh-app-boot/lib/index.js +32 -11
  49. package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/index.js +62 -11
  50. package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/types/darwin-lock.d.ts +7 -0
  51. package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/types/index.d.ts +7 -2
  52. package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/types/linux-lock.d.ts +1 -1
  53. package/runtime/node_modules/@deepseek-ai/dsh-client-locale/lib/client.js +7 -7
  54. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-agent-preset/lib/client.js +62 -62
  55. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-approval/lib/client.js +10 -10
  56. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-attachment/lib/client.js +49 -49
  57. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-chat/lib/client.js +204 -204
  58. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-commands/lib/client.js +16 -16
  59. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/client.js +159 -157
  60. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/types/client/service.d.ts +4 -2
  61. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-cordis/lib/client.js +74 -74
  62. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/client.js +129 -123
  63. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/index.js +19 -14
  64. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/types/changes.d.ts +2 -2
  65. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/types/client/Deliverables.d.ts +1 -2
  66. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/types/client/locales.d.ts +2 -1
  67. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/types/client/present-open.d.ts +1 -1
  68. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/package.json +2 -4
  69. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-browse/lib/client.js +39 -39
  70. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-goal/lib/client.js +16 -16
  71. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-input-trigger/lib/client.js +23 -23
  72. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-jobs/lib/client.js +37 -37
  73. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-layout/lib/client.js +9 -9
  74. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-message-feedback/lib/client.js +12 -12
  75. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/client.js +119 -32
  76. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/types/client/catalog.d.ts +13 -0
  77. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/types/client/directory.d.ts +2 -0
  78. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/types/client/effort-preferences.d.ts +20 -0
  79. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/types/client/slots.d.ts +2 -1
  80. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-open-in-app/lib/client.js +8 -8
  81. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-permission-presets/lib/client.js +18 -18
  82. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-plan/lib/client.js +22 -22
  83. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-plugin-manager/lib/client.js +128 -128
  84. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-schedule/lib/client.js +182 -182
  85. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +130 -130
  86. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +50 -50
  87. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-models/lib/client.js +88 -88
  88. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/lib/client.js +36 -36
  89. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-plugins/lib/client.js +13 -13
  90. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-subagent/lib/client.js +27 -27
  91. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-shortcuts/lib/client.js +42 -42
  92. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +44 -44
  93. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-browser/lib/client.js +25 -25
  94. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/lib/client.excel.js +9 -9
  95. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/lib/client.js +70 -70
  96. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/lib/client.pdf.js +9 -9
  97. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-files/lib/client.js +18 -18
  98. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-right/lib/client.js +26 -26
  99. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-terminal/lib/client.js +16 -16
  100. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar-terminal/lib/client.terminal.js +11 -11
  101. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-skill/lib/client.js +20 -20
  102. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-subagent/lib/client.js +37 -37
  103. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-theme/lib/client.js +27 -27
  104. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-tool/lib/client.js +95 -95
  105. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-trajectory/lib/client.js +197 -197
  106. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-user-questions/lib/client.js +49 -49
  107. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workflow-run/lib/client.js +24 -24
  108. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/client.js +656 -152
  109. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/ArchivedSessions.d.ts +9 -2
  110. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/locales.d.ts +46 -0
  111. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/session-actions/DeleteSession.d.ts +9 -10
  112. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/session-actions/deletion.d.ts +57 -0
  113. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/package.json +2 -0
  114. package/runtime/node_modules/@deepseek-ai/dsh-experimental-client-ui-agent-team/lib/client.js +32 -32
  115. package/runtime/node_modules/@deepseek-ai/dsh-experimental-client-ui-voice-input/lib/client.js +24 -24
  116. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js +899 -453
  117. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/adapter.d.ts +4 -20
  118. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/chat-completions/adapter.d.ts +8 -0
  119. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/chat-completions/serialize.d.ts +10 -0
  120. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/chat-completions/sse.d.ts +24 -0
  121. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/chat-completions/translate.d.ts +37 -0
  122. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/chat-completions/types.d.ts +159 -0
  123. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/file-store.d.ts +3 -0
  124. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/files-api.d.ts +4 -0
  125. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/index.d.ts +1 -0
  126. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/protocol-adapter.d.ts +41 -0
  127. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/protocol.d.ts +35 -0
  128. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/transport.d.ts +2 -1
  129. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/types.d.ts +2 -2
  130. package/runtime/node_modules/@deepseek-ai/dsh-mcp-client/lib/index.js +5 -4
  131. package/runtime/node_modules/@deepseek-ai/dsh-session-log-export/lib/client.js +4 -4
  132. package/runtime/node_modules/@deepseek-ai/dsh-session-log-export/lib/index.js +1 -1
  133. package/runtime/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/index.js +2 -2
  134. package/runtime/node_modules/@deepseek-ai/dsh-skill-filesystem/lib/index.js +33 -9
  135. package/runtime/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +12 -10
  136. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/index.js +208 -39
  137. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/archive.d.ts +47 -0
  138. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/archive.js +129 -0
  139. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/index.d.ts +2 -0
  140. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/index.js +31 -8
  141. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/recorder.d.ts +7 -2
  142. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/recorder.js +35 -19
  143. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/types.d.ts +11 -10
  144. package/runtime/node_modules/@deepseek-ai/dsh-workspace-changes/package.json +1 -0
  145. package/scripts/link-embedded-runtime.mjs +1 -1
  146. package/lib/dump-config-CDixiJNt.js +0 -2
  147. package/lib/{home-migration-BjDmRwBB.js → home-migration-lRjtl2fP.js} +1 -1
  148. package/lib/{startup-diagnostics-C_hRCp-q.js → startup-diagnostics-4mLHYTFc.js} +1 -1
@@ -5,11 +5,14 @@
5
5
  * listed file's before-and-after comparison on demand. Each summary is
6
6
  * announced by a `workspace/changes` Session event that carries only the turn
7
7
  * number; summaries and comparisons are served through the `workspaceChanges`
8
- * service until the Session is disposed. Outside a git repository, or without
9
- * git, the summary lists file-tool edits only.
8
+ * service across Host restarts until the Session is permanently deleted.
9
+ * Outside a git repository, or without git, the summary lists file-tool edits only.
10
10
  */
11
11
  import { homedir, tmpdir } from 'node:os';
12
+ import { isAbsolute } from 'node:path';
12
13
  import z from '@deepseek-ai/schemastery';
14
+ import { chatCodeCliHomePath } from '@deepseek-ai/dsh-home-paths';
15
+ import { ChangesArchive } from "./archive.js";
13
16
  import { GitRunner } from "./git.js";
14
17
  import { TurnRecorder } from "./recorder.js";
15
18
  /** Stable Loader identity. */
@@ -18,6 +21,7 @@ export const name = 'workspace-changes';
18
21
  export const inject = ['subprocess'];
19
22
  /** Schemastery validation for {@link Config}. */
20
23
  export const Config = z.object({
24
+ directory: z.string().default(chatCodeCliHomePath('workspace-changes')),
21
25
  timeoutMs: z.number().default(30_000),
22
26
  outputMaxBytes: z.number().default(8 * 1024 * 1024),
23
27
  maxFiles: z.number().default(500),
@@ -61,6 +65,8 @@ async function resolveGit(ctx, signal) {
61
65
  * @param config - validated bounds.
62
66
  */
63
67
  export function apply(ctx, config) {
68
+ if (!isAbsolute(config.directory))
69
+ throw new Error('workspace-changes requires an absolute directory');
64
70
  for (const [field, value] of [
65
71
  ['timeoutMs', config.timeoutMs], ['outputMaxBytes', config.outputMaxBytes], ['maxFiles', config.maxFiles],
66
72
  ['maxFileBytes', config.maxFileBytes], ['diffTimeoutMs', config.diffTimeoutMs],
@@ -69,21 +75,28 @@ export function apply(ctx, config) {
69
75
  throw new Error(`workspace-changes requires a positive integer ${field}`);
70
76
  }
71
77
  const lifetime = new AbortController();
78
+ const archive = new ChangesArchive(config.directory);
72
79
  const recorders = new Map();
73
80
  const byId = new Map();
81
+ const retiring = new Set();
74
82
  const forget = (session) => {
75
83
  const recorder = recorders.get(session);
76
84
  recorders.delete(session);
77
85
  byId.delete(session.id);
78
- return recorder?.dispose() ?? Promise.resolve();
86
+ if (recorder === undefined)
87
+ return Promise.resolve();
88
+ const disposal = recorder.dispose();
89
+ retiring.add(disposal);
90
+ void disposal.then(() => retiring.delete(disposal), () => retiring.delete(disposal));
91
+ return disposal;
79
92
  };
80
93
  ctx.effect(() => async () => {
81
94
  lifetime.abort();
82
- await Promise.all([...recorders.keys()].map(forget));
95
+ await Promise.all([...recorders.keys()].map(forget).concat([...retiring]));
83
96
  });
84
97
  const service = {
85
- summary: (sessionId, seq) => byId.get(sessionId)?.summary(seq),
86
- diff: (sessionId, seq, index, signal) => byId.get(sessionId)?.diff(seq, index, signal) ?? Promise.resolve(undefined),
98
+ summary: async (sessionId, seq) => byId.get(sessionId)?.summary(seq) ?? archive.summary(sessionId, seq),
99
+ diff: async (sessionId, seq, index, signal) => await archive.diff(sessionId, seq, index, signal) ?? byId.get(sessionId)?.diff(seq, index, signal),
87
100
  };
88
101
  ctx.provide('workspaceChanges', service);
89
102
  let runner;
@@ -101,7 +114,7 @@ export function apply(ctx, config) {
101
114
  let recorder = recorders.get(session);
102
115
  if (recorder === undefined) {
103
116
  recorder = new TurnRecorder(session, cwd, {
104
- git: gitRunner(), tempRoot: tmpdir(), maxFiles: config.maxFiles,
117
+ archive, git: gitRunner(), tempRoot: tmpdir(), maxFiles: config.maxFiles,
105
118
  maxFileBytes: config.maxFileBytes, diffTimeoutMs: config.diffTimeoutMs,
106
119
  warn: (message) => { ctx.logger.warn(message); },
107
120
  });
@@ -122,7 +135,17 @@ export function apply(ctx, config) {
122
135
  else if (event.type === 'turn/end')
123
136
  recorders.get(session)?.end(event.data.turn);
124
137
  });
125
- ctx.on('session/disposed', (session) => { void forget(session); });
138
+ ctx.on('session/disposed', (session) => {
139
+ void forget(session).catch((error) => { ctx.logger.warn(`workspace-changes: ${String(error)}`); });
140
+ });
141
+ ctx.on('session/deleting', async ({ sessionIds }) => {
142
+ for (const sessionId of sessionIds) {
143
+ const session = [...recorders.keys()].find(candidate => candidate.id === sessionId);
144
+ if (session !== undefined)
145
+ await forget(session);
146
+ await archive.remove(sessionId);
147
+ }
148
+ });
126
149
  ctx.on('agent/turn-stopping', async ({ agent, turn }) => {
127
150
  await recorders.get(agent.session)?.stopping(turn);
128
151
  });
@@ -1,8 +1,11 @@
1
1
  import type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
2
+ import type { ChangesArchive } from './archive.ts';
2
3
  import { type GitRunner } from './git.ts';
3
4
  import type { WorkspaceChangesSummary, WorkspaceFileDiff } from './types.ts';
4
5
  /** Facts shared by every recorder of one plugin instance. */
5
6
  export interface RecorderEnvironment {
7
+ /** Durable summaries and comparisons, retained after recorder disposal. */
8
+ archive: ChangesArchive;
6
9
  /** Resolves to the runner, or null when git is unavailable and no snapshot is taken. */
7
10
  git: Promise<GitRunner | null>;
8
11
  /** Directory that receives each Session's temporary directory. */
@@ -22,8 +25,9 @@ export interface RecorderEnvironment {
22
25
  * with its diff, and the appended `workspace/changes` event whose summary and
23
26
  * comparisons this recorder keeps. Snapshot objects and captured copies live in
24
27
  * a temporary directory owned by the recorder; disposal removes it together
25
- * with the summaries. Tool execution waits for pending work so a snapshot or
26
- * capture never races a mutation. A working directory outside any repository,
28
+ * with the live records; the durable archive retains the summaries and comparisons.
29
+ * Tool execution waits for pending work so a snapshot or capture never races a mutation.
30
+ * A working directory outside any repository,
27
31
  * or a Host without git, gets no snapshot; its summary lists the files the file
28
32
  * tools changed.
29
33
  */
@@ -90,6 +94,7 @@ export declare class TurnRecorder {
90
94
  * @throws when a read fails while the recorder lives.
91
95
  */
92
96
  diff(seq: number, index: number, signal: AbortSignal): Promise<WorkspaceFileDiff | undefined>;
97
+ private compare;
93
98
  /**
94
99
  * Abort queued work, forget every record, and remove the temporary directory.
95
100
  * @returns once the temporary directory is gone.
@@ -17,8 +17,9 @@ const OVERSIZED = Symbol('oversized');
17
17
  * with its diff, and the appended `workspace/changes` event whose summary and
18
18
  * comparisons this recorder keeps. Snapshot objects and captured copies live in
19
19
  * a temporary directory owned by the recorder; disposal removes it together
20
- * with the summaries. Tool execution waits for pending work so a snapshot or
21
- * capture never races a mutation. A working directory outside any repository,
20
+ * with the live records; the durable archive retains the summaries and comparisons.
21
+ * Tool execution waits for pending work so a snapshot or capture never races a mutation.
22
+ * A working directory outside any repository,
22
23
  * or a Host without git, gets no snapshot; its summary lists the files the file
23
24
  * tools changed.
24
25
  */
@@ -142,28 +143,30 @@ export class TurnRecorder {
142
143
  */
143
144
  async diff(seq, index, signal) {
144
145
  const record = this.records.get(seq);
145
- const file = record?.summary.files[index];
146
- const sources = record?.sources[index];
147
- if (file === undefined || sources === undefined)
146
+ if (record === undefined || record.summary.files[index] === undefined)
148
147
  return undefined;
149
- const { path, display } = file;
150
- if (sources.refusal !== undefined)
151
- return { kind: sources.refusal, path, display };
152
- const combined = AbortSignal.any([signal, this.lifetime.signal]);
153
148
  try {
154
- const [before, after] = await Promise.all([this.readSide(sources.before, combined), this.readSide(sources.after, combined)]);
155
- if (before === OVERSIZED || after === OVERSIZED)
156
- return { kind: 'oversized', path, display };
157
- const { hunks, coarse } = compareText(before, after, this.env.diffTimeoutMs);
158
- return { kind: 'text', path, display, before: before !== null, after: after !== null, hunks, coarse };
149
+ return await this.compare(record, index, signal);
159
150
  }
160
151
  catch (error) {
161
- // Disposal removes the temporary directory under a running read; the Session is gone either way.
162
152
  if (this.lifetime.signal.aborted)
163
153
  return undefined;
164
154
  throw error;
165
155
  }
166
156
  }
157
+ async compare(record, index, signal) {
158
+ const file = record.summary.files[index];
159
+ const sources = record.sources[index];
160
+ const { path, display } = file;
161
+ if (sources.refusal !== undefined)
162
+ return { kind: sources.refusal, path, display };
163
+ const combined = AbortSignal.any([signal, this.lifetime.signal]);
164
+ const [before, after] = await Promise.all([this.readSide(sources.before, combined), this.readSide(sources.after, combined)]);
165
+ if (before === OVERSIZED || after === OVERSIZED)
166
+ return { kind: 'oversized', path, display };
167
+ const { hunks, coarse } = compareText(before, after, this.env.diffTimeoutMs);
168
+ return { kind: 'text', path, display, before: before !== null, after: after !== null, hunks, coarse };
169
+ }
167
170
  /**
168
171
  * Abort queued work, forget every record, and remove the temporary directory.
169
172
  * @returns once the temporary directory is gone.
@@ -209,6 +212,10 @@ export class TurnRecorder {
209
212
  const workspace = await locateGitWorkspace(git, cwd, () => this.scratchDir(), signal);
210
213
  if (workspace === null)
211
214
  return null;
215
+ const archive = await canonicalPath(this.env.archive.directory);
216
+ if (isInside(workspace.root, archive)) {
217
+ workspace.excludes = [...workspace.excludes, toPosix(relative(workspace.root, archive))];
218
+ }
212
219
  this.repository = { git, workspace };
213
220
  return this.repository;
214
221
  }
@@ -283,9 +290,8 @@ export class TurnRecorder {
283
290
  // An empty list after an earlier in-turn record supersedes that record.
284
291
  if (sorted.length === 0 && state.recordedAfterSeq < 0)
285
292
  return;
286
- const event = this.session.append('workspace/changes', { turn: state.turn });
287
293
  const kept = sorted.slice(0, this.env.maxFiles);
288
- this.records.set(event.seq, {
294
+ const record = {
289
295
  summary: {
290
296
  turn: state.turn,
291
297
  cwd: this.cwd,
@@ -296,8 +302,18 @@ export class TurnRecorder {
296
302
  ...snapshot === undefined ? {} : { snapshot },
297
303
  },
298
304
  sources: kept.map(entry => entry.sources),
299
- });
300
- state.recordedAfterSeq = event.seq;
305
+ };
306
+ const staged = await this.env.archive.stage(this.session.id, record.summary, index => this.compare(record, index, signal), signal);
307
+ try {
308
+ signal.throwIfAborted();
309
+ const event = this.session.append('workspace/changes', { turn: state.turn });
310
+ this.records.set(event.seq, record);
311
+ state.recordedAfterSeq = event.seq;
312
+ await staged.commit(event.seq);
313
+ }
314
+ finally {
315
+ await staged.dispose();
316
+ }
301
317
  }
302
318
  /**
303
319
  * The listing of a captured pair: an oversized side lists the file without
@@ -19,7 +19,7 @@ export interface WorkspaceChangedFile {
19
19
  /** Present when a captured side exceeded the plugin's `maxFileBytes`; the file is listed without counts or comparison. */
20
20
  oversized?: true;
21
21
  }
22
- /** Files changed during one top-level turn, kept on the Host until its Session is disposed. */
22
+ /** Files changed during one top-level turn, retained on the Host across restarts. */
23
23
  export interface WorkspaceChangesSummary {
24
24
  /** The turn whose file changes this summary describes. */
25
25
  turn: number;
@@ -52,7 +52,7 @@ export interface WorkspaceDiffHunk {
52
52
  /** Hunk body in order, each line prefixed with `+`, `-`, or a space. */
53
53
  lines: string[];
54
54
  }
55
- /** The comparison of one listed file's turn-start and turn-end contents, computed when asked for. */
55
+ /** The comparison of one listed file's turn-start and turn-end contents, archived at turn end. */
56
56
  export type WorkspaceFileDiff = {
57
57
  kind: 'text';
58
58
  /** The listed file's `path`. */
@@ -80,23 +80,24 @@ export type WorkspaceFileDiff = {
80
80
  path: string;
81
81
  display: string;
82
82
  };
83
- /** Serves the summaries and file comparisons the recorder keeps for live Sessions. */
83
+ /** Serves live and archived turn summaries and file comparisons. */
84
84
  export interface WorkspaceChanges {
85
85
  /**
86
86
  * The summary announced by one `workspace/changes` event.
87
87
  * @param sessionId - the Session that appended the event.
88
88
  * @param seq - the event's sequence number.
89
- * @returns the summary, or undefined once its Session was disposed or when this Host never recorded it.
89
+ * @returns the live or archived summary, or undefined when no record exists.
90
+ * @throws when an archived summary cannot be read or validated.
90
91
  */
91
- summary(sessionId: SessionId, seq: number): WorkspaceChangesSummary | undefined;
92
+ summary(sessionId: SessionId, seq: number): Promise<WorkspaceChangesSummary | undefined>;
92
93
  /**
93
94
  * Compare one listed file's contents at turn start and turn end.
94
95
  * @param sessionId - the Session that appended the event.
95
96
  * @param seq - the event's sequence number.
96
97
  * @param index - the file's index in the summary's `files`.
97
98
  * @param signal - cancels the reads.
98
- * @returns the comparison, or undefined once its Session was disposed, when this Host never recorded it, or when no file has that index.
99
- * @throws when a snapshot read fails for a live Session.
99
+ * @returns the live or archived comparison, or undefined when no record or file exists.
100
+ * @throws when a snapshot or archive read fails.
100
101
  */
101
102
  diff(sessionId: SessionId, seq: number, index: number, signal: AbortSignal): Promise<WorkspaceFileDiff | undefined>;
102
103
  }
@@ -104,8 +105,8 @@ declare module '@deepseek-ai/dsh-session/types' {
104
105
  interface SessionEventMap {
105
106
  /**
106
107
  * A completed top-level turn's changed files were summarized; the summary itself stays on the
107
- * Host and is served by `workspaceChanges.summary` for the event's sequence while the Session
108
- * lives. The latest event for one turn replaces earlier ones.
108
+ * Host and is served by `workspaceChanges.summary` for the event's sequence across Host
109
+ * restarts. The latest event for one turn replaces earlier ones. Legacy events may have no archive.
109
110
  */
110
111
  'workspace/changes': {
111
112
  turn: number;
@@ -114,7 +115,7 @@ declare module '@deepseek-ai/dsh-session/types' {
114
115
  }
115
116
  declare module '@deepseek-ai/cordis' {
116
117
  interface Context {
117
- /** Per-turn changed-file summaries and comparisons of live Sessions. */
118
+ /** Live and archived per-turn changed-file summaries and comparisons. */
118
119
  workspaceChanges: WorkspaceChanges;
119
120
  }
120
121
  }
@@ -32,6 +32,7 @@
32
32
  "lib/types/**/*.d.ts"
33
33
  ],
34
34
  "dependencies": {
35
+ "@deepseek-ai/dsh-home-paths": "workspace:*",
35
36
  "@deepseek-ai/schemastery": "workspace:~",
36
37
  "diff": "^9.0.0"
37
38
  },
@@ -21,7 +21,7 @@ const externalPluginAliases = [
21
21
  'dsh-better-sidebar',
22
22
  'dsh-builtin-browser',
23
23
  'dsh-chat-import',
24
- 'dsh-llm-chatcode-config',
24
+ '@chatcode/cco-llm-chatcode-config',
25
25
  'dshmarket',
26
26
  ]
27
27
 
@@ -1,2 +0,0 @@
1
- import { n as runDumpConfig } from "./dump-config-ZzrfvtnX.js";
2
- export { runDumpConfig };
@@ -1,8 +1,8 @@
1
1
  import { n as expandHomePath, t as defaultChatCodeCliHome } from "./chatcode-home-B93iESZd.js";
2
2
  import { constants } from "node:fs";
3
+ import { createHash, randomUUID } from "node:crypto";
3
4
  import { homedir } from "node:os";
4
5
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
- import { createHash, randomUUID } from "node:crypto";
6
6
  import { chmod, copyFile, link, lstat, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
7
7
  const LEGACY_HOME_DIRECTORY = ".dsh";
8
8
  const LEGACY_TUI_HOME_DIRECTORY = ".dsh-tui";
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
1
  import { randomUUID } from "node:crypto";
2
+ import { join } from "node:path";
3
3
  import { mkdir, writeFile } from "node:fs/promises";
4
4
  import { inspect } from "node:util";
5
5
  //#region lib/types/startup-diagnostics.js