@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.
@@ -37,6 +37,33 @@ const upsert$parameter$2$schema = () => (upsert$parameter$2$schema$value ??= z.s
37
37
  let remove$parameter$0$schema$value
38
38
  const remove$parameter$0$schema = () => (remove$parameter$0$schema$value ??= z.string())
39
39
 
40
+ let setVar$parameter$0$schema$value
41
+ const setVar$parameter$0$schema = () => (setVar$parameter$0$schema$value ??= z.string())
42
+ let setVar$parameter$1$schema$value
43
+ const setVar$parameter$1$schema = () => (setVar$parameter$1$schema$value ??= z.string())
44
+
45
+ let setVars$parameter$0$schema$value
46
+ const setVars$parameter$0$schema = () => (setVars$parameter$0$schema$value ??= z.array(z.object({
47
+ name: z.string().readonly(),
48
+ value: z.string().readonly(),
49
+ }).readonly()).readonly())
50
+
51
+ let removeVar$parameter$0$schema$value
52
+ const removeVar$parameter$0$schema = () => (removeVar$parameter$0$schema$value ??= z.string())
53
+
54
+ let removeVars$parameter$0$schema$value
55
+ const removeVars$parameter$0$schema = () => (removeVars$parameter$0$schema$value ??= z.array(z.string()).readonly())
56
+
57
+ const envVarWriteJsonSchema = {
58
+ type: 'object',
59
+ properties: {
60
+ name: { type: 'string' },
61
+ value: { type: 'string' },
62
+ },
63
+ required: ['name', 'value'],
64
+ additionalProperties: false,
65
+ }
66
+
40
67
  let restore$parameter$0$schema$value
41
68
  const restore$parameter$0$schema = () => (restore$parameter$0$schema$value ??= z.string())
42
69
 
@@ -126,7 +153,7 @@ const $remote = createTypertRemoteInfo({
126
153
  },
127
154
  {
128
155
  name: 'value',
129
- description: 'non-empty value.',
156
+ description: 'value (empty string allowed).',
130
157
  source: 'json',
131
158
  codec: {
132
159
  mode: 'strict',
@@ -145,6 +172,121 @@ const $remote = createTypertRemoteInfo({
145
172
  },
146
173
  sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
147
174
  },
175
+ 'customEnv/setVars': {
176
+ service: 'customEnv',
177
+ description: 'Create or replace many variables by name in one rewrite. Empty values write NAME=.',
178
+ invocation: { kind: 'direct' },
179
+ parameters: [
180
+ {
181
+ name: 'entries',
182
+ description: 'name/value pairs (last duplicate name wins).',
183
+ source: 'json',
184
+ codec: {
185
+ mode: 'strict',
186
+ typeSymbol: 'readonly EnvVarWrite[]',
187
+ create: setVars$parameter$0$schema,
188
+ jsonSchema: { type: 'array', items: envVarWriteJsonSchema },
189
+ },
190
+ },
191
+ ],
192
+ result: {
193
+ mode: 'strict',
194
+ typeSymbol: 'void',
195
+ create: () => z.undefined(),
196
+ description: 'no return value.',
197
+ jsonSchema: { type: 'null' },
198
+ },
199
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
200
+ },
201
+ 'customEnv/setVar': {
202
+ service: 'customEnv',
203
+ description: 'Create or replace one variable by name. Empty value writes NAME=.',
204
+ invocation: { kind: 'direct' },
205
+ parameters: [
206
+ {
207
+ name: 'name',
208
+ description: 'writable variable name.',
209
+ source: 'json',
210
+ codec: {
211
+ mode: 'strict',
212
+ typeSymbol: 'string',
213
+ create: setVar$parameter$0$schema,
214
+ jsonSchema: { type: 'string' },
215
+ },
216
+ },
217
+ {
218
+ name: 'value',
219
+ description: 'value to store (empty string allowed).',
220
+ source: 'json',
221
+ codec: {
222
+ mode: 'strict',
223
+ typeSymbol: 'string',
224
+ create: setVar$parameter$1$schema,
225
+ jsonSchema: { type: 'string' },
226
+ },
227
+ },
228
+ ],
229
+ result: {
230
+ mode: 'strict',
231
+ typeSymbol: 'void',
232
+ create: () => z.undefined(),
233
+ description: 'no return value.',
234
+ jsonSchema: { type: 'null' },
235
+ },
236
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
237
+ },
238
+ 'customEnv/removeVars': {
239
+ service: 'customEnv',
240
+ description: 'Remove many variables by name from the file, Host, and OS user environment.',
241
+ invocation: { kind: 'direct' },
242
+ parameters: [
243
+ {
244
+ name: 'names',
245
+ description: 'writable variable names.',
246
+ source: 'json',
247
+ codec: {
248
+ mode: 'strict',
249
+ typeSymbol: 'readonly string[]',
250
+ create: removeVars$parameter$0$schema,
251
+ jsonSchema: { type: 'array', items: { type: 'string' } },
252
+ },
253
+ },
254
+ ],
255
+ result: {
256
+ mode: 'strict',
257
+ typeSymbol: 'number',
258
+ create: () => z.number(),
259
+ description: 'number of .env lines removed.',
260
+ jsonSchema: { type: 'number' },
261
+ },
262
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
263
+ },
264
+ 'customEnv/removeVar': {
265
+ service: 'customEnv',
266
+ description: 'Remove one variable by name from the file, Host, and OS user environment.',
267
+ invocation: { kind: 'direct' },
268
+ parameters: [
269
+ {
270
+ name: 'name',
271
+ description: 'writable variable name.',
272
+ source: 'json',
273
+ codec: {
274
+ mode: 'strict',
275
+ typeSymbol: 'string',
276
+ create: removeVar$parameter$0$schema,
277
+ jsonSchema: { type: 'string' },
278
+ },
279
+ },
280
+ ],
281
+ result: {
282
+ mode: 'strict',
283
+ typeSymbol: 'boolean',
284
+ create: () => z.boolean(),
285
+ description: 'true when a .env line was removed.',
286
+ jsonSchema: { type: 'boolean' },
287
+ },
288
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
289
+ },
148
290
  'customEnv/deleteEntry': {
149
291
  service: 'customEnv',
150
292
  description: 'Delete one entry from the file, Host, and OS user environment.',
@@ -257,6 +399,34 @@ export const TYPERT = {
257
399
  summary: 'Create or update one row by id.',
258
400
  jsDoc: '/** Create (`id === ""`) or update/rename one row. */',
259
401
  },
402
+ {
403
+ kind: 'method',
404
+ name: 'setVars',
405
+ signature: "@Remote('setVars') async setVars(entries: readonly EnvVarWrite[]): Promise<void>",
406
+ summary: 'Create or replace many variables by name (empty values allowed).',
407
+ jsDoc: '/** Create or replace many variables by name. Empty values allowed. */',
408
+ },
409
+ {
410
+ kind: 'method',
411
+ name: 'setVar',
412
+ signature: "@Remote('setVar') async setVar(name: string, value: string): Promise<void>",
413
+ summary: 'Create or replace one variable by name (empty value allowed).',
414
+ jsDoc: '/** Create or replace one variable by name. Empty value allowed. */',
415
+ },
416
+ {
417
+ kind: 'method',
418
+ name: 'removeVars',
419
+ signature: "@Remote('removeVars') async removeVars(names: readonly string[]): Promise<number>",
420
+ summary: 'Remove many variables by name.',
421
+ jsDoc: '/** Remove many variables by name. Returns how many lines were removed. */',
422
+ },
423
+ {
424
+ kind: 'method',
425
+ name: 'removeVar',
426
+ signature: "@Remote('removeVar') async removeVar(name: string): Promise<boolean>",
427
+ summary: 'Remove one variable by name.',
428
+ jsDoc: '/** Remove one variable by name. Returns whether a line was removed. */',
429
+ },
260
430
  {
261
431
  kind: 'method',
262
432
  name: 'deleteEntry',
@@ -37,6 +37,33 @@ const upsert$parameter$2$schema = () => (upsert$parameter$2$schema$value ??= z.s
37
37
  let remove$parameter$0$schema$value
38
38
  const remove$parameter$0$schema = () => (remove$parameter$0$schema$value ??= z.string())
39
39
 
40
+ let setVar$parameter$0$schema$value
41
+ const setVar$parameter$0$schema = () => (setVar$parameter$0$schema$value ??= z.string())
42
+ let setVar$parameter$1$schema$value
43
+ const setVar$parameter$1$schema = () => (setVar$parameter$1$schema$value ??= z.string())
44
+
45
+ let setVars$parameter$0$schema$value
46
+ const setVars$parameter$0$schema = () => (setVars$parameter$0$schema$value ??= z.array(z.object({
47
+ name: z.string().readonly(),
48
+ value: z.string().readonly(),
49
+ }).readonly()).readonly())
50
+
51
+ let removeVar$parameter$0$schema$value
52
+ const removeVar$parameter$0$schema = () => (removeVar$parameter$0$schema$value ??= z.string())
53
+
54
+ let removeVars$parameter$0$schema$value
55
+ const removeVars$parameter$0$schema = () => (removeVars$parameter$0$schema$value ??= z.array(z.string()).readonly())
56
+
57
+ const envVarWriteJsonSchema = {
58
+ type: 'object',
59
+ properties: {
60
+ name: { type: 'string' },
61
+ value: { type: 'string' },
62
+ },
63
+ required: ['name', 'value'],
64
+ additionalProperties: false,
65
+ }
66
+
40
67
  let restore$parameter$0$schema$value
41
68
  const restore$parameter$0$schema = () => (restore$parameter$0$schema$value ??= z.string())
42
69
 
@@ -126,7 +153,7 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
126
153
  },
127
154
  {
128
155
  name: 'value',
129
- description: 'non-empty value.',
156
+ description: 'value (empty string allowed).',
130
157
  source: 'json',
131
158
  codec: {
132
159
  mode: 'strict',
@@ -145,6 +172,121 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
145
172
  },
146
173
  sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
147
174
  },
175
+ 'customEnv/setVars': {
176
+ service: 'customEnv',
177
+ description: 'Create or replace many variables by name in one rewrite. Empty values write NAME=.',
178
+ invocation: { kind: 'direct' },
179
+ parameters: [
180
+ {
181
+ name: 'entries',
182
+ description: 'name/value pairs (last duplicate name wins).',
183
+ source: 'json',
184
+ codec: {
185
+ mode: 'strict',
186
+ typeSymbol: 'readonly EnvVarWrite[]',
187
+ create: setVars$parameter$0$schema,
188
+ jsonSchema: { type: 'array', items: envVarWriteJsonSchema },
189
+ },
190
+ },
191
+ ],
192
+ result: {
193
+ mode: 'strict',
194
+ typeSymbol: 'void',
195
+ create: () => z.undefined(),
196
+ description: 'no return value.',
197
+ jsonSchema: { type: 'null' },
198
+ },
199
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
200
+ },
201
+ 'customEnv/setVar': {
202
+ service: 'customEnv',
203
+ description: 'Create or replace one variable by name. Empty value writes NAME=.',
204
+ invocation: { kind: 'direct' },
205
+ parameters: [
206
+ {
207
+ name: 'name',
208
+ description: 'writable variable name.',
209
+ source: 'json',
210
+ codec: {
211
+ mode: 'strict',
212
+ typeSymbol: 'string',
213
+ create: setVar$parameter$0$schema,
214
+ jsonSchema: { type: 'string' },
215
+ },
216
+ },
217
+ {
218
+ name: 'value',
219
+ description: 'value to store (empty string allowed).',
220
+ source: 'json',
221
+ codec: {
222
+ mode: 'strict',
223
+ typeSymbol: 'string',
224
+ create: setVar$parameter$1$schema,
225
+ jsonSchema: { type: 'string' },
226
+ },
227
+ },
228
+ ],
229
+ result: {
230
+ mode: 'strict',
231
+ typeSymbol: 'void',
232
+ create: () => z.undefined(),
233
+ description: 'no return value.',
234
+ jsonSchema: { type: 'null' },
235
+ },
236
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
237
+ },
238
+ 'customEnv/removeVars': {
239
+ service: 'customEnv',
240
+ description: 'Remove many variables by name from the file, Host, and OS user environment.',
241
+ invocation: { kind: 'direct' },
242
+ parameters: [
243
+ {
244
+ name: 'names',
245
+ description: 'writable variable names.',
246
+ source: 'json',
247
+ codec: {
248
+ mode: 'strict',
249
+ typeSymbol: 'readonly string[]',
250
+ create: removeVars$parameter$0$schema,
251
+ jsonSchema: { type: 'array', items: { type: 'string' } },
252
+ },
253
+ },
254
+ ],
255
+ result: {
256
+ mode: 'strict',
257
+ typeSymbol: 'number',
258
+ create: () => z.number(),
259
+ description: 'number of .env lines removed.',
260
+ jsonSchema: { type: 'number' },
261
+ },
262
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
263
+ },
264
+ 'customEnv/removeVar': {
265
+ service: 'customEnv',
266
+ description: 'Remove one variable by name from the file, Host, and OS user environment.',
267
+ invocation: { kind: 'direct' },
268
+ parameters: [
269
+ {
270
+ name: 'name',
271
+ description: 'writable variable name.',
272
+ source: 'json',
273
+ codec: {
274
+ mode: 'strict',
275
+ typeSymbol: 'string',
276
+ create: removeVar$parameter$0$schema,
277
+ jsonSchema: { type: 'string' },
278
+ },
279
+ },
280
+ ],
281
+ result: {
282
+ mode: 'strict',
283
+ typeSymbol: 'boolean',
284
+ create: () => z.boolean(),
285
+ description: 'true when a .env line was removed.',
286
+ jsonSchema: { type: 'boolean' },
287
+ },
288
+ sourceLocation: { file: 'src/index.ts', line: 1, column: 1 },
289
+ },
148
290
  'customEnv/deleteEntry': {
149
291
  service: 'customEnv',
150
292
  description: 'Delete one entry from the file, Host, and OS user environment.',
@@ -0,0 +1,10 @@
1
+ /** Map Host Remote failures to settings.env locale strings. */
2
+ import type { EnvSettingsKey } from './locales.ts';
3
+ type Translate = (key: EnvSettingsKey) => string;
4
+ /**
5
+ * Localize a caught Remote failure for the settings section.
6
+ * @param error - thrown value from inject call helpers.
7
+ * @param t - bound settings.env translator.
8
+ */
9
+ export declare function formatRemoteError(error: unknown, t: Translate): string;
10
+ export {};
@@ -1,9 +1,67 @@
1
- /** Locale dictionaries for the environment-variables settings section. */
1
+ /** `settings.env` namespace dictionaries for the environment settings section. */
2
2
  /** Dictionary namespace owned by this plugin. */
3
- export declare const NS = "settings.env";
4
- /** Keys in the environment settings dictionaries. */
5
- export type EnvSettingsKey = 'nav' | 'title' | 'empty' | 'name' | 'value' | 'actions' | 'confirm' | 'cancel' | 'remove' | 'removeConfirmTitle' | 'removeConfirm' | 'restore' | 'close' | 'namePlaceholder' | 'valuePlaceholder' | 'loading' | 'error' | 'invalidName' | 'restartRequired' | 'cliTitle' | 'cliActiveMissing' | 'cliInstall' | 'cliMacConflict' | 'cliInstallError' | 'cliReasonUnresolved' | 'cliReasonUnsupported';
6
- /** English copy. */
7
- export declare const en: Record<EnvSettingsKey, string>;
8
- /** Chinese copy. */
9
- export declare const zh: Record<EnvSettingsKey, string>;
3
+ export declare const NS: "settings.env";
4
+ /** Simplified Chinese dictionary (the key-set source of truth). */
5
+ export declare const zh: {
6
+ 'panel.nav': string;
7
+ 'panel.title': string;
8
+ 'panel.empty': string;
9
+ 'panel.loading': string;
10
+ 'field.name': string;
11
+ 'field.value': string;
12
+ 'field.actions': string;
13
+ 'field.namePlaceholder': string;
14
+ 'field.valuePlaceholder': string;
15
+ 'action.confirm': string;
16
+ 'action.cancel': string;
17
+ 'action.remove': string;
18
+ 'action.removeConfirmTitle': string;
19
+ 'action.removeConfirm': string;
20
+ 'action.restore': string;
21
+ 'action.close': string;
22
+ 'status.restartRequired': string;
23
+ 'cli.title': string;
24
+ 'cli.activeMissing': string;
25
+ 'cli.install': string;
26
+ 'cli.macConflict': string;
27
+ 'error.generic': string;
28
+ 'error.invalidName': string;
29
+ 'error.invalidValue': string;
30
+ 'error.restoreFailed': string;
31
+ 'error.cliInstall': string;
32
+ 'error.cliUnresolved': string;
33
+ 'error.cliUnsupported': string;
34
+ };
35
+ /** The settings.env namespace key union. */
36
+ export type EnvSettingsKey = keyof typeof zh;
37
+ /** English dictionary, checked complete against the zh key set. */
38
+ export declare const en: {
39
+ 'panel.nav': string;
40
+ 'panel.title': string;
41
+ 'panel.empty': string;
42
+ 'panel.loading': string;
43
+ 'field.name': string;
44
+ 'field.value': string;
45
+ 'field.actions': string;
46
+ 'field.namePlaceholder': string;
47
+ 'field.valuePlaceholder': string;
48
+ 'action.confirm': string;
49
+ 'action.cancel': string;
50
+ 'action.remove': string;
51
+ 'action.removeConfirmTitle': string;
52
+ 'action.removeConfirm': string;
53
+ 'action.restore': string;
54
+ 'action.close': string;
55
+ 'status.restartRequired': string;
56
+ 'cli.title': string;
57
+ 'cli.activeMissing': string;
58
+ 'cli.install': string;
59
+ 'cli.macConflict': string;
60
+ 'error.generic': string;
61
+ 'error.invalidName': string;
62
+ 'error.invalidValue': string;
63
+ 'error.restoreFailed': string;
64
+ 'error.cliInstall': string;
65
+ 'error.cliUnresolved': string;
66
+ 'error.cliUnsupported': string;
67
+ };
@@ -7,10 +7,10 @@ export interface RawEnvEntry {
7
7
  /** Absolute path of `$DSH_HOME/.env`. */
8
8
  export declare function envFilePath(): string;
9
9
  /**
10
- * Read non-empty writable entries from `$DSH_HOME/.env`.
10
+ * Read writable entries from `$DSH_HOME/.env` (empty values included).
11
11
  * @returns Variable map, or `{}` when absent / empty.
12
12
  */
13
- export declare function loadEnvMap(): Readonly<Record<string, string>>;
13
+ export declare function readEnvMap(): Readonly<Record<string, string>>;
14
14
  /**
15
15
  * List writable entries in `.env` file order (new keys stay at the end).
16
16
  * @returns Path, existence, and ordered entries.
@@ -20,18 +20,66 @@ export declare function listEnvEntries(): {
20
20
  exists: boolean;
21
21
  entries: RawEnvEntry[];
22
22
  };
23
+ /** Options for empty-value write policy. */
24
+ export interface WriteEnvOptions {
25
+ /**
26
+ * When true, empty values always create/replace.
27
+ * When false (default), empty values only create a missing key; existing keys
28
+ * in `$DSH_HOME/.env` or the OS user environment are left unchanged.
29
+ */
30
+ readonly forceEmpty?: boolean;
31
+ }
32
+ /**
33
+ * Whether `name` already exists in `$DSH_HOME/.env` or the OS user environment.
34
+ * Presence counts even when the current value is empty.
35
+ * @param name - Variable name.
36
+ * @returns true when a same-named entry is already present.
37
+ */
38
+ export declare function hasEnvKey(name: string): boolean;
39
+ /**
40
+ * Drop empty writes that would clobber an existing key (unless `forceEmpty`).
41
+ * Non-empty values always pass; last duplicate name wins.
42
+ * @param entries - Candidate writes.
43
+ * @param options - Empty-value policy.
44
+ * @returns Entries that should be applied.
45
+ */
46
+ export declare function selectEnvWrites(entries: readonly {
47
+ readonly name: string;
48
+ readonly value: string;
49
+ }[], options?: WriteEnvOptions): RawEnvEntry[];
23
50
  /**
24
- * Write `name=value` in place of `replaceName` (keeps order), or append when missing.
25
- * Use the same name for both to update; different names to rename in place.
26
- * @param replaceName - line to replace.
27
- * @param name - name to store.
28
- * @param value - non-empty value.
51
+ * Create or replace many keys in one file rewrite (last duplicate name wins).
52
+ * Existing keys keep file order; new keys append in input order.
53
+ * Empty values write `NAME=` only when the key is absent (unless `forceEmpty`).
54
+ * @param entries - name/value pairs.
55
+ * @param options - Empty-value policy.
56
+ * @returns Entries actually written (may be empty when all empty writes were skipped).
57
+ */
58
+ export declare function writeEnvEntries(entries: readonly {
59
+ readonly name: string;
60
+ readonly value: string;
61
+ }[], options?: WriteEnvOptions): RawEnvEntry[];
62
+ /**
63
+ * Create or replace one key (append when new). Honors empty-skip unless `forceEmpty`.
64
+ * @param name - Variable name.
65
+ * @param value - Value to store.
66
+ * @param options - Empty-value policy.
67
+ * @returns true when the file was rewritten.
68
+ */
69
+ export declare function writeEnvEntry(name: string, value: string, options?: WriteEnvOptions): boolean;
70
+ /**
71
+ * Rename one key in place (keeps file order) and always write `value`.
72
+ * @param from - Existing name.
73
+ * @param to - New name.
74
+ * @param value - Value to store.
29
75
  */
30
- export declare function writeEnvEntry(replaceName: string, name: string, value: string): void;
31
- /** Create or replace one key (append when new). */
32
- export declare function upsertEnvEntry(name: string, value: string): void;
33
- /** Rename one key in place (keeps file order). */
34
76
  export declare function renameEnvEntry(from: string, to: string, value: string): void;
77
+ /**
78
+ * Remove many keys from `$DSH_HOME/.env` in one rewrite.
79
+ * @param names - variable names (all must be writable).
80
+ * @returns number of assignment lines removed.
81
+ */
82
+ export declare function removeEnvEntries(names: readonly string[]): number;
35
83
  /**
36
84
  * Remove one key from `$DSH_HOME/.env` when present.
37
85
  * @param name - variable name.
@@ -4,8 +4,8 @@
4
4
  import type { Context } from '@deepseek-ai/cordis';
5
5
  import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
6
6
  import { envFilePath } from './env-file.ts';
7
- import { type CliStatus, type EnvSnapshot } from './types.ts';
8
- export type { BaselineRow, CliStatus, EnvEntry, EnvSnapshot } from './types.ts';
7
+ import { type CliStatus, type EnvSnapshot, type EnvVarWrite } from './types.ts';
8
+ export type { BaselineRow, CliStatus, EnvEntry, EnvSnapshot, EnvVarWrite } from './types.ts';
9
9
  export { classifyEntry } from './types.ts';
10
10
  declare module '@deepseek-ai/cordis' {
11
11
  interface Context {
@@ -39,7 +39,10 @@ export default class CustomEnvController extends TypertRemoteService {
39
39
  private bind;
40
40
  private unbind;
41
41
  private requireName;
42
- /** Persist `name=value` replacing `from` in place; sync process.env / OS. */
42
+ /**
43
+ * Write `name=value` replacing `from` in place; sync process.env / OS.
44
+ * Empty values create missing keys only, unless `forceEmpty` (restore).
45
+ */
43
46
  private commit;
44
47
  /** @returns path, existence, and file-ordered entries. */
45
48
  list(): Promise<EnvSnapshot>;
@@ -47,9 +50,35 @@ export default class CustomEnvController extends TypertRemoteService {
47
50
  * Create or update one row. Empty `id` creates; otherwise keeps that baseline id across renames.
48
51
  * @param id - row id, or `""` for a new row.
49
52
  * @param name - variable name.
50
- * @param value - non-empty value.
53
+ * @param value - value (empty creates only when missing; Settings UI may still reject empty drafts).
51
54
  */
52
55
  upsert(id: string, name: string, value: string): Promise<EnvSnapshot>;
56
+ /**
57
+ * Create or replace many variables by name (plugin-facing).
58
+ * Non-empty values always write; empty values create missing keys only and do not
59
+ * clear existing `$DSH_HOME/.env` or OS user values. One file rewrite; last
60
+ * duplicate name wins. Invalid names reject the whole batch.
61
+ * @param entries - name/value pairs.
62
+ */
63
+ setVars(entries: readonly EnvVarWrite[]): Promise<void>;
64
+ /**
65
+ * Create or replace one variable by name (plugin-facing).
66
+ * @param name - writable variable name.
67
+ * @param value - non-empty always stores; `""` writes `NAME=` only when the key is absent.
68
+ */
69
+ setVar(name: string, value: string): Promise<void>;
70
+ /**
71
+ * Remove many variables by name (plugin-facing).
72
+ * @param names - writable variable names.
73
+ * @returns number of `.env` lines removed.
74
+ */
75
+ removeVars(names: readonly string[]): Promise<number>;
76
+ /**
77
+ * Remove one variable by name (plugin-facing).
78
+ * @param name - writable variable name.
79
+ * @returns true when a `.env` line was removed.
80
+ */
81
+ removeVar(name: string): Promise<boolean>;
53
82
  /** @param id - row id from list(). */
54
83
  deleteEntry(id: string): Promise<EnvSnapshot>;
55
84
  /** Restore Host-start original name+value, or delete if added after start. */
@@ -1,13 +1,24 @@
1
1
  /** OS user-environment sync for Windows and macOS (no-op elsewhere). */
2
2
  /**
3
- * Persist entries into the current user's OS environment when supported.
3
+ * Whether `name` already exists in the OS user environment (Windows HKCU or macOS user domain).
4
+ * @param name - Variable name.
5
+ * @returns true when present (value may be empty); false on unsupported platforms.
6
+ */
7
+ export declare function hasUserEnv(name: string): boolean;
8
+ /**
9
+ * Write entries into the current user's OS environment when supported.
4
10
  * @param entries - Variable map to write.
5
11
  */
6
- export declare function persistUserEnv(entries: Readonly<Record<string, string>>): void;
12
+ export declare function writeUserEnv(entries: Readonly<Record<string, string>>): void;
13
+ /**
14
+ * Remove many keys from the current user's OS environment when supported.
15
+ * @param names - Variable names to delete.
16
+ */
17
+ export declare function removeUserEnvs(names: readonly string[]): void;
7
18
  /**
8
19
  * Remove one key from the current user's OS environment when supported.
9
20
  * @param name - Variable name to delete.
10
21
  */
11
22
  export declare function removeUserEnv(name: string): void;
12
- export { persistWindowsUserEnv, removeWindowsUserEnv } from './windows.ts';
13
- export { persistMacosUserEnv, removeMacosUserEnv } from './macos.ts';
23
+ export { hasWindowsUserEnv, removeWindowsUserEnv, removeWindowsUserEnvs, writeWindowsUserEnv, } from './windows.ts';
24
+ export { hasMacosUserEnv, removeMacosUserEnv, removeMacosUserEnvs, writeMacosUserEnv, } from './macos.ts';
@@ -1,12 +1,26 @@
1
1
  /**
2
2
  * Persist user environment variables on macOS via launchctl and a Login LaunchAgent.
3
3
  */
4
+ /**
5
+ * Whether `name` is present in this process's macOS user-env tracking
6
+ * (`process.env` or the in-memory LaunchAgent cache).
7
+ * @param name - Variable name.
8
+ * @param platform - Override for tests; defaults to `process.platform`.
9
+ * @returns true when the name is already managed/visible.
10
+ */
11
+ export declare function hasMacosUserEnv(name: string, platform?: NodeJS.Platform): boolean;
4
12
  /**
5
13
  * Set user-domain environment variables for new GUI sessions and refresh the Login Agent.
6
14
  * @param entries - Variable map to persist.
7
15
  * @param platform - Override for tests; defaults to `process.platform`.
8
16
  */
9
- export declare function persistMacosUserEnv(entries: Readonly<Record<string, string>>, platform?: NodeJS.Platform): void;
17
+ export declare function writeMacosUserEnv(entries: Readonly<Record<string, string>>, platform?: NodeJS.Platform): void;
18
+ /**
19
+ * Unset many user-domain environment variables and refresh the Login Agent once.
20
+ * @param names - Variable names to remove.
21
+ * @param platform - Override for tests; defaults to `process.platform`.
22
+ */
23
+ export declare function removeMacosUserEnvs(names: readonly string[], platform?: NodeJS.Platform): void;
10
24
  /**
11
25
  * Unset one user-domain environment variable and refresh the Login Agent.
12
26
  * @param name - Variable name to remove.