gnosys 5.8.6 → 5.9.1
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/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +158 -94
- package/dist/index.js.map +1 -1
- package/dist/lib/chat/boot-splash.d.ts +17 -0
- package/dist/lib/chat/boot-splash.d.ts.map +1 -0
- package/dist/lib/chat/boot-splash.js +11 -0
- package/dist/lib/chat/boot-splash.js.map +1 -0
- package/dist/lib/chat/components/CitationText.d.ts +42 -0
- package/dist/lib/chat/components/CitationText.d.ts.map +1 -0
- package/dist/lib/chat/components/CitationText.js +41 -0
- package/dist/lib/chat/components/CitationText.js.map +1 -0
- package/dist/lib/chat/components/MarkdownRenderer.d.ts +29 -0
- package/dist/lib/chat/components/MarkdownRenderer.d.ts.map +1 -0
- package/dist/lib/chat/components/MarkdownRenderer.js +155 -0
- package/dist/lib/chat/components/MarkdownRenderer.js.map +1 -0
- package/dist/lib/chat/components/ToolCallCard.d.ts +20 -0
- package/dist/lib/chat/components/ToolCallCard.d.ts.map +1 -0
- package/dist/lib/chat/components/ToolCallCard.js +20 -0
- package/dist/lib/chat/components/ToolCallCard.js.map +1 -0
- package/dist/lib/chat/render.d.ts.map +1 -1
- package/dist/lib/chat/render.js +40 -26
- package/dist/lib/chat/render.js.map +1 -1
- package/dist/lib/chat/theme.d.ts +39 -0
- package/dist/lib/chat/theme.d.ts.map +1 -0
- package/dist/lib/chat/theme.js +43 -0
- package/dist/lib/chat/theme.js.map +1 -0
- package/dist/lib/chat/types.d.ts +13 -0
- package/dist/lib/chat/types.d.ts.map +1 -1
- package/dist/lib/projectIdentity.d.ts.map +1 -1
- package/dist/lib/projectIdentity.js +14 -0
- package/dist/lib/projectIdentity.js.map +1 -1
- package/dist/lib/resolver.d.ts.map +1 -1
- package/dist/lib/resolver.js +39 -4
- package/dist/lib/resolver.js.map +1 -1
- package/dist/lib/setup/sections/preferences.d.ts +8 -3
- package/dist/lib/setup/sections/preferences.d.ts.map +1 -1
- package/dist/lib/setup/sections/preferences.js +42 -15
- package/dist/lib/setup/sections/preferences.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v5.9.0 chat TUI — inline citation transformer.
|
|
3
|
+
*
|
|
4
|
+
* Scans a chunk of plain text for memory-id patterns (prefix-ULID or
|
|
5
|
+
* prefix-uuid forms) and renders each occurrence as an OSC8 hyperlink
|
|
6
|
+
* in the brand-hover red. Non-matching text passes through unchanged.
|
|
7
|
+
*
|
|
8
|
+
* Patterns matched:
|
|
9
|
+
* - `deci-01HXXJK2ABCDEFGHIJ` (ULID, Crockford base32)
|
|
10
|
+
* - `pref-some-key` (kebab-case key form, e.g. `pref-code-style`)
|
|
11
|
+
* - `mem-1738447692-abc` (legacy timestamp+random imports)
|
|
12
|
+
* - Optional surrounding brackets: `[gnosys-ai · deci-01H…]` → the inner
|
|
13
|
+
* id portion is the hyperlink target.
|
|
14
|
+
*
|
|
15
|
+
* URI scheme: `gnosys://memory/<full-id>` (matches v5.8.3 OSC8 work).
|
|
16
|
+
* Stripped ellipses are preserved in the visible text but the URI carries
|
|
17
|
+
* the full id when available.
|
|
18
|
+
*/
|
|
19
|
+
import React from "react";
|
|
20
|
+
export interface CitationTextProps {
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Splits `text` on memory-id citations and renders each match as a
|
|
25
|
+
* brand-red OSC8 hyperlink. Returns a React fragment safe to drop into
|
|
26
|
+
* any ink `<Text>` block.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CitationText: React.FC<CitationTextProps>;
|
|
29
|
+
interface PlainSegment {
|
|
30
|
+
kind: "plain";
|
|
31
|
+
text: string;
|
|
32
|
+
}
|
|
33
|
+
interface CitationSegment {
|
|
34
|
+
kind: "citation";
|
|
35
|
+
id: string;
|
|
36
|
+
display: string;
|
|
37
|
+
}
|
|
38
|
+
type Segment = PlainSegment | CitationSegment;
|
|
39
|
+
/** Split `text` into plain / citation segments in left-to-right order. */
|
|
40
|
+
export declare function splitCitations(text: string): Segment[];
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=CitationText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CitationText.d.ts","sourceRoot":"","sources":["../../../../src/lib/chat/components/CitationText.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAepD,CAAC;AAEF,UAAU,YAAY;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,eAAe;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,KAAK,OAAO,GAAG,YAAY,GAAG,eAAe,CAAC;AAE9C,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAiBtD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
import { THEME } from "../theme.js";
|
|
4
|
+
import { memoryUri, osc8Wrap } from "../../idFormat.js";
|
|
5
|
+
// Single regex that matches any of the supported id shapes:
|
|
6
|
+
// - ULID-style: `deci-01HXXJK2…` (kebab prefix + suffix containing at
|
|
7
|
+
// least one uppercase letter or digit)
|
|
8
|
+
// - pref-*: `pref-code-style` (explicit pref- prefix, lowercase
|
|
9
|
+
// kebab — opt-in by literal prefix to avoid false-
|
|
10
|
+
// positives on prose like "well-known" / "test-cases")
|
|
11
|
+
// Capture group 1 is the full id (no ellipsis); group 2 is the ellipsis.
|
|
12
|
+
const CITATION_RE = /\b(pref-[a-z0-9][a-z0-9-]*|[a-z]+-[a-zA-Z0-9-]*[A-Z0-9][a-zA-Z0-9-]*)(…)?/g;
|
|
13
|
+
/**
|
|
14
|
+
* Splits `text` on memory-id citations and renders each match as a
|
|
15
|
+
* brand-red OSC8 hyperlink. Returns a React fragment safe to drop into
|
|
16
|
+
* any ink `<Text>` block.
|
|
17
|
+
*/
|
|
18
|
+
export const CitationText = ({ text }) => {
|
|
19
|
+
const segments = splitCitations(text);
|
|
20
|
+
return (_jsx(_Fragment, { children: segments.map((seg, i) => seg.kind === "citation" ? (_jsx(Text, { color: THEME.accentHover, underline: true, children: osc8Wrap(memoryUri(seg.id), seg.display) }, i)) : (_jsx(Text, { children: seg.text }, i))) }));
|
|
21
|
+
};
|
|
22
|
+
/** Split `text` into plain / citation segments in left-to-right order. */
|
|
23
|
+
export function splitCitations(text) {
|
|
24
|
+
const out = [];
|
|
25
|
+
let lastEnd = 0;
|
|
26
|
+
for (const match of text.matchAll(CITATION_RE)) {
|
|
27
|
+
const id = match[1];
|
|
28
|
+
const ellipsis = match[2] ?? "";
|
|
29
|
+
const start = match.index ?? 0;
|
|
30
|
+
if (start > lastEnd) {
|
|
31
|
+
out.push({ kind: "plain", text: text.slice(lastEnd, start) });
|
|
32
|
+
}
|
|
33
|
+
out.push({ kind: "citation", id, display: id + ellipsis });
|
|
34
|
+
lastEnd = start + id.length + ellipsis.length;
|
|
35
|
+
}
|
|
36
|
+
if (lastEnd < text.length) {
|
|
37
|
+
out.push({ kind: "plain", text: text.slice(lastEnd) });
|
|
38
|
+
}
|
|
39
|
+
return out.length > 0 ? out : [{ kind: "plain", text }];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=CitationText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CitationText.js","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AAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;YACpB,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;QAC3D,OAAO,GAAG,KAAK,GAAG,EAAE,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAChD,CAAC;IACD,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC1B,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v5.9.0 chat TUI — markdown renderer for assistant turns.
|
|
3
|
+
*
|
|
4
|
+
* Parses with `marked` (lexer only — we don't want HTML output), then
|
|
5
|
+
* walks the token tree and emits ink components with the brand palette.
|
|
6
|
+
*
|
|
7
|
+
* Supported:
|
|
8
|
+
* - Headings (h1-h6 → bold + brand-red prefix)
|
|
9
|
+
* - Paragraphs with inline bold / italic / inline code / strikethrough
|
|
10
|
+
* - Bulleted + numbered lists (nested)
|
|
11
|
+
* - Code blocks (cli-highlight for fenced langs; plain dim for unfenced)
|
|
12
|
+
* - Block quotes (left-bar accent + dim text)
|
|
13
|
+
* - Tables (simple aligned)
|
|
14
|
+
* - Horizontal rules
|
|
15
|
+
* - Links (rendered as text + " (url)" in muted color)
|
|
16
|
+
*
|
|
17
|
+
* Out of scope (will fall through to plain text):
|
|
18
|
+
* - HTML inside markdown
|
|
19
|
+
* - Footnotes (GFM extension)
|
|
20
|
+
*
|
|
21
|
+
* Performance: parser AST is memoized per-input-string. Re-render of an
|
|
22
|
+
* unchanged turn is free.
|
|
23
|
+
*/
|
|
24
|
+
import React from "react";
|
|
25
|
+
export interface MarkdownRendererProps {
|
|
26
|
+
text: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const MarkdownRenderer: React.FC<MarkdownRendererProps>;
|
|
29
|
+
//# sourceMappingURL=MarkdownRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.d.ts","sourceRoot":"","sources":["../../../../src/lib/chat/components/MarkdownRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;AAOvC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAS5D,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* v5.9.0 chat TUI — markdown renderer for assistant turns.
|
|
4
|
+
*
|
|
5
|
+
* Parses with `marked` (lexer only — we don't want HTML output), then
|
|
6
|
+
* walks the token tree and emits ink components with the brand palette.
|
|
7
|
+
*
|
|
8
|
+
* Supported:
|
|
9
|
+
* - Headings (h1-h6 → bold + brand-red prefix)
|
|
10
|
+
* - Paragraphs with inline bold / italic / inline code / strikethrough
|
|
11
|
+
* - Bulleted + numbered lists (nested)
|
|
12
|
+
* - Code blocks (cli-highlight for fenced langs; plain dim for unfenced)
|
|
13
|
+
* - Block quotes (left-bar accent + dim text)
|
|
14
|
+
* - Tables (simple aligned)
|
|
15
|
+
* - Horizontal rules
|
|
16
|
+
* - Links (rendered as text + " (url)" in muted color)
|
|
17
|
+
*
|
|
18
|
+
* Out of scope (will fall through to plain text):
|
|
19
|
+
* - HTML inside markdown
|
|
20
|
+
* - Footnotes (GFM extension)
|
|
21
|
+
*
|
|
22
|
+
* Performance: parser AST is memoized per-input-string. Re-render of an
|
|
23
|
+
* unchanged turn is free.
|
|
24
|
+
*/
|
|
25
|
+
import React, { useMemo } from "react";
|
|
26
|
+
import { Box, Text } from "ink";
|
|
27
|
+
import { marked } from "marked";
|
|
28
|
+
import { highlight } from "cli-highlight";
|
|
29
|
+
import { THEME } from "../theme.js";
|
|
30
|
+
import { CitationText } from "./CitationText.js";
|
|
31
|
+
export const MarkdownRenderer = ({ text }) => {
|
|
32
|
+
const tokens = useMemo(() => marked.lexer(text), [text]);
|
|
33
|
+
return (_jsx(Box, { flexDirection: "column", children: tokens.map((tok, i) => (_jsx(BlockToken, { token: tok }, i))) }));
|
|
34
|
+
};
|
|
35
|
+
// ─── Block-level tokens ───────────────────────────────────────────────────
|
|
36
|
+
const BlockToken = ({ token }) => {
|
|
37
|
+
switch (token.type) {
|
|
38
|
+
case "heading":
|
|
39
|
+
return _jsx(HeadingToken, { token: token });
|
|
40
|
+
case "paragraph":
|
|
41
|
+
return _jsx(ParagraphToken, { token: token });
|
|
42
|
+
case "list":
|
|
43
|
+
return _jsx(ListToken, { token: token });
|
|
44
|
+
case "code":
|
|
45
|
+
return _jsx(CodeToken, { token: token });
|
|
46
|
+
case "blockquote":
|
|
47
|
+
return _jsx(BlockquoteToken, { token: token });
|
|
48
|
+
case "table":
|
|
49
|
+
return _jsx(TableToken, { token: token });
|
|
50
|
+
case "hr":
|
|
51
|
+
return (_jsx(Box, { marginY: 1, children: _jsx(Text, { color: THEME.border, children: "─".repeat(40) }) }));
|
|
52
|
+
case "space":
|
|
53
|
+
return _jsx(Box, { marginBottom: 0 });
|
|
54
|
+
default:
|
|
55
|
+
// Unknown token — print raw text so nothing is lost.
|
|
56
|
+
return (_jsx(Text, { color: THEME.text, children: token.raw ?? "" }));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const HeadingToken = ({ token }) => {
|
|
60
|
+
const prefix = "#".repeat(Math.min(token.depth, 6));
|
|
61
|
+
return (_jsxs(Box, { marginTop: token.depth === 1 ? 1 : 0, marginBottom: 0, children: [_jsxs(Text, { color: THEME.accent, bold: true, children: [prefix, " "] }), _jsx(Text, { color: THEME.text, bold: true, children: _jsx(InlineTokens, { tokens: token.tokens ?? [] }) })] }));
|
|
62
|
+
};
|
|
63
|
+
const ParagraphToken = ({ token }) => (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: THEME.text, children: _jsx(InlineTokens, { tokens: token.tokens ?? [] }) }) }));
|
|
64
|
+
const ListToken = ({ token, depth = 0, }) => {
|
|
65
|
+
const indent = " ".repeat(depth);
|
|
66
|
+
return (_jsx(Box, { flexDirection: "column", marginBottom: 1, children: token.items.map((item, i) => (_jsx(ListItem, { item: item, marker: token.ordered ? `${Number(token.start ?? 1) + i}.` : "·", indent: indent, depth: depth }, i))) }));
|
|
67
|
+
};
|
|
68
|
+
const ListItem = ({ item, marker, indent, depth }) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsxs(Text, { color: THEME.accent, children: [indent, marker, " "] }), _jsx(Text, { color: THEME.text, children: _jsx(InlineTokens, { tokens: inlineFromItem(item) }) })] }), item.tokens
|
|
69
|
+
.filter((t) => t.type === "list")
|
|
70
|
+
.map((sub, i) => (_jsx(ListToken, { token: sub, depth: depth + 1 }, i)))] }));
|
|
71
|
+
/** Pull just the inline content out of a list item (skip nested blocks). */
|
|
72
|
+
function inlineFromItem(item) {
|
|
73
|
+
// Find the first paragraph or text token; that's the visible content.
|
|
74
|
+
for (const tok of item.tokens) {
|
|
75
|
+
if (tok.type === "text") {
|
|
76
|
+
return tok.tokens ?? [{ type: "text", raw: tok.text, text: tok.text }];
|
|
77
|
+
}
|
|
78
|
+
if (tok.type === "paragraph") {
|
|
79
|
+
return tok.tokens ?? [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const CodeToken = ({ token }) => {
|
|
85
|
+
let body = token.text;
|
|
86
|
+
if (token.lang) {
|
|
87
|
+
try {
|
|
88
|
+
body = highlight(token.text, { language: token.lang, ignoreIllegals: true });
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Unknown language — fall back to plain.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: THEME.border, paddingX: 1, marginBottom: 1, children: [token.lang && (_jsx(Box, { marginBottom: 0, children: _jsx(Text, { color: THEME.muted, children: token.lang }) })), _jsx(Text, { children: body })] }));
|
|
95
|
+
};
|
|
96
|
+
const BlockquoteToken = ({ token }) => (_jsxs(Box, { marginBottom: 1, flexDirection: "row", children: [_jsx(Box, { marginRight: 1, children: _jsx(Text, { color: THEME.accent, children: "\u2502" }) }), _jsx(Box, { flexDirection: "column", children: (token.tokens ?? []).map((tok, i) => (_jsx(BlockToken, { token: tok }, i))) })] }));
|
|
97
|
+
const TableToken = ({ token }) => {
|
|
98
|
+
// Build a list of rows: header first, then body rows.
|
|
99
|
+
const rows = [
|
|
100
|
+
token.header.map((c) => extractInlineText(c.tokens ?? [])),
|
|
101
|
+
...token.rows.map((row) => row.map((c) => extractInlineText(c.tokens ?? []))),
|
|
102
|
+
];
|
|
103
|
+
// Column widths.
|
|
104
|
+
const colCount = rows[0].length;
|
|
105
|
+
const widths = Array(colCount).fill(0);
|
|
106
|
+
for (const row of rows) {
|
|
107
|
+
for (let i = 0; i < colCount; i++) {
|
|
108
|
+
widths[i] = Math.max(widths[i], (row[i] ?? "").length);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const sep = widths.map((w) => "─".repeat(w + 2)).join("┼");
|
|
112
|
+
return (_jsx(Box, { flexDirection: "column", marginBottom: 1, children: rows.map((row, ri) => (_jsxs(React.Fragment, { children: [_jsx(Box, { children: row.map((cell, ci) => (_jsxs(Text, { color: ri === 0 ? THEME.accent : THEME.text, bold: ri === 0, children: [" ", cell.padEnd(widths[ci]), " ", ci < colCount - 1 ? "│" : ""] }, ci))) }), ri === 0 && (_jsx(Box, { children: _jsx(Text, { color: THEME.border, children: sep }) }))] }, ri))) }));
|
|
113
|
+
};
|
|
114
|
+
// ─── Inline-level tokens ──────────────────────────────────────────────────
|
|
115
|
+
const InlineTokens = ({ tokens }) => (_jsx(_Fragment, { children: tokens.map((tok, i) => _jsx(InlineToken, { token: tok }, i)) }));
|
|
116
|
+
const InlineToken = ({ token }) => {
|
|
117
|
+
switch (token.type) {
|
|
118
|
+
case "text":
|
|
119
|
+
// v5.9.0 (#101 phase γ): scan plain text for memory-id citations and
|
|
120
|
+
// turn each match into a brand-red OSC8 hyperlink. Non-matching text
|
|
121
|
+
// passes through unchanged.
|
|
122
|
+
return _jsx(CitationText, { text: token.text });
|
|
123
|
+
case "strong":
|
|
124
|
+
return (_jsx(Text, { bold: true, color: THEME.accent, children: _jsx(InlineTokens, { tokens: token.tokens ?? [] }) }));
|
|
125
|
+
case "em":
|
|
126
|
+
return (_jsx(Text, { italic: true, children: _jsx(InlineTokens, { tokens: token.tokens ?? [] }) }));
|
|
127
|
+
case "codespan":
|
|
128
|
+
return (_jsxs(Text, { color: THEME.accentHover, backgroundColor: THEME.code, children: [" ", token.text, " "] }));
|
|
129
|
+
case "del":
|
|
130
|
+
return (_jsx(Text, { strikethrough: true, color: THEME.muted, children: _jsx(InlineTokens, { tokens: token.tokens ?? [] }) }));
|
|
131
|
+
case "link": {
|
|
132
|
+
const link = token;
|
|
133
|
+
// ink doesn't have a link primitive at the inline level — render text
|
|
134
|
+
// + " (url)" in muted. v5.8.3-style OSC8 wrap could go here later.
|
|
135
|
+
return (_jsxs(_Fragment, { children: [_jsx(Text, { color: THEME.accentHover, underline: true, children: _jsx(InlineTokens, { tokens: link.tokens ?? [] }) }), _jsxs(Text, { color: THEME.muted, children: [" (", link.href, ")"] })] }));
|
|
136
|
+
}
|
|
137
|
+
case "br":
|
|
138
|
+
return _jsx(_Fragment, { children: "\n" });
|
|
139
|
+
default:
|
|
140
|
+
return _jsx(_Fragment, { children: token.raw ?? "" });
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
function extractInlineText(tokens) {
|
|
144
|
+
return tokens
|
|
145
|
+
.map((t) => {
|
|
146
|
+
const tok = t;
|
|
147
|
+
if (typeof tok.text === "string")
|
|
148
|
+
return tok.text;
|
|
149
|
+
if (typeof tok.raw === "string")
|
|
150
|
+
return tok.raw;
|
|
151
|
+
return "";
|
|
152
|
+
})
|
|
153
|
+
.join("");
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=MarkdownRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.js","sourceRoot":"","sources":["../../../../src/lib/chat/components/MarkdownRenderer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMjD,MAAM,CAAC,MAAM,gBAAgB,GAAoC,CAAC,EAAE,IAAI,EA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AAE,SAAS,kBACvC,KAAC,YAAY,IAAC,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE,GAAI,GACtC,EACP,MAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,mBAAK,IAAI,CAAC,IAAI,SAAS,IAC9C,CACJ,CAAC;QACJ,CAAC;QACD,KAAK,IAAI;YACP,OAAO,4BAAG,IAAI,GAAI,CAAC;QACrB;YACE,OAAO,4BAAI,KAA0B,CAAC,GAAG,IAAI,EAAE,GAAI,CAAC;IACxD,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,iBAAiB,CAAC,MAAwB;IACjD,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,GAAG,GAAG,CAA+C,CAAC;QAC5D,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC;QAClD,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC,GAAG,CAAC;QAChD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v5.9.0 chat TUI — tool-call card.
|
|
3
|
+
*
|
|
4
|
+
* Renders one `gnosys-tool` invocation that happened inside the current
|
|
5
|
+
* assistant turn. Collapsed by default — shows just the tool name and a
|
|
6
|
+
* one-line args summary. The card can be expanded to reveal full args
|
|
7
|
+
* + truncated result via a parent-controlled `expanded` prop.
|
|
8
|
+
*
|
|
9
|
+
* Visual: rounded border in brand red on dark background, slight inset
|
|
10
|
+
* from the turn body. Errors render with the error red.
|
|
11
|
+
*/
|
|
12
|
+
import React from "react";
|
|
13
|
+
import type { ToolCallRecord } from "../types.js";
|
|
14
|
+
export interface ToolCallCardProps {
|
|
15
|
+
call: ToolCallRecord;
|
|
16
|
+
/** When true, show args + result. When false, only header + 1-line summary. */
|
|
17
|
+
expanded: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const ToolCallCard: React.FC<ToolCallCardProps>;
|
|
20
|
+
//# sourceMappingURL=ToolCallCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolCallCard.d.ts","sourceRoot":"","sources":["../../../../src/lib/chat/components/ToolCallCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,cAAc,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkEpD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import { THEME } from "../theme.js";
|
|
4
|
+
export const ToolCallCard = ({ call, expanded }) => {
|
|
5
|
+
const isError = !!call.error;
|
|
6
|
+
const borderColor = isError ? THEME.error : THEME.accent;
|
|
7
|
+
const argList = Object.entries(call.args);
|
|
8
|
+
const argSummary = argList.length === 0
|
|
9
|
+
? ""
|
|
10
|
+
: argList
|
|
11
|
+
.map(([k, v]) => `${k}=${truncate(String(v), 28)}`)
|
|
12
|
+
.join(" ");
|
|
13
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: borderColor, paddingX: 1, marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { color: borderColor, bold: true, children: [expanded ? "▼" : "▶", " ", call.tool] }), !expanded && argSummary && (_jsxs(Text, { color: THEME.muted, children: [" ", argSummary] }))] }), expanded && (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [argList.length > 0 && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: THEME.secondary, children: "args:" }), argList.map(([k, v]) => (_jsxs(Box, { marginLeft: 2, children: [_jsx(Text, { color: THEME.accent, children: k }), _jsx(Text, { color: THEME.muted, children: " = " }), _jsx(Text, { color: THEME.text, children: String(v) })] }, k)))] })), isError ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: THEME.error, children: "error:" }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: THEME.text, children: call.error }) })] })) : (call.result !== undefined && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: THEME.secondary, children: "result:" }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: THEME.text, children: truncate(call.result, 800) }) })] })))] }))] }));
|
|
14
|
+
};
|
|
15
|
+
function truncate(s, max) {
|
|
16
|
+
if (s.length <= max)
|
|
17
|
+
return s;
|
|
18
|
+
return s.slice(0, max - 1) + "…";
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ToolCallCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolCallCard.js","sourceRoot":"","sources":["../../../../src/lib/chat/components/ToolCallCard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAQpC,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9E,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IAEzD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,C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OAAO,EAAE,cAAc,EAAc,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/render.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAK3D,OAAO,EAAE,cAAc,EAAc,IAAI,EAAE,MAAM,YAAY,CAAC;AA8B9D,OAAO,EAAE,YAAY,EAAmB,MAAM,cAAc,CAAC;AAG7D,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,cAAc,CAAC;IAC9B,aAAa,EAAE,IAAI,EAAE,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,oEAAoE;IACpE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA20B1C,CAAC"}
|
package/dist/lib/chat/render.js
CHANGED
|
@@ -22,6 +22,10 @@ import SelectInput from "ink-select-input";
|
|
|
22
22
|
import Spinner from "ink-spinner";
|
|
23
23
|
import { dispatchCommand, listCommands } from "./commands.js";
|
|
24
24
|
import { SlashPalette, filterCommands } from "./SlashPalette.js";
|
|
25
|
+
import { THEME, ROLES } from "./theme.js";
|
|
26
|
+
import { BootSplash } from "./boot-splash.js";
|
|
27
|
+
import { MarkdownRenderer } from "./components/MarkdownRenderer.js";
|
|
28
|
+
import { ToolCallCard } from "./components/ToolCallCard.js";
|
|
25
29
|
import { appendEvent } from "./session.js";
|
|
26
30
|
import { runTurn, buildProvider } from "./llmTurn.js";
|
|
27
31
|
import { runRecall, reinforceMemory, buildRecallQuery } from "./recall.js";
|
|
@@ -639,6 +643,10 @@ export const ChatApp = ({ initialHeader, initialBuffer, config, projectId, onExi
|
|
|
639
643
|
setStatus({ kind: "streaming", partial });
|
|
640
644
|
lastRenderAt = Date.now();
|
|
641
645
|
};
|
|
646
|
+
// v5.9.0 (#101 phase δ): collect tool calls into a per-turn record list
|
|
647
|
+
// so the assistant turn can render them as inline cards instead of
|
|
648
|
+
// ephemeral system notices.
|
|
649
|
+
const turnToolCalls = [];
|
|
642
650
|
const result = await runTurn(configRef.current, {
|
|
643
651
|
buffer: [...buffer, userTurn],
|
|
644
652
|
userInput: text,
|
|
@@ -649,22 +657,20 @@ export const ChatApp = ({ initialHeader, initialBuffer, config, projectId, onExi
|
|
|
649
657
|
flushPartial();
|
|
650
658
|
},
|
|
651
659
|
onToolCall: (info) => {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
});
|
|
667
|
-
}
|
|
660
|
+
turnToolCalls.push({
|
|
661
|
+
tool: info.tool,
|
|
662
|
+
args: info.args,
|
|
663
|
+
result: info.error ? undefined : info.result,
|
|
664
|
+
error: info.error,
|
|
665
|
+
ts: nowIso(),
|
|
666
|
+
});
|
|
667
|
+
appendEvent(header.sessionId, {
|
|
668
|
+
type: "command",
|
|
669
|
+
ts: nowIso(),
|
|
670
|
+
name: `tool:${info.tool}`,
|
|
671
|
+
args: Object.entries(info.args).map(([k, v]) => `${k}=${v}`),
|
|
672
|
+
result: info.result?.slice(0, 200),
|
|
673
|
+
});
|
|
668
674
|
},
|
|
669
675
|
});
|
|
670
676
|
// v5.8.0 (#6): flush any partial that didn't make the last 16ms tick
|
|
@@ -703,6 +709,9 @@ export const ChatApp = ({ initialHeader, initialBuffer, config, projectId, onExi
|
|
|
703
709
|
provider: result.provider,
|
|
704
710
|
model: result.model,
|
|
705
711
|
citedMemoryIds: result.recalledIds,
|
|
712
|
+
// v5.9.0 (#101 phase δ): attach this turn's tool calls so they
|
|
713
|
+
// render as inline cards inside ConversationTurn.
|
|
714
|
+
toolCalls: turnToolCalls.length > 0 ? turnToolCalls : undefined,
|
|
706
715
|
};
|
|
707
716
|
setBuffer((b) => [...b, assistantTurn]);
|
|
708
717
|
appendEvent(header.sessionId, {
|
|
@@ -737,7 +746,7 @@ export const ChatApp = ({ initialHeader, initialBuffer, config, projectId, onExi
|
|
|
737
746
|
process.off("SIGINT", handler);
|
|
738
747
|
};
|
|
739
748
|
}, []);
|
|
740
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(ChatHeader, { info: header, recallScope: scope, threshold: threshold, pinnedCount: pinnedIds.length, focus: focusState.current, branchCount: focusState.branches.length }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [buffer.map((turn, i) => (_jsx(ConversationTurn, { turn: turn }, i))), status.kind === "streaming" && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color:
|
|
749
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(ChatHeader, { info: header, recallScope: scope, threshold: threshold, pinnedCount: pinnedIds.length, focus: focusState.current, branchCount: focusState.branches.length }), buffer.length === 0 && status.kind === "idle" && (_jsx(BootSplash, { subtitle: `memory for ai agents · ${header.provider}/${header.model}` })), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [buffer.map((turn, i) => (_jsx(ConversationTurn, { turn: turn }, i))), status.kind === "streaming" && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: ROLES.assistant, bold: true, children: "gnosys" }), _jsx(Text, { color: THEME.text, children: status.partial })] }))] }), systemNotice.length > 0 && (_jsx(Box, { flexDirection: "column", marginTop: 1, children: systemNotice.map((line, i) => (_jsx(Text, { dimColor: true, children: line }, i))) })), _jsx(Box, { marginTop: 1, children: _jsx(StatusLine, { status: status }) }), pendingIntent && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { color: THEME.accentHover, children: ["inferred: ", describeIntent(pendingIntent), isDestructive(pendingIntent.command) ? " (destructive)" : ""] }), _jsx(Text, { color: THEME.muted, children: "[Y]es \u00B7 [N]o \u00B7 [E]dit \u00B7 or type a new message" })] })), pendingChoice ? (_jsx(ChoosePicker, { block: pendingChoice, onSelect: async (option) => {
|
|
741
750
|
const selectionText = formatSelection(option);
|
|
742
751
|
appendEvent(header.sessionId, {
|
|
743
752
|
type: "choice_made",
|
|
@@ -804,33 +813,38 @@ const ChoosePicker = ({ block, onSelect }) => {
|
|
|
804
813
|
label: opt.detail ? `${opt.label} — ${opt.detail}` : opt.label,
|
|
805
814
|
value: opt.id,
|
|
806
815
|
}));
|
|
807
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { color:
|
|
816
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { color: THEME.accent, bold: true, children: block.prompt }), _jsx(SelectInput, { items: items, onSelect: (item) => {
|
|
808
817
|
const picked = block.options.find((o) => o.id === item.value);
|
|
809
818
|
if (picked)
|
|
810
819
|
onSelect(picked);
|
|
811
820
|
} })] }));
|
|
812
821
|
};
|
|
813
|
-
const ChatHeader = ({ info, recallScope, threshold, pinnedCount, focus, branchCount }) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color:
|
|
822
|
+
const ChatHeader = ({ info, recallScope, threshold, pinnedCount, focus, branchCount }) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: THEME.accent, bold: true, children: "gnosys" }), _jsx(Text, { color: THEME.muted, children: " \u00B7 " }), _jsxs(Text, { color: THEME.muted, children: ["session=", info.sessionId.slice(0, 8), "\u2026"] }), _jsx(Text, { color: THEME.muted, children: " \u00B7 " }), info.projectName && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: THEME.muted, children: ["project=", info.projectName] }), _jsx(Text, { color: THEME.muted, children: " \u00B7 " })] })), _jsxs(Text, { color: THEME.muted, children: [info.provider, "/", info.model] })] }), _jsxs(Box, { children: [_jsxs(Text, { color: THEME.muted, children: ["recall: scope=", recallScope] }), _jsx(Text, { color: THEME.muted, children: " \u00B7 " }), _jsxs(Text, { color: THEME.muted, children: ["threshold=", threshold.toFixed(2)] }), _jsx(Text, { color: THEME.muted, children: " \u00B7 " }), _jsxs(Text, { color: THEME.muted, children: ["pinned=", pinnedCount] }), focus && (_jsxs(_Fragment, { children: [_jsx(Text, { color: THEME.muted, children: " \u00B7 " }), _jsxs(Text, { color: THEME.accentHover, children: ["focus=", focus] })] })), branchCount > 0 && (_jsxs(_Fragment, { children: [_jsx(Text, { color: THEME.muted, children: " \u00B7 " }), _jsxs(Text, { color: THEME.muted, children: ["branches=", branchCount] })] }))] })] }));
|
|
814
823
|
const ConversationTurn = ({ turn }) => {
|
|
824
|
+
// v5.9.0 (#101 phase α): role-colored turn labels using the brand palette.
|
|
825
|
+
// - user label: brand red
|
|
826
|
+
// - assistant label: text primary (de-emphasized so prose carries it)
|
|
827
|
+
// - system: muted gray
|
|
815
828
|
if (turn.role === "user") {
|
|
816
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color:
|
|
829
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: ROLES.user, bold: true, children: "you" }), _jsx(Text, { color: THEME.text, children: turn.text })] }));
|
|
817
830
|
}
|
|
818
831
|
if (turn.role === "assistant") {
|
|
819
832
|
const cited = turn.citedMemoryIds ?? [];
|
|
820
|
-
|
|
833
|
+
const toolCalls = turn.toolCalls ?? [];
|
|
834
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: ROLES.assistant, bold: true, children: "gnosys" }), _jsx(MarkdownRenderer, { text: turn.text }), toolCalls.length > 0 && (_jsx(Box, { flexDirection: "column", marginTop: 1, children: toolCalls.map((call, i) => (_jsx(ToolCallCard, { call: call, expanded: false }, i))) })), cited.length > 0 && (_jsxs(Text, { color: THEME.muted, children: ["cited: ", cited.map((id) => `[${id}]`).join(" ")] }))] }));
|
|
821
835
|
}
|
|
822
|
-
return (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, {
|
|
836
|
+
return (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { color: ROLES.system, children: ["\u00B7 ", turn.text] }) }));
|
|
823
837
|
};
|
|
824
838
|
const StatusLine = ({ status }) => {
|
|
825
839
|
switch (status.kind) {
|
|
826
840
|
case "idle":
|
|
827
|
-
return _jsx(Text, {
|
|
841
|
+
return (_jsx(Text, { color: THEME.muted, children: "ready \u2014 type /help for commands, /quit to exit" }));
|
|
828
842
|
case "thinking":
|
|
829
|
-
return (_jsxs(Text, { color:
|
|
843
|
+
return (_jsxs(Text, { color: ROLES.spinner, children: [_jsx(Spinner, { type: "dots" }), " thinking\u2026"] }));
|
|
830
844
|
case "streaming":
|
|
831
|
-
return (_jsxs(Text, { color:
|
|
845
|
+
return (_jsxs(Text, { color: ROLES.spinner, children: [_jsx(Spinner, { type: "dots" }), " streaming\u2026"] }));
|
|
832
846
|
case "error":
|
|
833
|
-
return _jsxs(Text, { color:
|
|
847
|
+
return _jsxs(Text, { color: THEME.error, children: ["error: ", status.message] });
|
|
834
848
|
}
|
|
835
849
|
};
|
|
836
850
|
//# sourceMappingURL=render.js.map
|