dsh-desktop-kit 2.15.8 → 2.15.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.15.9 (2026-11-12)
4
+
5
+ - **Транскрипт после restart.** При завершении/отмене run сохраняется redacted-снимок в `.dsh/agents/transcripts/<run>.json` (0600, 80 записей).
6
+ - **API.** Живая сессия — источник истины; если её нет, читается снимок; иначе честная ошибка.
7
+ - **Тесты.** `transcripts-tests`: extract, redaction, save/load, missing.
8
+
3
9
  ## 2.15.8 (2026-11-12)
4
10
 
5
11
  - **Транскрипт агента.** Кнопка «Транскрипт» у фонового run открывает чтение сессии ребёнка через `ctx.sessions`: user/assistant, tool calls, tool results, errors.
package/README.md CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  Набор из **16 плагинов и 30 навыков** для DeepSeek Harness 0.2.x: MCP tools/resources/prompts + OAuth 2.1, sampling, elicitation; проектные агенты, worktrees, фон и read-only рой с общей доской; русский интерфейс, автопилот навыков, токен-лаборатория, студия навыков, память проектов, guardrails, карта репозитория, чекпоинты, plan mode, browser QA, GitHub review, hooks/commands и резервные копии профиля.
6
6
 
7
- ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.15.8/docs/images/hero.png)
7
+ ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.15.9/docs/images/hero.png)
8
8
 
9
9
  ## MCP: подключения без JSON
10
10
 
11
11
  Настройки → **MCP**: пресеты GitHub, PostgreSQL и Filesystem, живые статусы, health, список tools и безопасное хранение токенов в `~/.dsh/mcp.secrets.json`. Промпты сервера открываются кнопкой **Prompts**: аргументы, запуск и копирование результата. HTTP-серверы подключаются через **OAuth 2.1 + PKCE**, **sampling** идёт через approval-карточку DSH, а **elicitation** — через глобальную форму с Accept/Decline.
12
12
 
13
- ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
13
+ ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
14
14
 
15
- ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-mcp-manager/screenshots/settings-390.png)
15
+ ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-mcp-manager/screenshots/settings-390.png)
16
16
 
17
- ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-mcp-manager/screenshots/modal-390.png)
17
+ ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-mcp-manager/screenshots/modal-390.png)
18
18
 
19
19
  ## Агенты, worktrees и рой
20
20
 
@@ -26,17 +26,17 @@
26
26
  - **Живые сообщения** — `team_message` отправляет текст лиду (`to="parent"`) или участнику по run id; копия каждого сообщения остаётся в board.
27
27
  - **Инструкции проекта** — `AGENTS.md`/`CLAUDE.md` иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает корень проекта.
28
28
 
29
- ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-agent-extensions/screenshots/board-1440.png)
29
+ ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-agent-extensions/screenshots/board-1440.png)
30
30
 
31
- ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-agent-extensions/screenshots/board-390.png)
31
+ ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-agent-extensions/screenshots/board-390.png)
32
32
 
33
- ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
33
+ ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
34
34
 
35
- ![Транскрипт на 390px](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-agent-extensions/screenshots/transcript-390.png)
35
+ Транскрипт сохраняется в `.dsh/agents/transcripts/<run>.json` (0600) и доступен после restart.\n\n![Транскрипт на 390px](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-agent-extensions/screenshots/transcript-390.png)
36
36
 
37
- ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
37
+ ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
38
38
 
39
- ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
39
+ ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
40
40
 
41
41
  ## Права и субагенты
42
42
 
@@ -47,11 +47,11 @@
47
47
  - **Worktrees и фоновые агенты.** `project_worktree` создаёт ветку `dsh/<slug>` и отдельную папку `.dsh/worktrees/<slug>`; `project_agent ... worktree=auto background=true` запускает агента в изоляции, а страница **Агенты** показывает worktrees и очередь запусков с кнопкой «Остановить».
48
48
  - **Инструкции проекта.** `AGENTS.md` и `CLAUDE.md` читаются иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает серверу корень проекта.
49
49
 
50
- ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
50
+ ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
51
51
 
52
- ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-guardrails/screenshots/permissions-1440.png)
52
+ ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-guardrails/screenshots/permissions-1440.png)
53
53
 
54
- **v2.15.8** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
54
+ **v2.15.9** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
55
55
 
56
56
  **План развития:** [docs/ROADMAP-3.0.md](docs/ROADMAP-3.0.md) — Memory Fabric, семантическое
57
57
  слияние, локальный индекс памяти, шифрованные переносы, Memory Hub и npm trusted publishing.
@@ -146,27 +146,27 @@
146
146
  - перед каждой синхронизацией проверяется, что репозиторий всё ещё приватный;
