@ia-ccun/code-agent-cli 0.0.52-beta.4 → 0.0.52-beta.6
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.
|
@@ -362,25 +362,27 @@ function formatRuleMessage(
|
|
|
362
362
|
commandForMatching: string,
|
|
363
363
|
highlight: (value: string) => string = (value) => value,
|
|
364
364
|
): { title: string; message: string; nonInteractiveReason: string } {
|
|
365
|
-
const title = rule.level === "strong-confirm"
|
|
365
|
+
const title = rule.level === "strong-confirm"
|
|
366
|
+
? "⚠ aicode提示:高危 bash 命令"
|
|
367
|
+
: "⚠ aicode提示:危险 bash 命令";
|
|
366
368
|
const impact = rule.level === "strong-confirm"
|
|
367
|
-
? "
|
|
368
|
-
: "
|
|
369
|
+
? "此操作难以撤销。执行前请确认目标、分支和作用域。"
|
|
370
|
+
: "执行前请确认目标和作用域。";
|
|
369
371
|
const excerpt = matchingCommandExcerpt(rule, commandForMatching, highlight);
|
|
370
372
|
|
|
371
373
|
return {
|
|
372
374
|
title,
|
|
373
375
|
message: [
|
|
374
|
-
|
|
376
|
+
`原因:${highlight(rule.label)}(${rule.category})`,
|
|
375
377
|
impact,
|
|
376
378
|
"",
|
|
377
|
-
"
|
|
378
|
-
|
|
379
|
+
"危险行和上下文",
|
|
380
|
+
`标记为 ${highlight("!!!")} 的行触发了安全规则;匹配的模式包裹为 ${highlight(">>> pattern >>>")}。`,
|
|
379
381
|
"────────────────────────────────────────",
|
|
380
382
|
excerpt,
|
|
381
383
|
"────────────────────────────────────────",
|
|
382
384
|
"",
|
|
383
|
-
"
|
|
385
|
+
"确认执行?",
|
|
384
386
|
].join("\n"),
|
|
385
387
|
nonInteractiveReason: `Blocked ${rule.category} command (${rule.label}) in non-interactive mode`,
|
|
386
388
|
};
|
|
@@ -19,7 +19,66 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
// ============== Checklist 工具函数(内联自 @firstpick/pi-utils) ==============
|
|
24
|
+
|
|
25
|
+
type ChecklistStatus = "todo" | "partial" | "done";
|
|
26
|
+
type ChecklistItem = {
|
|
27
|
+
text: string;
|
|
28
|
+
status: ChecklistStatus;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const CHECKLIST_LINE_REGEX = /^\s*(?:(?:[-*]|\d+[.)])\s*)?\[( |x|X|-)\]\s+(.+)$/;
|
|
32
|
+
|
|
33
|
+
function parseChecklistLine(line: string): ChecklistItem | undefined {
|
|
34
|
+
const match = CHECKLIST_LINE_REGEX.exec(line);
|
|
35
|
+
if (!match) return undefined;
|
|
36
|
+
|
|
37
|
+
const mark = (match[1] || " ").toLowerCase();
|
|
38
|
+
const label = (match[2] || "").trim().replace(/\s+/g, " ");
|
|
39
|
+
if (!label) return undefined;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
status: mark === "x" ? "done" : mark === "-" ? "partial" : "todo",
|
|
43
|
+
text: label,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function extractChecklist(text: string): ChecklistItem[] {
|
|
48
|
+
const checklist: ChecklistItem[] = [];
|
|
49
|
+
let inFence = false;
|
|
50
|
+
|
|
51
|
+
for (const line of text.split(/\r?\n/)) {
|
|
52
|
+
if (/^\s*```/.test(line)) {
|
|
53
|
+
inFence = !inFence;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (inFence) continue;
|
|
57
|
+
|
|
58
|
+
const item = parseChecklistLine(line);
|
|
59
|
+
if (item) checklist.push(item);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return checklist;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function stripChecklistLines(text: string): string {
|
|
66
|
+
let inFence = false;
|
|
67
|
+
const kept: string[] = [];
|
|
68
|
+
|
|
69
|
+
for (const line of text.split(/\r?\n/)) {
|
|
70
|
+
if (/^\s*```/.test(line)) {
|
|
71
|
+
inFence = !inFence;
|
|
72
|
+
kept.push(line);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!inFence && parseChecklistLine(line)) continue;
|
|
77
|
+
kept.push(line);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return kept.join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
81
|
+
}
|
|
23
82
|
|
|
24
83
|
type TodoStatus = ChecklistStatus;
|
|
25
84
|
type TodoItem = ChecklistItem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ia-ccun/code-agent-cli",
|
|
3
|
-
"version": "0.0.52-beta.
|
|
3
|
+
"version": "0.0.52-beta.6",
|
|
4
4
|
"description": "AI Coding Agent CLI - 基于OpenClaw🦞底层Agent原理封装的编码智能体(供学习使用)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,11 +35,10 @@
|
|
|
35
35
|
"prepare": "husky"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@earendil-works/pi-agent-core": "^0.
|
|
39
|
-
"@earendil-works/pi-ai": "^0.
|
|
40
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
41
|
-
"@earendil-works/pi-tui": "^0.
|
|
42
|
-
"@firstpick/pi-utils": "^0.2.2"
|
|
38
|
+
"@earendil-works/pi-agent-core": "^0.80.0",
|
|
39
|
+
"@earendil-works/pi-ai": "^0.80.0",
|
|
40
|
+
"@earendil-works/pi-coding-agent": "^0.80.0",
|
|
41
|
+
"@earendil-works/pi-tui": "^0.80.0"
|
|
43
42
|
},
|
|
44
43
|
"overrides": {
|
|
45
44
|
"glob": "^11.0.0",
|