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
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.12.76] — 2026-10-19
4
+
5
+ ### Added
6
+
7
+ - **网络工具接入 DeepSeek 后端**:`websearch` / `fetch` 自动复用 `providers[]` 中 `api.deepseek.com` 渠道的 key(零新增配置)——搜索得结构化结果(date ∥ authority ∥ rerank + 长摘要),抓取得 Markdown 正文;后端失败软着陆(401/402/403/404 熔断 ∥ 408/429/5xx 退避一次 ∥ 工具永不失败);新增逃生口键 `websearch.backend` ∥ `fetch.backend`(∈ auto/local,缺省 auto;无该渠道的用户行为逐字不变)。
8
+
9
+ ## [0.12.75] — 2026-10-16
10
+
11
+ > 0.12.74 → 0.12.75(连续号——发布时定号)
12
+
13
+ ### Changed
14
+
15
+ - **核依赖升级**:`@thincoder/core` `^0.10.7` → `^0.10.8`(内建 `doc_check` ∥ 台账根读写同一推导随核生效)。
16
+ - **提示词面收正**:中文 = 设计文档 ∥ 英文 = 代码 口径落地;运行面去文档引用(P1/P3/P4);联网查证指导入册;S1/S2 优化。
17
+ - **登录成拍模型候选面即时刷新**(三端同拍)。
18
+ - **文档纪律面**:行宽口径定形 ∥ 陈旧引用/取值清扫 ∥ C 族行数声明面退役 ∥ R2 层前缀引称落地 ∥ 指针纪律收正(禁行号引)。
19
+
1
20
  ## [0.12.74] — 2026-10-14
2
21
 
3
22
  > 0.12.73 → 0.12.74(连续号——发布时定号)
package/README.md CHANGED
@@ -178,7 +178,9 @@ may hold a `${env:VAR}` reference, resolved at use time — the value is then ta
178
178
  // optional: Tavily structured search (stable JSON API, no HTML scraping).
179
179
  // Empty apiKey → silently falls back to Bing HTML extraction (zero-config).
180
180
  "apiKey": "tvly-...", // https://tavily.com — has a free monthly tier
181
+ "backend": "auto", // "auto" = DeepSeek when a DeepSeek provider is configured; "local" = skip DeepSeek
181
182
  },
183
+ "fetch": { "backend": "auto" }, // same values — "local" = fetch locally (skip DeepSeek)
182
184
  }
183
185
  ```
184
186
 
@@ -231,6 +233,12 @@ Code conventions: pure `.mjs`, no semicolons, no third-party npm dependencies al
231
233
 
232
234
  ## Changelog
233
235
 
236
+ ### 0.12.75 (2026-10)
237
+ - **Core `^0.10.8`** — builtin `doc_check` (document-discipline machine check as a product tool: anchors + line width, report-only) and ledger root derivation (single read/write criterion) ride in with the core.
238
+ - Prompt-face corrections: Chinese = design docs / English = code split landed; runtime face doc-reference removal; online-verification guidance; S1/S2 tuning.
239
+ - Login-time model candidate refresh (all three ends).
240
+ - Doc-discipline round: line-width criterion fixed, stale references swept, C-family line-count statements retired, R2 citation landing, no-line-number-citation discipline.
241
+
234
242
  ### 0.12.74 (2026-10)
235
243
  - **Core `^0.10.7`** — document index scoping: `docs/batches/**` excluded by default; index scope is now declared by manifest (declared dirs ∪ first-level subdirectory manifests).
236
244
 
package/bin/thincoder.mjs CHANGED
@@ -150,6 +150,7 @@ Usage:
150
150
  thincoder completion <sh> Generate shell completion script (bash / zsh / fish)
151
151
  thincoder team login [--server <url>] [--user <name>] Log in to a team server (password prompt — hidden echo)
152
152
  thincoder team logout | status Log out (revoke the team token) / show login state
153
+ thincoder team rotate Rotate the team token (revoke the current one + reissue; asks y/N)
153
154
  thincoder -v, --version Print version
154
155
 
155
156
  Config: ~/.thincoder/config.json — providers[] (one default model per channel) + defaultModel (new-session starting point); the available-model list is fetched from the provider at runtime (GET /models); manage via /config → 默认模型 and /model (session-level) in TUI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thincoder",
3
- "version": "0.12.74",
3
+ "version": "0.12.76",
4
4
  "description": "Thin coding agent - zero third-party dependencies, no build step, Node.js native. Sharp code, zero bloat.",
5
5
  "keywords": [
6
6
  "ai",
@@ -20,7 +20,7 @@
20
20
  "node": ">=24"
21
21
  },
22
22
  "dependencies": {
23
- "@thincoder/core": "^0.10.7"
23
+ "@thincoder/core": "^0.10.9"
24
24
  },
25
25
  "files": [
26
26
  "bin/",
@@ -80,16 +80,18 @@ function subagentMetaPayload(path, ev) {
80
80
  /**
81
81
  * Build the runAgent callbacks for an ACP session.
82
82
  * @param {{ sessionId: string, agent?: object, notify: (m, p) => void, request: (m, p, o?) => Promise<any>, log?: (s) => void,
83
- * clientCaps?: { fs?: { readTextFile?: boolean, writeTextFile?: boolean } } }} deps
83
+ * clientCaps?: { fs?: { readTextFile?: boolean, writeTextFile?: boolean } },
84
+ * onSecretInput?: Function }} deps
84
85
  * `agent` = 会话的活引用(§2.4——`set_config_option` 切模型后 `usage_update.size` 随动;
85
86
  * 不得在构造期固化数值);`clientCaps` = the §3.4 snapshot (taken at `session/new`); capabilities omitted by the
86
- * client are UNSUPPORTED ⇒ the fs reverse-RPC face stays local (§11.4 — never 30s 干等).
87
+ * client are UNSUPPORTED ⇒ the fs reverse-RPC face stays local (§11.4 — never 30s 干等);
88
+ * `onSecretInput` = 凭据窗注入缝(SSH-SESSION 批 §6.22 ⑧——无 UI 通道由装配侧给拒件;缺省零注入)。
87
89
  */
