@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 CHANGED
@@ -1,53 +1,84 @@
1
- # dsh-custom-env
2
-
3
- English | [中文](README.zh-CN.md)
4
-
5
- Community DeepSeek Harness plugin: manage `$DSH_HOME/.env` from **Settings → Environment**. Not an official DeepSeek AI product.
6
-
7
- Edits apply to the Host immediately and sync to the Windows / macOS user environment (new terminals pick up OS changes). Linux user-env sync is not supported.
8
-
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
10
-
11
- ## Features
12
-
13
- - CRUD for `$DSH_HOME/.env` in Settings
14
- - Hot-apply to the current Host process
15
- - Sync to Windows / macOS user environment
16
- - Rejects bootstrap names (`PATH`, `DSH_*`, `XDG_*`, …)
17
- - Optional **Install** for the `dsh` CLI used by this Host (Windows / macOS)
18
-
19
- ## Install
20
-
21
- Requires a working DSH install with the `dsh` CLI. Use profile `desktop` or `web`.
22
-
23
- ```powershell
24
- dsh plugin --profile desktop add @woosau/dsh-custom-env
25
- ```
26
-
27
- ```powershell
28
- dsh plugin --profile web add @woosau/dsh-custom-env
29
- ```
30
-
31
- GitHub: `dsh plugin --profile desktop add github:ownduck/dsh-custom-env`
32
-
33
- Close Desktop first if `plugin` hits `EPERM` on the profile `package.json`. GitHub installs may need `allowBuilds.koffi: true` in the profile `pnpm-workspace.yaml` (native `koffi`). Then restart DSH and open **Settings → Environment**.
34
-
35
- ## Uninstall
36
-
37
- ```powershell
38
- dsh plugin --profile desktop remove @woosau/dsh-custom-env
39
- ```
40
-
41
- ## Usage
42
-
43
- 1. Open **Settings → Environment**
44
- 2. Edit as a draft: **Confirm** writes `.env` and live Host/OS; **Cancel** reverts the inputs
45
- 3. After Confirm, restart tips appear for new/changed rows; **Restore** writes back the Host-start value
46
- 4. Restart DSH or open a new terminal for the full OS effect
47
- 5. Use **Install** in the dsh block only when offered (Windows user PATH / macOS `/usr/local/bin/dsh`; may replace Desktop’s link on macOS)
48
-
49
- Do not put bootstrap names (including `PATH`) in `.env`.
50
-
51
- ## License
52
-
53
- 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: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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 插件:在 **设置 → 环境变量** 管理 `$DSH_HOME/.env`。非 DeepSeek AI 官方产品。
6
-
7
- 保存后立即作用于 Host,并同步到 Windows / macOS 用户环境(新开终端可见 OS 侧变更)。不同步 Linux 用户环境。
8
-
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
10
-
11
- ## 功能
12
-
13
- - 设置页管理 `$DSH_HOME/.env`
14
- - 热写当前 Host 进程
15
- - 同步 Windows / macOS 用户环境
16
- - 拒绝 bootstrap 名(`PATH`、`DSH_*`、`XDG_*` 等)
17
- - 可选为本 Host **安装** `dsh` CLI(Windows / macOS)
18
-
19
- ## 安装
20
-
21
- 需已安装 DSH 且可用 `dsh` CLI。profile 选 `desktop` 或 `web`。
22
-
23
- ```powershell
24
- dsh plugin --profile desktop add @woosau/dsh-custom-env
25
- ```
26
-
27
- ```powershell
28
- dsh plugin --profile web add @woosau/dsh-custom-env
29
- ```
30
-
31
- GitHub:`dsh plugin --profile desktop add github:ownduck/dsh-custom-env`
32
-
33
- 若 `plugin` 报 profile `package.json` 的 `EPERM`,先退出 Desktop。从 GitHub 安装时,profile 的 `pnpm-workspace.yaml` 可能需要 `allowBuilds.koffi: true`(原生依赖 `koffi`)。然后重启 DSH,打开 **设置 → 环境变量**。
34
-
35
- ## 卸载
36
-
37
- ```powershell
38
- dsh plugin --profile desktop remove @woosau/dsh-custom-env
39
- ```
40
-
41
- ## 使用
42
-
43
- 1. 打开 **设置 → 环境变量**
44
- 2. 草稿编辑:**确定** 写入 `.env` 并热写 Host/OS;**取消** 只恢复输入框
45
- 3. 确定后新增/修改行旁有重启提示;**恢复** 可写回 Host 启动时的值
46
- 4. 完整生效请重启 DSH 或新开终端
47
- 5. **dsh** 区块仅在出现按钮时点 **安装**(Windows 用户 PATH / macOS `/usr/local/bin/dsh`;macOS 上可能覆盖 Desktop 的链接)
48
-
49
- 不要把 bootstrap 名(含 `PATH`)写进 `.env`。
50
-
51
- ## 许可证
52
-
53
- MIT
1
+ # dsh-custom-env
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 社区 DeepSeek Harness 插件:在 **设置 → 环境变量** 里管理环境变量。非 DeepSeek AI 官方产品。
6
+
7
+ 保存后立即作用于当前应用;在 Windows / macOS 上还会写入用户环境,方便新开的终端读到。不支持同步 Linux 用户环境。
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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: "non-empty value.",
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.",