thincoder 0.12.74 → 0.12.76

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +8 -0
  3. package/bin/thincoder.mjs +1 -0
  4. package/package.json +2 -2
  5. package/src/acp/bridge.mjs +14 -5
  6. package/src/acp/handlers-session.mjs +1 -1
  7. package/src/acp/handlers-slots.mjs +6 -4
  8. package/src/acp/read-data.mjs +23 -4
  9. package/src/acp/session.mjs +5 -4
  10. package/src/acp.mjs +7 -2
  11. package/src/cli/make-agent.mjs +1 -1
  12. package/src/cli/team-command.mjs +41 -8
  13. package/src/command-interactive.mjs +3 -2
  14. package/src/completions.mjs +4 -4
  15. package/src/prompt-injections.mjs +1 -1
  16. package/src/tui/agent-turn.mjs +5 -4
  17. package/src/tui/ask-steps.mjs +8 -0
  18. package/src/tui/cmd-advisor.mjs +3 -3
  19. package/src/tui/cmd-config-menus.mjs +245 -0
  20. package/src/tui/cmd-config.mjs +67 -249
  21. package/src/tui/cmd-eng.mjs +7 -5
  22. package/src/tui/cmd-session.mjs +7 -5
  23. package/src/tui/cmd-team.mjs +41 -9
  24. package/src/tui/cmd-think.mjs +3 -3
  25. package/src/tui/cmd-timers.mjs +9 -5
  26. package/src/tui/config-helpers.mjs +54 -4
  27. package/src/tui/index.mjs +3 -2
  28. package/src/tui/interaction.mjs +13 -1
  29. package/src/tui/key-handler-modals.mjs +16 -1
  30. package/src/tui/key-handler-search.mjs +11 -1
  31. package/src/tui/key-handler.mjs +10 -1
  32. package/src/tui/layout.mjs +14 -6
  33. package/src/tui/lifecycle-records.mjs +9 -3
  34. package/src/tui/model-picker.mjs +4 -4
  35. package/src/tui/pickers.mjs +1 -1
  36. package/src/tui/provider-admin.mjs +5 -5
  37. package/src/tui/queued-pickup.mjs +1 -1
  38. package/src/tui/render-frame.mjs +17 -183
  39. package/src/tui/render-segments.mjs +19 -8
  40. package/src/tui/secret-prompt.mjs +209 -0
  41. package/src/tui/slash-commands.mjs +4 -2
  42. package/src/tui/status-line.mjs +197 -0
  43. package/src/tui/subagent-freeze.mjs +16 -10
  44. package/src/tui/suspension-drive.mjs +2 -2
  45. package/src/tui/timer-watch.mjs +1 -1
  46. package/src/tui/tool-events.mjs +19 -11
  47. package/src/tui/tui-state.mjs +1 -0
  48. package/src/tui/turn-face.mjs +6 -4
