@axeai/axe 0.0.1-beta
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 +53 -0
- package/bin/axe.js +2 -0
- package/package.json +60 -0
- package/src/app.tsx +400 -0
- package/src/index.tsx +27 -0
- package/src/lib/agent.ts +108 -0
- package/src/lib/config.ts +76 -0
- package/src/lib/db.ts +135 -0
- package/src/lib/filesystem.ts +83 -0
- package/src/lib/prompt.ts +38 -0
- package/src/lib/provider.ts +71 -0
- package/src/tools/shell.ts +31 -0
- package/src/ui/autocomplete.tsx +22 -0
- package/src/ui/header.tsx +25 -0
- package/src/ui/input-area.tsx +121 -0
- package/src/ui/layout.tsx +28 -0
- package/src/ui/message.tsx +38 -0
- package/src/ui/session-picker.tsx +116 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, Text, useInput } from "ink";
|
|
3
|
+
import type { Session } from "../lib/db";
|
|
4
|
+
|
|
5
|
+
type SessionPickerProps = {
|
|
6
|
+
currentDirSessions: Session[];
|
|
7
|
+
selectedIndex: number;
|
|
8
|
+
onSelect: (session: Session | null) => void;
|
|
9
|
+
onNavigate: (direction: "up" | "down") => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const SessionPicker: React.FC<SessionPickerProps> = ({
|
|
13
|
+
currentDirSessions,
|
|
14
|
+
selectedIndex,
|
|
15
|
+
onSelect,
|
|
16
|
+
onNavigate,
|
|
17
|
+
}) => {
|
|
18
|
+
const totalItems = currentDirSessions.length + 1;
|
|
19
|
+
|
|
20
|
+
useInput((input, key) => {
|
|
21
|
+
if (key.upArrow) {
|
|
22
|
+
onNavigate("up");
|
|
23
|
+
}
|
|
24
|
+
if (key.downArrow) {
|
|
25
|
+
onNavigate("down");
|
|
26
|
+
}
|
|
27
|
+
if (key.return) {
|
|
28
|
+
if (selectedIndex === 0) {
|
|
29
|
+
onSelect(null);
|
|
30
|
+
} else {
|
|
31
|
+
onSelect(currentDirSessions[selectedIndex - 1]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const formatDate = (dateStr: string) => {
|
|
37
|
+
const date = new Date(dateStr);
|
|
38
|
+
const now = new Date();
|
|
39
|
+
const diffMs = now.getTime() - date.getTime();
|
|
40
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
41
|
+
const diffHours = Math.floor(diffMs / 3600000);
|
|
42
|
+
const diffDays = Math.floor(diffMs / 86400000);
|
|
43
|
+
|
|
44
|
+
if (diffMins < 1) return "just now";
|
|
45
|
+
if (diffMins < 60) return `${diffMins}m ago`;
|
|
46
|
+
if (diffHours < 24) return `${diffHours}h ago`;
|
|
47
|
+
if (diffDays < 7) return `${diffDays}d ago`;
|
|
48
|
+
return date.toLocaleDateString();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Box flexDirection="column" paddingX={2} paddingY={1}>
|
|
53
|
+
{/* Header */}
|
|
54
|
+
<Box marginBottom={1}>
|
|
55
|
+
<Text color="cyan" bold>
|
|
56
|
+
AXE
|
|
57
|
+
</Text>
|
|
58
|
+
<Text dimColor> - AI Coding Assistant</Text>
|
|
59
|
+
</Box>
|
|
60
|
+
|
|
61
|
+
{/* Divider */}
|
|
62
|
+
<Box marginBottom={1}>
|
|
63
|
+
<Text dimColor>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</Text>
|
|
64
|
+
</Box>
|
|
65
|
+
|
|
66
|
+
{/* Session Picker Title */}
|
|
67
|
+
<Box marginBottom={1}>
|
|
68
|
+
<Text color="yellow" bold>📂 Select a Session</Text>
|
|
69
|
+
</Box>
|
|
70
|
+
|
|
71
|
+
{/* New Session Option */}
|
|
72
|
+
<Box>
|
|
73
|
+
<Text color={selectedIndex === 0 ? "green" : "white"} bold={selectedIndex === 0}>
|
|
74
|
+
{selectedIndex === 0 ? "▸ " : " "}
|
|
75
|
+
<Text color={selectedIndex === 0 ? "green" : "cyan"}>✨ Start New Session</Text>
|
|
76
|
+
</Text>
|
|
77
|
+
</Box>
|
|
78
|
+
|
|
79
|
+
{/* Existing Sessions */}
|
|
80
|
+
{currentDirSessions.length > 0 && (
|
|
81
|
+
<Box flexDirection="column" marginTop={1}>
|
|
82
|
+
<Text dimColor bold> Recent Sessions:</Text>
|
|
83
|
+
{currentDirSessions.map((session, idx) => {
|
|
84
|
+
const itemIdx = idx + 1;
|
|
85
|
+
const isSelected = selectedIndex === itemIdx;
|
|
86
|
+
return (
|
|
87
|
+
<Box key={session.id} paddingLeft={0}>
|
|
88
|
+
<Text color={isSelected ? "green" : "white"} bold={isSelected}>
|
|
89
|
+
{isSelected ? "▸ " : " "}
|
|
90
|
+
<Text color={isSelected ? "green" : "gray"}>💬 </Text>
|
|
91
|
+
<Text color={isSelected ? "green" : "white"}>
|
|
92
|
+
{session.name || `Session ${session.id.slice(0, 8)}`}
|
|
93
|
+
</Text>
|
|
94
|
+
<Text dimColor>
|
|
95
|
+
{" "}({session.message_count} msgs • {formatDate(session.last_message_at)})
|
|
96
|
+
</Text>
|
|
97
|
+
</Text>
|
|
98
|
+
</Box>
|
|
99
|
+
);
|
|
100
|
+
})}
|
|
101
|
+
</Box>
|
|
102
|
+
)}
|
|
103
|
+
|
|
104
|
+
{/* Footer */}
|
|
105
|
+
<Box marginTop={2}>
|
|
106
|
+
<Text dimColor>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</Text>
|
|
107
|
+
</Box>
|
|
108
|
+
<Box marginTop={1}>
|
|
109
|
+
<Text dimColor>
|
|
110
|
+
<Text color="gray">↑↓</Text> Navigate
|
|
111
|
+
<Text color="gray"> Enter</Text> Select
|
|
112
|
+
</Text>
|
|
113
|
+
</Box>
|
|
114
|
+
</Box>
|
|
115
|
+
);
|
|
116
|
+
};
|