dsh-devdock-npm 0.0.0-stage → 3.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.
@@ -0,0 +1,11 @@
1
+ # dsh-devdock-npm bundle patch.
2
+ #
3
+ # 本行插入 npm 平台插件。它在 inject 里声明 `devdock`,所以必须先安装
4
+ # dsh-devdock-core;只装本插件时该行保持 INACTIVE(不报错、不崩),装上
5
+ # 内核后自动激活。
6
+ #
7
+ # 审查功能不在本包里:发布前审查已独立成 dsh-devdock-review。本插件会探测
8
+ # 它在不在——在就显示可用的审查入口,不在就显示灰色入口并提示安装。
9
+ - insert:
10
+ - id: push-npm
11
+ name: dsh-devdock-npm
package/icon.svg ADDED
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="32" height="32" role="img" aria-label="npm">
2
+ <rect width="24" height="24" rx="5.2" fill="#0D1117"/>
3
+ <rect x="3.6" y="6.4" width="16.8" height="11.2" rx="1.6" fill="#CB3837"/>
4
+ <path d="M6.1 9.1h4.4v6.4H8.3v-4.2H6.1z" fill="#FFFFFF"/>
5
+ <path d="M12.4 9.1h5.5v6.4h-2.2v-4.2h-1.1v4.2h-2.2z" fill="#FFFFFF"/>
6
+ </svg>
package/index.js ADDED
@@ -0,0 +1,108 @@
1
+ /**
2
+ * DevDock · npm 平台插件 · 加载器入口。
3
+ *
4
+ * 与内核同样的字节稳定 shim:本文件不得随版本变化,靠内容哈希导入实现。
5
+ *
6
+ * `inject` 里声明 `devdock` 之后,cordis 会等内核就绪再执行 apply —— 这就是
7
+ * 「先装内核、再装平台」的时序保证。内核不存在时本行保持 INACTIVE,不会让
8
+ * 组合启动失败。
9
+ *
10
+ * 本插件**不依赖**审查插件:发布前审查已独立成 dsh-devdock-review,客户端
11
+ * 用能力表探测它在不在。所以这里没有任何跨平台的 import。
12
+ *
13
+ * @module index.js
14
+ */
15
+
16
+ import { createHash } from 'node:crypto';
17
+ import { readFile } from 'node:fs/promises';
18
+
19
+ /** 实现模块。 */
20
+ const IMPL_URL = new URL('./src/host/platform.js', import.meta.url);
21
+
22
+ /**
23
+ * 按内容哈希导入实现模块。
24
+ * @returns {Promise<typeof import('./src/host/platform.js')>}
25
+ */
26
+ async function loadImpl() {
27
+ let href = IMPL_URL.href;
28
+ try {
29
+ const bytes = await readFile(IMPL_URL);
30
+ const hash = createHash('sha256').update(bytes).digest('hex').slice(0, 16);
31
+ href = `${IMPL_URL.href}?v=${hash}`;
32
+ } catch {
33
+ // 读不到就让 import 报出真正的原因。
34
+ }
35
+ return await import(/* @vite-ignore */ href);
36
+ }
37
+
38
+ /**
39
+ * 必须先就绪的宿主服务:内核 + HTTP 服务器。
40
+ *
41
+ * 把 `devdock` 写进 inject 是刻意的:没有内核时本插件没有意义,安静的
42
+ * INACTIVE 比「启动了但注册失败」更容易诊断。
43
+ *
44
+ * @type {string[]}
45
+ */
46
+ export const inject = ['webServer', 'devdock'];
47
+
48
+ /**
49
+ * 挂载:向内核注册 npm 平台。
50
+ *
51
+ * **与全量包的冲突要先说清楚**:全量包 `dsh-devdock` 自带 npm 能力,它直接
52
+ * 注册 `/api/push/npm/*`;本插件经内核挂出来的是同一批路径。两个都装时,
53
+ * 后注册的那个会撞上 `webServer` 的重复路径检查而失败——错误信息是
54
+ * 「无法注册路由 …(可能是上一次加载残留的路由)」,完全误导用户。
55
+ *
56
+ * 所以这里先探测:内核里已经有 `npm` 平台,说明全量包在场,本插件安静退出
57
+ * 并打印一句可执行的话,而不是抛一个看不懂的错。
58
+ *
59
+ * @param {import('@deepseek-ai/cordis').Context} ctx
60
+ * @returns {Promise<void>}
61
+ */
62
+ export async function apply(ctx) {
63
+ const mod = await loadImpl();
64
+ const core = typeof ctx.get === 'function' ? ctx.get('devdock') : ctx.devdock;
65
+ if (!core || typeof core.registerPlatform !== 'function') {
66
+ throw new Error('dsh-devdock-npm: 内核服务不可用,请先安装 dsh-devdock-core。');
67
+ }
68
+
69
+ /* 全量包已经在提供 npm 了:不重复注册,给一句能照做的话。 */
70
+ if (typeof core.platforms === 'function') {
71
+ const existing = core.platforms();
72
+ if (existing.some((p) => p.id === 'npm')) {
73
+ console.warn(
74
+ 'dsh-devdock-npm: 已有 npm 平台在运行(通常是全量包 dsh-devdock 自带),'
75
+ + '本插件不做重复注册。若要改用按需安装,请先卸载 dsh-devdock。',
76
+ );
77
+ return;
78
+ }
79
+ }
80
+
81
+ const definition = mod.npmPlatform(core.platformContext());
82
+ let unregister;
83
+ try {
84
+ unregister = core.registerPlatform(definition);
85
+ } catch (error) {
86
+ /* 兜底:全量包可能在我们探测之后才挂上,或路径被别的插件占用。
87
+ *
88
+ * 内核包在错误里的那句「可能是上一次加载残留的路由,重启 DSH 后重试」
89
+ * 在**这个**场景下是误导——重启没用,因为冲突来自另一个插件。所以把
90
+ * 原因和出路写清楚,并保留内核原来的信息作为 cause 供排查。 */
91
+ const detail = String(error?.message ?? error)
92
+ // 内核那句「可能是上一次加载残留的路由,重启 DSH 后重试」在这个场景
93
+ // 下是误导:重启没用,冲突来自另一个插件。引述时去掉它。
94
+ .replace(/(可能是上一次加载残留的路由;重启 DSH 后重试)/g, '');
95
+ throw new Error(
96
+ 'dsh-devdock-npm: 无法注册 npm 平台——路由已被占用。'
97
+ + '最常见的原因是同时安装了全量包 dsh-devdock(它自带 npm 能力)。'
98
+ + '二者只能留一个:想用按需安装就卸载 dsh-devdock,想用全量包就卸载本插件。'
99
+ + `(原始错误:${detail})`,
100
+ { cause: error },
101
+ );
102
+ }
103
+ if (typeof ctx.effect === 'function') {
104
+ ctx.effect(() => unregister, 'devdock: npm platform');
105
+ } else {
106
+ ctx.on?.('dispose', () => { try { unregister(); } catch { /* 已注销 */ } });
107
+ }
108
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "DevDock · npm",
4
+ "description": "Manage npm inside DeepSeek Harness: multi-account tokens, package search and details, pack preview and publish (with 2FA), preflight checks and dependency drift."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "DevDock · npm",
4
+ "description": "在 DeepSeek Harness 里管理 npm:多账号令牌、包的搜索与详情、打包预演与发布(含 2FA)、发布前自检与依赖检查。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,126 @@
1
1
  {
2
2
  "name": "dsh-devdock-npm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.0.0",
4
+ "description": "DevDock 的 npm 平台插件:Granular / Classic 令牌多账号、包的搜索与列表/卡片视图、包详情与 dist-tags、package.json 初始化、npm pack 打包预演与打包、发布(含 2FA OTP)、发布前自检与依赖是否落后。",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./client": "./client.js",
10
+ "./locale/*.json": "./locale/*.json",
11
+ "./icon": "./icon.svg",
12
+ "./cordis.patch.yml": "./cordis.patch.yml",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "index.js",
17
+ "client.js",
18
+ "cordis.patch.yml",
19
+ "src",
20
+ "locale/*.json",
21
+ "icon.svg",
22
+ "README.md",
23
+ "CHANGELOG.md",
24
+ "LICENSE"
25
+ ],
26
+ "engines": {
27
+ "node": ">=20"
28
+ },
29
+ "keywords": [
30
+ "dsh",
31
+ "dsh-plugin",
32
+ "deepseek-harness",
33
+ "devdock",
34
+ "npm",
35
+ "publish",
36
+ "pack",
37
+ "package-management"
38
+ ],
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/QingJing5906/dsh-DevDock.git"
42
+ },
43
+ "homepage": "https://github.com/QingJing5906/dsh-DevDock#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/QingJing5906/dsh-DevDock/issues"
46
+ },
47
+ "author": "QingJing5906",
48
+ "license": "MIT",
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "peerDependencies": {
53
+ "dsh-devdock-core": "^3.0.0"
54
+ },
55
+ "scripts": {
56
+ "test": "node tests/verify-platform.mjs && node tests/verify-client.mjs && node tests/verify-externals.mjs && node tests/verify-coexist.mjs"
57
+ },
58
+ "dsh": {
59
+ "bundle": {
60
+ "patch": "./cordis.patch.yml"
61
+ },
62
+ "client": {
63
+ "platform": "web",
64
+ "inject": [
65
+ "@deepseek-ai/dsh-client-ui-conversation"
66
+ ],
67
+ "external": [
68
+ "dsh-devdock-core/client"
69
+ ]
70
+ },
71
+ "surfaces": {
72
+ "settings": {
73
+ "id": "push-npm",
74
+ "label": "DevDock · npm",
75
+ "pages": [
76
+ {
77
+ "platform": "npm",
78
+ "title": "npm",
79
+ "content": [
80
+ "npm 账号卡片(Granular / Classic 令牌)",
81
+ "我的包(列表/卡片视图)",
82
+ "包管理弹窗"
83
+ ]
84
+ }
85
+ ]
86
+ },
87
+ "sidebar": {
88
+ "id": "push-npm",
89
+ "label": "DevDock · npm",
90
+ "icon": "NpmMark",
91
+ "platforms": [
92
+ {
93
+ "id": "npm",
94
+ "title": "npm 包",
95
+ "content": [
96
+ "包搜索",
97
+ "我的包",
98
+ "列表/卡片视图",
99
+ "包管理弹窗"
100
+ ]
101
+ }
102
+ ]
103
+ },
104
+ "workspaceTab": {
105
+ "id": "push-npm",
106
+ "label": "DevDock · npm",
107
+ "icon": "NpmMark",
108
+ "requires": "betterSidebar",
109
+ "fallback": "conversation.session.header.utilities",
110
+ "platforms": [
111
+ {
112
+ "id": "npm",
113
+ "title": "工作区 npm",
114
+ "content": [
115
+ "创建 package.json",
116
+ "打包预演与打包",
117
+ "发布到 npm(含 2FA)",
118
+ "发布前自检",
119
+ "依赖检查"
120
+ ]
121
+ }
122
+ ]
123
+ }
124
+ }
125
+ }
126
+ }