kcode-pi 0.1.19 → 0.1.20
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/extensions/kingdee-header.ts +19 -9
- package/package.json +1 -1
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
import type { ExtensionAPI, Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { inspectGate } from "../src/harness/gates.ts";
|
|
2
3
|
import { readActiveRun } from "../src/harness/state.ts";
|
|
3
|
-
import type { ActiveRun } from "../src/harness/types.ts";
|
|
4
|
+
import type { ActiveRun, GateResult } from "../src/harness/types.ts";
|
|
4
5
|
import { formatProductProfile } from "../src/product/profile.ts";
|
|
5
6
|
|
|
6
7
|
function formatProduct(run: ActiveRun | undefined): string {
|
|
7
|
-
|
|
8
|
+
if (!run) return "未选择";
|
|
9
|
+
if (run.profile?.product === "unknown") return "未确认";
|
|
10
|
+
return formatProductProfile(run.profile);
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
function formatPhase(phase: ActiveRun["phase"] | undefined): string {
|
|
11
14
|
return phase ?? "空闲";
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
function formatGate(
|
|
15
|
-
if (!
|
|
16
|
-
|
|
17
|
-
return `门禁:阻塞${run.gate.reason ? ` - ${run.gate.reason}` : ""}`;
|
|
17
|
+
function formatGate(gate: GateResult | undefined): string {
|
|
18
|
+
if (!gate) return "门禁:待检查";
|
|
19
|
+
return gate.passed ? "门禁:通过" : "门禁:阻塞";
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
function riskLevel(run: ActiveRun | undefined): string {
|
|
21
23
|
return run?.riskAssessment?.level ?? "未知";
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
function riskColor(risk: string): "error" | "warning" | "muted" | "success" {
|
|
27
|
+
if (risk === "high") return "error";
|
|
28
|
+
if (risk === "medium") return "warning";
|
|
29
|
+
if (risk === "未知") return "muted";
|
|
30
|
+
return "success";
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
function padOrTrim(text: string, width: number): string {
|
|
25
34
|
if (width <= 0) return "";
|
|
26
35
|
if (text.length > width) return text.slice(0, Math.max(0, width - 1)) + ">";
|
|
@@ -45,9 +54,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
45
54
|
return {
|
|
46
55
|
render(width: number): string[] {
|
|
47
56
|
const run = readActiveRun(ctx.cwd);
|
|
57
|
+
const gateState = run ? inspectGate(ctx.cwd, run) : undefined;
|
|
48
58
|
const phase = formatPhase(run?.phase);
|
|
49
59
|
const product = formatProduct(run);
|
|
50
|
-
const gate = formatGate(
|
|
60
|
+
const gate = formatGate(gateState);
|
|
51
61
|
const risk = riskLevel(run);
|
|
52
62
|
const runId = run?.id ?? "无";
|
|
53
63
|
|
|
@@ -57,9 +67,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
57
67
|
theme.fg("muted", " | 产品:"),
|
|
58
68
|
theme.fg("text", product),
|
|
59
69
|
theme.fg("muted", " | 风险:"),
|
|
60
|
-
theme.fg(risk
|
|
70
|
+
theme.fg(riskColor(risk), risk),
|
|
61
71
|
theme.fg("muted", " | "),
|
|
62
|
-
theme.fg(
|
|
72
|
+
theme.fg(gateState?.passed === false ? "error" : "muted", gate),
|
|
63
73
|
].join("");
|
|
64
74
|
|
|
65
75
|
return [
|