Skip to content

Commit 8a1fcd9

Browse files
committed
feat: 添加 Ink UI 组件库集成和现代化界面改进
- 集成 ink-text-input、ink-select-input 等社区组件 - 添加 ink-big-text 和 ink-gradient 实现渐变标题效果 - 使用社区 ink-spinner 和 ink-progress-bar 替换自定义实现 - 重构 InputManager 使用社区组件 - 更新 Header 组件支持大标题显示 - 修改 TableRenderer 基于 ink-table 实现 - 更新构建配置以排除 ink-* 外部依赖 - 添加 Claude 工具权限配置
1 parent 95be248 commit 8a1fcd9

14 files changed

Lines changed: 817 additions & 625 deletions

.claude/settings.local.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"WebFetch(domain:jannesklaas.github.io)",
2727
"Bash(npm view:*)",
2828
"Bash(for file in src/ui/hooks/useKeyboardInput.ts src/ui/components/ReplInterface.tsx src/ui/ink/Input.tsx src/ui/ink/InputManager.tsx)",
29-
"Bash(do echo \"=== $file ===\" grep -n \"useInput\\|key\\.\" \"$file\")"
29+
"Bash(do echo \"=== $file ===\" grep -n \"useInput\\|key\\.\" \"$file\")",
30+
"Bash(ls:*)",
31+
"Bash(xargs:*)"
3032
],
3133
"deny": [],
3234
"ask": [],

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"scripts": {
1818
"dev": "bun --watch src/blade.tsx",
19-
"build": "rm -rf dist && bun build src/blade.tsx --external react-devtools-core --external react --external react-dom --external ink --external yargs --external chalk --external inquirer --minify --outfile dist/blade.js --target=node",
19+
"build": "rm -rf dist && bun build src/blade.tsx --external react-devtools-core --external react --external react-dom --external ink --external ink-* --external yargs --external chalk --external inquirer --minify --outfile dist/blade.js --target=node",
2020
"start": "bun run dist/blade.js",
2121
"test": "vitest",
2222
"test:watch": "vitest --watch",
@@ -100,6 +100,13 @@
100100
"axios": "^1.12.2",
101101
"chalk": "^5.4.1",
102102
"ink": "^6.2.3",
103+
"ink-big-text": "^2.0.0",
104+
"ink-gradient": "^3.0.0",
105+
"ink-multi-select": "^2.0.0",
106+
"ink-progress-bar": "^3.0.0",
107+
"ink-select-input": "^6.2.0",
108+
"ink-spinner": "^5.0.0",
109+
"ink-text-input": "^6.0.0",
103110
"inquirer": "^12.6.3",
104111
"lodash-es": "^4.17.21",
105112
"lowlight": "^3.3.0",

pnpm-lock.yaml

Lines changed: 319 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ui/components/Header.tsx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,54 @@
11
import { Box, Text } from 'ink';
2+
import BigText from 'ink-big-text';
3+
import Gradient from 'ink-gradient';
24
import React from 'react';
35

46
interface HeaderProps {
57
testMode: boolean;
8+
useBigText?: boolean; // 是否使用大标题
69
}
710

811
/**
912
* 应用头部组件
1013
* 显示应用标题、测试模式标识和退出提示
1114
*/
12-
export const Header: React.FC<HeaderProps> = ({ testMode }) => {
15+
export const Header: React.FC<HeaderProps> = ({ testMode, useBigText = false }) => {
16+
// 渲染大标题版本
17+
if (useBigText) {
18+
return (
19+
<Box flexDirection="column" marginBottom={1}>
20+
<Gradient name="rainbow">
21+
<BigText text="BLADE" font="block" />
22+
</Gradient>
23+
<Box flexDirection="row" justifyContent="space-between" paddingX={2}>
24+
<Text color="cyan">⚡ 现代化 AI 编码助手</Text>
25+
<Box flexDirection="row" gap={2}>
26+
{testMode && (
27+
<Text backgroundColor="red" color="white">
28+
{' '}
29+
TEST{' '}
30+
</Text>
31+
)}
32+
<Text color="gray" dimColor>
33+
Press Ctrl+C to exit
34+
</Text>
35+
</Box>
36+
</Box>
37+
</Box>
38+
);
39+
}
40+
41+
// 渲染紧凑版本
1342
return (
1443
<Box
1544
flexDirection="row"
1645
justifyContent="space-between"
1746
marginBottom={1}
1847
paddingX={2}
1948
>
20-
<Text color="cyan" bold>
21-
⚡ Blade Code
22-
</Text>
49+
<Gradient name="pastel">
50+
<Text bold>⚡ Blade Code</Text>
51+
</Gradient>
2352
<Box flexDirection="row" gap={2}>
2453
{testMode && (
2554
<Text backgroundColor="red" color="white">

src/ui/components/InputArea.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
import { Box, Text } from 'ink';
2+
import TextInput from 'ink-text-input';
23
import React from 'react';
34

45
interface InputAreaProps {
56
input: string;
67
isProcessing: boolean;
8+
onChange?: (value: string) => void;
9+
onSubmit?: (value: string) => void;
710
}
811

912
/**
1013
* 输入区域组件
1114
* 显示命令输入框和光标
1215
*/
13-
export const InputArea: React.FC<InputAreaProps> = ({ input, isProcessing }) => {
16+
export const InputArea: React.FC<InputAreaProps> = ({
17+
input,
18+
isProcessing,
19+
onChange,
20+
onSubmit,
21+
}) => {
1422
return (
1523
<Box
1624
flexDirection="row"
@@ -22,8 +30,20 @@ export const InputArea: React.FC<InputAreaProps> = ({ input, isProcessing }) =>
2230
<Text color="blue" bold>
2331
{'> '}
2432
</Text>
25-
<Text>{input}</Text>
26-
{isProcessing ? <Text color="yellow"></Text> : <Text color="white"></Text>}
33+
{onChange && onSubmit ? (
34+
<TextInput
35+
value={input}
36+
onChange={onChange}
37+
onSubmit={onSubmit}
38+
placeholder="输入命令..."
39+
showCursor={!isProcessing}
40+
/>
41+
) : (
42+
<>
43+
<Text>{input}</Text>
44+
{isProcessing ? <Text color="yellow"></Text> : <Text color="white"></Text>}
45+
</>
46+
)}
2747
</Box>
2848
);
2949
};

0 commit comments

Comments
 (0)