dsh-session-superagent 0.9.26 → 0.9.28

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
@@ -2,6 +2,64 @@
2
2
 
3
3
  格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## [0.9.28] - 2026-11-02 —— 并发隔离真跑通;隔离区不再污染 `git status`
6
+
7
+ ### 新增:`scripts/verify-concurrency.mjs`(9 步)
8
+ 两个会话同时对同一仓库开隔离区,改**同一个文件**,各自提交,再尝试合入主线:
9
+
10
+ ```
11
+ PASS 两个隔离区并存 zhuli/a + zhuli/b
12
+ PASS .dsh-zhuli 不污染 git status status 干净
13
+ PASS 各自改同一文件互不干扰
14
+ PASS A 提交不影响 B 的工作区
15
+ PASS 两条分支各自独立提交
16
+ PASS 先合的能进
17
+ PASS 后合的会冲突(同文件同区域) 自动检测为冲突,符合预期
18
+ PASS 冲突可中止,仓库回到干净状态
19
+ ```
20
+
21
+ ### 它发现并修掉的产品问题
22
+ 隔离区开在仓库内的 `.dsh-zhuli/`,默认是**未跟踪目录** ——
23
+ 客户一切 `git status` 就看到它,甚至可能顺手 `git add` 进去。
24
+ 修法:开隔离区前把 `.dsh-zhuli/` 写进 `.git/info/exclude`
25
+ (本地、不提交、**不改客户的 .gitignore**)。
26
+
27
+ ### 边界写进 README
28
+ 两个会话守同一仓库不会互相踩,但**改同一文件同一区域**时后合并的会冲突 —— 这是 git 的语义。
29
+
30
+ ### 门禁
31
+ `preflight --fast` 第 **14** 项:`PASS 并发隔离 9 步全部通过`。
32
+
33
+ ## [0.9.27] - 2026-11-02 —— 隔离执行链路在本机真跑通了(9 步)
34
+
35
+ ### 为什么做
36
+ 唤醒消息里写着"在隔离工作区里改,推分支开 PR",但这条链路一直只有"读过代码"
37
+ 和"worktree list 里出现过目录" —— 从没真跑过一遍完整流程。
38
+
39
+ ### 新增:`scripts/verify-isolation.mjs`
40
+ 在本机临时仓库里真开 worktree、真改文件、真提交、真回收,输出 9 步结论:
41
+ ```
42
+ PASS 临时仓库就绪
43
+ PASS 开隔离工作区 <tmp>
44
+ epo\.dsh-zhuli\zhuli-demo
45
+ PASS 隔离区里能改能提交 d08af28 fix: #42
46
+ PASS 主工作区没被污染 README.md 仍是原样
47
+ PASS 回收隔离区 1 个 worktree
48
+ PASS 回收后分支仍在(remove 不管分支) zhuli/demo
49
+ PASS 显式删分支才真的清掉 zhuli/demo 已删除
50
+ PASS 数量线回收最旧的 3 个 wt6,wt7,wt8
51
+ PASS 孤儿目录 prune 后不再挂着 1 个 worktree
52
+ PASS 隔离链路 9 步全部通过
53
+ ```
54
+
55
+ ### 它纠正了一个误解
56
+ `git worktree remove` **不会**删分支。产品里是显式再跑 `git branch -D` 才清理干净 ——
57
+ 脚本第一版断言"分支随回收删除",直接 FAIL,按产品的真实命令序列改写后才通过。
58
+ **这就是"读代码以为懂"和"真跑一遍"的差别。**
59
+
60
+ ### 门禁
61
+ `preflight --fast` 第 **13** 项:`PASS 隔离链路 9 步全部通过`(1.3 秒)。
62
+
5
63
  ## [0.9.26] - 2026-11-02 —— 客户会读到的文字有了快照,改动必须是有意的
6
64
 
