@michengai/dsh-codex-ui 0.2.57 → 0.2.59
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/assets/branding/dsh-banner.png +0 -0
- package/dist/client.js +0 -2
- package/dist/index.mjs +42 -5
- package/package.json +1 -1
|
Binary file
|
package/dist/client.js
CHANGED
|
@@ -3417,8 +3417,6 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
|
|
|
3417
3417
|
});
|
|
3418
3418
|
}
|
|
3419
3419
|
CodexSidebar.displayName = "michengai-codex-ui";
|
|
3420
|
-
//#endregion
|
|
3421
|
-
//#region src/dependencies.ts
|
|
3422
3420
|
const MANAGED_DEPENDENCIES = [
|
|
3423
3421
|
{
|
|
3424
3422
|
id: "suite",
|
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,19 @@ import { homedir } from "node:os";
|
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
//#region src/dependencies.ts
|
|
7
|
+
const SUITE_PACKAGE = "@michengai/dsh-codex-suite";
|
|
8
|
+
const SUITE_MEMBER_PACKAGES = [
|
|
9
|
+
"@michengai/dsh-codex-ui",
|
|
10
|
+
"@michengai/dsh-agency-agents",
|
|
11
|
+
"@michengai/dsh-skills-manager",
|
|
12
|
+
"@michengai/dsh-archive-manager",
|
|
13
|
+
"@michengai/dsh-im-connect",
|
|
14
|
+
"@michengai/dsh-automation"
|
|
15
|
+
];
|
|
7
16
|
const MANAGED_DEPENDENCIES = [
|
|
8
17
|
{
|
|
9
18
|
id: "suite",
|
|
10
|
-
packageName:
|
|
19
|
+
packageName: SUITE_PACKAGE
|
|
11
20
|
},
|
|
12
21
|
{
|
|
13
22
|
id: "ui",
|
|
@@ -47,6 +56,28 @@ function profileDirectory() {
|
|
|
47
56
|
if (process.env.DSH_PROFILE_DIR !== void 0) return process.env.DSH_PROFILE_DIR;
|
|
48
57
|
return resolve(homedir(), ".dsh", "profiles", "web");
|
|
49
58
|
}
|
|
59
|
+
async function declaredPluginNames() {
|
|
60
|
+
try {
|
|
61
|
+
const manifest = JSON.parse(await readFile(resolve(profileDirectory(), "package.json"), "utf8"));
|
|
62
|
+
return Object.keys({
|
|
63
|
+
...manifest.devDependencies,
|
|
64
|
+
...manifest.dependencies
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (error.code === "ENOENT") return [];
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** 安装套件前卸掉已单独安装的子插件,避免两套 patch 重复注册同一 id。 */
|
|
72
|
+
function pluginsToRemoveBeforeInstall(declared, installing) {
|
|
73
|
+
if (installing !== "@michengai/dsh-codex-suite") return [];
|
|
74
|
+
return SUITE_MEMBER_PACKAGES.filter((name) => declared.includes(name));
|
|
75
|
+
}
|
|
76
|
+
/** 已装套件时,子插件的安装/更新改走套件,避免再写入一份 bundle。 */
|
|
77
|
+
function resolveDshPluginTarget(installing, declared) {
|
|
78
|
+
if (installing !== "@michengai/dsh-codex-suite" && SUITE_MEMBER_PACKAGES.includes(installing) && declared.includes("@michengai/dsh-codex-suite")) return SUITE_PACKAGE;
|
|
79
|
+
return installing;
|
|
80
|
+
}
|
|
50
81
|
async function installedPackageVersion(packageName) {
|
|
51
82
|
try {
|
|
52
83
|
const manifest = JSON.parse(await readFile(resolve(profileDirectory(), "node_modules", ...packageName.split("/"), "package.json"), "utf8"));
|
|
@@ -222,14 +253,20 @@ async function installDependencyLocked(id) {
|
|
|
222
253
|
if (dependency === void 0) throw new Error("不支持安装该依赖。");
|
|
223
254
|
const latestVersion = await npmLatestVersion(dependency.packageName);
|
|
224
255
|
if (latestVersion === void 0) throw new Error("无法获取 npm 最新版本,请检查网络或 npm registry 后重试。");
|
|
225
|
-
await
|
|
256
|
+
const declared = await declaredPluginNames();
|
|
257
|
+
const target = resolveDshPluginTarget(dependency.packageName, declared);
|
|
258
|
+
const targetVersion = target === dependency.packageName ? latestVersion : await npmLatestVersion(target);
|
|
259
|
+
if (targetVersion === void 0) throw new Error("无法获取 npm 最新版本,请检查网络或 npm registry 后重试。");
|
|
260
|
+
const remove = pluginsToRemoveBeforeInstall(declared, target);
|
|
261
|
+
if (remove.length > 0) await runDshPlugin(["remove", ...remove]);
|
|
262
|
+
await ensureLatestReleaseAllowed(target, targetVersion);
|
|
226
263
|
await runDshPlugin([
|
|
227
264
|
"add",
|
|
228
|
-
`${
|
|
265
|
+
`${target}@${targetVersion}`,
|
|
229
266
|
"--registry=https://registry.npmjs.org/"
|
|
230
267
|
]);
|
|
231
|
-
const installed = await installedPackageVersion(
|
|
232
|
-
if (installed !==
|
|
268
|
+
const installed = await installedPackageVersion(target);
|
|
269
|
+
if (installed !== targetVersion) throw new Error(`已请求 ${target}@${targetVersion},但当前仍是 ${installed ?? "未安装"}。请先停止 DSH Web 后再更新。`);
|
|
233
270
|
return dependencyStatuses();
|
|
234
271
|
}
|
|
235
272
|
//#endregion
|