@miphamai/cli 0.85.6 → 0.85.8
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/package.json +1 -1
- package/src/agent-view/dashboard.tsx +7 -0
- package/src/core/context.ts +75 -39
- package/src/core/crsi-modify.ts +40 -3
- package/src/core/crsi-producer.ts +123 -8
- package/src/core/crsi-sandbox.ts +7 -0
- package/src/core/eval-harness.ts +38 -0
- package/src/core/instructions.ts +27 -3
- package/src/core/reward-fn.ts +10 -1
- package/src/core/session-log.ts +9 -0
- package/src/i18n-core/locales/en-US.json +0 -1
- package/src/i18n-core/locales/zh-CN.json +0 -1
- package/src/shared/package-info.ts +2 -2
- package/src/telemetry/consent.ts +50 -4
- package/src/telemetry/index.ts +27 -0
- package/src/tools/exec/task.ts +73 -61
- package/src/ui/commands.ts +86 -20
- package/src/ui/input.tsx +15 -9
- package/src/ui/picker.tsx +19 -15
- package/src/workflow/primitives/agent.ts +23 -7
package/src/core/reward-fn.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// 统一「给一个 policy 打分」:机制哨兵(runEval)与任务表现(runTaskPerformance)
|
|
3
3
|
// 都 conform 成 RewardFn,自改进环的 verify 阶段可对任意奖励源比分数、判退化。
|
|
4
4
|
import type { Llm } from '../providers/llm'
|
|
5
|
-
import { runEval, type EvalResult } from './eval-harness'
|
|
5
|
+
import { runEval, MIN_CONTRACT_COUNT, type EvalResult } from './eval-harness'
|
|
6
6
|
import { runTaskPerformance } from './task-performance'
|
|
7
7
|
|
|
8
8
|
/** 奖励函数统一输出的「分数」形状——所有 RewardFn 的 evaluate 都产出它。 */
|
|
@@ -19,6 +19,14 @@ export interface ScoreReport {
|
|
|
19
19
|
export interface RewardFn {
|
|
20
20
|
name: string
|
|
21
21
|
description: string
|
|
22
|
+
/**
|
|
23
|
+
* 该奖励源契约电池的**下限**:实际条数低于它即判「量具不可用」而非「判它差」。
|
|
24
|
+
*
|
|
25
|
+
* 只有**自己拥有电池**的奖励源才该声明它(机制哨兵声明 `MIN_CONTRACT_COUNT`)。
|
|
26
|
+
* 不声明的(如任务表现,或测试替身)只受「空契约集」这条普适判据约束 ——
|
|
27
|
+
* 拿我们的电池下限去卡第三方奖励源会把「它本来就报得少」误判成量具故障。
|
|
28
|
+
*/
|
|
29
|
+
minContracts?: number
|
|
22
30
|
evaluate(): Promise<ScoreReport> | ScoreReport
|
|
23
31
|
}
|
|
24
32
|
|
|
@@ -27,6 +35,7 @@ export function mechanismSentinel(): RewardFn {
|
|
|
27
35
|
return {
|
|
28
36
|
name: 'mechanism-sentinel',
|
|
29
37
|
description: '冻结契约评当前仓库机制代码(无 LLM)',
|
|
38
|
+
minContracts: MIN_CONTRACT_COUNT,
|
|
30
39
|
evaluate: () => runEval(),
|
|
31
40
|
}
|
|
32
41
|
}
|
package/src/core/session-log.ts
CHANGED
|
@@ -23,6 +23,9 @@ export type SessionEvent =
|
|
|
23
23
|
| { type: 'context/inject'; at: number; source: string; text: string }
|
|
24
24
|
| { type: 'compaction/summary'; at: number; summary: string; replacedCount: number }
|
|
25
25
|
| { type: 'compaction/rewrite'; at: number; messages: Message[] }
|
|
26
|
+
// 回退(`/rewind`)。投影语义与 `compaction/rewrite` 相同(整份快照替换),但**不是压缩**:
|
|
27
|
+
// 合用一个类型会让「这份日志里哪些轮被摘要过」的答案变成错的。
|
|
28
|
+
| { type: 'rewind'; at: number; messages: Message[] }
|
|
26
29
|
| { type: 'checker/decision'; at: number; toolName: string; decision: CheckerDecision }
|
|
27
30
|
|
|
28
31
|
export function messageToEvents(msg: Message, at = 0): SessionEvent[] {
|
|
@@ -110,6 +113,9 @@ export function deriveMessages(events: SessionEvent[]): Message[] {
|
|
|
110
113
|
} else if (e.type === 'compaction/rewrite') {
|
|
111
114
|
// 快照替换:整个投影重建(微压缩/截断等结构性编辑的字节级复现)
|
|
112
115
|
out = structuredClone(e.messages)
|
|
116
|
+
} else if (e.type === 'rewind') {
|
|
117
|
+
// 回退同样是快照替换:整份投影重建为回退到的那一点
|
|
118
|
+
out = structuredClone(e.messages)
|
|
113
119
|
}
|
|
114
120
|
// 'session/start' / 'checker/decision' → 无消息(决策仅记录证据,不进投影,保字节级可逆)
|
|
115
121
|
}
|
|
@@ -311,6 +317,9 @@ function isValidEvent(e: unknown): e is SessionEvent {
|
|
|
311
317
|
case 'compaction/rewrite':
|
|
312
318
|
// 快照替换:整份投影由它重建 ⇒ 元素形状与 message 事件同罪
|
|
313
319
|
return Array.isArray(ev.messages) && ev.messages.every(isValidMessage)
|
|
320
|
+
case 'rewind':
|
|
321
|
+
// 同上:回退也是整份投影替换,坏元素同样会让投影崩
|
|
322
|
+
return Array.isArray(ev.messages) && ev.messages.every(isValidMessage)
|
|
314
323
|
default:
|
|
315
324
|
return true
|
|
316
325
|
}
|
|
@@ -186,7 +186,6 @@
|
|
|
186
186
|
},
|
|
187
187
|
"task_list": {
|
|
188
188
|
"title": "── Background Tasks ──",
|
|
189
|
-
"detected": "{count} task operations detected in this session.\n\nUse the Task tool (action \"create\" / \"update\" / \"list\") to manage structured task tracking.",
|
|
190
189
|
"no_tasks": "No tasks tracked yet. Use the Task tool with action \"create\", \"update\", or \"list\" to manage structured tasks.",
|
|
191
190
|
"reference": "Quick reference:",
|
|
192
191
|
"legacy_hint": "Type /todos for the legacy task interface."
|
|
@@ -186,7 +186,6 @@
|
|
|
186
186
|
},
|
|
187
187
|
"task_list": {
|
|
188
188
|
"title": "── 后台任务 ──",
|
|
189
|
-
"detected": "在此会话中检测到 {count} 次任务操作。\n\n使用 Task 工具(action \"create\" / \"update\" / \"list\")管理结构化任务跟踪。",
|
|
190
189
|
"no_tasks": "尚未跟踪任何任务。使用 Task 工具的 action \"create\"、\"update\" 或 \"list\" 管理结构化任务。",
|
|
191
190
|
"reference": "快速参考:",
|
|
192
191
|
"legacy_hint": "输入 /todos 使用旧版任务界面。"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
export const PACKAGE_NAME = '@miphamai/cli' as const
|
|
10
10
|
|
|
11
11
|
/** 当前发布版本 */
|
|
12
|
-
export const PACKAGE_VERSION = '0.85.
|
|
12
|
+
export const PACKAGE_VERSION = '0.85.8' as const
|
|
13
13
|
|
|
14
14
|
/** npm install 全局安装命令 */
|
|
15
15
|
export const NPM_INSTALL_COMMAND = `npm install -g ${PACKAGE_NAME}` as const
|
|
@@ -90,4 +90,4 @@ export const TOOL_COUNT = 31 as const
|
|
|
90
90
|
* —— `test/e2e/full-pipeline.test.ts` 在 Linux 上整文件 skip、在 macOS 上跑 ——
|
|
91
91
|
* 但**总数相同**(两边都把被 skip 的算进去)。
|
|
92
92
|
*/
|
|
93
|
-
export const TEST_COUNT =
|
|
93
|
+
export const TEST_COUNT = 3584 as const
|
package/src/telemetry/consent.ts
CHANGED
|
@@ -31,6 +31,15 @@ export interface TelemetrySettings {
|
|
|
31
31
|
/** Why telemetry ended up on or off — surfaced by `/telemetry status`. */
|
|
32
32
|
export type ConsentSource = 'env-off' | 'project-veto' | 'user-optin' | 'default-off'
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* 项目级文件里**写了、但按设计不采纳**的键。
|
|
36
|
+
*
|
|
37
|
+
* 只有这两档词汇:`enabled: true`(项目不能授予同意)与非空 `endpoint`(项目不能选
|
|
38
|
+
* 目的地)。`installId` / `promptedAt` 不在内 —— 那两键由本工具写进**用户**文件,
|
|
39
|
+
* 出现在项目文件里是「键写错了」,报成「一档被拒绝」只会把人引偏。
|
|
40
|
+
*/
|
|
41
|
+
export type ProjectIgnoredKey = 'enabled' | 'endpoint'
|
|
42
|
+
|
|
34
43
|
export interface TelemetryConsent {
|
|
35
44
|
enabled: boolean
|
|
36
45
|
endpoint: string
|
|
@@ -43,6 +52,28 @@ export interface TelemetryConsent {
|
|
|
43
52
|
* user debugging an unexpected destination needs the second one.
|
|
44
53
|
*/
|
|
45
54
|
endpointSource: EndpointSource | 'off'
|
|
55
|
+
/**
|
|
56
|
+
* 项目级文件里声明了、而**没有生效**的键(按 `enabled` → `endpoint` 固定序)。
|
|
57
|
+
*
|
|
58
|
+
* 为什么要有这个名单:「按设计不采纳」与「压根没读你的文件」从外面看是**同一片
|
|
59
|
+
* 沉默**,而这是用户自己写下的字,就在他还能看见的那个文件里。兄弟形状见
|
|
60
|
+
* `config/loader.ts` 的 `projectModeSkipped` —— 同一条理由,同一句公告。
|
|
61
|
+
*
|
|
62
|
+
* 为什么不干脆采纳:项目这一档只许**收紧**(`enabled: false` 是否决)。采纳
|
|
63
|
+
* `endpoint` 等于克隆一个仓库就把用户已 opt-in 的遥测改道到仓库指定的收集器,
|
|
64
|
+
* 与「项目不能授予同意」是同一件事的两种写法。
|
|
65
|
+
*
|
|
66
|
+
* 空串不算声明 —— 名单要说的是「你写了 X 而它不生效」,不是「这个键存在过」。
|
|
67
|
+
*/
|
|
68
|
+
ignoredProjectKeys: ProjectIgnoredKey[]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 项目文件里声明了这两档词汇的那些键(顺序固定,与文件里的书写顺序无关)。 */
|
|
72
|
+
function declaredProjectKeys(project: TelemetrySettings): ProjectIgnoredKey[] {
|
|
73
|
+
const keys: ProjectIgnoredKey[] = []
|
|
74
|
+
if (project.enabled === true) keys.push('enabled')
|
|
75
|
+
if (typeof project.endpoint === 'string' && project.endpoint !== '') keys.push('endpoint')
|
|
76
|
+
return keys
|
|
46
77
|
}
|
|
47
78
|
|
|
48
79
|
/**
|
|
@@ -93,6 +124,12 @@ export function readTelemetrySettings(
|
|
|
93
124
|
* consenting on the user's behalf. Same shape as the existing
|
|
94
125
|
* `permissionRestrictions` fail-closed downgrade.
|
|
95
126
|
*
|
|
127
|
+
* **The withholding is reported, not silent.** A project that declared
|
|
128
|
+
* `enabled: true` or a destination gets those keys named back to it in
|
|
129
|
+
* `ignoredProjectKeys` — from the outside, "ignored on purpose" and "never read
|
|
130
|
+
* your file" are the same silence, and the user is the one who wrote those
|
|
131
|
+
* lines, in a file they can still see.
|
|
132
|
+
*
|
|
96
133
|
* There is intentionally no env var that grants consent. Consent has to be a
|
|
97
134
|
* persistent, deliberate act (the first-run prompt or `/telemetry on`) — env
|
|
98
135
|
* vars are inherited by child processes and end up in CI logs, so they must not
|
|
@@ -102,21 +139,30 @@ export function resolveTelemetry(
|
|
|
102
139
|
cwd: string = process.cwd(),
|
|
103
140
|
env: NodeJS.ProcessEnv = process.env,
|
|
104
141
|
): TelemetryConsent {
|
|
142
|
+
// The kill switch is resolved first and reads no file at all — so there is no
|
|
143
|
+
// project-tier declaration to report here, not even an unread one.
|
|
105
144
|
if (isHardDisabled(env)) {
|
|
106
|
-
return {
|
|
145
|
+
return {
|
|
146
|
+
enabled: false,
|
|
147
|
+
endpoint: '',
|
|
148
|
+
source: 'env-off',
|
|
149
|
+
endpointSource: 'off',
|
|
150
|
+
ignoredProjectKeys: [],
|
|
151
|
+
}
|
|
107
152
|
}
|
|
108
153
|
|
|
109
154
|
const user = readTelemetrySettings('user', cwd)
|
|
110
155
|
const project = readTelemetrySettings('project', cwd)
|
|
111
156
|
const { endpoint, source: endpointSource } = resolveEndpoint(user.endpoint, env)
|
|
157
|
+
const ignoredProjectKeys = declaredProjectKeys(project)
|
|
112
158
|
|
|
113
159
|
if (project.enabled === false) {
|
|
114
|
-
return { enabled: false, endpoint, source: 'project-veto', endpointSource }
|
|
160
|
+
return { enabled: false, endpoint, source: 'project-veto', endpointSource, ignoredProjectKeys }
|
|
115
161
|
}
|
|
116
162
|
if (user.enabled === true) {
|
|
117
|
-
return { enabled: true, endpoint, source: 'user-optin', endpointSource }
|
|
163
|
+
return { enabled: true, endpoint, source: 'user-optin', endpointSource, ignoredProjectKeys }
|
|
118
164
|
}
|
|
119
|
-
return { enabled: false, endpoint, source: 'default-off', endpointSource }
|
|
165
|
+
return { enabled: false, endpoint, source: 'default-off', endpointSource, ignoredProjectKeys }
|
|
120
166
|
}
|
|
121
167
|
|
|
122
168
|
function patchUserTelemetry(patch: TelemetrySettings, cwd: string): void {
|
package/src/telemetry/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto'
|
|
2
2
|
import { getMetrics } from '../core/metrics'
|
|
3
|
+
import { settingsPathFor } from '../config/loader'
|
|
3
4
|
import { resolveTelemetry, getOrCreateInstallId, type TelemetryConsent } from './consent'
|
|
4
5
|
import { enqueueSync } from './queue'
|
|
5
6
|
import { buildSessionEvent } from './payload'
|
|
@@ -50,6 +51,12 @@ export function initTelemetry(cwd: string = process.cwd()): TelemetryConsent {
|
|
|
50
51
|
|
|
51
52
|
state = { consent, installId, startedAt: Date.now(), flushed: false }
|
|
52
53
|
|
|
54
|
+
// A project that declared a telemetry key we do not honour is told so, here
|
|
55
|
+
// rather than in the TUI path — this is the one place consent is resolved, so
|
|
56
|
+
// it is also the one place that knows something was withheld, and it covers
|
|
57
|
+
// remote-attach and non-interactive runs the TUI setup never reaches.
|
|
58
|
+
announceIgnoredProjectKeys(consent, cwd)
|
|
59
|
+
|
|
53
60
|
// Crash capture is installed unconditionally, even when telemetry is off:
|
|
54
61
|
// it is what keeps a crash from becoming a silent hang. When telemetry is
|
|
55
62
|
// off the record is simply never uploaded.
|
|
@@ -71,6 +78,26 @@ export function initTelemetry(cwd: string = process.cwd()): TelemetryConsent {
|
|
|
71
78
|
return consent
|
|
72
79
|
}
|
|
73
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Tell the user that a project-level telemetry key was read and not honoured.
|
|
83
|
+
*
|
|
84
|
+
* The same shape as `index.tsx`'s `projectModeSkipped` notice, and for the same
|
|
85
|
+
* reason: "ignored on purpose" and "never read your file" are the same silence
|
|
86
|
+
* from the outside — and this is the user's own line, in a file they can still
|
|
87
|
+
* open. Once per startup, on stderr, so it cannot corrupt stdout rendering.
|
|
88
|
+
*
|
|
89
|
+
* Not a permission prompt: the outcome is already final by the time this runs.
|
|
90
|
+
* It only removes the ambiguity about *why*.
|
|
91
|
+
*/
|
|
92
|
+
function announceIgnoredProjectKeys(consent: TelemetryConsent, cwd: string): void {
|
|
93
|
+
if (consent.ignoredProjectKeys.length === 0) return
|
|
94
|
+
const keys = consent.ignoredProjectKeys.map((k) => `telemetry.${k}`).join(', ')
|
|
95
|
+
process.stderr.write(
|
|
96
|
+
`⚠ Mipham Code: ignored ${keys} from ${settingsPathFor('project', cwd)}\n` +
|
|
97
|
+
` (a repository may turn telemetry off, but must not turn it on or choose where it goes — set that in ${settingsPathFor('user', cwd)})\n`,
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
74
101
|
/**
|
|
75
102
|
* Record a slash-command invocation.
|
|
76
103
|
*
|
package/src/tools/exec/task.ts
CHANGED
|
@@ -112,6 +112,78 @@ function getBlockingIds(task: Task): string[] {
|
|
|
112
112
|
})
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Render the session's task list: status-grouped, availability-sorted, blockers marked.
|
|
117
|
+
*
|
|
118
|
+
* **One renderer, two readers.** The `list` action answers the model, and the
|
|
119
|
+
* `/tasks` panel answers the human — both show the same session registry, so
|
|
120
|
+
* both go through here. A second renderer for the panel would be the "two
|
|
121
|
+
* paths, one wired" mistake this repo has already paid for once.
|
|
122
|
+
*/
|
|
123
|
+
export function formatTaskList(): string {
|
|
124
|
+
const all = getTasks()
|
|
125
|
+
if (all.length === 0) return '(no tasks)'
|
|
126
|
+
|
|
127
|
+
// Sort by availability: in_progress → pending(available) → pending(blocked) → completed
|
|
128
|
+
const sortOrder: Record<string, number> = {
|
|
129
|
+
in_progress: 0,
|
|
130
|
+
pending: 1,
|
|
131
|
+
completed: 2,
|
|
132
|
+
failed: 3,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const sorted = [...all].sort((a, b) => {
|
|
136
|
+
const orderA = sortOrder[a.status] ?? 3
|
|
137
|
+
const orderB = sortOrder[b.status] ?? 3
|
|
138
|
+
if (orderA !== orderB) return orderA - orderB
|
|
139
|
+
// Within same status: available before blocked
|
|
140
|
+
if (a.status === 'pending' && b.status === 'pending') {
|
|
141
|
+
const aBlocked = isBlocked(a)
|
|
142
|
+
const bBlocked = isBlocked(b)
|
|
143
|
+
if (aBlocked !== bBlocked) return aBlocked ? 1 : -1
|
|
144
|
+
}
|
|
145
|
+
return 0
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
const lines: string[] = []
|
|
149
|
+
const statusLabels: Record<string, { emoji: string; label: string }> = {
|
|
150
|
+
in_progress: { emoji: '🔄', label: 'In Progress' },
|
|
151
|
+
pending: { emoji: '📋', label: 'Pending' },
|
|
152
|
+
completed: { emoji: '✅', label: 'Completed' },
|
|
153
|
+
failed: { emoji: '❌', label: 'Failed' },
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let currentStatus = ''
|
|
157
|
+
for (const t of sorted) {
|
|
158
|
+
const statusInfo = statusLabels[t.status]
|
|
159
|
+
if (!statusInfo) continue
|
|
160
|
+
|
|
161
|
+
if (statusInfo.label !== currentStatus) {
|
|
162
|
+
currentStatus = statusInfo.label
|
|
163
|
+
// Count tasks in this status group
|
|
164
|
+
const count = sorted.filter((s) => statusLabels[s.status]?.label === currentStatus).length
|
|
165
|
+
lines.push(`${statusInfo.emoji} ${currentStatus} (${count}):`)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const blocked = isBlocked(t)
|
|
169
|
+
const prefix = blocked && t.status === 'pending' ? '🚫 ' : ' '
|
|
170
|
+
const blockingNote = blocked ? ` 🚫 阻塞中 (等待: ${getBlockingIds(t).join(', ')})` : ''
|
|
171
|
+
lines.push(`${prefix}${formatTask(t)}${blockingNote}`)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Summary footer
|
|
175
|
+
const available = all.filter((t) => t.status === 'pending' && !isBlocked(t)).length
|
|
176
|
+
const blockedCount = all.filter((t) => t.status === 'pending' && isBlocked(t)).length
|
|
177
|
+
if (blockedCount > 0) {
|
|
178
|
+
lines.push('')
|
|
179
|
+
lines.push(
|
|
180
|
+
`📊 ${available} available · ${blockedCount} blocked · ${all.filter((t) => t.status === 'completed').length} done`,
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return lines.join('\n')
|
|
185
|
+
}
|
|
186
|
+
|
|
115
187
|
export const taskTool: ToolDefinition = {
|
|
116
188
|
name: 'Task',
|
|
117
189
|
description:
|
|
@@ -205,67 +277,7 @@ export const taskTool: ToolDefinition = {
|
|
|
205
277
|
|
|
206
278
|
// ── LIST ──
|
|
207
279
|
if (action === 'list') {
|
|
208
|
-
|
|
209
|
-
if (all.length === 0) return { success: true, content: '(no tasks)' }
|
|
210
|
-
|
|
211
|
-
// Sort by availability: in_progress → pending(available) → pending(blocked) → completed
|
|
212
|
-
const sortOrder: Record<string, number> = {
|
|
213
|
-
in_progress: 0,
|
|
214
|
-
pending: 1,
|
|
215
|
-
completed: 2,
|
|
216
|
-
failed: 3,
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const sorted = [...all].sort((a, b) => {
|
|
220
|
-
const orderA = sortOrder[a.status] ?? 3
|
|
221
|
-
const orderB = sortOrder[b.status] ?? 3
|
|
222
|
-
if (orderA !== orderB) return orderA - orderB
|
|
223
|
-
// Within same status: available before blocked
|
|
224
|
-
if (a.status === 'pending' && b.status === 'pending') {
|
|
225
|
-
const aBlocked = isBlocked(a)
|
|
226
|
-
const bBlocked = isBlocked(b)
|
|
227
|
-
if (aBlocked !== bBlocked) return aBlocked ? 1 : -1
|
|
228
|
-
}
|
|
229
|
-
return 0
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
const lines: string[] = []
|
|
233
|
-
const statusLabels: Record<string, { emoji: string; label: string }> = {
|
|
234
|
-
in_progress: { emoji: '🔄', label: 'In Progress' },
|
|
235
|
-
pending: { emoji: '📋', label: 'Pending' },
|
|
236
|
-
completed: { emoji: '✅', label: 'Completed' },
|
|
237
|
-
failed: { emoji: '❌', label: 'Failed' },
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
let currentStatus = ''
|
|
241
|
-
for (const t of sorted) {
|
|
242
|
-
const statusInfo = statusLabels[t.status]
|
|
243
|
-
if (!statusInfo) continue
|
|
244
|
-
|
|
245
|
-
if (statusInfo.label !== currentStatus) {
|
|
246
|
-
currentStatus = statusInfo.label
|
|
247
|
-
// Count tasks in this status group
|
|
248
|
-
const count = sorted.filter((s) => statusLabels[s.status]?.label === currentStatus).length
|
|
249
|
-
lines.push(`${statusInfo.emoji} ${currentStatus} (${count}):`)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const blocked = isBlocked(t)
|
|
253
|
-
const prefix = blocked && t.status === 'pending' ? '🚫 ' : ' '
|
|
254
|
-
const blockingNote = blocked ? ` 🚫 阻塞中 (等待: ${getBlockingIds(t).join(', ')})` : ''
|
|
255
|
-
lines.push(`${prefix}${formatTask(t)}${blockingNote}`)
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Summary footer
|
|
259
|
-
const available = all.filter((t) => t.status === 'pending' && !isBlocked(t)).length
|
|
260
|
-
const blockedCount = all.filter((t) => t.status === 'pending' && isBlocked(t)).length
|
|
261
|
-
if (blockedCount > 0) {
|
|
262
|
-
lines.push('')
|
|
263
|
-
lines.push(
|
|
264
|
-
`📊 ${available} available · ${blockedCount} blocked · ${all.filter((t) => t.status === 'completed').length} done`,
|
|
265
|
-
)
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return { success: true, content: lines.join('\n') }
|
|
280
|
+
return { success: true, content: formatTaskList() }
|
|
269
281
|
}
|
|
270
282
|
|
|
271
283
|
// ── GET ──
|
package/src/ui/commands.ts
CHANGED
|
@@ -33,6 +33,8 @@ import {
|
|
|
33
33
|
hasProposedProse,
|
|
34
34
|
appendProseProposal,
|
|
35
35
|
clearProseProposals,
|
|
36
|
+
loadAlwaysOnLessonsBlock,
|
|
37
|
+
formatNetChange,
|
|
36
38
|
LESSONS_FILE,
|
|
37
39
|
MANAGED_RULES_FILE,
|
|
38
40
|
} from '../core/crsi-producer'
|
|
@@ -110,6 +112,7 @@ import { listActiveAutoloops, formatLoopRows } from '../commands/autoloop-journa
|
|
|
110
112
|
import { execSync } from 'node:child_process'
|
|
111
113
|
import { MIPHAM_DIR, OLLAMA_PRESET_MODELS } from '../shared/constants'
|
|
112
114
|
import { renameActiveSession } from '../agent/cross-session/discovery'
|
|
115
|
+
import { formatTaskList } from '../tools/exec/task'
|
|
113
116
|
|
|
114
117
|
export interface CommandContext {
|
|
115
118
|
engine: QueryEngine
|
|
@@ -848,6 +851,19 @@ const crsiInventoryCmd: CommandHandler = async (ctx) => {
|
|
|
848
851
|
return { content: buildCapabilityReport(ctx.engine) }
|
|
849
852
|
}
|
|
850
853
|
|
|
854
|
+
/**
|
|
855
|
+
* 奖励闸的可见附注,放在 ✅ 头行之后。
|
|
856
|
+
*
|
|
857
|
+
* 抽成一个渲染器是因为它有**四个读者**(`/crsi modify` + `/crsi propose` 的三条路径);
|
|
858
|
+
* 逐处手拼迟早漏一个,而漏掉的那个就是「公布了字段、没有落点」—— 闸自称施加了、
|
|
859
|
+
* 实际没施加,从外面看不出区别,等于没说的话术。
|
|
860
|
+
*
|
|
861
|
+
* 无附注时返回空串,且**调用点保持逐字不变**(附注前不补空行,附注后自带一个)。
|
|
862
|
+
*/
|
|
863
|
+
function renderGateNote(result: { rewardNote?: string }): string {
|
|
864
|
+
return result.rewardNote ? `⚠️ 奖励闸附注:${result.rewardNote}\n` : ''
|
|
865
|
+
}
|
|
866
|
+
|
|
851
867
|
const crsiModifyCmd: CommandHandler = async (ctx, args) => {
|
|
852
868
|
if (args[0] === '--approve') {
|
|
853
869
|
if (shouldBlockApproval(getPendingVerdict() ?? 'inconclusive')) {
|
|
@@ -932,7 +948,9 @@ const crsiModifyCmd: CommandHandler = async (ctx, args) => {
|
|
|
932
948
|
|
|
933
949
|
return {
|
|
934
950
|
content:
|
|
935
|
-
`✅ 测试通过。审阅下方 diff:\n
|
|
951
|
+
`✅ 测试通过。审阅下方 diff:\n` +
|
|
952
|
+
renderGateNote(result) +
|
|
953
|
+
`\n${result.diff}\n` +
|
|
936
954
|
improvementLine +
|
|
937
955
|
'\n/crsi modify --approve 合并\n/crsi modify --reject 丢弃',
|
|
938
956
|
}
|
|
@@ -982,8 +1000,14 @@ const crsiProposeCmd: CommandHandler = async (ctx, args) => {
|
|
|
982
1000
|
const llm = ctx.engine.getLlm() ?? ctx.engine.getRegistry()
|
|
983
1001
|
const { readFileSync } = await import('node:fs')
|
|
984
1002
|
const { join } = await import('node:path')
|
|
985
|
-
const proposal = await produceProseProposal(
|
|
986
|
-
|
|
1003
|
+
const proposal = await produceProseProposal(
|
|
1004
|
+
signal,
|
|
1005
|
+
llm,
|
|
1006
|
+
skillFiles,
|
|
1007
|
+
(p) => readFileSync(join(root, p), 'utf-8'),
|
|
1008
|
+
// 常驻教训块**内联**(不带指针):生成算子是无工具的 `llm.chat` 单条消息 ——
|
|
1009
|
+
// 在此之前它拿到零条教训,而它写出的散文随后就是主代理要遵守的规则。
|
|
1010
|
+
loadAlwaysOnLessonsBlock(join(root, LESSONS_FILE)),
|
|
987
1011
|
)
|
|
988
1012
|
if (!proposal) {
|
|
989
1013
|
return { content: '散文提议生成失败(LLM 未返回有效结果)。' }
|
|
@@ -1040,11 +1064,39 @@ const crsiProposeCmd: CommandHandler = async (ctx, args) => {
|
|
|
1040
1064
|
|
|
1041
1065
|
appendProseProposal({ id, filePath: proposal.filePath, timestamp: new Date().toISOString() })
|
|
1042
1066
|
|
|
1067
|
+
// 事前声明风险(R):与 ε 同一段提示词产出(PROSE_GENERATE_PROMPT 第 365 行要求「这次改动
|
|
1068
|
+
// 可能在哪方面变差」),但 ε 进账本并被 predictionHitRate 读回,R 此前**零落点** —— 它在
|
|
1069
|
+
// commands.ts:1025 那个调用里与 expectedEffect 同一作用域、被丢掉,连沙箱都到不了
|
|
1070
|
+
//(CrsiModification 无 risk 字段)。这里给它在**人类真正做决定的那一刻**一个落点:
|
|
1071
|
+
// 回执上打印,紧挨着它描述的那份 diff。
|
|
1072
|
+
// **只呈现、不判定** —— 判「风险有没有成真」需要语义裁判,违反 A1 铁律(同 fdfbb5e6 记下的
|
|
1073
|
+
// 「证明更好」边界),故与 formatCostLine 同一纪律;且必须带「未验证」,否则这一行会让人以为
|
|
1074
|
+
// 风险被处理过了 —— **按键有反应而世界不变,比按键不存在更坏**。
|
|
1075
|
+
// 缺席(含空串)⇒ 整行不打,不是打一行空的。
|
|
1076
|
+
const riskLine = proposal.risk ? `\n📋 事前声明风险(未验证): ${proposal.risk}` : ''
|
|
1077
|
+
|
|
1078
|
+
// 净变化 —— 教训 #20「未要求的功能是负债」**可机械化的那一半**。
|
|
1079
|
+
// 与已落地的那三条(ε 命中 / 代价 / 风险)同一纪律:**只呈现、不判定**。
|
|
1080
|
+
// 判「这轮改写有没有塞进未要求的功能」需要语义裁判 ⇒ 违反 A1 铁律;
|
|
1081
|
+
// 但「它长胖了多少」是手上两份文本就能算出的**事实**,不需要模型参与,故可以做。
|
|
1082
|
+
// 与 riskLine **刻意不同**:R 缺席就不打行,净变化**永远可算**(恒打,含零)——
|
|
1083
|
+
// 零也打,正是因为它才是「这次没长胖」的可证伪读数;只打非零等于让读者看不见基线。
|
|
1084
|
+
// 前缀 `\n` 是为了自成一行:`predictionLine` 不以换行结尾(同下条注释记的那个坑)。
|
|
1085
|
+
const netChangeLine = `\n${formatNetChange(proposal.originalContent, proposal.newContent)}`
|
|
1086
|
+
|
|
1043
1087
|
return {
|
|
1044
1088
|
content:
|
|
1045
|
-
`✅ 已生成散文提议并跑过测试。审阅 diff:\n
|
|
1089
|
+
`✅ 已生成散文提议并跑过测试。审阅 diff:\n` +
|
|
1090
|
+
renderGateNote(result) +
|
|
1091
|
+
`\n${result.diff}\n\n` +
|
|
1046
1092
|
predictionLine +
|
|
1047
|
-
|
|
1093
|
+
netChangeLine +
|
|
1094
|
+
riskLine +
|
|
1095
|
+
// 操作提示必须**自成一行**:`predictionLine` / `netChangeLine` / `riskLine` 三条都自我
|
|
1096
|
+
// 负责换行、彼此不粘连,而提示串自身不以 `\n` 打头 ⇒ 直接拼接就会被粘在最后一条内容
|
|
1097
|
+
// 尾部。本条由探针实测确认(回执尾部为 `DIFF\n\n\n…`),而风险声明正是当年新增的落点,
|
|
1098
|
+
// 粘上去会让它读起来像延续到了命令里,故一并钉住。
|
|
1099
|
+
'\n/crsi modify --approve 合并 | /crsi modify --reject 丢弃',
|
|
1048
1100
|
}
|
|
1049
1101
|
}
|
|
1050
1102
|
|
|
@@ -1078,7 +1130,9 @@ const crsiProposeCmd: CommandHandler = async (ctx, args) => {
|
|
|
1078
1130
|
|
|
1079
1131
|
return {
|
|
1080
1132
|
content:
|
|
1081
|
-
`✅ 已生成受管理规则并跑过测试。审阅 diff:\n
|
|
1133
|
+
`✅ 已生成受管理规则并跑过测试。审阅 diff:\n` +
|
|
1134
|
+
renderGateNote(result) +
|
|
1135
|
+
`\n${result.diff}\n\n` +
|
|
1082
1136
|
'/crsi modify --approve 合并 | /crsi modify --reject 丢弃',
|
|
1083
1137
|
}
|
|
1084
1138
|
}
|
|
@@ -1110,7 +1164,9 @@ const crsiProposeCmd: CommandHandler = async (ctx, args) => {
|
|
|
1110
1164
|
|
|
1111
1165
|
return {
|
|
1112
1166
|
content:
|
|
1113
|
-
`✅ 已生成合并教训并跑过测试。审阅 diff:\n
|
|
1167
|
+
`✅ 已生成合并教训并跑过测试。审阅 diff:\n` +
|
|
1168
|
+
renderGateNote(result) +
|
|
1169
|
+
`\n${result.diff}\n\n` +
|
|
1114
1170
|
'/crsi modify --approve 合并 | /crsi modify --reject 丢弃',
|
|
1115
1171
|
}
|
|
1116
1172
|
}
|
|
@@ -1138,7 +1194,9 @@ const crsiProposeCmd: CommandHandler = async (ctx, args) => {
|
|
|
1138
1194
|
|
|
1139
1195
|
return {
|
|
1140
1196
|
content:
|
|
1141
|
-
`✅ 已生成教训并跑过测试。审阅 diff:\n
|
|
1197
|
+
`✅ 已生成教训并跑过测试。审阅 diff:\n` +
|
|
1198
|
+
renderGateNote(result) +
|
|
1199
|
+
`\n${result.diff}\n\n` +
|
|
1142
1200
|
'/crsi modify --approve 合并 | /crsi modify --reject 丢弃',
|
|
1143
1201
|
}
|
|
1144
1202
|
}
|
|
@@ -2775,7 +2833,11 @@ const rewindCmd: CommandHandler = (ctx) => {
|
|
|
2775
2833
|
count: String(result.messageCount),
|
|
2776
2834
|
remaining: String(c.getCheckpoints().length),
|
|
2777
2835
|
}),
|
|
2836
|
+
// `clearMessages` 单用是 `/clear` 的形状(屏幕上**没有**该留的东西);回退不一样 ——
|
|
2837
|
+
// 留到那一点为止的历史仍然算数,只是屏幕上的那份旧了。不带 `forwardedMessages`
|
|
2838
|
+
// 就会把消息列表清成空、再也不回填:模型看得见回退后的历史,用户看得见一片空白。
|
|
2778
2839
|
clearMessages: true,
|
|
2840
|
+
forwardedMessages: c.getMessages(),
|
|
2779
2841
|
}
|
|
2780
2842
|
}
|
|
2781
2843
|
|
|
@@ -2918,24 +2980,20 @@ const ultracodeCmd: CommandHandler = (ctx, args) => {
|
|
|
2918
2980
|
|
|
2919
2981
|
const tasksCmd: CommandHandler = (ctx) => {
|
|
2920
2982
|
const t = resolveT(ctx)
|
|
2921
|
-
const c = ctx.engine.getContext()
|
|
2922
|
-
const msgs = c.getMessages()
|
|
2923
2983
|
|
|
2924
|
-
//
|
|
2925
|
-
//
|
|
2926
|
-
//
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
return []
|
|
2932
|
-
})
|
|
2984
|
+
// 读**登记表**,不数历史。此前这个面板数的是历史里 `Task` 工具调用块的个数,
|
|
2985
|
+
// 于是压缩掉历史之后(块没了、任务还在)它会说「尚未跟踪任何任务」,而没有任务
|
|
2986
|
+
// 却有历史时又会说「检测到 N 次任务操作」。面板自称 "Background tasks"、标题写
|
|
2987
|
+
// 「后台任务」、空态写「尚未跟踪任何任务」—— 全是登记表词汇,而登记表就在
|
|
2988
|
+
// 一步之外(`getTasks()`,`GoalProgress` 早就接了)。
|
|
2989
|
+
const taskList = formatTaskList()
|
|
2990
|
+
const hasTasks = taskList !== '(no tasks)'
|
|
2933
2991
|
|
|
2934
2992
|
return {
|
|
2935
2993
|
content: stripIndent`
|
|
2936
2994
|
${t('commands.task_list.title')}
|
|
2937
2995
|
|
|
2938
|
-
${
|
|
2996
|
+
${hasTasks ? taskList : t('commands.task_list.no_tasks')}
|
|
2939
2997
|
|
|
2940
2998
|
${t('commands.task_list.reference')}
|
|
2941
2999
|
Task(action: "create") — create a new task
|
|
@@ -4001,6 +4059,14 @@ const telemetryCmd: CommandHandler = async (ctx, args) => {
|
|
|
4001
4059
|
`| Source | \`${consent.endpointSource}\` |`,
|
|
4002
4060
|
`| Install id | ${settings.installId ?? '_(not yet generated)_'} |`,
|
|
4003
4061
|
`| Prompted | ${settings.promptedAt ?? '_(never)_'} |`,
|
|
4062
|
+
// Only when there is something to say. An always-present "Ignored: _(none)_"
|
|
4063
|
+
// row would be noise in the common case, and this table is read when
|
|
4064
|
+
// something already looks wrong.
|
|
4065
|
+
...(consent.ignoredProjectKeys.length > 0
|
|
4066
|
+
? [
|
|
4067
|
+
`| Ignored from project | ${consent.ignoredProjectKeys.map((k) => `\`telemetry.${k}\``).join(', ')} — a repository may veto, not grant |`,
|
|
4068
|
+
]
|
|
4069
|
+
: []),
|
|
4004
4070
|
'',
|
|
4005
4071
|
'Full data dictionary: `docs/telemetry.md`',
|
|
4006
4072
|
]
|
package/src/ui/input.tsx
CHANGED
|
@@ -271,17 +271,23 @@ function MiphamTextInput({
|
|
|
271
271
|
{ isActive: focus },
|
|
272
272
|
)
|
|
273
273
|
|
|
274
|
+
// 光标**两个分支都要画**。此前它只写在 placeholder 三元表达式的 else 里,而
|
|
275
|
+
// `value.length === 0 && placeholder` 在真实使用中永远成立(placeholder 是
|
|
276
|
+
// `t('ui.input.placeholder')` 或加载动词,从不是空串)⇒ 初始状态一个光标都没有,
|
|
277
|
+
// 而那正是最常看到的状态。
|
|
278
|
+
//
|
|
279
|
+
// 方块是**显式白色**(`backgroundColor` + 黑字),不是 `inverse`:反显取的是终端
|
|
280
|
+
// **前景色**,主题一换就变成别的颜色;而「白色直立长方形」是定死的形状要求。
|
|
281
|
+
// 落在字符上时即「白块挖空一个黑字」;落在末尾时 `value[cursor]` 是 undefined,
|
|
282
|
+
// 用空格补 —— 空格加背景色就是一整个实心方块。
|
|
274
283
|
return (
|
|
275
284
|
<Text>
|
|
276
|
-
{value.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
{value.slice(cursor + 1)}
|
|
283
|
-
</>
|
|
284
|
-
)}
|
|
285
|
+
{value.slice(0, cursor)}
|
|
286
|
+
<Text backgroundColor="white" color="black">
|
|
287
|
+
{value[cursor] ?? ' '}
|
|
288
|
+
</Text>
|
|
289
|
+
{value.slice(cursor + 1)}
|
|
290
|
+
{value.length === 0 && placeholder ? <Text dimColor>{placeholder}</Text> : null}
|
|
285
291
|
</Text>
|
|
286
292
|
)
|
|
287
293
|
}
|