dsh-session-ops 0.2.2 → 0.2.3

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 (2) hide show
  1. package/lib/admin.js +9 -4
  2. package/package.json +2 -2
package/lib/admin.js CHANGED
@@ -658,11 +658,11 @@ const TOOL_PARAMETERS = {
658
658
  },
659
659
  dryRun: {
660
660
  type: 'boolean',
661
- description: 'Report what would be deleted without touching anything.',
661
+ description: 'Report what would be deleted without touching anything. Takes precedence over confirm: when true, nothing is removed even if confirm is also true.',
662
662
  },
663
663
  confirm: {
664
664
  type: 'boolean',
665
- description: 'Must be true for action="delete" to actually remove data.',
665
+ description: 'Must be true for action="delete" to actually remove data (and dryRun must not be true).',
666
666
  },
667
667
  limit: {
668
668
  type: 'integer',
@@ -737,6 +737,7 @@ function buildTool(admin, config, log, holds) {
737
737
  'Always start with action="list" plus a scope to see exactly what is in range, then call action="delete" with the SAME scope and confirm=true. ' +
738
738
  'Scope values: all (every persisted session), ungrouped (exactly the rows the sidebar shows under Ungrouped — no workspace, and neither archived nor a subagent child), temp (sessions whose working directory is gone or under the OS temp dir), archived, subagent, orphan (no session log left, only a stale cache entry). ' +
739
739
  'Sessions that belong to a workspace, are currently open/running, are archived, or are subagent children are REFUSED unless you pass the matching include* flag; report those refusals to the user instead of retrying blindly. ' +
740
+ 'Pass dryRun=true to preview exactly what would be removed — dryRun takes precedence over confirm and never deletes anything. ' +
740
741
  'Deletion is irreversible — there is no undo and no trash.',
741
742
  parameters: TOOL_PARAMETERS,
742
743
  output: {
@@ -772,7 +773,11 @@ function buildTool(admin, config, log, holds) {
772
773
  .join(' | ')}`,
773
774
  };
774
775
  }
775
- if (args.confirm !== true) {
776
+ // `dryRun` 的语义是「绝不落盘」,优先级高于 `confirm`:`confirm=true` 只是
777
+ // 「允许真删」的前置条件,不能反过来把 dryRun 盖掉。2026-11-07 修:此前只在
778
+ // confirm !== true 时才走预演,confirm=true 时 dryRun 被静默忽略、直接真删。
779
+ const dryRun = args.dryRun === true || args.confirm !== true;
780
+ if (dryRun) {
776
781
  // 不真删:把它们当作一次预演,把「确认后会发生什么」原样回给模型。
777
782
  const payload = {
778
783
  scope,
@@ -793,7 +798,7 @@ function buildTool(admin, config, log, holds) {
793
798
  matched: value.results.length,
794
799
  reclaimedBytes: value.reclaimed,
795
800
  rejections: rejections.map((r) => ({ id: r.id, reason: r.reason })),
796
- summary: `DRY RUN — confirm is not true, nothing was deleted. ${value.results.length} session(s) in range, ${value.reclaimed} bytes would be reclaimed. ${rejections.length} would be refused (${summarizeReasons(rejections)}). Re-issue with confirm=true to proceed.`,
801
+ summary: `DRY RUN — nothing was deleted (${args.dryRun === true ? 'dryRun=true' : 'confirm is not true'}). ${value.results.length} session(s) in range, ${value.reclaimed} bytes would be reclaimed. ${rejections.length} would be refused (${summarizeReasons(rejections)}). Re-issue with dryRun=false and confirm=true to proceed.`,
797
802
  };
798
803
  }
799
804
  const value = await api.delete({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-ops",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -88,4 +88,4 @@
88
88
  "@types/node": "^26.6.5",
89
89
  "typescript": "^7.0.2"
90
90
  }
91
- }
91
+ }