@miphamai/cli 0.85.8 → 0.85.10
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/README.md +2 -2
- package/bin/mipham.ts +6 -4
- package/package.json +1 -1
- package/src/commands/project.ts +39 -7
- package/src/config/loader.ts +262 -71
- package/src/core/crsi-producer.ts +341 -29
- package/src/core/engine.ts +54 -0
- package/src/core/eval-harness.ts +13 -4
- package/src/core/instructions.ts +35 -5
- package/src/core/permission-config.ts +22 -0
- package/src/daemon/auth.ts +50 -3
- package/src/daemon/feishu/adapter.ts +57 -1
- package/src/daemon/server.ts +24 -12
- package/src/index.tsx +27 -1
- package/src/shared/package-info.ts +3 -3
- package/src/telemetry/consent.ts +18 -2
- package/src/tools/index.ts +5 -3
- package/src/tools/system/config.ts +119 -52
- package/src/ui/app.tsx +7 -1
- package/src/ui/commands.ts +49 -0
package/src/ui/app.tsx
CHANGED
|
@@ -276,9 +276,15 @@ export function App({
|
|
|
276
276
|
const [inputHistory, setInputHistory] = useState<string[]>([])
|
|
277
277
|
const [updateStatus, setUpdateStatus] = useState<UpdateStatus | null>(null)
|
|
278
278
|
// Current git branch — read once at mount (not a git repo → null).
|
|
279
|
+
// `stdio` 显式给:默认下 git 的 stderr 是继承的,「不是仓库」这个正常路径会把
|
|
280
|
+
// `fatal:` 漏到终端上(与 `core/instructions.ts` 的 `gitRoot` 同一件事)。
|
|
281
|
+
// stdout 仍须是管道,否则读到的永远是空串 —— 分支名直接消失,且不报错。
|
|
279
282
|
const [gitBranch] = useState<string | null>(() => {
|
|
280
283
|
try {
|
|
281
|
-
const b = execSync('git branch --show-current', {
|
|
284
|
+
const b = execSync('git branch --show-current', {
|
|
285
|
+
encoding: 'utf-8',
|
|
286
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
287
|
+
}).trim()
|
|
282
288
|
return b || null
|
|
283
289
|
} catch {
|
|
284
290
|
return null
|
package/src/ui/commands.ts
CHANGED
|
@@ -34,7 +34,11 @@ import {
|
|
|
34
34
|
appendProseProposal,
|
|
35
35
|
clearProseProposals,
|
|
36
36
|
loadAlwaysOnLessonsBlock,
|
|
37
|
+
buildResidentLessonReport,
|
|
38
|
+
extractCrsiLessonSummaries,
|
|
39
|
+
selectResidentLessons,
|
|
37
40
|
formatNetChange,
|
|
41
|
+
formatSeverityShift,
|
|
38
42
|
LESSONS_FILE,
|
|
39
43
|
MANAGED_RULES_FILE,
|
|
40
44
|
} from '../core/crsi-producer'
|
|
@@ -1162,10 +1166,15 @@ const crsiProposeCmd: CommandHandler = async (ctx, args) => {
|
|
|
1162
1166
|
return { content: `❌ 合并失败(phase: ${result.phase})。\n${result.error ?? ''}` }
|
|
1163
1167
|
}
|
|
1164
1168
|
|
|
1169
|
+
// 档位迁移:**只呈现、不判定**,与 ε 命中 / 代价 / 事前风险 / 净变化同一纪律
|
|
1170
|
+
//(见 crsi-producer.ts 的 formatSeverityShift)。落点在**人类真正做决定的那一刻** ——
|
|
1171
|
+
// 紧挨着它描述的那份 diff。恒打(含无变化):「这次没把一条非常驻的教训变成常驻」
|
|
1172
|
+
// 正是那条可证伪的基线读数,只打有变化的等于让读者看不见基线。
|
|
1165
1173
|
return {
|
|
1166
1174
|
content:
|
|
1167
1175
|
`✅ 已生成合并教训并跑过测试。审阅 diff:\n` +
|
|
1168
1176
|
renderGateNote(result) +
|
|
1177
|
+
`${formatSeverityShift(proposal.severityA, proposal.severityB, proposal.mergedSeverity)}\n` +
|
|
1169
1178
|
`\n${result.diff}\n\n` +
|
|
1170
1179
|
'/crsi modify --approve 合并 | /crsi modify --reject 丢弃',
|
|
1171
1180
|
}
|
|
@@ -1309,6 +1318,45 @@ const crsiProseClearCmd: CommandHandler = () => {
|
|
|
1309
1318
|
return { content: `已清空散文提议 ledger(移除 ${count} 条记录)。` }
|
|
1310
1319
|
}
|
|
1311
1320
|
|
|
1321
|
+
/**
|
|
1322
|
+
* `/crsi lessons` —— 常驻档名册(只读)。
|
|
1323
|
+
*
|
|
1324
|
+
* 这是 `selectResidentLessons` 唯一**给人看**的读者。另两个(系统提示、`--prose` 算子)
|
|
1325
|
+
* 的输出都只进模型的上下文;而常驻档的成本是**人**在付(每条 critical 随每次请求发出),
|
|
1326
|
+
* 能动手降档、缩短的也只有人。没有它,「这档涨得值不值」没有材料可查。
|
|
1327
|
+
*
|
|
1328
|
+
* 读的是**当前磁盘上的文件**(不是启动时那份快照):刚改完 `- 严重度:` 就该看到新名册。
|
|
1329
|
+
*/
|
|
1330
|
+
const crsiLessonsCmd: CommandHandler = async () => {
|
|
1331
|
+
// 目标文件按仓库根解析 —— 与 `/crsi propose` 同一口径(那里的 filePath 是仓库根相对)
|
|
1332
|
+
let root = process.cwd()
|
|
1333
|
+
try {
|
|
1334
|
+
root = execSync('git rev-parse --show-toplevel', {
|
|
1335
|
+
timeout: 5000,
|
|
1336
|
+
encoding: 'utf-8',
|
|
1337
|
+
}).trim()
|
|
1338
|
+
} catch {
|
|
1339
|
+
// 非 git 目录 → 回退 cwd
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
const { readFileSync, existsSync } = await import('node:fs')
|
|
1343
|
+
const { join } = await import('node:path')
|
|
1344
|
+
const lessonsPath = join(root, LESSONS_FILE)
|
|
1345
|
+
if (!existsSync(lessonsPath)) {
|
|
1346
|
+
return { content: `教训文件不存在:${lessonsPath}` }
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
let summaries
|
|
1350
|
+
try {
|
|
1351
|
+
summaries = extractCrsiLessonSummaries(readFileSync(lessonsPath, 'utf-8'))
|
|
1352
|
+
} catch (e) {
|
|
1353
|
+
return { content: `教训文件读取失败:${lessonsPath}\n${String(e)}` }
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
// 择点与两个已有读者同一个 ⇒ 名册报的就是这条会话真正会注入的那一份
|
|
1357
|
+
return { content: buildResidentLessonReport(selectResidentLessons(summaries), lessonsPath) }
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1312
1360
|
const crsiHealthCmd: CommandHandler = async (ctx) => {
|
|
1313
1361
|
const engine = ctx.engine.getRuleEngine()
|
|
1314
1362
|
const tracker = ctx.engine.getEffectivenessTracker()
|
|
@@ -5854,6 +5902,7 @@ registry.set('/crsi inventory', crsiInventoryCmd)
|
|
|
5854
5902
|
registry.set('/crsi modify', crsiModifyCmd)
|
|
5855
5903
|
registry.set('/crsi propose', crsiProposeCmd)
|
|
5856
5904
|
registry.set('/crsi prose-clear', crsiProseClearCmd)
|
|
5905
|
+
registry.set('/crsi lessons', crsiLessonsCmd)
|
|
5857
5906
|
registry.set('/crsi eval', crsiEvalCmd)
|
|
5858
5907
|
registry.set('/crsi bench', crsiBenchCmd)
|
|
5859
5908
|
registry.set('/crsi meta', crsiMetaCmd)
|