@kangyishuai/dsh-session-delete 0.4.2 → 0.4.4

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/README.md CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  > Real session deletion for DeepSeek Harness: trash by default, a plan before you delete, an audit log, and a receipt for whatever is left behind.
4
4
 
5
+ [![npm](https://img.shields.io/npm/v/@kangyishuai/dsh-session-delete?color=cb3837&logo=npm)](https://www.npmjs.com/package/@kangyishuai/dsh-session-delete) [![DSH](https://img.shields.io/badge/verified%20on%20DSH-0.2.2--rc.1-4b6bfb)](#compatibility--degradation) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+
5
7
  [中文](./README.zh-CN.md)
6
8
 
7
- Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai). Not affiliated with DeepSeek.
9
+ Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness). Not affiliated with DeepSeek.
10
+
11
+ > **Status: v0.4.2, early.** Verified on DSH 0.2.2-rc.1 with `pnpm smoke:session-delete` (24 end-to-end assertions) plus a check of the plugin status in the desktop GUI. Treat it as young software and keep backups of anything you cannot lose.
12
+
8
13
 
9
- > **Status: v0.4.2, early.** Verified on DSH 0.2.1-rc.5 with `pnpm smoke:session-delete` (24 end-to-end assertions) plus a manual pass in the desktop GUI. Treat it as young software and keep backups of anything you cannot lose.
14
+ ![Delete confirmation with the plan: size, sub-sessions, references to clean](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/overview.png)
10
15
 
11
16
  ## What it does
12
17
 
@@ -18,6 +23,14 @@ DSH's built-in _archive_ only hides a session: the id goes into the workspace's
18
23
  - **Audit log.** Every delete / restore / purge appends one JSON line to `~/.dsh/session-trash/audit.log`, readable from the trash panel.
19
24
  - **Receipt after delete.** After the move, the plugin checks the places a session can be referenced and reports anything left behind (deletion is one session at a time; the trash tab supports batch restore / batch permanent delete).
20
25
 
26
+ ## Screenshots
27
+
28
+ | Plan before delete | Trash | Audit log | Receipts |
29
+ | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
30
+ | ![Plan before delete](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/confirm-dialog.png) | ![Trash](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/trash-panel.png) | ![Audit log](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/audit-tab.png) | ![Receipts](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/receipts-tab.png) |
31
+
32
+ <sub>Screenshots come from <code>SMOKE_DEMO=1 pnpm smoke:session-delete</code>: workspace names, session titles and IDs are replaced with demo data. The UI language follows DSH (Chinese here).</sub>
33
+
21
34
  ## Install
22
35
 
23
36
  ```bash
@@ -103,9 +116,10 @@ Capability grades:
103
116
  - `minimal` — the host has no `workspaceRegistry` (for example the headless composition). Deletion works; the archive gate, pin/workspace bookkeeping and projection-cache steps are skipped and listed in the receipt.
104
117
  - `unknown` — the persistence seam itself is missing: **read-only mode**. Plan, audit and trash listing keep working; delete/restore/purge are disabled.
105
118
 
106
- | Plugin | Verified on DSH | Notes |
107
- | ------ | ------------------------ | ------------------------------------------------------------------------------------------- |
108
- | 0.4.2 | **0.2.1-rc.5** (desktop) | `pnpm smoke:session-delete`: 24 assertions green; manual GUI pass on the same host version. |
119
+ | Plugin | Verified on DSH | Notes |
120
+ | ------ | ------------------------ | -------------------------------------------------------------------------------------------------------------- |
121
+ | 0.4.2 | **0.2.2-rc.1** (desktop) | `pnpm smoke:session-delete`: 24 assertions green; plugin active with no bundle error on the same host version. |
122
+ | 0.4.2 | 0.2.1-rc.5 (desktop) | `pnpm smoke:session-delete`: 24 assertions green; manual GUI pass on the same host version. |
109
123
 
110
124
  After a DSH upgrade: restart, then open the plugin status (settings → plugins). If it reports read-only mode, the host API changed — upgrade the plugin or report the version pair; don't force it.
111
125
 
package/README.zh-CN.md CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  > 真正的删除会话:默认进回收站、删前先预演、留审计日志,删完给你一份残留回执。
4
4
 
5
+ [![npm](https://img.shields.io/npm/v/@kangyishuai/dsh-session-delete?color=cb3837&logo=npm)](https://www.npmjs.com/package/@kangyishuai/dsh-session-delete) [![DSH](https://img.shields.io/badge/verified%20on%20DSH-0.2.2--rc.1-4b6bfb)](#兼容性与降级) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+
5
7
  [English](./README.md)
6
8
 
7
- 非官方 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai) 插件,与 DeepSeek 无关。
9
+ 非官方 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) 插件,与 DeepSeek 无关。
10
+
11
+ > **状态:v0.4.2,早期可用。** 已在 DSH 0.2.2-rc.1 上用 `pnpm smoke:session-delete`(24 项端到端断言)验证,并确认桌面版里插件正常激活、状态条不是只读模式。仍是年轻软件,重要数据请自行备份。
12
+
8
13
 
9
- > **状态:v0.4.2,早期可用。** 已在 DSH 0.2.1-rc.5 上用 `pnpm smoke:session-delete`(24 项端到端断言)加一轮桌面版人工验收。仍是年轻软件,重要数据请自行备份。
14
+ ![删除确认框:展示体积、子会话和将要清理的引用](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/overview.png)
10
15
 
11
16
  ## 做什么
12
17
 
@@ -18,6 +23,14 @@ DSH 自带的「归档」只是把会话藏起来:id 记进工作区的归档
18
23
  - **审计日志。** 每次删除 / 恢复 / 彻底删除都往 `~/.dsh/session-trash/audit.log` 追加一行 JSON,回收站面板里能直接看。
19
24
  - **删除回执。** 移走之后核对会话可能被引用的几处,把没清干净的残留列出来(删除仍是一次一条;回收站页签支持批量恢复 / 批量彻底删除)。
20
25
 
26
+ ## 截图
27
+
28
+ | 删前预演 | 回收站 | 审计日志 | 回执 |
29
+ | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
30
+ | ![删前预演](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/confirm-dialog.png) | ![回收站](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/trash-panel.png) | ![审计日志](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/audit-tab.png) | ![回执](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/session-delete/docs/images/receipts-tab.png) |
31
+
32
+ <sub>截图由 <code>SMOKE_DEMO=1 pnpm smoke:session-delete</code> 生成,工作区名、会话标题和 ID 都已替换为演示数据。</sub>
33
+
21
34
  ## 安装
22
35
 
23
36
  ```bash
