@dsh-workbench/core 1.0.0-beta.0 → 1.0.0

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
@@ -12,7 +12,7 @@
12
12
 
13
13
  | 装法 | 命令 | 得到什么 |
14
14
  |---|---|---|
15
- | 独立实例(推荐) | `npx @dsh-workbench/core create` | 自己的 profile、`:3081`、独立进程与数据 |
15
+ | 独立实例(推荐) | `npx @dsh-workbench/core create` | 自己的 profile、`:3081`、独立进程;会话 / 项目 / 附件跟 web 共用 |
16
16
  | 装进现有 `dsh web` | 侧栏 Plugins → Add plugin → `@dsh-workbench/core` → Install → Enable now → 刷新 | 当前实例多一列面板,会话不变 |
17
17
  | 装进 Desktop | 同上,装完重开窗口 | Desktop 里多一列面板 |
18
18
 
@@ -24,11 +24,11 @@ npx --yes @dsh-workbench/core@latest setup # 或非交互:建默认的
24
24
  npx @dsh-workbench/core # 起 :3081
25
25
  ```
26
26
 
27
- `create` 有 `dsh web` 就拿它当模板,并问要不要复制设置、本地插件、项目列表和会话;
28
- 本机一个 profile 都没有时,用 dsh 出厂的 web 模板建一个空的。脚本 / CI 里直接给参数:
27
+ `create` 有 `dsh web` 就拿它当模板,并问要不要复制设置;会话、项目、附件本来就共用,
28
+ 不用复制。本机一个 profile 都没有时,用 dsh 出厂的 web 模板建一个空的。脚本 / CI 里直接给参数:
29
29
 
30
30
  ```bash
31
- npx --yes @dsh-workbench/core@latest setup --from web --profile wb2 --with-sessions
31
+ npx --yes @dsh-workbench/core@latest setup --from web --profile wb2
32
32
  npx @dsh-workbench/core --profile wb2
