@woosau/dsh-custom-env 0.1.0 → 0.1.4
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.md +84 -133
- package/README.zh-CN.md +47 -96
- package/lib/client.js +243 -88
- package/lib/index.js +312 -159
- package/lib/typert.host.js +171 -1
- package/lib/typert.remote-client.js +143 -1
- package/lib/types/client/format-remote-error.d.ts +10 -0
- package/lib/types/client/locales.d.ts +66 -8
- package/lib/types/env-file.d.ts +59 -11
- package/lib/types/index.d.ts +33 -4
- package/lib/types/os-user-env/index.d.ts +15 -4
- package/lib/types/os-user-env/macos.d.ts +15 -1
- package/lib/types/os-user-env/windows.d.ts +16 -1
- package/lib/types/types.d.ts +5 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,133 +1,84 @@
|
|
|
1
|
-
# dsh-custom-env
|
|
2
|
-
|
|
3
|
-
English | [中文](README.zh-CN.md)
|
|
4
|
-
|
|
5
|
-
Community DeepSeek Harness
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](LICENSE)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
dsh plugin --profile desktop add github:ownduck/dsh-custom-env
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
For a `file:` / local checkout, rebuild `lib/` after source changes, then restart DSH. Re-run `plugin add` only when `package.json` or `cordis.patch.yml` changed.
|
|
89
|
-
|
|
90
|
-
## Usage
|
|
91
|
-
|
|
92
|
-
1. Open **Settings → Environment**
|
|
93
|
-
2. Edit as a **draft**: **Confirm** writes `$DSH_HOME/.env` (and Host/OS live); **Cancel** only reverts the input
|
|
94
|
-
3. After Confirm, rows show a restart tip — **new** items say “added”; **modified** items (relative to Host start) also get **Restore** (writes back the Host-start value)
|
|
95
|
-
4. Restart DSH / open a new terminal for the full OS effect; after Host restart, tips and Restore clear
|
|
96
|
-
5. In the **dsh command** block, compare PATH vs expected; click **Install** only when offered
|
|
97
|
-
|
|
98
|
-
Do not store bootstrap names in `.env` (including `PATH`). Prefer ordinary names for app config. Names containing `KEY` / `SECRET` / `TOKEN` remain scrubbed from model-visible shells by existing harness policy.
|
|
99
|
-
|
|
100
|
-
### Installing the `dsh` CLI from Settings
|
|
101
|
-
|
|
102
|
-
Expected path is inferred from **how this Host was started** (Desktop packaged `resources/runtime/cli/bin`, or the Node/source launcher on `argv`).
|
|
103
|
-
|
|
104
|
-
| Platform | What Install does | Conflict note |
|
|
105
|
-
| --- | --- | --- |
|
|
106
|
-
| **Windows** | Prepends the expected bin directory to the **user** `Path` (registry). Ownership key: `Software\dsh-custom-env\Command` (not DeepSeekHarness). | Can coexist with Desktop’s PATH entry; whichever directory is first wins in new terminals. |
|
|
107
|
-
| **macOS** | Writes symlink `/usr/local/bin/dsh` → expected launcher. Receipt: `.dsh-custom-env-command.json`. | **Same path as Desktop “Manage dsh Command…”** — installing here may replace that link. |
|
|
108
|
-
| **Linux** | Status only; no Install button. | — |
|
|
109
|
-
|
|
110
|
-
Open a **new** terminal after Install. This plugin never calls Desktop `app.relaunch`.
|
|
111
|
-
|
|
112
|
-
## Development
|
|
113
|
-
|
|
114
|
-
```powershell
|
|
115
|
-
cd dsh-custom-env
|
|
116
|
-
pnpm test # or: node --import tsx/esm --test tests/*.spec.ts
|
|
117
|
-
pnpm build # rebuilds lib/ (needs sibling vertax-work esbuild for client bundle)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Tests live under [`tests/`](tests/) (`env-file.spec.ts`, `cli-path.spec.ts`). Docs are this README pair only.
|
|
121
|
-
|
|
122
|
-
## GitHub vs npmjs
|
|
123
|
-
|
|
124
|
-
| Channel | Enough for users? | Install command |
|
|
125
|
-
| --- | --- | --- |
|
|
126
|
-
| **GitHub only** | Yes | `dsh plugin add github:ownduck/dsh-custom-env` |
|
|
127
|
-
| **npmjs** | Optional | `dsh plugin add @woosau/dsh-custom-env` |
|
|
128
|
-
|
|
129
|
-
Pushing to GitHub is enough to share and install. Publishing to npmjs is optional convenience (shorter name, version tags, npm badges), similar to community plugins that also publish `@scope/name` on the registry.
|
|
130
|
-
|
|
131
|
-
## License
|
|
132
|
-
|
|
133
|
-
MIT
|
|
1
|
+
# dsh-custom-env
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Community DeepSeek Harness plugin for managing environment variables in **Settings → Environment**. Not an official DeepSeek AI product.
|
|
6
|
+
|
|
7
|
+
Changes apply to the running app right away, and on Windows / macOS also to the user environment so new terminals can see them. Linux user-environment sync is not supported.
|
|
8
|
+
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Requires DSH with the `dsh` CLI (`desktop` or `web`).
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
dsh plugin --profile desktop add @woosau/dsh-custom-env
|
|
17
|
+
# or: dsh plugin --profile web add @woosau/dsh-custom-env
|
|
18
|
+
# or: dsh plugin --profile desktop add github:ownduck/dsh-custom-env
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If install fails because Desktop is locking files, quit Desktop first. After install, restart DSH and open **Settings → Environment**.
|
|
22
|
+
|
|
23
|
+
```powershell
|
|
24
|
+
dsh plugin --profile desktop remove @woosau/dsh-custom-env
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## For users
|
|
28
|
+
|
|
29
|
+
1. Open **Settings → Environment**
|
|
30
|
+
2. Edit a row as a draft → **Confirm** to save, **Cancel** to discard
|
|
31
|
+
3. **Restore** brings back the value from when this app session started
|
|
32
|
+
4. Restart the app or open a new terminal if other tools should pick up OS-level changes
|
|
33
|
+
5. Use **Install** only when shown, to wire this Host’s `dsh` command into your user PATH (Windows / macOS)
|
|
34
|
+
|
|
35
|
+
System-reserved names (such as `PATH` and names starting with `DSH_` / `XDG_`) cannot be edited here.
|
|
36
|
+
|
|
37
|
+
### When saving a value
|
|
38
|
+
|
|
39
|
+
| You save | Variable does not exist yet | Variable already exists |
|
|
40
|
+
|----------|-----------------------------|-------------------------|
|
|
41
|
+
| A non-empty value | Created | Replaced |
|
|
42
|
+
| An empty value | Created as empty | Left unchanged |
|
|
43
|
+
|
|
44
|
+
## For other plugins (Remote API)
|
|
45
|
+
|
|
46
|
+
Call the Host `customEnv` service (`ctx.get('customEnv')` or injected `ctx.customEnv`).
|
|
47
|
+
|
|
48
|
+
**Everyday use — by variable name**
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const env = ctx.get('customEnv')
|
|
52
|
+
|
|
53
|
+
await env?.setVar('MY_KEY', 'value') // create or replace
|
|
54
|
+
await env?.setVar('MY_KEY', '') // create only if missing
|
|
55
|
+
await env?.removeVar('MY_KEY')
|
|
56
|
+
|
|
57
|
+
await env?.setVars([
|
|
58
|
+
{ name: 'A', value: '1' },
|
|
59
|
+
{ name: 'B', value: '' }, // no-op if B already exists
|
|
60
|
+
])
|
|
61
|
+
await env?.removeVars(['A', 'B'])
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Reserved names are rejected (batch calls fail entirely).
|
|
65
|
+
|
|
66
|
+
**Settings UI — by row id**
|
|
67
|
+
|
|
68
|
+
| Call | Purpose |
|
|
69
|
+
|------|---------|
|
|
70
|
+
| `list()` | Current variables and row ids |
|
|
71
|
+
| `upsert(id, name, value)` | Create (`id` empty) or update/rename a row |
|
|
72
|
+
| `deleteEntry(id)` | Delete that row |
|
|
73
|
+
| `restore(id)` | Restore session-start value, or remove if the row was added later |
|
|
74
|
+
|
|
75
|
+
**CLI helpers**
|
|
76
|
+
|
|
77
|
+
| Call | Purpose |
|
|
78
|
+
|------|---------|
|
|
79
|
+
| `cliStatus()` | Whether this Host’s `dsh` CLI is ready / can be installed |
|
|
80
|
+
| `cliInstall()` | Install or repair that CLI entry |
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
package/README.zh-CN.md
CHANGED
|
@@ -2,131 +2,82 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
社区 DeepSeek Harness 插件:在 **设置 → 环境变量** 里管理环境变量。非 DeepSeek AI 官方产品。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
保存后立即作用于当前应用;在 Windows / macOS 上还会写入用户环境,方便新开的终端读到。不支持同步 Linux 用户环境。
|
|
8
8
|
|
|
9
9
|
[](LICENSE)
|
|
10
|
-
[](https://github.com/ownduck/dsh-custom-env)
|
|
11
|
-
|
|
12
|
-
## 功能
|
|
13
|
-
|
|
14
|
-
- 设置页对 `$DSH_HOME/.env` 增删改(文件不存在时自动创建)
|
|
15
|
-
- 热写到当前 Host 进程
|
|
16
|
-
- Windows / macOS 用户环境同步
|
|
17
|
-
- 拒绝 bootstrap 名(`PATH`、`DSH_*`、`XDG_*` 等),与 app-boot 对 `.env` 的限制一致
|
|
18
|
-
- **dsh 命令**区块:展示用户 PATH 上的 `dsh` 与启动本 Host 的期望启动器;不一致时显示 **安装** 按钮(Windows 用户 PATH / macOS `/usr/local/bin/dsh`)。无卸载按钮。
|
|
19
|
-
|
|
20
|
-
## 前置条件
|
|
21
|
-
|
|
22
|
-
- 已安装可用的 DeepSeek Harness,且终端里能运行 `dsh`(CLI 或 Desktop 自带 CLI)
|
|
23
|
-
- 选择 profile:`desktop`(Electron)或 `web`(浏览器)。下文两种都有。
|
|
24
10
|
|
|
25
11
|
## 安装
|
|
26
12
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### Desktop(推荐)
|
|
30
|
-
|
|
31
|
-
若 `plugin` 报 profile `package.json` 的 `EPERM`,先退出 Desktop / VertaxWork。
|
|
32
|
-
|
|
33
|
-
```powershell
|
|
34
|
-
dsh plugin --profile desktop add github:ownduck/dsh-custom-env
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
本插件依赖原生包 `koffi`。若 pnpm 拦截其 install 脚本,在该 profile 的 `pnpm-workspace.yaml` 中加入后重新 `add`:
|
|
38
|
-
|
|
39
|
-
```yaml
|
|
40
|
-
allowBuilds:
|
|
41
|
-
koffi: true
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
重启 Desktop,打开 **设置 → 环境变量**。
|
|
45
|
-
|
|
46
|
-
### Web
|
|
47
|
-
|
|
48
|
-
```powershell
|
|
49
|
-
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
50
|
-
$OutputEncoding = [System.Text.Encoding]::UTF8
|
|
51
|
-
dsh plugin --profile web add github:ownduck/dsh-custom-env
|
|
52
|
-
dsh --profile web --dump-config
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
等价:`dsh plugin --profile web add https://github.com/ownduck/dsh-custom-env.git`
|
|
56
|
-
|
|
57
|
-
配置输出中应出现 `# == dsh-custom-env` 层和 `custom-env` 插件行。然后重启 DSH Web,并在浏览器硬刷新。
|
|
58
|
-
|
|
59
|
-
### 让 Agent 帮你安装
|
|
60
|
-
|
|
61
|
-
```text
|
|
62
|
-
请将 DSH 插件 github:ownduck/dsh-custom-env 安装到本机 desktop profile,执行:dsh plugin --profile desktop add github:ownduck/dsh-custom-env。若 pnpm 提示忽略 koffi 的 build scripts,在该 profile 的 pnpm-workspace.yaml 中加入 allowBuilds.koffi: true 后重新 add。重启 Desktop 后确认「设置 → 环境变量」可用。
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### 从本地克隆安装(`file:` / `.`)
|
|
66
|
-
|
|
67
|
-
```powershell
|
|
68
|
-
git clone https://github.com/ownduck/dsh-custom-env.git
|
|
69
|
-
cd dsh-custom-env
|
|
70
|
-
dsh plugin --profile desktop add .
|
|
71
|
-
# 或:dsh plugin --profile web add .
|
|
72
|
-
dsh --profile web --dump-config
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### 从 npm 安装(可选,发布后)
|
|
13
|
+
需已安装 DSH,并能使用 `dsh` 命令(`desktop` 或 `web`)。
|
|
76
14
|
|
|
77
15
|
```powershell
|
|
78
|
-
dsh plugin --profile desktop add @woosau/dsh-custom-env
|
|
16
|
+
dsh plugin --profile desktop add @woosau/dsh-custom-env
|
|
17
|
+
# 或: dsh plugin --profile web add @woosau/dsh-custom-env
|
|
18
|
+
# 或: dsh plugin --profile desktop add github:ownduck/dsh-custom-env
|
|
79
19
|
```
|
|
80
20
|
|
|
81
|
-
|
|
21
|
+
若因 Desktop 占用文件导致安装失败,先退出 Desktop。安装后重启 DSH,打开 **设置 → 环境变量**。
|
|
82
22
|
|
|
83
23
|
```powershell
|
|
84
24
|
dsh plugin --profile desktop remove @woosau/dsh-custom-env
|
|
85
|
-
dsh plugin --profile desktop add github:ownduck/dsh-custom-env
|
|
86
25
|
```
|
|
87
26
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## 使用
|
|
27
|
+
## 给使用者
|
|
91
28
|
|
|
92
29
|
1. 打开 **设置 → 环境变量**
|
|
93
|
-
2.
|
|
94
|
-
3.
|
|
95
|
-
4.
|
|
96
|
-
5.
|
|
30
|
+
2. 先改草稿 → **确定** 保存,**取消** 放弃
|
|
31
|
+
3. **恢复** 可回到本次应用启动时的值
|
|
32
|
+
4. 若希望其他工具也读到系统侧变更,请重启应用或新开终端
|
|
33
|
+
5. 仅在出现 **安装** 时使用:把本 Host 的 `dsh` 接到用户 PATH(Windows / macOS)
|
|
97
34
|
|
|
98
|
-
|
|
35
|
+
系统保留名(如 `PATH`,以及 `DSH_` / `XDG_` 开头)不可在此编辑。
|
|
99
36
|
|
|
100
|
-
###
|
|
37
|
+
### 保存时怎么处理
|
|
101
38
|
|
|
102
|
-
|
|
39
|
+
| 你保存的内容 | 变量还不存在 | 变量已存在 |
|
|
40
|
+
|--------------|--------------|------------|
|
|
41
|
+
| 非空 | 新建 | 覆盖 |
|
|
42
|
+
| 空 | 建为空变量 | 保持原样不动 |
|
|
103
43
|
|
|
104
|
-
|
|
105
|
-
| --- | --- | --- |
|
|
106
|
-
| **Windows** | 将期望 bin 目录写入用户 `Path`(注册表)。所有权键:`Software\dsh-custom-env\Command`(不用 DeepSeekHarness)。 | 可与 Desktop 的 PATH 条目并存;新终端里谁排前用谁。 |
|
|
107
|
-
| **macOS** | 写符号链接 `/usr/local/bin/dsh` → 期望启动器。收据:`.dsh-custom-env-command.json`。 | **与 Desktop「管理 dsh 命令…」同一路径**,可能覆盖其链接。 |
|
|
108
|
-
| **Linux** | 仅展示状态,无安装按钮。 | — |
|
|
44
|
+
## 给其他插件(Remote API)
|
|
109
45
|
|
|
110
|
-
|
|
46
|
+
通过 Host 的 `customEnv` 服务调用(`ctx.get('customEnv')` 或已注入的 `ctx.customEnv`)。
|
|
111
47
|
|
|
112
|
-
|
|
48
|
+
**常用:按变量名**
|
|
113
49
|
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
50
|
+
```ts
|
|
51
|
+
const env = ctx.get('customEnv')
|
|
52
|
+
|
|
53
|
+
await env?.setVar('MY_KEY', 'value') // 新建或覆盖
|
|
54
|
+
await env?.setVar('MY_KEY', '') // 仅当不存在时新建
|
|
55
|
+
await env?.removeVar('MY_KEY')
|
|
56
|
+
|
|
57
|
+
await env?.setVars([
|
|
58
|
+
{ name: 'A', value: '1' },
|
|
59
|
+
{ name: 'B', value: '' }, // B 已存在则跳过
|
|
60
|
+
])
|
|
61
|
+
await env?.removeVars(['A', 'B'])
|
|
118
62
|
```
|
|
119
63
|
|
|
120
|
-
|
|
64
|
+
保留名会被拒绝(批量调用整批失败)。
|
|
65
|
+
|
|
66
|
+
**设置页:按行 id**
|
|
121
67
|
|
|
122
|
-
|
|
68
|
+
| 调用 | 用途 |
|
|
69
|
+
|------|------|
|
|
70
|
+
| `list()` | 列出当前变量与行 id |
|
|
71
|
+
| `upsert(id, name, value)` | 新建(`id` 为空)或更新/重命名一行 |
|
|
72
|
+
| `deleteEntry(id)` | 删除该行 |
|
|
73
|
+
| `restore(id)` | 恢复启动时的值;若是启动后新增的行则删除 |
|
|
123
74
|
|
|
124
|
-
|
|
125
|
-
| --- | --- | --- |
|
|
126
|
-
| **只推 GitHub** | 够 | `dsh plugin add github:ownduck/dsh-custom-env` |
|
|
127
|
-
| **再发 npmjs** | 可选 | `dsh plugin add @woosau/dsh-custom-env` |
|
|
75
|
+
**CLI**
|
|
128
76
|
|
|
129
|
-
|
|
77
|
+
| 调用 | 用途 |
|
|
78
|
+
|------|------|
|
|
79
|
+
| `cliStatus()` | 本 Host 的 `dsh` 是否可用 / 能否安装 |
|
|
80
|
+
| `cliInstall()` | 安装或修复该 CLI 入口 |
|
|
130
81
|
|
|
131
82
|
## 许可证
|
|
132
83
|
|