7
65
  ### 做法
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="assets/icon-180.png" width="88" height="88" alt="">
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-0.9.26-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.28-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
7
7
  [![npm](https://img.shields.io/npm/v/dsh-session-superagent.svg)](https://www.npmjs.com/package/dsh-session-superagent)
8
8
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-plugin-orange.svg)](https://github.com/topics/dsh-plugin)
9
9
 
@@ -107,7 +107,10 @@ dsh plugin install /path/to/dsh-session-superagent
107
107
  (面板会写「约 X 分钟后可再唤醒」)。默认上限下,**会话级 12 次/小时**:
108
108
  守 3 个活跃仓库时约能处理 12 条/小时,其余攒到下一小时(离线模拟实测,见 docs/kb)。
109
109
  - 隔离执行会在仓库下留 `.dsh-zhuli/` 副本:默认**最多 5 个**、超 3 天回收;
110
- 副本体积≈该仓库工作树大小。
110
+ 副本体积≈该仓库工作树大小。开隔离区时会自动把它写进 `.git/info/exclude`,
111
+ 所以**不会污染 `git status`**、也不会误提交。
112
+ - 两个会话守同一个仓库时,隔离区互不影响;但如果它们改了**同一个文件的同一区域**,
113
+ 后合并的那条会产生 git 冲突(这是 git 的语义,不是产品缺陷)。
111
114
 
112
115
  ## 开发
113
116
 
package/client.js CHANGED
@@ -14,7 +14,7 @@ window.__ModuleLoader__.load({
14
14
  const { useCallback, useEffect, useRef, useState } = React
15
15
 
16
16
  // 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
17
- const CLIENT_VERSION = '0.9.26'
17
+ const CLIENT_VERSION = '0.9.28'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
package/lib/index.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
 
35
35
  export const name = 'dsh-session-superagent'
36
36
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
37
- export const SERVER_VERSION = '0.9.26'
37
+ export const SERVER_VERSION = '0.9.28'
38
38
  export const inject = ['tools', 'agents', 'webServer']
39
39
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
40
40
  const DEFAULT_SESSION_WAKES = 12
@@ -396,6 +396,30 @@ async function cleanupWorktrees(workdir, keepDays = 3, keepCount = 5, options =
396
396
  * 给一次唤醒准备隔离工作区:在目标仓库上开一个一次性 git worktree。
397
397
  * 失败不阻断唤醒 —— 退化成普通模式,并在消息里说明原因。
398
398
  */
399
+ /**
400
+ * 让隔离区不污染客户的 `git status`。
401
+ *
402
+ * 隔离区开在仓库内的 .dsh-zhuli/ 下,默认是**未跟踪目录** ——
403
+ * 客户一切 git status 就会看到它,甚至可能顺手 git add 进去。
404
+ * 写到 `.git/info/exclude`(本地、不提交、不修改客户的 .gitignore)最合适。
405
+ */
406
+ async function ensureIsolationExcluded(workdir) {
407
+ try {
408
+ const res = await run('git', ['-C', workdir, 'rev-parse', '--git-path', 'info/exclude'], { timeoutMs: 15000 })
409
+ if (res.code !== 0) return false
410
+ const file = String(res.stdout || '').trim()
411
+ if (!file) return false
412
+ let current = ''
413
+ try { current = readFileSync(file, 'utf8') } catch { current = '' }
414
+ if (current.split(/\r?\n/).includes('.dsh-zhuli/')) return true
415
+ const next = current + (current.endsWith('\n') || current === '' ? '' : '\n') + '.dsh-zhuli/' + '\n'
416
+ writeFileSync(file, next)
417
+ return true
418
+ } catch {
419
+ return false
420
+ }
421
+ }
422
+
399
423
  async function prepareIsolation(entry) {
400
424
  if (!entry || !entry.isolated || !entry.workdir) return null
401
425
  const plan = worktreePlan({ workdir: entry.workdir, repo: entry.repo, sessionTag: entry.sessionId })
@@ -405,6 +429,7 @@ async function prepareIsolation(entry) {
405
429
  lastRunAt: Number(entry.lastCleanupAt) || 0,
406
430
  onRun: () => { entry.lastCleanupAt = Date.now() },
407
431
  })
432
+ await ensureIsolationExcluded(entry.workdir)
408
433
  const res = await run('git', ['-C', entry.workdir, 'worktree', 'add', plan.dir, '-b', plan.branch], { timeoutMs: 45000 })
409
434
  if (res.code !== 0) {
410
435
  return { error: redact([res.stderr, res.stdout].filter(Boolean).join(' ')).slice(0, 200) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.26",
3
+ "version": "0.9.28",
4
4
  "description": "Session-level superagent for DeepSeek Harness: watch a GitHub repository and wake a session when something needs doing. Credentials never reach the model.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",