@@ -0,0 +1,245 @@
1
+ /**
2
+ * cmd-config-menus.mjs — the four `/config` sub-menus: proxy ∥ consult/escalate pool ∥ async
3
+ * pools ∥ default model. Split out of cmd-config.mjs (CONTEXT-COMPACTION.md §6.16.9 — C2):
4
+ * the entry file keeps the command spine (embedding key / save + reload / main menu / numeric
5
+ * items), this file only renders sub-menus.
6
+ *
7
+ * Factory form (design-pinned): `create<Name>Menu(ctx)` with
8
+ * ctx = { agent, DEFAULTS, showPicker, askQuestion, pushLine, pushLabel, saveProxy, pickModelForSlot }
9
+ * cmd-config.mjs builds `saveProxy` first, then constructs the four menus once and reuses them —
10
+ * behaviour is unchanged (same entries, same wording, same save path).
11
+ */
12
+
13
+ import { ansi, C } from "./ansi.mjs"
14
+ import { probeChannelModels, dedupeModels } from "./model-catalog.mjs"
15
+ // 派生条目隐藏判据单源(TEAM.md §2.4——#1223:/config 渠道读面过滤)
16
+ import { isDerivedProviderHidden } from "./provider-admin.mjs"
17
+ import { probeTargetOf } from "@thincoder/core/provider-flows.mjs"
18
+ import { effortMenuLevels, poolCur } from "./config-helpers.mjs"
19
+
20
+ /** ── 代理子菜单:URI ∥ Web 工具开关 ∥ 连通性自测 ∥ 清除。
21
+ * 每轮重建 entries 显示最新状态,defaultIndex 记住上次位置。 */
22
+ export function createProxyMenu(ctx) {
23
+ const { agent, showPicker, askQuestion, pushLine, pushLabel, saveProxy } = ctx
24
+ return async function proxyMenu() {
25
+ let proxyIdx = 0
26
+ for (;;) {
27
+ const pc = agent.config?.proxy // 已归一化 { uri, web } | undefined
28
+ const entries = [
29
+ { type: "header", text: `Proxy: ${pc?.uri || "(not set)"}` },
30
+ { type: "item", text: "Set proxy URI…", action: "seturi" },
31
+ { type: "item", text: `Web tools (fetch/websearch): ${!pc || pc.web ? "ON" : "OFF"}`, action: "toggleweb" },
32
+ { type: "item", text: "Test connection", action: "test" },
33
+ { type: "item", text: "Clear proxy", action: "clear" },
34
+ ]
35
+ const c = await showPicker("Proxy", entries, { defaultIndex: proxyIdx })
36
+ if (!c) return // Esc 返回主菜单
37
+ proxyIdx = Math.max(0, entries.filter((e) => e.type === "item").indexOf(c))
38
+
39
+ try {
40
+ if (c.action === "seturi") {
41
+ const newUri = await askQuestion("Proxy URI (e.g. http://127.0.0.1:7890):")
42
+ if (!newUri) continue // 空输入不改动
43
+ // 写即归一:两键重建 `{ uri, web }`——旧 string 形态 ∥ 盘上退役残键(如 `model`)读后即清;
44
+ // `web` 不显式 OFF 即 true(沿现值显示口径 `!pc || pc.web`——改 URI 不动 web 开合)。
45
+ await saveProxy((raw) => {
46
+ raw.proxy = { uri: newUri, web: !pc || pc.web !== false }
47
+ })
48
+ pushLabel("❯ Config", ansi.bold + C.tool)
49
+ pushLine(`proxy.uri = ${newUri}`, C.tool)
50
+ } else if (c.action === "toggleweb") {
51
+ if (!pc) { pushLine("Proxy URI not set — use Set proxy URI… first", C.error); continue }
52
+ await saveProxy((raw) => { raw.proxy = { ...pc, web: !pc.web } })
53
+ pushLabel("❯ Config", ansi.bold + C.tool)
54
+ pushLine(`proxy.web = ${!pc.web ? "on" : "off"}`, C.tool)
55
+ } else if (c.action === "test") {
56
+ const { proxyFetch, resolveWebProxy } = await import("@thincoder/core/proxy.mjs")
57
+ const { UA } = await import("@thincoder/core/tools/web.mjs")
58
+ const uri = resolveWebProxy({ agent })
59
+ pushLabel("❯ Config", ansi.bold + C.tool)
60
+ pushLine(`Testing ${uri ? `via proxy ${uri}` : "direct (no proxy)"}...`, C.dim)
61
+ try {
62
+ const res = await Promise.race([
63
+ proxyFetch("https://www.gstatic.com/generate_204", { headers: { "User-Agent": UA } }, uri),
64
+ new Promise((_, reject) => setTimeout(() => reject(new Error("timeout after 5s")), 5000)),
65
+ ])
66
+ if (res.ok) pushLine(`✓ OK (HTTP ${res.status})`, C.tool)
67
+ else pushLine(`✗ HTTP ${res.status}`, C.error)
68
+ } catch (error) {
69
+ pushLine(`✗ ${error.message}`, C.error)
70
+ }
71
+ } else if (c.action === "clear") {
72
+ await saveProxy((raw) => { delete raw.proxy })
73
+ pushLabel("❯ Config", ansi.bold + C.tool)
74
+ pushLine("Proxy cleared", C.tool)
75
+ }
76
+ } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
77
+ }
78
+ }
79
+ }
80
+
81
+ /** Reasoning-effort 取档(会诊条目用):显示该模型真实枚举——枚举跨渠道异构(deepseek:
82
+ * low/high/max;qwen3.8-max: xhigh/medium/low;kimi: 7 级),固定 min/low/medium/high/max
83
+ * 会让用户选出运行期静默丢弃的档(2026-08-17 审计)。 */
84
+ async function pickEffort(ctx, current, model) {
85
+ const { showPicker } = ctx
86
+ const { specForModel } = await import("@thincoder/core/config.mjs")
87
+ const enumList = model ? specForModel(model).reasoningEffortEnum : null
88
+ if (!enumList || enumList.length === 0) return null // model has no effort — skip
89
+ const levels = effortMenuLevels(enumList) // "none" = clear the effort(自带去重——#16)
90
+ const entries = levels.map((l) => ({ type: "item", text: l === current ? `${l} ← current` : l, action: l }))
91
+ const c = await showPicker("Reasoning effort", entries, { defaultIndex: Math.max(0, levels.indexOf(current ?? "none")) })
92
+ return c ? c.action : null // Esc → null (keep unchanged)
93
+ }
94
+
95
+ /** ── 会诊/飞刀候选池子菜单:列出 / 添加 / 编辑 effort / 删除 consultModels 条目。 */
96
+ export function createConsultMenu(ctx) {
97
+ const { agent, showPicker, pushLine, pushLabel, saveProxy, pickModelForSlot } = ctx
98
+ return async function consultMenu() {
99
+ let idx = 0
100
+ for (;;) {
101
+ const cm = agent.config?.agent?.consultModels ?? []
102
+ const entries = [
103
+ { type: "header", text: `Consult/escalate pool: ${cm.length} model(s) (max 5)` },
104
+ ...cm.map((m, i) => ({ type: "item", text: `${m.provider}:${m.model}${m.effort ? ` (${m.effort})` : ""}`, action: "edit", index: i })),
105
+ { type: "item", text: cm.length ? "+ Add model" : "+ Add model (none yet)", action: "add" },
106
+ ]
107
+ const c = await showPicker("Consult models", entries, { defaultIndex: idx })
108
+ if (!c) return // Esc → 返回主菜单
109
+ if (c.action === "add") {
110
+ if (cm.length >= 5) { pushLine("At most 5 consult models", C.error); continue }
111
+ // BOTH provider and model are pickers (discipline: options, never free-text) —
112
+ // pickModelForSlot reuses /model's provider list + async-fetched model list.
113
+ const picked = await pickModelForSlot()
114
+ if (!picked) continue
115
+ const effort = await pickEffort(ctx, null, picked.model)
116
+ const entry = { provider: picked.provider, model: picked.model }
117
+ if (effort && effort !== "none") entry.effort = effort
118
+ const next = [...cm, entry]
119
+ await saveProxy((raw) => { raw.agent ??= {}; raw.agent.consultModels = next })
120
+ pushLabel("❯ Config", ansi.bold + C.tool)
121
+ pushLine(`Added ${entry.provider}:${entry.model}${entry.effort ? ` (${entry.effort})` : ""}`, C.tool)
122
+ idx = 0
123
+ } else if (c.action === "edit") {
124
+ // Per-model sub-menu: change effort or remove.
125
+ const m = cm[c.index]
126
+ const tag = `${m.provider}:${m.model}`
127
+ const subEntries = [
128
+ { type: "header", text: `${tag} — effort: ${m.effort ?? "(none)"}` },
129
+ { type: "item", text: `Change effort (current: ${m.effort ?? "none"})`, action: "effort" },
130
+ { type: "item", text: "Remove", action: "remove" },
131
+ ]
132
+ const s = await showPicker(tag, subEntries, {})
133
+ if (!s) continue
134
+ if (s.action === "remove") {
135
+ const next = cm.filter((_, i) => i !== c.index)
136
+ await saveProxy((raw) => { raw.agent ??= {}; raw.agent.consultModels = next })
137
+ pushLabel("❯ Config", ansi.bold + C.tool)
138
+ pushLine(`Removed ${tag}`, C.tool)
139
+ } else if (s.action === "effort") {
140
+ const effort = await pickEffort(ctx, m.effort, m.model)
141
+ if (effort === null) { continue } // Esc 保持
142
+ const next = cm.map((x, i) => {
143
+ if (i !== c.index) return x
144
+ if (effort === "none") { const { effort, ...rest } = x; return rest }
145
+ return { ...x, effort }
146
+ })
147
+ await saveProxy((raw) => { raw.agent ??= {}; raw.agent.consultModels = next })
148
+ pushLabel("❯ Config", ansi.bold + C.tool)
149
+ const after = next[c.index]
150
+ pushLine(`${tag} effort = ${after?.effort ?? "none"}`, C.tool)
151
+ }
152
+ idx = 0
153
+ }
154
+ }
155
+ }
156
+ }
157
+
158
+ /** ── 并发池子菜单(agent.poolLimits——读/改三域;保存经 saveProxy
159
+ * 落盘 + reloadConfig 热应用——下个 spawn 生效)── */
160
+ export function createPoolMenu(ctx) {
161
+ const { agent, DEFAULTS, showPicker, askQuestion, pushLine, pushLabel, saveProxy } = ctx
162
+ return async function poolMenu() {
163
+ let poolIdx = 0
164
+ for (;;) {
165
+ const pl = agent.config?.agent?.poolLimits ?? {}
166
+ // 显示回退与默认同源(DEFAULTS.agent.poolLimits——配置 DEFAULTS 与运行时回退常量
167
+ // ASYNC_POOL_LIMITS/ADVISOR_POOL_LIMIT 的耦合由 T-24a4 锚定断言锁住——防默认值单侧漂移)
168
+ const cur = poolCur(pl, DEFAULTS)
169
+ const entries = [
170
+ { type: "header", text: `Async pools: eng-coder ${cur("engCoder")} / other ${cur("other")} / advisor ${cur("advisor")}(默认 4/4/4——分域互不阻塞——subagent 超限排队/advisor 超限即拒)` },
171
+ { type: "item", text: `eng-coder 池上限 = ${cur("engCoder")}`, action: "engCoder" },
172
+ { type: "item", text: `其他角色池上限 = ${cur("other")}`, action: "other" },
173
+ { type: "item", text: `advisor 评审池上限 = ${cur("advisor")}`, action: "advisor" },
174
+ ]
175
+ const c = await showPicker("并发池(agent.poolLimits)", entries, { defaultIndex: poolIdx })
176
+ if (!c) return // Esc 返回主菜单
177
+ poolIdx = Math.max(0, entries.filter((e) => e.type === "item").indexOf(c))
178
+ const val = await askQuestion(`${c.action} pool limit (current: ${cur(c.action)} — positive integer ≥1):`)
179
+ if (!val) continue // 空输入不改动
180
+ const num = Number(val)
181
+ if (!Number.isInteger(num) || num < 1) { pushLine("Pool limit must be a positive integer (≥1)", C.error); continue }
182
+ // 写盘全对象(三键——未触碰的键带当前值重写——全非法/空输入不改动)
183
+ const next = { engCoder: cur("engCoder"), other: cur("other"), advisor: cur("advisor"), [c.action]: num }
184
+ try {
185
+ await saveProxy((raw) => { raw.agent ??= {}; raw.agent.poolLimits = { engCoder: next.engCoder, other: next.other, advisor: next.advisor } })
186
+ pushLabel("❯ Config", ansi.bold + C.tool)
187
+ pushLine(`agent.poolLimits = { engCoder: ${next.engCoder}, other: ${next.other}, advisor: ${next.advisor} }(下个 spawn 生效——分域互不阻塞)`, C.tool)
188
+ } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
189
+ }
190
+ }
191
+ }
192
+
193
+ /** ── 默认模型子菜单(F-5:config.defaultModel 专用入口——L1 provider → L2 **运行期拉取**候选 →
194
+ * 写 config.defaultModel——saveProxy/writeConfigAtomic 通道——不落会话槽;不加手输行——O1 已裁)── */
195
+ export function createDefaultModelMenu(ctx) {
196
+ const { agent, showPicker, pushLine, pushLabel, saveProxy } = ctx
197
+ return async function defaultModelMenu() {
198
+ let idx = 0
199
+ // M9 配置阶段准入:进本子菜单探一次各渠道 `/models`(复用 M1 + 会话缓存)。
200
+ // 探通 → 渠道可用 + 候选直接可用;探不通 → 不缓存不阻断(标「不可用」且不入可选来源)。
201
+ // #1223(TEAM.md §2.4 六消费面):派生无 key 条目隐藏——探针 ∥ 条目录入两面同过滤。
202
+ const probes = new Map()
203
+ pushLine("Fetching channel model lists (GET /models)…", C.dim)
204
+ await Promise.all(agent.providers.filter((p) => !isDerivedProviderHidden(p)).map(async (p) => {
205
+ const r = await probeChannelModels(probeTargetOf(p)) // 探针目标构造收敛核判据(③′——逐渠旗 ∧ `uri` 在案;执行体零改)
206
+ probes.set(p.name, r)
207
+ if (r.ok) delete p._unavailable
208
+ else p._unavailable = true
209
+ }))
210
+ for (;;) {
211
+ const dm = agent.config?.defaultModel ?? null
212
+ const entries = [
213
+ { type: "header", text: `config.defaultModel = ${dm ?? "(not set — 新会话起点未配置)"}` },
214
+ ...agent.providers.filter((p) => !isDerivedProviderHidden(p)).map((p) => {
215
+ const r = probes.get(p.name)
216
+ if (!r?.ok) return { type: "item", text: `${p.name.padEnd(10)} 不可用`, action: "provider", provider: p.name, unavailable: true }
217
+ const n = r.list.length
218
+ // M3③:渠道行显示回退 = `baseURL`(渠道条目不携模型——2026-10-09 清除批)+ 探得候选数
219
+ return { type: "item", text: `${p.name.padEnd(10)} ${p.baseURL} (${n} model${n === 1 ? "" : "s"})`, action: "provider", provider: p.name }
220
+ }),
221
+ ]
222
+ const c = await showPicker("Default Model (新会话起点)", entries, { defaultIndex: idx })
223
+ if (!c) return // Esc → 返回主菜单
224
+ idx = Math.max(0, entries.filter((e) => e.type === "item").indexOf(c))
225
+ if (c.action !== "provider") continue
226
+ const r = probes.get(c.provider)
227
+ if (!r?.ok) {
228
+ // 准入判据:探不通的渠道不作为默认模型的可选来源——明示原因(M8 长句),不阻断菜单
229
+ pushLine(r?.message ?? `${c.provider} 不可用`, C.error)
230
+ continue
231
+ }
232
+ if (r.list.length === 0) { pushLine(`${c.provider}: /models 未返回任何模型`, C.error); continue }
233
+ const me = await showPicker(`${c.provider} models`, [
234
+ { type: "header", text: "选为 config.defaultModel(新会话起点——当前会话槽不受影响)" },
235
+ ...dedupeModels(r.list).map((m) => ({ type: "item", text: m, action: "model", model: m })),
236
+ ])
237
+ if (!me) continue // Esc → 回默认模型菜单
238
+ try {
239
+ await saveProxy((raw) => { raw.defaultModel = `${c.provider}:${me.model}` })
240
+ pushLabel("❯ Config", ansi.bold + C.tool)
241
+ pushLine(`config.defaultModel = ${c.provider}:${me.model}(新会话起点;会话模型不受影响)`, C.tool)
242
+ } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
243
+ }
244
+ }
245
+ }
@@ -1,33 +1,7 @@
1
1
  import { ansi, C } from "./ansi.mjs"
