@dsh-plugin/dsh-pack-plugin 0.0.0-stage → 0.0.1

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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +178 -3
  3. package/cordis.patch.yml +9 -0
  4. package/icons/folder-zip-line.svg +1 -0
  5. package/lib/ball.js +597 -0
  6. package/lib/client.js +2934 -0
  7. package/lib/host.js +51745 -0
  8. package/lib/migrate-helper.js +35346 -0
  9. package/lib/progress-main.cjs +79 -0
  10. package/lib/progress-window.ps1 +114 -0
  11. package/lib/progress.html +126 -0
  12. package/lib/publish-to-github/SKILL.md +132 -0
  13. package/package.json +77 -4
  14. package/src/ball-entry.js +5 -0
  15. package/src/ball-host.js +99 -0
  16. package/src/ball-settings.js +352 -0
  17. package/src/ball.js +418 -0
  18. package/src/channel.js +12 -0
  19. package/src/client-plugin.js +58 -0
  20. package/src/client-rpc.js +14 -0
  21. package/src/client.js +5 -0
  22. package/src/core/discovery.js +192 -0
  23. package/src/core/dspack.js +93 -0
  24. package/src/core/extension-files.js +102 -0
  25. package/src/core/extension-install.js +295 -0
  26. package/src/core/extension-patch.js +369 -0
  27. package/src/core/extension-skills.js +164 -0
  28. package/src/core/extension-validate.js +127 -0
  29. package/src/core/extensions.js +207 -0
  30. package/src/core/home-store.js +32 -0
  31. package/src/core/host.js +149 -0
  32. package/src/core/index.js +59 -0
  33. package/src/core/inspect.js +162 -0
  34. package/src/core/install.js +775 -0
  35. package/src/core/managed-install.js +84 -0
  36. package/src/core/manifest.js +717 -0
  37. package/src/core/market.js +268 -0
  38. package/src/core/mcp-composition.js +189 -0
  39. package/src/core/mcp-install.js +112 -0
  40. package/src/core/mcp-transport.js +116 -0
  41. package/src/core/pack.js +371 -0
  42. package/src/core/plugin-metadata.js +355 -0
  43. package/src/core/registry.js +316 -0
  44. package/src/core/repo.js +339 -0
  45. package/src/core/scan.js +78 -0
  46. package/src/core/security.js +101 -0
  47. package/src/core/special.js +50 -0
  48. package/src/core/tar.js +103 -0
  49. package/src/core/update-config.js +234 -0
  50. package/src/core/update.js +792 -0
  51. package/src/core/vendored.js +715 -0
  52. package/src/core/workspace.js +95 -0
  53. package/src/endpoints.js +455 -0
  54. package/src/ensure-manager.js +186 -0
  55. package/src/host-node.js +625 -0
  56. package/src/host.js +17 -0
  57. package/src/index.d.ts +7 -0
  58. package/src/index.js +39 -0
  59. package/src/junction.js +142 -0
  60. package/src/migrate-helper.js +225 -0
  61. package/src/migrate.js +56 -0
  62. package/src/packaged.js +9 -0
  63. package/src/profiles.js +106 -0
  64. package/src/progress-main.cjs +79 -0
  65. package/src/progress-window.ps1 +114 -0
  66. package/src/progress.html +126 -0
  67. package/src/progress.js +132 -0
  68. package/src/rpc.js +157 -0
  69. package/src/runtime.js +43 -0
  70. package/src/section-gate.js +50 -0
  71. package/src/settings-nav-icon.js +188 -0
  72. package/src/settings.js +1611 -0
  73. package/src/skills/index.js +90 -0
  74. package/src/skills/publish-to-github/SKILL.md +132 -0
  75. package/src/tasks.js +145 -0
  76. package/src/v6-dialogs.js +312 -0