88
- export function buildAcpCallbacks({ sessionId, agent, notify, request, log = () => {}, clientCaps = {} }) {
90
+ export function buildAcpCallbacks({ sessionId, agent, notify, request, log = () => {}, clientCaps = {}, onSecretInput = null }) {
89
91
  const update = (sessionUpdate, extra = {}) =>
90
92
  notify("session/update", { sessionId, update: { sessionUpdate, ...extra } })
91
93
  // §11.4 fs 能力位(默认 false——文档「MUST treat all capabilities omitted … as UNSUPPORTED」);
92
- // 判据同构 = kimi server.ts:626-636。edit 桥需读回 + 写回 ⇒ 两位皆真才路由。
94
+ // 判据同构 = kimi server.ts。edit 桥需读回 + 写回 ⇒ 两位皆真才路由。
93
95
  const canReadFile = clientCaps?.fs?.readTextFile === true
94
96
  const canWriteFile = clientCaps?.fs?.writeTextFile === true
95
97
  let toolSeq = 0
@@ -220,7 +222,7 @@ export function buildAcpCallbacks({ sessionId, agent, notify, request, log = ()
220
222
  // D7 + 批 1 B2/D13(ACP-CLIENT.md §7.2):剥离判据 = **形态**(`⟦ev⟧<小写名>` + RS
221
223
  // 终止符同现)——枚举是漏项发生器(`queued` / `cancelled` 发射点在位而白名单未跟 ⇒
222
224
  // 随 agent_message_chunk 泄漏给客户端)。终止符约束 load-bearing:放宽为无终止符形态
223
- // 会吞真实正文(先例教训见 src/tui/render.mjs:250-252)。
225
+ // 会吞真实正文(先例教训见 src/tui/render.mjs)。
224
226
  // 判据单源 = 核模块 `subagent-event.mjs`(2026-10-04 批统一——桥内联式退役,剥离语义
225
227
  // 零改):`parseSubagentEvent` 非空 ⇒ 剥;§12 结构化发射 = 同一调用取投影载荷。
226
228
  const ev = parseSubagentEvent(payload)
@@ -322,6 +324,13 @@ export function buildAcpCallbacks({ sessionId, agent, notify, request, log = ()
322
324
  }
323
325
  },
324
326
 
327
+ /**
328
+ * SSH 凭据窗(SSH-SESSION 批 · TOOLS.md §6.22 ⑧——无 UI 场合):注入侧给拒件(可读句 + 指引——
329
+ * 不挂起、不静默;装配 = `acp.mjs` `refuseSecretInput`);缺省零注入 ⇒ 核工具自身抛句
330
+ * (同 `question.mjs` 无 UI 例)。
331
+ */
332
+ ...(onSecretInput ? { onSecretInput: (payload) => onSecretInput(payload) } : {}),
333
+
325
334
  /**
326
335
  * fs reverse-RPC router (dispatch.mjs toolRouter, M2) — 能力位 + 工具形态双判(§11.4):
327
336
  * - write → fs/write_text_file (full content, no read-back) — 需 clientCaps.fs.writeTextFile
@@ -130,7 +130,7 @@ export function applyConfigOption(agent, configId, value) {
130
130
  // on 侧同引核(thinkEnabledValue——自定义开值族 MiniMax = "adaptive")。
131
131
  const spec = providerSpec(agent.provider)
132
132
  agent.provider.thinking = value ? { type: spec.thinkEnabledValue ?? "enabled" } : thinkOffShape(spec)
133
- // effort 族:`null` 标记在载荷层由「无显式档」门控(provider/core.mjs:193 显式档优先会
133
+ // effort 族:`null` 标记在载荷层由「无显式档」门控(provider/core.mjs 显式档优先会
134
134
  // 跳过标记)⇒ off 清档位(与 CLI `/think off` 同法——cmd-think.mjs `applyThink` off 支)。
135
135
  if (!value) delete agent.provider.reasoningEffort
136
136
  return true
@@ -75,10 +75,11 @@ export function createSlotsHandlers(ctx) {
75
75
  // 2026-08-31 会诊 deepseek 🟡(搬迁保留):读槽走 session.mjs 共享 `loadSlotFile`(校验/
76
76
  // 保现场/.tmp 回退与主路径一致)——本地实现此前无 .unreadable/.corrupted 保留。
77
77
  // #41 先判(F3 合值 / F4 装配期判据):目标槽合值 === true ⇒ 判据前置于 `createSession`
78
- // (拒 ⇒ 走既有 ACP 错误通道、**不建会话**——无半态);准 ⇒ 既有装载 + 下方重估。
78
+ // (**可拒面 = 仅「档非法」格**;工作区 `workspace` ⇒ 放行,零附着——F2 表工作区行)。
79
+ // 拒 ⇒ 走既有 ACP 错误通道、**不建会话**——无半态;准 ⇒ 既有装载 + 下方重估。
79
80
  if (slotEngineering(data)) {
80
81
  const r = resolveEngineeringManifest(getCwd(), { writer: "main" })
81
- if (!r.ok) {
82
+ if (!r.ok && r.code !== "workspace") {
82
83
  return { error: { code: ACP_ERRORS.INTERNAL.code, message: `failed to load session ${slot}: ${r.message}` } }
83
84
  }
84
85
  }
@@ -147,10 +148,11 @@ export function createSlotsHandlers(ctx) {
147
148
  if (!data) {
148
149
  return { error: { ...ACP_ERRORS.INVALID_PARAMS, message: `session ${slot} not found (corrupt or deleted)` } }
149
150
  }
150
- // #41 先判(同 session/load——合值判据前置于 `createSession`;拒 ⇒ 不建会话)。
151
+ // #41 先判(同 session/load——合值判据前置于 `createSession`;**可拒面 = 仅「档非法」**;
152
+ // 工作区 `workspace` ⇒ 放行——拒 ⇒ 不建会话)。
151
153
  if (slotEngineering(data)) {
152
154
  const r = resolveEngineeringManifest(getCwd(), { writer: "main" })
153
- if (!r.ok) {
155
+ if (!r.ok && r.code !== "workspace") {
154
156
  return { error: { code: ACP_ERRORS.INTERNAL.code, message: `failed to resume session ${slot}: ${r.message}` } }
155
157
  }
156
158
  }
@@ -73,7 +73,8 @@ export function createReadDataHandlers(ctx, { intervalMs = WATCH_INTERVAL_MS } =
73
73
  const c = resolveCwd(params, ctx)
74
74
  if (c.error) return c.error
75
75
  const { ledgerCmd } = await core()
76
- try { return { count: ledgerCmd.ledgerCount({ cwd: c.cwd }) } } catch (e) { return badParams(e?.message ?? String(e)) }
76
+ // `ledgerCount` 出参 = 对象形 `{ count, overdue, evidenceOversize }`(设计档 §7.1)——直传核对象,零包装
77
+ try { return ledgerCmd.ledgerCount({ cwd: c.cwd }) } catch (e) { return badParams(e?.message ?? String(e)) }
77
78
  },
78
79
 
79
80
  "batch/list": async (params) => {
@@ -90,6 +91,7 @@ export function createReadDataHandlers(ctx, { intervalMs = WATCH_INTERVAL_MS } =
90
91
  let last = null
91
92
  let timer = null
92
93
  let inflight = false // 重叠防衛(先例 = 核 ledger-surface.mjs):上一拍未落定 ⇒ 跳过本拍
94
+ let lastError = null // 上次失败比较键(同因连续 ⇒ 不重复;`check()` resolve 当拍复位)
93
95
 
94
96
  async function check() {
95
97
  if (inflight) return []
@@ -97,7 +99,10 @@ export function createReadDataHandlers(ctx, { intervalMs = WATCH_INTERVAL_MS } =
97
99
  try {
98
100
  const cwd = ctx.getCwd()
99
101
  const { ledgerDb, batchRead } = await core()
100
- const ledgerSig = fileSig(ledgerDb.ledgerDbPath(cwd))
102
+ // 观察域根 = 判据单源 `resolveLedgerRoot`(与写入面同源):根 ⇒ 其键控库指纹;无根 ⇒ 该域无台账库、
103
+ // 指纹恒 "0"(观察域照常上报——键控库在盘 / 变动即报 `ledger/changed`)。
104
+ const root = ledgerDb.resolveLedgerRoot(cwd)?.root
105
+ const ledgerSig = root ? fileSig(ledgerDb.ledgerDbPath(root)) : "0"
101
106
  const batchSig = batchRead.listBatchRecords({ cwd }).batches.map((b) => `${b.path}:${fileSig(b.path)}`).join("|")
102
107
  if (!last || last.cwd !== cwd) { last = { cwd, ledgerSig, batchSig }; return [] } // 首查 / 观察域切换 ⇒ 立基线(静默)
103
108
  const fired = []
@@ -109,11 +114,25 @@ export function createReadDataHandlers(ctx, { intervalMs = WATCH_INTERVAL_MS } =
109
114
  } finally { inflight = false }
110
115
  }
111
116
 
117
+ /** 拍包装(失败可见——同因不刷屏):`check()` reject ⇒ 比较键(`code` 优先、无则 `message`、再无则 `String(e)`);
118
+ * 与上次同键 ⇒ 不重复,异键 ⇒ 记键 + `ctx.log` 一行(`acp.mjs` 注入口 = stderr——协议面零触);resolve ⇒ 复位。 */
119
+ function runCheck() {
120
+ return check().then(
121
+ () => { lastError = null },
122
+ (e) => {
123
+ const key = String(e?.code ?? e?.message ?? e)
124
+ if (key === lastError) return
125
+ lastError = key
126
+ ctx.log?.("[acp] read-data watcher check failed:", key)
127
+ },
128
+ )
129
+ }
130
+
112
131
  /** 启动:立即首查(立基线——静默)+ 周期轮询;unref 定时器(不阻塞进程退出)。 */
113
132
  function start() {
114
133
  if (timer) return
115
- void check().catch(() => {})
116
- timer = setInterval(() => { void check().catch(() => {}) }, intervalMs)
134
+ void runCheck()
135
+ timer = setInterval(() => { void runCheck() }, intervalMs)
117
136
  timer.unref?.()
118
137
  }
119
138
 
@@ -4,8 +4,8 @@
4
4
  * - `run(input)` serializes prompts through a per-session FIFO promise chain
5
5
  * (concurrent prompts queue; each runs after the previous turn's end_turn).
6
6
  * - `cancel()` aborts the in-flight turn via a REAL AbortController — the
7
- * provider layer composes `AbortSignal.any([signal, timeout])` (core.mjs:280,
8
- * anthropic.mjs:67, google.mjs:98), which requires a real AbortSignal; a
7
+ * provider layer composes `AbortSignal.any([signal, timeout])` (core.mjs,
8
+ * anthropic.mjs, google.mjs), which requires a real AbortSignal; a
9
9
  * plain object would throw TypeError on every LLM call.
10
10
  * - The controller is rebuilt after every turn, so one cancel only affects the
11
11
  * in-flight turn; the next queued prompt starts with a clean signal.
@@ -17,9 +17,10 @@ import { runAgent } from "@thincoder/core/agent.mjs"
17
17
  import { saveSession } from "@thincoder/core/session.mjs"
18
18
  import { buildAcpCallbacks } from "./bridge.mjs"
19
19
 
20
- export function createAcpSession({ id, agent, notify, request = async () => { throw new Error("no request channel") }, log = () => {}, run = runAgent, save = saveSession, clientCaps = {} }) {
20
+ export function createAcpSession({ id, agent, notify, request = async () => { throw new Error("no request channel") }, log = () => {}, run = runAgent, save = saveSession, clientCaps = {}, onSecretInput = null }) {
21
21
  let controller = new AbortController()
22
- const callbacks = buildAcpCallbacks({ sessionId: id, agent, notify, request, log, clientCaps })
22
+ // onSecretInput(SSH-SESSION 批 §6.22 ⑧):无 UI 显式拒由装配侧给(acp.mjs);缺省零注入
23
+ const callbacks = buildAcpCallbacks({ sessionId: id, agent, notify, request, log, clientCaps, onSecretInput })
23
24
  let queue = Promise.resolve()
24
25
  let busy = false
25
26
 
package/src/acp.mjs CHANGED
@@ -34,6 +34,8 @@ import { createRequireConfigured, createSessionHandlers, createSlotReleaser } fr
34
34
  import { createSlotsHandlers } from "./acp/handlers-slots.mjs"
35
35
  import { createExtHandlers } from "./acp/ext.mjs"
36
36
  import { createReadDataHandlers } from "./acp/read-data.mjs"
37
+ // SSH 凭据窗无 UI 拒件(SSH-SESSION 批 · TOOLS.md §6.22 ⑧/E6——端面单源单句:secret-prompt.mjs)
38
+ import { refuseSecretInput } from "./tui/secret-prompt.mjs"
37
39
 
38
40
  const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version
39
41
 
@@ -72,10 +74,13 @@ export const ACP_EXCLUDED_TOOLS = ["question"]
72
74
  * `id` is the ACP session id — it is baked into the callbacks at construction time
73
75
  * (buildAcpCallbacks closure), so it must be known BEFORE createAcpSession runs.
74
76
  * `request` is the transport's reverse-RPC channel (permissions + fs routing).
75
- * `clientCaps` = the §3.4 snapshot taken at `session/new` time (fs gate, §11.4). */
77
+ * `clientCaps` = the §3.4 snapshot taken at `session/new` time (fs gate, §11.4).
78
+ * SSH-SESSION 批(TOOLS.md §6.22 ⑧):ACP = 无 UI 通道——ssh 凭据窗无人可问 ⇒ 注入显式拒
79
+ * (可读句 + 指引——不挂起、不静默);**ssh 工具本体不剔除**(密钥 / agent 径照常可用——S1–S4),
80
+ * 仅密码径经该句失败(E6)。 */
76
81
  export async function defaultCreateSession({ id, notify, request, log, clientCaps }) {
77
82
  const agent = await assembleAgent({ excludeTools: ACP_EXCLUDED_TOOLS })
78
- return createAcpSession({ id, agent, notify, request, log, clientCaps })
83
+ return createAcpSession({ id, agent, notify, request, log, clientCaps, onSecretInput: refuseSecretInput })
79
84
  }
80
85
 
81
86
  /**
@@ -107,7 +107,7 @@ async function finalizeTools(baseTools, { cwd, config, excludeTools, warnings })
107
107
  *
108
108
  * 模式门(判据单源 = 会话权威值,槽优先 + config 回退——KD-M1-12 / KD-M1-13):
109
109
  * 「恢复槽带 `engineering` 字段 ? 槽值 : `agent.config.agent.engineering`」(槽字段在场判据
110
- * 与 `applySession` 同款——`thincoder-core/session.mjs:314-317`)。普通会话 → **装配钩子
110
+ * 与 `applySession` 同款——`thincoder-core/session.mjs`)。普通会话 → **装配钩子
111
111
  * 零 manifest I/O**(不读 / 不拒 / 不建档)+ `agent.manifest = null`(清残留附着——复用
112
112
  * agent 跨模式防陈旧)。
113
113
  *
@@ -1,32 +1,33 @@
1
1
  /**
2
- * team-command.mjs — `thincoder team` 命令族(login ∥ logout ∥ status;CLI-ENTRY.md §2 `team` 行 ·
3
- * 2026-10-10 B1 批 · 台账 #1212)。
2
+ * team-command.mjs — `thincoder team` 命令族(login ∥ logout ∥ rotate ∥ status;CLI-ENTRY.md §2 `team` 行 ·
3
+ * 2026-10-10 B1 批 · 台账 #1212;rotate = team-token-rotation 批 · 台账 #1238)。
4
4
  *
5
5
  * 机制单源 = 核 `@thincoder/core/team.mjs`(登录 ∥ 退出 ∥ 状态 ∥ 地址归一 ∥ 端标签 ∥ 派生条目写面)——
6
6
  * 本档 = 命令面壳(旗标解析 ∥ 问句收集 ∥ 出词);**端侧零自写盘**(一切写经核单源)。
7
7
  * 输入形(D-TM6):地址/用户名可旗标注入(`--server <url>` ∥ `--user <name>`——空格形,缺 ⇒ 问句);
8
8
  * 密码恒问句(零旗标——零命令历史)——TTY = 隐藏回显(原始模式逐键,零回显)∥ 非 TTY = stdin 行读。
9
- * 文案(TEAM.md §2.5——三端逐字同句):未登录「未登录——登录后可用」;失败四句(理由域四值单源 =
10
- * 核 `reason` 闭集);两条一次性提示(同名冲突(登录当刻)∥ 吊销未达(退出当刻))——读面零提示字段。
9
+ * 文案(TEAM.md §2.5——三端逐字同句):未登录「未登录——登录后可用」;失败五句(理由域五值单源 =
10
+ * 核 `reason` 闭集);三条一次性提示(同名冲突(登录当刻)∥ 吊销未达(退出当刻)∥ 轮换(确认句 + 成句))——读面零提示字段。
11
11
  * 输出流:结果行 = stdout;问句 ∥ 失败句 ∥ 一次性提示 = stderr(问句先例 = setup-wizard.mjs `ask`)。
12
12
  * 返回 = 退出码(0 成 ∥ 1 败);未知参 ∥ 缺子命令 ⇒ usage + 1(fail-closed,先例 ledger-read.mjs)。
13
- * 词面导出面(登录面补全批 · 2026-10-10):四句闭集表 ∥ 未登录句 ∥ 两条一次性提示 ∥ 结果行首句
13
+ * 词面导出面(登录面补全批 · 2026-10-10):五句闭集表 ∥ 未登录句 ∥ 三条一次性提示 ∥ 结果行
14
14
  * ∥ `renderState`——TUI 面(`src/tui/cmd-team.mjs`)逐字同源消费(判据「CLI = 单语直出同句」),
15
15
  * 本档行为零变(导出关键字与常量收拢;出词 ∥ 退出码 ∥ 旗标面逐字不动)。
16
16
  */
17
17
  import { createInterface } from "node:readline"
18
18
 
19
- import { teamLogin, teamLogout, teamStatus, NOTICE_MANUAL_NAME_CONFLICT } from "@thincoder/core/team.mjs"
19
+ import { teamLogin, teamLogout, teamRotate, teamStatus, NOTICE_MANUAL_NAME_CONFLICT } from "@thincoder/core/team.mjs"
20
20
 
21
21
  /** 命令面 usage(未知参 / 缺子命令 ⇒ stderr + 退出 1)。 */
22
- const TEAM_USAGE = "Usage: thincoder team login [--server <url>] [--user <name>] | thincoder team logout | thincoder team status"
22
+ const TEAM_USAGE = "Usage: thincoder team login [--server <url>] [--user <name>] | thincoder team logout | thincoder team rotate | thincoder team status"
23
23
 
24
- /** 失败出词四句(TEAM.md §2.5 失败理由域;核 `reason` 四值闭集 ⇔ 四句——三端逐字同句)。 */
24
+ /** 失败出词五句(TEAM.md §2.5 失败理由域;核 `reason` 五值闭集 ⇔ 五句——三端逐字同句)。 */
25
25
  export const FAILURE_TEXT = {
26
26
  network: "网络不可达——请检查地址与端口",
27
27
  credentials: "用户名或密码错误",
28
28
  rate_limited: "登录尝试过于频繁",
29
29
  write_failed: "本机配置写入失败",
30
+ invalid: "已失效——重新登录",
30
31
  }
31
32
 
32
33
  /** 未登录提示(§2.5 未登录行——三端逐字同句)+ 指引进登录。 */
@@ -41,17 +42,49 @@ export const TEXT_LOGGED_OUT = "Logged out."
41
42
  export const TEXT_MANUAL_CONFLICT = "已存在同名 provider「team」——未自动添加;请改名或删除后重登"
42
43
  export const TEXT_REVOKE_UNDELIVERED = "服务端吊销未达"
43
44
 
45
+ /** 轮换两串(§2.7——三端逐字同句):确认句(后果句一步——确认 ∥ 取消)∥ 成句(结果行直出)。 */
46
+ export const TEXT_ROTATE_CONFIRM = "轮换将立即吊销当前登录 token(旧 token 失效),本机随即改用新 token。继续?"
47
+ export const TEXT_ROTATED = "已轮换——本机已改用新 token"
48
+
44
49
  /** 命令入口(`bin/thincoder.mjs` → command-table 分发):返回退出码(0 成 ∥ 1 败)。 */
45
50
  export async function teamCommand(args) {
46
51
  const argv = Array.isArray(args) ? args : []
47
52
  const sub = argv[0]
48
53
  if (sub === "login") return runLogin(argv.slice(1))
49
54
  if (sub === "logout") return runLogout(argv.slice(1))
55
+ if (sub === "rotate") return runRotate(argv.slice(1))
50
56
  if (sub === "status") return runStatus(argv.slice(1))
51
57
  console.error(TEAM_USAGE)
52
58
  return 1
53
59
  }
54
60
 
61
+ /** `team rotate`(§2.7):未登录 ⇒ 未登录提示(幂等——退出码 0);确认一步(后果句 ⇒ y/N)⇒ 核
62
+ * `teamRotate`(写盘单源);取消 ∥ 未确认(非 y ∥ EOF)⇒ 零动作(零请求零写盘);成 ⇒ 成句直出。 */
63
+ async function runRotate(rest) {
64
+ if (rest.length > 0) {
65
+ console.error(TEAM_USAGE)
66
+ return 1
67
+ }
68
+ if (teamStatus().loggedIn !== true) {
69
+ printNotLoggedIn()
70
+ return 0
71
+ }
72
+ const input = createInput()
73
+ try {
74
+ const answer = await input.ask(`${TEXT_ROTATE_CONFIRM} [y/N] `)
75
+ if (answer.trim().toLowerCase() !== "y") return 0 // 取消 ∥ 未确认(非 y 应答 ∥ EOF)⇒ 零请求零写盘
76
+ const result = await teamRotate()
77
+ if (result.ok !== true) {
78
+ console.error(FAILURE_TEXT[result.reason] ?? FAILURE_TEXT.network) // 401 ⇒ `invalid` ⇔「已失效——重新登录」
79
+ return 1
80
+ }
81
+ console.log(TEXT_ROTATED) // 结果行 = 成句直出(同句集;`Rotated.` 径弃用)
82
+ return 0
83
+ } finally {
84
+ input.close()
85
+ }
86
+ }
87
+
55
88
  /** `team login`:收集(旗标 ∥ 问句)⇒ 核 `teamLogin`(写盘单源)⇒ 出词。 */
56
89
  async function runLogin(rest) {
57
90
  const flags = parseLoginArgs(rest)
@@ -34,7 +34,7 @@ export async function chatCommand(args, ctx) {
34
34
  // 与 TUI 面同式):**invalid 类**(`state === "invalid"` ∨ `providerInvalidReason` 非空——无渠/key
35
35
  // ⇒ 不可运行)⇒ 可读错误 + 退出码 1(不弹 UI、不崩溃);**fallback**(无有效 defaultModel 但可运行)
36
36
  // ⇒ stderr 一行明示 + 继续运行(不退出——D-S2 同态同解)。条目结构不全不在本门(负向锁 =
37
- // PROVIDER.md:437)——归运行期失败径(stderr + 非 0 退出)。
37
+ // PROVIDER.md §6.22)——归运行期失败径(stderr + 非 0 退出)。
38
38
  const headlessCfg = agent.config ?? {}
39
39
  const invalidClass = headlessCfg.providerState === "invalid"
40
40
  || (typeof headlessCfg.providerInvalidReason === "string" && headlessCfg.providerInvalidReason !== "")
@@ -136,7 +136,8 @@ export async function tuiCommand(ctx) {
136
136
  if (agent.config?.providerState === "invalid") agent.provider = null
137
137
  const config = loadConfig()
138
138
  if (data) {
139
- // applySession 内部已按槽复合重算 compactThreshold(auto 时)——不再需要 switched 分支
139
+ // applySession 内部已按槽复合刷新显示面 compactThresholdResolved(auto 时)——判定阈值由
140
+ // setup.mjs 每 run 现算(§6.17),此处不再需要 switched 分支
140
141
  // TUI-OOM-ROOTCAUSE(SESSION.md §6.14):传 slot → 绑定记录存储(身份核验 + 对账)
141
142
  // ——人读线 = 尾窗(磁盘为准);未传 = 模式 F(全量数组)
142
143
  applySession(agent, data, { slot })
@@ -30,7 +30,7 @@ export function printCompletion(shell) {
30
30
  list) COMPREPLY=( $(compgen -W "--json --full --family --cwd" -- "$cur") ) ;;
31
31
  esac ;;
32
32
  team) case "$prev" in
33
- team) COMPREPLY=( $(compgen -W "login logout status" -- "$cur") ) ;;
33
+ team) COMPREPLY=( $(compgen -W "login logout rotate status" -- "$cur") ) ;;
34
34
  login) COMPREPLY=( $(compgen -W "--server --user" -- "$cur") ) ;;
35
35
  esac ;;
36
36
  distill) COMPREPLY=( $(compgen -W "--yes --layer=" -- "$cur") ) ;;
@@ -65,7 +65,7 @@ _thincoder() {
65
65
  'completion[Generate shell completion script]' \\
66
66
  'session[Session dir GC: session gc --dry-run|--confirm]' \\
67
67
  'ledger[Ledger variants: migrate / audit / list]' \\
68
- 'team[Team login: login / logout / status]'
68
+ 'team[Team login: login / logout / rotate / status]'
69
69
  ;;
70
70
  args)
71
71
  case "$words[1]" in
@@ -105,7 +105,7 @@ complete -c thincoder -a completion -d 'Shell completion'
105
105
  complete -c thincoder -a session -d 'Session dir GC (session gc --dry-run|--confirm)'
106
106
  complete -c thincoder -a ledger -d 'Ledger variants: migrate / audit / list'
107
107
  complete -c thincoder -a acp -d 'Agent Client Protocol server for IDEs'
108
- complete -c thincoder -a team -d 'Team login: login / logout / status'
108
+ complete -c thincoder -a team -d 'Team login: login / logout / rotate / status'
109
109
 
110
110
  # Flags
111
111
  complete -c thincoder -s v -l version -d 'Print version'
@@ -148,7 +148,7 @@ complete -c thincoder -n '__fish_seen_subcommand_from ledger' -l dry-run -l conf
148
148
  complete -c thincoder -n '__fish_seen_subcommand_from ledger; and __fish_seen_subcommand_from list' -l json -l full -l family -l cwd -d 'Ledger list flags'
149
149
 
150
150
  # team subcommands / flags
151
- complete -c thincoder -n '__fish_seen_subcommand_from team' -a 'login logout status' -d 'Team login commands'
151
+ complete -c thincoder -n '__fish_seen_subcommand_from team' -a 'login logout rotate status' -d 'Team login commands'
152
152
  complete -c thincoder -n '__fish_seen_subcommand_from team; and __fish_seen_subcommand_from login' -l server -d 'Team server URL'
153
153
  complete -c thincoder -n '__fish_seen_subcommand_from team; and __fish_seen_subcommand_from login' -l user -d 'Team user name'
154
154
  `)
@@ -23,7 +23,7 @@
23
23
  import { resolveShellIdentity, executorLine } from "@thincoder/core/shell-identity.mjs"
24
24
  import { loadConfig } from "@thincoder/core/config.mjs"
25
25
 
26
- // 配置读容错(先例 = `bin/thincoder.mjs:54` 同式「配置缺失/损坏 ⇒ 各向默认」):读取失败不阻断进程,
26
+ // 配置读容错(先例 = `bin/thincoder.mjs` 同式「配置缺失/损坏 ⇒ 各向默认」):读取失败不阻断进程,
27
27
  // 读失败 ⇒ null ⇒ 默认链(fail-open——探测面不猜)。
28
28
  function configShell() {
29
29
  try { return loadConfig()?.shell ?? null } catch { return null }
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { runAgent } from "@thincoder/core/agent.mjs"
18
18
  import { saveSession } from "@thincoder/core/session.mjs"
19
+ import { t } from "@thincoder/core/i18n.mjs" // 回合停止行词面单源(SESSION.md §6.26):键 status.stopped
19
20
  import { continueDecision } from "@thincoder/core/agent/continue-decision.mjs" // #677 · I10 续跑判定单源(#127 ④ 双写退役)
20
21
  import { ansi, C } from "./ansi.mjs"
21
22
  import { buildToolCallbacks, sweepToolBlocks } from "./tool-events.mjs"
@@ -106,7 +107,7 @@ async function runAgentTurnInner(ctx, text, opts) {
106
107
  /** runAgentTurn 正文(原 `runAgentTurnInner` 逐字——唯一改动 = 链尾 `sync()` 上收收口层 `finally`)。 */
107
108
  async function runAgentTurnBody(ctx, text, opts) {
108
109
  const { autoTurn = false, skipSession = false, upstreamTurn = false, timerTurn = false } = opts ?? {} // upstreamTurn / timerTurn:系统轮旗标(§6.27.12.5 D/I · §6.30.3 D-TW4)——透传核 `runAgent`,仅供域文本选择
109
- const { agent, state, pushLine, pushLabel, render, scheduleRender, ensureAssistantLabel, askPermission, askBatchPermission, askQuestion, handleSlash } = ctx
110
+ const { agent, state, pushLine, pushLabel, render, scheduleRender, ensureAssistantLabel, askPermission, askBatchPermission, askQuestion, askSecretInput, handleSlash } = ctx
110
111
  // 可注入覆盖(测试用);默认走真实实现
111
112
  const runAgentImpl = ctx.runAgent ?? runAgent
112
113
  const saveSessionImpl = ctx.saveSession ?? saveSession
@@ -181,7 +182,7 @@ async function runAgentTurnBody(ctx, text, opts) {
181
182
  render()
182
183
 
183
184
  const { callbacks, flushStream } = buildToolCallbacks({
184
- agent, state, pushLine, render, scheduleRender, ensureAssistantLabel, askPermission, askBatchPermission, askQuestion, saveSessionImpl,
185
+ agent, state, pushLine, render, scheduleRender, ensureAssistantLabel, askPermission, askBatchPermission, askQuestion, askSecretInput, saveSessionImpl,
185
186
  })
186
187
 
187
188
  // try/finally: every exit path — including an unexpected throw inside the catch
@@ -218,7 +219,7 @@ async function runAgentTurnBody(ctx, text, opts) {
218
219
  const h = agent.history
219
220
  while (h?.length > 0 && String(h.at(-1)?.content ?? "") === "[User interrupt: undefined]") h.pop()
220
221
  }
221
- pushLine("[stopped]", C.warn)
222
+ pushLine(t("status.stopped"), C.warn)
222
223
  // #448② KD-6「显式撤销」:Ctrl+C 全停(`{ abortTrigger: "stop" }`——key-handler 二按语义)
223
224
  // ⇒ 落粘滞位:链尾闩不重武装(链头复位后新链恢复——见 `timerRearmBlocked`)。
224
225
  if (reason?.abortTrigger === "stop") state._timerRearmRevoked = true
@@ -262,7 +263,7 @@ async function runAgentTurnBody(ctx, text, opts) {
262
263
  }
263
264
  // decision === "error":其余异常 —— provider 失败面(X8 原语义)——
264
265
  // X8(2026-09-20 端差·显示面消差批):provider 失败面 = 友好首行(判据同 VSC
265
- // panel-turn-loop.mjs:152-153:原文首行 + URL 脱敏)+ 诊断两行(Provider/Model)+ Retry
266
+ // panel-turn-loop.mjs:原文首行 + URL 脱敏)+ 诊断两行(Provider/Model)+ Retry
266
267
  // 询问(复用 permission 机制——同意 ⇒ 重建 controller + resume 重入,与 ContinueError
267
268
  // 同法;拒绝 ⇒ 现状 break,[error] 行保留)。
268
269
  const rawMsg = error?.message || String(error)
@@ -47,6 +47,14 @@ export function askMaskActive(state) {
47
47
  return face != null && teamAskStepAt(face.step)?.mask === true
48
48
  }
49
49
 
50
+ /** 掩码族在场判据(三面:凭据窗整面 ∥ 团队问句面整面 ∥ 密码步 `askMaskActive`)——搜索层让位
51
+ * 单源(#1437 自 `key-handler-search.mjs` 本地件迁入:键路由 ∥ 显示面两用同引——两处分开写
52
+ * 必然漂移,故收敛一档)。消费点 = `key-handler-search.mjs`(逐键重判)∥ `layout.mjs` 输入框
53
+ * 内容式 ∥ `render-frame.mjs` 框题式(判据单源 = `docs/cli/design/TUI.md` §4 掩码守卫)。 */
54
+ export function maskSurfacePresent(state) {
55
+ return state.secretPrompt != null || state.teamAsk != null || askMaskActive(state)
56
+ }
57
+
50
58
  /** 问句屏行构造(两消费方共用):已填两值(地址 ∥ 账号——密码恒不示)作 dim 上下文行 +
51
59
  * 加粗问句行 + 输入提示行。`fields` 缺省 = 零上下文行。 */
52
60
  export function teamAskLines(step, fields = {}) {
@@ -137,9 +137,9 @@ export async function handleAdvisorCommand(ctx) {
137
137
  pushLabel("❯ Advisor", ansi.bold + C.tool)
138
138
  pushLine("Thinking: OFF", C.tool)
139
139
  } else if (c.action === "effort_none") {
140
- // 归一(镜像 `cmd-think.mjs:104` 归一式 / `:127` 删档 / `:82` 回执):档位 `none` 不是
140
+ // 归一(镜像 `cmd-think.mjs` 归一式 / 删档 / 回执):档位 `none` 不是
141
141
  // 「强度零」而是**关思考**——与菜单 off 项同语义。不归一则残留 `reasoningEffort:"none"`
142
- // 被载荷层当强度档送(`provider/core.mjs:197-204`)⇒ 与 off 形矛盾同发、服务端仍思考。
142
+ // 被载荷层当强度档送(`provider/core.mjs`)⇒ 与 off 形矛盾同发、服务端仍思考。
143
143
  delete cfg.reasoningEffort
144
144
  await applyThinkOff()
145
145
  await persist()
@@ -147,7 +147,7 @@ export async function handleAdvisorCommand(ctx) {
147
147
  pushLine("Thinking: OFF", C.tool)
148
148
  } else if (c.action.startsWith("effort_")) {
149
149
  // #346-①(§16.4 表末行):选档 = 要思考 ⇒ 先清 `thinking === null` 标记(对齐
150
- // `cmd-think.mjs:119-120` 先例 / §15.4-2 末句);`{type:"disabled"}` 不动(同先例;
150
+ // `cmd-think.mjs` 先例 / §15.4-2 末句);`{type:"disabled"}` 不动(同先例;
151
151
  // 残余登记 = §16.6-⑸——type 族 off ⇒ 选档 后该标记保持)。
152
152
  if (cfg.thinking === null) delete cfg.thinking
153
153
  cfg.reasoningEffort = c.action.slice(7)