@twinsearth/dsh-fang 3.1.22 → 3.1.23

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 (112) hide show
  1. package/client.js +36 -2
  2. package/package.json +1 -1
  3. package/src/kernel/types.mjs +1 -1
  4. package/LICENSES/LICENSES/cordis-MIT.txt +0 -39
  5. package/defaults/defaults/umbrella-rules.yaml +0 -113
  6. package/sdk/sdk/README.md +0 -65
  7. package/sdk/sdk/examples/status-badge/README.md +0 -16
  8. package/sdk/sdk/examples/status-badge/client.js +0 -60
  9. package/sdk/sdk/examples/status-badge/cordis.patch.yml +0 -7
  10. package/sdk/sdk/examples/status-badge/index.js +0 -12
  11. package/sdk/sdk/examples/status-badge/package.json +0 -24
  12. package/sdk/sdk/templates/plugin/README.md +0 -36
  13. package/sdk/sdk/templates/plugin/client.js +0 -35
  14. package/sdk/sdk/templates/plugin/cordis.patch.yml +0 -8
  15. package/sdk/sdk/templates/plugin/icon.svg +0 -5
  16. package/sdk/sdk/templates/plugin/index.js +0 -23
  17. package/sdk/sdk/templates/plugin/locale/en.json +0 -6
  18. package/sdk/sdk/templates/plugin/package.json +0 -36
  19. package/src/src/compose.mjs +0 -67
  20. package/src/src/contract/client.js +0 -86
  21. package/src/src/contract/constants.js +0 -79
  22. package/src/src/contract/envelope.js +0 -83
  23. package/src/src/contract/index.js +0 -19
  24. package/src/src/contract/negotiate.js +0 -106
  25. package/src/src/contract/server.js +0 -77
  26. package/src/src/contract/transports.js +0 -301
  27. package/src/src/index.mjs +0 -11
  28. package/src/src/kernel/core.mjs +0 -100
  29. package/src/src/kernel/extensions.mjs +0 -61
  30. package/src/src/kernel/fsx.mjs +0 -349
  31. package/src/src/kernel/index.mjs +0 -21
  32. package/src/src/kernel/ledger.mjs +0 -94
  33. package/src/src/kernel/paths.mjs +0 -182
  34. package/src/src/kernel/role.mjs +0 -68
  35. package/src/src/kernel/rounds.mjs +0 -172
  36. package/src/src/kernel/schema.mjs +0 -5
  37. package/src/src/kernel/types.mjs +0 -264
  38. package/src/src/kernel/vendor/cosmokit.mjs +0 -421
  39. package/src/src/kernel/vendor/schemastery.mjs +0 -638
  40. package/src/src/lib/adapter-client.mjs +0 -383
  41. package/src/src/lib/adapter-protocol.mjs +0 -243
  42. package/src/src/lib/ai-secret-store.mjs +0 -202
  43. package/src/src/lib/boot-guard.mjs +0 -182
  44. package/src/src/lib/branch-store.mjs +0 -84
  45. package/src/src/lib/branch.mjs +0 -74
  46. package/src/src/lib/bridge-client.mjs +0 -133
  47. package/src/src/lib/broker-adapter.mjs +0 -67
  48. package/src/src/lib/broker.mjs +0 -45
  49. package/src/src/lib/business-producers.mjs +0 -109
  50. package/src/src/lib/command-cache.mjs +0 -209
  51. package/src/src/lib/compat.mjs +0 -170
  52. package/src/src/lib/composer-journal.mjs +0 -128
  53. package/src/src/lib/container/index.mjs +0 -806
  54. package/src/src/lib/decision-events.mjs +0 -129
  55. package/src/src/lib/decision-ingest-client.mjs +0 -41
  56. package/src/src/lib/decision-outbox.mjs +0 -129
  57. package/src/src/lib/default-essence.mjs +0 -61
  58. package/src/src/lib/desktop-launch.mjs +0 -138
  59. package/src/src/lib/essence.mjs +0 -1211
  60. package/src/src/lib/fork-client.mjs +0 -410
  61. package/src/src/lib/fork-config-lock.mjs +0 -153
  62. package/src/src/lib/fork-seed.mjs +0 -304
  63. package/src/src/lib/fork-supervision-settings.mjs +0 -58
  64. package/src/src/lib/fork-supervisor.mjs +0 -122
  65. package/src/src/lib/fs-guard.mjs +0 -28
  66. package/src/src/lib/http-auth.mjs +0 -162
  67. package/src/src/lib/idle-audit.mjs +0 -178
  68. package/src/src/lib/interaction-poke.mjs +0 -61
  69. package/src/src/lib/mirror-etag.mjs +0 -92
  70. package/src/src/lib/mirror-official-source.mjs +0 -93
  71. package/src/src/lib/mirror.mjs +0 -478
  72. package/src/src/lib/mother-link.mjs +0 -156
  73. package/src/src/lib/mutex.mjs +0 -31
  74. package/src/src/lib/permissions.mjs +0 -115
  75. package/src/src/lib/pnpm-store.mjs +0 -189
  76. package/src/src/lib/preferences.mjs +0 -212
  77. package/src/src/lib/producer-contract.mjs +0 -162
  78. package/src/src/lib/reflow.mjs +0 -41
  79. package/src/src/lib/remote.mjs +0 -408
  80. package/src/src/lib/restart-contract.mjs +0 -650
  81. package/src/src/lib/roots.mjs +0 -30
  82. package/src/src/lib/rule-registry.mjs +0 -1101
  83. package/src/src/lib/runtime-capture.mjs +0 -307
  84. package/src/src/lib/semaphore.mjs +0 -34
  85. package/src/src/lib/session-bundle.mjs +0 -138
  86. package/src/src/lib/session-format.mjs +0 -658
  87. package/src/src/lib/sse-parser.mjs +0 -102
  88. package/src/src/lib/ssrf-guard.mjs +0 -170
  89. package/src/src/lib/status-store.mjs +0 -257
  90. package/src/src/lib/task-handle.mjs +0 -622
  91. package/src/src/lib/ui-actions.mjs +0 -55
  92. package/src/src/lib/umbrella.mjs +0 -1661
  93. package/src/src/lib/upgrade-coordinator.mjs +0 -107
  94. package/src/src/lib/upgrade-status.mjs +0 -43
  95. package/src/src/plugins/adapter.mjs +0 -1468
  96. package/src/src/plugins/approver.mjs +0 -1210
  97. package/src/src/plugins/auditor.mjs +0 -330
  98. package/src/src/plugins/buffer-keeper.mjs +0 -522
  99. package/src/src/plugins/decision-center.mjs +0 -2265
  100. package/src/src/plugins/forker.mjs +0 -1594
  101. package/src/src/plugins/healer.mjs +0 -664
  102. package/src/src/plugins/hot-reloader.mjs +0 -274
  103. package/src/src/plugins/imports.mjs +0 -247
  104. package/src/src/plugins/orchestrator.mjs +0 -3806
  105. package/src/src/plugins/restart-guard.mjs +0 -948
  106. package/src/src/plugins/router.mjs +0 -714
  107. package/src/src/plugins/scorer.mjs +0 -624
  108. package/src/src/plugins/session-bridge.mjs +0 -166
  109. package/src/src/plugins/session-catalog.mjs +0 -771
  110. package/src/src/plugins/session-router.mjs +0 -125
  111. package/src/src/plugins/session-sync.mjs +0 -171
  112. package/src/src/plugins/umbrella.mjs +0 -419