2
- import { probeChannelModels, dedupeModels } from "./model-catalog.mjs"
3
- import { probeTargetOf } from "@thincoder/core/provider-flows.mjs"
4
- /** Merge an embedding-key save into the raw config, backfilling baseURL/model from defaults.
5
- * Keeps existing custom values (Ollama/local embedding); defaults are the single source
6
- * (TUI.md §9.3D — NF1). Exported for unit tests. */
7
- export function embeddingPatch(raw, embKey, defaults) {
8
- const prev = raw?.embedding ?? {}
9
- return {
10
- ...prev,
11
- apiKey: embKey,
12
- baseURL: prev.baseURL ?? defaults.baseURL,
13
- model: prev.model ?? defaults.model,
14
- }
15
- }
16
-
17
- /** 并发池三键当前值读取(POOL-CONFIG-UNIFIED F-3——2026-09-09):配置值合法(≥1 整数)
18
- * 读配置——非法/缺省回退 DEFAULTS(agent.poolLimits 三键——/config 并发池子菜单/
19
- * 主菜单/view 三面共用同一读取——config-pool.test.mjs 单元测试)。 */
20
- export function poolCur(pl, defaults) {
21
- return (k) => (Number.isInteger(pl?.[k]) && pl[k] >= 1 ? pl[k] : defaults.agent.poolLimits[k])
22
- }
23
-
24
- /** Effort 菜单档位构造(#16 双 `none` 去重——枚举自带 `none` 的族如 qwen3.8-flash 时原来出两行):
25
- * `none` 恒为首项且唯一,其余档序保持(`filter` 保序)。语义面零改——`none` = 清档,
26
- * 消费点 `:205`/`:232` 只认 `=== "none"`;空枚举在 `pickEffort` 处已早退 null、不经本函数。
27
- * Exported for unit tests (`cmd-config-effort.test.mjs`). */
28
- export function effortMenuLevels(enumList) {
29
- return ["none", ...(enumList ?? []).filter((l) => l !== "none")]
30
- }
2
+ import { embeddingPatch, poolCur, compactThresholdSuffix, compactThresholdHint } from "./config-helpers.mjs"
3
+ // 四子菜单(代理 ∥ 会诊池 ∥ 并发池 ∥ 默认模型)已迁 `cmd-config-menus.mjs`(§6.16.9 —— C2)
4
+ import { createProxyMenu, createConsultMenu, createPoolMenu, createDefaultModelMenu } from "./cmd-config-menus.mjs"
31
5
 
