@deepseek-ai/dsh 0.1.5-rc.2 → 0.1.6-alpha.2
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.i18n.yaml +2 -2
- package/README.md +9 -5
- package/README.zh.md +15 -11
- package/lib/bin.js +118 -48
- package/lib/{dump-config-lFgMwK8i.js → dump-config-Bb5YvFIX.js} +1 -1
- package/lib/plugin-DJ-rVHUS.js +31 -0
- package/lib/{profile-boot-Dk-7KqJc.js → profile-boot-BNu17Y9U.js} +85 -130
- package/lib/profile-boot.js +2 -0
- package/lib/types/args.d.ts +56 -0
- package/lib/types/bin.d.ts +11 -0
- package/lib/types/dump-config.d.ts +18 -0
- package/lib/types/plugin.d.ts +7 -0
- package/lib/types/process-shutdown.d.ts +20 -0
- package/lib/types/profile-boot.d.ts +92 -0
- package/lib/types/startup-diagnostics.d.ts +19 -0
- package/package.json +123 -110
- package/lib/plugin-Ddi42qoW.js +0 -130
- package/lib/profile-boot-BP_C0vpU.js +0 -2
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write apps/cli/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 46c6a66336839db443a825c66ebfd71dcce398af
|
|
6
|
+
README.zh.md: 14838114b04977e7668e33479d1ba84a8ddc8434
|
package/README.md
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
The `dsh` command is the sole supported Node application launcher: profiles are ordered stacks of plugin-bundle patch layers under the user's own overrides. SDK and ACP are profiles, not separate public bins. The Python runtime wheel packages this same command; the SDK defaults to `sdk`, and the minimal example selects `sdk-minimal`. [`src/args.ts`](src/args.ts) owns the command grammar, and [`src/bin.ts`](src/bin.ts) loads only the selected runner. Invalid commands, options from another mode, configuration
|
|
5
|
+
The `dsh` command is the sole supported Node application launcher: profiles are ordered stacks of plugin-bundle patch layers under the user's own overrides. SDK and ACP are profiles, not separate public bins. The Python runtime wheel packages this same command; the SDK defaults to `sdk`, and the minimal example selects `sdk-minimal`. [`src/args.ts`](src/args.ts) owns the command grammar, and [`src/bin.ts`](src/bin.ts) loads only the selected runner. Invalid commands, options from another mode, and fatal configuration or boot failures exit nonzero.
|
|
6
6
|
|
|
7
7
|
## Entry modes
|
|
8
8
|
|
|
9
9
|
| Command | Purpose |
|
|
10
10
|
|---|---|
|
|
11
|
-
| `dsh --profile <name>` | Boot the named profile under `$DSH_HOME/profiles/<name>`. |
|
|
11
|
+
| `dsh <name>` / `dsh --profile <name>` | Boot the named profile under `$DSH_HOME/profiles/<name>`. |
|
|
12
12
|
| `dsh --profile <name> --from-default-profile <template>` | Create a new custom profile from a shipped template, then boot it. |
|
|
13
13
|
| `dsh --profile acp` | Serve automation clients over ACP stdio until disconnect. |
|
|
14
14
|
| `dsh --profile headless "job"` | Run one fresh persisted session, print the final answer, and exit. |
|
|
15
15
|
| `dsh --profile sdk` | Serve SDK clients over JSON-RPC stdio until shutdown or disconnect. |
|
|
16
16
|
| `dsh --profile sdk-minimal` | Serve SDK clients with the standalone minimal agent tree. |
|
|
17
|
-
| `dsh web` |
|
|
17
|
+
| `dsh web` | Boot the Web profile. |
|
|
18
18
|
| `dsh plugin --profile <name> <pnpm args>` | Manage a profile's plugins by forwarding to pnpm in the profile directory. |
|
|
19
19
|
|
|
20
20
|
The invoking directory is the default workspace root. The `web`, `headless`, `sdk`, `sdk-minimal`, and `acp` profiles auto-initialize on first use from shipped templates. Create another profile at an unused, non-shipped name with `--from-default-profile`, or initialize a base-backed profile through `dsh plugin`. The `desktop` name is reserved for the Electron-owned profile, so the CLI rejects boot, config-dump, and plugin-management requests for it.
|
|
@@ -34,7 +34,7 @@ dsh --help # the launcher's own help
|
|
|
34
34
|
<a id="profiles"></a>
|
|
35
35
|
## Profiles
|
|
36
36
|
|
|
37
|
-
A profile directory holds a `package.json` (out-of-tree plugin dependencies plus the profile manifest `dsh.profile` with its ordered `bundles` list
|
|
37
|
+
A profile directory holds a `package.json` (out-of-tree plugin dependencies plus the profile manifest `dsh.profile` with its ordered `bundles` list) and a `cordis.patch.yml` (the user's own patch layer). `dsh-hmr`, when enabled in YAML, watches the profile manifest and both profile and home patch files, then recomposes all layers through one serialized reload. Without HMR, changes apply on restart. Edits arriving during watcher registration use the same nonfatal reload reporting as later edits. [Plugin Manager](../../packages/boot/plugin-manager/README.md) shares package operations and the profile write lock with `dsh plugin`; package updates retain disabled bundle selections. CLI package commands inherit authentication variables and terminal descriptors, including interactive build approval; service calls retain their scrubbed environment and captured diagnostics.
|
|
38
38
|
|
|
39
39
|
The tree composes over an empty root:
|
|
40
40
|
- each bundle's patch in `dsh.profile.bundles` order
|
|
@@ -45,7 +45,7 @@ Bundles named in `dsh.profile.bundles` resolve from the dsh installation first (
|
|
|
45
45
|
|
|
46
46
|
Use `--dump-default-config` and `--dump-config` to inspect the composed tree without booting it.
|
|
47
47
|
|
|
48
|
-
The [CLI behavior reference](reference/README.md) owns exact layer precedence, flags, shutdown behavior, deployment defaults, and source execution.
|
|
48
|
+
The [CLI behavior reference](reference/README.md) owns exact layer precedence, flags, shutdown behavior, deployment defaults, and source execution. The [startup and reload failure table](../../packages/boot/app-boot/README.md#startup-and-reload-failures) compares optional and required plugin failures with configuration HMR.
|
|
49
49
|
|
|
50
50
|
## Optional overlays
|
|
51
51
|
|
|
@@ -54,3 +54,7 @@ The [CLI behavior reference](reference/README.md) owns exact layer precedence, f
|
|
|
54
54
|
## Development
|
|
55
55
|
|
|
56
56
|
Production runs require built package and frontend artifacts. From the repository root, run `pnpm run build` separately, then use `pnpm dsh <args...>` to run the TypeScript entry and forward every argument; the [source-execution reference](reference/README.md#source-execution) owns the module-resolution contract.
|
|
57
|
+
|
|
58
|
+
The `@deepseek-ai/dsh/profile-boot` export provides the shared profile lifecycle to the Desktop host. A resolved application profile supplies its own installation anchor for runtime package resolution while retaining the Harness home patch, proxy environment, telemetry switch, patch reload, and bounded shutdown.
|
|
59
|
+
|
|
60
|
+
The [Web failure matrix](tests/profiles/web/tests/web-failure-matrix.expected.e2e.ts) runs the built CLI through startup failures and native configuration HMR with `awaitWriteFinish` enabled in `test:expected`. It verifies authenticated HTTP responses, diagnostics, recovery, process exits, and disposal without model API calls; the [startup acceptance](tests/profiles/web/tests/web-best-effort-startup.expected.e2e.ts) also covers the shipped required Web dependencies and port conflicts.
|
package/README.zh.md
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
`dsh` 是唯一受支持的 Node 应用启动器;profile 由多个插件组合包 patch 层按顺序叠加而成,其上再应用用户自己的覆盖配置。SDK 与 ACP
|
|
5
|
+
`dsh` 是唯一受支持的 Node 应用启动器;profile 由多个插件组合包 patch 层按顺序叠加而成,其上再应用用户自己的覆盖配置。SDK 与 ACP(Agent Client Protocol)都是 profile,而不是独立的公开可执行命令。Python 运行时 wheel 包中也包含同一个命令;SDK 默认使用 `sdk`,极简示例选择 `sdk-minimal`。[`src/args.ts`](src/args.ts) 负责命令语法,[`src/bin.ts`](src/bin.ts) 只加载选中的运行器。无效命令、来自其他模式的选项,以及致命的配置或启动错误都会以非零状态退出。
|
|
6
6
|
|
|
7
7
|
## 入口模式
|
|
8
8
|
|
|
9
9
|
| 命令 | 用途 |
|
|
10
10
|
|---|---|
|
|
11
|
-
| `dsh --profile <name>` | 启动位于 `$DSH_HOME/profiles/<name>` 的指定 profile。 |
|
|
11
|
+
| `dsh <name>` / `dsh --profile <name>` | 启动位于 `$DSH_HOME/profiles/<name>` 的指定 profile。 |
|
|
12
12
|
| `dsh --profile <name> --from-default-profile <template>` | 从随附模板创建新的自定义 profile,然后启动它。 |
|
|
13
|
-
| `dsh --profile acp` | 通过 ACP stdio
|
|
13
|
+
| `dsh --profile acp` | 通过 ACP stdio 为自动化客户端提供服务,直至断开连接。 |
|
|
14
14
|
| `dsh --profile headless "job"` | 运行一个全新的持久化会话,打印最终答案并退出。 |
|
|
15
|
-
| `dsh --profile sdk` | 通过 JSON-RPC stdio 为 SDK
|
|
16
|
-
| `dsh --profile sdk-minimal` | 以独立极简 agent
|
|
17
|
-
| `dsh web` |
|
|
15
|
+
| `dsh --profile sdk` | 通过 JSON-RPC stdio 为 SDK 客户端提供服务,直至关闭或断开连接。 |
|
|
16
|
+
| `dsh --profile sdk-minimal` | 以独立极简 agent(智能体)配置树为 SDK 客户端提供服务。 |
|
|
17
|
+
| `dsh web` | 启动 Web profile。 |
|
|
18
18
|
| `dsh plugin --profile <name> <pnpm args>` | 通过在 profile 目录中转发给 pnpm 来管理该 profile 的插件。 |
|
|
19
19
|
|
|
20
|
-
运行命令时所在的目录将作为默认 workspace 根目录。`web`、`headless`、`sdk`、`sdk-minimal` 和 `acp` profile 在首次使用时会从随附模板自动初始化。使用 `--from-default-profile` 可以基于这些模板之一,在尚未使用的非内置名称处创建其他 profile;通过 `dsh plugin` 则可以初始化一个以 base 为基础的 profile。`desktop` 名称保留给 Electron 持有的 profile,因此 CLI
|
|
20
|
+
运行命令时所在的目录将作为默认 workspace 根目录。`web`、`headless`、`sdk`、`sdk-minimal` 和 `acp` profile 在首次使用时会从随附模板自动初始化。使用 `--from-default-profile` 可以基于这些模板之一,在尚未使用的非内置名称处创建其他 profile;通过 `dsh plugin` 则可以初始化一个以 base 为基础的 profile。`desktop` 名称保留给 Electron 持有的 profile,因此 CLI(命令行界面)会拒绝针对它的启动、配置 dump 和插件管理请求。
|
|
21
21
|
|
|
22
22
|
## 应用参数
|
|
23
23
|
|
|
@@ -34,7 +34,7 @@ dsh --help # the launcher's own help
|
|
|
34
34
|
<a id="profiles"></a>
|
|
35
35
|
## Profile
|
|
36
36
|
|
|
37
|
-
profile 目录包含一个 `package.json`,其中记录树外插件依赖,以及 profile manifest(元数据清单)`dsh.profile`、其中按顺序排列的 `bundles`
|
|
37
|
+
profile 目录包含一个 `package.json`,其中记录树外插件依赖,以及 profile manifest(元数据清单)`dsh.profile`、其中按顺序排列的 `bundles` 列表;还包含一个 `cordis.patch.yml`,其中保存用户自己的 patch 层。在 YAML 中启用的 `dsh-hmr` 监视 profile manifest、profile 与 home 级 patch 文件,再通过统一串行重载重新组合所有层。未启用 HMR 时,更改在重启后生效。监听器注册期间发生的编辑与后续编辑使用相同的非致命重载错误报告。[插件管理器](../../packages/boot/plugin-manager/README.zh.md) 与 `dsh plugin` 共享包操作和 profile 写锁;更新依赖会保留已停用的组合包选择。CLI 包操作继承认证环境和终端描述符,支持交互式构建批准;service 调用保留清理后的环境并捕获诊断。
|
|
38
38
|
|
|
39
39
|
配置树以空根为起点,依次叠加以下配置层:
|
|
40
40
|
- `dsh.profile.bundles` 中各组合包的 patch
|
|
@@ -45,12 +45,16 @@ profile 目录包含一个 `package.json`,其中记录树外插件依赖,以
|
|
|
45
45
|
|
|
46
46
|
使用 `--dump-default-config` 和 `--dump-config` 可在不启动的情况下检查组合后的配置树。
|
|
47
47
|
|
|
48
|
-
层的确切优先级、flag、关闭行为、部署默认值和源码执行方式,以 [CLI
|
|
48
|
+
层的确切优先级、flag、关闭行为、部署默认值和源码执行方式,以 [CLI 行为参考](reference/README.zh.md)为准。[启动与重载失败表](../../packages/boot/app-boot/README.zh.md#startup-and-reload-failures)对比 optional、required 插件启动失败与配置 HMR 的行为。
|
|
49
49
|
|
|
50
|
-
##
|
|
50
|
+
## 可选覆盖层
|
|
51
51
|
|
|
52
|
-
`config/examples/` 交付 GitHub 评审 webhook、会话内 Schedule、记忆 MCP
|
|
52
|
+
`config/examples/` 交付 GitHub 评审 webhook、会话内 Schedule、记忆 MCP 服务器与运行时 Cordis 工具的可选覆盖层。它们绝不属于默认 profile;设置与安全说明由[用户指南](../../docs/user/guide/index.zh.md)和[开发实战指南](../../docs/user/develop/practice/index.zh.md)负责。
|
|
53
53
|
|
|
54
54
|
## 开发
|
|
55
55
|
|
|
56
56
|
生产运行需要已构建的包与前端产物。请在仓库根目录单独运行 `pnpm run build`,然后使用 `pnpm dsh <args...>` 运行 TypeScript 入口并转发所有参数;模块解析约定以[源码执行参考](reference/README.zh.md#source-execution)为准。
|
|
57
|
+
|
|
58
|
+
`@deepseek-ai/dsh/profile-boot` 导出向 Desktop Host 提供共享 profile 生命周期。已解析的应用 profile 为运行时包解析指定自己的安装锚点,同时沿用 Harness home patch、代理环境、遥测开关、patch 热重载和有界关闭。
|
|
59
|
+
|
|
60
|
+
[Web 失败矩阵](tests/profiles/web/tests/web-failure-matrix.expected.e2e.ts)在 `test:expected` 中通过构建后的 CLI 验证启动失败与启用 `awaitWriteFinish` 的原生配置 HMR。它不调用模型 API,而是检查经过认证的 HTTP 响应、诊断、恢复、进程退出与 dispose;[启动验收测试](tests/profiles/web/tests/web-best-effort-startup.expected.e2e.ts)还覆盖随附 Web 的必需依赖与端口冲突。
|
package/lib/bin.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { loadLayeredEnv } from "@deepseek-ai/dsh-app-boot";
|
|
5
|
-
import {
|
|
4
|
+
import { StartupError, loadLayeredEnv } from "@deepseek-ai/dsh-app-boot";
|
|
5
|
+
import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
|
|
6
|
+
import { Command, CommanderError, InvalidArgumentError } from "commander";
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { inspect } from "node:util";
|
|
6
11
|
//#region lib/types/args.js
|
|
7
12
|
/**
|
|
8
13
|
* Commander adapter for the `dsh` command line.
|
|
@@ -16,7 +21,7 @@ import { Command, CommanderError } from "commander";
|
|
|
16
21
|
* `dsh --profile tui --resume abc` boots the tui profile with `--resume abc`,
|
|
17
22
|
* and `dsh --profile web -h` prints the web app's help, not this one's.
|
|
18
23
|
*
|
|
19
|
-
* `
|
|
24
|
+
* `dsh <name>` abbreviates `dsh --profile <name>`; `plugin` manages a profile's
|
|
20
25
|
* plugin dependencies by forwarding to pnpm.
|
|
21
26
|
* @module @deepseek-ai/dsh/args
|
|
22
27
|
*/
|
|
@@ -25,25 +30,29 @@ import { Command, CommanderError } from "commander";
|
|
|
25
30
|
* variadic — a variadic `--patch` would swallow the inner arguments.
|
|
26
31
|
*/
|
|
27
32
|
const collect = (value, previous = []) => [...previous, value];
|
|
33
|
+
function selectProfile(value, previous) {
|
|
34
|
+
if (previous !== void 0) throw new InvalidArgumentError("select a profile only once");
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
28
37
|
function rejectElectronProfile(program, profile) {
|
|
29
38
|
if (profile.toLowerCase() === "desktop") program.error("error: profile \"desktop\" is managed exclusively by the Electron application");
|
|
30
39
|
}
|
|
31
40
|
/** The launcher's own help text; each app prints its own. */
|
|
32
41
|
const HELP_EXAMPLES = `
|
|
33
42
|
Examples:
|
|
34
|
-
dsh
|
|
35
|
-
dsh
|
|
36
|
-
|
|
37
|
-
dsh
|
|
38
|
-
dsh
|
|
39
|
-
dsh
|
|
40
|
-
dsh
|
|
41
|
-
dsh plugin --profile tui add <package>
|
|
43
|
+
dsh web boot the web profile (same as: dsh --profile web)
|
|
44
|
+
dsh rescue --from-default-profile web
|
|
45
|
+
create rescue from the shipped web template, then boot it
|
|
46
|
+
dsh headless "run the tests" answer one task, print the result, and exit
|
|
47
|
+
dsh tui --patch ./extra.yml boot a custom profile with one extra overlay
|
|
48
|
+
dsh tui --resume <session> arguments after the launcher flags reach the app
|
|
49
|
+
dsh web --help the web app's own flags and help
|
|
50
|
+
dsh plugin --profile tui add <package> install a plugin into the tui profile
|
|
42
51
|
`;
|
|
43
52
|
/**
|
|
44
53
|
* Resolve a boot or dump invocation from the launcher flags and the leftover
|
|
45
54
|
* inner arguments.
|
|
46
|
-
* @param program - the command whose options were parsed
|
|
55
|
+
* @param program - the command whose options were parsed.
|
|
47
56
|
* @param profile - the profile these flags boot.
|
|
48
57
|
* @param options - the launcher flags commander collected.
|
|
49
58
|
* @param args - the leftover arguments, in argv order.
|
|
@@ -80,9 +89,10 @@ function resolveBoot(program, profile, options, args) {
|
|
|
80
89
|
* @returns the resolved invocation.
|
|
81
90
|
*/
|
|
82
91
|
function parseDshArgs(argv, version) {
|
|
92
|
+
const first = argv[0];
|
|
83
93
|
let resolved;
|
|
84
94
|
const program = new Command();
|
|
85
|
-
program.name("dsh").version(version, "-V, --version", "output the version number").description("dsh: boot a DeepSeek Harness profile — an ordered stack of plugin-bundle patch layers under your own overrides.").addHelpText("after", HELP_EXAMPLES).exitOverride().helpOption(false).allowUnknownOption().passThroughOptions().enablePositionalOptions().argument("[args...]", "arguments for the booted profile's app (see: dsh --profile <name> --help)").option("--profile <name>", "the profile under $DSH_HOME/profiles to boot").option("--from-default-profile <name>", "initialize a new custom profile from a shipped profile template").option("--patch <path>", "extra patch-list overlay applied after the profile layer (repeatable)", collect).option("--dump-config", "print the composed profile tree and exit").option("--dump-default-config", "print the profile tree without its user layer or --patch overlays and exit").action((args, options) => {
|
|
95
|
+
program.name("dsh").version(version, "-V, --version", "output the version number").usage("[--profile] <name> [options] [app-args...]\n dsh plugin --profile <name> <pnpm-args...>").description("dsh: boot a DeepSeek Harness profile — an ordered stack of plugin-bundle patch layers under your own overrides.").addHelpText("after", HELP_EXAMPLES).exitOverride().helpOption(false).helpCommand(false).allowUnknownOption().passThroughOptions().enablePositionalOptions().argument("[args...]", "arguments for the booted profile's app (see: dsh --profile <name> --help)").option("--profile <name>", "the profile under $DSH_HOME/profiles to boot", selectProfile).option("--from-default-profile <name>", "initialize a new custom profile from a shipped profile template").option("--patch <path>", "extra patch-list overlay applied after the profile layer (repeatable)", collect).option("--dump-config", "print the composed profile tree and exit").option("--dump-default-config", "print the profile tree without its user layer or --patch overlays and exit").action((args, options) => {
|
|
86
96
|
if (options.profile === void 0) {
|
|
87
97
|
if (args.some((argument) => argument === "-h" || argument === "--help")) program.help();
|
|
88
98
|
program.error("error: --profile <name> is required");
|
|
@@ -92,30 +102,22 @@ function parseDshArgs(argv, version) {
|
|
|
92
102
|
rejectElectronProfile(program, profile);
|
|
93
103
|
resolved = resolveBoot(program, profile, options, args);
|
|
94
104
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (options.profile === "") program.error("error: --profile needs a name");
|
|
109
|
-
rejectElectronProfile(plugin, options.profile);
|
|
110
|
-
if (args.length === 0) program.error("error: plugin needs pnpm arguments to forward (e.g. add <package>)");
|
|
111
|
-
resolved = {
|
|
112
|
-
mode: "plugin",
|
|
113
|
-
profile: options.profile,
|
|
114
|
-
args
|
|
115
|
-
};
|
|
116
|
-
});
|
|
105
|
+
if (first === "plugin") {
|
|
106
|
+
const plugin = program.command("plugin").description("manage a profile's plugins by forwarding the remaining arguments to pnpm in the profile directory");
|
|
107
|
+
plugin.requiredOption("--profile <name>", "the profile whose plugins to manage (initialized on first use)", selectProfile).allowUnknownOption().argument("[args...]", "pnpm arguments, forwarded verbatim (add <pkg>, remove <pkg>, why <pkg>, ...)").action((args, options) => {
|
|
108
|
+
if (options.profile === "") program.error("error: --profile needs a name");
|
|
109
|
+
rejectElectronProfile(plugin, options.profile);
|
|
110
|
+
if (args.length === 0) program.error("error: plugin needs pnpm arguments to forward (e.g. add <package>)");
|
|
111
|
+
resolved = {
|
|
112
|
+
mode: "plugin",
|
|
113
|
+
profile: options.profile,
|
|
114
|
+
args
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
117
118
|
try {
|
|
118
|
-
|
|
119
|
+
const expanded = first !== void 0 && !first.startsWith("-") && first !== "plugin" ? ["--profile", ...argv] : argv;
|
|
120
|
+
program.parse(expanded, { from: "user" });
|
|
119
121
|
} catch (error) {
|
|
120
122
|
return process.exit(error instanceof CommanderError ? error.exitCode : 1);
|
|
121
123
|
}
|
|
@@ -124,6 +126,63 @@ function parseDshArgs(argv, version) {
|
|
|
124
126
|
return resolved;
|
|
125
127
|
}
|
|
126
128
|
//#endregion
|
|
129
|
+
//#region lib/types/startup-diagnostics.js
|
|
130
|
+
/** Save original startup diagnostics while keeping the terminal report concise. */
|
|
131
|
+
/** Wait for stderr to finish the write before the failed process exits. */
|
|
132
|
+
function writeStderr(text) {
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
process.stderr.write(text, (error) => {
|
|
135
|
+
if (error) reject(error);
|
|
136
|
+
else resolve();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Print the startup summary and save a private, uniquely named report under DSH_HOME/logs.
|
|
142
|
+
* Failed writes print the complete report to stderr instead of claiming a saved path.
|
|
143
|
+
* @param error - startup audit failure retaining plugin metadata and original errors.
|
|
144
|
+
* @param context - resolved Harness home, application version, and selected profile.
|
|
145
|
+
* @param write - terminal output sink; awaited before returning, defaults to stderr.
|
|
146
|
+
* @returns after saving or printing the report and completing terminal writes.
|
|
147
|
+
*/
|
|
148
|
+
async function reportStartupFailure(error, context, write = writeStderr) {
|
|
149
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
150
|
+
const report = "WARNING: Raw diagnostics may contain configuration or credential values from plugin errors. Review before sharing.\n\n" + inspect({
|
|
151
|
+
timestamp: now,
|
|
152
|
+
dshVersion: context.version,
|
|
153
|
+
nodeVersion: process.version,
|
|
154
|
+
platform: process.platform,
|
|
155
|
+
arch: process.arch,
|
|
156
|
+
profile: context.profile,
|
|
157
|
+
error
|
|
158
|
+
}, {
|
|
159
|
+
depth: null,
|
|
160
|
+
maxArrayLength: null,
|
|
161
|
+
maxStringLength: null,
|
|
162
|
+
showHidden: true,
|
|
163
|
+
customInspect: false,
|
|
164
|
+
getters: false,
|
|
165
|
+
colors: false
|
|
166
|
+
}) + "\n";
|
|
167
|
+
await write(`${error.message}\n`);
|
|
168
|
+
const logDir = join(context.home, "logs");
|
|
169
|
+
const logPath = join(logDir, `startup-${now.replaceAll(":", "-")}-${randomUUID()}.log`);
|
|
170
|
+
try {
|
|
171
|
+
await mkdir(logDir, {
|
|
172
|
+
recursive: true,
|
|
173
|
+
mode: 448
|
|
174
|
+
});
|
|
175
|
+
await writeFile(logPath, report, {
|
|
176
|
+
flag: "wx",
|
|
177
|
+
mode: 384
|
|
178
|
+
});
|
|
179
|
+
} catch (writeError) {
|
|
180
|
+
await write(`\ndsh: warning: could not write startup diagnostics: ${String(writeError)}\nFull diagnostics:\n${report}`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
await write(`\nFull diagnostics: ${logPath}\n`);
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
127
186
|
//#region lib/types/bin.js
|
|
128
187
|
/**
|
|
129
188
|
* Command-line entry for dsh.
|
|
@@ -139,26 +198,37 @@ function readVersion() {
|
|
|
139
198
|
* @returns a promise that settles when the selected command mode finishes.
|
|
140
199
|
*/
|
|
141
200
|
async function runCli() {
|
|
142
|
-
const
|
|
201
|
+
const version = readVersion();
|
|
202
|
+
const invocation = parseDshArgs(process.argv.slice(2), version);
|
|
143
203
|
switch (invocation.mode) {
|
|
144
204
|
case "profile": {
|
|
145
|
-
const { runProfile } = await import("./profile-boot
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
205
|
+
const { runProfile } = await import("./profile-boot.js");
|
|
206
|
+
try {
|
|
207
|
+
await runProfile({
|
|
208
|
+
environment: loadLayeredEnv("dsh"),
|
|
209
|
+
profile: invocation.profile,
|
|
210
|
+
fromDefaultProfile: invocation.fromDefaultProfile,
|
|
211
|
+
patchFiles: invocation.patches,
|
|
212
|
+
args: invocation.args
|
|
213
|
+
});
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (!(error instanceof StartupError)) throw error;
|
|
216
|
+
await reportStartupFailure(error, {
|
|
217
|
+
home: resolveDshHome(),
|
|
218
|
+
version,
|
|
219
|
+
profile: invocation.profile
|
|
220
|
+
});
|
|
221
|
+
process.exit(1);
|
|
222
|
+
}
|
|
153
223
|
break;
|
|
154
224
|
}
|
|
155
225
|
case "plugin": {
|
|
156
|
-
const { runPlugin } = await import("./plugin-
|
|
157
|
-
process.exit(runPlugin(invocation.profile, invocation.args));
|
|
226
|
+
const { runPlugin } = await import("./plugin-DJ-rVHUS.js");
|
|
227
|
+
process.exit(await runPlugin(invocation.profile, invocation.args));
|
|
158
228
|
break;
|
|
159
229
|
}
|
|
160
230
|
case "dump-config": {
|
|
161
|
-
const { runDumpConfig } = await import("./dump-config-
|
|
231
|
+
const { runDumpConfig } = await import("./dump-config-Bb5YvFIX.js");
|
|
162
232
|
runDumpConfig(invocation.profile, invocation.defaultOnly, invocation.patches, invocation.fromDefaultProfile);
|
|
163
233
|
break;
|
|
164
234
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as prepareProfile, n as PROFILE_ROOT_FILENAME, r as homePatchPath } from "./profile-boot-
|
|
1
|
+
import { a as prepareProfile, n as PROFILE_ROOT_FILENAME, r as homePatchPath } from "./profile-boot-BNu17Y9U.js";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { loadOptionalPatches, loadOverlayPatches, renderConfigDump } from "@deepseek-ai/dsh-app-boot";
|
|
4
4
|
import { join, resolve } from "node:path";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { t as INSTALL_ANCHOR } from "./profile-boot-BNu17Y9U.js";
|
|
2
|
+
import { resolveProfileDir } from "@deepseek-ai/dsh-app-boot";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { runPluginCommand } from "@deepseek-ai/dsh-plugin-manager/operations";
|
|
5
|
+
//#region lib/types/plugin.js
|
|
6
|
+
/** dsh plugin forwards pnpm through the shared profile package operations. */
|
|
7
|
+
/** Run package management for a profile.
|
|
8
|
+
* @param profile Profile name.
|
|
9
|
+
* @param args Pnpm arguments relative to the invoking directory.
|
|
10
|
+
* @returns Pnpm exit code.
|
|
11
|
+
*/
|
|
12
|
+
async function runPlugin(profile, args) {
|
|
13
|
+
const result = await runPluginCommand({
|
|
14
|
+
profile,
|
|
15
|
+
installAnchor: INSTALL_ANCHOR,
|
|
16
|
+
cwd: process.cwd()
|
|
17
|
+
}, args, {
|
|
18
|
+
execution: "cli",
|
|
19
|
+
outputBytes: 16384,
|
|
20
|
+
lockWaitMs: 12e4,
|
|
21
|
+
onOutput: (text, stream) => {
|
|
22
|
+
process[stream].write(text);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (result.exitCode === 127) process.stderr.write("dsh: pnpm was not found; install pnpm and make it available on PATH.\n");
|
|
26
|
+
if (result.exitCode !== 0) process.stderr.write(`dsh: pnpm failed; diagnostics: ${result.logPath}\n`);
|
|
27
|
+
if (result.exitCode !== 0 && args.some((argument) => /^git\+|^github:|\.git(?:#|$)/.test(argument))) process.stderr.write(`dsh: git-hosted plugins build on install via their prepare script, which pnpm blocks until allowed — add the exact key pnpm printed above under allowBuilds in ${join(resolveProfileDir(profile), "pnpm-workspace.yaml")}, then re-run\n`);
|
|
28
|
+
return result.exitCode;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { runPlugin };
|