package/client.js CHANGED
@@ -6452,7 +6452,9 @@ window.__ModuleLoader__.load({
6452
6452
  const matchNav = (text) => {
6453
6453
  const value = clean(text)
6454
6454
  if (!value) return false
6455
- return NAV_HIDDEN.some((label) => value === label || value.startsWith(label + ' '))
6455
+ // 实机发现:宿主会把快捷键拼在文案后面(「新会话Ctrl+Alt+N」),
6456
+ // 因此按「标签前缀」匹配,而不是要求空格分隔。
6457
+ return NAV_HIDDEN.some((label) => value === label || value.startsWith(label))
6456
6458
  }
6457
6459
  const isPluginNav = (text) => {
6458
6460
  const value = clean(text)
@@ -6480,6 +6482,37 @@ window.__ModuleLoader__.load({
6480
6482
  }
6481
6483
  }
6482
6484
 
6485
+ /**
6486
+ * v3.1.23 实机补充:等工作区不是单个按钮,而是「工作区」分组标题 + 若干工作区行。
6487
+ * 元主只做插件控制台,因此整段收起:标题所在分组 + 所有工作区行。
6488
+ */
6489
+ const hideWorkspaceBlock = () => {
6490
+ if (disposed || !active) return
6491
+ // ① 分组标题:文本恰好是「工作区」的任意元素(标题/按钮/标签)
6492
+ for (const node of doc.querySelectorAll('div,span,h2,h3,button,a')) {
6493
+ const text = clean(node.textContent)
6494
+ if (text !== '工作区' && text !== 'Workspace') continue
6495
+ const blockNode = node.closest('[class*="panelRow"],[class*="workspaceRow"],[class*="section"],[class*="group"]') || node.parentElement
6496
+ if (!blockNode || blockNode === doc.body) continue
6497
+ if (blockNode.dataset.fangEssenceHidden === '1') continue
6498
+ blockNode.dataset.fangEssenceHidden = '1'
6499
+ blockNode.hidden = true
6500
+ blockNode.setAttribute('aria-hidden', 'true')
6501
+ blockNode.style.setProperty('display', 'none', 'important')
6502
+ }
6503
+ // ② 工作区行(默认工作区 / 某个工作区名)
6504
+ for (const node of doc.querySelectorAll('button,div,li')) {
6505
+ if (!node || node.dataset.fangEssenceHidden === '1') continue
6506
+ const text = clean(node.textContent)
6507
+ if (!/^(默认工作区|工作区|Workspace)/.test(text)) continue
6508
+ if (!node.closest('[class*="sidebar"],[class*="sideBar"],[class*="sider"],nav,aside')) continue
6509
+ node.dataset.fangEssenceHidden = '1'
6510
+ node.hidden = true
6511
+ node.setAttribute('aria-hidden', 'true')
6512
+ node.style.setProperty('display', 'none', 'important')
6513
+ }
6514
+ }
6515
+
6483
6516
  /** 隐藏输入区:元主不执行会话/指令(避免误以为能在这里跑任务)。 */
6484
6517
  const hideComposer = () => {
6485
6518
  if (disposed || !active) return
@@ -6553,6 +6586,7 @@ window.__ModuleLoader__.load({
6553
6586
  const apply = () => {
6554
6587
  if (disposed) return
6555
6588
  hideNavRows()
6589
+ hideWorkspaceBlock()
6556
6590
  hideComposer()
6557
6591
  insertNotice()
6558
6592
  landOnPlugins()
@@ -6626,7 +6660,7 @@ window.__ModuleLoader__.load({
6626
6660
  for (const node of doc.querySelectorAll('button')) {
6627
6661
  if (!isPanelRow(node)) continue
6628
6662
  const navText = String(node.textContent || '').trim()
6629
- if (!isPluginNavText(navText) && !/^新会话$|^新建会话$/.test(navText)) continue
6663
+ if (!isPluginNavText(navText) && !/^新会话|^新建会话/.test(navText)) continue
6630
6664
  if (node.dataset.fangForkHidden === '1' && node.hidden) continue
6631
6665
  node.dataset.fangForkHidden = '1'
6632
6666
  node.hidden = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/dsh-fang",
3
- "version": "3.1.22",
3
+ "version": "3.1.23",
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.22'
132
+ export const FANG_VERSION = '3.1.23'
133
133
 
134
134
  /**
135
135
  * @typedef {object} ForkInfo
@@ -1,39 +0,0 @@
1
- # Third-party licenses
2
-
3
- This directory contains license texts for third-party components included in this repository.
4
-
5
- ## cordis (schemastery, cosmokit) — MIT
6
-
7
- Upstream project: https://github.com/shigma/cordis
8
- Copyright (c) 2022-present Shigma and cordis contributors.
9
-
10
- Files vendored into `src/kernel/vendor/`:
11
-
12
- - `schemastery.mjs` — runtime config schema library (import paths rewritten to a sibling file)
13
- - `cosmokit.mjs` — utility library used by schemastery
14
-
15
- ```
16
- MIT License
17
-
18
- Copyright (c) 2022-present Shigma and cordis contributors
19
-
20
- Permission is hereby granted, free of charge, to any person obtaining a copy
21
- of this software and associated documentation files (the "Software"), to deal
22
- in the Software without restriction, including without limitation the rights
23
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
- copies of the Software, and to permit persons to whom the Software is
25
- furnished to do so, subject to the following conditions:
26
-
27
- The above copyright notice and this permission notice shall be included in all
28
- copies or substantial portions of the Software.
29
-
30
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
- SOFTWARE.
37
- ```
38
-
39
- > If the upstream license changes, the upstream `LICENSE` at the URL above governs.
@@ -1,113 +0,0 @@
1
- # dsh-Fang v2.8.1 — Umbrella 推荐基线配置(随包分发,项目不可替换,只能叠加)
2
- #
3
- # 加载顺序(后加载的层按 id 覆盖先加载的层;未列出的规则保持内置默认):
4
- # 1) 本文件(包内基线) ← defaults/umbrella-rules.yaml
5
- # 2) 项目级 <project>/.dsh/umbrella-rules.yaml(插件配置 rulesFile)
6
- # 3) 环境级 $UMBRELLA_RULES_PATH(CI/部署注入,可选)
7
- #
8
- # 锁定语义:带 non-negotiable / hard-deny 标签的规则不可被**关闭**、不可被**降低灯色**;
9
- # 允许项目追加 pattern(扩大覆盖面)或提升灯色(更严格)。
10
- # 项目尝试关闭硬规则 → 该层错误;若该层 failOnInvalidPattern: true → 整层拒绝,回退到基线。
11
- #
12
- # 说明:本文件刻意**只显式写硬规则与兜底**。可调规则留空 = 使用内置默认值,
13
- # 项目按需在自己的叠加层里覆盖(示例见文件末尾注释与 docs/RULES-BASELINE.md)。
14
-
15
- version: 1
16
-
17
- settings:
18
- failOnUnknownRule: false # 未知 id 只警告,不阻断(基线可能领先于代码)
19
- failOnInvalidPattern: true # 正则/声明式规则编译失败视为配置错误,整层拒绝(宁可不启动)
20
- rejectUnsafeRegex: true # 拒绝明显灾难回溯的正则形状
21
-
22
- rules:
23
- # ── 硬规则:显式锁定(不可关闭、不可降级)──────────────────────────────
24
- - id: dsh-lifecycle
25
- enabled: true
26
- light: red
27
- priority: 10
28
- reason: "DSH 宿主的生命周期动作(重启/终止/进程级),必须转交 restart-guard 审批"
29
- tags: [hard-deny, non-negotiable, delegate-to-restart-guard]
30
-
31
- - id: destructive-command
32
- enabled: true
33
- light: red
34
- priority: 20
35
- reason: "破坏性 shell 命令(rm -rf / format / shutdown / 强制推送等),一律红色"
36
- tags: [hard-deny, non-negotiable]
37
-
38
- - id: credential-access
39
- enabled: true
40
- light: red
41
- priority: 30
42
- reason: "读取凭据路径(.ssh/.aws/.gnupg/.git-credentials 等),唯一硬拒绝出口"
43
- tags: [hard-deny, non-negotiable]
44
-
45
- # ── 兜底:安全网(不可关闭)──────────────────────────────────────────────
46
- # 未登记的工具/没有可识别目标时落到这里;优先级 9999 保证它永远最后。
47
- - id: unknown-tool
48
- enabled: true
49
- light: yellow
50
- priority: 9999
51
- reason: "未知工具或目标:行为不可预测,保守判黄(需审批)"
52
- tags: [conservative, non-negotiable]
53
-
54
- # ── 可调规则:留空 = 使用内置默认。下面是**推荐值**(注释形式),项目按需覆盖 ──
55
- #
56
- # 用于参考的默认(与 DEFAULT_RULE_PRIORITIES 一致):
57
- # network-allowlisted blue 40 外连命中允许列表 → 放行 + 标记
58
- # network-egress yellow 50 外连未在允许列表 → 拆审批
59
- # dynamic-import yellow 60 动态加载未评分模块 → 先扫描
60
- # write-in-buffer blue 70 写沙箱缓冲区 → 放行 + 标记
61
- # write-in-allowlist blue 80 写允许列表路径 → 放行 + 标记
62
- # write-production yellow 90 写生产区 → 需审批
63
- # write-outside-buffer yellow 100 写越界 → 需审批
64
- # exec-read-only blue 110 只读 shell(无重定向)→ 放行 + 标记
65
- # exec-side-effect yellow 120 shell 有副作用 → 需审批
66
- # read-in-buffer green 130 读沙箱缓冲区 → 自动放行
67
- # read-outside-buffer blue 140 读缓冲区外 → 放行 + 标记
68
- #
69
- # 项目级覆盖示例(写在 <project>/.dsh/umbrella-rules.yaml):
70
- #
71
- # version: 1
72
- # settings:
73
- # failOnInvalidPattern: true
74
- # rules:
75
- # # 更严格:越界写从黄升红
76
- # - id: write-outside-buffer
77
- # light: red
78
- # reason: "本项目:任何越界写都直接拒绝"
79
- #
80
- # # 更严格:生产区写也需要人工审批(升红)
81
- # - id: write-production
82
- # light: red
83
- #
84
- # # 追加凭据 pattern(硬规则允许"扩大覆盖面",不允许关闭)
85
- # - id: credential-access
86
- # pathPatterns:
87
- # - re: "\\.npmrc$"
88
- # label: "npm registry token"
89
- # - re: "secrets[\\\\/]"
90
- # label: "project secrets directory"
91
- #
92
- # # 项目专属声明式规则
93
- # - id: project-build-guard
94
- # category: destructive
95
- # light: red
96
- # reason: "禁止删除构建目录"
97
- # priority: 25
98
- # match:
99
- # kind: command-pattern
100
- # patterns:
101
- # - re: "\\brm\\s+-rf\\s+(?:dist|build|out)\\b"
102
- # label: "delete build directory"
103
- # evidence:
104
- # kind: pattern-match
105
- #
106
- # # 以下写法会被拒绝(硬规则锁定):
107
- # # - id: destructive-command
108
- # # enabled: false # → "cannot be disabled"
109
- # # - id: credential-access
110
- # # light: yellow # → "light cannot be lowered from red to yellow"
111
- #
112
- # 注意:`light: blue` 不能把 network-egress 变成"内网放行"——它的谓词看 allowHosts;
113
- # 要放行内网域请把它们加入 policy.networkAllowlist,而不是只改灯色。
package/sdk/sdk/README.md DELETED
@@ -1,65 +0,0 @@
1
- # dsh-Fang 生态层(MIT)
2
-
3
- 这个目录是 dsh-Fang 的**生态层**,使用 [MIT 许可](../LICENSE-SDK):
4
- 插件 SDK、模板、示例都可以零摩擦复制、修改、二次分发,甚至闭源集成进你的产品。
5
-
6
- > 核心层(编排器/派生器/红线守卫/Adapter/容器执行器等)在 `src/` 下,使用 **AGPL-3.0**(见
7
- > `../LICENSE-CORE`);商业层(Relay/企业功能)在 `../relay-server`、`../enterprise`,闭源。
8
- > 逐目录许可地图见 [`../NOTICE`](../NOTICE)。
9
-
10
- ---
11
-
12
- ## 1. 一个 dsh-Fang 插件长什么样
13
-
14
- Fang 插件就是一个 DSH bundle:一个 npm 包目录,带
15
-
16
- ```
17
- my-plugin/
18
- ├── package.json # name + dsh.bundle.patch(+ 可选 dsh.client 声明浏览器半)
19
- ├── cordis.patch.yml # 安装时把本插件的 loader 行 insert 进 profile
20
- ├── index.js # Host 半:export const name/inject/Config/apply
21
- └── client.js # 可选 Client 半:window.__ModuleLoader__.load({...})
22
- ```
23
-
24
- 安装(不需要发布到 npm):
25
-
26
- ```powershell
27
- # 在 DSH 会话里对 Agent 说:
28
- # plugin_manager install_bundle(target="E:\path\to\my-plugin")
29
- # 或者由你的发布脚本调用 DSH 的 plugin_manager
30
- ```
31
-
32
- ## 2. 模板
33
-
34
- - [`templates/plugin/`](templates/plugin/) — 最小可安装插件(Host + 可选 Client + 图标 + locale)
35
- - [`examples/status-badge/`](examples/status-badge/) — 读取瓮城 `/fang/api/status` 并在输入框下方显示徽标
36
- (演示"第三方插件如何安全调用 Fang 的公开 HTTP 面")
37
-
38
- 复制模板:
39
-
40
- ```powershell
41
- Copy-Item -Recurse sdk\templates\plugin my-plugin
42
- # 改 package.json 里的 name / 行 id / patch 里的 id
43
- ```
44
-
45
- ## 3. 与瓮城核心交互的三种合法方式
46
-
47
- | 方式 | 适用 | 协议边界 |
48
- |---|---|---|
49
- | 读 `/fang/api/status`、`/fang/api/tasks`、`/fang/api/sessions` | 面板/徽标/旁路观察 | 只读 HTTP,最安全 |
50
- | `POST /fang/api/derive`、`/tasks/*`、`/promote` | 自动化工作流 | 写入前请遵守核心的配额与审批语义 |
51
- | Adapter 协议(仅分身内,`/fang/adapter/*`) | 分身内插件 | 需要分身 token;不要在母体调用 |
52
-
53
- > 插件与核心之间通过**公开 HTTP API** 交互时,你的插件是独立作品,可以自选许可证
54
- > (MIT/Apache/闭源均可)——这正是生态层 MIT 的意义。
55
-
56
- ## 4. 需要遵守的少量规则
57
-
58
- - 不要从其他插件的 DOM / 样式表里"猜"布局;用 slots 与主题 token(`--dsw-alias-*`)。
59
- - Client 半不要 `require` 其他 DSH Client 包;React 来自浏览器模块表。
60
- - 定时器/监听器用 `ctx.effect` 注册清理。
61
- - 不要写 `$DSH_HOME/profiles/**`;通过 bundle/plugin_manager 安装。
62
-
63
- ## 5. 贡献
64
-
65
- 生态层(`sdk/`、`tools/fangctl.mjs`)的贡献同样需要签署 [CLA](../CLA.md)(为了让项目能双许可)。
@@ -1,16 +0,0 @@
1
- # status-badge(MIT 示例插件)
2
-
3
- 演示第三方插件如何**只通过公开 HTTP 面**与瓮城交互:
4
-
5
- - `index.js`:Host 半,提供一个只读服务(证明插件已加载);
6
- - `client.js`:Client 半,每 10s 拉一次 `GET /fang/api/status`,在输入框下方显示「瓮城 N/M」。
7
- - 不 import 任何瓮城内部模块 → 它是独立作品,可自由选许可证(本示例为 MIT)。
8
-
9
- 安装:
10
-
11
- ```powershell
12
- # DSH 会话里:
13
- # plugin_manager install_bundle(target="<repo>\\sdk\\examples\\status-badge")
14
- ```
15
-
16
- 失败态:拉不到 `/fang/api/status` 时显示「瓮城离线」,不假装有数据。
@@ -1,60 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // Example client half: read dsh-Fang's public read-only HTTP surface and show it in the dock.
3
- // This demonstrates the recommended third-party integration: HTTP only, no host internals.
4
- window.__ModuleLoader__.load({
5
- id: '@fang-example/status-badge',
6
- factory(require) {
7
- const React = require('react')
8
- const h = React.createElement
9
-
10
- function StatusBadge() {
11
- const [view, setView] = React.useState({ state: 'loading', text: '瓮城 …' })
12
- React.useEffect(() => {
13
- let alive = true
14
- const poll = async () => {
15
- try {
16
- const res = await fetch('/fang/api/status', { headers: { accept: 'application/json' } })
17
- if (!res.ok) throw new Error('status ' + res.status)
18
- const body = await res.json()
19
- if (!alive) return
20
- const ready = body?.tasks?.ready ?? 0
21
- const max = body?.tasks?.max ?? '?'
22
- setView({ state: 'ok', text: `瓮城 ${ready}/${max}`, version: body?.version })
23
- } catch {
24
- if (alive) setView({ state: 'off', text: '瓮城离线' })
25
- }
26
- }
27
- poll()
28
- const timer = setInterval(poll, 10000)
29
- return () => { alive = false; clearInterval(timer) }
30
- }, [])
31
-
32
- const color = view.state === 'ok'
33
- ? 'var(--dsw-alias-state-success, #22c55e)'
34
- : view.state === 'off'
35
- ? 'var(--dsw-alias-state-warning, #9ca3af)'
36
- : 'var(--dsw-alias-state-business-primary, #2563eb)'
37
- return h('div', {
38
- title: view.version ? `dsh-Fang ${view.version}` : 'dsh-Fang 状态(第三方插件示例)',
39
- style: {
40
- display: 'inline-flex', alignItems: 'center', gap: 6, padding: '2px 8px', borderRadius: 999,
41
- fontSize: 11, color: 'var(--dsw-alias-label-secondary, #888)',
42
- border: '1px solid var(--dsw-alias-border, rgba(127,127,127,.3))',
43
- },
44
- },
45
- h('span', { 'aria-hidden': true, style: { width: 6, height: 6, borderRadius: '50%', background: color } }),
46
- h('span', null, view.text))
47
- }
48
-
49
- return {
50
- inject: ['slots'],
51
- apply(ctx) {
52
- return ctx.slots.inject('conversation.composer.dock', () => ctx.slots.register({
53
- name: 'conversation.composer.dock',
54
- id: 'fang-example-status-badge',
55
- order: 70,
56
- }, (props) => h(StatusBadge, { ...props, ctx })))
57
- },
58
- }
59
- },
60
- })
@@ -1,7 +0,0 @@
1
- # SPDX-License-Identifier: MIT
2
- # Example plugin row: host half marks the plugin present; the client half talks to /fang/api/status.
3
- - insert:
4
- - id: fang-example-status-badge
5
- name: '@fang-example/status-badge'
6
- config:
7
- intervalMs: 10000
@@ -1,12 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // Example host half: exposes a tiny service so the plugin is observable, and nothing else.
3
- export const name = 'fang-example-status-badge'
4
- export const inject = []
5
-
6
- export function apply(ctx, config) {
7
- const cfg = { intervalMs: 10000, ...(config ?? {}) }
8
- ctx.effect(() => ctx.provide('fangExampleStatusBadge', {
9
- intervalMs: () => cfg.intervalMs,
10
- at: new Date().toISOString(),
11
- }))
12
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@fang-example/status-badge",
3
- "version": "0.1.0",
4
- "private": true,
5
- "type": "module",
6
- "description": "Example MIT plugin: shows dsh-Fang status next to the composer (third-party plugin calling Fang's public HTTP surface).",
7
- "exports": {
8
- ".": "./index.js",
9
- "./client": {
10
- "browser": "./client.js",
11
- "default": "./client.js"
12
- }
13
- },
14
- "files": ["index.js", "client.js", "cordis.patch.yml"],
15
- "license": "MIT",
16
- "dsh": {
17
- "bundle": { "patch": "./cordis.patch.yml" },
18
- "client": {
19
- "platform": "web",
20
- "immediately": true,
21
- "inject": ["@deepseek-ai/dsh-client-connection"]
22
- }
23
- }
24
- }
@@ -1,36 +0,0 @@
1
- # 插件模板(MIT)
2
-
3
- 最小可安装的 DSH / dsh-Fang 插件,包含 Host 半(`index.js`)与可选的 Client 半(`client.js`)。
4
-
5
- ## 用法
6
-
7
- ```powershell
8
- Copy-Item -Recurse sdk\templates\plugin E:\my\my-plugin
9
- cd E:\my\my-plugin
10
- # 1) 改 package.json:name、dsh.client(不需要 UI 就删掉 dsh.client 与 client.js)
11
- # 2) 改 cordis.patch.yml:id 与 name 保持一致
12
- # 3) 在 DSH 会话里安装:
13
- # plugin_manager install_bundle(target="E:\\my\\my-plugin")
14
- ```
15
-
16
- ## 结构
17
-
18
- | 文件 | 作用 |
19
- |---|---|
20
- | `package.json` | `dsh.bundle.patch` 让它成为可安装 bundle;`dsh.client` 声明浏览器半 |
21
- | `cordis.patch.yml` | 安装时把 `my-plugin` 这一行 insert 进 profile 的 loader 树 |
22
- | `index.js` | Host 半:`export const name / inject / apply`;用 `ctx.effect(ctx.provide(...))` 提供能力 |
23
- | `client.js` | Client 半:向 `conversation.composer.dock` 注册一个徽标(可删) |
24
- | `locale/en.json` | 界面上显示给用户的标题与描述(国际化) |
25
- | `icon.svg` | 插件图标;不要用上游/他人的图标 |
26
-
27
- ## 可配置
28
-
29
- 模板刻意**不带** `Config`,避免模板依赖 schema 库。需要配置时,把 schemastery(MIT)复制到
30
- `vendor/` 再 `export const Config = z.object({...})`——核心层的做法可直接参考。
31
-
32
- ## 与瓮城交互
33
-
34
- 第三方插件调用瓮城只看公开 HTTP 面:`/fang/api/status`、`/fang/api/tasks`、`/fang/api/sessions`、
35
- `POST /fang/api/derive` 等(见 [`../../README.md`](../../README.md))。用 HTTP 交互时你的插件是独立作品,
36
- 可以选择自己的许可证。
@@ -1,35 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // dsh-Fang / DSH plugin template — optional Client half.
3
- //
4
- // Contract: window.__ModuleLoader__.load({ id: <package name>, factory(require) {...} })
5
- // React comes from the browser module table; do not require other DSH client packages.
6
- window.__ModuleLoader__.load({
7
- id: '@your-scope/dsh-plugin-template',
8
- factory(require) {
9
- const React = require('react')
10
- const h = React.createElement
11
-
12
- function Badge() {
13
- return h('div', {
14
- title: 'my-plugin: 输入框下方的一个示例徽标',
15
- style: {
16
- display: 'inline-flex', alignItems: 'center', gap: 6,
17
- padding: '2px 8px', borderRadius: 999, fontSize: 11,
18
- color: 'var(--dsw-alias-label-secondary, #888)',
19
- border: '1px solid var(--dsw-alias-border, rgba(127,127,127,.3))',
20
- },
21
- }, 'my-plugin')
22
- }
23
-
24
- return {
25
- inject: ['slots'],
26
- apply(ctx) {
27
- return ctx.slots.inject('conversation.composer.dock', () => ctx.slots.register({
28
- name: 'conversation.composer.dock',
29
- id: 'my-plugin-badge',
30
- order: 60,
31
- }, (props) => h(Badge, { ...props, ctx })))
32
- },
33
- }
34
- },
35
- })
@@ -1,8 +0,0 @@
1
- # SPDX-License-Identifier: MIT
2
- # Bundle patch for the plugin template: one loader row inserted at install time.
3
- # Rename the id / package name when you copy this template.
4
- - insert:
5
- - id: my-plugin
6
- name: '@your-scope/dsh-plugin-template'
7
- config:
8
- greeting: 'hello from my plugin'
@@ -1,5 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="my-plugin">
2
- <rect x="4" y="4" width="56" height="56" rx="12" fill="#0f172a"/>
3
- <circle cx="32" cy="30" r="12" fill="none" stroke="#22c55e" stroke-width="4"/>
4
- <path d="M20 48h24" stroke="#94a3b8" stroke-width="4" stroke-linecap="round"/>
5
- </svg>
@@ -1,23 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // dsh-Fang / DSH plugin template — Host half.
3
- //
4
- // A Cordis plugin module: export name / inject / (optional Config) / apply.
5
- // Copy this file, change the names, and install the directory as a bundle:
6
- // plugin_manager install_bundle(target="E:\\path\\to\\my-plugin")
7
- //
8
- // The optional `Config` two lines below needs a schema library. If you want a configurable
9
- // plugin, copy `schemastery.mjs` + `cosmokit.mjs` (MIT, upstream cordis) into a `vendor/`
10
- // folder next to this file and `export const Config = z.object({...})`, exactly like the
11
- // dsh-Fang core does; otherwise a plugin with no Config is perfectly valid.
12
- export const name = 'my-plugin'
13
- export const inject = []
14
-
15
- const DEFAULTS = { greeting: 'hello from my plugin' }
16
-
17
- export function apply(ctx, config) {
18
- const cfg = { ...DEFAULTS, ...(config ?? {}) }
19
- ctx.effect(() => ctx.provide('myPlugin', {
20
- greeting: () => cfg.greeting,
21
- status: () => ({ ok: true, at: new Date().toISOString() }),
22
- }))
23
- }
@@ -1,6 +0,0 @@
1
- {
2
- "meta": {
3
- "title": "my-plugin (template)",
4
- "description": "Minimal MIT plugin template for DSH / dsh-Fang: host half plus an optional composer-dock badge."
5
- }
6
- }
@@ -1,36 +0,0 @@
1
- {
2
- "name": "@your-scope/dsh-plugin-template",
3
- "version": "0.1.0",
4
- "private": true,
5
- "type": "module",
6
- "description": "Minimal dsh-Fang / DSH plugin template (MIT): host half + optional client half.",
7
- "exports": {
8
- ".": "./index.js",
9
- "./client": {
10
- "browser": "./client.js",
11
- "default": "./client.js"
12
- },
13
- "./locale/*.json": "./locale/*.json",
14
- "./icon": "./icon.svg"
15
- },
16
- "files": [
17
- "index.js",
18
- "client.js",
19
- "cordis.patch.yml",
20
- "locale/*.json",
21
- "icon.svg"
22
- ],
23
- "license": "MIT",
24
- "dsh": {
25
- "bundle": {
26
- "patch": "./cordis.patch.yml"
27
- },
28
- "client": {
29
- "platform": "web",
30
- "immediately": true,
31
- "inject": [
32
- "@deepseek-ai/dsh-client-connection"
33
- ]
34
- }
35
- }
36
- }
@@ -1,67 +0,0 @@
1
- // SPDX-License-Identifier: AGPL-3.0-or-later
2
- // Copyright (c) 2026 dsh-Fang contributors — see LICENSE-CORE.
3
- // dsh-Fang compose mode — mounts the orchestrator and every sub-plugin as nested
4
- // fibers of one loader row. This is the fallback composition used when the split-row
5
- // patch (`./cordis.patch.yml`) cannot resolve subpath entries; it is behaviourally
6
- // identical because every sub-plugin is the same module the split rows would load.
7
- import { z } from './kernel/index.mjs'
8
- import * as auditor from './plugins/auditor.mjs'
9
- import * as forker from './plugins/forker.mjs'
10
- import * as bufferKeeper from './plugins/buffer-keeper.mjs'
11
- import * as scorer from './plugins/scorer.mjs'
12
- import * as umbrella from './plugins/umbrella.mjs'
13
- import * as healer from './plugins/healer.mjs'
14
- import * as router from './plugins/router.mjs'
15
- import * as approver from './plugins/approver.mjs'
16
- import * as hotReloader from './plugins/hot-reloader.mjs'
17
- import * as restartGuard from './plugins/restart-guard.mjs'
18
- import * as adapter from './plugins/adapter.mjs'
19
- import * as orchestrator from './plugins/orchestrator.mjs'
20
- import * as sessionBridge from './plugins/session-bridge.mjs'
21
- import * as sessionSync from './plugins/session-sync.mjs'
22
- import * as sessionRouter from './plugins/session-router.mjs'
23
- import * as decisionCenter from './plugins/decision-center.mjs'
24
-
25
- export const name = 'fang-compose'
26
- export const inject = []
27
-
28
- export const Config = z.object({
29
- auditor: z.object({}).default({}).description('审计子插件配置'),
30
- forker: z.object({}).default({}).description('派生器配置'),
31
- bufferKeeper: z.object({}).default({}).description('缓冲管理器配置'),
32
- scorer: z.object({}).default({}).description('评分配置'),
33
- umbrella: z.object({}).default({}).description('保护伞(动作灯色 + 决策)配置'),
34
- healer: z.object({}).default({}).description('修复子插件配置'),
35
- router: z.object({}).default({}).description('路由决策配置'),
36
- approver: z.object({}).default({}).description('审批子插件配置'),
37
- hotReloader: z.object({}).default({}).description('热更新引擎配置'),
38
- restartGuard: z.object({}).default({}).description('红线守卫配置'),
39
- adapter: z.object({}).default({}).description('分身侧 Adapter 配置'),
40
- orchestrator: z.object({}).default({}).description('编排器配置'),
41
- sessionBridge: z.object({}).default({}).description('桥接(实时驱动 PC 会话)配置'),
42
- sessionSync: z.object({}).default({}).description('同步(勾选会话搬运)配置'),
43
- sessionRouter: z.object({}).default({}).description('混合路由配置'),
44
- decisionCenter: z.object({}).default({}).description('决策中心配置'),
45
- }).description('dsh-Fang 单行装载模式配置')
46
-
47
- export function apply(ctx, config) {
48
- const cfg = config ?? {}
49
- ctx.plugin(auditor, cfg.auditor ?? {})
50
- ctx.plugin(forker, cfg.forker ?? {})
51
- ctx.plugin(bufferKeeper, cfg.bufferKeeper ?? {})
52
- ctx.plugin(scorer, cfg.scorer ?? {})
53
- ctx.plugin(umbrella, cfg.umbrella ?? {})
54
- ctx.plugin(healer, cfg.healer ?? {})
55
- ctx.plugin(router, cfg.router ?? {})
56
- ctx.plugin(approver, cfg.approver ?? {})
57
- ctx.plugin(hotReloader, cfg.hotReloader ?? {})
58
- ctx.plugin(restartGuard, cfg.restartGuard ?? {})
59
- ctx.plugin(adapter, cfg.adapter ?? {})
60
- ctx.plugin(orchestrator, cfg.orchestrator ?? {})
61
- ctx.plugin(sessionBridge, cfg.sessionBridge ?? {})
62
- ctx.plugin(sessionSync, cfg.sessionSync ?? {})
63
- ctx.plugin(sessionRouter, cfg.sessionRouter ?? {})
64
- ctx.plugin(decisionCenter, cfg.decisionCenter ?? {})
65
- }
66
-
67
- export const _modules = { auditor, forker, bufferKeeper, scorer, umbrella, healer, router, approver, hotReloader, restartGuard, adapter, orchestrator, sessionBridge, sessionSync, sessionRouter, decisionCenter }