32
6
  /** /config command: view and set agent/embedding/proxy config. */
33
7
  export async function handleConfigCommand(ctx, args = []) {
@@ -92,9 +66,11 @@ export async function handleConfigCommand(ctx, args = []) {
92
66
  }
93
67
  // 运行时重建后同步注入结果(cfg.provider 系 loadConfig 内建——injectProxy 后建)
94
68
  agent.provider.proxyUri = cfg.providersList.find((p) => p.name === agent.activeProvider)?.proxyUri
69
+ // §6.17:auto 派生值永不回写 agent.compactThreshold——只刷新显示面 compactThresholdResolved
70
+ // (每 run 的判定阈值由 setup.mjs 现算,本处只管 /config 显示面与显式键隔离)
95
71
  if (agent.config?.agent?.compactThresholdAuto) {
96
72
  const { resolveCompactThreshold } = await import("@thincoder/core/config.mjs")
97
- agent.config.agent.compactThreshold = resolveCompactThreshold(null, agent.provider).value
73
+ agent.config.agent.compactThresholdResolved = resolveCompactThreshold(null, agent.provider).value
98
74
  }
99
75
  }
100
76
 
@@ -111,62 +87,13 @@ export async function handleConfigCommand(ctx, args = []) {
111
87
  if (failure) throw failure
112
88
  }
113
89
 
