@dsh-workbench/core 1.0.0 → 1.1.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.
Files changed (41) hide show
  1. package/README.md +16 -3
  2. package/bin/dsh-workbench +38 -6
  3. package/client.js +669 -305
  4. package/dist/client/client.body.js +669 -305
  5. package/dist/client/index.js +669 -305
  6. package/dist/host/index.js +445 -37
  7. package/dist/types/app/layouts/market/discover-sources-dialog.d.ts +4 -0
  8. package/dist/types/app/layouts/market/discover-states.d.ts +3 -0
  9. package/dist/types/app/layouts/market/use-add-module.d.ts +0 -1
  10. package/dist/types/app/layouts/market/use-discover.d.ts +1 -0
  11. package/dist/types/app/layouts/rightbar/MarketView.d.ts +3 -1
  12. package/dist/types/app/layouts/rightbar/market-names.d.ts +8 -0
  13. package/dist/types/app/layouts/rightbar/market-row-types.d.ts +11 -3
  14. package/dist/types/app/layouts/rightbar/market-rows.d.ts +6 -4
  15. package/dist/types/app/layouts/rightbar/market-view-text.d.ts +4 -3
  16. package/dist/types/app/units/unit-titles.d.ts +3 -0
  17. package/dist/types/kernel/contract/bundle-install.d.ts +1 -1
  18. package/dist/types/kernel/contract/market-index.d.ts +1 -1
  19. package/dist/types/modules/panels/model/diy-tools.d.ts +1 -1
  20. package/dist/types/modules/panels/model/market-dispatch.d.ts +8 -0
  21. package/dist/types/modules/panels/model/market-follow-up.d.ts +16 -0
  22. package/dist/types/modules/panels/model/market-sources-act.d.ts +2 -0
  23. package/dist/types/modules/panels/model/market-types.d.ts +5 -0
  24. package/dist/types/modules/panels/model/market.d.ts +2 -0
  25. package/dist/types/modules/panels/model/publish-preview-routes.d.ts +1 -1
  26. package/dist/types/shared/api/host/diy-publish-preview.d.ts +11 -0
  27. package/dist/types/shared/api/host/follow-up-dismiss.d.ts +2 -0
  28. package/dist/types/shared/api/host/migrate-workbench.d.ts +20 -0
  29. package/dist/types/shared/api/host/migration-follow-up.d.ts +12 -0
  30. package/dist/types/shared/hooks/market-queries.d.ts +3 -2
  31. package/dist/types/shared/hooks/resource-view.d.ts +14 -0
  32. package/dist/types/shared/hooks/use-api-resource.d.ts +3 -7
  33. package/package.json +3 -3
  34. package/scripts/seed-profile.sh +9 -7
  35. package/scripts/share-data-root.mjs +272 -64
  36. package/skills/workbench-module-diy/FAMILY.md +1 -1
  37. package/skills/workbench-module-diy/REVIEW.md +2 -2
  38. package/skills/workbench-module-diy/SKILL.md +1 -0
  39. package/skills/workbench-module-diy/TOOLS.md +1 -1
  40. package/skills/workbench-module-diy/WIRING.md +3 -1
  41. package/skills/workbench-module-diy/WRITES.md +1 -1
package/README.md CHANGED
@@ -34,6 +34,18 @@ npx @dsh-workbench/core --profile wb2
34
34
 
35
35
  全局装过就不用 `npx`:`npm i -g @dsh-workbench/core` 之后直接 `dsh-workbench`。
36
36
 
37
+ 从 1.0.0 之前的独立实例升上来:旧数据**不会**自动并。先退出所有 dsh,再跑:
38
+
39
+ ```bash
40
+ dsh-workbench migrate # 切共用根 + 并旧会话/项目/附件
41
+ dsh-workbench migrate --force # 已经迁过一次、想再补并一次
42
+ ```
43
+
44
+ 只会补缺、不覆盖;旧目录保留。npx 用户把 `dsh-workbench` 换成 `npx @dsh-workbench/core`。
45
+
46
+ 更新后也可以直接在模块市场的「工作台」那一行点「迁移旧数据」;和命令行是同一条迁移逻辑,不需要自己敲命令。
47
+ 这条提示是非硬性的:也可以点「不再提醒」把它收起——不会删旧数据,旧项目仍然留在旧目录,以后需要时仍可跑 `dsh-workbench migrate`。
48
+
37
49
  先决条件(就三条):
38
50
 
39
51
  | 要有 | 为什么 |
@@ -48,6 +60,7 @@ npx @dsh-workbench/core --profile wb2
48
60
  |---|---|
