@0perator/operator 0.1.42 → 0.1.44
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/dist/cli.js +1 -1
- package/dist/ui/ToolStep.js +34 -5
- package/dist/ui/Transcript.js +45 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ import { expandFileMentions } from "./util/mentions.js";
|
|
|
19
19
|
import { join } from "node:path";
|
|
20
20
|
import { homedir, hostname } from "node:os";
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
|
-
const VERSION = "0.1.
|
|
22
|
+
const VERSION = "0.1.44";
|
|
23
23
|
// operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
|
|
24
24
|
const settings = loadSettings();
|
|
25
25
|
// Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
|
package/dist/ui/ToolStep.js
CHANGED
|
@@ -6,13 +6,42 @@ import { Box, Text } from "ink";
|
|
|
6
6
|
import { formatDuration } from "./format.js";
|
|
7
7
|
const GLYPH = { selected: "○", running: "◐", done: "✓", error: "✗" };
|
|
8
8
|
const COLOR = { selected: "gray", running: "#e8a33d", done: "green", error: "red" };
|
|
9
|
-
|
|
9
|
+
// Args that identify WHAT a tool acted on — a path, a command, a URL. These are shown FIRST and IN FULL
|
|
10
|
+
// (never truncated), so you can always read the exact file name / path a tool wrote or read. Order matters:
|
|
11
|
+
// path-like keys first.
|
|
12
|
+
const KEY_ARGS = ["path", "file", "filename", "command", "cmd", "pattern", "url", "query", "workspace", "cwd", "name"];
|
|
13
|
+
// Bulky payloads — never dumped (they'd bury the path and blow up the line); shown as a size instead.
|
|
14
|
+
const BULK_ARGS = ["content", "text", "body", "data", "new_string", "old_string", "diff", "message"];
|
|
15
|
+
export function argsPreview(args) {
|
|
10
16
|
if (!args)
|
|
11
17
|
return "";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
const parts = [];
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
// 1) identifying keys, in full — the file name/path is the point, so it is NEVER clipped.
|
|
21
|
+
for (const k of KEY_ARGS) {
|
|
22
|
+
const v = args[k];
|
|
23
|
+
if (v != null && (typeof v === "string" || typeof v === "number")) {
|
|
24
|
+
parts.push(`${k}: ${v}`);
|
|
25
|
+
seen.add(k);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// 2) bulky payloads → just a length, never the content.
|
|
29
|
+
for (const k of BULK_ARGS) {
|
|
30
|
+
if (typeof args[k] === "string") {
|
|
31
|
+
parts.push(`${k}: ${args[k].length} chars`);
|
|
32
|
+
seen.add(k);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// 3) any remaining scalar args, each individually trimmed (never at the cost of the path above).
|
|
36
|
+
for (const [k, v] of Object.entries(args)) {
|
|
37
|
+
if (seen.has(k))
|
|
38
|
+
continue;
|
|
39
|
+
const s = typeof v === "string" ? v : JSON.stringify(v);
|
|
40
|
+
if (s == null)
|
|
41
|
+
continue;
|
|
42
|
+
parts.push(`${k}=${s.length > 40 ? `${s.slice(0, 37)}...` : s}`);
|
|
43
|
+
}
|
|
44
|
+
return parts.join(", ");
|
|
16
45
|
}
|
|
17
46
|
export function ToolStep({ step }) {
|
|
18
47
|
const [now, setNow] = useState(() => Date.now());
|
package/dist/ui/Transcript.js
CHANGED
|
@@ -5,6 +5,35 @@ import { Markdown } from "./Markdown.js";
|
|
|
5
5
|
function entryKey(entry) {
|
|
6
6
|
return entry.kind === "message" ? entry.message.id : entry.step.id;
|
|
7
7
|
}
|
|
8
|
+
// Rows the live frame must leave free for the spinner + status/input rules + composer + margins. The live
|
|
9
|
+
// streaming message is tailed to (terminal rows - this) so the DYNAMIC (non-Static) frame never grows
|
|
10
|
+
// taller than the window — the Ink failure that collapses the whole frame to the top and scrolls the
|
|
11
|
+
// transcript away. The full text is unaffected: it renders complete via <Static> once it settles.
|
|
12
|
+
// The live tail must keep the WHOLE dynamic (non-Static) frame comfortably under the terminal height —
|
|
13
|
+
// not just fit it. Ink corrupts (clears to the top, scrolls the transcript away) when the dynamic frame
|
|
14
|
+
// approaches the window height, and the worst moment is the settle transition when this frame is erased.
|
|
15
|
+
// So cap the live view to a small slice (≤ ~16 rows, less on short terminals): enough to watch the answer
|
|
16
|
+
// stream, while the full text always renders complete via <Static> once it settles. Pure (dimensions
|
|
17
|
+
// passed in) so the bound is unit-testable.
|
|
18
|
+
export function liveTail(s, rows, cols) {
|
|
19
|
+
const budget = Math.max(6, Math.min(rows - 14, 16)); // rendered rows the live frame may occupy
|
|
20
|
+
const lines = s.split("\n");
|
|
21
|
+
// Walk up from the last line, counting the PHYSICAL rows each takes after wrapping, and keep only what
|
|
22
|
+
// fits the budget — so even all-long-wrapping lines can't push the dynamic frame past the window.
|
|
23
|
+
let used = 0, start = lines.length;
|
|
24
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
25
|
+
const wrapped = Math.max(1, Math.ceil(lines[i].length / cols));
|
|
26
|
+
if (used + wrapped > budget && start !== lines.length)
|
|
27
|
+
break;
|
|
28
|
+
used += wrapped;
|
|
29
|
+
start = i;
|
|
30
|
+
if (used >= budget)
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
if (start <= 0)
|
|
34
|
+
return { text: s, clipped: 0 };
|
|
35
|
+
return { text: lines.slice(start).join("\n"), clipped: start };
|
|
36
|
+
}
|
|
8
37
|
function renderEntry(entry, live = false) {
|
|
9
38
|
if (entry.kind === "message") {
|
|
10
39
|
const { message } = entry;
|
|
@@ -14,11 +43,22 @@ function renderEntry(entry, live = false) {
|
|
|
14
43
|
if (message.role === "system") {
|
|
15
44
|
return _jsx(Text, { dimColor: true, children: message.content }); // slash-command output / status notes
|
|
16
45
|
}
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
46
|
+
// Settled answers render as markdown (bold/code/lists/headers formatted, not raw `**`/backticks); the
|
|
47
|
+
// LIVE stream stays plain text (a half-open ``` fence can't swallow it) AND is height-bounded: while
|
|
48
|
+
// streaming we show only the tail that fits the window, so the dynamic frame can't overflow. Once the
|
|
49
|
+
// message settles it leaves `live` and renders in full via <Static> below, into scrollback.
|
|
50
|
+
if (live) {
|
|
51
|
+
// Prefer the answer once it starts; before then, tail the reasoning so a long "thinking" stream
|
|
52
|
+
// can't overflow either. Only the in-flight tail is shown here — never the whole message.
|
|
53
|
+
const src = message.content ? message.content : (message.reasoning ?? "");
|
|
54
|
+
if (!src)
|
|
55
|
+
return _jsx(Box, { marginBottom: 1 });
|
|
56
|
+
const { text, clipped } = liveTail(src, process.stdout.rows ?? 24, process.stdout.columns ?? 80);
|
|
57
|
+
const dim = !message.content; // reasoning is dim; the answer is full weight
|
|
58
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${clipped} more line${clipped === 1 ? "" : "s"} above (full text shown when complete)` }) : null, _jsx(Text, { dimColor: dim, children: text })] }));
|
|
59
|
+
}
|
|
60
|
+
// Thought process first, dimmed; the real answer follows at full weight.
|
|
61
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [message.reasoning ? _jsx(Text, { dimColor: true, children: message.reasoning }) : null, message.content ? _jsx(Markdown, { content: message.content }) : null] }));
|
|
22
62
|
}
|
|
23
63
|
return _jsx(ToolStep, { step: entry.step });
|
|
24
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|