114
- // ── Proxy sub-menu loop:每轮重建 entries 显示最新状态,defaultIndex 记住上次位置 ──
115
- async function proxyMenu() {
116
- let proxyIdx = 0
117
- for (;;) {
118
- const pc = agent.config?.proxy // 已归一化 { uri, web } | undefined
119
- const entries = [
120
- { type: "header", text: `Proxy: ${pc?.uri || "(not set)"}` },
121
- { type: "item", text: "Set proxy URI…", action: "seturi" },
122
- { type: "item", text: `Web tools (fetch/websearch): ${!pc || pc.web ? "ON" : "OFF"}`, action: "toggleweb" },
123
- { type: "item", text: "Test connection", action: "test" },
124
- { type: "item", text: "Clear proxy", action: "clear" },
125
- ]
126
- const c = await showPicker("Proxy", entries, { defaultIndex: proxyIdx })
127
- if (!c) return // Esc 返回主菜单
128
- proxyIdx = Math.max(0, entries.filter((e) => e.type === "item").indexOf(c))
129
-
130
- try {
131
- if (c.action === "seturi") {
132
- const newUri = await askQuestion("Proxy URI (e.g. http://127.0.0.1:7890):")
133
- if (!newUri) continue // 空输入不改动
134
- // 写即归一:两键重建 `{ uri, web }`——旧 string 形态 ∥ 盘上退役残键(如 `model`)读后即清;
135
- // `web` 不显式 OFF 即 true(沿现值显示口径 `!pc || pc.web`——改 URI 不动 web 开合)。
136
- await saveProxy((raw) => {
137
- raw.proxy = { uri: newUri, web: !pc || pc.web !== false }
138
- })
139
- pushLabel("❯ Config", ansi.bold + C.tool)
140
- pushLine(`proxy.uri = ${newUri}`, C.tool)
141
- } else if (c.action === "toggleweb") {
142
- if (!pc) { pushLine("Proxy URI not set — use Set proxy URI… first", C.error); continue }
143
- await saveProxy((raw) => { raw.proxy = { ...pc, web: !pc.web } })
144
- pushLabel("❯ Config", ansi.bold + C.tool)
145
- pushLine(`proxy.web = ${!pc.web ? "on" : "off"}`, C.tool)
146
- } else if (c.action === "test") {
147
- const { proxyFetch, resolveWebProxy } = await import("@thincoder/core/proxy.mjs")
148
- const { UA } = await import("@thincoder/core/tools/web.mjs")
149
- const uri = resolveWebProxy({ agent })
150
- pushLabel("❯ Config", ansi.bold + C.tool)
151
- pushLine(`Testing ${uri ? `via proxy ${uri}` : "direct (no proxy)"}...`, C.dim)
152
- try {
153
- const res = await Promise.race([
154
- proxyFetch("https://www.gstatic.com/generate_204", { headers: { "User-Agent": UA } }, uri),
155
- new Promise((_, reject) => setTimeout(() => reject(new Error("timeout after 5s")), 5000)),
156
- ])
157
- if (res.ok) pushLine(`✓ OK (HTTP ${res.status})`, C.tool)
158
- else pushLine(`✗ HTTP ${res.status}`, C.error)
159
- } catch (error) {
160
- pushLine(`✗ ${error.message}`, C.error)
161
- }
162
- } else if (c.action === "clear") {
163
- await saveProxy((raw) => { delete raw.proxy })
164
- pushLabel("❯ Config", ansi.bold + C.tool)
165
- pushLine("Proxy cleared", C.tool)
166
- }
167
- } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
168
- }
169
- }
90
+ // ── 四子菜单(代理 ∥ 会诊池 ∥ 并发池 ∥ 默认模型)已迁 `cmd-config-menus.mjs`(§6.16.9 —— C2):
91
+ // 工厂形接收 ctx 袋——saveProxy 在本处已建好,四个菜单各建一次、主循环复用(行为零变)──
92
+ const menuCtx = { agent, DEFAULTS, showPicker, askQuestion, pushLine, pushLabel, saveProxy, pickModelForSlot }
93
+ const proxyMenu = createProxyMenu(menuCtx)
94
+ const consultMenu = createConsultMenu(menuCtx)
95
+ const poolMenu = createPoolMenu(menuCtx)
96
+ const defaultModelMenu = createDefaultModelMenu(menuCtx)
170
97
 
171
98
  // Direct args: /config embedkey
172
99
  const sub = args[0]?.toLowerCase()
@@ -176,163 +103,6 @@ export async function handleConfigCommand(ctx, args = []) {
176
103
  }
177
104
  if (sub) { pushLine("Usage: /config [embedkey]", C.error); return }
178
105
 