49
61
  | `dsh-workbench create` | 交互式新建一个工作台实例 |
50
62
  | `dsh-workbench setup` | 幂等建默认的 `workbench` profile;配 `--from` 建别的名字 |
63
+ | `dsh-workbench migrate` | 把旧实例的会话 / 项目 / 附件并到共用数据根(`--force` 可重跑) |
51
64
  | `dsh-workbench` | 起工作台(默认端口 `:3081`,其余参数透传给 `dsh web`) |
52
65
  | `dsh-workbench --profile <名字>` | 起指定实例 |
53
66
  | `dsh-workbench setup --from <来源> --profile <新名>` | 以某个现有 profile 为模板建一个 |
@@ -78,7 +91,7 @@ npx @dsh-workbench/core --profile wb2
78
91
  | `profile/` | 出厂 profile 模板:可写根那一行(启动器 `--patch` 用,seed 也抄进 profile) |
79
92
  | `skills/` | 模块 DIY 指引,装好后挂给 agent;漏了不报错,只是 agent 不知道要怎么做模块 |
80
93
  | `bin/` | `dsh-workbench` 启动器、隔离 opencli 的入口 |
81
- | `scripts/` | 随包出货的脚本:`seed-profile.sh` / `seed-workshop.sh` / `create-workbench.mjs` / `clone-profile.mjs` |
94
+ | `scripts/` | 随包出货的脚本:`seed-profile.sh` / `seed-workshop.sh` / `create-workbench.mjs` / `clone-profile.mjs` / `share-data-root.mjs` |
82
95
 
83
96
  ## 数据落在哪
84
97
 
@@ -92,8 +105,8 @@ npx @dsh-workbench/core --profile wb2
92
105
  | DIY 工坊依赖安装日志 | `~/.dsh/workbench/seed.log` |
93
106
 
94
107
  独立实例**只分 profile,不分数据根**:会话、项目、附件跟 `dsh web` 和 Desktop 是同一份,
95
- 只有设置与插件各一份。旧版本分过家的实例,下次启动会把 `~/.dsh/workbench/{sessions,storages,attachments}`
96
- 并回共用根(只补不覆盖,旧目录保留)。
108
+ 只有设置与插件各一份。旧版本分过家的实例,启动时**不会**自动并;先退出所有 dsh,再跑
109
+ `dsh-workbench migrate`(只补不覆盖,旧目录保留)。
97
110
 
98
111
  设置只有一份,写在哪都看得见:
99
112
 
package/bin/dsh-workbench CHANGED
@@ -8,6 +8,7 @@
8
8
  # # 以 web 为模板建一个独立工作台
9
9
  # ./bin/dsh-workbench --profile wb2 # ② 起指定 profile,默认 :3081
10
10
  # ./bin/dsh-workbench --no-open # 其余参数透传给 dsh web
11
+ # ./bin/dsh-workbench migrate # 把旧实例的会话/项目/附件并到共用数据根(--force 可重跑)
11
12
  # ./bin/dsh-workbench --help
12
13
  #
13
14
  # 与 `dsh web` 并存:不同的 profile、不同的 node_modules、不同的端口、独立的进程。
@@ -35,6 +36,8 @@ PROFILE_EXPLICIT=0
35
36
  [ -n "${WORKBENCH_PROFILE:-}" ] && PROFILE_EXPLICIT=1
36
37
  SETUP=0
37
38
  CREATE=0
39
+ MIGRATE=0
40
+ FORCE=0
38
41
  DSH_ARGS=()
39
42
 
40
43
  die() {
@@ -43,7 +46,7 @@ die() {
43
46
  }
44
47
 
45
48
  usage() {
46
- sed -n '3,15p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
49
+ sed -n '3,12p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
47
50
  }
48
51
 
49
52
  if [ "${1:-}" = "create" ]; then
@@ -54,6 +57,10 @@ if [ "${1:-}" = "setup" ]; then
54
57
  SETUP=1
55
58
  shift
56
59
  fi
60
+ if [ "${1:-}" = "migrate" ]; then
61
+ MIGRATE=1
62
+ shift
63
+ fi
57
64
 
58
65
  while [ $# -gt 0 ]; do
59
66
  case "$1" in
@@ -75,6 +82,11 @@ while [ $# -gt 0 ]; do
75
82
  echo "dsh-workbench: 会话与项目跟 dsh web 共用一份数据根,$1 不再需要(忽略)。" >&2
76
83
  shift
77
84
  ;;
85
+ --force)
86
+ [ "$MIGRATE" = "1" ] || die "--force 只用于 migrate"
87
+ FORCE=1
88
+ shift
89
+ ;;
78
90
  --no-settings) WB_COPY_SETTINGS=0; shift ;;
79
91
  help | --help | -h) usage; exit 0 ;;
