@woosau/dsh-custom-env 0.1.1 → 0.1.6
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 -53
- package/README.zh-CN.md +84 -53
- package/lib/client.js +138 -1
- package/lib/index.js +327 -180
- package/lib/typert.host.js +171 -1
- package/lib/typert.remote-client.js +143 -1
- 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 +20 -6
- package/lib/types/types.d.ts +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,53 +1,84 @@
|
|
|
1
|
-
# dsh-custom-env
|
|
2
|
-
|
|
3
|
-
English | [中文](README.zh-CN.md)
|
|
4
|
-
|
|
5
|
-
Community DeepSeek Harness plugin
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](LICENSE)
|
|
10
|
-
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```powershell
|
|
24
|
-
dsh plugin --profile desktop
|
|
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
|
-
|
|
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. At startup, values are injected into the Host `process.env` first; writing the user environment (registry / launchctl) is deferred off the boot path and is not broadcast. Log off or reboot before other tools need those values
|
|
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
|
@@ -1,53 +1,84 @@
|
|
|
1
|
-
# dsh-custom-env
|
|
2
|
-
|
|
3
|
-
[English](README.md) | 中文
|
|
4
|
-
|
|
5
|
-
社区 DeepSeek Harness 插件:在 **设置 → 环境变量**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](LICENSE)
|
|
10
|
-
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```powershell
|
|
24
|
-
dsh plugin --profile desktop
|
|
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
|
-
|
|
1
|
+
# dsh-custom-env
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
社区 DeepSeek Harness 插件:在 **设置 → 环境变量** 里管理环境变量。非 DeepSeek AI 官方产品。
|
|
6
|
+
|
|
7
|
+
保存后立即作用于当前应用;在 Windows / macOS 上还会写入用户环境,方便新开的终端读到。不支持同步 Linux 用户环境。
|
|
8
|
+
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
需已安装 DSH,并能使用 `dsh` 命令(`desktop` 或 `web`)。
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
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
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
若因 Desktop 占用文件导致安装失败,先退出 Desktop。安装后重启 DSH,打开 **设置 → 环境变量**。
|
|
22
|
+
|
|
23
|
+
```powershell
|
|
24
|
+
dsh plugin --profile desktop remove @woosau/dsh-custom-env
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 给使用者
|
|
28
|
+
|
|
29
|
+
1. 打开 **设置 → 环境变量**
|
|
30
|
+
2. 先改草稿 → **确定** 保存,**取消** 放弃
|
|
31
|
+
3. **恢复** 可回到本次应用启动时的值
|
|
32
|
+
4. 启动时先注入当前 Host 的 `process.env`;写入用户环境(注册表 / launchctl)会延后到启动路径之后,且不会广播。其它工具若要读到,请注销/重启后再开终端
|
|
33
|
+
5. 仅在出现 **安装** 时使用:把本 Host 的 `dsh` 接到用户 PATH(Windows / macOS)
|
|
34
|
+
|
|
35
|
+
系统保留名(如 `PATH`,以及 `DSH_` / `XDG_` 开头)不可在此编辑。
|
|
36
|
+
|
|
37
|
+
### 保存时怎么处理
|
|
38
|
+
|
|
39
|
+
| 你保存的内容 | 变量还不存在 | 变量已存在 |
|
|
40
|
+
|--------------|--------------|------------|
|
|
41
|
+
| 非空 | 新建 | 覆盖 |
|
|
42
|
+
| 空 | 建为空变量 | 保持原样不动 |
|
|
43
|
+
|
|
44
|
+
## 给其他插件(Remote API)
|
|
45
|
+
|
|
46
|
+
通过 Host 的 `customEnv` 服务调用(`ctx.get('customEnv')` 或已注入的 `ctx.customEnv`)。
|
|
47
|
+
|
|
48
|
+
**常用:按变量名**
|
|
49
|
+
|
|
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'])
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
保留名会被拒绝(批量调用整批失败)。
|
|
65
|
+
|
|
66
|
+
**设置页:按行 id**
|
|
67
|
+
|
|
68
|
+
| 调用 | 用途 |
|
|
69
|
+
|------|------|
|
|
70
|
+
| `list()` | 列出当前变量与行 id |
|
|
71
|
+
| `upsert(id, name, value)` | 新建(`id` 为空)或更新/重命名一行 |
|
|
72
|
+
| `deleteEntry(id)` | 删除该行 |
|
|
73
|
+
| `restore(id)` | 恢复启动时的值;若是启动后新增的行则删除 |
|
|
74
|
+
|
|
75
|
+
**CLI**
|
|
76
|
+
|
|
77
|
+
| 调用 | 用途 |
|
|
78
|
+
|------|------|
|
|
79
|
+
| `cliStatus()` | 本 Host 的 `dsh` 是否可用 / 能否安装 |
|
|
80
|
+
| `cliInstall()` | 安装或修复该 CLI 入口 |
|
|
81
|
+
|
|
82
|
+
## 许可证
|
|
83
|
+
|
|
84
|
+
MIT
|
package/lib/client.js
CHANGED
|
@@ -209,6 +209,28 @@ var upsert$parameter$2$schema$value;
|
|
|
209
209
|
var upsert$parameter$2$schema = () => upsert$parameter$2$schema$value ??= import_zod.z.string();
|
|
210
210
|
var remove$parameter$0$schema$value;
|
|
211
211
|
var remove$parameter$0$schema = () => remove$parameter$0$schema$value ??= import_zod.z.string();
|
|
212
|
+
var setVar$parameter$0$schema$value;
|
|
213
|
+
var setVar$parameter$0$schema = () => setVar$parameter$0$schema$value ??= import_zod.z.string();
|
|
214
|
+
var setVar$parameter$1$schema$value;
|
|
215
|
+
var setVar$parameter$1$schema = () => setVar$parameter$1$schema$value ??= import_zod.z.string();
|
|
216
|
+
var setVars$parameter$0$schema$value;
|
|
217
|
+
var setVars$parameter$0$schema = () => setVars$parameter$0$schema$value ??= import_zod.z.array(import_zod.z.object({
|
|
218
|
+
name: import_zod.z.string().readonly(),
|
|
219
|
+
value: import_zod.z.string().readonly()
|
|
220
|
+
}).readonly()).readonly();
|
|
221
|
+
var removeVar$parameter$0$schema$value;
|
|
222
|
+
var removeVar$parameter$0$schema = () => removeVar$parameter$0$schema$value ??= import_zod.z.string();
|
|
223
|
+
var removeVars$parameter$0$schema$value;
|
|
224
|
+
var removeVars$parameter$0$schema = () => removeVars$parameter$0$schema$value ??= import_zod.z.array(import_zod.z.string()).readonly();
|
|
225
|
+
var envVarWriteJsonSchema = {
|
|
226
|
+
type: "object",
|
|
227
|
+
properties: {
|
|
228
|
+
name: { type: "string" },
|
|
229
|
+
value: { type: "string" }
|
|
230
|
+
},
|
|
231
|
+
required: ["name", "value"],
|
|
232
|
+
additionalProperties: false
|
|
233
|
+
};
|
|
212
234
|
var restore$parameter$0$schema$value;
|
|
213
235
|
var restore$parameter$0$schema = () => restore$parameter$0$schema$value ??= import_zod.z.string();
|
|
214
236
|
var cliStatusJsonSchema = {
|
|
@@ -295,7 +317,7 @@ var TYPERT_REMOTE = createTypertRemoteInfo({
|
|
|
295
317
|
},
|
|
296
318
|
{
|
|
297
319
|
name: "value",
|
|
298
|
-
description: "
|
|
320
|
+
description: "value (empty string allowed).",
|
|
299
321
|
source: "json",
|
|
300
322
|
codec: {
|
|
301
323
|
mode: "strict",
|
|
@@ -314,6 +336,121 @@ var TYPERT_REMOTE = createTypertRemoteInfo({
|
|
|
314
336
|
},
|
|
315
337
|
sourceLocation: { file: "src/index.ts", line: 1, column: 1 }
|
|
316
338
|
},
|
|
339
|
+
"customEnv/setVars": {
|
|
340
|
+
service: "customEnv",
|
|
341
|
+
description: "Create or replace many variables by name in one rewrite. Empty values write NAME=.",
|
|
342
|
+
invocation: { kind: "direct" },
|
|
343
|
+
parameters: [
|
|
344
|
+
{
|
|
345
|
+
name: "entries",
|
|
346
|
+
description: "name/value pairs (last duplicate name wins).",
|
|
347
|
+
source: "json",
|
|
348
|
+
codec: {
|
|
349
|
+
mode: "strict",
|
|
350
|
+
typeSymbol: "readonly EnvVarWrite[]",
|
|
351
|
+
create: setVars$parameter$0$schema,
|
|
352
|
+
jsonSchema: { type: "array", items: envVarWriteJsonSchema }
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
],
|
|
356
|
+
result: {
|
|
357
|
+
mode: "strict",
|
|
358
|
+
typeSymbol: "void",
|
|
359
|
+
create: () => import_zod.z.undefined(),
|
|
360
|
+
description: "no return value.",
|
|
361
|
+
jsonSchema: { type: "null" }
|
|
362
|
+
},
|
|
363
|
+
sourceLocation: { file: "src/index.ts", line: 1, column: 1 }
|
|
364
|
+
},
|
|
365
|
+
"customEnv/setVar": {
|
|
366
|
+
service: "customEnv",
|
|
367
|
+
description: "Create or replace one variable by name. Empty value writes NAME=.",
|
|
368
|
+
invocation: { kind: "direct" },
|
|
369
|
+
parameters: [
|
|
370
|
+
{
|
|
371
|
+
name: "name",
|
|
372
|
+
description: "writable variable name.",
|
|
373
|
+
source: "json",
|
|
374
|
+
codec: {
|
|
375
|
+
mode: "strict",
|
|
376
|
+
typeSymbol: "string",
|
|
377
|
+
create: setVar$parameter$0$schema,
|
|
378
|
+
jsonSchema: { type: "string" }
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
name: "value",
|
|
383
|
+
description: "value to store (empty string allowed).",
|
|
384
|
+
source: "json",
|
|
385
|
+
codec: {
|
|
386
|
+
mode: "strict",
|
|
387
|
+
typeSymbol: "string",
|
|
388
|
+
create: setVar$parameter$1$schema,
|
|
389
|
+
jsonSchema: { type: "string" }
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
result: {
|
|
394
|
+
mode: "strict",
|
|
395
|
+
typeSymbol: "void",
|
|
396
|
+
create: () => import_zod.z.undefined(),
|
|
397
|
+
description: "no return value.",
|
|
398
|
+
jsonSchema: { type: "null" }
|
|
399
|
+
},
|
|
400
|
+
sourceLocation: { file: "src/index.ts", line: 1, column: 1 }
|
|
401
|
+
},
|
|
402
|
+
"customEnv/removeVars": {
|
|
403
|
+
service: "customEnv",
|
|
404
|
+
description: "Remove many variables by name from the file, Host, and OS user environment.",
|
|
405
|
+
invocation: { kind: "direct" },
|
|
406
|
+
parameters: [
|
|
407
|
+
{
|
|
408
|
+
name: "names",
|
|
409
|
+
description: "writable variable names.",
|
|
410
|
+
source: "json",
|
|
411
|
+
codec: {
|
|
412
|
+
mode: "strict",
|
|
413
|
+
typeSymbol: "readonly string[]",
|
|
414
|
+
create: removeVars$parameter$0$schema,
|
|
415
|
+
jsonSchema: { type: "array", items: { type: "string" } }
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
result: {
|
|
420
|
+
mode: "strict",
|
|
421
|
+
typeSymbol: "number",
|
|
422
|
+
create: () => import_zod.z.number(),
|
|
423
|
+
description: "number of .env lines removed.",
|
|
424
|
+
jsonSchema: { type: "number" }
|
|
425
|
+
},
|
|
426
|
+
sourceLocation: { file: "src/index.ts", line: 1, column: 1 }
|
|
427
|
+
},
|
|
428
|
+
"customEnv/removeVar": {
|
|
429
|
+
service: "customEnv",
|
|
430
|
+
description: "Remove one variable by name from the file, Host, and OS user environment.",
|
|
431
|
+
invocation: { kind: "direct" },
|
|
432
|
+
parameters: [
|
|
433
|
+
{
|
|
434
|
+
name: "name",
|
|
435
|
+
description: "writable variable name.",
|
|
436
|
+
source: "json",
|
|
437
|
+
codec: {
|
|
438
|
+
mode: "strict",
|
|
439
|
+
typeSymbol: "string",
|
|
440
|
+
create: removeVar$parameter$0$schema,
|
|
441
|
+
jsonSchema: { type: "string" }
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
],
|
|
445
|
+
result: {
|
|
446
|
+
mode: "strict",
|
|
447
|
+
typeSymbol: "boolean",
|
|
448
|
+
create: () => import_zod.z.boolean(),
|
|
449
|
+
description: "true when a .env line was removed.",
|
|
450
|
+
jsonSchema: { type: "boolean" }
|
|
451
|
+
},
|
|
452
|
+
sourceLocation: { file: "src/index.ts", line: 1, column: 1 }
|
|
453
|
+
},
|
|
317
454
|
"customEnv/deleteEntry": {
|
|
318
455
|
service: "customEnv",
|
|
319
456
|
description: "Delete one entry from the file, Host, and OS user environment.",
|