thincoder 0.12.74 → 0.12.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +6 -0
- package/bin/thincoder.mjs +1 -0
- package/package.json +2 -2
- package/src/acp/bridge.mjs +14 -5
- package/src/acp/handlers-session.mjs +1 -1
- package/src/acp/handlers-slots.mjs +6 -4
- package/src/acp/read-data.mjs +4 -1
- package/src/acp/session.mjs +5 -4
- package/src/acp.mjs +7 -2
- package/src/cli/make-agent.mjs +1 -1
- package/src/cli/team-command.mjs +41 -8
- package/src/command-interactive.mjs +1 -1
- package/src/completions.mjs +4 -4
- package/src/prompt-injections.mjs +1 -1
- package/src/tui/agent-turn.mjs +5 -4
- package/src/tui/ask-steps.mjs +8 -0
- package/src/tui/cmd-advisor.mjs +3 -3
- package/src/tui/cmd-config.mjs +28 -3
- package/src/tui/cmd-eng.mjs +7 -5
- package/src/tui/cmd-session.mjs +7 -5
- package/src/tui/cmd-team.mjs +41 -9
- package/src/tui/cmd-think.mjs +3 -3
- package/src/tui/cmd-timers.mjs +9 -5
- package/src/tui/index.mjs +1 -1
- package/src/tui/interaction.mjs +13 -1
- package/src/tui/key-handler-modals.mjs +16 -1
- package/src/tui/key-handler-search.mjs +11 -1
- package/src/tui/key-handler.mjs +10 -1
- package/src/tui/layout.mjs +14 -6
- package/src/tui/lifecycle-records.mjs +9 -3
- package/src/tui/model-picker.mjs +1 -1
- package/src/tui/pickers.mjs +1 -1
- package/src/tui/provider-admin.mjs +2 -2
- package/src/tui/queued-pickup.mjs +1 -1
- package/src/tui/render-frame.mjs +17 -183
- package/src/tui/render-segments.mjs +19 -8
- package/src/tui/secret-prompt.mjs +202 -0
- package/src/tui/slash-commands.mjs +4 -2
- package/src/tui/status-line.mjs +197 -0
- package/src/tui/subagent-freeze.mjs +16 -10
- package/src/tui/suspension-drive.mjs +2 -2
- package/src/tui/timer-watch.mjs +1 -1
- package/src/tui/tool-events.mjs +19 -11
- package/src/tui/tui-state.mjs +1 -0
- package/src/tui/turn-face.mjs +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [0.12.75] — 2026-10-16
|
|
2
|
+
|
|
3
|
+
> 0.12.74 → 0.12.75(连续号——发布时定号)
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **核依赖升级**:`@thincoder/core` `^0.10.7` → `^0.10.8`(内建 `doc_check` ∥ 台账根读写同一推导随核生效)。
|
|
8
|
+
- **提示词面收正**:中文 = 设计文档 ∥ 英文 = 代码 口径落地;运行面去文档引用(P1/P3/P4);联网查证指导入册;S1/S2 优化。
|
|
9
|
+
- **登录成拍模型候选面即时刷新**(三端同拍)。
|
|
10
|
+
- **文档纪律面**:行宽口径定形 ∥ 陈旧引用/取值清扫 ∥ C 族行数声明面退役 ∥ R2 层前缀引称落地 ∥ 指针纪律收正(禁行号引)。
|
|
11
|
+
|
|
1
12
|
## [0.12.74] — 2026-10-14
|
|
2
13
|
|
|
3
14
|
> 0.12.73 → 0.12.74(连续号——发布时定号)
|
package/README.md
CHANGED
|
@@ -231,6 +231,12 @@ Code conventions: pure `.mjs`, no semicolons, no third-party npm dependencies al
|
|
|
231
231
|
|
|
232
232
|
## Changelog
|
|
233
233
|
|
|
234
|
+
### 0.12.75 (2026-10)
|
|
235
|
+
- **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.
|
|
236
|
+
- Prompt-face corrections: Chinese = design docs / English = code split landed; runtime face doc-reference removal; online-verification guidance; S1/S2 tuning.
|
|
237
|
+
- Login-time model candidate refresh (all three ends).
|
|
238
|
+
- Doc-discipline round: line-width criterion fixed, stale references swept, C-family line-count statements retired, R2 citation landing, no-line-number-citation discipline.
|
|
239
|
+
|
|
234
240
|
### 0.12.74 (2026-10)
|
|
235
241
|
- **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
242
|
|
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.
|
|
3
|
+
"version": "0.12.75",
|
|
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.
|
|
23
|
+
"@thincoder/core": "^0.10.8"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"bin/",
|
package/src/acp/bridge.mjs
CHANGED
|
@@ -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 } }
|
|
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
|
|
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
|
|
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
|
|
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
|
-
//
|
|
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
|
}
|
package/src/acp/read-data.mjs
CHANGED
|
@@ -97,7 +97,10 @@ export function createReadDataHandlers(ctx, { intervalMs = WATCH_INTERVAL_MS } =
|
|
|
97
97
|
try {
|
|
98
98
|
const cwd = ctx.getCwd()
|
|
99
99
|
const { ledgerDb, batchRead } = await core()
|
|
100
|
-
|
|
100
|
+
// 观察域根 = 判据单源 `resolveLedgerRoot`(与写入面同源):根 ⇒ 其键控库指纹;无根 ⇒ 该域无台账库、
|
|
101
|
+
// 指纹恒 "0"(观察域照常上报——键控库在盘 / 变动即报 `ledger/changed`)。
|
|
102
|
+
const root = ledgerDb.resolveLedgerRoot(cwd)?.root
|
|
103
|
+
const ledgerSig = root ? fileSig(ledgerDb.ledgerDbPath(root)) : "0"
|
|
101
104
|
const batchSig = batchRead.listBatchRecords({ cwd }).batches.map((b) => `${b.path}:${fileSig(b.path)}`).join("|")
|
|
102
105
|
if (!last || last.cwd !== cwd) { last = { cwd, ledgerSig, batchSig }; return [] } // 首查 / 观察域切换 ⇒ 立基线(静默)
|
|
103
106
|
const fired = []
|
package/src/acp/session.mjs
CHANGED
|
@@ -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
|
|
8
|
-
* anthropic.mjs
|
|
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
|
-
|
|
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
|
/**
|
package/src/cli/make-agent.mjs
CHANGED
|
@@ -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
|
|
110
|
+
* 与 `applySession` 同款——`thincoder-core/session.mjs`)。普通会话 → **装配钩子
|
|
111
111
|
* 零 manifest I/O**(不读 / 不拒 / 不建档)+ `agent.manifest = null`(清残留附着——复用
|
|
112
112
|
* agent 跨模式防陈旧)。
|
|
113
113
|
*
|
package/src/cli/team-command.mjs
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
|
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 !== "")
|
package/src/completions.mjs
CHANGED
|
@@ -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
|
|
26
|
+
// 配置读容错(先例 = `bin/thincoder.mjs` 同式「配置缺失/损坏 ⇒ 各向默认」):读取失败不阻断进程,
|
|
27
27
|
// 读失败 ⇒ null ⇒ 默认链(fail-open——探测面不猜)。
|
|
28
28
|
function configShell() {
|
|
29
29
|
try { return loadConfig()?.shell ?? null } catch { return null }
|
package/src/tui/agent-turn.mjs
CHANGED
|
@@ -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("
|
|
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
|
|
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)
|
package/src/tui/ask-steps.mjs
CHANGED
|
@@ -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 = {}) {
|
package/src/tui/cmd-advisor.mjs
CHANGED
|
@@ -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
|
|
140
|
+
// 归一(镜像 `cmd-think.mjs` 归一式 / 删档 / 回执):档位 `none` 不是
|
|
141
141
|
// 「强度零」而是**关思考**——与菜单 off 项同语义。不归一则残留 `reasoningEffort:"none"`
|
|
142
|
-
// 被载荷层当强度档送(`provider/core.mjs
|
|
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
|
|
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)
|
package/src/tui/cmd-config.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ansi, C } from "./ansi.mjs"
|
|
2
2
|
import { probeChannelModels, dedupeModels } from "./model-catalog.mjs"
|
|
3
|
+
// 派生条目隐藏判据单源(TEAM.md §2.4——#1223:/config 渠道读面过滤)
|
|
4
|
+
import { isDerivedProviderHidden } from "./provider-admin.mjs"
|
|
3
5
|
import { probeTargetOf } from "@thincoder/core/provider-flows.mjs"
|
|
4
6
|
/** Merge an embedding-key save into the raw config, backfilling baseURL/model from defaults.
|
|
5
7
|
* Keeps existing custom values (Ollama/local embedding); defaults are the single source
|
|
@@ -23,7 +25,7 @@ export function poolCur(pl, defaults) {
|
|
|
23
25
|
|
|
24
26
|
/** Effort 菜单档位构造(#16 双 `none` 去重——枚举自带 `none` 的族如 qwen3.8-flash 时原来出两行):
|
|
25
27
|
* `none` 恒为首项且唯一,其余档序保持(`filter` 保序)。语义面零改——`none` = 清档,
|
|
26
|
-
*
|
|
28
|
+
* 消费点(`consultMenu` 两支)只认 `=== "none"`;空枚举在 `pickEffort` 处已早退 null、不经本函数。
|
|
27
29
|
* Exported for unit tests (`cmd-config-effort.test.mjs`). */
|
|
28
30
|
export function effortMenuLevels(enumList) {
|
|
29
31
|
return ["none", ...(enumList ?? []).filter((l) => l !== "none")]
|
|
@@ -289,9 +291,10 @@ export async function handleConfigCommand(ctx, args = []) {
|
|
|
289
291
|
let idx = 0
|
|
290
292
|
// M9 配置阶段准入:进本子菜单探一次各渠道 `/models`(复用 M1 + 会话缓存)。
|
|
291
293
|
// 探通 → 渠道可用 + 候选直接可用;探不通 → 不缓存不阻断(标「不可用」且不入可选来源)。
|
|
294
|
+
// #1223(TEAM.md §2.4 六消费面):派生无 key 条目隐藏——探针 ∥ 条目录入两面同过滤。
|
|
292
295
|
const probes = new Map()
|
|
293
296
|
pushLine("Fetching channel model lists (GET /models)…", C.dim)
|
|
294
|
-
await Promise.all(agent.providers.map(async (p) => {
|
|
297
|
+
await Promise.all(agent.providers.filter((p) => !isDerivedProviderHidden(p)).map(async (p) => {
|
|
295
298
|
const r = await probeChannelModels(probeTargetOf(p)) // 探针目标构造收敛核判据(③′——逐渠旗 ∧ `uri` 在案;执行体零改)
|
|
296
299
|
probes.set(p.name, r)
|
|
297
300
|
if (r.ok) delete p._unavailable
|
|
@@ -301,7 +304,7 @@ export async function handleConfigCommand(ctx, args = []) {
|
|
|
301
304
|
const dm = agent.config?.defaultModel ?? null
|
|
302
305
|
const entries = [
|
|
303
306
|
{ type: "header", text: `config.defaultModel = ${dm ?? "(not set — 新会话起点未配置)"}` },
|
|
304
|
-
...agent.providers.map((p) => {
|
|
307
|
+
...agent.providers.filter((p) => !isDerivedProviderHidden(p)).map((p) => {
|
|
305
308
|
const r = probes.get(p.name)
|
|
306
309
|
if (!r?.ok) return { type: "item", text: `${p.name.padEnd(10)} 不可用`, action: "provider", provider: p.name, unavailable: true }
|
|
307
310
|
const n = r.list.length
|
|
@@ -356,6 +359,9 @@ export async function handleConfigCommand(ctx, args = []) {
|
|
|
356
359
|
{ type: "item", text: `traces.enabled = ${tc.enabled === false ? "off" : "on"}(轨迹存档——发布默认关——隐私)`, action: "traces.enabled" },
|
|
357
360
|
{ type: "item", text: `traces.retentionHours = ${tc.retentionHours ?? 24} h(超期文件启动时清理)`, action: "traces.retentionHours" },
|
|
358
361
|
{ type: "item", text: `diagnostics.heapSnapshot = ${dc.heapSnapshot === true ? "on" : "off"}(堆快照采集——默认关——桌面会话即时生效)`, action: "diagnostics.heapSnapshot" },
|
|
362
|
+
{ type: "item", text: `agent.injectProjectRules = ${ac.injectProjectRules !== false ? "on" : "off"}(项目指令注入——AGENTS.md / project_rules.md——默认开)`, action: "agent.injectProjectRules" },
|
|
363
|
+
{ type: "item", text: `agent.injectDocs = ${ac.injectDocs !== false ? "on" : "off"}(文档注入——相关文档自动检索——默认开)`, action: "agent.injectDocs" },
|
|
364
|
+
{ type: "item", text: `agent.injectMemories = ${ac.injectMemories !== false ? "on" : "off"}(记忆注入——往期相关记忆召回——默认开)`, action: "agent.injectMemories" },
|
|
359
365
|
{ type: "item", text: `agent.consultModels = ${consultCount} model(s)${consultCount ? ` (${(ac.consultModels ?? []).map((m) => m.provider + ":" + m.model).join(", ")})` : ""}`, action: "consult" },
|
|
360
366
|
{ type: "item", text: `agent.consultTurns = ${ac.consultTurns ?? 40}`, action: "agent.consultTurns" },
|
|
361
367
|
{ type: "item", text: `agent.consultTimeoutMs = ${Math.round((ac.consultTimeoutMs ?? 600000) / 60000)} min`, action: "agent.consultTimeoutMs" },
|
|
@@ -380,6 +386,9 @@ export async function handleConfigCommand(ctx, args = []) {
|
|
|
380
386
|
pushLine(`traces.enabled: ${tc.enabled === false ? "off" : "on"}(默认 off——发布隐私——本地分析可开)`, C.dim)
|
|
381
387
|
pushLine(`traces.retentionHours: ${tc.retentionHours ?? 24}(超期文件启动清理——D-TR10)`, C.dim)
|
|
382
388
|
pushLine(`diagnostics.heapSnapshot: ${dc.heapSnapshot === true ? "on" : "off"}(堆快照采集——默认关——桌面会话即时生效)`, C.dim)
|
|
389
|
+
pushLine(`agent.injectProjectRules: ${ac.injectProjectRules !== false ? "on" : "off"}(项目指令注入——AGENTS.md / project_rules.md——默认开)`, C.dim)
|
|
390
|
+
pushLine(`agent.injectDocs: ${ac.injectDocs !== false ? "on" : "off"}(文档注入——相关文档自动检索——默认开)`, C.dim)
|
|
391
|
+
pushLine(`agent.injectMemories: ${ac.injectMemories !== false ? "on" : "off"}(记忆注入——往期相关记忆召回——默认开)`, C.dim)
|
|
383
392
|
pushLine(`agent.consultModels: ${(ac.consultModels ?? []).map((m) => `${m.provider}:${m.model}${m.effort ? ` (${m.effort})` : ""}`).join(", ") || "(none)"}`, C.dim)
|
|
384
393
|
pushLine(`agent.poolLimits: { engCoder: ${cur("engCoder")}, other: ${cur("other")}, advisor: ${cur("advisor")} }(async 分域上限——默认 4/4/4——agent.poolLimits 可配)`, C.dim)
|
|
385
394
|
pushLine(`agent.consultTurns: ${ac.consultTurns ?? 40}`, C.dim)
|
|
@@ -452,6 +461,22 @@ export async function handleConfigCommand(ctx, args = []) {
|
|
|
452
461
|
continue // 回主菜单(Esc 退出)
|
|
453
462
|
}
|
|
454
463
|
|
|
464
|
+
if (choice.action === "agent.injectProjectRules" || choice.action === "agent.injectDocs" || choice.action === "agent.injectMemories") {
|
|
465
|
+
// 注入开关(PROMPT-SYSTEM.md §6.24 §6.27 · 台账 #1420 #1465):判据 `!== false`(缺省 = 开)——三键共用一支;
|
|
466
|
+
// 保存经 saveProxy(写盘 + reloadConfig 即热——下一次提示词组装生效,无「重启」注)。
|
|
467
|
+
const key = choice.action.slice("agent.".length)
|
|
468
|
+
const newVal = ac[key] === false // 现为关 ⇒ 写 true;现为开(含缺省)⇒ 写 false
|
|
469
|
+
try {
|
|
470
|
+
await saveProxy((raw) => {
|
|
471
|
+
raw.agent ??= {}
|
|
472
|
+
raw.agent[key] = newVal
|
|
473
|
+
})
|
|
474
|
+
pushLabel("❯ Config", ansi.bold + C.tool)
|
|
475
|
+
pushLine(`${choice.action} = ${newVal ? "on" : "off"}(即热——下一次提示词组装生效)`, C.tool)
|
|
476
|
+
} catch (error) { pushLine(`Save failed: ${error.message}`, C.error) }
|
|
477
|
+
continue // 回主菜单(Esc 退出)
|
|
478
|
+
}
|
|
479
|
+
|
|
455
480
|
// Embedding model is fixed (BAAI/bge-m3, SiliconFlow) — no picker; it's over-engineering
|
|
456
481
|
// to expose model choice when the vector index format assumes one embedding space.
|
|
457
482
|
|
package/src/tui/cmd-eng.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** /eng command: toggle engineering mode.
|
|
2
|
-
* No retired-concept prerequisites (FR11 收正口径 — `docs/core/requirements/PORTABILITY.md
|
|
3
|
-
* no methodology file, no docs tree.
|
|
4
|
-
*
|
|
2
|
+
* No retired-concept prerequisites (FR11 收正口径 — `docs/core/requirements/PORTABILITY.md` §5.1):
|
|
3
|
+
* no methodology file, no docs tree. **可拒面 = 仅「档非法」一格**(工作区 `workspace` 放行):
|
|
4
|
+
* 该格上 ON = 拒翻 + 明示原因、模式保持 OFF(#41 —
|
|
5
5
|
* `docs/core/design/MANIFEST.md` §2.8 F2/F3;判定面 = 入口决策树单源)。
|
|
6
6
|
* ctx: { agent, pushLine, pushLabel } */
|
|
7
7
|
import { readFileSync, writeFileSync, mkdirSync, renameSync, unlinkSync } from "node:fs"
|
|
@@ -37,16 +37,18 @@ export async function handleEngCommand(ctx) {
|
|
|
37
37
|
//
|
|
38
38
|
// #41 先判后翻(MANIFEST.md §2.8 F2/F3 · KD-M1-21):**ON 方向**先走入口决策树单源
|
|
39
39
|
// (resolveEngineeringManifest——KD-M1-20),判据通过才写态;OFF 方向零改(F2 表 OFF 行)。
|
|
40
|
+
// **可拒面 = 仅「档非法」格**(工作区 `workspace` ⇒ 放行——放行 ⇒ **零附着**,模式照开)。
|
|
40
41
|
// 拒 ⇒ warn 行 + **零标签**(标签 = 成功回显——拒时零标签防假成功)+ 零副作用
|
|
41
42
|
// (模式未翻 / token 未清 / `_advisorRuns` 未重置 / 提醒未入列 / 槽未写)。
|
|
42
43
|
// 准 ⇒ 缺档格就地建档(writer:'main')+ `agent.manifest` ← 结果(相位行当回合起活)。
|
|
43
44
|
if (!agent.config.agent.engineering) {
|
|
44
45
|
const r = resolveEngineeringManifest(agent.cwd ?? process.cwd(), { writer: "main" })
|
|
45
|
-
if (!r.ok) {
|
|
46
|
+
if (!r.ok && r.code !== "workspace") {
|
|
46
47
|
pushLine(`Engineering mode not enabled — ${r.message} (mode unchanged)`, C.warn)
|
|
47
48
|
return
|
|
48
49
|
}
|
|
49
|
-
agent.manifest = r.manifest
|
|
50
|
+
if (r.ok) agent.manifest = r.manifest
|
|
51
|
+
else agent.manifest = null // 工作区放行 ⇒ 零附着(显式置 null——§2.8 F2 放行行)
|
|
50
52
|
}
|
|
51
53
|
agent.config.agent.engineering = !agent.config.agent.engineering
|
|
52
54
|
// FR31 ③ / KD10(翻转点②·CLI `/eng`):ON ⇒ 清 plan 残留(内存位 + 未注入的 plan 提示语);
|
package/src/tui/cmd-session.mjs
CHANGED
|
@@ -96,7 +96,8 @@ export async function handleSessionCommand(ctx) {
|
|
|
96
96
|
// 会话写回目标槽 = 跨槽覆盖)。预读 = `loadSlotFile`(**纯读**——无认领副作用)。
|
|
97
97
|
// 触发条件 = 合值(遗留槽(无 `engineering` 字段)自工程会话切入时合值 = true ⇒ 预判据
|
|
98
98
|
// 照触发——F3 触发条件口径);槽不可读(preview null)不判:该次切换本就以「Slot not
|
|
99
|
-
// found」收场(switchToSlot 返回 null
|
|
99
|
+
// found」收场(switchToSlot 返回 null),无半态面。**可拒面 = 仅「档非法」格**(工作区
|
|
100
|
+
// `workspace` ⇒ 放行——放行 ⇒ **零附着**)。拒 ⇒ 切槽整体不发生(switchToSlot /
|
|
100
101
|
// applySession 均不调——零副作用)+ 原因行;准 ⇒ 既有切换 + applySession 之后一行附着。
|
|
101
102
|
const preview = loadSlotFile(agent.cwd, e.slot)
|
|
102
103
|
const slotEng = preview?.engineering
|
|
@@ -104,11 +105,11 @@ export async function handleSessionCommand(ctx) {
|
|
|
104
105
|
let manifestAfterSwitch = null
|
|
105
106
|
if (targetEng) {
|
|
106
107
|
const r = resolveEngineeringManifest(agent.cwd, { writer: "main" })
|
|
107
|
-
if (!r.ok) {
|
|
108
|
+
if (!r.ok && r.code !== "workspace") {
|
|
108
109
|
pushLine(`Cannot switch to slot ${e.slot} — ${r.message} (slot unchanged)`, C.warn)
|
|
109
110
|
return
|
|
110
111
|
}
|
|
111
|
-
manifestAfterSwitch = r.manifest
|
|
112
|
+
manifestAfterSwitch = r.ok ? r.manifest : null // 工作区放行 ⇒ 零附着(显式 null)
|
|
112
113
|
}
|
|
113
114
|
const data = switchToSlot(agent.cwd, e.slot)
|
|
114
115
|
if (!data) {
|
|
@@ -119,8 +120,9 @@ export async function handleSessionCommand(ctx) {
|
|
|
119
120
|
pushLine(`⚠ Slot ${e.slot} is being used by another live process (${occ.owner}) — continuing here will create a new copy on the next save`, C.warn)
|
|
120
121
|
}
|
|
121
122
|
applySession(agent, data, occ.occupied ? {} : { slot: e.slot })
|
|
122
|
-
// #41 准翻列:附着动作 = 翻转面自己赋值(`agent.manifest` ←
|
|
123
|
-
|
|
123
|
+
// #41 准翻列:附着动作 = 翻转面自己赋值(`agent.manifest` ← 判据结果——相位行当回合起活;
|
|
124
|
+
// 工作区放行 ⇒ 显式置 `null` = 零附着)。
|
|
125
|
+
if (targetEng) agent.manifest = manifestAfterSwitch
|
|
124
126
|
// Rebuild from history (lazy) — the display snapshot is deprecated.
|
|
125
127
|
// SESSION.md §6.14:描述符 { history(尾窗+±1), total, base }——标签口径 = total(非窗口长度);
|
|
126
128
|
// 未绑定(占用分支——模式 F)回退全量数组。
|