@@ -103,9 +116,10 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-session-delete-*.tgz
103
116
  - `minimal` —— 宿主没有 `workspaceRegistry`(例如 headless 组合)。删除照常进行;归档闸门、置顶/工作区记账、投影缓存这些步骤被跳过并写进回执。
104
117
  - `unknown` —— 持久化本体缺失:**只读模式**。plan、审计、回收站列表还能用;删除、恢复、彻底删除被禁用。
105
118
 
106
- | 插件版本 | 已验证的 DSH 版本 | 说明 |
107
- | -------- | ------------------------ | -------------------------------------------------------------------------------- |
108
- | 0.4.2 | **0.2.1-rc.5**(桌面版) | `pnpm smoke:session-delete` 24 项断言全绿,并在同一版本桌面版做过人工 GUI 验收。 |
119
+ | 插件版本 | 已验证的 DSH 版本 | 说明 |
120
+ | -------- | ------------------------ | ------------------------------------------------------------------------------------------------- |
121
+ | 0.4.2 | **0.2.2-rc.1**(桌面版) | `pnpm smoke:session-delete` 24 项断言全绿,并确认同一版本桌面版里插件正常激活、没有 bundle 错误。 |
122
+ | 0.4.2 | 0.2.1-rc.5(桌面版) | `pnpm smoke:session-delete` 24 项断言全绿,并在同一版本桌面版做过人工 GUI 验收。 |
109
123
 
110
124
  目前只在 **macOS** 上验证过。Windows 相关路径(`session.lock` 的 EBUSY/EPERM 重试、宿主在那儿用的命名信号量)代码里有,但**还没实测**。
111
125
 
package/lib/agent-tool.js CHANGED
@@ -140,17 +140,17 @@ export function summarizePlanForModel(planResult) {
140
140
  return (
141
141
  "Delete preview failed: " +
142
142
  (planResult.code || "blocked") +
143
- (blockers ? " (" + blockers + ")" : "")
143
+ (blockers ? ` (${blockers})` : "")
144
144
  );
145
145
  }
146
146
  const parts = [
147
- "Delete preview for " + (planResult.title || planResult.sessionId),
147
+ `Delete preview for ${planResult.title || planResult.sessionId}`,
148
148
  "size " +
149
- (typeof planResult.sizeBytes === "number" ? planResult.sizeBytes + " bytes" : "unknown"),
149
+ (typeof planResult.sizeBytes === "number" ? `${planResult.sizeBytes} bytes` : "unknown"),
150
150
  ];
151
151
  if (planResult.live) parts.push("session is live");
152
- if (planResult.children.length > 0) parts.push(planResult.children.length + " child session(s)");
153
- parts.push("token " + planResult.token + " expires " + planResult.expiresAt);
152
+ if (planResult.children.length > 0) parts.push(`${planResult.children.length} child session(s)`);
153
+ parts.push(`token ${planResult.token} expires ${planResult.expiresAt}`);
154
154
  return parts.join(" | ");