@@ -0,0 +1,79 @@
1
+ // 切换进度窗口(方案 A 执行体)。
2
+ //
3
+ // 由 progress.js 用 process.execPath 直接派生、不带 ELECTRON_RUN_AS_NODE,走 GUI:
4
+ // frameless + always-on-top 小窗,主进程轮询 progress.json,phase=done/failed 时自动关闭。
5
+ // 渲染在 progress.html(renderer 直读 progress.json,走 nodeIntegration,无远程内容、无需 IPC)。
6
+ const { app, BrowserWindow } = require('electron');
7
+ const fs = require('node:fs');
8
+ const path = require('node:path');
9
+
10
+ const progressFile = (() => {
11
+ for (const a of process.argv.slice(2)) {
12
+ const m = /^--progress-file=(.*)$/.exec(a);
13
+ if (m) return m[1];
14
+ }
15
+ return null;
16
+ })();
17
+
18
+ let win = null;
19
+ let closed = false;
20
+
21
+ function closeAfter(ms) {
22
+ if (closed) return;
23
+ closed = true;
24
+ setTimeout(() => {
25
+ if (win && !win.isDestroyed()) win.close();
26
+ }, ms);
27
+ }
28
+
29
+ function tick() {
30
+ if (!win || win.isDestroyed()) return;
31
+ let raw = null;
32
+ try {
33
+ raw = fs.readFileSync(progressFile, 'utf8');
34
+ } catch { /* 尚未写入 */ }
35
+ if (!raw) return;
36
+ let data = null;
37
+ try {
38
+ data = JSON.parse(raw);
39
+ } catch { return; /* 半截写,等下一帧 */ }
40
+ if (data.phase === 'done') closeAfter(1200);
41
+ else if (data.phase === 'failed') closeAfter(2500);
42
+ }
43
+
44
+ if (!progressFile) {
45
+ app.whenReady().then(() => app.quit());
46
+ } else {
47
+ app.whenReady().then(() => {
48
+ win = new BrowserWindow({
49
+ width: 420,
50
+ height: 380,
51
+ frame: false,
52
+ resizable: false,
53
+ alwaysOnTop: true,
54
+ skipTaskbar: true,
55
+ show: false,
56
+ backgroundColor: '#1e1f24',
57
+ webPreferences: {
58
+ nodeIntegration: true,
59
+ contextIsolation: false,
60
+ sandbox: false,
61
+ },
62
+ });
63
+ win.loadFile(path.join(__dirname, 'progress.html'), { query: { file: progressFile } });
64
+ win.once('ready-to-show', () => {
65
+ if (win && !win.isDestroyed()) win.show();
66
+ });
67
+ const timer = setInterval(tick, 200);
68
+ win.on('closed', () => {
69
+ clearInterval(timer);
70
+ win = null;
71
+ });
72
+ // 兜底:60s 无论如何都关(helper 若中途崩掉,窗口不能赖在屏幕上)。
73
+ setTimeout(() => {
74
+ if (win && !win.isDestroyed()) win.close();
75
+ }, 60000);
76
+ });
77
+ }
78
+
79
+ app.on('window-all-closed', () => app.quit());
@@ -0,0 +1,114 @@
1
+ # DSH PackForge profile-switch progress window (packaged-build replacement for the electron popup).
2
+ #
3
+ # Spawned by the migration helper as:
4
+ # powershell -NoProfile -File progress-window.ps1 -ProgressFile <path>
5
+ # It polls progress.json and renders the step timeline; closes itself when phase is done/failed.
6
+ #
7
+ # MUST run under Windows PowerShell 5.1 (powershell.exe), which is STA and can show WPF windows.
8
+ # pwsh (PowerShell 7+) is MTA and will throw on window creation.
9
+ #
10
+ # Keep this file pure ASCII: Windows PowerShell 5.1 reads .ps1 in the ANSI codepage, so any
11
+ # non-ASCII literal (Chinese comments, symbols) would garble. Labels come from progress.json
12
+ # (read as UTF-8), so nothing non-ASCII is hardcoded here.
13
+ param([Parameter(Mandatory = $true)][string]$ProgressFile)
14
+
15
+ Add-Type -AssemblyName PresentationFramework
16
+ Add-Type -AssemblyName PresentationCore
17
+
18
+ function Read-Progress {
19
+ if (-not (Test-Path -LiteralPath $ProgressFile)) { return $null }
20
+ try {
21
+ $raw = [System.IO.File]::ReadAllText($ProgressFile)
22
+ return ($raw | ConvertFrom-Json)
23
+ } catch { return $null }
24
+ }
25
+
26
+ function New-Brush([string]$hex) {
27
+ return ([System.Windows.Media.BrushConverter]::new()).ConvertFromString($hex)
28
+ }
29
+
30
+ $window = New-Object System.Windows.Window
31
+ $window.Title = 'DSH PackForge'
32
+ $window.WindowStyle = [System.Windows.WindowStyle]::None
33
+ $window.ResizeMode = [System.Windows.ResizeMode]::NoResize
34
+ $window.Topmost = $true
35
+ $window.ShowInTaskbar = $false
36
+ $window.Width = 380
37
+ $window.Height = 272
38
+ $window.Background = New-Brush '#1e1f24'
39
+ $window.WindowStartupLocation = [System.Windows.WindowStartupLocation]::Manual
40
+ $wa = [System.Windows.SystemParameters]::WorkArea
41
+ $window.Left = $wa.Right - $window.Width - 20
42
+ $window.Top = $wa.Bottom - $window.Height - 20
43
+
44
+ $root = New-Object System.Windows.Controls.StackPanel
45
+ $root.Margin = New-Object System.Windows.Thickness(18)
46
+
47
+ $title = New-Object System.Windows.Controls.TextBlock
48
+ $title.FontSize = 14
49
+ $title.FontWeight = 'SemiBold'
50
+ $title.Foreground = New-Brush '#e6e6ea'
51
+ $title.Text = 'DSH PackForge'
52
+ $root.AddChild($title) | Out-Null
53
+
54
+ $subtitle = New-Object System.Windows.Controls.TextBlock
55
+ $subtitle.FontSize = 11
56
+ $subtitle.Foreground = New-Brush '#8b8c95'
57
+ $subtitle.Margin = New-Object System.Windows.Thickness(0, 2, 0, 0)
58
+ $root.AddChild($subtitle) | Out-Null
59
+
60
+ $stepsPanel = New-Object System.Windows.Controls.StackPanel
61
+ $stepsPanel.Margin = New-Object System.Windows.Thickness(0, 12, 0, 0)
62
+ $root.AddChild($stepsPanel) | Out-Null
63
+
64
+ $hint = New-Object System.Windows.Controls.TextBlock
65
+ $hint.FontSize = 11
66
+ $hint.Foreground = New-Brush '#8b8c95'
67
+ $hint.TextWrapping = [System.Windows.TextWrapping]::Wrap
68
+ $hint.Margin = New-Object System.Windows.Thickness(0, 12, 0, 0)
69
+ $root.AddChild($hint) | Out-Null
70
+
71
+ $window.Content = $root
72
+
73
+ $statusGlyph = @{
74
+ pending = ' '
75
+ running = [char]0x25D1
76
+ done = [char]0x25C9
77
+ failed = [char]0x00D7
78
+ }
79
+ $statusColor = @{
80
+ pending = '#5a5b63'
81
+ running = '#6ab7ff'
82
+ done = '#2ea44f'
83
+ failed = '#d3383a'
84
+ }
85
+
86
+ $timer = New-Object System.Windows.Threading.DispatcherTimer
87
+ $timer.Interval = [System.TimeSpan]::FromMilliseconds(200)
88
+ $timer.Add_Tick({
89
+ $p = Read-Progress
90
+ if ($null -eq $p) { return }
91
+ $subtitle.Text = "$($p.from) -> $($p.to)"
92
+ if ($null -ne $p.hint) { $hint.Text = [string]$p.hint } else { $hint.Text = '' }
93
+ $stepsPanel.Children.Clear()
94
+ foreach ($s in @($p.steps)) {
95
+ $line = New-Object System.Windows.Controls.TextBlock
96
+ $glyph = $statusGlyph[$s.status]
97
+ if ($null -eq $glyph) { $glyph = ' ' }
98
+ $line.Text = "$glyph $($s.label)"
99
+ $line.FontSize = 13
100
+ $line.Margin = New-Object System.Windows.Thickness(0, 4, 0, 0)
101
+ $col = $statusColor[$s.status]
102
+ if ($null -eq $col) { $col = '#9a9ba3' }
103
+ $line.Foreground = New-Brush $col
104
+ $stepsPanel.AddChild($line) | Out-Null
105
+ }
106
+ if ($p.phase -eq 'done' -or $p.phase -eq 'failed') {
107
+ $timer.Stop()
108
+ Start-Sleep -Milliseconds 700
109
+ $window.Close()
110
+ }
111
+ })
112
+ $timer.Start()
113
+
114
+ $window.ShowDialog() | Out-Null
@@ -0,0 +1,126 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>切换中</title>
6
+ <style>
7
+ :root { color-scheme: dark; }
8
+ * { box-sizing: border-box; }
9
+ html, body { margin: 0; }
10
+ body {
11
+ padding: 16px 18px 18px;
12
+ font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
13
+ background: #1e1f24; color: #e8e9ed;
14
+ user-select: none; -webkit-user-select: none;
15
+ }
16
+ .title { font-size: 15px; font-weight: 600; text-align: center; margin: 2px 0 12px; letter-spacing: 3px; }
17
+ .current {
18
+ text-align: center; font-size: 17px; font-weight: 700; color: #6ab7ff;
19
+ margin: 0 0 16px; min-height: 24px;
20
+ }
21
+ .current .dots { display: inline-block; animation: blink 1.2s steps(2, start) infinite; }
22
+ @keyframes blink { to { visibility: hidden; } }
23
+ .timeline { display: flex; flex-direction: column; gap: 10px; }
24
+ .step { display: flex; align-items: center; gap: 10px; }
25
+ .dot {
26
+ width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
27
+ display: flex; align-items: center; justify-content: center;
28
+ font-size: 12px; color: #fff; background: #3a3c43;
29
+ }
30
+ .step.done .dot { background: #2ea44f; }
31
+ .step.failed .dot { background: #d3383a; }
32
+ .step.pending .dot { background: #3a3c43; color: #6b6d76; }
33
+ .step.running .dot {
34
+ background: transparent;
35
+ border: 2px solid #6ab7ff; border-top-color: transparent;
36
+ animation: spin 0.8s linear infinite;
37
+ }
38
+ @keyframes spin { to { transform: rotate(360deg); } }
39
+ .label { font-size: 14px; line-height: 20px; }
40
+ .step.pending .label { color: #6b6d76; }
41
+ .step.done .label { color: #9aa0aa; }
42
+ .step.running .label { color: #e8e9ed; font-weight: 600; }
43
+ .step.failed .label { color: #ff8b8c; }
44
+ .mark { margin-left: auto; font-size: 12px; color: #6b6d76; }
45
+ .step.done .mark { color: #2ea44f; }
46
+ .step.failed .mark { color: #d3383a; }
47
+ .error { margin-top: 10px; font-size: 12px; line-height: 18px; color: #ff8b8c; word-break: break-all; }
48
+ .hint { margin-top: 14px; padding-top: 12px; border-top: 1px solid #2c2d33; font-size: 12px; line-height: 18px; color: #8b8c95; text-align: center; }
49
+ </style>
50
+ </head>
51
+ <body>
52
+ <div class="title">切换中</div>
53
+ <div class="current" id="current"></div>
54
+ <div class="timeline" id="timeline"></div>
55
+ <div class="hint" id="hint"></div>
56
+ <script>
57
+ const fs = require('node:fs');
58
+ const q = new URLSearchParams(location.search);
59
+ const file = q.get('file');
60
+ const currentEl = document.getElementById('current');
61
+ const timelineEl = document.getElementById('timeline');
62
+ const hintEl = document.getElementById('hint');
63
+ const DOT_MARK = { done: '✓', running: '', pending: '○', failed: '✗' };
64
+ const TAIL = { done: '完成', running: '进行中', failed: '失败', pending: '待办' };
65
+ let lastRaw = null;
66
+
67
+ function render(data) {
68
+ const steps = Array.isArray(data.steps) ? data.steps : [];
69
+ const running = steps.find((s) => s.status === 'running');
70
+ currentEl.innerHTML = running
71
+ ? '正在:' + escapeHtml(running.label) + '<span class="dots">…</span>'
72
+ : (data.phase === 'done' ? '完成' : data.phase === 'failed' ? '切换失败' : '准备中…');
73
+
74
+ timelineEl.textContent = '';
75
+ for (const s of steps) {
76
+ const st = s.status || 'pending';
77
+ const row = document.createElement('div');
78
+ row.className = 'step ' + st;
79
+
80
+ const dot = document.createElement('div');
81
+ dot.className = 'dot';
82
+ dot.textContent = st === 'running' ? '' : (DOT_MARK[st] || '○');
83
+
84
+ const label = document.createElement('div');
85
+ label.className = 'label';
86
+ label.textContent = s.label;
87
+
88
+ const mark = document.createElement('div');
89
+ mark.className = 'mark';
90
+ mark.textContent = TAIL[st] || '';
91
+
92
+ row.appendChild(dot);
93
+ row.appendChild(label);
94
+ row.appendChild(mark);
95
+ timelineEl.appendChild(row);
96
+ }
97
+ if (data.phase === 'failed' && data.error) {
98
+ const err = document.createElement('div');
99
+ err.className = 'error';
100
+ err.textContent = String(data.error);
101
+ timelineEl.appendChild(err);
102
+ }
103
+ hintEl.textContent = data.hint ? String(data.hint) : '';
104
+ }
105
+
106
+ function escapeHtml(s) {
107
+ return String(s).replace(/[&<>"']/g, (c) => (
108
+ { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]
109
+ ));
110
+ }
111
+
112
+ function tick() {
113
+ let raw = null;
114
+ try { raw = fs.readFileSync(file, 'utf8'); } catch { /* 尚未写入 */ }
115
+ if (raw === lastRaw) return;
116
+ lastRaw = raw;
117
+ let data = null;
118
+ try { data = raw ? JSON.parse(raw) : null; } catch { return; }
119
+ if (data) render(data);
120
+ }
121
+
122
+ setInterval(tick, 200);
123
+ tick();
124
+ </script>
125
+ </body>
126
+ </html>
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: publish-to-github
3
+ description: 把 DSH 整合包发布到 GitHub 供 dsh-pack-market 自动收录——建 public 仓库、打 dsh-pack 话题、发正式 Release(.dspack + .sha256 侧车)、逐项校验。
4
+ whenToUse: 用户要「发布/上传整合包到 GitHub」「发 Release」「让整合包被市场收录」时。
5
+ invocation: 发布到 GitHub / 发布整合包 / publish to github
6
+ ---
7
+
8
+ # 发布整合包到 GitHub
9
+
10
+ 把「一个整合包从本机走上 GitHub、被 `dsh-pack-market` 自动收录」执行到底。权威契约见 `specs/publishing/v1.md`,冲突时以 spec 为准;分步教程见 `docs/publishing-tutorial.md`。
11
+
12
+ ## 执行前:收集变量
13
+
14
+ 先向用户确认(或从 manifest / 产物读取)以下四个变量,缺一不可:
15
+
16
+ | 变量 | 含义 | 来源 |
17
+ |---|---|---|
18
+ | `<owner>` | GitHub 用户 / 组织名 | 问用户 |
19
+ | `<name>` | 包名 = 仓库名(kebab-case) | `manifest.name` |
20
+ | `<version>` | 包版本(semver) | `manifest.version` |
21
+ | `<tag>` | Release tag = `v<version>` | 由 `<version>` 派生 |
22
+
23
+ > 硬约束:`<name>` 与 `<version>` 必须和根 `manifest.json` 的 `name` / `version` **逐字一致**,否则采集器扫不到或索引键错位。
24
+
25
+ ## 第 1 步:确认产物路径(二选一)
26
+
27
+ - **路径 A(推荐)**:用户装了 `dsh-packforge-app`、有 `dspack` CLI 和本机 profile → 用 `dspack pack --repo`。
28
+ - **路径 B(手工)**:用户手里已有 `manifest.json` + `overrides/` + 已打包的 `.dspack`。
29
+
30
+ ## 第 2 步:准备产物(按所选路径)
31
+
32
+ **路径 A**:
33
+
34
+ ```bash
35
+ dspack pack --repo <profile目录> --out <输出目录>
36
+ ```
37
+
38
+ 产出 `<输出目录>/<name>/`:源仓库(已 git init + commit)+ `release/` 成品区(`.dspack` 与 `.dspack.sha256` 侧车已写好)。校验点:`release/` 里两个文件都在;`git log` 有提交 `export:<name>@<version>`。
39
+
40
+ **路径 B**:在 `<name>/` 下摆好 `manifest.json`(根,v5)、`overrides/`、`README.md`,然后:
41
+
42
+ ```bash
43
+ git init && git add . && git commit -m "export:<name>@<version>"
44
+ ```
45
+
46
+ 再生成 sha256 侧车(文件名 = 打包资产名 + `.sha256`,内容 = 64 位小写 hex):
47
+
48
+ ```powershell
49
+ # Windows PowerShell
50
+ (Get-FileHash .\<name>-<version>.dspack -Algorithm SHA256).Hash.ToLower() `
51
+ | Out-File -Encoding ascii .\<name>-<version>.dspack.sha256
52
+ ```
53
+
54
+ ```bash
55
+ # macOS / Linux
56
+ shasum -a 256 <name>-<version>.dspack | cut -d' ' -f1 > <name>-<version>.dspack.sha256
57
+ ```
58
+
59
+ 校验点:`.dspack` 与 `.dspack.sha256` 都在;侧车为 64 位小写 hex,无大写、无多余内容。
60
+
61
+ ## 第 3 步:建 public 仓库 + 打话题
62
+
63
+ 在源仓库目录内执行:
64
+
65
+ ```bash
66
+ gh repo create <owner>/<name> --public --source . --push
67
+ gh repo edit <owner>/<name> --add-topic dsh-pack
68
+ ```
69
+
70
+ 校验点:
71
+
72
+ ```bash
73
+ gh repo view <owner>/<name> --json visibility,repositoryTopics \
74
+ --jq '{visibility, topics: [.repositoryTopics[].name]}'
75
+ # 期望:{"visibility":"PUBLIC", "topics":["dsh-pack", ...]}
76
+ ```
77
+
78
+ > 三件硬事缺一不可:**public**、**`dsh-pack` 话题**、**根 `manifest.json`**。`archived` 仓库会被跳过,别归档。
79
+
80
+ ## 第 4 步:发正式 Release
81
+
82
+ ```bash
83
+ # 路径 A:资产在 release/ 目录
84
+ gh release create <tag> \
85
+ release/<name>-<version>.dspack \
86
+ release/<name>-<version>.dspack.sha256 \
87
+ --title "<name> v<version>"
88
+
89
+ # 路径 B:资产在当前目录(去掉 release/ 前缀)
90
+ gh release create <tag> \
91
+ <name>-<version>.dspack \
92
+ <name>-<version>.dspack.sha256 \
93
+ --title "<name> v<version>"
94
+ ```
95
+
96
+ 硬约束:
97
+
98
+ - tag 必须是 `v<version>`(对应 `manifest.version`);
99
+ - 必须是**正式发布**——**不加** `--draft` / `--prerelease`,否则 `releases/latest` 取不到;
100
+ - **同一 Release 只放一个打包资产**(采集器按 `.dspack > .tgz > .zip` 只取一个,混放可能选中旧包)。
101
+
102
+ 校验点:`gh release view <tag>` → 非 draft、非 prerelease;资产恰好两个(`.dspack` + `.dspack.sha256`)。
103
+
104
+ ## 第 5 步:逐项校验并回报用户
105
+
106
+ - [ ] 仓库 `public`;已打 `dsh-pack`;未 `archived`
107
+ - [ ] 默认分支根 `manifest.json` 存在,`name` / `version` 与仓库名 / tag 一致
108
+ - [ ] Release tag = `v<version>`
109
+ - [ ] Release 为正式发布(非 draft / 非 prerelease)
110
+ - [ ] 只有一个打包资产 `<name>-<version>.dspack`
111
+ - [ ] 侧车 `<name>-<version>.dspack.sha256` 为 64 位小写 hex
112
+
113
+ ## 第 6 步:告知收录方式
114
+
115
+ 收录是**异步**的(采集器按周期跑,非发版即时)。告诉用户等一轮扫描后查市场:
116
+
117
+ ```bash
118
+ curl -s https://raw.githubusercontent.com/dsh-pack-market/dsh-pack-market/main/index/index.json \
119
+ | jq '.modpacks[] | select(.name == "<name>")'
120
+ ```
121
+
122
+ 期望出现条目,且 `downloadUrl` / `sha256` / `size` 三指针齐全。
123
+
124
+ ## 常见坑速查(出现即按此修)
125
+
126
+ | 现象 | 原因 | 修法 |
127
+ |---|---|---|
128
+ | 市场扫不到 | 没打 `dsh-pack` 话题 / 仓库私有 / 已 `archived` | 三件套补齐 |
129
+ | 有条目但下载失败 | Release 是 draft / prerelease | 删掉重发正式 Release |
130
+ | 装的是旧包 | 同一 Release 混放多个打包资产 | 只留一个 `.dspack` |
131
+ | sha256 对不上 | 侧车写了大写 hex 或带多余内容 | 重生成,只写小写 hex |
132
+ | tag 与版本不一致 | `v<tag>` 没对齐 `manifest.version` | 改 tag 或改 manifest |
package/package.json CHANGED
@@ -1,6 +1,79 @@
1
1
  {
2
2
  "name": "@dsh-plugin/dsh-pack-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "DSH 纯方案 B 插件 bundle:.dspack 导出/导入/多 profile,零官方源码改动、零第三方插件",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "hxh230802",
9
+ "url": "https://github.com/hxh230802"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/dsh-plugins/dsh-pack-plugin.git"
14
+ },
15
+ "homepage": "https://github.com/dsh-plugins/dsh-pack-plugin#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/dsh-plugins/dsh-pack-plugin/issues"
18
+ },
19
+ "icon": "icons/folder-zip-line.svg",
20
+ "main": "lib/host.js",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./src/index.d.ts",
24
+ "default": "./lib/host.js"
25
+ },
26
+ "./client": "./lib/client.js",
27
+ "./cordis.patch.yml": "./cordis.patch.yml"
28
+ },
29
+ "files": [
30
+ "src",
31
+ "lib",
32
+ "icons",
33
+ "cordis.patch.yml"
34
+ ],
35
+ "dsh": {
36
+ "bundle": {
37
+ "patch": "./cordis.patch.yml"
38
+ },
39
+ "client": {
40
+ "platform": "web",
41
+ "inject": [
42
+ "@deepseek-ai/dsh-client-runtime",
43
+ "@deepseek-ai/dsh-client-ui-settings",
44
+ "@deepseek-ai/dsh-client-locale",
45
+ "@deepseek-ai/dsh-client-ui-slots",
46
+ "@deepseek-ai/dsh-api-session-controller",
47
+ "@deepseek-ai/dsh-client-ui-workspace",
48
+ "@deepseek-ai/dsh-client-ui-conversation"
49
+ ]
50
+ }
51
+ },
52
+ "keywords": [
53
+ "dsh",
54
+ "deepseek",
55
+ "dspack",
56
+ "整合包",
57
+ "cordis"
58
+ ],
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "scripts": {
63
+ "test": "node --test --experimental-test-isolation=none \"test/*.test.js\"",
64
+ "bundle": "node scripts/bundle-client.mjs && node scripts/bundle-host.mjs && node scripts/bundle-ball.mjs",
65
+ "prepack": "npm run bundle && npm test"
66
+ },
67
+ "devDependencies": {
68
+ "@deepseek-ai/cordis": "4.0.2",
69
+ "@deepseek-ai/cordis-plugin-include": "1.0.7",
70
+ "@deepseek-ai/cordis-plugin-loader": "1.0.3",
71
+ "esbuild": "^0.25.0",
72
+ "fflate": "^0.8.2",
73
+ "proxy-agent": "^8.0.2",
74
+ "proxy-from-env": "^2.1.0",
75
+ "react": "^18.3.1",
76
+ "semver": "^7.8.6",
77
+ "yaml": "^2.8.1"
78
+ }
79
+ }
@@ -0,0 +1,5 @@
1
+ // 浏览器入口:宿主路由下发的 /dsh-pack/ball.js 就是本文件的 iife 产物。
2
+ // 只做一件事——自我挂载(mountBall 内部有幂等守卫,重复加载无副作用)。
3
+ import { mountBall } from './ball.js';
4
+
5
+ mountBall();
@@ -0,0 +1,99 @@
1
+ // 宿主的悬浮球接线:①把球脚本注入页面 ②给路由模块提供脚本字节。
2
+ //
3
+ // 为什么球必须由**宿主**注入,而不是挂在我们的 client 插件里:
4
+ // 整合包会装进一堆 client 插件,有的会把侧边栏/设置页搞坏 —— 那时用户进不去设置界面,
5
+ // 连换包、卸载都做不到。宿主活在 Node 进程里,注入 index.html 这条路不经过 DSH 的任何
6
+ // 前端插件,所以「别人把 UI 拆了,球还在」。这也正是鲸鱼挂件(DeepSeek-Balance-Whale-Widget)
7
+ // 的结论:动态 cordis 插件页面一刷新就没了,要常驻自启必须静态挂进组合。
8
+ //
9
+ // 注入走两条通道,靠 BALL_INJECT_MARK 互相去重:
10
+ // ① 结构化行 `webserver/index-inject`:web 形态由 renderIndexInjections 渲染进 index.html;
11
+ // 桌面壳 index.html 从静态 dist 直出、函数变换过不去,靠 IPC 把这张行表交给页面解释器
12
+ // —— 所以它是**桌面端唯一生效**的通道,且必须在宿主启动收集那次就注册上。
13
+ // ② `webServer.tapIndex` 函数变换:web 形态兜底。
14
+ //
15
+ // 行内容用内联 script(而不是 kind:'script-src'):官方页面解释器对两类行处理不对称 ——
16
+ // kind:'script' → createElement + textContent + append,没有 await,不可能"加载失败";
17
+ // kind:'script-src' → await loadScript(src),失败即 reject,会炸成致命错误
18
+ // 「failed to load /dsh-pack/ball.js」把整个页面带下水。
19
+ // 所以自己建 <script src> 并吞掉 onerror:路由在就正常加载,不在也只是没有球,页面无恙。
20
+ import { readFile } from 'node:fs/promises';
21
+ import { CHANNEL } from './channel.js';
22
+
23
+ /** 球脚本的下载路径(同 prefix 路由下发,见 rpc.js 的 GET 分支)。 */
24
+ export const BALL_SCRIPT_PATH = `${CHANNEL}/ball.js`;
25
+ /** 注入标记:用路径判断「是否已注入过」,让结构化行与 tapIndex 两条通道互相去重。 */
26
+ export const BALL_INJECT_MARK = BALL_SCRIPT_PATH;
27
+
28
+ /** 内联 loader(一行,注入进 index.html)。 */
29
+ export const BALL_INLINE_LOADER = [
30
+ '(function(){try{',
31
+ 'if(window.__dspackBall)return;',
32
+ 'var s=document.createElement("script");',
33
+ `s.src=${JSON.stringify(BALL_SCRIPT_PATH)};`,
34
+ 's.async=true;s.onerror=function(){};',
35
+ '(document.body||document.documentElement).appendChild(s);',
36
+ '}catch(e){}})();',
37
+ ].join('');
38
+
39
+ /** 结构化注入行:已存在等价行 / 已注入标记则不动(返回是否真的推了)。 */
40
+ export function ensureBallRow(table) {
41
+ if (!Array.isArray(table)) return false;
42
+ const exists = table.some((row) => {
43
+ if (!row || typeof row !== 'object') return false;
44
+ if (row.kind === 'script' && typeof row.text === 'string' && row.text.includes(BALL_INJECT_MARK)) return true;
45
+ if (row.kind === 'script-src' && row.src === BALL_SCRIPT_PATH) return true;
46
+ return false;
47
+ });
48
+ if (exists) return false;
49
+ table.push({ kind: 'script', placement: 'body', text: BALL_INLINE_LOADER });
50
+ return true;
51
+ }
52
+
53
+ /** tapIndex 变换:把 script 标签插到 </body> 前;已有标记则原样返回(幂等)。 */
54
+ export function injectBallIntoHtml(html) {
55
+ if (typeof html !== 'string' || html.includes(BALL_INJECT_MARK)) return html;
56
+ const tag = `<script defer src="${BALL_SCRIPT_PATH}"></script>`;
57
+ const at = html.lastIndexOf('</body>');
58
+ return at < 0 ? `${html}${tag}` : `${html.slice(0, at)}${tag}${html.slice(at)}`;
59
+ }
60
+
61
+ /** 球脚本产物路径:dev(src/)与打包态(lib/host.js)都解析到 <包根>/lib/ball.js。 */
62
+ const BALL_LIB_URL = new URL('../lib/ball.js', import.meta.url);
63
+
64
+ /**
65
+ * 读球脚本字节。未构建(无 lib/ball.js)时返回 null,由路由层回 404 —— 不能让缺文件
66
+ * 变成抛错(路由 handler 抛错会变成 400 空响应,页面侧完全没法诊断)。
67
+ */
68
+ export async function readBallAsset() {
69
+ try {
70
+ const bytes = await readFile(BALL_LIB_URL);
71
+ return bytes?.length ? { bytes } : null;
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * 接线:注册注入通道。ctx.effect 收尾,HMR 重载时自动摘干净(否则重复注入)。
79
+ * @returns {boolean} 是否挂上(webServer 不可用时 false)
80
+ */
81
+ export function registerBall(ctx, { log } = {}) {
82
+ const ws = ctx?.webServer;
83
+ if (!ws) return false;
84
+ const say = typeof log === 'function' ? log : () => {};
85
+
86
+ // ① 结构化行:桌面端唯一生效通道 —— 监听器要在宿主启动收集前就在位。
87
+ ctx.effect(() => {
88
+ const off = ctx.on('webserver/index-inject', (table) => {
89
+ if (ensureBallRow(table)) say(`悬浮球:已推注入行(${BALL_SCRIPT_PATH})`);
90
+ });
91
+ return () => { try { off?.(); } catch { /* 忽略 */ } };
92
+ }, 'dspack: ball index-inject');
93
+
94
+ // ② tapIndex:web 形态兜底(按标记去重,与 ① 不冲突)。
95
+ if (typeof ws.tapIndex === 'function') {
96
+ ctx.effect(() => ws.tapIndex((html) => injectBallIntoHtml(html)), 'dspack: ball tapIndex');
97
+ }
98
+ return true;
99
+ }