33
33
  ```
34
34
 
@@ -40,7 +40,7 @@ npx @dsh-workbench/core --profile wb2
40
40
  |---|---|
41
41
  | `dsh` ≥ 0.2.1-rc.2 | 本体。更旧的会被拒绝:`engines.dsh` 声明了下限,老到不认这个字段的 dsh 由启动器当场拒绝并给升级命令 |
42
42
  | Node + pnpm | dsh 的 `plugin` 子命令转发给 pnpm;没有 pnpm 会报 `dsh: pnpm was not found` |
43
- | 可选:跑过一次 `dsh web` | 想继承它的设置 / 插件 / 项目时。只建工作台不需要 |
43
+ | 可选:跑过一次 `dsh web` | 想继承它的设置 / 项目时。只建工作台不需要 |
44
44
 
45
45
  ## 命令行
46
46
 
@@ -51,7 +51,7 @@ npx @dsh-workbench/core --profile wb2
51
51
  | `dsh-workbench` | 起工作台(默认端口 `:3081`,其余参数透传给 `dsh web`) |
52
52
  | `dsh-workbench --profile <名字>` | 起指定实例 |
53
53
  | `dsh-workbench setup --from <来源> --profile <新名>` | 以某个现有 profile 为模板建一个 |
54
- | `--with-sessions` / `--no-settings` / `--no-plugins` / `--no-projects` | 复制 / 不复制哪一类(默认复制设置、插件、项目,不复制会话) |
54
+ | `--no-settings` | 不复制来源的设置(默认复制 `--from` 那份里改已有插件的行) |
55
55
  | `dsh-workbench --help` | 用法;其余参数透传给 `dsh web` |
56
56
 
57
57
  环境变量:
@@ -60,8 +60,8 @@ npx @dsh-workbench/core --profile wb2
60
60
  |---|---|---|
61
61
  | `WORKBENCH_PORT` | `3081` | 端口;`dsh web` 默认 `:3080`,两边可以同时开 |
62
62
  | `WORKBENCH_PROFILE` | `workbench` | 用哪个 profile(等价于 `--profile`) |
63
- | `DSH_HOME` | `~/.dsh` | dsh 的数据根 |
64
- | `DSH_WORKBENCH_HOME` | `$DSH_HOME/workbench` | 工作台自己的数据根(opencli 运行时、模块、截图…) |
63
+ | `DSH_HOME` | `~/.dsh` | dsh 的数据根;会话 / 项目 / 附件都在这里,工作台跟 web 共用 |
64
+ | `DSH_WORKBENCH_HOME` | `$DSH_HOME/<profile>` | 工作台运行时根(opencli 隔离运行时、工坊、模块市场、自更新) |
65
65
 
66
66
  装进 `dsh web` 或 Desktop 时没有启动命令:它们用自己那一份 profile,工作台只是其中一层插件。
67
67
 
@@ -75,7 +75,7 @@ npx @dsh-workbench/core --profile wb2
75
75
  | `client.js` | 浏览器侧 bundle,dsh 客户端按 `dsh.client` 加载 |
76
76
  | `cordis.patch.yml` | 把自己插进 profile 组合图的补丁(装载) |
77
77
  | `preset/diy.patch.yml` | 「工作台 DIY 模式」的 preset;由 `scripts/gen-diy-preset.mjs` 从 dsh 出厂那份 `standard.patch.yml` 派生(生成后提交,selfcheck 盯过期) |
78
- | `profile/` | 出厂 profile 模板(隔离 opencli、可写根两份补丁) |
78
+ | `profile/` | 出厂 profile 模板:可写根那一行(启动器 `--patch` 用,seed 也抄进 profile) |
79
79
  | `skills/` | 模块 DIY 指引,装好后挂给 agent;漏了不报错,只是 agent 不知道要怎么做模块 |
80
80
  | `bin/` | `dsh-workbench` 启动器、隔离 opencli 的入口 |
81
81
  | `scripts/` | 随包出货的脚本:`seed-profile.sh` / `seed-workshop.sh` / `create-workbench.mjs` / `clone-profile.mjs` |
@@ -85,18 +85,21 @@ npx @dsh-workbench/core --profile wb2
85
85
  | 内容 | 位置 |
86
86
  |---|---|
87
87
  | profile(设置、`node_modules`、`cordis.patch.yml`) | `~/.dsh/profiles/<名字>` |
88
- | 工作台数据(模块、面板、截图与录制、opencli 运行时) | `~/.dsh/workbench/**` |
88
+ | 会话、项目列表、附件 | `~/.dsh/{sessions,storages,attachments}` —— 跟 `dsh web` / Desktop **共用一份** |
89
+ | 工作台运行时(opencli 隔离运行时、工坊、模块市场、自更新日志) | `~/.dsh/workbench/**`;别的 profile 是 `~/.dsh/<名字>/**` |
90
+ | 面板与模块配置 | `~/.dsh/workbench/workspaces/**` |
89
91
  | API 凭据 | `~/.dsh/.credentials.yaml` —— 它与 `dsh web` **有意共用**,一台机器一把 key |
90
92
  | DIY 工坊依赖安装日志 | `~/.dsh/workbench/seed.log` |
91
93
 
92
- 独立实例与 `dsh web` **数据分家**:各自会话、各自设置,互不影响。装进 `dsh web` / Desktop
93
- 则沿用它们自己的会话与存储,面板与模块配置照旧落在 `~/.dsh/workbench/**`。
94
+ 独立实例**只分 profile,不分数据根**:会话、项目、附件跟 `dsh web` 和 Desktop 是同一份,
95
+ 只有设置与插件各一份。旧版本分过家的实例,下次启动会把 `~/.dsh/workbench/{sessions,storages,attachments}`
96
+ 并回共用根(只补不覆盖,旧目录保留)。
94
97
 
95
98
  设置只有一份,写在哪都看得见:
96
99
 
97
100
  - 独立实例:`:3081` → Settings,落进 `profiles/<名字>/cordis.patch.yml`,每一行都改得动。
98
101
  - 想用 `dsh web` 已经配好的行:`:3081` → `Meta+,` → 「工作台设置」→「配置同步」→
99
- 选来源 → 勾行 → 同步,即时生效。只搬显式配过的行,同 id 内容不同默认不覆盖;
102
+ 选来源 → 勾行 → 同步,即时生效。只同步显式配过的行,同 id 内容不同默认不覆盖;
100
103
  web 后来改的不会自动过来,再打开这一页拉一次即可。
101
104
 
102
105
  ## 日常
@@ -108,9 +111,9 @@ npx @dsh-workbench/core --profile wb2
108
111
  | 升级 | 重跑一次 `npx --yes @dsh-workbench/core@latest setup`(幂等),然后重启工作台。工坊工具链会在下一次启动时自动跟到同代,不必手动删工坊 |
109
112
  | 重建 profile | `mv ~/.dsh/profiles/workbench ~/.dsh/profiles/workbench.bak`,再跑一次 `setup` |
110
113
  | 换左栏 | 设置 → 工作台设置 → 会话列表:默认官方;切完自动刷新页面生效(从旧版升上来第一次要重启) |
111
- | 从 `dsh web` 搬设置 | 设置 → 工作台设置 → 配置同步 → 选来源 → 勾行 → 同步 |
114
+ | 从 `dsh web` 同步设置 | 设置 → 工作台设置 → 配置同步 → 选来源 → 勾行 → 同步 |
112
115
  | 装模块 | `:3081` 的「工作台模块市场」,或让 agent 装 |
113
- | 彻底不用了 | 删 `~/.dsh/profiles/workbench` 与 `~/.dsh/workbench` 两个目录(都不影响 `dsh web`) |
116
+ | 彻底不用了 | 删 `~/.dsh/profiles/workbench` 与 `~/.dsh/workbench` 两个目录(会话 / 项目 / 附件在 `~/.dsh` 下,不跟着删) |
114
117
 
115
118
  外壳本身**零业务模块**:右侧面板装什么有什么。装进 `dsh web` / Desktop 时少一条命令 ——
116
119
  没有独立端口与进程,改用它们自己的插件页装模块。
package/bin/dsh-workbench CHANGED
@@ -6,14 +6,13 @@
6
6
  # ./bin/dsh-workbench setup # 建默认 workbench profile(幂等)
7
7
  # ./bin/dsh-workbench setup --from web --profile wb2
8
8
  # # 以 web 为模板建一个独立工作台
9
- # ./bin/dsh-workbench setup --from web --profile wb2 --with-sessions
10
- # # 连会话一起复制
11
9
  # ./bin/dsh-workbench --profile wb2 # ② 起指定 profile,默认 :3081
12
10
  # ./bin/dsh-workbench --no-open # 其余参数透传给 dsh web
13
11
  # ./bin/dsh-workbench --help
14
12
  #
15
- # 与 `dsh web` 完全独立:不同的 profile 目录、不同的 node_modules、
16
- # 不同的端口、独立的进程。两个可以同时开着,互不干扰。
13
+ # 与 `dsh web` 并存:不同的 profile、不同的 node_modules、不同的端口、独立的进程。
14
+ # 会话 / 项目 / 附件跟 `dsh web` 和 Desktop 共用一份(都在 $DSH_HOME 下),
15
+ # 只有设置与插件分家;运行时的 opencli、工坊、模块市场仍按 profile 各一份。
17
16
  #
18
17
  # ── 这份脚本有两种身份,它自己分得清 ──────────────────────────────────────
19
18
  # · **仓库副本**(这个包落在一个 git 工作树里):开发用。bundle 以 link 方式装本目录,
@@ -44,7 +43,7 @@ die() {
44
43
  }
45
44
 
46
45
  usage() {
47
- sed -n '3,13p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
46
+ sed -n '3,15p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
48
47
  }
49
48
 
50
49
  if [ "${1:-}" = "create" ]; then
@@ -72,11 +71,11 @@ while [ $# -gt 0 ]; do
72
71
  WB_CLONE=1
73
72
  shift 2
74
73
  ;;
75
- --with-sessions) WB_COPY_SESSIONS=1; shift ;;
76
- --no-sessions) WB_COPY_SESSIONS=0; shift ;;
74
+ --with-sessions | --no-sessions | --no-projects)
75
+ echo "dsh-workbench: 会话与项目跟 dsh web 共用一份数据根,$1 不再需要(忽略)。" >&2
76
+ shift
77
+ ;;
77
78
  --no-settings) WB_COPY_SETTINGS=0; shift ;;
78
- --no-plugins) WB_COPY_PLUGINS=0; shift ;;
79
- --no-projects) WB_COPY_PROJECTS=0; shift ;;
80
79
  help | --help | -h) usage; exit 0 ;;
81
80
  --) shift; DSH_ARGS+=("$@"); break ;;
82
81
  *) DSH_ARGS+=("$1"); shift ;;
@@ -90,10 +89,18 @@ if [ "${WB_CLONE:-0}" = "1" ] && [ "$PROFILE_EXPLICIT" = "0" ]; then
90
89
  die "用 --from 时还要指定 --profile <新名字>(例如 --from web --profile wb2)"
91
90
  fi
92
91
 
92
+ # `desktop` 只归 Desktop app 管(Electron 自己起 profile、自己决定数据根),dsh 那边也拒。
93
+ # 更要紧的是 setup:它把隔离层**追加**进目标 profile —— 目标是 desktop 时,那个 profile
94
+ # 就再也看不到 `$DSH_HOME/sessions` 里的历史,而且一声不响(2026-10-23 发生过一次)。
95
+ if [ "$PROFILE" = "desktop" ]; then
96
+ die "'desktop' 只归 Desktop app 管(dsh 自己也拒)—— 换一个名字,例如 --profile wb2"
97
+ fi
98
+
93
99
  export WORKBENCH_PROFILE="$PROFILE"
94
100
  export WB_CLONE="${WB_CLONE:-0}"
95
101
  PROFILE_DIR="$DSH_HOME/profiles/$PROFILE"
96
- # 每个 profile 一份自己的运行时数据根;默认 profile 仍是 <home>/workbench。
102
+ # 每个 profile 一份自己的**运行时**根(opencli 隔离运行时、工坊、模块市场);
103
+ # 会话 / 项目 / 附件不在这里 —— 它们跟 `dsh web` / Desktop 共用 $DSH_HOME。
97
104
  WORKBENCH_HOME="${DSH_WORKBENCH_HOME:-$DSH_HOME/$PROFILE}"
98
105
  export DSH_WORKBENCH_HOME="$WORKBENCH_HOME"
99
106
 
@@ -203,25 +210,9 @@ run_setup() {
203
210
  bash "$REPO_DIR/scripts/seed-profile.sh"
204
211
 
205
212
  if [ "${WB_CLONE:-0}" = "1" ]; then
206
- if [ -z "${WB_SOURCE_HOME:-}" ]; then
207
- SRC_PATCH="$DSH_HOME/profiles/$SRC_PROFILE/cordis.patch.yml"
208
- if grep -q 'id: session-persistence-jsonl' "$SRC_PATCH" 2>/dev/null; then
209
- if [ "$SRC_PROFILE" != "workbench" ] && grep -q 'DSH_WORKBENCH_HOME' "$SRC_PATCH" 2>/dev/null; then
210
- WB_SOURCE_HOME="$DSH_HOME/$SRC_PROFILE"
211
- else
212
- WB_SOURCE_HOME="$DSH_HOME/workbench"
213
- fi
214
- else
215
- WB_SOURCE_HOME="$DSH_HOME"
216
- fi
217
- fi
218
213
  WB_SOURCE_PROFILE="$SRC_PROFILE" \
219
214
  WB_TARGET_PROFILE="$PROFILE" \
220
- WB_SOURCE_HOME="$WB_SOURCE_HOME" \
221
215
  WB_COPY_SETTINGS="${WB_COPY_SETTINGS:-1}" \
222
- WB_COPY_PLUGINS="${WB_COPY_PLUGINS:-1}" \
223
- WB_COPY_PROJECTS="${WB_COPY_PROJECTS:-1}" \
224
- WB_COPY_SESSIONS="${WB_COPY_SESSIONS:-0}" \
225
216
  node "$REPO_DIR/scripts/clone-profile.mjs" || die "从 $SRC_PROFILE 初始化 $PROFILE 失败"
226
217
  fi
227
218
 
@@ -316,6 +307,16 @@ if [ "$BUNDLE_GUARD" -ne 0 ]; then
316
307
  exit 1
317
308
  fi
318
309
 
310
+ # ── 已有实例:把会话 / 项目 / 附件收回到共用数据根(幂等,每次启动都过一遍)
311
+ #
312
+ # 旧版本给 workbench profile 追加过隔离的三行(sessions / storages / attachment 指到
313
+ # `$DSH_HOME/workbench/**`)。现在改成跟 Desktop 一样「只分 profile、不分数据根」,
314
+ # 那三行与旧数据都在这条命令里收回来;新 profile 上它只补可写根那一行。
315
+ # 必须排在这里(exec dsh 之前):那几行要在这一代配置读进去之前就改好。
316
+ WORKBENCH_PROFILE="$PROFILE" DSH_HOME="$DSH_HOME" DSH_WORKBENCH_HOME="$WORKBENCH_HOME" \
317
+ node "$REPO_DIR/scripts/share-data-root.mjs" ||
318
+ echo "dsh-workbench: 提醒 —— 数据根没整理成(见上一行),这次仍按现在的 profile 起。" >&2
319
+
319
320
  # 清掉从父 dsh 会话继承来的身份变量。
320
321
  #
321
322
  # 它们描述的是**另一个** profile 和会话。如果你是在某个 dsh 会话的 shell 里