147
147
  - секреты и PII вычищаются, домашние пути заменяются токеном `%DSH_HOME%`; LLM не вызывается — **0 токенов**.
148
148
 
149
- ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-memory-bridge/docs/images/settings-light.png)
149
+ ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-memory-bridge/docs/images/settings-light.png)
150
150
 
151
- ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-memory-bridge/docs/images/conflicts.png)
151
+ ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-memory-bridge/docs/images/conflicts.png)
152
152
 
153
153
  ## Скриншоты
154
154
 
155
155
  ### Skills Studio: каталог, стоимость и редактор
156
156
 
157
- ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
157
+ ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
158
158
 
159
- ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
159
+ ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
160
160
 
161
161
  ### Token Lab: куда уходит контекст
162
162
 
163
- ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
163
+ ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
164
164
 
165
165
  ### Тёмная тема и мобильный
166
166
 
167
- ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
167
+ ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
168
168
 
169
- ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
169
+ ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
170
170
 
171
171
  ## Окно-напоминание: пиковый тариф
172
172
 
@@ -176,11 +176,11 @@ DeepSeek включает двойной тариф в пиковые часы (
176
176
  - **в окне** — красная карточка: причина, границы окна в местном времени и UTC, живой отсчёт до конца и рекомендация, когда вернуться;
177
177
  - **после окна** — карточка исчезает; состояние всегда доступно через `window.__DSH_PEAK_GUARD__.state()`.
178
178
 
179
- ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
179
+ ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
180
180
 
181
- ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
181
+ ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
182
182
 
183
- ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.8/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
183
+ ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.9/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
184
184
 
185
185
  Подробности и настройки — [plugins/dsh-peak-guard/README.md](plugins/dsh-peak-guard/README.md).
186
186
 
package/client.js CHANGED
@@ -8083,7 +8083,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
8083
8083
  if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
8084
8084
  };
8085
8085
  try {
8086
- window.__DSH_DESKTOP_KIT__ = { version: "2.15.8", parts: __partNames, errors: __kitErrors, ready: false };
8086
+ window.__DSH_DESKTOP_KIT__ = { version: "2.15.9", parts: __partNames, errors: __kitErrors, ready: false };
8087
8087
  } catch {}
8088
8088
  const __inject = [];
