min-agent 0.2.1 → 0.4.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/README.md +242 -31
- package/dist/agent.js +1233 -485
- package/dist/assistant-stream.js +11 -7
- package/dist/cli/commands/chat.js +10 -0
- package/dist/cli/commands/exec.js +32 -0
- package/dist/cli/commands/history.js +58 -0
- package/dist/cli/commands/index.js +224 -0
- package/dist/cli/commands/init.js +18 -0
- package/dist/cli/commands/mcp.js +173 -0
- package/dist/cli/commands/memory.js +69 -0
- package/dist/cli/commands/models.js +21 -0
- package/dist/cli/commands/permission.js +12 -0
- package/dist/cli/commands/rules.js +33 -0
- package/dist/cli/commands/sandbox.js +13 -0
- package/dist/cli/commands/serve.js +9 -0
- package/dist/cli/commands/setup.js +4 -0
- package/dist/cli/commands/shared.js +16 -0
- package/dist/cli/commands/skills.js +119 -0
- package/dist/cli/commands/update.js +7 -0
- package/dist/cli/commands/write-config.js +30 -0
- package/dist/cli/errors.js +36 -0
- package/dist/cli/exec-prompt.js +26 -0
- package/dist/cli/option-helpers.js +53 -0
- package/dist/cli/program.js +180 -0
- package/dist/cli.js +7 -632
- package/dist/clipboard.js +59 -23
- package/dist/code-mode.js +35 -17
- package/dist/compaction.js +457 -169
- package/dist/config.js +298 -38
- package/dist/confirm.js +105 -9
- package/dist/context-window.js +156 -75
- package/dist/doom-loop.js +268 -26
- package/dist/fetch-timeout.js +152 -0
- package/dist/http-approvals.js +60 -0
- package/dist/http.js +119 -0
- package/dist/instructions.js +72 -33
- package/dist/logger.js +95 -0
- package/dist/markdown.js +35 -50
- package/dist/mcp.js +847 -102
- package/dist/memory.js +128 -45
- package/dist/output.js +42 -31
- package/dist/paste-handler.js +3 -3
- package/dist/permission-cli.js +43 -0
- package/dist/plugins.js +76 -11
- package/dist/pricing.js +119 -0
- package/dist/provider.js +34 -15
- package/dist/question-format.js +60 -0
- package/dist/sandbox-cli.js +82 -0
- package/dist/sandbox.js +403 -0
- package/dist/save-throttle.js +45 -0
- package/dist/serve/common.js +404 -0
- package/dist/serve/routes-chat.js +347 -0
- package/dist/serve/routes-mcp.js +212 -0
- package/dist/serve/routes-memory.js +66 -0
- package/dist/serve/routes-meta.js +205 -0
- package/dist/serve/routes-sessions.js +61 -0
- package/dist/serve/routes-skills.js +70 -0
- package/dist/serve.js +74 -635
- package/dist/sessions.js +197 -15
- package/dist/skills.js +531 -77
- package/dist/synthetic.js +7 -0
- package/dist/title-gen.js +9 -2
- package/dist/token-display.js +36 -0
- package/dist/tool-display.js +178 -0
- package/dist/tool-output.js +53 -46
- package/dist/tools/apply_patch.js +265 -0
- package/dist/tools/atomic-file.js +35 -0
- package/dist/tools/backend.js +61 -0
- package/dist/tools/bash.js +186 -71
- package/dist/tools/code_search.js +13 -6
- package/dist/tools/edit.js +26 -9
- package/dist/tools/explore.js +144 -16
- package/dist/tools/glob.js +7 -3
- package/dist/tools/grep.js +153 -14
- package/dist/tools/index.js +9 -24
- package/dist/tools/question.js +31 -30
- package/dist/tools/read.js +77 -15
- package/dist/tools/search-searxng.js +223 -0
- package/dist/tools/search-serper.js +189 -0
- package/dist/tools/task.js +100 -33
- package/dist/tools/todo.js +178 -67
- package/dist/tools/web_fetch.js +158 -46
- package/dist/tools/web_search.js +217 -29
- package/dist/tools/write.js +34 -11
- package/dist/tui/App.js +89 -6
- package/dist/tui/ConfirmBar.js +57 -4
- package/dist/tui/InputBar.js +504 -44
- package/dist/tui/MessageList.js +674 -20
- package/dist/tui/ModelPicker.js +113 -0
- package/dist/tui/QuestionBar.js +136 -0
- package/dist/tui/SessionPicker.js +79 -0
- package/dist/tui/StatusBar.js +14 -12
- package/dist/tui/agent-runner.js +223 -0
- package/dist/tui/caret-pos.js +177 -0
- package/dist/tui/caret.js +69 -0
- package/dist/tui/click-count.js +13 -0
- package/dist/tui/diff-view.js +61 -0
- package/dist/tui/drag-state.js +49 -0
- package/dist/tui/hydrate.js +129 -0
- package/dist/tui/index.js +189 -31
- package/dist/tui/input-history.js +125 -0
- package/dist/tui/layout.js +88 -0
- package/dist/tui/mouse.js +46 -0
- package/dist/tui/prompt-queue.js +24 -0
- package/dist/tui/selection.js +226 -0
- package/dist/tui/session-switch.js +28 -0
- package/dist/tui/slash-commands.js +106 -0
- package/dist/tui/slash-handler.js +545 -0
- package/dist/tui/text-width.js +113 -0
- package/dist/tui/theme.js +12 -0
- package/dist/tui/token-info.js +7 -0
- package/dist/tui/tool-children.js +19 -0
- package/dist/tui/undo-stack.js +14 -0
- package/dist/tui/use-sgr-mouse.js +29 -0
- package/dist/tui-chat.js +346 -330
- package/dist/updater.js +116 -0
- package/dist/xml-search.js +194 -0
- package/docs/API.md +410 -32
- package/docs/superpowers/plans/2026-08-16-batch1-tui-improvements.md +1510 -0
- package/docs/superpowers/plans/2026-08-16-batch2-cli-tools-api.md +2105 -0
- package/docs/superpowers/plans/2026-08-16-batch3-config-engineering.md +1595 -0
- package/docs/superpowers/plans/2026-08-16-input-caret.md +782 -0
- package/docs/superpowers/plans/2026-08-20-tui-completeness.md +873 -0
- package/docs/superpowers/plans/2026-08-20-unified-tui-default.md +631 -0
- package/docs/superpowers/specs/2026-08-16-batch1-tui-improvements-design.md +183 -0
- package/docs/superpowers/specs/2026-08-16-batch2-cli-tools-api-design.md +220 -0
- package/docs/superpowers/specs/2026-08-16-batch3-config-engineering-design.md +196 -0
- package/docs/superpowers/specs/2026-08-16-input-caret-design.md +63 -0
- package/docs/superpowers/specs/2026-08-17-mouse-selection-design.md +116 -0
- package/docs/superpowers/specs/2026-08-20-config-http-alignment-design.md +47 -0
- package/docs/superpowers/specs/2026-08-20-mcp-plugins-alignment-design.md +37 -0
- package/docs/superpowers/specs/2026-08-20-sandbox-permissions-design.md +68 -0
- package/docs/superpowers/specs/2026-08-20-tui-completeness-design.md +273 -0
- package/docs/superpowers/specs/2026-08-20-unified-tui-default-design.md +165 -0
- package/package.json +12 -8
- package/skills/self-config/SKILL.md +90 -0
- package/skills/self-config/reference.md +149 -0
package/dist/tui/App.js
CHANGED
|
@@ -1,15 +1,98 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Box, useInput, useStdout } from "ink";
|
|
3
4
|
import { Spinner } from "./Spinner.js";
|
|
4
5
|
import { InputBar } from "./InputBar.js";
|
|
5
6
|
import { MessageList } from "./MessageList.js";
|
|
6
|
-
import { ConfirmBar } from "./ConfirmBar.js";
|
|
7
|
+
import { ConfirmBar, confirmBarRows } from "./ConfirmBar.js";
|
|
8
|
+
import { QuestionBar, questionBarRows } from "./QuestionBar.js";
|
|
7
9
|
import { StatusBar } from "./StatusBar.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
import { ModelPicker, modelPickerRows } from "./ModelPicker.js";
|
|
11
|
+
import { SessionPicker, sessionPickerRows } from "./SessionPicker.js";
|
|
12
|
+
import { setCaretPosition } from "./caret.js";
|
|
13
|
+
import { computeMessageMaxHeight, frameRows, INPUT_BAR_ROWS } from "./layout.js";
|
|
14
|
+
import { isCtrlC } from "./input-history.js";
|
|
15
|
+
export function App({ initialState, onSubmit, onConfirm, onQuestionAnswer, onModelPick, onModelCancel, onSessionPick, onSessionCancel, onToggleSelectionMode, onExitSelectionMode, onExit, onCopyNotice, }) {
|
|
16
|
+
// Ink recalculates its own layout on resize without re-rendering React, so
|
|
17
|
+
// track terminal size ourselves to keep heights/widths in sync.
|
|
18
|
+
const { stdout } = useStdout();
|
|
19
|
+
const [terminal, setTerminal] = useState({ columns: stdout.columns || 80, rows: stdout.rows || 0 });
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const onResize = () => setTerminal({ columns: stdout.columns || 80, rows: stdout.rows || 0 });
|
|
22
|
+
stdout.on("resize", onResize);
|
|
23
|
+
return () => {
|
|
24
|
+
stdout.off("resize", onResize);
|
|
25
|
+
};
|
|
26
|
+
}, [stdout]);
|
|
27
|
+
useInput((input, key) => {
|
|
28
|
+
if (isCtrlC(input, key)) {
|
|
29
|
+
if (initialState.confirmMessage) {
|
|
30
|
+
onConfirm(false);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (initialState.question) {
|
|
34
|
+
onQuestionAnswer(null);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (initialState.modelPicker) {
|
|
38
|
+
onModelCancel();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (initialState.sessionPicker) {
|
|
42
|
+
onSessionCancel();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (initialState.selectionMode) {
|
|
46
|
+
onExitSelectionMode();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (initialState.isRunning) {
|
|
50
|
+
onExit();
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (key.ctrl && input === "b") {
|
|
55
|
+
if (initialState.confirmMessage ||
|
|
56
|
+
initialState.question ||
|
|
57
|
+
initialState.modelPicker ||
|
|
58
|
+
initialState.sessionPicker)
|
|
59
|
+
return;
|
|
60
|
+
if (initialState.isRunning)
|
|
61
|
+
return;
|
|
62
|
+
if (!initialState.selectionMode)
|
|
63
|
+
return;
|
|
64
|
+
onToggleSelectionMode();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (key.escape &&
|
|
68
|
+
initialState.isRunning &&
|
|
69
|
+
!initialState.confirmMessage &&
|
|
70
|
+
!initialState.question &&
|
|
71
|
+
!initialState.modelPicker &&
|
|
72
|
+
!initialState.sessionPicker) {
|
|
11
73
|
onExit();
|
|
12
74
|
}
|
|
13
75
|
});
|
|
14
|
-
|
|
76
|
+
if (initialState.confirmMessage || initialState.question || initialState.modelPicker || initialState.sessionPicker)
|
|
77
|
+
setCaretPosition(null);
|
|
78
|
+
const columns = terminal.columns;
|
|
79
|
+
const terminalRows = terminal.rows;
|
|
80
|
+
const layoutRows = frameRows(terminalRows);
|
|
81
|
+
const confirmActive = Boolean(initialState.confirmMessage);
|
|
82
|
+
const questionActive = Boolean(initialState.question);
|
|
83
|
+
const modelPickerActive = Boolean(initialState.modelPicker);
|
|
84
|
+
const sessionPickerActive = Boolean(initialState.sessionPicker);
|
|
85
|
+
const footerRows = confirmActive
|
|
86
|
+
? confirmBarRows(initialState.confirmMessage ?? "", columns, layoutRows)
|
|
87
|
+
: questionActive
|
|
88
|
+
? questionBarRows(initialState.question.prompt, initialState.question.options, columns, layoutRows)
|
|
89
|
+
: modelPickerActive
|
|
90
|
+
? modelPickerRows(layoutRows)
|
|
91
|
+
: sessionPickerActive
|
|
92
|
+
? sessionPickerRows(layoutRows)
|
|
93
|
+
: INPUT_BAR_ROWS;
|
|
94
|
+
const spinnerVisible = initialState.isRunning && !confirmActive && !questionActive && !modelPickerActive && !sessionPickerActive;
|
|
95
|
+
const spinnerRows = spinnerVisible ? 1 : 0;
|
|
96
|
+
const messageMaxHeight = computeMessageMaxHeight(layoutRows, footerRows, spinnerRows);
|
|
97
|
+
return (_jsxs(Box, { flexDirection: "column", width: "100%", height: layoutRows || undefined, overflow: "hidden", children: [!modelPickerActive && (_jsx(Box, { flexDirection: "column", flexGrow: 1, flexShrink: 1, minHeight: 0, overflow: "hidden", width: "100%", children: _jsx(MessageList, { messages: initialState.messages, maxHeight: messageMaxHeight, columns: columns, onCopyNotice: onCopyNotice, selectionMode: Boolean(initialState.selectionMode), onExitSelectionMode: onExitSelectionMode, interactive: !confirmActive && !questionActive }) })), spinnerVisible && (_jsx(Box, { paddingLeft: 1, flexShrink: 0, width: "100%", children: _jsx(Spinner, { label: initialState.spinnerText || "思考中..." }) })), _jsx(StatusBar, { state: initialState, columns: columns }), initialState.confirmMessage ? (_jsx(ConfirmBar, { message: initialState.confirmMessage, onConfirm: onConfirm, columns: columns, maxRows: footerRows })) : initialState.question ? (_jsx(QuestionBar, { prompt: initialState.question.prompt, options: initialState.question.options, onAnswer: onQuestionAnswer, columns: columns, maxRows: footerRows })) : initialState.modelPicker ? (_jsx(ModelPicker, { currentModel: initialState.model, onSelect: onModelPick, onCancel: onModelCancel })) : initialState.sessionPicker ? (_jsx(SessionPicker, { currentId: initialState.sessionId, onSelect: onSessionPick, onCancel: onSessionCancel })) : (_jsx(InputBar, { onSubmit: onSubmit, disabled: initialState.isRunning || Boolean(initialState.selectionMode), placeholder: initialState.isRunning ? "按 Esc 取消运行..." : "输入消息... (Ctrl+J 换行)", columns: columns, terminalRows: layoutRows, onSelectionMode: onToggleSelectionMode, onExit: onExit }))] }));
|
|
15
98
|
}
|
package/dist/tui/ConfirmBar.js
CHANGED
|
@@ -1,13 +1,66 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
2
3
|
import { Box, Text, useInput } from "ink";
|
|
3
|
-
|
|
4
|
+
import { wrapByWidth } from "./text-width.js";
|
|
5
|
+
import { CONFIRM_CHROME_ROWS, footerMaxRows, innerTextWidth, sliceLineWindow } from "./layout.js";
|
|
6
|
+
import { theme } from "./theme.js";
|
|
7
|
+
export function confirmMessageLines(message, columns) {
|
|
8
|
+
const textWidth = innerTextWidth(columns);
|
|
9
|
+
return String(message ?? "")
|
|
10
|
+
.split("\n")
|
|
11
|
+
.flatMap((line) => wrapByWidth(line, textWidth));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Terminal rows the confirm bar occupies, mirroring the JSX layout below.
|
|
15
|
+
* Capped so a huge permission payload cannot push [y]/[N] off the screen.
|
|
16
|
+
*/
|
|
17
|
+
export function confirmBarRows(message, columns, frameRowCount = 0) {
|
|
18
|
+
const natural = confirmMessageLines(message, columns).length + CONFIRM_CHROME_ROWS;
|
|
19
|
+
return Math.min(natural, footerMaxRows(frameRowCount, CONFIRM_CHROME_ROWS));
|
|
20
|
+
}
|
|
21
|
+
export function ConfirmBar({ message, onConfirm, columns, maxRows }) {
|
|
22
|
+
const lines = useMemo(() => confirmMessageLines(message, columns), [message, columns]);
|
|
23
|
+
const bodyMax = Math.max(0, maxRows - CONFIRM_CHROME_ROWS);
|
|
24
|
+
const [top, setTop] = useState(0);
|
|
25
|
+
const window = useMemo(() => sliceLineWindow(lines, bodyMax, top), [lines, bodyMax, top]);
|
|
26
|
+
const scrollable = window.above > 0 || window.below > 0;
|
|
4
27
|
useInput((input, key) => {
|
|
5
|
-
if (
|
|
28
|
+
if (key.escape) {
|
|
29
|
+
onConfirm(false);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const hasEnter = key.return || /[\r\n]/.test(input);
|
|
33
|
+
const stripped = input
|
|
34
|
+
.replace(/[\r\n]+/g, "")
|
|
35
|
+
.trim()
|
|
36
|
+
.toLowerCase();
|
|
37
|
+
if (stripped === "y") {
|
|
6
38
|
onConfirm(true);
|
|
39
|
+
return;
|
|
7
40
|
}
|
|
8
|
-
|
|
41
|
+
if (stripped === "n" || (stripped === "" && hasEnter)) {
|
|
9
42
|
onConfirm(false);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!scrollable)
|
|
46
|
+
return;
|
|
47
|
+
const view = Math.max(1, window.lines.length);
|
|
48
|
+
if (key.upArrow) {
|
|
49
|
+
setTop((t) => sliceLineWindow(lines, bodyMax, t - 1).start);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (key.downArrow) {
|
|
53
|
+
setTop((t) => sliceLineWindow(lines, bodyMax, t + 1).start);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (key.pageUp) {
|
|
57
|
+
setTop((t) => sliceLineWindow(lines, bodyMax, t - view).start);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (key.pageDown) {
|
|
61
|
+
setTop((t) => sliceLineWindow(lines, bodyMax, t + view).start);
|
|
62
|
+
return;
|
|
10
63
|
}
|
|
11
64
|
});
|
|
12
|
-
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor:
|
|
65
|
+
return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, width: "100%", borderStyle: "round", borderColor: theme.confirmBorder, paddingX: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { bold: true, color: theme.confirmBorder, wrap: "truncate-end", children: "\u26A0 \u8BF7\u6C42\u6267\u884C\u6743\u9650" }) }), bodyMax > 0 && (_jsxs(Box, { flexDirection: "column", height: bodyMax, overflow: "hidden", flexShrink: 0, width: "100%", children: [window.above > 0 && (_jsx(Box, { paddingLeft: 1, flexShrink: 0, children: _jsxs(Text, { color: theme.muted, dimColor: true, children: ["\u2026 \u4EE5\u4E0A ", window.above, " \u884C"] }) })), window.lines.map((line, i) => (_jsx(Box, { paddingLeft: 1, flexShrink: 0, children: _jsx(Text, { wrap: "truncate-end", children: line }) }, i))), window.below > 0 && (_jsx(Box, { paddingLeft: 1, flexShrink: 0, children: _jsxs(Text, { color: theme.muted, dimColor: true, children: ["\u2193 \u8FD8\u6709 ", window.below, " \u884C"] }) }))] })), _jsxs(Box, { marginTop: 1, flexShrink: 0, height: 1, overflow: "hidden", width: "100%", children: [_jsxs(Text, { bold: true, color: theme.confirmBorder, children: ["? \u662F\u5426\u5141\u8BB8\u6267\u884C\uFF1F", " "] }), _jsx(Text, { color: theme.success, children: "[y]" }), _jsx(Text, { color: theme.muted, children: " / " }), _jsx(Text, { color: theme.error, children: "[N]" })] })] }));
|
|
13
66
|
}
|