killeros 3.0.6 → 3.0.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.
@@ -1,111 +1,111 @@
1
- import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
2
- import { truncateToWidth } from "@earendil-works/pi-tui";
3
- import { modelDisplayName } from "./display.ts";
4
- import { safeTerminalText } from "./safe-terminal-text.ts";
5
-
6
- export type ActivityMessage =
7
- | { kind: "prompt" }
8
- | { kind: "tool"; toolName: string }
9
- | { kind: "tool-result"; failed: boolean }
10
- | { kind: "responding" };
11
-
12
- function safeToolName(toolName: string): string {
13
- const normalized = safeTerminalText(toolName.replace(/[\r\n\t]+/gu, " ")).replace(/\s+/gu, " ").trim();
14
- return truncateToWidth(normalized || "tool", 32, "…");
15
- }
16
-
17
- export function formatActivityMessage(message: ActivityMessage, theme: Theme, modelId?: string): string {
18
- let verb: string;
19
- let detail: string;
20
-
21
- switch (message.kind) {
22
- case "prompt":
23
- verb = "Mapping…";
24
- detail = "understanding request";
25
- break;
26
- case "tool-result":
27
- verb = message.failed ? "Recovering…" : "Reviewing…";
28
- detail = message.failed ? "tool failed" : "reading the result";
29
- break;
30
- case "responding":
31
- verb = "Responding…";
32
- detail = "assembling the answer";
33
- break;
34
- case "tool":
35
- switch (message.toolName.trim().toLowerCase()) {
36
- case "read":
37
- case "grep":
38
- case "find":
39
- case "ls":
40
- verb = "Inspecting…";
41
- detail = "reading relevant code";
42
- break;
43
- case "edit":
44
- case "write":
45
- verb = "Changing…";
46
- detail = "editing";
47
- break;
48
- case "bash":
49
- verb = "Running…";
50
- detail = "command";
51
- break;
52
- default:
53
- verb = "Working…";
54
- detail = `using ${safeToolName(message.toolName)}`;
55
- }
56
- break;
57
- default: {
58
- const exhaustive: never = message;
59
- return exhaustive;
60
- }
61
- }
62
-
63
- const suffix = modelDisplayName({ id: modelId }) || "unknown model";
64
- return `${theme.fg("accent", verb)} ${theme.fg("dim", `(${theme.bold("esc")} to interrupt · ${detail})`)}${theme.fg("dim", ` · ${suffix}`)}`;
65
- }
66
-
67
- export function registerRequestActivity(pi: ExtensionAPI): void {
68
- let active = false;
69
- let activeModel: string | undefined;
70
-
71
- const render = (message: ActivityMessage, ctx: ExtensionContext): void => {
72
- ctx.ui.setWorkingMessage(formatActivityMessage(message, ctx.ui.theme, activeModel));
73
- };
74
-
75
- const clear = (ctx?: ExtensionContext): void => {
76
- active = false;
77
- activeModel = undefined;
78
- if (ctx?.mode === "tui") {
79
- ctx.ui.setWorkingMessage();
80
- }
81
- };
82
-
83
- pi.on("agent_start", (_event, ctx) => {
84
- if (ctx.mode !== "tui") return;
85
- if (!active) activeModel = ctx.model?.id;
86
- active = true;
87
- render({ kind: "prompt" }, ctx);
88
- });
89
-
90
- pi.on("tool_execution_start", (event, ctx) => {
91
- if (ctx.mode !== "tui" || !active) return;
92
- render({ kind: "tool", toolName: event.toolName }, ctx);
93
- });
94
-
95
- pi.on("tool_execution_end", (event, ctx) => {
96
- if (ctx.mode !== "tui" || !active) return;
97
- render({ kind: "tool-result", failed: event.isError }, ctx);
98
- });
99
-
100
- pi.on("message_update", (event, ctx) => {
101
- if (ctx.mode !== "tui" || !active || event.assistantMessageEvent.type !== "text_start") return;
102
- render({ kind: "responding" }, ctx);
103
- });
104
-
105
- pi.on("agent_settled", (_event, ctx) => {
106
- if (!active || ctx.mode !== "tui" || !ctx.isIdle?.() || ctx.hasPendingMessages?.()) return;
107
- clear(ctx);
108
- });
109
-
110
- pi.on("session_shutdown", (_event, ctx) => clear(ctx));
111
- }
1
+ import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
2
+ import { truncateToWidth } from "@earendil-works/pi-tui";
3
+ import { modelDisplayName } from "./display.ts";
4
+ import { safeTerminalText } from "./safe-terminal-text.ts";
5
+
6
+ export type ActivityMessage =
7
+ | { kind: "prompt" }
8
+ | { kind: "tool"; toolName: string }
9
+ | { kind: "tool-result"; failed: boolean }
10
+ | { kind: "responding" };
11
+
12
+ function safeToolName(toolName: string): string {
13
+ const normalized = safeTerminalText(toolName.replace(/[\r\n\t]+/gu, " ")).replace(/\s+/gu, " ").trim();
14
+ return truncateToWidth(normalized || "tool", 32, "…");
15
+ }
16
+
17
+ export function formatActivityMessage(message: ActivityMessage, theme: Theme, modelId?: string): string {
18
+ let verb: string;
19
+ let detail: string;
20
+
21
+ switch (message.kind) {
22
+ case "prompt":
23
+ verb = "Mapping…";
24
+ detail = "understanding request";
25
+ break;
26
+ case "tool-result":
27
+ verb = message.failed ? "Recovering…" : "Reviewing…";
28
+ detail = message.failed ? "tool failed" : "reading the result";
29
+ break;
30
+ case "responding":
31
+ verb = "Responding…";
32
+ detail = "assembling the answer";
33
+ break;
34
+ case "tool":
35
+ switch (message.toolName.trim().toLowerCase()) {
36
+ case "read":
37
+ case "grep":
38
+ case "find":
39
+ case "ls":
40
+ verb = "Inspecting…";
41
+ detail = "reading relevant code";
42
+ break;
43
+ case "edit":
44
+ case "write":
45
+ verb = "Changing…";
46
+ detail = "editing";
47
+ break;
48
+ case "bash":
49
+ verb = "Running…";
50
+ detail = "command";
51
+ break;
52
+ default:
53
+ verb = "Working…";
54
+ detail = `using ${safeToolName(message.toolName)}`;
55
+ }
56
+ break;
57
+ default: {
58
+ const exhaustive: never = message;
59
+ return exhaustive;
60
+ }
61
+ }
62
+
63
+ const suffix = modelDisplayName({ id: modelId }) || "unknown model";
64
+ return `${theme.fg("accent", verb)} ${theme.fg("dim", `(${theme.bold("esc")} to interrupt · ${detail})`)}${theme.fg("dim", ` · ${suffix}`)}`;
65
+ }
66
+
67
+ export function registerRequestActivity(pi: ExtensionAPI): void {
68
+ let active = false;
69
+ let activeModel: string | undefined;
70
+
71
+ const render = (message: ActivityMessage, ctx: ExtensionContext): void => {
72
+ ctx.ui.setWorkingMessage(formatActivityMessage(message, ctx.ui.theme, activeModel));
73
+ };
74
+
75
+ const clear = (ctx?: ExtensionContext): void => {
76
+ active = false;
77
+ activeModel = undefined;
78
+ if (ctx?.mode === "tui") {
79
+ ctx.ui.setWorkingMessage();
80
+ }
81
+ };
82
+
83
+ pi.on("agent_start", (_event, ctx) => {
84
+ if (ctx.mode !== "tui") return;
85
+ if (!active) activeModel = ctx.model?.id;
86
+ active = true;
87
+ render({ kind: "prompt" }, ctx);
88
+ });
89
+
90
+ pi.on("tool_execution_start", (event, ctx) => {
91
+ if (ctx.mode !== "tui" || !active) return;
92
+ render({ kind: "tool", toolName: event.toolName }, ctx);
93
+ });
94
+
95
+ pi.on("tool_execution_end", (event, ctx) => {
96
+ if (ctx.mode !== "tui" || !active) return;
97
+ render({ kind: "tool-result", failed: event.isError }, ctx);
98
+ });
99
+
100
+ pi.on("message_update", (event, ctx) => {
101
+ if (ctx.mode !== "tui" || !active || event.assistantMessageEvent.type !== "text_start") return;
102
+ render({ kind: "responding" }, ctx);
103
+ });
104
+
105
+ pi.on("agent_settled", (_event, ctx) => {
106
+ if (!active || ctx.mode !== "tui" || !ctx.isIdle?.() || ctx.hasPendingMessages?.()) return;
107
+ clear(ctx);
108
+ });
109
+
110
+ pi.on("session_shutdown", (_event, ctx) => clear(ctx));
111
+ }