8089
8089
  for (const __part of __parts) {
@@ -0,0 +1,16 @@
1
+ # DSH Desktop Kit 2.15.9 — тест
2
+
3
+ Дата: 2026-11-12.
4
+
5
+ ## Persistent transcript
6
+
7
+ - При завершении/отмене фонового run: `.dsh/agents/transcripts/<run>.json`, mode 0600.
8
+ - 80 записей, 4 КБ на сообщение, redaction.
9
+ - API: live session → snapshot → error.
10
+ - UI не менялся; кнопка «Транскрипт» работает после restart.
11
+
12
+ ## Проверки
13
+
14
+ - `transcripts-tests` — OK.
15
+ - `npm test` — exit 0.
16
+ - `build:client` / `check:client` — OK.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-desktop-kit",
3
- "version": "2.15.8",
4
- "description": "DeepSeek Harness desktop kit 2.15.8: 16 plugins and 30 skills — MCP tools/resources/prompts with OAuth 2.1, sampling and elicitation, project agents, git worktrees, background runs and a read-only/writer swarm with a shared board, plus self-applying skills, token lab, Skills Studio, project memory, guardrails, repo map, checkpoints, plan mode, browser QA, GitHub review, hooks/commands, Russian UI and profile transfer.",
3
+ "version": "2.15.9",
4
+ "description": "DeepSeek Harness desktop kit 2.15.9: 16 plugins and 30 skills — MCP tools/resources/prompts with OAuth 2.1, sampling and elicitation, project agents, git worktrees, background runs and a read-only/writer swarm with a shared board, plus self-applying skills, token lab, Skills Studio, project memory, guardrails, repo map, checkpoints, plan mode, browser QA, GitHub review, hooks/commands, Russian UI and profile transfer.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -82,7 +82,7 @@
82
82
  "build:client": "node tools/build-client.mjs",
83
83
  "build:skills": "node tools/build-skill-manifest.mjs",
84
84
  "check:client": "node tools/check-client.mjs client.js",
85
- "test": "node tools/smoke-tests.mjs && node tools/memory-tests.mjs && node tools/skills-sync-tests.mjs && node tools/kit-upgrade-tests.mjs && node plugins/dsh-profile-transfer/test/transfer.test.mjs && node --test plugins/dsh-memory-bridge/test/bridge.test.mjs plugins/dsh-memory-bridge/test/github.test.mjs plugins/dsh-memory-bridge/test/merge.test.mjs plugins/dsh-memory-bridge/test/user-specific.test.mjs && node tools/repo-map-tests.mjs && node tools/checkpoints-tests.mjs && node tools/plan-mode-tests.mjs && node tools/browser-qa-tests.mjs && node tools/ui-gate-tests.mjs && node tools/agent-extensions-tests.mjs && node tools/mcp-manager-tests.mjs && node tools/github-review-tests.mjs && node tools/instructions-tests.mjs && node tools/mcp-elicitation-tests.mjs && node tools/mcp-sampling-tests.mjs && node tools/mcp-oauth-tests.mjs && node tools/worktrees-tests.mjs && node tools/team-messages-tests.mjs && node tools/team-board-tests.mjs && node tools/team-agents-tests.mjs && node tools/background-agents-tests.mjs && node tools/permissions-ui-tests.mjs && node plugins/dsh-guardrails/tools/guardrails-tests.mjs",
85
+ "test": "node tools/smoke-tests.mjs && node tools/memory-tests.mjs && node tools/skills-sync-tests.mjs && node tools/kit-upgrade-tests.mjs && node plugins/dsh-profile-transfer/test/transfer.test.mjs && node --test plugins/dsh-memory-bridge/test/bridge.test.mjs plugins/dsh-memory-bridge/test/github.test.mjs plugins/dsh-memory-bridge/test/merge.test.mjs plugins/dsh-memory-bridge/test/user-specific.test.mjs && node tools/repo-map-tests.mjs && node tools/checkpoints-tests.mjs && node tools/plan-mode-tests.mjs && node tools/browser-qa-tests.mjs && node tools/ui-gate-tests.mjs && node tools/agent-extensions-tests.mjs && node tools/mcp-manager-tests.mjs && node tools/github-review-tests.mjs && node tools/instructions-tests.mjs && node tools/mcp-elicitation-tests.mjs && node tools/mcp-sampling-tests.mjs && node tools/mcp-oauth-tests.mjs && node tools/worktrees-tests.mjs && node tools/transcripts-tests.mjs && node tools/team-messages-tests.mjs && node tools/team-board-tests.mjs && node tools/team-agents-tests.mjs && node tools/background-agents-tests.mjs && node tools/permissions-ui-tests.mjs && node plugins/dsh-guardrails/tools/guardrails-tests.mjs",
86
86
  "skills:cost": "node tools/skill-cost.mjs",
87
87
  "skills:check": "node tools/skill-cost.mjs --check",
88
88
  "release": "node tools/release.mjs"
@@ -9,6 +9,7 @@ import crypto from "node:crypto";
9
9
  import { loadAgents, projectFor } from "./project.js";
10
10
  import { clearChildPolicy, setChildPolicy } from "./policy.js";
11
11
  import { loadRuns, runPreview, updateRun, upsertRun } from "./runs.js";
12
+ import { saveTranscript } from "./transcripts.js";
12
13
 
13
14
  const background = new Map();
14
15
 
@@ -99,6 +100,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
99
100
  upsertRun(project.root, record);
100
101
  remember(record, activation, project.root, signal, abort);
101
102
  activation.result.then(async (result) => {
103
+ try { saveTranscript(project.root, record.id, ctx.get("sessions")?.get(activeId)); } catch { /* best effort */ }
102
104
  const currentRecord = loadRuns(project.root).find((item) => item.id === record.id);
103
105
  if (currentRecord?.status !== "canceled") {
104
106
  const text = textFromOutput(result?.output);
@@ -115,6 +117,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
115
117
  background.delete(record.id);
116
118
  signal?.removeEventListener?.("abort", abort);
117
119
  }).catch((error) => {
120
+ try { saveTranscript(project.root, record.id, ctx.get("sessions")?.get(activeId)); } catch { /* best effort */ }
118
121
  const currentRecord = loadRuns(project.root).find((item) => item.id === record.id);
119
122
  if (currentRecord?.status !== "canceled") {
120
123
  finishRun(project.root, record.id, {
@@ -214,6 +217,7 @@ export async function cancelRun(ctx, exec, id) {
214
217
  parentSessionId: entry.record.parentId ?? exec?.agent?.session?.id,
215
218
  });
216
219
  } catch { /* disposal below still stops the local activation */ }
220
+ try { saveTranscript(project.root, entry.record.id, ctx.get?.("sessions")?.get?.(entry.record.childId)); } catch { /* best effort */ }
217
221
  try { await entry.activation.dispose?.(); } catch { /* best effort */ }
218
222
  clearChildPolicy(entry.record.childId);
219
223
  background.delete(entry.record.id);
@@ -5,6 +5,7 @@ import { loadAgents, projectFor } from "./project.js";
5
5
  import { cancelRun, listRuns } from "./agents.js";
6
6
  import { worktreeSummary } from "./worktrees.js";
7
7
  import { readBoard } from "./board.js";
8
+ import { extractTranscript, loadTranscript } from "./transcripts.js";
8
9
 
9
10
  export const RPC_NAMESPACE = "dsh-agent-extensions";
10
11
  const ROUTE_BASE = "/api/dsh-agent-extensions";
@@ -122,8 +123,10 @@ export function registerAgentApi(ctx) {
122
123
  if (!run) throw new Error(`run not found: ${value.payload?.runId}`);
123
124
  const sessions = ctx.get?.("sessions");
124
125
  const child = sessions?.get?.(run.childId);
125
- if (!child) throw new Error("child session is not live (restart or already disposed)");
126
- return ok(rpcId, transcriptOf(child, run));
126
+ if (child) return ok(rpcId, { run, entries: extractTranscript(child), persisted: false });
127
+ const saved = loadTranscript(project.root, run.id);
128
+ if (!saved) throw new Error("transcript is unavailable: child session is gone and no saved snapshot exists");
129
+ return ok(rpcId, { run, entries: saved.entries, persisted: true, savedAt: saved.savedAt });
127
130
  } catch (error) {
128
131
  return fail(rpcId, error instanceof Error ? error.message : String(error));
129
132
  }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Durable, bounded transcripts for background project agents.
3
+ *
4
+ * A live child session is authoritative while it exists. When the run finishes
5
+ * we persist a redacted snapshot so the Agents UI still has a transcript after
6
+ * a DSH restart or session disposal.
7
+ */
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+ import { redact } from "./runs.js";
11
+
12
+ const LIMIT = 80;
13
+ const TEXT_LIMIT = 4_000;
14
+
15
+ function textOf(content) {
16
+ if (typeof content === "string") return content;
17
+ if (!Array.isArray(content)) return String(content?.text ?? "");
18
+ return content.map((block) => {
19
+ if (block?.type === "text") return block.text ?? "";
20
+ if (block?.type === "tool-call") return `→ ${block.name}(${block.arguments ?? ""})`;
21
+ if (block?.type === "image") return "[image]";
22
+ return "";
23
+ }).filter(Boolean).join("\n");
24
+ }
25
+
26
+ export function transcriptPath(projectRoot, runId) {
27
+ return path.join(projectRoot, ".dsh", "agents", "transcripts", `${String(runId)}.json`);
28
+ }
29
+
30
+ export function extractTranscript(session) {
31
+ const events = typeof session?.ownEvents === "function" ? session.ownEvents() : [];
32
+ const entries = [];
33
+ for (const event of events) {
34
+ const data = event?.data ?? {};
35
+ if (event.type === "user/message" || event.type === "assistant/message") {
36
+ const text = textOf(data.message?.content ?? data.content).trim();
37
+ if (text) entries.push({ role: event.type === "user/message" ? "user" : "assistant", text: text.slice(0, TEXT_LIMIT) });
38
+ } else if (event.type === "tool/call") {
39
+ entries.push({ role: "tool", text: `${data.name}(${String(data.arguments ?? "").slice(0, 500)})` });
40
+ } else if (event.type === "tool/result") {
41
+ const text = textOf(data.message?.content ?? data.content).trim();
42
+ if (text) entries.push({ role: data.error ? "error" : "tool-result", text: text.slice(0, 2_000) });
43
+ }
44
+ }
45
+ return entries.slice(-LIMIT).map((entry) => ({ ...entry, text: redact(entry.text) }));
46
+ }
47
+
48
+ export function saveTranscript(projectRoot, runId, session) {
49
+ const entries = extractTranscript(session);
50
+ if (entries.length === 0) return null;
51
+ const file = transcriptPath(projectRoot, runId);
52
+ fs.mkdirSync(path.dirname(file), { recursive: true });
53
+ const temp = `${file}.${process.pid}.tmp`;
54
+ fs.writeFileSync(temp, `${JSON.stringify({ runId: String(runId), savedAt: new Date().toISOString(), entries }, null, 2)}\n`, { mode: 0o600, encoding: "utf8" });
55
+ fs.renameSync(temp, file);
56
+ return { file, count: entries.length };
57
+ }
58
+
59
+ export function loadTranscript(projectRoot, runId) {
60
+ try {
61
+ const parsed = JSON.parse(fs.readFileSync(transcriptPath(projectRoot, runId), "utf8"));
62
+ return Array.isArray(parsed.entries) ? { savedAt: parsed.savedAt ?? "", entries: parsed.entries } : null;
63
+ } catch {
64
+ return null;
65
+ }
66
+ }