179
- /** 会诊/飞刀候选池子菜单:列出 / 添加 / 编辑 effort / 删除 consultModels 条目。 */
180
- async function pickEffort(current, model) {
181
- const { specForModel } = await import("@thincoder/core/config.mjs")
182
- const enumList = model ? specForModel(model).reasoningEffortEnum : null
183
- // The model's reasoning-effort enum is HETEROGENEOUS across providers (deepseek:
184
- // low/high/max; qwen3.8-max: xhigh/medium/low; kimi: 7 levels). A fixed
185
- // min/low/medium/high/max list made the user pick values that the runtime then
186
- // silently dropped as out-of-enum (2026-08-17 audit). Show the model's real enum.
187
- if (!enumList || enumList.length === 0) return null // model has no effort — skip
188
- const levels = effortMenuLevels(enumList) // "none" = clear the effort(自带去重——#16)
189
- const entries = levels.map((l) => ({ type: "item", text: l === current ? `${l} ← current` : l, action: l }))
190
- const c = await showPicker("Reasoning effort", entries, { defaultIndex: Math.max(0, levels.indexOf(current ?? "none")) })
191
- return c ? c.action : null // Esc → null (keep unchanged)
192
- }
193
-
194
- async function consultMenu() {
195
- let idx = 0
196
- for (;;) {
197
- const cm = agent.config?.agent?.consultModels ?? []
198
- const entries = [
199
- { type: "header", text: `Consult/escalate pool: ${cm.length} model(s) (max 5)` },
200
- ...cm.map((m, i) => ({ type: "item", text: `${m.provider}:${m.model}${m.effort ? ` (${m.effort})` : ""}`, action: "edit", index: i })),
201
- { type: "item", text: cm.length ? "+ Add model" : "+ Add model (none yet)", action: "add" },
202
- ]
203
- const c = await showPicker("Consult models", entries, { defaultIndex: idx })
204
- if (!c) return // Esc → 返回主菜单
205
- if (c.action === "add") {
206
- if (cm.length >= 5) { pushLine("At most 5 consult models", C.error); continue }
207
- // BOTH provider and model are pickers (discipline: options, never free-text) —
208
- // pickModelForSlot reuses /model's provider list + async-fetched model list.
209
- const picked = await pickModelForSlot()
210
- if (!picked) continue
211
- const effort = await pickEffort(null, picked.model)
212
- const entry = { provider: picked.provider, model: picked.model }
213
- if (effort && effort !== "none") entry.effort = effort
214
- const next = [...cm, entry]
215
- await saveProxy((raw) => { raw.agent ??= {}; raw.agent.consultModels = next })
216
- pushLabel("❯ Config", ansi.bold + C.tool)
217
- pushLine(`Added ${entry.provider}:${entry.model}${entry.effort ? ` (${entry.effort})` : ""}`, C.tool)
218
- idx = 0
219
- } else if (c.action === "edit") {
220
- // Per-model sub-menu: change effort or remove.
221
- const m = cm[c.index]
222
- const tag = `${m.provider}:${m.model}`
223
- const subEntries = [
224
- { type: "header", text: `${tag} — effort: ${m.effort ?? "(none)"}` },
225
- { type: "item", text: `Change effort (current: ${m.effort ?? "none"})`, action: "effort" },
226
- { type: "item", text: "Remove", action: "remove" },
227
- ]
228
- const s = await showPicker(tag, subEntries, {})
229
- if (!s) continue
230
- if (s.action === "remove") {
231
- const next = cm.filter((_, i) => i !== c.index)
232
- await saveProxy((raw) => { raw.agent ??= {}; raw.agent.consultModels = next })
233
- pushLabel("❯ Config", ansi.bold + C.tool)
234
- pushLine(`Removed ${tag}`, C.tool)
235
- } else if (s.action === "effort") {
236
- const effort = await pickEffort(m.effort, m.model)
237
- if (effort === null) { continue } // Esc 保持
238
- const next = cm.map((x, i) => {
239
- if (i !== c.index) return x
240
- if (effort === "none") { const { effort, ...rest } = x; return rest }
241
- return { ...x, effort }
242
- })
243
- await saveProxy((raw) => { raw.agent ??= {}; raw.agent.consultModels = next })
244
- pushLabel("❯ Config", ansi.bold + C.tool)
245
- const after = next[c.index]
246
- pushLine(`${tag} effort = ${after?.effort ?? "none"}`, C.tool)
247
- }
248
- idx = 0
249
- }
250
- }
251
- }
252
-
253
- // ── 并发池子菜单(agent.poolLimits——读/改三域;保存经 saveProxy
254
- // 落盘 + reloadConfig 热应用——下个 spawn 生效)──
255
- async function poolMenu() {
256
- let poolIdx = 0
257
- for (;;) {
258
- const pl = agent.config?.agent?.poolLimits ?? {}
259
- // 显示回退与默认同源(DEFAULTS.agent.poolLimits——配置 DEFAULTS 与运行时回退常量
260
- // ASYNC_POOL_LIMITS/ADVISOR_POOL_LIMIT 的耦合由 T-24a4 锚定断言(config-pool.test.mjs)
261
- // 锁住——防默认值单侧漂移)
262
- const cur = poolCur(pl, DEFAULTS)
263
- const entries = [
264
- { type: "header", text: `Async pools: eng-coder ${cur("engCoder")} / other ${cur("other")} / advisor ${cur("advisor")}(默认 4/4/4——分域互不阻塞——subagent 超限排队/advisor 超限即拒)` },
265
- { type: "item", text: `eng-coder 池上限 = ${cur("engCoder")}`, action: "engCoder" },
266
- { type: "item", text: `其他角色池上限 = ${cur("other")}`, action: "other" },
267
- { type: "item", text: `advisor 评审池上限 = ${cur("advisor")}`, action: "advisor" },
268
- ]
269
- const c = await showPicker("并发池(agent.poolLimits)", entries, { defaultIndex: poolIdx })
270
- if (!c) return // Esc 返回主菜单
271
- poolIdx = Math.max(0, entries.filter((e) => e.type === "item").indexOf(c))
272
- const val = await askQuestion(`${c.action} pool limit (current: ${cur(c.action)} — positive integer ≥1):`)
273
- if (!val) continue // 空输入不改动
274
- const num = Number(val)
275
- if (!Number.isInteger(num) || num < 1) { pushLine("Pool limit must be a positive integer (≥1)", C.error); continue }
276
- // 写盘全对象(三键——未触碰的键带当前值重写——全非法/空输入不改动)
277
- const next = { engCoder: cur("engCoder"), other: cur("other"), advisor: cur("advisor"), [c.action]: num }
278
- try {
279
- await saveProxy((raw) => { raw.agent ??= {}; raw.agent.poolLimits = { engCoder: next.engCoder, other: next.other, advisor: next.advisor } })
280
- pushLabel("❯ Config", ansi.bold + C.tool)
281
- pushLine(`agent.poolLimits = { engCoder: ${next.engCoder}, other: ${next.other}, advisor: ${next.advisor} }(下个 spawn 生效——分域互不阻塞)`, C.tool)
282
- } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
283
- }
284
- }
285
-
286
- // ── 默认模型子菜单(F-5:config.defaultModel 专用入口——L1 provider → L2 **运行期拉取**候选 →
287
- // 写 config.defaultModel——saveProxy/writeConfigAtomic 通道——不落会话槽;不加手输行——O1 已裁)──
288
- async function defaultModelMenu() {
289
- let idx = 0
290
- // M9 配置阶段准入:进本子菜单探一次各渠道 `/models`(复用 M1 + 会话缓存)。
291
- // 探通 → 渠道可用 + 候选直接可用;探不通 → 不缓存不阻断(标「不可用」且不入可选来源)。
292
- const probes = new Map()
293
- pushLine("Fetching channel model lists (GET /models)…", C.dim)
294
- await Promise.all(agent.providers.map(async (p) => {
295
- const r = await probeChannelModels(probeTargetOf(p)) // 探针目标构造收敛核判据(③′——逐渠旗 ∧ `uri` 在案;执行体零改)
296
- probes.set(p.name, r)
297
- if (r.ok) delete p._unavailable
298
- else p._unavailable = true
299
- }))
300
- for (;;) {
301
- const dm = agent.config?.defaultModel ?? null
302
- const entries = [
303
- { type: "header", text: `config.defaultModel = ${dm ?? "(not set — 新会话起点未配置)"}` },
304
- ...agent.providers.map((p) => {
305
- const r = probes.get(p.name)
306
- if (!r?.ok) return { type: "item", text: `${p.name.padEnd(10)} 不可用`, action: "provider", provider: p.name, unavailable: true }
307
- const n = r.list.length
308
- // M3③:渠道行显示回退 = `baseURL`(渠道条目不携模型——2026-10-09 清除批)+ 探得候选数
309
- return { type: "item", text: `${p.name.padEnd(10)} ${p.baseURL} (${n} model${n === 1 ? "" : "s"})`, action: "provider", provider: p.name }
310
- }),
311
- ]
312
- const c = await showPicker("Default Model (新会话起点)", entries, { defaultIndex: idx })
313
- if (!c) return // Esc → 返回主菜单
314
- idx = Math.max(0, entries.filter((e) => e.type === "item").indexOf(c))
315
- if (c.action !== "provider") continue
316
- const r = probes.get(c.provider)
317
- if (!r?.ok) {
318
- // 准入判据:探不通的渠道不作为默认模型的可选来源——明示原因(M8 长句),不阻断菜单
319
- pushLine(r?.message ?? `${c.provider} 不可用`, C.error)
320
- continue
321
- }
322
- if (r.list.length === 0) { pushLine(`${c.provider}: /models 未返回任何模型`, C.error); continue }
323
- const me = await showPicker(`${c.provider} models`, [
324
- { type: "header", text: "选为 config.defaultModel(新会话起点——当前会话槽不受影响)" },
325
- ...dedupeModels(r.list).map((m) => ({ type: "item", text: m, action: "model", model: m })),
326
- ])
327
- if (!me) continue // Esc → 回默认模型菜单
328
- try {
329
- await saveProxy((raw) => { raw.defaultModel = `${c.provider}:${me.model}` })
330
- pushLabel("❯ Config", ansi.bold + C.tool)
331
- pushLine(`config.defaultModel = ${c.provider}:${me.model}(新会话起点;会话模型不受影响)`, C.tool)
332
- } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
333
- }
334
- }
335
-
336
106
  // ── Main config loop ──
