@chances-ai/tui 13.0.0 → 15.0.0
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/api-key-prompt.d.ts +8 -15
- package/dist/api-key-prompt.d.ts.map +1 -1
- package/dist/api-key-prompt.js +21 -31
- package/dist/api-key-prompt.js.map +1 -1
- package/dist/app.d.ts +15 -21
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +180 -151
- package/dist/app.js.map +1 -1
- package/dist/code-view.d.ts +9 -0
- package/dist/code-view.d.ts.map +1 -0
- package/dist/code-view.js +28 -0
- package/dist/code-view.js.map +1 -0
- package/dist/diff-model.d.ts +64 -0
- package/dist/diff-model.d.ts.map +1 -0
- package/dist/diff-model.js +156 -0
- package/dist/diff-model.js.map +1 -0
- package/dist/diff-view.d.ts +13 -0
- package/dist/diff-view.d.ts.map +1 -0
- package/dist/diff-view.js +60 -0
- package/dist/diff-view.js.map +1 -0
- package/dist/highlight-to-segments.d.ts +18 -0
- package/dist/highlight-to-segments.d.ts.map +1 -0
- package/dist/highlight-to-segments.js +224 -0
- package/dist/highlight-to-segments.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +117 -0
- package/dist/markdown.js.map +1 -0
- package/dist/modal.d.ts +3 -2
- package/dist/modal.d.ts.map +1 -1
- package/dist/modal.js +3 -2
- package/dist/modal.js.map +1 -1
- package/dist/model-picker.d.ts +7 -39
- package/dist/model-picker.d.ts.map +1 -1
- package/dist/model-picker.js +14 -65
- package/dist/model-picker.js.map +1 -1
- package/dist/progress.d.ts +41 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +122 -0
- package/dist/progress.js.map +1 -0
- package/dist/select.d.ts +59 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +114 -0
- package/dist/select.js.map +1 -0
- package/dist/session-picker.d.ts +7 -15
- package/dist/session-picker.d.ts.map +1 -1
- package/dist/session-picker.js +14 -40
- package/dist/session-picker.js.map +1 -1
- package/dist/slash-typeahead.d.ts +34 -0
- package/dist/slash-typeahead.d.ts.map +1 -0
- package/dist/slash-typeahead.js +78 -0
- package/dist/slash-typeahead.js.map +1 -0
- package/dist/theme-context.d.ts +25 -0
- package/dist/theme-context.d.ts.map +1 -0
- package/dist/theme-context.js +24 -0
- package/dist/theme-context.js.map +1 -0
- package/dist/theme.d.ts +106 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +116 -0
- package/dist/theme.js.map +1 -0
- package/dist/tool-line.d.ts +33 -0
- package/dist/tool-line.d.ts.map +1 -0
- package/dist/tool-line.js +168 -0
- package/dist/tool-line.js.map +1 -0
- package/dist/tool-message.d.ts +18 -0
- package/dist/tool-message.d.ts.map +1 -0
- package/dist/tool-message.js +37 -0
- package/dist/tool-message.js.map +1 -0
- package/dist/view-model.d.ts +46 -1
- package/dist/view-model.d.ts.map +1 -1
- package/dist/view-model.js +109 -16
- package/dist/view-model.js.map +1 -1
- package/package.json +9 -4
package/dist/theme.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (5.9 / v14) The single home for the TUI's visual-language literals: glyphs +
|
|
3
|
+
* color palettes. Pure module — NO React, NO Ink — so every consumer (the
|
|
4
|
+
* pure diff/highlight/markdown cores AND the components) reads one source and
|
|
5
|
+
* the constants are unit-testable in isolation. The React seam lives in
|
|
6
|
+
* `theme-context.tsx`.
|
|
7
|
+
*
|
|
8
|
+
* Colors are emitted as Ink-compatible `rgb(r,g,b)` strings; Ink renders them
|
|
9
|
+
* through chalk, which downsamples truecolor → 256/16 by the terminal's
|
|
10
|
+
* detected level. We therefore keep ONE truecolor palette per mode and let
|
|
11
|
+
* chalk degrade — there is no hand-rolled 16-ANSI fallback table (5.9 §0).
|
|
12
|
+
*
|
|
13
|
+
* `NO_COLOR` (https://no-color.org) is honored explicitly here because chalk
|
|
14
|
+
* 5 / Ink 7 only read the `--no-color` *flag*, not the env var (codex R1
|
|
15
|
+
* MUST-2): when set, `resolveTheme` returns a palette whose every color is
|
|
16
|
+
* `undefined`, so components emit no `color`/`backgroundColor` and meaning is
|
|
17
|
+
* carried by glyphs + sigils alone (the diff `+`/`-`, the `⏺`/`⎿` shapes).
|
|
18
|
+
*
|
|
19
|
+
* Dark RGB values are the facts of claude-code's `darkTheme` visual language
|
|
20
|
+
* (verified `~/Projects/github/claude-code/src/utils/theme.ts`); light values
|
|
21
|
+
* track its `lightTheme`. Syntax colors are an OneDark-ish set legible on the
|
|
22
|
+
* respective background.
|
|
23
|
+
*/
|
|
24
|
+
const darkTheme = {
|
|
25
|
+
accent: "rgb(215,119,87)",
|
|
26
|
+
success: "rgb(78,186,101)",
|
|
27
|
+
error: "rgb(255,107,128)",
|
|
28
|
+
warning: "rgb(255,193,7)",
|
|
29
|
+
permission: "rgb(177,185,249)",
|
|
30
|
+
planMode: "rgb(72,150,140)",
|
|
31
|
+
autoAccept: "rgb(175,135,255)",
|
|
32
|
+
bashPink: "rgb(253,93,177)",
|
|
33
|
+
diffAddedBg: "rgb(34,92,43)",
|
|
34
|
+
diffRemovedBg: "rgb(122,41,54)",
|
|
35
|
+
diffAddedWordBg: "rgb(56,166,96)",
|
|
36
|
+
diffRemovedWordBg: "rgb(179,89,107)",
|
|
37
|
+
userMessageBg: "rgb(55,55,55)",
|
|
38
|
+
stall: "rgb(171,43,63)",
|
|
39
|
+
synKeyword: "rgb(198,120,221)",
|
|
40
|
+
synString: "rgb(152,195,121)",
|
|
41
|
+
synComment: "rgb(106,115,125)",
|
|
42
|
+
synNumber: "rgb(209,154,102)",
|
|
43
|
+
synFunction: "rgb(97,175,239)",
|
|
44
|
+
synType: "rgb(229,192,123)",
|
|
45
|
+
synLiteral: "rgb(86,182,194)",
|
|
46
|
+
synTitle: "rgb(97,175,239)",
|
|
47
|
+
synAttr: "rgb(209,154,102)",
|
|
48
|
+
};
|
|
49
|
+
const lightTheme = {
|
|
50
|
+
accent: "rgb(215,119,87)",
|
|
51
|
+
success: "rgb(44,122,57)",
|
|
52
|
+
error: "rgb(171,43,63)",
|
|
53
|
+
warning: "rgb(150,108,30)",
|
|
54
|
+
permission: "rgb(87,105,247)",
|
|
55
|
+
planMode: "rgb(0,102,102)",
|
|
56
|
+
autoAccept: "rgb(135,0,255)",
|
|
57
|
+
bashPink: "rgb(255,0,135)",
|
|
58
|
+
diffAddedBg: "rgb(105,219,124)",
|
|
59
|
+
diffRemovedBg: "rgb(255,168,180)",
|
|
60
|
+
diffAddedWordBg: "rgb(47,157,68)",
|
|
61
|
+
diffRemovedWordBg: "rgb(209,69,75)",
|
|
62
|
+
userMessageBg: "rgb(240,240,240)",
|
|
63
|
+
stall: "rgb(171,43,63)",
|
|
64
|
+
synKeyword: "rgb(166,38,164)",
|
|
65
|
+
synString: "rgb(80,161,79)",
|
|
66
|
+
synComment: "rgb(160,161,167)",
|
|
67
|
+
synNumber: "rgb(152,104,1)",
|
|
68
|
+
synFunction: "rgb(64,120,242)",
|
|
69
|
+
synType: "rgb(193,132,1)",
|
|
70
|
+
synLiteral: "rgb(1,132,188)",
|
|
71
|
+
synTitle: "rgb(64,120,242)",
|
|
72
|
+
synAttr: "rgb(152,104,1)",
|
|
73
|
+
};
|
|
74
|
+
/** Every color undefined ⇒ no color props emitted (glyphs/sigils carry meaning). */
|
|
75
|
+
const noColorTheme = {};
|
|
76
|
+
/** `NO_COLOR` (https://no-color.org): present and NON-EMPTY ⇒ disable color,
|
|
77
|
+
* regardless of value. An empty string does NOT disable (per the spec). */
|
|
78
|
+
export function isNoColor(env = process.env) {
|
|
79
|
+
const v = env.NO_COLOR;
|
|
80
|
+
return typeof v === "string" && v.length > 0;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve a palette. `NO_COLOR` wins over any setting; otherwise `'light'` →
|
|
84
|
+
* the light palette and `'dark'`/`'auto'`/undefined → dark.
|
|
85
|
+
*/
|
|
86
|
+
export function resolveTheme(setting, env = process.env) {
|
|
87
|
+
if (isNoColor(env))
|
|
88
|
+
return noColorTheme;
|
|
89
|
+
return setting === "light" ? lightTheme : darkTheme;
|
|
90
|
+
}
|
|
91
|
+
/** Build the glyph set for a platform. Exported as a function so tests can pin
|
|
92
|
+
* both the darwin (`⏺`) and non-darwin (`●`) dot without monkey-patching. */
|
|
93
|
+
export function makeGlyphs(platform = process.platform) {
|
|
94
|
+
return {
|
|
95
|
+
dot: platform === "darwin" ? "⏺" : "●",
|
|
96
|
+
branch: "⎿",
|
|
97
|
+
prompt: "❯",
|
|
98
|
+
blockquote: "▎",
|
|
99
|
+
plan: "⏸",
|
|
100
|
+
accept: "⏵⏵",
|
|
101
|
+
tick: "✓",
|
|
102
|
+
hr: "─",
|
|
103
|
+
bullet: "•",
|
|
104
|
+
thinking: "✻",
|
|
105
|
+
arrowDown: "↓",
|
|
106
|
+
arrowUp: "↑",
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export const GLYPHS = makeGlyphs();
|
|
110
|
+
/** Spinner pulse: 6 frames then their reverse = a 12-step in/out pulse
|
|
111
|
+
* (claude-code `Spinner.tsx` `[...frames, ...reversed]`). Tick ~120 ms. */
|
|
112
|
+
const SPINNER_BASE = ["·", "✢", "✱", "✶", "✻", "✽"];
|
|
113
|
+
export const SPINNER_FRAMES = [...SPINNER_BASE, ...[...SPINNER_BASE].reverse()];
|
|
114
|
+
/** Static glyph shown instead of the animation under reduced-motion / NO_COLOR. */
|
|
115
|
+
export const SPINNER_STATIC = "●";
|
|
116
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA+CH,MAAM,SAAS,GAAU;IACvB,MAAM,EAAE,iB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C,GAAG,YAAY,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAEnG,mFAAmF;AACnF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (5.9 / v14) Pure view-side tool-call label. Renders `⏺ Name(argSummary)` —
|
|
3
|
+
* see `tool-message.tsx`. This is a MINIMAL, NON-AUTHORITATIVE label (codex R1
|
|
4
|
+
* SHOULD-1): it only echoes the call's own args (available on the `tool:call`
|
|
5
|
+
* bus event, which carries no `ToolContext`). It deliberately does NOT claim
|
|
6
|
+
* create-vs-overwrite, byte counts, or diffs — that fidelity comes only from
|
|
7
|
+
* the richer permission summary (`tool:permission`), which the view stashes
|
|
8
|
+
* and renders under the `⎿` branch (see `view-model.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Pure `(name, args) => string`, so it is fully unit-testable without Ink.
|
|
11
|
+
*/
|
|
12
|
+
/** Collapse a leading home-dir to `~`. `home` is injectable for deterministic
|
|
13
|
+
* tests; defaults to the real home directory. Handles both POSIX (`/`) and
|
|
14
|
+
* Windows (`\`) separators after the home prefix (codex R2 NICE-8). */
|
|
15
|
+
export declare function homeRelative(path: string, home?: string): string;
|
|
16
|
+
/** Display name for a tool: builtin names verbatim; `mcp__<server>__<tool>`
|
|
17
|
+
* shown as `<server›>`. Edit/write get a claude-code-style verb. */
|
|
18
|
+
export declare function toolDisplayName(name: string): string;
|
|
19
|
+
/** `mcp__<server>__<tool>` → `{server, tool}`; null for non-MCP or malformed
|
|
20
|
+
* names (empty server — codex R2 NICE-9). A `mcp__<server>` with no `__tool`
|
|
21
|
+
* is allowed (server-level), but an empty server component is rejected. */
|
|
22
|
+
export declare function parseMcpName(name: string): {
|
|
23
|
+
server: string;
|
|
24
|
+
tool: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* The parenthesized argument summary for the header. Empty string ⇒ the header
|
|
28
|
+
* renders just `⏺ Name` with no parens.
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatToolCall(name: string, args: unknown, opts?: {
|
|
31
|
+
home?: string;
|
|
32
|
+
}): string;
|
|
33
|
+
//# sourceMappingURL=tool-line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-line.d.ts","sourceRoot":"","sources":["../src/tool-line.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH;;wEAEwE;AACxE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAO3E;AAQD;qEACqE;AACrE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmCpD;AAED;;4EAE4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOlF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAsD5F"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (5.9 / v14) Pure view-side tool-call label. Renders `⏺ Name(argSummary)` —
|
|
3
|
+
* see `tool-message.tsx`. This is a MINIMAL, NON-AUTHORITATIVE label (codex R1
|
|
4
|
+
* SHOULD-1): it only echoes the call's own args (available on the `tool:call`
|
|
5
|
+
* bus event, which carries no `ToolContext`). It deliberately does NOT claim
|
|
6
|
+
* create-vs-overwrite, byte counts, or diffs — that fidelity comes only from
|
|
7
|
+
* the richer permission summary (`tool:permission`), which the view stashes
|
|
8
|
+
* and renders under the `⎿` branch (see `view-model.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Pure `(name, args) => string`, so it is fully unit-testable without Ink.
|
|
11
|
+
*/
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
/** Read a string property from an unknown JSON args bag, or "" if absent. */
|
|
14
|
+
function s(args, key) {
|
|
15
|
+
if (args && typeof args === "object" && key in args) {
|
|
16
|
+
const v = args[key];
|
|
17
|
+
if (typeof v === "string")
|
|
18
|
+
return v;
|
|
19
|
+
if (typeof v === "number" || typeof v === "boolean")
|
|
20
|
+
return String(v);
|
|
21
|
+
}
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
/** Collapse a leading home-dir to `~`. `home` is injectable for deterministic
|
|
25
|
+
* tests; defaults to the real home directory. Handles both POSIX (`/`) and
|
|
26
|
+
* Windows (`\`) separators after the home prefix (codex R2 NICE-8). */
|
|
27
|
+
export function homeRelative(path, home = homedir()) {
|
|
28
|
+
if (!path || !home)
|
|
29
|
+
return path;
|
|
30
|
+
if (path === home)
|
|
31
|
+
return "~";
|
|
32
|
+
if (path.startsWith(`${home}/`) || path.startsWith(`${home}\\`)) {
|
|
33
|
+
return `~${path.slice(home.length)}`;
|
|
34
|
+
}
|
|
35
|
+
return path;
|
|
36
|
+
}
|
|
37
|
+
/** Truncate a single-line value for the inline label. */
|
|
38
|
+
function clip(text, max = 60) {
|
|
39
|
+
const oneLine = text.replace(/\s+/g, " ").trim();
|
|
40
|
+
return oneLine.length <= max ? oneLine : `${oneLine.slice(0, max - 1)}…`;
|
|
41
|
+
}
|
|
42
|
+
/** Display name for a tool: builtin names verbatim; `mcp__<server>__<tool>`
|
|
43
|
+
* shown as `<server›>`. Edit/write get a claude-code-style verb. */
|
|
44
|
+
export function toolDisplayName(name) {
|
|
45
|
+
const mcp = parseMcpName(name);
|
|
46
|
+
if (mcp)
|
|
47
|
+
return mcp.server;
|
|
48
|
+
switch (name) {
|
|
49
|
+
case "edit":
|
|
50
|
+
return "Edit";
|
|
51
|
+
case "write":
|
|
52
|
+
return "Write";
|
|
53
|
+
case "read":
|
|
54
|
+
return "Read";
|
|
55
|
+
case "bash":
|
|
56
|
+
return "Bash";
|
|
57
|
+
case "grep":
|
|
58
|
+
return "Grep";
|
|
59
|
+
case "glob":
|
|
60
|
+
return "Glob";
|
|
61
|
+
case "diff":
|
|
62
|
+
return "Diff";
|
|
63
|
+
case "web_fetch":
|
|
64
|
+
return "Fetch";
|
|
65
|
+
case "task":
|
|
66
|
+
return "Task";
|
|
67
|
+
case "lsp":
|
|
68
|
+
return "Lsp";
|
|
69
|
+
case "pty":
|
|
70
|
+
return "Pty";
|
|
71
|
+
case "memory_save":
|
|
72
|
+
return "Memory";
|
|
73
|
+
case "memory_delete":
|
|
74
|
+
return "Memory";
|
|
75
|
+
case "memory_list":
|
|
76
|
+
return "Memory";
|
|
77
|
+
default:
|
|
78
|
+
return name;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** `mcp__<server>__<tool>` → `{server, tool}`; null for non-MCP or malformed
|
|
82
|
+
* names (empty server — codex R2 NICE-9). A `mcp__<server>` with no `__tool`
|
|
83
|
+
* is allowed (server-level), but an empty server component is rejected. */
|
|
84
|
+
export function parseMcpName(name) {
|
|
85
|
+
if (!name.startsWith("mcp__"))
|
|
86
|
+
return null;
|
|
87
|
+
const rest = name.slice("mcp__".length);
|
|
88
|
+
const sep = rest.indexOf("__");
|
|
89
|
+
const server = sep < 0 ? rest : rest.slice(0, sep);
|
|
90
|
+
if (server.length === 0)
|
|
91
|
+
return null;
|
|
92
|
+
return { server, tool: sep < 0 ? "" : rest.slice(sep + 2) };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The parenthesized argument summary for the header. Empty string ⇒ the header
|
|
96
|
+
* renders just `⏺ Name` with no parens.
|
|
97
|
+
*/
|
|
98
|
+
export function formatToolCall(name, args, opts) {
|
|
99
|
+
const home = opts?.home;
|
|
100
|
+
const rel = (p) => homeRelative(p, home ?? homedir());
|
|
101
|
+
const mcp = parseMcpName(name);
|
|
102
|
+
if (mcp)
|
|
103
|
+
return mcp.tool;
|
|
104
|
+
switch (name) {
|
|
105
|
+
case "read":
|
|
106
|
+
case "edit":
|
|
107
|
+
case "write":
|
|
108
|
+
case "diff":
|
|
109
|
+
return clip(rel(s(args, "path")));
|
|
110
|
+
case "bash": {
|
|
111
|
+
const desc = s(args, "description");
|
|
112
|
+
return clip(desc || s(args, "command"));
|
|
113
|
+
}
|
|
114
|
+
case "grep": {
|
|
115
|
+
const pattern = s(args, "pattern");
|
|
116
|
+
const path = s(args, "path");
|
|
117
|
+
return clip(path ? `${pattern} in ${rel(path)}` : pattern);
|
|
118
|
+
}
|
|
119
|
+
case "glob": {
|
|
120
|
+
const pattern = s(args, "pattern");
|
|
121
|
+
const path = s(args, "path");
|
|
122
|
+
return clip(path ? `${pattern} in ${rel(path)}` : pattern);
|
|
123
|
+
}
|
|
124
|
+
case "web_fetch":
|
|
125
|
+
return clip(s(args, "url"));
|
|
126
|
+
case "task": {
|
|
127
|
+
const sub = s(args, "subagent_type");
|
|
128
|
+
const desc = s(args, "description");
|
|
129
|
+
return clip([sub, desc].filter(Boolean).join(": ") || desc || sub);
|
|
130
|
+
}
|
|
131
|
+
case "lsp": {
|
|
132
|
+
const op = s(args, "op");
|
|
133
|
+
const path = s(args, "path");
|
|
134
|
+
const query = s(args, "query");
|
|
135
|
+
const detail = path ? rel(path) : query;
|
|
136
|
+
return clip([op, detail].filter(Boolean).join(" "));
|
|
137
|
+
}
|
|
138
|
+
case "pty": {
|
|
139
|
+
const op = s(args, "op");
|
|
140
|
+
const cmd = s(args, "command");
|
|
141
|
+
return clip([op, cmd].filter(Boolean).join(" "));
|
|
142
|
+
}
|
|
143
|
+
case "memory_save":
|
|
144
|
+
case "memory_delete":
|
|
145
|
+
return clip(s(args, "name"));
|
|
146
|
+
case "memory_list":
|
|
147
|
+
return clip(s(args, "scope"));
|
|
148
|
+
default:
|
|
149
|
+
return compactArgs(args);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** Fallback for unknown tools: a compact `key=value` join of scalar args. */
|
|
153
|
+
function compactArgs(args) {
|
|
154
|
+
if (!args || typeof args !== "object")
|
|
155
|
+
return "";
|
|
156
|
+
const parts = [];
|
|
157
|
+
for (const [k, v] of Object.entries(args)) {
|
|
158
|
+
if (v === null || v === undefined)
|
|
159
|
+
continue;
|
|
160
|
+
if (typeof v === "object")
|
|
161
|
+
continue; // skip nested for a one-liner
|
|
162
|
+
parts.push(`${k}=${String(v)}`);
|
|
163
|
+
if (parts.length >= 3)
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return clip(parts.join(" "));
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=tool-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-line.js","sourceRoot":"","sources":["../src/tool-line.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,6EAA6E;AAC7E,SAAS,CAAC,CAAC,IAAa,EAAE,GAAW;IACnC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACpD,MAAM,CAAC,GAAI,IAAgC,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,CAAC,CAAC;QACpC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;wEAEwE;AACxE,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAe,OAAO,EAAE;IACjE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,GAAG,CAAC;IAC9B,IAAI,IAAI,CAAC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,WAAW,CAAC,IAAa;IAChC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAA+B,CAAC,EAAE,CAAC;QACrE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;YAAE,SAAS;QAC5C,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,SAAS,CAAC,8BAA8B;QACnE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;YAAE,MAAM;IAC/B,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
export interface ToolMessageProps {
|
|
3
|
+
/** Raw tool name (e.g. "edit", "mcp__github__create_issue"). */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Pure arg summary from `formatToolCall`. */
|
|
6
|
+
argSummary: string;
|
|
7
|
+
/** undefined ⇒ still running; true/false ⇒ finished ok/error. */
|
|
8
|
+
ok?: boolean;
|
|
9
|
+
/** Result preview text (already line-capped by `previewToolResult`). */
|
|
10
|
+
result?: string;
|
|
11
|
+
/** Raw `linesDiff` text for write/edit (rendered under the ⎿ branch). */
|
|
12
|
+
diff?: string;
|
|
13
|
+
/** Whether `diff` is whole-file-anchored (write) vs snippet (edit). */
|
|
14
|
+
anchored?: boolean;
|
|
15
|
+
width?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function ToolMessage({ name, argSummary, ok, result, diff, anchored, width, }: ToolMessageProps): JSX.Element;
|
|
18
|
+
//# sourceMappingURL=tool-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-message.d.ts","sourceRoot":"","sources":["../src/tool-message.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAajC,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,UAAU,EACV,EAAE,EACF,MAAM,EACN,IAAI,EACJ,QAAgB,EAChB,KAAK,GACN,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CA4BhC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* (5.9 / v14) claude-code-style tool block:
|
|
4
|
+
* ⏺ Name(argSummary)
|
|
5
|
+
* ⎿ result one-liner
|
|
6
|
+
* <structured diff for write/edit>
|
|
7
|
+
*
|
|
8
|
+
* The status dot color reflects the FINAL state once known (running while
|
|
9
|
+
* `ok === undefined`, then success/error) — the view-model fills `ok`/`result`/
|
|
10
|
+
* `diff` onto the still-live tool line before committing it, so the dot never
|
|
11
|
+
* has to mutate after commit (append-only preserved; see `view-model.ts`).
|
|
12
|
+
*/
|
|
13
|
+
import { Box, Text } from "ink";
|
|
14
|
+
import { DiffView } from "./diff-view.js";
|
|
15
|
+
import { toolDisplayName } from "./tool-line.js";
|
|
16
|
+
import { useTheme } from "./theme-context.js";
|
|
17
|
+
/** Left indent (cols) the embedded diff sits under the `⎿` branch. */
|
|
18
|
+
const DIFF_INDENT = 5;
|
|
19
|
+
function termColumns() {
|
|
20
|
+
const cols = process.stdout?.columns;
|
|
21
|
+
return typeof cols === "number" && cols > 0 ? cols : 80;
|
|
22
|
+
}
|
|
23
|
+
export function ToolMessage({ name, argSummary, ok, result, diff, anchored = false, width, }) {
|
|
24
|
+
const { theme, glyphs } = useTheme();
|
|
25
|
+
const dotColor = ok === undefined ? theme.accent : ok ? theme.success : theme.error;
|
|
26
|
+
const display = toolDisplayName(name);
|
|
27
|
+
const resultLines = result ? splitPreview(result) : [];
|
|
28
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: dotColor, children: glyphs.dot }), " ", _jsx(Text, { bold: true, children: display }), argSummary ? `(${argSummary})` : ""] }), resultLines.map((line, i) => (_jsxs(Text, { color: ok === false ? theme.error : undefined, dimColor: ok !== false, children: [i === 0 ? ` ${glyphs.branch} ` : " ", line] }, i))), diff ? (_jsx(Box, { paddingLeft: DIFF_INDENT, children: _jsx(DiffView, { diff: diff, anchored: anchored, width: (width ?? termColumns()) - DIFF_INDENT }) })) : null] }));
|
|
29
|
+
}
|
|
30
|
+
/** Split a result preview into display lines (cap defensively so a pathological
|
|
31
|
+
* result can't blow up the block; the view-model already line-caps via
|
|
32
|
+
* previewToolResult, this is a second floor). */
|
|
33
|
+
function splitPreview(result) {
|
|
34
|
+
const lines = result.split("\n");
|
|
35
|
+
return lines.length > 20 ? [...lines.slice(0, 20), `… +${lines.length - 20} more`] : lines;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=tool-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-message.js","sourceRoot":"","sources":["../src/tool-message.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE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CAAC,CAAC,CAAC,EAAE,IAC/B,EACN,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC5B,MAAC,IAAI,IAAS,KAAK,EAAE,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,KAAK,KAAK,aAChF,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,EACzC,IAAI,KAFI,CAAC,CAGL,CACR,CAAC,EACD,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,GAAG,IAAC,WAAW,EAAE,WAAW,YAG3B,KAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,WAAW,EAAE,CAAC,GAAG,WAAW,GAAI,GACvF,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC;AAED;;kDAEkD;AAClD,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7F,CAAC"}
|
package/dist/view-model.d.ts
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import type { ApprovalMode, ApprovalState, EventBus } from "@chances-ai/runtime";
|
|
2
2
|
import type { PermissionDecision, PermissionRequest } from "@chances-ai/tools";
|
|
3
3
|
import { type FrameScheduler } from "./frame-scheduler.js";
|
|
4
|
-
|
|
4
|
+
/** (5.9) Extract the `linesDiff` block (from the first `@@ -d` hunk header to
|
|
5
|
+
* the end) out of a write/edit permission summary, or null when the summary
|
|
6
|
+
* carries no diff (single-line edits, "diff preview skipped", non-write tools). */
|
|
7
|
+
export declare function extractDiff(summary: string): string | null;
|
|
8
|
+
export type LineKind = "user" | "assistant" | "tool" | "error" | "info";
|
|
5
9
|
export interface Line {
|
|
6
10
|
kind: LineKind;
|
|
11
|
+
/** user/assistant/info/error body — OR, for a `tool` line, the pure arg
|
|
12
|
+
* summary from `formatToolCall`. */
|
|
7
13
|
text: string;
|
|
14
|
+
/** `tool`: undefined while running, then the result's ok/err. */
|
|
8
15
|
ok?: boolean;
|
|
16
|
+
/** `tool`: raw tool name (drives the ⏺ header + display-name mapping). */
|
|
17
|
+
toolName?: string;
|
|
18
|
+
/** `tool`: correlates the call / permission / result bus events. */
|
|
19
|
+
callId?: string;
|
|
20
|
+
/** `tool`: result preview shown under the ⎿ branch. */
|
|
21
|
+
result?: string;
|
|
22
|
+
/** `tool`: raw `linesDiff` text for write/edit, rendered under ⎿ (5.9). */
|
|
23
|
+
diff?: string;
|
|
24
|
+
/** `tool`: whether `diff` is whole-file-anchored (write) vs snippet (edit). */
|
|
25
|
+
anchored?: boolean;
|
|
9
26
|
}
|
|
10
27
|
interface Pending {
|
|
11
28
|
req: PermissionRequest;
|
|
@@ -60,6 +77,15 @@ export declare class ChatViewModel {
|
|
|
60
77
|
private readonly toolResultPreviewLines;
|
|
61
78
|
/** Non-null while a coalesced delta frame is queued (see `scheduleBump`). */
|
|
62
79
|
private pendingFrame;
|
|
80
|
+
/**
|
|
81
|
+
* (5.9) Diff blocks parsed from `tool:permission` summaries, keyed by callId,
|
|
82
|
+
* awaiting their `tool:result` so they can be attached to the tool line and
|
|
83
|
+
* rendered under the `⎿` branch. Emitted before `gate.evaluate` for every
|
|
84
|
+
* write/edit call (engine.ts:763) — so this populates even under
|
|
85
|
+
* auto-edit/yolo, giving transcript diffs in all approval modes with zero
|
|
86
|
+
* engine/contract change. Cleared on detach/clear so it can't leak.
|
|
87
|
+
*/
|
|
88
|
+
private readonly diffStash;
|
|
63
89
|
/**
|
|
64
90
|
* (5.3) Optional session approval-mode holder. When wired (interactive
|
|
65
91
|
* `chat`), the footer reflects `approvalMode` and Shift+Tab / `/approval`
|
|
@@ -84,6 +110,25 @@ export declare class ChatViewModel {
|
|
|
84
110
|
* streaming, or an in-flight tool / tool-result line awaiting its terminal
|
|
85
111
|
* event. Usually 0–1 entries. */
|
|
86
112
|
liveLines(): Line[];
|
|
113
|
+
/** (5.9) The still-live `tool` line for a callId (normally the last line).
|
|
114
|
+
* Returns a mutable ref so `tool:result` can fill it in place — safe because
|
|
115
|
+
* it is in the live region (index ≥ committedCount), not yet committed. */
|
|
116
|
+
private findLiveTool;
|
|
117
|
+
/**
|
|
118
|
+
* (5.9 codex R2 MUST-1) Advance `committedCount` toward `target` but NEVER
|
|
119
|
+
* past the earliest still-running tool line (`kind:"tool"` with `ok ===
|
|
120
|
+
* undefined`). A sync/background subagent emits its own `tool:call` /
|
|
121
|
+
* `assistant:delta` frames on the SAME bus BETWEEN a parent `task` tool's
|
|
122
|
+
* call and its result; without this clamp those frames would commit the
|
|
123
|
+
* parent's tool line, after which `findLiveTool` could no longer fill it
|
|
124
|
+
* (mutating a committed line breaks the `<Static>` append-only invariant) and
|
|
125
|
+
* the parent result would spawn a duplicate empty block. Keeping every
|
|
126
|
+
* unresolved tool line live until its result arrives makes the fill always
|
|
127
|
+
* append-only-safe. `turn:end` force-commits unconditionally (the turn is
|
|
128
|
+
* over). Monotonic: `target ≥ committedCount`, and the result is in
|
|
129
|
+
* `[committedCount, target]`.
|
|
130
|
+
*/
|
|
131
|
+
private commitThrough;
|
|
87
132
|
private bump;
|
|
88
133
|
/**
|
|
89
134
|
* (5.8) Coalesce a streamed-token re-render onto the next frame. The first
|
package/dist/view-model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-model.d.ts","sourceRoot":"","sources":["../src/view-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"view-model.d.ts","sourceRoot":"","sources":["../src/view-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;AAG9B;;oFAEoF;AACpF,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI1D;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AACxE,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf;yCACqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,UAAU,OAAO;IACf,GAAG,EAAE,iBAAiB,CAAC;IACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IA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