@vietor/easy-agent 0.4.4 → 0.4.6
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/README.md +6 -1
- package/dist/config.js +1 -0
- package/dist/main.js +38 -41
- package/dist/tui/App.js +40 -16
- package/dist/tui/AppHeader.js +3 -2
- package/dist/tui/ErrorBoundary.js +15 -0
- package/dist/tui/PromptOrCommandInput.js +6 -1
- package/dist/tui/QuestionView.js +2 -2
- package/dist/tui/Spinner.js +2 -2
- package/dist/tui/StatusBar.js +14 -3
- package/dist/tui/TimelineView.js +1 -1
- package/dist/tui/TodoView.js +2 -3
- package/dist/tui/components/Markdown.js +14 -14
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -29,13 +29,18 @@ Create `~/.easy-agent.json` in your home directory:
|
|
|
29
29
|
"llm": {
|
|
30
30
|
"baseUrl": "https://api.deepseek.com/v1",
|
|
31
31
|
"apiKey": "your-api-key",
|
|
32
|
-
"model": "deepseek-v4-flash"
|
|
32
|
+
"model": "deepseek-v4-flash",
|
|
33
|
+
"reasoningEffort": "high"
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
```
|
|
36
37
|
|
|
37
38
|
`llm.baseUrl`, `llm.apiKey`, and `llm.model` are all required. Point `baseUrl` at any OpenAI-compatible endpoint (OpenAI, Azure OpenAI, local servers, etc.) and set `model` to a model that endpoint serves.
|
|
38
39
|
|
|
40
|
+
#### `reasoningEffort` (optional)
|
|
41
|
+
|
|
42
|
+
Controls the depth of model reasoning. Valid values: `"high"` | `"max"`. Defaults to `"high"`. When set to `"max"` the model spends more tokens on deeper reasoning before responding — useful for complex logic, math, or multi-step analysis. The current setting is shown in the TUI header (e.g. ` · reasoning max`). Requires a model that supports the `reasoning_effort` parameter.
|
|
43
|
+
|
|
39
44
|
### Proxy
|
|
40
45
|
|
|
41
46
|
The agent automatically routes HTTP requests through a proxy when the standard environment variables are set:
|
package/dist/config.js
CHANGED
package/dist/main.js
CHANGED
|
@@ -1,41 +1,26 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { Command } from "commander";
|
|
4
5
|
import { loadConfig } from "./config.js";
|
|
5
|
-
import { tryLoadSkills, tryReadFileText, createSession
|
|
6
|
+
import { tryLoadSkills, tryReadFileText, createSession } from "@vietor/easy-agent-core";
|
|
6
7
|
import { builtinCommands } from "./cmds/builtin.js";
|
|
7
8
|
import { startApp } from "./tui/App.js";
|
|
9
|
+
import { getPackageInfo } from "./util/package.js";
|
|
8
10
|
import { FileSessionPersistence } from "./util/sessionStore.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
function buildSystemPromptBase(cwd) {
|
|
12
|
+
return [
|
|
13
|
+
"You are Easy Agent, an autonomous assistant. You complete tasks by calling tools, inspecting their results, and iterating until the work is done.",
|
|
14
|
+
`Output:
|
|
12
15
|
- Be concise and use GitHub-flavored markdown.
|
|
13
16
|
- State what you did and stop once the task is complete; report outcomes faithfully.
|
|
14
17
|
- Reference code as file_path:line_number.`,
|
|
15
|
-
|
|
18
|
+
`Environment:
|
|
16
19
|
- Platform: ${process.platform}
|
|
17
|
-
- Working directory: ${
|
|
18
|
-
|
|
20
|
+
- Working directory: ${cwd}`,
|
|
21
|
+
`Decision making:
|
|
19
22
|
- When a decision belongs to the user, call AskUser and wait for the answer rather than listing options in prose. Ask when there are multiple reasonable approaches, an irreversible or consequential action, or the request is ambiguous; when you have enough to proceed, act without asking.`,
|
|
20
|
-
].join("\n\n");
|
|
21
|
-
function parseArgs(argv) {
|
|
22
|
-
let mode = "new";
|
|
23
|
-
let id;
|
|
24
|
-
for (let i = 0; i < argv.length; i++) {
|
|
25
|
-
const a = argv[i];
|
|
26
|
-
if (a === "-c" || a === "--continue") {
|
|
27
|
-
mode = "continue";
|
|
28
|
-
}
|
|
29
|
-
else if (a === "-r" || a === "--resume") {
|
|
30
|
-
mode = "resume";
|
|
31
|
-
const next = argv[i + 1];
|
|
32
|
-
if (next && !next.startsWith("-")) {
|
|
33
|
-
id = next;
|
|
34
|
-
i++;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return { mode, id };
|
|
23
|
+
].join("\n\n");
|
|
39
24
|
}
|
|
40
25
|
async function listSessions(store) {
|
|
41
26
|
const sessions = await store.listSessions();
|
|
@@ -51,35 +36,43 @@ async function listSessions(store) {
|
|
|
51
36
|
console.log("\nResume with: easy-agent --resume <id>");
|
|
52
37
|
}
|
|
53
38
|
export async function main(argv = []) {
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
39
|
+
const pkg = getPackageInfo();
|
|
40
|
+
const program = new Command();
|
|
41
|
+
program
|
|
42
|
+
.name("easy-agent")
|
|
43
|
+
.version(pkg.version)
|
|
44
|
+
.description("Terminal-based AI agent CLI with conversational TUI")
|
|
45
|
+
.option("-c, --continue", "Continue the most recent session")
|
|
46
|
+
.option("-r, --resume [id]", "Resume a session by ID (omit to list sessions)")
|
|
47
|
+
.parse(argv, { from: "user" });
|
|
48
|
+
const opts = program.opts();
|
|
49
|
+
const cwd = process.cwd();
|
|
50
|
+
const store = new FileSessionPersistence(cwd);
|
|
51
|
+
if (opts.resume !== undefined && typeof opts.resume !== "string") {
|
|
57
52
|
await listSessions(store);
|
|
58
53
|
return;
|
|
59
54
|
}
|
|
60
55
|
const config = loadConfig();
|
|
61
56
|
let sessionId;
|
|
62
57
|
let resume = false;
|
|
63
|
-
if (
|
|
58
|
+
if (opts.continue) {
|
|
64
59
|
const sessions = await store.listSessions();
|
|
65
60
|
if (sessions.length) {
|
|
66
61
|
sessionId = sessions[0].id;
|
|
67
62
|
resume = true;
|
|
68
63
|
}
|
|
69
64
|
}
|
|
70
|
-
else if (
|
|
71
|
-
sessionId =
|
|
65
|
+
else if (opts.resume && typeof opts.resume === "string") {
|
|
66
|
+
sessionId = opts.resume;
|
|
72
67
|
resume = true;
|
|
73
68
|
}
|
|
74
69
|
if (!sessionId)
|
|
75
70
|
sessionId = randomUUID();
|
|
76
|
-
const globalSkills = tryLoadSkills(join(homedir(), ".easy-agent", "skills"))
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
?? tryReadFileText(join(process.cwd(), "CLAUDE.md"));
|
|
82
|
-
const systemPrompt = [SYSTEM_PROMPT_BASE, globalPrompt, projectPrompt]
|
|
71
|
+
const globalSkills = tryLoadSkills(join(homedir(), ".easy-agent", "skills")) ?? tryLoadSkills(join(homedir(), ".claude", "skills"));
|
|
72
|
+
const globalPrompt = tryReadFileText(join(homedir(), ".easy-agent", "AGENTS.md")) ??
|
|
73
|
+
tryReadFileText(join(homedir(), ".claude", "CLAUDE.md"));
|
|
74
|
+
const projectPrompt = tryReadFileText(join(cwd, "AGENTS.md")) ?? tryReadFileText(join(cwd, "CLAUDE.md"));
|
|
75
|
+
const systemPrompt = [buildSystemPromptBase(cwd), globalPrompt, projectPrompt]
|
|
83
76
|
.filter(Boolean)
|
|
84
77
|
.join("\n\n=================\n\n");
|
|
85
78
|
const session = await createSession({
|
|
@@ -90,13 +83,17 @@ export async function main(argv = []) {
|
|
|
90
83
|
commands: builtinCommands,
|
|
91
84
|
builtinTools: {
|
|
92
85
|
askUser: true,
|
|
93
|
-
todoWrite: true
|
|
86
|
+
todoWrite: true,
|
|
94
87
|
},
|
|
88
|
+
cwd: cwd,
|
|
95
89
|
sessionId,
|
|
96
90
|
persistence: store,
|
|
97
91
|
});
|
|
98
92
|
if (resume)
|
|
99
93
|
await session.restore();
|
|
100
94
|
const app = startApp(session);
|
|
101
|
-
await app.waitUntilExit().finally(() =>
|
|
95
|
+
await app.waitUntilExit().finally(() => {
|
|
96
|
+
session.dispose();
|
|
97
|
+
console.log(["Resume this session with:", `easy-agent --resume ${sessionId}`].join("\n"));
|
|
98
|
+
});
|
|
102
99
|
}
|
package/dist/tui/App.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
-
import { Box, render, useApp, useInput, useWindowSize } from "ink";
|
|
3
|
+
import { Box, render, Text, useApp, useInput, useWindowSize } from "ink";
|
|
4
4
|
import { Markdown } from "./components/Markdown.js";
|
|
5
|
-
import {
|
|
5
|
+
import { TimelineView } from "./TimelineView.js";
|
|
6
6
|
import { TodoView } from "./TodoView.js";
|
|
7
7
|
import { AppHeader } from "./AppHeader.js";
|
|
8
8
|
import { PromptOrCommandInput } from "./PromptOrCommandInput.js";
|
|
@@ -14,10 +14,14 @@ export function App({ session }) {
|
|
|
14
14
|
const { exit } = useApp();
|
|
15
15
|
const { columns } = useWindowSize();
|
|
16
16
|
const view = useSyncExternalStore(session.subscribe, session.getSnapshot);
|
|
17
|
-
const [runState, setRunState] = useState({ running: false, elapsed: 0, promptTokens: 0, completionTokens: 0 });
|
|
17
|
+
const [runState, setRunState] = useState({ running: false, elapsed: 0, thinkingElapsed: 0, replyElapsed: 0, promptTokens: 0, completionTokens: 0 });
|
|
18
18
|
const [streamingText, setStreamingText] = useState("");
|
|
19
19
|
const streamingRef = useRef("");
|
|
20
20
|
const renderTimerRef = useRef(undefined);
|
|
21
|
+
const [reasoningText, setReasoningText] = useState("");
|
|
22
|
+
const reasoningRef = useRef("");
|
|
23
|
+
const reasoningRenderTimerRef = useRef(undefined);
|
|
24
|
+
const [showReasoning, setShowReasoning] = useState(false);
|
|
21
25
|
const allCmds = useMemo(() => session.commandSchemas, [session]);
|
|
22
26
|
const pendingQuestion = session.getPendingQuestion();
|
|
23
27
|
useEffect(() => {
|
|
@@ -27,6 +31,14 @@ export function App({ session }) {
|
|
|
27
31
|
streamingRef.current += e.text;
|
|
28
32
|
scheduleStreamingRender();
|
|
29
33
|
break;
|
|
34
|
+
case "reasoning_delta":
|
|
35
|
+
reasoningRef.current += e.text;
|
|
36
|
+
scheduleReasoningRender();
|
|
37
|
+
break;
|
|
38
|
+
case "reasoning_clear":
|
|
39
|
+
reasoningRef.current = "";
|
|
40
|
+
setReasoningText("");
|
|
41
|
+
break;
|
|
30
42
|
case "assistant":
|
|
31
43
|
streamingRef.current = "";
|
|
32
44
|
setStreamingText("");
|
|
@@ -46,12 +58,24 @@ export function App({ session }) {
|
|
|
46
58
|
setStreamingText(streamingRef.current);
|
|
47
59
|
}, STREAM_FRAME_MS);
|
|
48
60
|
};
|
|
61
|
+
const scheduleReasoningRender = () => {
|
|
62
|
+
if (reasoningRenderTimerRef.current)
|
|
63
|
+
return;
|
|
64
|
+
reasoningRenderTimerRef.current = setTimeout(() => {
|
|
65
|
+
reasoningRenderTimerRef.current = undefined;
|
|
66
|
+
setReasoningText(reasoningRef.current);
|
|
67
|
+
}, STREAM_FRAME_MS);
|
|
68
|
+
};
|
|
49
69
|
useInput((_input, key) => {
|
|
50
70
|
if (pendingQuestion) {
|
|
51
71
|
if (key.ctrl && _input === "c")
|
|
52
72
|
session.abort();
|
|
53
73
|
return;
|
|
54
74
|
}
|
|
75
|
+
if (_input === "t" && runState.running && reasoningText) {
|
|
76
|
+
setShowReasoning((v) => !v);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
55
79
|
if (key.escape) {
|
|
56
80
|
session.abort();
|
|
57
81
|
}
|
|
@@ -68,28 +92,28 @@ export function App({ session }) {
|
|
|
68
92
|
exit();
|
|
69
93
|
}
|
|
70
94
|
async function handlePrompt(text) {
|
|
71
|
-
|
|
72
|
-
if (first.startsWith("/") || session.isCommand(first)) {
|
|
73
|
-
const name = first.startsWith("/") ? first.slice(1) : first;
|
|
74
|
-
await handleCommand(name, rest.join(" "));
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
await session.startPrompt(text);
|
|
78
|
-
}
|
|
95
|
+
await session.startPrompt(text);
|
|
79
96
|
}
|
|
80
97
|
let runningView = null;
|
|
81
98
|
if (runState.running) {
|
|
82
99
|
if (pendingQuestion) {
|
|
83
100
|
runningView = (_jsx(QuestionView, { question: pendingQuestion, onAnswer: (ans) => session.submitAnswer(pendingQuestion.id, ans) }));
|
|
84
101
|
}
|
|
85
|
-
else if (streamingText) {
|
|
86
|
-
runningView = (_jsx(Box, { marginTop: 1, paddingLeft: 1, paddingRight: 1, borderStyle: "single", borderTop: false, borderRight: false, borderBottom: false, borderColor: "gray", children: _jsx(Markdown, { color: "green", children: streamingText }) }));
|
|
87
|
-
}
|
|
88
102
|
else {
|
|
89
|
-
|
|
103
|
+
const spinnerLabel = streamingText ? "replying" : "thinking";
|
|
104
|
+
runningView = (_jsxs(_Fragment, { children: [reasoningText ? renderReasoning(reasoningText, showReasoning) : null, streamingText ? (_jsx(Box, { marginTop: 1, paddingLeft: 1, paddingRight: 1, borderStyle: "single", borderTop: false, borderRight: false, borderBottom: false, borderColor: "gray", children: _jsx(Markdown, { children: streamingText }) })) : null, _jsx(Box, { marginTop: 1, paddingLeft: 1, children: _jsx(Spinner, { label: spinnerLabel, thinkingElapsed: runState.thinkingElapsed, replyElapsed: runState.replyElapsed, promptTokens: runState.promptTokens, completionTokens: runState.completionTokens }) })] }));
|
|
90
105
|
}
|
|
91
106
|
}
|
|
92
|
-
return (_jsxs(Box, { width: columns, flexDirection: "column", children: [_jsx(AppHeader, {}), _jsx(
|
|
107
|
+
return (_jsxs(Box, { width: columns, flexDirection: "column", children: [_jsx(AppHeader, { cwd: session.cwd, model: session.model, reasoningEffort: session.reasoningEffort }), view.timeline.length > 0 ? (_jsx(Box, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: view.timeline.map((entry, i) => (_jsx(TimelineView, { entry: entry }, i))) })) : null, view.todos.length > 0 ? _jsx(TodoView, { todos: view.todos }) : null, runningView, !runState.running ? (_jsx(PromptOrCommandInput, { commands: allCmds, onCommand: handleCommand, onPrompt: handlePrompt })) : null, _jsx(StatusBar, { contextTokens: session.contextTokens, contextLimit: session.compactThreshold, running: runState.running, questionPending: !!pendingQuestion, reasoningAvailable: !!reasoningText })] }));
|
|
108
|
+
}
|
|
109
|
+
function renderReasoning(text, expanded) {
|
|
110
|
+
const lines = text.split("\n");
|
|
111
|
+
const firstLine = (lines[0] ?? "").slice(0, 80);
|
|
112
|
+
if (expanded) {
|
|
113
|
+
return (_jsxs(Box, { marginTop: 1, paddingLeft: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "\u250A thinking (t to collapse)" }), _jsx(Box, { paddingLeft: 1, children: _jsx(Text, { dimColor: true, children: text }) })] }));
|
|
114
|
+
}
|
|
115
|
+
const extra = lines.length > 1 ? ` …+${lines.length - 1} lines` : "";
|
|
116
|
+
return (_jsx(Box, { marginTop: 1, paddingLeft: 1, children: _jsxs(Text, { dimColor: true, children: ["\u250A ", firstLine, extra, " (t to expand)"] }) }));
|
|
93
117
|
}
|
|
94
118
|
export function startApp(session) {
|
|
95
119
|
process.stdout.write("[2J[H");
|
package/dist/tui/AppHeader.js
CHANGED
|
@@ -2,8 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import { Box, Text, useWindowSize } from "ink";
|
|
4
4
|
import { getPackageInfo } from "../util/package.js";
|
|
5
|
-
export const AppHeader = memo(function AppHeader() {
|
|
5
|
+
export const AppHeader = memo(function AppHeader({ cwd, model, reasoningEffort }) {
|
|
6
6
|
const { columns } = useWindowSize();
|
|
7
7
|
const pkginfo = getPackageInfo();
|
|
8
|
-
|
|
8
|
+
const reasoning = ` · reasoning ${reasoningEffort}`;
|
|
9
|
+
return (_jsxs(Box, { width: columns, paddingX: 1, flexDirection: "column", children: [_jsxs(Box, { flexDirection: "row", justifyContent: "space-between", children: [_jsxs(Text, { children: [_jsx(Text, { bold: true, children: "Easy Agent" }), _jsxs(Text, { dimColor: true, children: [" v", pkginfo.version] })] }), _jsx(Text, { dimColor: true, children: `${model}${reasoning}` })] }), _jsx(Text, { dimColor: true, children: cwd })] }));
|
|
9
10
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
import { Box, Text } from "ink";
|
|
4
|
+
export class ErrorBoundary extends Component {
|
|
5
|
+
state = { error: null };
|
|
6
|
+
static getDerivedStateFromError(error) {
|
|
7
|
+
return { error };
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
if (this.state.error) {
|
|
11
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, marginTop: 1, children: [_jsx(Text, { color: "red", bold: true, children: "\u2717 TUI Error" }), _jsx(Text, { dimColor: true, children: this.state.error.message })] }));
|
|
12
|
+
}
|
|
13
|
+
return this.props.children;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -56,10 +56,15 @@ export function PromptOrCommandInput({ commands, onCommand, onPrompt }) {
|
|
|
56
56
|
}
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
+
const [first, ...rest] = text.split(/\s+/);
|
|
60
|
+
if (commands.some((c) => c.name === first)) {
|
|
61
|
+
onCommand(first, rest.join(" "));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
59
64
|
onPrompt(text);
|
|
60
65
|
};
|
|
61
66
|
return (_jsxs(Box, { flexDirection: "column", children: [showMenu && filtered.length > 0 ? (_jsx(Box, { flexDirection: "column", borderStyle: "single", borderColor: "gray", children: visibleItems.items.map((cmd, i) => {
|
|
62
67
|
const realIdx = visibleItems.start + i;
|
|
63
68
|
return (_jsxs(Box, { children: [_jsxs(Text, { color: realIdx === selectedIndex ? "cyan" : undefined, children: [realIdx === selectedIndex ? "▸ " : " ", "/", cmd.name] }), _jsxs(Text, { dimColor: true, children: [" ", cmd.description] })] }, cmd.name));
|
|
64
|
-
}) })) : null, _jsxs(Box, { borderStyle: "single", borderLeft: false, borderRight: false, borderColor: "gray", children: [_jsx(Text, { color: "gray", children: "> " }), _jsx(TextInput, { value: input, onChange: setInput, onSubmit: onSubmit })] })] }));
|
|
69
|
+
}) })) : null, _jsxs(Box, { borderStyle: "single", borderBottom: false, borderLeft: false, borderRight: false, borderColor: "gray", children: [_jsx(Text, { color: "gray", children: "> " }), _jsx(TextInput, { value: input, onChange: setInput, onSubmit: onSubmit })] })] }));
|
|
65
70
|
}
|
package/dist/tui/QuestionView.js
CHANGED
|
@@ -39,7 +39,7 @@ export function QuestionView({ question, onAnswer }) {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
if (mode === "input") {
|
|
42
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 1, paddingRight: 1, children: [_jsx(Text, { color: "cyan", children: `? ${question.text}` }), _jsxs(Box, { borderStyle: "single", borderLeft: false, borderRight: false, borderColor: "gray", children: [_jsx(Text, { color: "gray", children: "\u276F " }), _jsx(TextInput, { value: text, onChange: setText, onSubmit: () => onAnswer(text) })] })] }));
|
|
42
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 1, paddingRight: 1, children: [_jsx(Text, { color: "cyan", children: `? ${question.text}` }), _jsxs(Box, { borderStyle: "single", borderBottom: false, borderLeft: false, borderRight: false, borderColor: "gray", children: [_jsx(Text, { color: "gray", children: "\u276F " }), _jsx(TextInput, { value: text, onChange: setText, onSubmit: () => onAnswer(text) })] })] }));
|
|
43
43
|
}
|
|
44
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 1, paddingRight: 1, children: [_jsx(Text, { color: "cyan", children: `? ${question.text}` }), _jsx(Box, { flexDirection: "column", borderStyle: "single", borderColor: "gray", children: items.map((item, i) => (_jsx(Box, { children: _jsxs(Text, { color: i === selected ? "cyan" : undefined, children: [i === selected ? "▸ " : " ", item] }) }, item))) })] }));
|
|
44
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 1, paddingRight: 1, children: [_jsx(Text, { color: "cyan", children: `? ${question.text}` }), _jsx(Box, { flexDirection: "column", borderStyle: "single", borderBottom: false, borderColor: "gray", children: items.map((item, i) => (_jsx(Box, { children: _jsxs(Text, { color: i === selected ? "cyan" : undefined, children: [i === selected ? "▸ " : " ", item] }) }, item))) })] }));
|
|
45
45
|
}
|
package/dist/tui/Spinner.js
CHANGED
|
@@ -3,11 +3,11 @@ import { useEffect, useState } from "react";
|
|
|
3
3
|
import { Text } from "ink";
|
|
4
4
|
import { timeDisplay, compactDisplay } from "../util/format.js";
|
|
5
5
|
const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
6
|
-
export function Spinner({ label,
|
|
6
|
+
export function Spinner({ label, thinkingElapsed, replyElapsed, promptTokens, completionTokens, }) {
|
|
7
7
|
const [frame, setFrame] = useState(0);
|
|
8
8
|
useEffect(() => {
|
|
9
9
|
const id = setInterval(() => setFrame((f) => (f + 1) % SPINNER_FRAMES.length), 80);
|
|
10
10
|
return () => clearInterval(id);
|
|
11
11
|
}, []);
|
|
12
|
-
return (_jsxs(Text, { children: [_jsx(Text, { color: "cyan", children: SPINNER_FRAMES[frame] }), _jsxs(Text, { children: [" ", label] }), _jsxs(Text, { dimColor: true, children: [" \u00B7 ", timeDisplay(
|
|
12
|
+
return (_jsxs(Text, { children: [_jsx(Text, { color: "cyan", children: SPINNER_FRAMES[frame] }), _jsxs(Text, { children: [" ", label] }), _jsxs(Text, { dimColor: true, children: [" \u00B7 think ", timeDisplay(thinkingElapsed), " \u00B7 reply ", timeDisplay(replyElapsed), " \u00B7 \u2191", compactDisplay(promptTokens), " \u00B7 \u2193", compactDisplay(completionTokens)] })] }));
|
|
13
13
|
}
|
package/dist/tui/StatusBar.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import { Box, Text, useWindowSize } from "ink";
|
|
4
4
|
import { compactDisplay } from "../util/format.js";
|
|
5
|
-
export const StatusBar = memo(function StatusBar({ contextTokens }) {
|
|
5
|
+
export const StatusBar = memo(function StatusBar({ contextTokens, contextLimit, running, questionPending, reasoningAvailable }) {
|
|
6
6
|
const { columns } = useWindowSize();
|
|
7
|
-
|
|
7
|
+
const pct = Math.min(100, contextLimit > 0 ? Math.round((contextTokens / contextLimit) * 100) : 0);
|
|
8
|
+
const filled = Math.round((pct / 100) * 10);
|
|
9
|
+
const bar = "█".repeat(filled) + "░".repeat(10 - filled);
|
|
10
|
+
const ctxColor = pct >= 85 ? "red" : pct >= 60 ? "yellow" : "green";
|
|
11
|
+
let hints;
|
|
12
|
+
if (questionPending)
|
|
13
|
+
hints = "↑↓ select · enter confirm · esc skip";
|
|
14
|
+
else if (running)
|
|
15
|
+
hints = reasoningAvailable ? "esc stop · t reasoning" : "esc stop";
|
|
16
|
+
else
|
|
17
|
+
hints = "/ commands";
|
|
18
|
+
return (_jsxs(Box, { width: columns, paddingX: 1, flexDirection: "row", justifyContent: "space-between", borderStyle: "single", borderTop: true, borderBottom: false, borderLeft: false, borderRight: false, borderColor: "gray", children: [_jsxs(Text, { children: [_jsx(Text, { dimColor: true, children: `ctx ${compactDisplay(contextTokens)} ` }), _jsx(Text, { color: ctxColor, children: `▕${bar}▏ ${pct}%` })] }), _jsx(Text, { dimColor: true, children: hints })] }));
|
|
8
19
|
});
|
package/dist/tui/TimelineView.js
CHANGED
|
@@ -18,7 +18,7 @@ export const TimelineView = memo(function Entry({ entry }) {
|
|
|
18
18
|
case "skill":
|
|
19
19
|
return (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "\u25C8 " }), _jsx(Text, { dimColor: true, children: "skill " }), _jsx(Text, { color: "magenta", bold: true, children: entry.name })] }) }));
|
|
20
20
|
case "assistant":
|
|
21
|
-
return (_jsx(Box, { marginTop: 1, children: _jsx(Markdown, {
|
|
21
|
+
return (_jsx(Box, { marginTop: 1, children: _jsx(Markdown, { children: entry.text }) }));
|
|
22
22
|
case "tool":
|
|
23
23
|
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "yellow", children: "\u25CF " }), _jsx(Text, { color: "yellow", bold: true, children: entry.name }), entry.summary ? _jsxs(Text, { dimColor: true, children: [" ", entry.summary] }) : null] }), entry.result !== null ? (_jsx(Text, { color: entry.isError ? "red" : "gray", children: ` ${preview(entry.isError ?? false, entry.result)}` })) : null] }));
|
|
24
24
|
case "retry":
|
package/dist/tui/TodoView.js
CHANGED
|
@@ -12,8 +12,7 @@ const COLORS = {
|
|
|
12
12
|
completed: "green",
|
|
13
13
|
};
|
|
14
14
|
export const TodoView = memo(function TodoView({ todos }) {
|
|
15
|
-
if (todos.length === 0)
|
|
16
|
-
return null;
|
|
17
15
|
const done = todos.filter((t) => t.status === "completed").length;
|
|
18
|
-
|
|
16
|
+
const headerColor = done === todos.length ? "green" : "cyan";
|
|
17
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 1, paddingRight: 1, children: [_jsx(Box, { borderStyle: "single", borderTop: true, borderBottom: false, borderLeft: false, borderRight: false, borderColor: "gray" }), _jsx(Text, { color: headerColor, children: `Tasks [${done}/${todos.length}]` }), todos.map((t, i) => (_jsx(Text, { color: COLORS[t.status], strikethrough: t.status === "completed", children: `${ICONS[t.status]} ${t.content}` }, i)))] }));
|
|
19
18
|
});
|
|
@@ -4,14 +4,14 @@ import { Box, Text } from "ink";
|
|
|
4
4
|
import { lexer } from "marked";
|
|
5
5
|
import stringWidth from "string-width";
|
|
6
6
|
const HEADING_COLOR = ["magentaBright", "cyanBright", "blue", "yellow", "green", "gray"];
|
|
7
|
-
export function Markdown({ children
|
|
7
|
+
export function Markdown({ children }) {
|
|
8
8
|
const tokens = useMemo(() => lexer(children, { gfm: true }), [children]);
|
|
9
|
-
return _jsx(Box, { flexDirection: "column", children: renderBlocks(tokens
|
|
9
|
+
return _jsx(Box, { flexDirection: "column", children: renderBlocks(tokens) });
|
|
10
10
|
}
|
|
11
|
-
function renderBlocks(tokens
|
|
12
|
-
return tokens.map((token, i) => (_jsx(Fragment, { children: renderBlock(token
|
|
11
|
+
function renderBlocks(tokens) {
|
|
12
|
+
return tokens.map((token, i) => (_jsx(Fragment, { children: renderBlock(token) }, i)));
|
|
13
13
|
}
|
|
14
|
-
function renderBlock(token
|
|
14
|
+
function renderBlock(token) {
|
|
15
15
|
switch (token.type) {
|
|
16
16
|
case "space":
|
|
17
17
|
return _jsx(Text, { children: " " });
|
|
@@ -22,15 +22,15 @@ function renderBlock(token, color) {
|
|
|
22
22
|
case "code":
|
|
23
23
|
return (_jsxs(Box, { borderStyle: "round", borderColor: "gray", paddingX: 1, flexDirection: "column", children: [token.lang ? _jsx(Text, { dimColor: true, children: token.lang }) : null, _jsx(Text, { children: token.text })] }));
|
|
24
24
|
case "blockquote":
|
|
25
|
-
return (_jsx(Box, { borderStyle: "single", borderTop: false, borderBottom: false, borderRight: false, borderColor: "gray", paddingLeft: 1, children: renderBlocks(token.tokens
|
|
25
|
+
return (_jsx(Box, { borderStyle: "single", borderTop: false, borderBottom: false, borderRight: false, borderColor: "gray", paddingLeft: 1, children: renderBlocks(token.tokens) }));
|
|
26
26
|
case "list":
|
|
27
|
-
return renderList(token
|
|
27
|
+
return renderList(token);
|
|
28
28
|
case "table":
|
|
29
|
-
return renderTable(token
|
|
29
|
+
return renderTable(token);
|
|
30
30
|
case "paragraph":
|
|
31
|
-
return _jsx(Text, {
|
|
31
|
+
return _jsx(Text, { children: renderInline(token.tokens) });
|
|
32
32
|
case "text":
|
|
33
|
-
return _jsx(Text, {
|
|
33
|
+
return _jsx(Text, { children: token.tokens ? renderInline(token.tokens) : token.text });
|
|
34
34
|
case "html":
|
|
35
35
|
return _jsx(Text, { dimColor: true, children: token.text });
|
|
36
36
|
default:
|
|
@@ -68,7 +68,7 @@ function renderInline(tokens) {
|
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function renderList(token
|
|
71
|
+
function renderList(token) {
|
|
72
72
|
const markers = token.items.map((item, i) => {
|
|
73
73
|
if (item.task)
|
|
74
74
|
return item.checked ? "[x]" : "[ ]";
|
|
@@ -77,9 +77,9 @@ function renderList(token, color) {
|
|
|
77
77
|
return "•";
|
|
78
78
|
});
|
|
79
79
|
const markerWidth = Math.max(1, ...markers.map((s) => stringWidth(s)));
|
|
80
|
-
return (_jsx(Box, { flexDirection: "column", children: token.items.map((item, i) => (_jsxs(Box, { marginTop: token.loose && i > 0 ? 1 : 0, children: [_jsxs(Text, {
|
|
80
|
+
return (_jsx(Box, { flexDirection: "column", children: token.items.map((item, i) => (_jsxs(Box, { marginTop: token.loose && i > 0 ? 1 : 0, children: [_jsxs(Text, { children: [padAlign(markers[i], markerWidth, "right"), " "] }), _jsx(Box, { flexDirection: "column", flexGrow: 1, children: renderBlocks(item.tokens) })] }, i))) }));
|
|
81
81
|
}
|
|
82
|
-
function renderTable(token
|
|
82
|
+
function renderTable(token) {
|
|
83
83
|
const aligns = token.align;
|
|
84
84
|
const cols = token.header.length;
|
|
85
85
|
const overhead = 3 * cols + 1;
|
|
@@ -99,7 +99,7 @@ function renderTable(token, color) {
|
|
|
99
99
|
return Array.from({ length: height }, (_, r) => (_jsx(Text, { children: [
|
|
100
100
|
...row.flatMap((_, c) => [
|
|
101
101
|
_jsx(Text, { dimColor: true, children: "\u2502" }, `s${c}`),
|
|
102
|
-
_jsx(Text, {
|
|
102
|
+
_jsx(Text, { bold: bold, children: ` ${padAlign(wrapped[c][r] ?? "", widths[c], aligns[c])} ` }, `c${c}`),
|
|
103
103
|
]),
|
|
104
104
|
_jsx(Text, { dimColor: true, children: "\u2502" }, "e"),
|
|
105
105
|
] }, r)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vietor/easy-agent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"url": "https://github.com/vietor/easy-agent.git"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"commander": "^13.0.0",
|
|
19
20
|
"ink": "^7.1.0",
|
|
20
21
|
"ink-text-input": "^6.0.0",
|
|
21
22
|
"marked": "^18.0.5",
|
|
22
23
|
"react": "^19.2.7",
|
|
23
24
|
"string-width": "^8.2.1",
|
|
24
25
|
"zod": "^4.4.3",
|
|
25
|
-
"@vietor/easy-agent-core": "0.4.
|
|
26
|
+
"@vietor/easy-agent-core": "0.4.6"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "^22.0.0",
|