@twinsearth/dsh-fang 3.1.17 → 3.1.19

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
@@ -3,24 +3,37 @@
3
3
  [![SDK: MIT](https://img.shields.io/badge/SDK-MIT-green.svg)](LICENSE-SDK)
4
4
  [![npm latest](https://img.shields.io/npm/v/@twinsearth/dsh-fang.svg?label=npm&color=red)](https://www.npmjs.com/package/@twinsearth/dsh-fang)
5
5
 
6
- # 瓮城
7
6
 
8
- ## 让DSH不再需要反复重启客户端:
9
- 加载、运行、更新、回滚、卸载、回收,全生命周期管理。
7
+ # 瓮城:DSH 的第一台虚拟机!
10
8
 
11
- ### 技术原理:DeepSeekHarness的第一台虚拟机!
9
+ > Dsh-瓮城,诞生于一群热爱折腾、也被折腾过无数次的极客之手。
10
+ > 我们深知在「自进化 AI」时代,**「如何安全地尝试新事物」比「新事物本身」更重要**。
12
11
 
13
- 1.用dsh-Web,当瓮城完成风险阻隔&审批(Beta)
12
+ ## 如果你是以下三类人,瓮城就是为你量身定制的
14
13
 
15
- 2.DeepSeekHarness,当主城保存原样不变(稳定版)
14
+ ### 1. 插件开发狂魔
15
+ 每天要写 N 个新插件、改几百次代码。以前改一次重启一次 DSH;现在在瓮城里随便热更新,坏了直接秒回滚。
16
+
17
+ ### 2. 多任务并发狂
18
+ 一个窗口跑数据分析,一个窗口写爬虫,一个窗口做长周期测试。瓮城让你像开浏览器一样「多开不崩」,并且各跑各的绝对隔离。
19
+
20
+ ### 3. 安全焦虑症患者
21
+ 不敢把客户端交给第三方插件,怕乱删文件、怕被盗取 API Key。瓮城的审核系统和独立沙箱,把危险代码安排得明明白白。
22
+
23
+ ---
24
+
25
+ ## 它怎么做到
16
26
 
17
27
  **母体大脑 + 分身器官 + 容器兜底**:
18
28
 
19
- 一个只读母体,每个任务派生一个用完即弃的子 dsh-Web;
29
+ - 一个只读母体,每个任务派生一个用完即弃的子 dsh-Web;
30
+ - 开发都在分身里,母体只在「提升」时被显式更新;
31
+ - 崩溃不扩散、污染不残留、插件不串味。
20
32
 
21
- 开发都在分身里,母体只在「提升」时被显式更新。
33
+ > 技术定位:**DeepSeek Harness 的第一台虚拟机**。
34
+ > 用 dsh-Web 当瓮城完成风险阻隔与审批(Beta),把 DeepSeek Harness 当主城保存原样不变(稳定版)。
22
35
 
23
- 崩溃不扩散、污染不残留、插件不串味。
36
+ ---
24
37
 
25
38
  > v2.3.1 把「瓮城」做进 Web UI(左侧导航 + 3:7 分屏控制面板 + 双击派生 + 母体/分身会话继续开发);
26
39
  > v2.0.0 按三层拓扑重新部署,
package/client.js CHANGED
@@ -6399,15 +6399,189 @@ window.__ModuleLoader__.load({
6399
6399
  })
6400
6400
  }
6401
6401
 
6402
+
6403
+ /**
6404
+ * v3.1.19:分身 Web 的界面收敛。
6405
+ *
6406
+ * 1) 隐藏左侧栏「插件」入口 —— 分身里不允许进入插件设置页(避免用户在一次性沙箱里
6407
+ * 改动宿主插件配置,导致下一次派生继承脏配置)。
6408
+ * 2) 「启动」类按钮在分身里变成真正无操作:capture 阶段拦下点击,
6409
+ * 宿主处理器不执行 → 不切换面板、不弹提醒、不打印错误。
6410
+ * (此前用户点「启动」会收到一条无法处理的报错,属噪音。)
6411
+ *
6412
+ * 只在 role === 'fork' 时生效;母体/元主不受影响。
6413
+ */
6414
+ function mountForkUiLocks() {
6415
+ if (typeof document === 'undefined' || !document.body) return () => {}
6416
+ const doc = document
6417
+ let disposed = false
6418
+ let active = false
6419
+ let timer = 0
6420
+ let observer = null
6421
+ const NAV_TEXTS = ['插件']
6422
+ const ACTION_TEXTS = ['启动', '启动插件', '开始使用', '启用']
6423
+
6424
+ const isPanelRow = (node) => {
6425
+ try {
6426
+ if (!node || node.tagName !== 'BUTTON') return false
6427
+ const cls = String(node.className || '')
6428
+ return /panelRow/i.test(cls)
6429
+ } catch { return false }
6430
+ }
6431
+
6432
+ const hidePluginNav = () => {
6433
+ if (disposed || !active) return
6434
+ for (const node of doc.querySelectorAll('button')) {
6435
+ if (!isPanelRow(node)) continue
6436
+ const text = String(node.textContent || '').trim()
6437
+ if (!NAV_TEXTS.includes(text)) continue
6438
+ if (node.dataset.fangForkHidden === '1' && node.hidden) continue
6439
+ node.dataset.fangForkHidden = '1'
6440
+ node.hidden = true
6441
+ node.setAttribute('aria-hidden', 'true')
6442
+ node.style.setProperty('display', 'none', 'important')
6443
+ }
6444
+ }
6445
+
6446
+ const onClickCapture = (event) => {
6447
+ if (!active || disposed) return
6448
+ const target = event.target
6449
+ const button = target && typeof target.closest === 'function' ? target.closest('button') : null
6450
+ if (!button) return
6451
+ const text = String(button.textContent || '').trim()
6452
+ // ① 侧栏「插件」入口:双重保险(DOM 已隐藏,这里再拦一次点击/键盘激活)
6453
+ if (isPanelRow(button) && NAV_TEXTS.includes(text)) {
6454
+ event.preventDefault()
6455
+ event.stopPropagation()
6456
+ event.stopImmediatePropagation()
6457
+ return
6458
+ }
6459
+ // ② 插件页「启动」:无操作(不切换、不提醒、不报错)
6460
+ const isAction = ACTION_TEXTS.some((label) => text === label || text.startsWith(label))
6461
+ if (!isAction) return
6462
+ event.preventDefault()
6463
+ event.stopPropagation()
6464
+ event.stopImmediatePropagation()
6465
+ // ③ 万一宿主已被别处触发过提示,把残留的错误气泡收掉(仅限含错误语义的气泡)
6466
+ setTimeout(() => {
6467
+ if (disposed) return
6468
+ for (const node of doc.querySelectorAll('[role="alert"],[class*="toast"],[class*="Toast"]')) {
6469
+ const body = String(node.textContent || '')
6470
+ if (!/失败|错误|异常|无法|不能|不可|不允许|拒绝|failed|error/i.test(body)) continue
6471
+ if (node.dataset.fangForkAlertHidden === '1') continue
6472
+ node.dataset.fangForkAlertPrevDisplay = node.style.display || ''
6473
+ node.dataset.fangForkAlertHidden = '1'
6474
+ node.style.setProperty('display', 'none', 'important')
6475
+ }
6476
+ }, 60)
6477
+ }
6478
+
6479
+ const activate = () => {
6480
+ if (active || disposed) return
6481
+ active = true
6482
+ hidePluginNav()
6483
+ doc.addEventListener('click', onClickCapture, true)
6484
+ try {
6485
+ observer = new MutationObserver(() => { hidePluginNav() })
6486
+ observer.observe(doc.body, { childList: true, subtree: true })
6487
+ } catch { observer = null }
6488
+ timer = setInterval(hidePluginNav, 1500)
6489
+ try { timer && timer.unref && timer.unref() } catch { /* ignore */ }
6490
+ hidePluginNav()
6491
+ }
6492
+
6493
+ void (async () => {
6494
+ try {
6495
+ const role = await detectWebRole()
6496
+ if (disposed || role !== 'fork') return
6497
+ activate()
6498
+ } catch { /* 识别失败:保持原样,不误伤母体 */ }
6499
+ })()
6500
+
6501
+ return () => {
6502
+ disposed = true
6503
+ active = false
6504
+ if (timer) { clearInterval(timer); timer = 0 }
6505
+ try { observer?.disconnect() } catch { /* ignore */ }
6506
+ observer = null
6507
+ try { doc.removeEventListener('click', onClickCapture, true) } catch { /* ignore */ }
6508
+ // 恢复被隐藏的入口与提示,避免热卸载后宿主界面残缺
6509
+ for (const node of doc.querySelectorAll('button[data-fang-fork-hidden="1"]')) {
6510
+ try {
6511
+ node.hidden = false
6512
+ node.removeAttribute('aria-hidden')
6513
+ node.style.removeProperty('display')
6514
+ delete node.dataset.fangForkHidden
6515
+ } catch { /* ignore */ }
6516
+ }
6517
+ for (const node of doc.querySelectorAll('[data-fang-fork-alert-hidden="1"]')) {
6518
+ try {
6519
+ const prev = node.dataset.fangForkAlertPrevDisplay || ''
6520
+ if (prev) node.style.display = prev
6521
+ else node.style.removeProperty('display')
6522
+ delete node.dataset.fangForkAlertPrevDisplay
6523
+ delete node.dataset.fangForkAlertHidden
6524
+ } catch { /* ignore */ }
6525
+ }
6526
+ }
6527
+ }
6528
+
6529
+
6530
+ /**
6531
+ * v3.1.19:元主 / 分身 Web 的「关闭二次确认」。
6532
+ *
6533
+ * 右上角直接关闭很容易误触(尤其是把分身窗口当临时浏览器用时)。
6534
+ * 这里注册 beforeunload:浏览器会弹出原生「离开此网站?」确认框,
6535
+ * 用户确认后才真正关闭;母体(主会话)不注册,避免打断正常主机操作。
6536
+ */
6537
+ function mountCloseConfirm() {
6538
+ if (typeof window === 'undefined') return () => {}
6539
+ let installed = false
6540
+ let disposed = false
6541
+ const onBeforeUnload = (event) => {
6542
+ try {
6543
+ event.preventDefault()
6544
+ // 现代浏览器忽略自定义文案,但仍要求设置 returnValue 才会弹确认框
6545
+ event.returnValue = '确认关闭瓮城窗口?未保存的分身状态会丢失。'
6546
+ } catch { /* ignore */ }
6547
+ return event.returnValue
6548
+ }
6549
+ const activate = () => {
6550
+ if (installed || disposed) return
6551
+ installed = true
6552
+ window.addEventListener('beforeunload', onBeforeUnload)
6553
+ // 兜底:宿主若用 history/路由隐藏关闭入口,键盘快捷键也走同一确认
6554
+ window.addEventListener('unload', () => {}, { once: true })
6555
+ }
6556
+ void (async () => {
6557
+ try {
6558
+ const role = await detectWebRole()
6559
+ if (disposed) return
6560
+ // 母体是主机式长驻窗口,不打断;元主/分身需要确认
6561
+ if (role === 'essence' || role === 'fork') activate()
6562
+ } catch { /* ignore */ }
6563
+ })()
6564
+ return () => {
6565
+ disposed = true
6566
+ if (!installed) return
6567
+ installed = false
6568
+ try { window.removeEventListener('beforeunload', onBeforeUnload) } catch { /* ignore */ }
6569
+ }
6570
+ }
6571
+
6402
6572
  // ── 插件入口 ──────────────────────────────────────────────────────────
6403
6573
  return {
6404
6574
  mountPanel,
6405
- ...(typeof window !== 'undefined' && window.__FANG_TEST_HOOK__ ? { __renderDecisionMini: renderDecisionMini, __mountWebRoleBadge: mountWebRoleBadge, __detectWebRole: detectWebRole, __mountDecisionRelay: mountDecisionRelay } : {}),
6575
+ ...(typeof window !== 'undefined' && window.__FANG_TEST_HOOK__ ? { __renderDecisionMini: renderDecisionMini, __mountWebRoleBadge: mountWebRoleBadge, __detectWebRole: detectWebRole, __mountForkUiLocks: mountForkUiLocks, __mountCloseConfirm: mountCloseConfirm, __mountDecisionRelay: mountDecisionRelay } : {}),
6406
6576
  inject: ['slots'],
6407
6577
  apply(ctx) {
6408
6578
  const disposers = []
6409
6579
  // v3.1.12:侧栏 HARNESS 右侧的 Web 端身份徽标(母体 / 元主 / 分身)。
6410
6580
  disposers.push(mountWebRoleBadge())
6581
+ // v3.1.19:分身 Web 界面收敛(隐藏「插件」入口 + 「启动」无操作)。
6582
+ disposers.push(mountForkUiLocks())
6583
+ // v3.1.19:元主 / 分身 Web 关闭前二次确认(防误触)。
6584
+ disposers.push(mountCloseConfirm())
6411
6585
  // 母体 Web = DSH 主会话视图;Web 端直接切回 conversation 面板。
6412
6586
  const goMother = () => {
6413
6587
  try {
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
- "title": "dsh-Fang (mother/fork plugin development)",
4
- "description": "One readonly mother plus a disposable child dsh-Web per task: crash containment without restarting the mother, with scoring, approval, audit and promotion gates."
3
+ "title": "Fangcheng: DSH's First Virtual Machine!",
4
+ "description": "Dsh-Fangcheng was born from a group of geeks who love tinkering — and have been burned by it more times than we can count. In the era of self-evolving AI, we believe that \"how to safely try something new\" matters more than \"the new thing itself\".\n\nIf you are one of these three, Fangcheng was built for you:\n1. The plugin-building maniac: writing N new plugins a day and changing code hundreds of times. You used to restart DSH after every edit; now you hot-reload inside Fangcheng, and a broken build rolls back instantly.\n2. The multi-tasker: one window for data analysis, one for a crawler, one for long-running tests. Fangcheng lets you open as many as you like without crashing — each in its own absolute isolation.\n3. The security worrier: unwilling to hand your client to third-party plugins, afraid of deleted files or stolen API keys. Fangcheng's review gates and independent sandboxes keep risky code boxed in."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
- "title": "dsh-Fang(母体-分身插件开发)",
4
- "description": "一个只读母体 + 每个任务一个用完即弃的子 dsh-Web:崩溃不外溢、不重启母体,并带评分、审批、审计与提升门禁。"
3
+ "title": "瓮城:DSH的第一台虚拟机!",
4
+ "description": "Dsh-瓮城,诞生于一群热爱折腾、也被折腾过无数次的极客之手。我们深知在“自进化 AI”时代,“如何安全地尝试新事物”比“新事物本身”更重要!\n\n如果你是以下三类人,瓮城就是为你量身定制的:\n1. 插件开发狂魔:每天要写 N 个新插件、改几百次代码。以前改一次重启一次 DSH;现在在瓮城里随便热更新,坏了直接秒回滚。\n2. 多任务并发狂:一个窗口跑数据分析,一个窗口写爬虫,一个窗口做长周期测试。瓮城让你像开浏览器一样“多开不崩”,并各跑各的绝对隔离。\n3. 安全焦虑症患者:不敢把客户端交给第三方插件,怕乱删文件、怕被盗取 API Key。瓮城的审核系统和独立沙箱,把危险代码安排得明明白白。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/dsh-fang",
3
- "version": "3.1.17",
3
+ "version": "3.1.19",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "dsh-Fang (瓮城) — mother/fork plugin development environment for DeepSeek Harness: one readonly mother, a disposable child dsh-Web per task.",
@@ -129,7 +129,7 @@ export const AUDIT = {
129
129
  RUNTIME_ERROR: 'runtime-error',
130
130
  }
131
131
 
132
- export const FANG_VERSION = '3.1.17'
132
+ export const FANG_VERSION = '3.1.19'
133
133
 
134
134
  /**
135
135
  * @typedef {object} ForkInfo