337
107
  let running = true
338
108
  let mainIdx = 0 // 记住上次选中位置,改完一项回主菜单时恢复
@@ -345,17 +115,26 @@ export async function handleConfigCommand(ctx, args = []) {
345
115
  const consultCount = (ac.consultModels ?? []).length
346
116
  const pl = ac.poolLimits ?? {}
347
117
  const cur = poolCur(pl, DEFAULTS)
118
+ // §6.17 显示面(一处助手,四处共用):数值 = compactThresholdResolved(缺场 ⇒ `(unavailable)`——
119
+ // 链尾不产数、不回落任何默认数——回落 100000 会造一条 10% 假线;该支不可达,纯护栏);
120
+ // auto 旗 ⇒ 缀 ` (auto)`。写入数值 = 固定为显式阈值(保存回显明示)。
121
+ const ctResolved = ac.compactThresholdResolved
122
+ const ctDisplay = ctResolved === undefined ? "(unavailable)" : String(ctResolved)
123
+ const ctSuffix = compactThresholdSuffix(ac.compactThresholdAuto)
348
124
  const mainEntries = [
349
- { type: "header", text: `proxy=${proxySummary()} | maxTurns=${ac.maxTurns ?? 200} | compactThreshold=${ac.compactThreshold ?? 100000} | verifyGuard=${ac.verifyGuard === true ? "on" : "off"} | consult=${consultCount} model(s) | embedding=${agent.memory?.embedder ? "on" : "off"} | traces=${tc.enabled === false ? "off" : "on"}` },
125
+ { type: "header", text: `proxy=${proxySummary()} | maxTurns=${ac.maxTurns ?? 200} | compactThreshold=${ctDisplay}${ctSuffix} | verifyGuard=${ac.verifyGuard === true ? "on" : "off"} | consult=${consultCount} model(s) | embedding=${agent.memory?.embedder ? "on" : "off"} | traces=${tc.enabled === false ? "off" : "on"}` },
350
126
  { type: "item", text: `agent.maxTurns = ${ac.maxTurns ?? 200}`, action: "agent.maxTurns" },
351
127
  { type: "item", text: `agent.subagentTurns = ${ac.subagentTurns ?? 100}`, action: "agent.subagentTurns" },
352
128
  { type: "item", text: `并发池 agent.poolLimits = engCoder ${cur("engCoder")} / other ${cur("other")} / advisor ${cur("advisor")}(async 分域上限)`, action: "pool" },
353
- { type: "item", text: `agent.compactThreshold = ${ac.compactThreshold ?? 100000}${agent.config?.agent?.compactThresholdAuto ? " (auto)" : ""}`, action: "agent.compactThreshold" },
129
+ { type: "item", text: `agent.compactThreshold = ${ctDisplay}${ctSuffix}`, action: "agent.compactThreshold" },
354
130
  { type: "item", text: `config.defaultModel = ${agent.config?.defaultModel ?? "(未设置 — 新会话起点)"}`, action: "defaultModel" },
355
131
  { type: "item", text: `agent.verifyGuard = ${ac.verifyGuard === true ? "on" : "off"}`, action: "agent.verifyGuard" },
356
132
  { type: "item", text: `traces.enabled = ${tc.enabled === false ? "off" : "on"}(轨迹存档——发布默认关——隐私)`, action: "traces.enabled" },
357
133
  { type: "item", text: `traces.retentionHours = ${tc.retentionHours ?? 24} h(超期文件启动时清理)`, action: "traces.retentionHours" },
358
134
  { type: "item", text: `diagnostics.heapSnapshot = ${dc.heapSnapshot === true ? "on" : "off"}(堆快照采集——默认关——桌面会话即时生效)`, action: "diagnostics.heapSnapshot" },
135
+ { type: "item", text: `agent.injectProjectRules = ${ac.injectProjectRules !== false ? "on" : "off"}(项目指令注入——AGENTS.md / project_rules.md——默认开)`, action: "agent.injectProjectRules" },
136
+ { type: "item", text: `agent.injectDocs = ${ac.injectDocs !== false ? "on" : "off"}(文档注入——相关文档自动检索——默认开)`, action: "agent.injectDocs" },
137
+ { type: "item", text: `agent.injectMemories = ${ac.injectMemories !== false ? "on" : "off"}(记忆注入——往期相关记忆召回——默认开)`, action: "agent.injectMemories" },
359
138
  { type: "item", text: `agent.consultModels = ${consultCount} model(s)${consultCount ? ` (${(ac.consultModels ?? []).map((m) => m.provider + ":" + m.model).join(", ")})` : ""}`, action: "consult" },
360
139
  { type: "item", text: `agent.consultTurns = ${ac.consultTurns ?? 40}`, action: "agent.consultTurns" },
361
140
  { type: "item", text: `agent.consultTimeoutMs = ${Math.round((ac.consultTimeoutMs ?? 600000) / 60000)} min`, action: "agent.consultTimeoutMs" },
@@ -375,11 +154,14 @@ export async function handleConfigCommand(ctx, args = []) {
375
154
  pushLine(`Key: ${maskKey(agent.provider.apiKey)}`, C.dim)
376
155
  pushLine(`agent.maxTurns: ${ac.maxTurns ?? 200}`, C.dim)
377
156
  pushLine(`agent.subagentTurns: ${ac.subagentTurns ?? 100}`, C.dim)
378
- pushLine(`agent.compactThreshold: ${ac.compactThreshold ?? 100000}${agent.config?.agent?.compactThresholdAuto ? " (auto)" : ""}`, C.dim)
157
+ pushLine(`agent.compactThreshold: ${ctDisplay}${ctSuffix}`, C.dim)
379
158
  pushLine(`agent.verifyGuard: ${ac.verifyGuard === true ? "on" : "off"}`, C.dim)
380
159
  pushLine(`traces.enabled: ${tc.enabled === false ? "off" : "on"}(默认 off——发布隐私——本地分析可开)`, C.dim)
381
160
  pushLine(`traces.retentionHours: ${tc.retentionHours ?? 24}(超期文件启动清理——D-TR10)`, C.dim)
382
161
  pushLine(`diagnostics.heapSnapshot: ${dc.heapSnapshot === true ? "on" : "off"}(堆快照采集——默认关——桌面会话即时生效)`, C.dim)
162
+ pushLine(`agent.injectProjectRules: ${ac.injectProjectRules !== false ? "on" : "off"}(项目指令注入——AGENTS.md / project_rules.md——默认开)`, C.dim)
163
+ pushLine(`agent.injectDocs: ${ac.injectDocs !== false ? "on" : "off"}(文档注入——相关文档自动检索——默认开)`, C.dim)
164
+ pushLine(`agent.injectMemories: ${ac.injectMemories !== false ? "on" : "off"}(记忆注入——往期相关记忆召回——默认开)`, C.dim)
383
165
  pushLine(`agent.consultModels: ${(ac.consultModels ?? []).map((m) => `${m.provider}:${m.model}${m.effort ? ` (${m.effort})` : ""}`).join(", ") || "(none)"}`, C.dim)
384
166
  pushLine(`agent.poolLimits: { engCoder: ${cur("engCoder")}, other: ${cur("other")}, advisor: ${cur("advisor")} }(async 分域上限——默认 4/4/4——agent.poolLimits 可配)`, C.dim)
385
167
  pushLine(`agent.consultTurns: ${ac.consultTurns ?? 40}`, C.dim)
@@ -452,24 +234,59 @@ export async function handleConfigCommand(ctx, args = []) {
452
234
  continue // 回主菜单(Esc 退出)
453
235
  }
454
236
 
237
+ if (choice.action === "agent.injectProjectRules" || choice.action === "agent.injectDocs" || choice.action === "agent.injectMemories") {
238
+ // 注入开关(PROMPT-SYSTEM.md §6.24 §6.27 · 台账 #1420 #1465):判据 `!== false`(缺省 = 开)——三键共用一支;
239
+ // 保存经 saveProxy(写盘 + reloadConfig 即热——下一次提示词组装生效,无「重启」注)。
240
+ const key = choice.action.slice("agent.".length)
241
+ const newVal = ac[key] === false // 现为关 ⇒ 写 true;现为开(含缺省)⇒ 写 false
242
+ try {
243
+ await saveProxy((raw) => {
244
+ raw.agent ??= {}
245
+ raw.agent[key] = newVal
246
+ })
247
+ pushLabel("❯ Config", ansi.bold + C.tool)
248
+ pushLine(`${choice.action} = ${newVal ? "on" : "off"}(即热——下一次提示词组装生效)`, C.tool)
249
+ } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
250
+ continue // 回主菜单(Esc 退出)
251
+ }
252
+
455
253
  // Embedding model is fixed (BAAI/bge-m3, SiliconFlow) — no picker; it's over-engineering
456
254
  // to expose model choice when the vector index format assumes one embedding space.
457
255
 
458
256
  // Numeric config items
459
257
  const label = choice.action
460
258
  const isTimeout = label === "agent.consultTimeoutMs"
259
+ const isCompact = label === "agent.compactThreshold"
461
260
  const current = label === "agent.maxTurns" ? (ac.maxTurns ?? 200)
462
261
  : label === "agent.subagentTurns" ? (ac.subagentTurns ?? 100)
463
- : label === "agent.compactThreshold" ? (ac.compactThreshold ?? 100000)
262
+ // §6.17 编辑初值 = 同一数值(resolved 缺场 ⇒ 留空——不预填任何默认数)
263
+ : label === "agent.compactThreshold" ? (ctResolved ?? "")
464
264
  : label === "agent.consultTurns" ? (ac.consultTurns ?? 40)
465
265
  : label === "traces.retentionHours" ? (tc.retentionHours ?? 24)
466
266
  : isTimeout ? Math.round((ac.consultTimeoutMs ?? 600000) / 60000)
467
267
  : ""
468
- const val = await askQuestion(`${label} (current: ${current}${isTimeout ? " min" : ""}):`)
268
+ // §6.17 提问行后缀(两档互斥文案):compact 项按 auto 旗二选一,非 compact 项传 null ⇒ 空串
269
+ // (台账 `#1679`——auto 档学「数值会锁死派生线」、显式档学「怎么回 auto」)。
270
+ const hint = compactThresholdHint(isCompact ? ac.compactThresholdAuto === true : null)
271
+ const val = await askQuestion(`${label} (current: ${current}${isTimeout ? " min" : ""}${hint}):`)
469
272
  if (!val) continue
273
+ // §6.17 写回面:输入 auto(大小写不敏感、去首尾空白)⇒ 删键回 auto(仅 `agent.compactThreshold`
274
+ // 认该形;其余数值项照旧走数值判,空输入仍 = 取消)。
275
+ if (isCompact && String(val).trim().toLowerCase() === "auto") {
276
+ try {
277
+ await saveProxy((raw) => { if (raw.agent) delete raw.agent.compactThreshold })
278
+ pushLabel("❯ Config", ansi.bold + C.tool)
279
+ pushLine("agent.compactThreshold = (auto)(键已删除——压缩线按在用模型的窗口每轮现算)", C.tool)
280
+ } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
281
+ continue
282
+ }
470
283
  try {
471
284
  const num = Number(val)
472
- if (isNaN(num)) { pushLine("Value must be a number", C.error); continue }
285
+ if (isNaN(num)) {
286
+ // 报错行射程:`auto` 子句仅 `agent.compactThreshold` 一项,其余数值项文案不变(R13)
287
+ pushLine(isCompact ? `Value must be a number (or "auto" to clear the explicit override)` : "Value must be a number", C.error)
288
+ continue
289
+ }
473
290
  const stored = isTimeout ? Math.round(num * 60000) : num
474
291
  await saveProxy((raw) => {
475
292
  const keys = label.split(".")
@@ -479,6 +296,7 @@ export async function handleConfigCommand(ctx, args = []) {
479
296
  })
480
297
  pushLabel("❯ Config", ansi.bold + C.tool)
481
298
  pushLine(`${label} = ${isTimeout ? `${val} min (${stored} ms)` : val}`, C.tool)
299
+ if (isCompact) pushLine("显式阈值——auto 派生线不再生效(压缩线改按该显式值判定)", C.dim)
482
300
  pushLine("(restart to apply)", C.dim)
483
301
  } catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
484
302
  // 回主菜单(Esc 退出)——数值输入 Enter 空值也已 continue 于此