80
92
  --) shift; DSH_ARGS+=("$@"); break ;;
@@ -85,6 +97,9 @@ done
85
97
  if [ "$SETUP" = "1" ] && [ ${#DSH_ARGS[@]} -gt 0 ]; then
86
98
  die "setup 不认识这些参数:${DSH_ARGS[*]}"
87
99
  fi
100
+ if [ "$MIGRATE" = "1" ] && [ ${#DSH_ARGS[@]} -gt 0 ]; then
101
+ die "migrate 不认识这些参数:${DSH_ARGS[*]}"
102
+ fi
88
103
  if [ "${WB_CLONE:-0}" = "1" ] && [ "$PROFILE_EXPLICIT" = "0" ]; then
89
104
  die "用 --from 时还要指定 --profile <新名字>(例如 --from web --profile wb2)"
90
105
  fi
@@ -272,6 +287,22 @@ if [ ! -f "$PROFILE_DIR/package.json" ]; then
272
287
  exit 1
273
288
  fi
274
289
 
290
+ if [ "$MIGRATE" = "1" ]; then
291
+ MIGRATE_ARGS=(--migrate)
292
+ [ "$FORCE" = "1" ] && MIGRATE_ARGS+=(--force)
293
+ WORKBENCH_PROFILE="$PROFILE" DSH_HOME="$DSH_HOME" DSH_WORKBENCH_HOME="$WORKBENCH_HOME" \
294
+ node "$REPO_DIR/scripts/share-data-root.mjs" "${MIGRATE_ARGS[@]}" || exit 1
295
+ if [ "$PROFILE" = "workbench" ]; then
296
+ START_CMD="$REPO_DIR/bin/dsh-workbench"
297
+ else
298
+ START_CMD="$REPO_DIR/bin/dsh-workbench --profile $PROFILE"
299
+ fi
300
+ echo
301
+ echo "迁移结束。现在起工作台:$START_CMD"
302
+ echo "如果 dsh web 刚才也开着,先重启它,让它从共用根重新读一遍。"
303
+ exit 0
304
+ fi
305
+
275
306
  # ── 硬门禁:工作台 bundle 必须**被选中**(在 `dsh.profile.bundles` 里)─────────
276
307
  #
277
308
  # 判据只能是 `dsh.profile.bundles`,**不能** grep 整个 package.json:依赖装着 ≠ 被选中。
@@ -307,15 +338,16 @@ if [ "$BUNDLE_GUARD" -ne 0 ]; then
307
338
  exit 1
308
339
  fi
309
340
 
310
- # ── 已有实例:把会话 / 项目 / 附件收回到共用数据根(幂等,每次启动都过一遍)
341
+ # ── 已有实例:只整理配置,旧数据不自动迁移
311
342
  #
312
343
  # 旧版本给 workbench profile 追加过隔离的三行(sessions / storages / attachment 指到
313
- # `$DSH_HOME/workbench/**`)。现在改成跟 Desktop 一样「只分 profile、不分数据根」,
314
- # 那三行与旧数据都在这条命令里收回来;新 profile 上它只补可写根那一行。
315
- # 必须排在这里(exec dsh 之前):那几行要在这一代配置读进去之前就改好。
344
+ # `$DSH_HOME/workbench/**`)。现在缺省跟 Desktop 一样「只分 profile、不分数据根」;
345
+ # 但如果旧目录里还有数据、且没有 `.data-root-shared`,这里只打印 migrate 提示,
346
+ # 不改 profile、不动数据 —— 由用户自己决定什么时候并。
347
+ # 必须排在这里(exec dsh 之前):配置要在这一代 dsh 读进去之前就定好。
316
348
  WORKBENCH_PROFILE="$PROFILE" DSH_HOME="$DSH_HOME" DSH_WORKBENCH_HOME="$WORKBENCH_HOME" \
317
349
  node "$REPO_DIR/scripts/share-data-root.mjs" ||
318
- echo "dsh-workbench: 提醒 —— 数据根没整理成(见上一行),这次仍按现在的 profile 起。" >&2
350
+ echo "dsh-workbench: 提醒 —— 数据根配置没整理成(见上一行),这次仍按现在的 profile 起。" >&2
319
351
 
320
352
  # 清掉从父 dsh 会话继承来的身份变量。
321
353
  #