155
155
  }
156
156
 
package/lib/audit.js CHANGED
@@ -25,7 +25,7 @@ const MAX_LINE = 4096;
25
25
  */
26
26
  function clip(value) {
27
27
  if (typeof value !== "string") return "";
28
- return value.length > 200 ? value.slice(0, 197) + "..." : value;
28
+ return value.length > 200 ? `${value.slice(0, 197)}...` : value;
29
29
  }
30
30
 
31
31
  /**
@@ -53,7 +53,7 @@ export function createAudit(dataRoot) {
53
53
  line = JSON.stringify({ ...record, detail: clip(record.detail).slice(0, 80) });
54
54
  const job = chain.then(async () => {
55
55
  await mkdir(dirname(file), { recursive: true });
56
- await appendFile(file, line + "\n", { encoding: "utf8", mode: 0o600 });
56
+ await appendFile(file, `${line}\n`, { encoding: "utf8", mode: 0o600 });
57
57
  return { ok: true };
58
58
  });
59
59
  chain = job.catch(() => undefined);
package/lib/client.js CHANGED
@@ -18,7 +18,7 @@ window.__ModuleLoader__.load({
18
18
  var primitives = {};
19
19
  try {
20
20
  primitives = require("@deepseek-ai/dsh-client-ui-primitives") || {};
21
- } catch (error) {
21
+ } catch (_error) {
22
22
  primitives = {};
23
23
  }
24
24
  var MenuItemButton = primitives.MenuItemButton;
@@ -200,7 +200,7 @@ window.__ModuleLoader__.load({
200
200
  autoFocus: props.autoFocus,
201
201
  disabled: props.disabled,
202
202
  onClick: props.onClick,
203
- className: "dsh-sdel-btn" + (props.danger ? " dsh-sdel-btn--danger" : ""),
203
+ className: `dsh-sdel-btn${props.danger ? " dsh-sdel-btn--danger" : ""}`,
204
204
  style: {
205
205
  padding: "6px 14px",
206
206
  borderRadius: "8px",
@@ -288,7 +288,7 @@ window.__ModuleLoader__.load({
288
288
  overflow: "auto",
289
289
  background: T.bg,
290
290
  color: T.text,
291
- border: "1px solid " + T.border,
291
+ border: `1px solid ${T.border}`,
292
292
  borderRadius: T.radius,
293
293
  padding: "18px 20px",
294
294
  fontSize: "13px",
@@ -331,7 +331,7 @@ window.__ModuleLoader__.load({
331
331
 
332
332
  function formatBytes(/** @type {any} */ bytes) {
333
333
  if (typeof bytes !== "number" || bytes < 0) return "?";
334
- if (bytes < 1024) return Math.round(bytes) + " B";
334
+ if (bytes < 1024) return `${Math.round(bytes)} B`;
335
335
  var units = ["KB", "MB", "GB", "TB"];
336
336
  var value = bytes / 1024;
337
337
  var unit = 0;
@@ -339,7 +339,7 @@ window.__ModuleLoader__.load({
339
339
  value = value / 1024;
340
340
  unit += 1;
341
341
  }
342
- return (value >= 10 ? value.toFixed(0) : value.toFixed(1)) + " " + units[unit];
342
+ return `${value >= 10 ? value.toFixed(0) : value.toFixed(1)} ${units[unit]}`;
343
343
  }
344
344
 
345
345
  function formatTime(/** @type {any} */ value) {
@@ -416,7 +416,7 @@ window.__ModuleLoader__.load({
416
416
  props
417
417
  .call("list")
418
418
  .then((/** @type {any} */ value) => {
419
- setCount(value && value.entries ? value.entries.length : 0);
419
+ setCount(value?.entries ? value.entries.length : 0);
420
420
  })
421
421
  .catch(() => setCount(null));
422
422
  };
@@ -432,8 +432,7 @@ window.__ModuleLoader__.load({
432
432
  }, []);
433
433
 
434
434
  var label =
435
- props.t("footer.trash") +
436
- (typeof count === "number" && count > 0 ? " (" + count + ")" : "");
435
+ props.t("footer.trash") + (typeof count === "number" && count > 0 ? ` (${count})` : "");
437
436
  return h(
438
437
  "button",
439
438
  {
@@ -562,7 +561,7 @@ window.__ModuleLoader__.load({
562
561
  if (plan.blockers && plan.blockers.length > 0)
563
562
  lines.push(props.t("confirm.blocked", { reason: plan.blockers[0].message }));
564
563
  }
565
- var blocked = !!(plan && plan.blockers && plan.blockers.length > 0);
564
+ var blocked = !!(plan?.blockers && plan.blockers.length > 0);
566
565
 
567
566
  var body = h(
568
567
  React.Fragment,
@@ -607,7 +606,7 @@ window.__ModuleLoader__.load({
607
606
  )
608
607
  : null,
609
608
  lines.map((/** @type {any} */ line, /** @type {any} */ index) =>
610
- h("div", { key: "line-" + index, style: { marginBottom: "4px" } }, line),
609
+ h("div", { key: `line-${index}`, style: { marginBottom: "4px" } }, line),
611
610
  ),
612
611
  !plan && !error ? h("div", { style: { color: T.dim } }, props.t("confirm.loading")) : null,
613
612
  error ? h("div", { style: { color: T.danger, marginTop: "8px" } }, error) : null,
@@ -688,7 +687,7 @@ window.__ModuleLoader__.load({
688
687
  props
689
688
  .call("receipts", { limit: 50 })
690
689
  .then((/** @type {any} */ value) => {
691
- setReceipts(value && value.entries ? value.entries : []);
690
+ setReceipts(value?.entries ? value.entries : []);
692
691
  })
693
692
  .catch(() => setReceipts([]));
694
693
  }, []);
@@ -710,7 +709,7 @@ window.__ModuleLoader__.load({
710
709
  props
711
710
  .call("audit", { limit: 100 })
712
711
  .then((/** @type {any} */ value) => {
713
- setAudit(value && value.entries ? value.entries : []);
712
+ setAudit(value?.entries ? value.entries : []);
714
713
  })
715
714
  .catch(() => {});
716
715
  }, []);
@@ -851,9 +850,9 @@ window.__ModuleLoader__.load({
851
850
  });
852
851
  };
853
852
 
854
- var entries = (data && data.entries) || [];
855
- var readOnly = !!(health && health.readOnly);
856
- var rowStyle = { borderTop: "1px solid " + T.border, padding: "10px 0" };
853
+ var entries = data?.entries || [];
854
+ var readOnly = !!health?.readOnly;
855
+ var rowStyle = { borderTop: `1px solid ${T.border}`, padding: "10px 0" };
857
856
 
858
857
  var content = [];
859
858
  if (readOnly)
@@ -879,7 +878,7 @@ window.__ModuleLoader__.load({
879
878
  setTab("trash");
880
879
  },
881
880
  },
882
- props.t("panel.tabTrash") + (entries.length ? " (" + entries.length + ")" : ""),
881
+ props.t("panel.tabTrash") + (entries.length ? ` (${entries.length})` : ""),
883
882
  ),
884
883
  h(
885
884
  Btn,
@@ -931,7 +930,7 @@ window.__ModuleLoader__.load({
931
930
  ).length;
932
931
  const detail =
933
932
  receipt.action === "trash"
934
- ? formatBytes(receipt.sizeBytes || 0) + " · " + okCount + "/" + removed.length
933
+ ? `${formatBytes(receipt.sizeBytes || 0)} · ${okCount}/${removed.length}`
935
934
  : receipt.action === "restore"
936
935
  ? props.t("receipts.restored")
937
936
  : receipt.action === "purge"
@@ -941,10 +940,10 @@ window.__ModuleLoader__.load({
941
940
  h(
942
941
  "div",
943
942
  {
944
- key: "receipt-" + index,
943
+ key: `receipt-${index}`,
945
944
  title: String(receipt.sessionId || ""),
946
945
  style: {
947
- borderTop: "1px solid " + T.border,
946
+ borderTop: `1px solid ${T.border}`,
948
947
  padding: "7px 0",
949
948
  fontSize: "12px",
950
949
  display: "flex",
@@ -1031,9 +1030,9 @@ window.__ModuleLoader__.load({
1031
1030
  h(
1032
1031
  "div",
1033
1032
  {
1034
- key: "finding-" + index,
1033
+ key: `finding-${index}`,
1035
1034
  style: {
1036
- borderTop: "1px solid " + T.border,
1035
+ borderTop: `1px solid ${T.border}`,
1037
1036
  padding: "8px 0",
1038
1037
  color: finding.severity === "warn" ? T.text : T.dim,
1039
1038
  },
@@ -1041,7 +1040,7 @@ window.__ModuleLoader__.load({
1041
1040
  h(
1042
1041
  "div",
1043
1042
  { style: { fontWeight: 600 } },
1044
- finding.label + " · " + props.t("health.items", { n: finding.items.length }),
1043
+ `${finding.label} · ${props.t("health.items", { n: finding.items.length })}`,
1045
1044
  ),
1046
1045
  h(
1047
1046
  "div",
@@ -1275,24 +1274,24 @@ window.__ModuleLoader__.load({
1275
1274
  h(
1276
1275
  "div",
1277
1276
  {
1278
- key: "audit-" + index,
1279
- style: { borderTop: "1px solid " + T.border, padding: "6px 0", fontSize: "12px" },
1277
+ key: `audit-${index}`,
1278
+ style: { borderTop: `1px solid ${T.border}`, padding: "6px 0", fontSize: "12px" },
1280
1279
  },
1281
- h("span", { style: { color: T.faint } }, formatTime(entry.ts) + " "),
1282
- h("span", { style: { fontWeight: 600 } }, String(entry.action || "") + " "),
1280
+ h("span", { style: { color: T.faint } }, `${formatTime(entry.ts)} `),
1281
+ h("span", { style: { fontWeight: 600 } }, `${String(entry.action || "")} `),
1283
1282
  h(
1284
1283
  "span",
1285
1284
  { title: entry.sessionId || "", style: { color: T.dim } },
1286
1285
  String(entry.result || "") +
1287
- (entry.sessionId ? " · " + String(entry.sessionId).slice(0, 13) + "…" : "") +
1288
- (entry.detail ? " · " + entry.detail : ""),
1286
+ (entry.sessionId ? ` · ${String(entry.sessionId).slice(0, 13)}…` : "") +
1287
+ (entry.detail ? ` · ${entry.detail}` : ""),
1289
1288
  ),
1290
1289
  ),
1291
1290
  );
1292
1291
  });
1293
1292
  }
1294
1293
 
1295
- if (data && data.unknown && data.unknown.length > 0) {
1294
+ if (data?.unknown && data.unknown.length > 0) {
1296
1295
  content.push(
1297
1296
  h(
1298
1297
  "div",
@@ -1301,7 +1300,7 @@ window.__ModuleLoader__.load({
1301
1300
  ),
1302
1301
  );
1303
1302
  }
1304
- if (data && data.pending && data.pending.length > 0) {
1303
+ if (data?.pending && data.pending.length > 0) {
1305
1304
  content.push(
1306
1305
  h(
1307
1306
  "div",
@@ -1377,7 +1376,7 @@ window.__ModuleLoader__.load({
1377
1376
  zIndex: 2147000000,
1378
1377
  background: T.toastBg,
1379
1378
  color: T.toastText,
1380
- border: "1px solid " + T.border,
1379
+ border: `1px solid ${T.border}`,
1381
1380
  borderRadius: "10px",
1382
1381
  padding: "10px 14px",
1383
1382
  fontSize: "13px",
@@ -1476,19 +1475,19 @@ window.__ModuleLoader__.load({
1476
1475
  * @returns {Promise<any>}
1477
1476
  */
1478
1477
  function call(method, request) {
1479
- var rpc = ctx.connection && ctx.connection.rpc;
1478
+ var rpc = ctx.connection?.rpc;
1480
1479
  if (!rpc || typeof rpc.call !== "function") {
1481
1480
  return Promise.reject(new Error("session-delete: no connection to the host"));
1482
1481
  }
1483
1482
  var payload = request === undefined ? { args: {} } : { args: { request: request } };
1484
- return Promise.resolve(rpc.call("/api", "sessionDelete/" + method, payload)).then(
1483
+ return Promise.resolve(rpc.call("/api", `sessionDelete/${method}`, payload)).then(
1485
1484
  (/** @type {any} */ result) => {
1486
1485
  if (!result || typeof result !== "object") return result;
1487
1486
  if (result.ok === false) {
1488
1487
  const error = /** @type {any} */ (
1489
- new Error((result.error && result.error.message) || "host rejected the call")
1488
+ new Error(result.error?.message || "host rejected the call")
1490
1489
  );
1491
- error.code = result.error && result.error.code;
1490
+ error.code = result.error?.code;
1492
1491
  throw error;
1493
1492
  }
1494
1493
  return "value" in result ? result.value : result;
@@ -1502,7 +1501,7 @@ window.__ModuleLoader__.load({
1502
1501
  const hostSessions = () => {
1503
1502
  try {
1504
1503
  return ctx.get ? ctx.get("sessions") : undefined;
1505
- } catch (error) {
1504
+ } catch (_error) {
1506
1505
  return undefined;
1507
1506
  }
1508
1507
  };
@@ -1512,13 +1511,13 @@ window.__ModuleLoader__.load({
1512
1511
  if (!sessions) return;
1513
1512
  try {
1514
1513
  await sessions.refresh?.();
1515
- } catch (error) {
1514
+ } catch (_error) {
1516
1515
  /* 刷新失败不影响已经完成的删除 */
1517
1516
  }
1518
1517
  retired.forEach((id) => {
1519
1518
  try {
1520
1519
  sessions.handleSessionRemoved?.(id);
1521
- } catch (error) {
1520
+ } catch (_error) {
1522
1521
  /* 旧版本没有该通道时忽略 */
1523
1522
  }
1524
1523
  });
@@ -1528,17 +1527,17 @@ window.__ModuleLoader__.load({
1528
1527
  if (!(event.metaKey || event.ctrlKey) || !event.altKey) return;
1529
1528
  if (event.key !== "t" && event.key !== "T") return;
1530
1529
  const target = /** @type {any} */ (event.target);
1531
- const tag = target && target.tagName ? String(target.tagName).toLowerCase() : "";
1532
- if (tag === "input" || tag === "textarea" || (target && target.isContentEditable)) return;
1530
+ const tag = target?.tagName ? String(target.tagName).toLowerCase() : "";
1531
+ if (tag === "input" || tag === "textarea" || target?.isContentEditable) return;
1533
1532
  event.preventDefault();
1534
1533
  panelStore.set(true);
1535
1534
  });
1536
1535
 
1537
1536
  const onTrashed = (/** @type {any} */ result) => {
1538
- if (result && result.entryId) {
1537
+ if (result?.entryId) {
1539
1538
  toastStore.set({ entryId: result.entryId, title: result.title || null });
1540
1539
  }
1541
- void refreshRows(result && result.sessionId ? result.sessionId : undefined);
1540
+ void refreshRows(result?.sessionId ? result.sessionId : undefined);
1542
1541
  tickStore.set(tickStore.getSnapshot() + 1);
1543
1542
  };
1544
1543
  // 外部变更(agent 工具、另一个窗口、CLI)不会通知本页面,
package/lib/journal.js CHANGED
@@ -23,7 +23,7 @@ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
23
23
 
24
24
  /** @param {string} file @param {unknown} value @returns {Promise<void>} */
25
25
  async function writeAtomic(file, value) {
26
- const tmp = file + ".tmp";
26
+ const tmp = `${file}.tmp`;
27
27
  await writeFile(tmp, JSON.stringify(value, null, 2), "utf8");
28
28
  await rename(tmp, file);
29
29
  }
@@ -35,7 +35,7 @@ async function writeAtomic(file, value) {
35
35
  */
36
36
  function recordPath(dataRoot, id) {
37
37
  if (!ID_RE.test(id)) throw new Error("invalid journal id");
38
- const path = join(journalDir(dataRoot), id + ".json");
38
+ const path = join(journalDir(dataRoot), `${id}.json`);
39
39
  requireInside(dataRoot, path);
40
40
  return path;
41
41
  }
package/lib/operations.js CHANGED
@@ -87,11 +87,11 @@ export function createOperations({ ctx, dataRoot, logger }) {
87
87
  try {
88
88
  stored = await caps.services.persistence?.stat?.(sessionId);
89
89
  } catch (error) {
90
- notes.push("stat failed: " + messageOf(error));
90
+ notes.push(`stat failed: ${messageOf(error)}`);
91
91
  }
92
92
  const liveEntry = caps.services.sessions?.get?.(sessionId);
93
93
  if (!stored && !liveEntry) {
94
- throw failure("session/not-found", "no session named " + sessionId, { sessionId });
94
+ throw failure("session/not-found", `no session named ${sessionId}`, { sessionId });
95
95
  }
96
96
  const header = stored?.header ?? liveEntry?.header ?? null;
97
97
 
@@ -101,7 +101,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
101
101
  try {
102
102
  rawActivity = await ctx.waterfall("workspace/session-activity", { sessionId }, () => []);
103
103
  } catch (error) {
104
- notes.push("activity unavailable: " + messageOf(error));
104
+ notes.push(`activity unavailable: ${messageOf(error)}`);
105
105
  }
106
106
  }
107
107
  const activity = normalizeActivity(rawActivity);
@@ -143,7 +143,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
143
143
  }
144
144
  }
145
145
  } catch (error) {
146
- notes.push("lineage unavailable: " + messageOf(error));
146
+ notes.push(`lineage unavailable: ${messageOf(error)}`);
147
147
  }
148
148
  }
149
149
  childMap.delete(sessionId);
@@ -176,7 +176,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
176
176
  ambiguous.length > 1
177
177
  ? {
178
178
  code: "session-delete/ambiguous-location",
179
- message: "同一会话在 " + ambiguous.length + " 个项目目录下都有副本,已拒绝操作。",
179
+ message: `同一会话在 ${ambiguous.length} 个项目目录下都有副本,已拒绝操作。`,
180
180
  }
181
181
  : {
182
182
  code: "session-delete/location-unknown",
@@ -227,9 +227,9 @@ export function createOperations({ ctx, dataRoot, logger }) {
227
227
  operator: "system",
228
228
  detail: "会话目录在移走后被重建,已记录(复活守卫)",
229
229
  });
230
- logger.warn("session-delete: session " + sessionId + " was recreated after deletion");
230
+ logger.warn(`session-delete: session ${sessionId} was recreated after deletion`);
231
231
  } catch (error) {
232
- logger.warn("session-delete: revive check failed: " + messageOf(error));
232
+ logger.warn(`session-delete: revive check failed: ${messageOf(error)}`);
233
233
  }
234
234
  }, REVIVE_CHECK_MS);
235
235
  /** @type {any} */ (timer).unref?.();
@@ -315,7 +315,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
315
315
  try {
316
316
  snapshots[ref.id] = await ref.snapshot(plan.sessionId);
317
317
  } catch (error) {
318
- logger.warn("session-delete: snapshot " + ref.id + " failed: " + messageOf(error));
318
+ logger.warn(`session-delete: snapshot ${ref.id} failed: ${messageOf(error)}`);
319
319
  }
320
320
  }
321
321
 
@@ -419,7 +419,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
419
419
  operator: request.operator ?? "ui",
420
420
  detail: messageOf(error),
421
421
  });
422
- throw failure("session-delete/failed", "删除失败:" + messageOf(error), {
422
+ throw failure("session-delete/failed", `删除失败:${messageOf(error)}`, {
423
423
  partial: moved,
424
424
  entryId: moved ? entryId : null,
425
425
  });
@@ -474,7 +474,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
474
474
  pinned: meta.pinned,
475
475
  });
476
476
  } catch (error) {
477
- logger.warn("session-delete: restore " + ref.id + " failed: " + messageOf(error));
477
+ logger.warn(`session-delete: restore ${ref.id} failed: ${messageOf(error)}`);
478
478
  }
479
479
  }
480
480
  await finishOperation({ dataRoot, id: record.id, state: "done" });
@@ -504,7 +504,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
504
504
  operator: request.operator ?? "ui",
505
505
  detail: messageOf(error),
506
506
  });
507
- throw failure("session-delete/restore-failed", "恢复失败:" + messageOf(error));
507
+ throw failure("session-delete/restore-failed", `恢复失败:${messageOf(error)}`);
508
508
  }
509
509
  }
510
510
 
@@ -527,7 +527,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
527
527
  result: "ok",
528
528
  entryId,
529
529
  operator: request.operator ?? "ui",
530
- detail: "释放约 " + result.bytes + " 字节",
530
+ detail: `释放约 ${result.bytes} 字节`,
531
531
  });
532
532
  const receiptId = await writeReceipt(dataRoot, {
533
533
  action: "purge",
@@ -547,7 +547,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
547
547
  operator: request.operator ?? "ui",
548
548
  detail: messageOf(error),
549
549
  });
550
- throw failure("session-delete/purge-failed", "彻底删除失败:" + messageOf(error));
550
+ throw failure("session-delete/purge-failed", `彻底删除失败:${messageOf(error)}`);
551
551
  }
552
552
  }
553
553
 
@@ -576,7 +576,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
576
576
  id: "session-dir",
577
577
  label: "会话目录",
578
578
  status: "failed",
579
- detail: "目录仍存在:" + located.location.path,
579
+ detail: `目录仍存在:${located.location.path}`,
580
580
  }
581
581
  : { id: "session-dir", label: "会话目录", status: "ok", detail: "会话目录已不存在" },
582
582
  );
@@ -607,7 +607,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
607
607
  } catch (error) {
608
608
  return {
609
609
  ok: false,
610
- reason: "无法读取 " + file + ":" + messageOf(error),
610
+ reason: `无法读取 ${file}:${messageOf(error)}`,
611
611
  archivedIds: [],
612
612
  pinnedIds: [],
613
613
  workspaces: [],
@@ -798,10 +798,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
798
798
  : ["archived", "pinned", "workspace"];
799
799
  const scan = await scanHealth();
800
800
  if (!scan.ok)
801
- throw failure(
802
- "session-delete/health-unavailable",
803
- "无法体检:" + (scan.reason ?? "未知原因"),
804
- );
801
+ throw failure("session-delete/health-unavailable", `无法体检:${scan.reason ?? "未知原因"}`);
805
802
  const state = await readWorkspaceState();
806
803
  const counts = { archived: 0, pinned: 0, workspace: 0 };
807
804
  /** @type {string[]} */
@@ -814,7 +811,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
814
811
  await caps.services.workspace?.unarchiveSession?.(id);
815
812
  counts.archived += 1;
816
813
  } catch (error) {
817
- errors.push("unarchive " + id + ": " + messageOf(error));
814
+ errors.push(`unarchive ${id}: ${messageOf(error)}`);
818
815
  }
819
816
  }
820
817
  }
@@ -826,7 +823,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
826
823
  await caps.services.workspace?.unpinSession?.(id);
827
824
  counts.pinned += 1;
828
825
  } catch (error) {
829
- errors.push("unpin " + id + ": " + messageOf(error));
826
+ errors.push(`unpin ${id}: ${messageOf(error)}`);
830
827
  }
831
828
  }
832
829
  }
@@ -841,7 +838,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
841
838
  await workspace.detachSession(item.sessionId);
842
839
  counts.workspace += 1;
843
840
  } catch (error) {
844
- errors.push("detach " + item.sessionId + ": " + messageOf(error));
841
+ errors.push(`detach ${item.sessionId}: ${messageOf(error)}`);
845
842
  }
846
843
  }
847
844
  }
@@ -851,10 +848,7 @@ export function createOperations({ ctx, dataRoot, logger }) {
851
848
  result: errors.length > 0 ? "failed" : "ok",
852
849
  operator: request.operator ?? "ui",
853
850
  detail:
854
- "清理失效引用 " +
855
- total +
856
- " 条" +
857
- (errors.length > 0 ? ",失败 " + errors.length + " 条" : ""),
851
+ "清理失效引用 " + total + " 条" + (errors.length > 0 ? `,失败 ${errors.length} 条` : ""),
858
852
  });
859
853
  const receiptId = await writeReceipt(dataRoot, {
860
854
  action: "health",
package/lib/paths.js CHANGED
@@ -87,7 +87,7 @@ export function encodeSegment(raw) {
87
87
  const code = raw.charCodeAt(i);
88
88
  const ch = String.fromCharCode(code);
89
89
  if (ch !== "~" && /^[A-Za-z0-9._-]$/.test(ch)) out += ch;
90
- else out += "~" + code.toString(16).toUpperCase().padStart(4, "0");
90
+ else out += `~${code.toString(16).toUpperCase().padStart(4, "0")}`;
91
91
  }
92
92
  return out;
93
93
  }
@@ -113,7 +113,7 @@ export function projectKey(cwd) {
113
113
  readable += ch;
114
114
  separatorRun = false;
115
115
  } else {
116
- readable += "~" + code.toString(16).toUpperCase().padStart(4, "0");
116
+ readable += `~${code.toString(16).toUpperCase().padStart(4, "0")}`;
117
117
  separatorRun = false;
118
118
  }
119
119
  }
package/lib/plan.js CHANGED
@@ -55,14 +55,14 @@ import { createHash } from "node:crypto";
55
55
  */
56
56
  export function stableStringify(value) {
57
57
  if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
58
- if (Array.isArray(value)) return "[" + value.map(stableStringify).join(",") + "]";
58
+ if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
59
59
  const record = /** @type {Record<string, unknown>} */ (value);
60
60
  const keys = Object.keys(record).sort();
61
61
  return (
62
62
  "{" +
63
63
  keys
64
64
  .filter((k) => record[k] !== undefined)
65
- .map((k) => JSON.stringify(k) + ":" + stableStringify(record[k]))
65
+ .map((k) => `${JSON.stringify(k)}:${stableStringify(record[k])}`)
66
66
  .join(",") +
67
67
  "}"
68
68
  );
package/lib/receipts.js CHANGED
@@ -24,15 +24,15 @@ export async function writeReceipt(dataRoot, record) {
24
24
  const id =
25
25
  typeof record.id === "string" && record.id.length > 0
26
26
  ? record.id
27
- : Date.now().toString(36) + "-" + randomUUID().slice(0, 6);
28
- const file = join(dir, id + ".json");
27
+ : `${Date.now().toString(36)}-${randomUUID().slice(0, 6)}`;
28
+ const file = join(dir, `${id}.json`);
29
29
  requireInside(dataRoot, file);
30
30
  await mkdir(dir, { recursive: true });
31
31
  await writeFile(
32
- file + ".tmp",
32
+ `${file}.tmp`,
33
33
  JSON.stringify({ ...record, schema: RECEIPT_SCHEMA, id }, null, 2),
34
34
  );
35
- await rename(file + ".tmp", file);
35
+ await rename(`${file}.tmp`, file);
36
36
  return id;
37
37
  }
38
38
 
package/lib/service.js CHANGED
@@ -28,7 +28,7 @@ function declareRemote(Proto, method) {
28
28
  },
29
29
  });
30
30
  if (initializers.length !== 1) {
31
- throw new Error("session-delete: cannot declare Remote method " + method);
31
+ throw new Error(`session-delete: cannot declare Remote method ${method}`);
32
32
  }
33
33
  initializers[0].call(Object.create(Proto.prototype));
34
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangyishuai/dsh-session-delete",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Real session deletion for DSH: trash by default, plan before delete, audit log, residue receipt",
5
5
  "keywords": [
6
6
  "dsh",
@@ -36,6 +36,9 @@
36
36
  "README.zh-CN.md",
37
37
  "LICENSE"
38
38
  ],
39
+ "scripts": {
40
+ "test": "node --test"
41
+ },
39
42
  "publishConfig": {
40
43
  "access": "public"
41
44
  },
@@ -53,8 +56,5 @@
53
56
  "@deepseek-ai/dsh-client-ui-primitives"
54
57
  ]
55
58
  }
56
- },
57
- "scripts": {
58
- "test": "node --test"
59
59
  }
60
- }
60
+ }