kovence-cli 1.2.0 → 1.3.0

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.
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ const crypto = require("node:crypto");
4
+
3
5
  const AGENT_MODES = ["default", "accept-edits", "plan", "auto"];
4
6
  const TOOL_PERMISSIONS = ["ask", "allow-reads", "allow-edits", "always-proceed"];
5
7
  const NON_WORKSPACE_MODES = ["ask", "allow", "deny"];
@@ -8,14 +10,111 @@ const LANGUAGES = ["banglish", "bangla", "english"];
8
10
  const RENDERING_MODES = ["fullscreen", "inline"];
9
11
  const QUEUED_MESSAGE_MODES = ["queue", "interrupt"];
10
12
  const COLOR_SCHEMES = ["amber", "dark", "light", "terminal"];
13
+ const COMMAND_TIMEOUT_BEHAVIORS = ["background", "kill"];
14
+ const TOOLSET_MODES = ["core", "full"];
15
+ const REASONING_LEVELS = ["off", "low", "medium", "high"];
11
16
 
12
- const DEFAULT_SYSTEM_PROMPT = [
17
+ const LEGACY_V1_SYSTEM_PROMPT = [
13
18
  "You are Kovence CLI, an advanced multi-step CLI agent harness built by Kovence (https://kovence.com).",
14
19
  "Use tools proactively to inspect files, search code, edit cleanly, run tests/commands, download files/installers with download_file and install them with run_command, search online with web_search/google_search, fetch pages with web_fetch, and track multi-step plans with todo_write.",
15
20
  "When answering with online search results, synthesize the retrieved context cleanly and cite relevant sources.",
16
21
  "MEMORY RULE: Save persistent user preferences ONLY when explicitly requested via save_global_memory. Save temporary current-task notes using save_session_memory.",
17
22
  ].join("\n");
18
23
 
24
+ function hashPromptText(text) {
25
+ return crypto
26
+ .createHash("sha256")
27
+ .update(
28
+ String(text || "")
29
+ .replace(/\r\n/g, "\n")
30
+ .trim()
31
+ )
32
+ .digest("hex");
33
+ }
34
+
35
+ const LEGACY_DEFAULT_PROMPT_HASHES = new Set([hashPromptText(LEGACY_V1_SYSTEM_PROMPT)]);
36
+
37
+ const MEMORY_RULE_LINE =
38
+ "MEMORY RULE: Save persistent user preferences ONLY when explicitly requested via save_global_memory. Save temporary current-task notes using save_session_memory.";
39
+
40
+ const DEFAULT_SYSTEM_PROMPT = [
41
+ "You are Kovence CLI, a coding agent working inside the user's workspace. You help with software engineering tasks: understanding code, fixing bugs, adding features, refactoring, running and fixing tests.",
42
+ "",
43
+ "# Workflow",
44
+ "1. Understand the request. Ask ONE short question only if something essential is missing and cannot be found in the code.",
45
+ "2. Explore with read-only tools first (list_dir, glob_files, search_files, read_file). Never guess file contents or paths.",
46
+ "3. For work with 3 or more steps, write a plan with todo_write and keep it current: one item in progress, mark items done as soon as they finish.",
47
+ "4. Implement with small, targeted edits.",
48
+ "5. Verify: run the project's tests, lint, typecheck or build with run_command when they exist. Fix failures before you report completion.",
49
+ "6. Report.",
50
+ "",
51
+ "# Tool rules",
52
+ "- Always read a file with read_file before you edit it.",
53
+ "- Prefer edit_file / multi_edit for existing files. Use write_file only for new files or complete rewrites; write large files in parts.",
54
+ "- Use search_files / glob_files / list_dir instead of shell grep, find, cat or ls.",
55
+ "- When several tool calls are independent, issue them in the SAME message so they run in parallel.",
56
+ "- Do not repeat an identical tool call. Do not re-read a file that has not changed and is still in context.",
57
+ "- If an edit fails, read the error: it shows the closest match. Re-read that region and retry with exact text.",
58
+ "- For long-running commands use background:true and poll with command_output.",
59
+ "- Use web_search / web_fetch only when the task needs information that is not in the workspace.",
60
+ "",
61
+ "# Editing rules",
62
+ "- Follow the existing conventions (style, naming, structure, libraries). Look at neighbouring files first.",
63
+ "- Make the smallest change that solves the task. Do not refactor unrelated code. Do not create files unless needed.",
64
+ "",
65
+ "# Verification and honesty",
66
+ "- Never claim that something works without evidence from a command you ran. If tests fail or you could not run them, say so plainly.",
67
+ "",
68
+ "# Output",
69
+ "- Be concise and direct. No filler, no restating the request.",
70
+ "- Refer to code as path:line.",
71
+ "- Final answer: what changed and what you verified (commands and results). Mention anything left undone.",
72
+ "",
73
+ "# Safety",
74
+ "- Respect the permission system. In plan mode do not modify anything.",
75
+ "- Do not run destructive commands (rm -rf, force pushes, dropping data) without a clear need.",
76
+ "",
77
+ MEMORY_RULE_LINE,
78
+ ].join("\n");
79
+
80
+ const CURRENT_SETTINGS_VERSION = 2;
81
+ const CURRENT_PROMPT_VERSION = 2;
82
+
83
+ const DEFAULT_AGENTS_SETTINGS = {
84
+ maxParallel: 3,
85
+ parallelGeneral: false,
86
+ explore: { model: "", provider: "", maxSteps: 30 },
87
+ general: { model: "", provider: "", maxSteps: 30 },
88
+ };
89
+
90
+ function normalizeAgentRoleConfig(raw, fallbackMaxSteps = 30) {
91
+ const src = raw && typeof raw === "object" ? raw : {};
92
+ const maxRaw = Number.parseInt(String(src.maxSteps ?? ""), 10);
93
+ const maxSteps = Number.isSafeInteger(maxRaw) && maxRaw >= 1 && maxRaw <= 200 ? maxRaw : fallbackMaxSteps;
94
+ return {
95
+ model: typeof src.model === "string" ? src.model.trim() : "",
96
+ provider: typeof src.provider === "string" ? src.provider.trim() : "",
97
+ maxSteps,
98
+ };
99
+ }
100
+
101
+ function normalizeAgentsConfig(raw) {
102
+ const src = raw && typeof raw === "object" ? raw : {};
103
+ const maxPRaw = Number.parseInt(String(src.maxParallel ?? ""), 10);
104
+ const maxParallel =
105
+ Number.isSafeInteger(maxPRaw) && maxPRaw >= 1 && maxPRaw <= 10 ? maxPRaw : DEFAULT_AGENTS_SETTINGS.maxParallel;
106
+ const parallelGeneral =
107
+ typeof src.parallelGeneral === "boolean"
108
+ ? src.parallelGeneral
109
+ : /^(true|on|1|yes)$/i.test(String(src.parallelGeneral ?? "").trim());
110
+ return {
111
+ maxParallel,
112
+ parallelGeneral,
113
+ explore: normalizeAgentRoleConfig(src.explore, DEFAULT_AGENTS_SETTINGS.explore.maxSteps),
114
+ general: normalizeAgentRoleConfig(src.general, DEFAULT_AGENTS_SETTINGS.general.maxSteps),
115
+ };
116
+ }
117
+
19
118
  const DEFAULT_SETTINGS = {
20
119
  agentMode: "default",
21
120
  toolPermission: "ask",
@@ -23,10 +122,15 @@ const DEFAULT_SETTINGS = {
23
122
  model: "",
24
123
  provider: "",
25
124
  toolsEnabled: true,
26
- autoSummarize: true,
125
+ autoSummarize: false,
27
126
  maxToolSteps: 100,
28
- maxHistoryMessages: 24,
29
- contextWindow: 128000,
127
+ maxHistoryMessages: null,
128
+ contextWindow: null,
129
+ contextReserveTokens: null,
130
+ pruneThreshold: 0.75,
131
+ compactThreshold: 0.85,
132
+ pruneProtectTokens: 40000,
133
+ pruneMinSavings: 20000,
30
134
  temperature: null,
31
135
  maxTokens: null,
32
136
  verbosity: "normal",
@@ -37,6 +141,16 @@ const DEFAULT_SETTINGS = {
37
141
  showActiveTasks: true,
38
142
  notifications: true,
39
143
  colorScheme: "amber",
144
+ commandTimeoutMs: 120000,
145
+ commandTimeoutMaxMs: 600000,
146
+ commandTimeoutBehavior: "background",
147
+ toolset: "core",
148
+ checkAfterEdit: false,
149
+ checkCommand: "",
150
+ checkTimeoutMs: 30000,
151
+ checkMaxLines: 30,
152
+ reasoning: "off",
153
+ agents: normalizeAgentsConfig(DEFAULT_AGENTS_SETTINGS),
40
154
  systemPrompt: DEFAULT_SYSTEM_PROMPT,
41
155
  chatHistoryRetentionDays: 30,
42
156
  };
@@ -92,7 +206,8 @@ const SETTINGS_SCHEMA = [
92
206
  key: "autoSummarize",
93
207
  label: "Auto Summarize",
94
208
  type: "boolean",
95
- description: "'on': compact older turns in background when history grows large; 'off': manual /compact only.",
209
+ description:
210
+ "'on': update rolling session summary after each turn; 'off': manual /compact & auto-compaction only.",
96
211
  },
97
212
  {
98
213
  key: "maxToolSteps",
@@ -105,18 +220,58 @@ const SETTINGS_SCHEMA = [
105
220
  {
106
221
  key: "maxHistoryMessages",
107
222
  label: "Max History Messages",
108
- type: "integer",
223
+ type: "nullableInteger",
109
224
  min: 2,
110
225
  max: 500,
111
- description: "Target turn-aware message budget retained verbatim before pruning/summarizing (2-500).",
226
+ description: "Optional hard message-count cap (2-500), or 'null' for unlimited token-budget management.",
112
227
  },
113
228
  {
114
229
  key: "contextWindow",
115
230
  label: "Context Window",
116
- type: "integer",
231
+ type: "nullableInteger",
117
232
  min: 1024,
118
233
  max: 2000000,
119
- description: "Model context window size in tokens used for budget tracking and auto-compaction (>= 1024).",
234
+ description: "Model context window in tokens, or 'null' to auto-detect from model registry (32k if unknown).",
235
+ },
236
+ {
237
+ key: "contextReserveTokens",
238
+ label: "Context Reserve Tokens",
239
+ type: "nullableInteger",
240
+ min: 1024,
241
+ max: 500000,
242
+ description: "Output headroom reserved from context window, or 'null' for max(20000, maxOutputTokens).",
243
+ },
244
+ {
245
+ key: "pruneThreshold",
246
+ label: "Prune Threshold",
247
+ type: "nullableFloat",
248
+ min: 0.1,
249
+ max: 0.95,
250
+ description: "Fraction of usable context that triggers old tool-output pruning (default 0.75).",
251
+ },
252
+ {
253
+ key: "compactThreshold",
254
+ label: "Compact Threshold",
255
+ type: "nullableFloat",
256
+ min: 0.2,
257
+ max: 0.99,
258
+ description: "Fraction of usable context that triggers structured compaction after pruning (default 0.85).",
259
+ },
260
+ {
261
+ key: "pruneProtectTokens",
262
+ label: "Prune Protect Tokens",
263
+ type: "integer",
264
+ min: 1000,
265
+ max: 500000,
266
+ description: "Recent tool-output tokens protected from Zone B pruning (default 40000).",
267
+ },
268
+ {
269
+ key: "pruneMinSavings",
270
+ label: "Prune Min Savings",
271
+ type: "integer",
272
+ min: 500,
273
+ max: 500000,
274
+ description: "Minimum token savings required before Zone B pruning activates (default 20000).",
120
275
  },
121
276
  {
122
277
  key: "temperature",
@@ -189,6 +344,57 @@ const SETTINGS_SCHEMA = [
189
344
  options: COLOR_SCHEMES,
190
345
  description: "UI palette: 'amber' (Kovence orange/amber), 'dark', 'light', or 'terminal' (minimal ANSI).",
191
346
  },
347
+ {
348
+ key: "commandTimeoutMs",
349
+ label: "Command Timeout (ms)",
350
+ type: "integer",
351
+ min: 500,
352
+ max: 600000,
353
+ description: "Default run_command timeout in milliseconds (default 120000 = 120s).",
354
+ },
355
+ {
356
+ key: "commandTimeoutMaxMs",
357
+ label: "Max Command Timeout (ms)",
358
+ type: "integer",
359
+ min: 1000,
360
+ max: 3600000,
361
+ description: "Maximum allowed run_command timeout in milliseconds (default 600000 = 600s).",
362
+ },
363
+ {
364
+ key: "commandTimeoutBehavior",
365
+ label: "Command Timeout Behavior",
366
+ type: "enum",
367
+ options: COMMAND_TIMEOUT_BEHAVIORS,
368
+ description: "'background': promote timed-out command to a background task; 'kill': terminate process group.",
369
+ },
370
+ {
371
+ key: "toolset",
372
+ label: "Toolset",
373
+ type: "enum",
374
+ options: TOOLSET_MODES,
375
+ description:
376
+ "'core': focused coding tools (default); 'full': also includes download_file, memory, move_file, mkdir, delete_file, ask_user.",
377
+ },
378
+ {
379
+ key: "checkAfterEdit",
380
+ label: "Check After Edit",
381
+ type: "boolean",
382
+ description: "'on': run user-level checkCommand after successful file edits; 'off': skip post-edit checks.",
383
+ },
384
+ {
385
+ key: "checkCommand",
386
+ label: "Post-Edit Check Command",
387
+ type: "string",
388
+ description: "User-level shell command run after file edits (supports {file}; never read from repo files).",
389
+ },
390
+ {
391
+ key: "reasoning",
392
+ label: "Reasoning Effort",
393
+ type: "enum",
394
+ options: REASONING_LEVELS,
395
+ description:
396
+ "Extended reasoning/thinking budget ('off', 'low', 'medium', 'high') for Anthropic & reasoning models.",
397
+ },
192
398
  {
193
399
  key: "systemPrompt",
194
400
  label: "Edit System Prompt",
@@ -236,6 +442,15 @@ const KEY_ALIASES = {
236
442
  show_tips: "showTips",
237
443
  show_active_tasks: "showActiveTasks",
238
444
  color_scheme: "colorScheme",
445
+ command_timeout_ms: "commandTimeoutMs",
446
+ command_timeout_max_ms: "commandTimeoutMaxMs",
447
+ command_timeout_behavior: "commandTimeoutBehavior",
448
+ tool_set: "toolset",
449
+ check_after_edit: "checkAfterEdit",
450
+ check_command: "checkCommand",
451
+ check_timeout_ms: "checkTimeoutMs",
452
+ check_max_lines: "checkMaxLines",
453
+ reasoning_effort: "reasoning",
239
454
  system_prompt: "systemPrompt",
240
455
  chat_history_retention: "chatHistoryRetentionDays",
241
456
  chat_history_retention_days: "chatHistoryRetentionDays",
@@ -258,14 +473,70 @@ function canonicalSettingKey(rawKey) {
258
473
  return null;
259
474
  }
260
475
 
476
+ function parseAgentSubsetting(rawKey, rawValue) {
477
+ const clean = String(rawKey || "").trim();
478
+ const parts = clean.split(".");
479
+ if (parts[0] !== "agents" || parts.length < 2 || parts.length > 3) return null;
480
+
481
+ if (parts.length === 2 && parts[1] === "maxParallel") {
482
+ const str = String(rawValue ?? "").trim();
483
+ if (!/^\d+$/.test(str)) return { ok: false, error: "agents.maxParallel must be an integer (1-10)." };
484
+ const n = Number.parseInt(str, 10);
485
+ if (n < 1 || n > 10) return { ok: false, error: "agents.maxParallel must be between 1 and 10." };
486
+ return { ok: true, key: "agents", subPath: ["maxParallel"], value: n };
487
+ }
488
+ if (parts.length === 2 && parts[1] === "parallelGeneral") {
489
+ const str = String(rawValue ?? "").trim();
490
+ if (/^(true|on|1|yes)$/i.test(str)) {
491
+ return { ok: true, key: "agents", subPath: ["parallelGeneral"], value: true };
492
+ }
493
+ if (/^(false|off|0|no)$/i.test(str)) {
494
+ return { ok: true, key: "agents", subPath: ["parallelGeneral"], value: false };
495
+ }
496
+ return { ok: false, error: "agents.parallelGeneral expects on/off or true/false." };
497
+ }
498
+ if (parts.length === 3 && (parts[1] === "explore" || parts[1] === "general")) {
499
+ const role = parts[1];
500
+ const field = parts[2];
501
+ if (field === "model" || field === "provider") {
502
+ const val =
503
+ rawValue === null || /^(null|none|default|unset)$/i.test(String(rawValue ?? "").trim())
504
+ ? ""
505
+ : String(rawValue ?? "").trim();
506
+ return { ok: true, key: "agents", subPath: [role, field], value: val };
507
+ }
508
+ if (field === "maxSteps") {
509
+ const str = String(rawValue ?? "").trim();
510
+ if (!/^\d+$/.test(str)) return { ok: false, error: `agents.${role}.maxSteps must be an integer (1-200).` };
511
+ const n = Number.parseInt(str, 10);
512
+ if (n < 1 || n > 200) return { ok: false, error: `agents.${role}.maxSteps must be between 1 and 200.` };
513
+ return { ok: true, key: "agents", subPath: [role, "maxSteps"], value: n };
514
+ }
515
+ }
516
+ return { ok: false, error: `Unknown agent setting '${clean}'.` };
517
+ }
518
+
261
519
  /**
262
520
  * Parse and strictly validate a raw input value for a setting key.
263
521
  */
264
522
  function parseSettingValue(rawKey, rawValue) {
523
+ if (
524
+ String(rawKey || "")
525
+ .trim()
526
+ .startsWith("agents.")
527
+ ) {
528
+ return parseAgentSubsetting(rawKey, rawValue);
529
+ }
265
530
  const key = canonicalSettingKey(rawKey);
266
531
  if (!key) {
267
532
  return { ok: false, error: `Unknown setting '${rawKey}'.` };
268
533
  }
534
+ if (key === "agents") {
535
+ if (!rawValue || typeof rawValue !== "object" || Array.isArray(rawValue)) {
536
+ return { ok: false, error: "agents must be a configuration object." };
537
+ }
538
+ return { ok: true, key: "agents", value: normalizeAgentsConfig(rawValue) };
539
+ }
269
540
  const meta = SCHEMA_BY_KEY.get(key);
270
541
  if (!meta || meta.type === "action") {
271
542
  return { ok: false, error: `'${key}' cannot be set directly.` };
@@ -331,6 +602,13 @@ function parseSettingValue(rawKey, rawValue) {
331
602
  return { ok: true, key, value: n };
332
603
  }
333
604
 
605
+ if (meta.type === "multilineString") {
606
+ if (rawValue === null || /^(null|default|reset)$/i.test(str)) {
607
+ return { ok: true, key, value: DEFAULT_SYSTEM_PROMPT };
608
+ }
609
+ return { ok: true, key, value: typeof rawValue === "string" ? rawValue : str };
610
+ }
611
+
334
612
  return { ok: true, key, value: typeof rawValue === "string" ? rawValue : str };
335
613
  }
336
614
 
@@ -343,8 +621,19 @@ module.exports = {
343
621
  RENDERING_MODES,
344
622
  QUEUED_MESSAGE_MODES,
345
623
  COLOR_SCHEMES,
624
+ COMMAND_TIMEOUT_BEHAVIORS,
625
+ TOOLSET_MODES,
626
+ REASONING_LEVELS,
627
+ LEGACY_V1_SYSTEM_PROMPT,
628
+ LEGACY_DEFAULT_PROMPT_HASHES,
629
+ MEMORY_RULE_LINE,
346
630
  DEFAULT_SYSTEM_PROMPT,
631
+ CURRENT_SETTINGS_VERSION,
632
+ CURRENT_PROMPT_VERSION,
633
+ DEFAULT_AGENTS_SETTINGS,
347
634
  DEFAULT_SETTINGS,
635
+ normalizeAgentsConfig,
636
+ hashPromptText,
348
637
  SETTINGS_SCHEMA,
349
638
  SCHEMA_BY_KEY,
350
639
  PERSISTABLE_KEYS,
@@ -1,15 +1,39 @@
1
1
  "use strict";
2
2
 
3
3
  const { ensureStorageDirs, readJsonSafe, atomicWriteJson, resolvePaths } = require("../config/paths");
4
- const { DEFAULT_SETTINGS, PERSISTABLE_KEYS, SCHEMA_BY_KEY, parseSettingValue } = require("./schema");
4
+ const {
5
+ CURRENT_SETTINGS_VERSION,
6
+ CURRENT_PROMPT_VERSION,
7
+ DEFAULT_SETTINGS,
8
+ DEFAULT_SYSTEM_PROMPT,
9
+ LEGACY_DEFAULT_PROMPT_HASHES,
10
+ PERSISTABLE_KEYS,
11
+ SCHEMA_BY_KEY,
12
+ normalizeAgentsConfig,
13
+ hashPromptText,
14
+ parseSettingValue,
15
+ } = require("./schema");
16
+
17
+ function isCustomSystemPrompt(settings) {
18
+ const cur = String(settings?.systemPrompt || "").trim();
19
+ if (!cur) return false;
20
+ return hashPromptText(cur) !== hashPromptText(DEFAULT_SYSTEM_PROMPT);
21
+ }
5
22
 
6
23
  /**
7
24
  * Normalize loaded settings object against schema defaults without introducing runtime-only keys.
8
25
  */
9
26
  function sanitizePersistedObject(raw) {
10
- const out = { ...DEFAULT_SETTINGS };
27
+ const out = {
28
+ ...DEFAULT_SETTINGS,
29
+ agents: normalizeAgentsConfig(DEFAULT_SETTINGS.agents),
30
+ settingsVersion: CURRENT_SETTINGS_VERSION,
31
+ promptVersion: CURRENT_PROMPT_VERSION,
32
+ };
11
33
  if (!raw || typeof raw !== "object") return out;
12
34
 
35
+ const storedVersion = Number(raw.settingsVersion) || 1;
36
+
13
37
  // Legacy compatibility: read old autoApprove=true only when agentMode was not explicitly stored.
14
38
  if (raw.autoApprove === true && raw.agentMode === undefined) {
15
39
  out.agentMode = "auto";
@@ -17,6 +41,34 @@ function sanitizePersistedObject(raw) {
17
41
 
18
42
  for (const key of PERSISTABLE_KEYS) {
19
43
  if (raw[key] === undefined) continue;
44
+ // Migrate v1 shipped defaults that would otherwise lock users into message-count truncation.
45
+ if (storedVersion < 2) {
46
+ if (key === "maxHistoryMessages" && Number(raw[key]) === 24) {
47
+ out[key] = null;
48
+ continue;
49
+ }
50
+ if (key === "contextWindow" && Number(raw[key]) === 128000) {
51
+ out[key] = null;
52
+ continue;
53
+ }
54
+ }
55
+ if (key === "systemPrompt") {
56
+ if (raw[key] === null || String(raw[key]).trim() === "") {
57
+ out.systemPrompt = DEFAULT_SYSTEM_PROMPT;
58
+ continue;
59
+ }
60
+ const h = hashPromptText(raw[key]);
61
+ if (LEGACY_DEFAULT_PROMPT_HASHES.has(h)) {
62
+ out.systemPrompt = DEFAULT_SYSTEM_PROMPT;
63
+ continue;
64
+ }
65
+ out.systemPrompt = String(raw[key]);
66
+ continue;
67
+ }
68
+ if (key === "agents") {
69
+ out.agents = normalizeAgentsConfig(raw[key]);
70
+ continue;
71
+ }
20
72
  const parsed = parseSettingValue(key, raw[key]);
21
73
  if (parsed.ok) {
22
74
  out[key] = parsed.value;
@@ -38,9 +90,15 @@ function loadPersistedSettings(paths = resolvePaths()) {
38
90
  */
39
91
  function savePersistedSettings(settings, paths = resolvePaths()) {
40
92
  ensureStorageDirs(paths);
41
- const clean = sanitizePersistedObject(settings);
93
+ const clean = sanitizePersistedObject({
94
+ ...(settings && typeof settings === "object" ? settings : {}),
95
+ settingsVersion: settings?.settingsVersion ?? CURRENT_SETTINGS_VERSION,
96
+ });
42
97
  // Explicitly strip legacy autoApprove from disk whenever settings are written.
43
- const toWrite = {};
98
+ const toWrite = {
99
+ settingsVersion: CURRENT_SETTINGS_VERSION,
100
+ promptVersion: CURRENT_PROMPT_VERSION,
101
+ };
44
102
  for (const key of PERSISTABLE_KEYS) {
45
103
  toWrite[key] = clean[key];
46
104
  }
@@ -55,7 +113,17 @@ function updatePersistedSetting(key, rawValue, paths = resolvePaths()) {
55
113
  const parsed = parseSettingValue(key, rawValue);
56
114
  if (!parsed.ok) return parsed;
57
115
  const currentPersisted = loadPersistedSettings(paths);
58
- currentPersisted[parsed.key] = parsed.value;
116
+ if (Array.isArray(parsed.subPath) && parsed.key === "agents") {
117
+ const nextAgents = normalizeAgentsConfig(currentPersisted.agents);
118
+ if (parsed.subPath.length === 1) {
119
+ nextAgents[parsed.subPath[0]] = parsed.value;
120
+ } else if (parsed.subPath.length === 2) {
121
+ nextAgents[parsed.subPath[0]][parsed.subPath[1]] = parsed.value;
122
+ }
123
+ currentPersisted.agents = nextAgents;
124
+ } else {
125
+ currentPersisted[parsed.key] = parsed.value;
126
+ }
59
127
  const saved = savePersistedSettings(currentPersisted, paths);
60
128
  return {
61
129
  ok: true,
@@ -85,7 +153,7 @@ function stepSettingValue(key, currentValue, direction = 1) {
85
153
  */
86
154
  function resolveEffectiveSettings(persisted, runtimeOverrides = {}) {
87
155
  const base = sanitizePersistedObject(persisted);
88
- const effective = { ...base };
156
+ const effective = { ...base, agents: normalizeAgentsConfig(base.agents) };
89
157
 
90
158
  if (runtimeOverrides.cliAuto === true) {
91
159
  effective.agentMode = "auto";
@@ -126,6 +194,7 @@ function resolveEffectiveModel({
126
194
  }
127
195
 
128
196
  module.exports = {
197
+ isCustomSystemPrompt,
129
198
  sanitizePersistedObject,
130
199
  loadPersistedSettings,
131
200
  savePersistedSettings,