zelari-code 0.6.2 → 0.7.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.
- package/dist/cli/app.js +64 -29
- package/dist/cli/app.js.map +1 -1
- package/dist/cli/components/ChatStream.js +40 -126
- package/dist/cli/components/ChatStream.js.map +1 -1
- package/dist/cli/components/LiveRegion.js +54 -0
- package/dist/cli/components/LiveRegion.js.map +1 -0
- package/dist/cli/components/SplashScreen.js +158 -0
- package/dist/cli/components/SplashScreen.js.map +1 -0
- package/dist/cli/components/StatusBar.js +42 -0
- package/dist/cli/components/StatusBar.js.map +1 -0
- package/dist/cli/components/ToolOutput.js +68 -0
- package/dist/cli/components/ToolOutput.js.map +1 -0
- package/dist/cli/components/toolFormat.js +195 -0
- package/dist/cli/components/toolFormat.js.map +1 -0
- package/dist/cli/councilDispatcher.js +20 -0
- package/dist/cli/councilDispatcher.js.map +1 -1
- package/dist/cli/grokOAuth.js +93 -75
- package/dist/cli/grokOAuth.js.map +1 -1
- package/dist/cli/hooks/chatState.js +139 -0
- package/dist/cli/hooks/chatState.js.map +1 -0
- package/dist/cli/hooks/eventsToMessages.js +1 -1
- package/dist/cli/hooks/eventsToMessages.js.map +1 -1
- package/dist/cli/hooks/messageHelpers.js +11 -4
- package/dist/cli/hooks/messageHelpers.js.map +1 -1
- package/dist/cli/hooks/useBatchedMessages.js +14 -10
- package/dist/cli/hooks/useBatchedMessages.js.map +1 -1
- package/dist/cli/hooks/useChatTurn.js +400 -87
- package/dist/cli/hooks/useChatTurn.js.map +1 -1
- package/dist/cli/hooks/useSession.js +23 -11
- package/dist/cli/hooks/useSession.js.map +1 -1
- package/dist/cli/hooks/useSlashDispatch.js +9 -1
- package/dist/cli/hooks/useSlashDispatch.js.map +1 -1
- package/dist/cli/main.bundled.js +15468 -12961
- package/dist/cli/main.bundled.js.map +4 -4
- package/dist/cli/main.js +43 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/mcp/mcpClient.js +152 -0
- package/dist/cli/mcp/mcpClient.js.map +1 -0
- package/dist/cli/mcp/mcpManager.js +139 -0
- package/dist/cli/mcp/mcpManager.js.map +1 -0
- package/dist/cli/refreshRegistry.js +9 -6
- package/dist/cli/refreshRegistry.js.map +1 -1
- package/dist/cli/skillsMd.js +155 -0
- package/dist/cli/skillsMd.js.map +1 -0
- package/dist/cli/slashHandlers/skills.js +16 -0
- package/dist/cli/slashHandlers/skills.js.map +1 -1
- package/dist/cli/toolRegistry.js +31 -0
- package/dist/cli/toolRegistry.js.map +1 -1
- package/dist/cli/wizard/index.js +1 -1
- package/dist/cli/wizard/index.js.map +1 -1
- package/dist/cli/workspace/completeDesign.js +128 -0
- package/dist/cli/workspace/completeDesign.js.map +1 -0
- package/dist/cli/workspace/paths.js +20 -13
- package/dist/cli/workspace/paths.js.map +1 -1
- package/dist/cli/workspace/postCouncilHook.js +146 -20
- package/dist/cli/workspace/postCouncilHook.js.map +1 -1
- package/dist/cli/workspace/storage.js +7 -3
- package/dist/cli/workspace/storage.js.map +1 -1
- package/dist/cli/workspace/stubs.js +350 -136
- package/dist/cli/workspace/stubs.js.map +1 -1
- package/dist/cli/workspace/workspaceSummary.js +255 -0
- package/dist/cli/workspace/workspaceSummary.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { formatCost, formatTokens } from '../modelPricing.js';
|
|
4
|
+
/**
|
|
5
|
+
* StatusBar — single one-line status bar replacing the persistent v0.6
|
|
6
|
+
* `Header`. It lives in the dynamic region (repainted by Ink) and condenses:
|
|
7
|
+
* provider · model · session · tokens · cost · queue · busy.
|
|
8
|
+
*
|
|
9
|
+
* Why one line: the static-scrollback model (v0.7.0) needs the dynamic
|
|
10
|
+
* region as short as possible. A single status line + the input bar + the
|
|
11
|
+
* streaming tail is always well under a screen, so no full repaint.
|
|
12
|
+
*/
|
|
13
|
+
export function StatusBar({ model, provider, sessionId, sessionActive, totalTokens, totalCostUsd, queueCount = 0, busy = false, }) {
|
|
14
|
+
const hasCost = typeof totalCostUsd === 'number' && totalCostUsd > 0;
|
|
15
|
+
const costStr = hasCost ? formatCost(totalCostUsd) : '$0.0000';
|
|
16
|
+
const tokStr = formatTokens(totalTokens ?? 0);
|
|
17
|
+
return (React.createElement(Box, { paddingX: 1 },
|
|
18
|
+
React.createElement(Text, { color: sessionActive ? 'green' : 'gray' }, sessionActive ? '●' : '○'),
|
|
19
|
+
React.createElement(Text, { dimColor: true }, " "),
|
|
20
|
+
React.createElement(Text, { bold: true, color: "cyan" }, provider),
|
|
21
|
+
React.createElement(Text, { dimColor: true }, " \u00B7 "),
|
|
22
|
+
React.createElement(Text, null, model),
|
|
23
|
+
React.createElement(Text, { dimColor: true }, " \u00B7 "),
|
|
24
|
+
React.createElement(Text, { dimColor: true },
|
|
25
|
+
"session ",
|
|
26
|
+
sessionId),
|
|
27
|
+
React.createElement(Text, { dimColor: true }, " \u00B7 "),
|
|
28
|
+
React.createElement(Text, { color: "gray" },
|
|
29
|
+
tokStr,
|
|
30
|
+
" tok"),
|
|
31
|
+
React.createElement(Text, { dimColor: true }, " \u00B7 "),
|
|
32
|
+
React.createElement(Text, { color: hasCost ? 'yellow' : 'gray' }, costStr),
|
|
33
|
+
queueCount > 0 ? (React.createElement(React.Fragment, null,
|
|
34
|
+
React.createElement(Text, { dimColor: true }, " \u00B7 "),
|
|
35
|
+
React.createElement(Text, { color: "magenta" },
|
|
36
|
+
"queue ",
|
|
37
|
+
queueCount))) : null,
|
|
38
|
+
busy ? (React.createElement(React.Fragment, null,
|
|
39
|
+
React.createElement(Text, { dimColor: true }, " \u00B7 "),
|
|
40
|
+
React.createElement(Text, { color: "yellow" }, "working"))) : null));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=StatusBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusBar.js","sourceRoot":"","sources":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AAI,IAAC,QAAQ,qBAAW;QACzB,oBAAC,IAAI,IAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAG,OAAO,CAAQ;QACzD,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAChB;YACE,oBAAC,IAAI,IAAC,QAAQ,qBAAW;YACzB,oBAAC,IAAI,IAAC,KAAK,EAAC,SAAS;;gBAAQ,UAAU,CAAQ,CAC9C,CACJ,CAAC,CAAC,CAAC,IAAI;QACP,IAAI,CAAC,CAAC,CAAC,CACN;YACE,oBAAC,IAAI,IAAC,QAAQ,qBAAW;YACzB,oBAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,cAAe,CAClC,CACJ,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { useStdout } from 'ink';
|
|
4
|
+
import { formatToolResult } from './toolFormat.js';
|
|
5
|
+
function borderColor(toolName, ok) {
|
|
6
|
+
if (ok === false)
|
|
7
|
+
return 'red';
|
|
8
|
+
const lower = toolName.toLowerCase();
|
|
9
|
+
if (lower.includes('read') || lower === 'cat' || lower.includes('grep') || lower.includes('search'))
|
|
10
|
+
return 'green';
|
|
11
|
+
if (lower.includes('write') || lower.includes('edit'))
|
|
12
|
+
return 'yellow';
|
|
13
|
+
if (lower === 'bash' || lower === 'shell' || lower === 'exec')
|
|
14
|
+
return 'red';
|
|
15
|
+
return 'cyan';
|
|
16
|
+
}
|
|
17
|
+
function ToolOutputImpl(props) {
|
|
18
|
+
const { toolName, summary, body, ok, durationMs, live = false } = props;
|
|
19
|
+
const color = borderColor(toolName, ok);
|
|
20
|
+
const { stdout } = useStdout();
|
|
21
|
+
// B3: clamp bordered box width so boxes don't stretch to full terminal and
|
|
22
|
+
// produce the mixed-width wall seen in v0.7.0.
|
|
23
|
+
const termWidth = stdout?.columns ?? 80;
|
|
24
|
+
const boxWidth = Math.min(Math.max(40, termWidth - 6), 100);
|
|
25
|
+
// Pending (live region): single line, no body, no duration.
|
|
26
|
+
if (live || ok === undefined) {
|
|
27
|
+
const summaryLine = ['⋯', `[${toolName}]`, summary].filter(Boolean).join(' ');
|
|
28
|
+
return (React.createElement(Box, { flexDirection: "column", marginLeft: 2 },
|
|
29
|
+
React.createElement(Box, null,
|
|
30
|
+
React.createElement(Text, { color: color }, summaryLine))));
|
|
31
|
+
}
|
|
32
|
+
// Finalized — format the body per tool policy (B1).
|
|
33
|
+
const isError = ok === false;
|
|
34
|
+
const formatted = formatToolResult(toolName, body);
|
|
35
|
+
const status = ok ? '✓' : '✗';
|
|
36
|
+
const summaryLine = [
|
|
37
|
+
status,
|
|
38
|
+
`[${toolName}]`,
|
|
39
|
+
summary,
|
|
40
|
+
durationMs !== undefined ? `(${durationMs}ms)` : '',
|
|
41
|
+
].filter(Boolean).join(' ');
|
|
42
|
+
// B3: one-line results (write_file/edit_file success) print inline — no box.
|
|
43
|
+
if (formatted.oneLine && !isError) {
|
|
44
|
+
const inline = formatted.lines[0] ?? '';
|
|
45
|
+
return (React.createElement(Box, { flexDirection: "column", marginLeft: 2 },
|
|
46
|
+
React.createElement(Box, null,
|
|
47
|
+
React.createElement(Text, { color: color }, summaryLine)),
|
|
48
|
+
React.createElement(Box, { marginLeft: 2 },
|
|
49
|
+
React.createElement(Text, { dimColor: true }, inline))));
|
|
50
|
+
}
|
|
51
|
+
const bodyText = formatted.lines.join('\n');
|
|
52
|
+
const metaSuffix = formatted.meta ? `\n${formatted.meta}` : '';
|
|
53
|
+
return (React.createElement(Box, { flexDirection: "column", marginLeft: 2 },
|
|
54
|
+
React.createElement(Box, null,
|
|
55
|
+
React.createElement(Text, { color: color }, summaryLine)),
|
|
56
|
+
React.createElement(Box, { flexDirection: "column", marginLeft: 2, width: boxWidth, borderStyle: "single", borderColor: color, paddingX: 1 },
|
|
57
|
+
React.createElement(Text, { dimColor: isError },
|
|
58
|
+
bodyText,
|
|
59
|
+
metaSuffix))));
|
|
60
|
+
}
|
|
61
|
+
export const ToolOutput = React.memo(ToolOutputImpl);
|
|
62
|
+
/**
|
|
63
|
+
* Pure helper: classify tool color (exported for unit tests).
|
|
64
|
+
*/
|
|
65
|
+
export function classifyToolColor(toolName, ok) {
|
|
66
|
+
return borderColor(toolName, ok);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=ToolOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolOutput.js","sourceRoot":"","sources":["../../../src/cli/components/ToolOutput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA4CnD,SAAS,WAAW,CAAC,QAAgB,EAAE,EAAY;IACjD,IAAI,EAAE,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,OAAO,CAAC;IACpH,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvE,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAC5E,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,c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,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,EAAY;IAC9D,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolFormat.ts — v0.7.1 pure formatters for tool rendering (plan B1+B2+B3).
|
|
3
|
+
*
|
|
4
|
+
* The v0.6/v0.7.0 renderer dumped the raw JSON result envelope into a bordered
|
|
5
|
+
* box: escaped `\n`, full-terminal-width borders with inconsistent widths per
|
|
6
|
+
* box, and summary lines that were raw JSON args truncated mid-string. These
|
|
7
|
+
* pure functions replace that with human-readable output keyed by tool name.
|
|
8
|
+
*
|
|
9
|
+
* Two formatters:
|
|
10
|
+
* - {@link formatToolSummary}: the one-line summary (replaces raw-JSON args).
|
|
11
|
+
* - {@link formatToolResult}: the multi-line body (replaces the raw envelope).
|
|
12
|
+
*
|
|
13
|
+
* Both are pure (no React, no Ink) so they are trivially unit-testable and
|
|
14
|
+
* usable by any renderer (the current ToolOutput, the Static path, /last-tool).
|
|
15
|
+
*
|
|
16
|
+
* Truncation is line-based (default 8, `ZELARI_TOOL_OUTPUT_LINES`) with a
|
|
17
|
+
* `… (+K lines)` tail, replacing the 600-char mid-string cut that split JSON
|
|
18
|
+
* strings awkwardly.
|
|
19
|
+
*/
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
/** Default line cap for the printed result body. */
|
|
22
|
+
const DEFAULT_TOOL_OUTPUT_LINES = 8;
|
|
23
|
+
function toolOutputLineCap() {
|
|
24
|
+
const raw = process.env.ZELARI_TOOL_OUTPUT_LINES;
|
|
25
|
+
const n = raw ? Number.parseInt(raw, 10) : DEFAULT_TOOL_OUTPUT_LINES;
|
|
26
|
+
return Number.isFinite(n) && n >= 0 ? n : DEFAULT_TOOL_OUTPUT_LINES;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Best-effort JSON parse. Returns the parsed value or `null` (caller falls
|
|
30
|
+
* back to treating the input as a plain string).
|
|
31
|
+
*/
|
|
32
|
+
function tryParseJson(s) {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(s);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Truncate an array of lines to the cap, appending a `… (+K lines)` marker. */
|
|
41
|
+
function truncateLines(lines) {
|
|
42
|
+
const cap = toolOutputLineCap();
|
|
43
|
+
if (lines.length <= cap)
|
|
44
|
+
return lines;
|
|
45
|
+
return [...lines.slice(0, cap), `… (+${lines.length - cap} lines)`];
|
|
46
|
+
}
|
|
47
|
+
/** Human-readable byte size (KB / MB). */
|
|
48
|
+
function formatBytes(n) {
|
|
49
|
+
if (n >= 1024 * 1024)
|
|
50
|
+
return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
51
|
+
if (n >= 1024)
|
|
52
|
+
return `${(n / 1024).toFixed(1)} KB`;
|
|
53
|
+
return `${n} B`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Format the body of a tool result for display.
|
|
57
|
+
*
|
|
58
|
+
* @param toolName tool name (determines the per-tool shape handling)
|
|
59
|
+
* @param resultStr the raw result string (JSON envelope from the harness, or
|
|
60
|
+
* a plain string for non-JSON tools / errors)
|
|
61
|
+
*/
|
|
62
|
+
export function formatToolResult(toolName, resultStr) {
|
|
63
|
+
const lower = toolName.toLowerCase();
|
|
64
|
+
// bash / shell — envelope: { stdout, stderr, exitCode, hint? }
|
|
65
|
+
if (lower === 'bash' || lower === 'shell' || lower === 'exec') {
|
|
66
|
+
const parsed = tryParseJson(resultStr);
|
|
67
|
+
if (parsed && typeof parsed === 'object') {
|
|
68
|
+
const stdout = parsed.stdout ?? '';
|
|
69
|
+
const lines = stdout.length > 0 ? stdout.replace(/\r\n/g, '\n').split('\n') : [];
|
|
70
|
+
const metaParts = [];
|
|
71
|
+
if (parsed.stderr && parsed.stderr.trim().length > 0) {
|
|
72
|
+
metaParts.push(`stderr: ${parsed.stderr.trim().split('\n')[0]}`);
|
|
73
|
+
}
|
|
74
|
+
if (typeof parsed.exitCode === 'number' && parsed.exitCode !== 0) {
|
|
75
|
+
metaParts.push(`exit ${parsed.exitCode}`);
|
|
76
|
+
}
|
|
77
|
+
// v0.7.3: interactive-prompt detection (see shell.ts INTERACTIVE_HINT).
|
|
78
|
+
if (typeof parsed.hint === 'string' && parsed.hint.length > 0) {
|
|
79
|
+
metaParts.push('⚠ interactive prompt cancelled — needs non-interactive flags or manual file creation');
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
lines: truncateLines(lines),
|
|
83
|
+
meta: metaParts.length > 0 ? metaParts.join(' · ') : undefined,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// read_file — envelope: { path, content, ... }
|
|
88
|
+
if (lower.includes('read') || lower === 'cat') {
|
|
89
|
+
const parsed = tryParseJson(resultStr);
|
|
90
|
+
if (parsed && typeof parsed === 'object' && typeof parsed.content === 'string') {
|
|
91
|
+
return { lines: truncateLines(parsed.content.replace(/\r\n/g, '\n').split('\n')) };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// write_file / edit_file — success is a single line, no box (B3).
|
|
95
|
+
if (lower.includes('write') || lower.includes('edit')) {
|
|
96
|
+
const parsed = tryParseJson(resultStr);
|
|
97
|
+
if (parsed && typeof parsed === 'object') {
|
|
98
|
+
const p = parsed.path ? rel(parsed.path) : '';
|
|
99
|
+
if (typeof parsed.bytesWritten === 'number') {
|
|
100
|
+
return { lines: [`wrote ${formatBytes(parsed.bytesWritten)} → ${p}`], oneLine: true };
|
|
101
|
+
}
|
|
102
|
+
if (typeof parsed.occurrencesReplaced === 'number') {
|
|
103
|
+
return {
|
|
104
|
+
lines: [`replaced ${parsed.occurrencesReplaced} occurrence(s) in ${p}`],
|
|
105
|
+
oneLine: true,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// list_files — envelope: { dir, entries: [{name, type}], truncated }
|
|
111
|
+
if (lower.includes('list') || lower.includes('ls')) {
|
|
112
|
+
const parsed = tryParseJson(resultStr);
|
|
113
|
+
if (parsed && Array.isArray(parsed.entries)) {
|
|
114
|
+
const names = parsed.entries.slice(0, 10).map((e) => e.name);
|
|
115
|
+
const head = truncateLines(names);
|
|
116
|
+
const count = parsed.entries.length;
|
|
117
|
+
const dir = parsed.dir ? rel(parsed.dir) : '';
|
|
118
|
+
const metaParts = [];
|
|
119
|
+
if (dir)
|
|
120
|
+
metaParts.push(`${count} entries in ${dir}`);
|
|
121
|
+
else
|
|
122
|
+
metaParts.push(`${count} entries`);
|
|
123
|
+
if (parsed.truncated)
|
|
124
|
+
metaParts.push(`(truncated)`);
|
|
125
|
+
return { lines: head, meta: metaParts.join(' ') };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// grep_content / search — envelope: { matches/results: [...] }
|
|
129
|
+
if (lower.includes('grep') || lower.includes('search')) {
|
|
130
|
+
const parsed = tryParseJson(resultStr);
|
|
131
|
+
const arr = parsed?.matches ?? parsed?.results;
|
|
132
|
+
if (Array.isArray(arr)) {
|
|
133
|
+
return {
|
|
134
|
+
lines: truncateLines(arr.map((m) => (typeof m === 'string' ? m : JSON.stringify(m)))),
|
|
135
|
+
meta: `${arr.length} match(es)`,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Fallback: treat as plain text (split on real newlines; if it's JSON we
|
|
140
|
+
// already failed to match a known shape, so show it verbatim).
|
|
141
|
+
return { lines: truncateLines(resultStr.replace(/\r\n/g, '\n').split('\n')) };
|
|
142
|
+
}
|
|
143
|
+
/** Make a path relative to cwd when possible (shorter display). */
|
|
144
|
+
function rel(p) {
|
|
145
|
+
try {
|
|
146
|
+
const r = path.relative(process.cwd(), p);
|
|
147
|
+
return r && !r.startsWith('..') ? r : p;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return p;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Format the one-line summary for a tool invocation (replaces raw-JSON args).
|
|
155
|
+
*
|
|
156
|
+
* @param toolName tool name
|
|
157
|
+
* @param args the args object/value as received from the model
|
|
158
|
+
* @param maxWidth optional column cap; the summary is truncated (with `…`) to
|
|
159
|
+
* fit so it never wraps mid-token. When omitted, a sane default
|
|
160
|
+
* is applied.
|
|
161
|
+
*/
|
|
162
|
+
export function formatToolSummary(toolName, args, maxWidth) {
|
|
163
|
+
const cap = maxWidth && maxWidth > 10 ? maxWidth : 100;
|
|
164
|
+
const lower = toolName.toLowerCase();
|
|
165
|
+
const a = (args && typeof args === 'object' ? args : {});
|
|
166
|
+
let summary;
|
|
167
|
+
if (lower === 'bash' || lower === 'shell' || lower === 'exec') {
|
|
168
|
+
summary = String(a['command'] ?? a['cmd'] ?? '');
|
|
169
|
+
}
|
|
170
|
+
else if (lower.includes('read') || lower === 'cat') {
|
|
171
|
+
summary = typeof a['path'] === 'string' ? rel(a['path']) : '';
|
|
172
|
+
}
|
|
173
|
+
else if (lower.includes('write') || lower.includes('edit')) {
|
|
174
|
+
const p = typeof a['path'] === 'string' ? rel(a['path']) : '';
|
|
175
|
+
summary = p;
|
|
176
|
+
}
|
|
177
|
+
else if (lower.includes('list') || lower.includes('ls')) {
|
|
178
|
+
const dir = typeof a['dir'] === 'string' ? rel(a['dir']) : '.';
|
|
179
|
+
const depth = typeof a['maxDepth'] === 'number' ? ` (depth ${a['maxDepth']})` : '';
|
|
180
|
+
summary = `${dir}${depth}`;
|
|
181
|
+
}
|
|
182
|
+
else if (lower.includes('grep') || lower.includes('search')) {
|
|
183
|
+
const pattern = String(a['pattern'] ?? a['query'] ?? '');
|
|
184
|
+
const p = typeof a['path'] === 'string' ? ` in ${rel(a['path'])}` : '';
|
|
185
|
+
summary = `${pattern}${p}`;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// Fallback: compact JSON, but truncated at the column cap (not mid-string
|
|
189
|
+
// like the old slice(0,120) which cut content values arbitrarily).
|
|
190
|
+
const json = JSON.stringify(args) ?? '';
|
|
191
|
+
summary = json;
|
|
192
|
+
}
|
|
193
|
+
return summary.length > cap ? `${summary.slice(0, cap - 1)}…` : summary;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=toolFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolFormat.js","sourceRoot":"","sources":["../../../src/cli/components/toolFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,oDAAoD;AACpD,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC,SAAS,iBAAiB;IACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IACjD,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC;IACrE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC;AACtE,CAAC;AAgBD;;;GAGG;AACH,SAAS,YAAY,CAAc,CAAS;IAC1C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAM,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,SAAS,aAAa,CAAC,KAAe;IACpC,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAC;IAChC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG;QAA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AC,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,OAAO,GAAG,GAAG,OAAO,GAAG,CAAC,EAAE,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,0EAA0E;QAC1E,mEAAmE;QACnE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AAC1E,CAAC"}
|
|
@@ -59,6 +59,26 @@ export async function* dispatchCouncil(userMessage, options) {
|
|
|
59
59
|
maxToolCallsPerTurn: options.maxToolCallsPerTurn,
|
|
60
60
|
feedbackStore: options.feedbackStore,
|
|
61
61
|
};
|
|
62
|
+
// Bug A fix (v0.7.5): also register workspace stubs in the global static
|
|
63
|
+
// (setWorkspaceStubs from @zelari/core/skills) so that getAllTools() —
|
|
64
|
+
// called by buildSystemPrompt when constructing the AVAILABLE TOOLS block —
|
|
65
|
+
// exposes them to the model. Without this, the per-call ToolRegistry can
|
|
66
|
+
// execute workspace tool calls, but the model never sees the names in its
|
|
67
|
+
// system prompt and either guesses them or skips them.
|
|
68
|
+
//
|
|
69
|
+
// Mirrors the pattern in src/cli/runHeadless.ts:141-152 and
|
|
70
|
+
// src/cli/hooks/useChatTurn.ts:572-586. Dynamic import avoids the load-
|
|
71
|
+
// order cycle that a static import would create (councilDispatcher is
|
|
72
|
+
// imported by hooks/runHeadless, and @zelari/core/skills is consumed by
|
|
73
|
+
// those same modules — see Gotcha #9 of zelari-code-headless-driver).
|
|
74
|
+
if (!options.disableWorkspaceTools) {
|
|
75
|
+
const { setWorkspaceStubs } = await import('@zelari/core/skills');
|
|
76
|
+
const { createWorkspaceContext: buildCtx, createWorkspaceStubs: buildStubs } = await import('./workspace/stubs.js');
|
|
77
|
+
const wsCtx = options.workspaceRoot
|
|
78
|
+
? buildCtx(options.workspaceRoot)
|
|
79
|
+
: buildCtx();
|
|
80
|
+
setWorkspaceStubs(buildStubs(wsCtx));
|
|
81
|
+
}
|
|
62
82
|
yield* runCouncilPure(userMessage, config, {});
|
|
63
83
|
}
|
|
64
84
|
//# sourceMappingURL=councilDispatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"councilDispatcher.js","sourceRoot":"","sources":["../../src/cli/councilDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,cAAc,GAEf,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"councilDispatcher.js","sourceRoot":"","sources":["../../src/cli/councilDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,cAAc,GAEf,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AA4D1E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,eAAe,CACpC,WAAmB,EACnB,OAA+B;IAE/B,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC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