@dyyz1993/create-agent 2.0.1 → 2.1.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/package.json +1 -1
- package/src/commands/create.ts +31 -31
- package/src/commands/workspace.ts +112 -105
- package/src/lib/copy.ts +1 -0
- package/templates/agent/electron/main.js +46 -0
- package/templates/agent/electron/preload.js +5 -0
- package/templates/agent/electron-builder.json +40 -0
- package/templates/agent/eslint.config.mjs +2 -0
- package/templates/agent/package.json +60 -2
- package/templates/agent/src/mainview/App.tsx +29 -26
- package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +88 -88
- package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +105 -81
- package/templates/agent/src/mainview/components/search/SearchPanel.tsx +427 -378
- package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +3 -3
- package/templates/agent/src/mainview/hooks/use-input-history.ts +70 -61
- package/templates/agent/src/mainview/lib/api-client.ts +1 -4
- package/templates/agent/src/mainview/main.tsx +4 -10
- package/templates/agent/src/mainview/stores/use-feed-store.ts +107 -107
- package/templates/agent/src/mainview/utils/drop-handler.ts +114 -115
- package/templates/agent/src/server-config.ts +1 -1
- package/templates/agent/src/server.ts +1 -2
- package/templates/agent/src/shared/handlers/chat.ts +5 -5
- package/templates/agent/src/shared/handlers/debug.ts +5 -1
- package/templates/agent/src/shared/handlers/git.ts +286 -243
- package/templates/agent/src/shared/http-routes.ts +1 -1
- package/templates/agent/src/shared/lib/bash-security.ts +43 -43
- package/templates/agent/tsconfig.ipc.json +5 -1
- package/templates/agent/tsconfig.json +3 -1
- package/templates/chat/package.json +3 -0
- package/templates/chat/src/mainview/hooks/use-input-history.ts +70 -61
- package/templates/chat/src/mainview/lib/api-client.ts +2 -5
- package/templates/chat/src/mainview/main.tsx +10 -7
- package/templates/chat/src/server-config.ts +1 -1
- package/templates/chat/src/server.ts +1 -2
- package/templates/chat/src/shared/handlers/chat.ts +5 -5
- package/templates/chat/src/shared/handlers/debug.ts +5 -1
- package/templates/chat/src/shared/http-routes.ts +1 -1
- package/templates/chat/tsconfig.ipc.json +5 -1
- package/templates/chat/tsconfig.json +12 -2
- package/templates/general/package.json +3 -0
- package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +101 -81
- package/templates/general/src/mainview/components/search/SearchPanel.tsx +429 -378
- package/templates/general/src/mainview/hooks/use-input-history.ts +70 -61
- package/templates/general/src/mainview/lib/api-client.ts +2 -5
- package/templates/general/src/mainview/main.tsx +10 -7
- package/templates/general/src/mainview/stores/use-feed-store.ts +107 -107
- package/templates/general/src/mainview/utils/drop-handler.ts +114 -115
- package/templates/general/src/server-config.ts +1 -1
- package/templates/general/src/server.ts +1 -2
- package/templates/general/src/shared/handlers/chat.ts +5 -5
- package/templates/general/src/shared/handlers/debug.ts +5 -1
- package/templates/general/src/shared/handlers/git.ts +286 -243
- package/templates/general/src/shared/http-routes.ts +1 -1
- package/templates/general/tsconfig.ipc.json +5 -1
- package/templates/general/tsconfig.json +12 -2
- package/templates/shared/components/ErrorBoundary.tsx +50 -49
- package/templates/shared/http-routes.ts +210 -190
|
@@ -6,97 +6,97 @@ import { useChatStore } from "../../stores/use-chat-store";
|
|
|
6
6
|
import { MessageBubble } from "./MessageBubble";
|
|
7
7
|
|
|
8
8
|
export function ChatPanel() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const messages = useChatStore((s) => s.messages);
|
|
11
|
+
const inputText = useChatStore((s) => s.inputText);
|
|
12
|
+
const setInputText = useChatStore((s) => s.setInputText);
|
|
13
|
+
const sendMessage = useChatStore((s) => s.sendMessage);
|
|
14
|
+
const parentRef = useRef<HTMLDivElement>(null);
|
|
15
|
+
const prevMessageCountRef = useRef(0);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const virtualizer = useVirtualizer({
|
|
18
|
+
count: messages.length,
|
|
19
|
+
getScrollElement: () => parentRef.current,
|
|
20
|
+
estimateSize: () => 80,
|
|
21
|
+
overscan: 5,
|
|
22
|
+
measureElement: (element) => element?.getBoundingClientRect().height ?? 80,
|
|
23
|
+
});
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (messages.length > prevMessageCountRef.current) {
|
|
27
|
+
virtualizer.scrollToIndex(messages.length - 1, { align: "end" });
|
|
28
|
+
}
|
|
29
|
+
prevMessageCountRef.current = messages.length;
|
|
30
|
+
}, [messages.length, virtualizer]);
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
return (
|
|
33
|
+
<div className="flex-1 flex flex-col overflow-hidden relative">
|
|
34
|
+
<div className="px-4 py-2 bg-[var(--color-bg-secondary)] border-b border-[var(--color-border-primary)] flex items-center justify-between flex-shrink-0">
|
|
35
|
+
<h2 className="text-sm font-semibold flex items-center gap-1.5">
|
|
36
|
+
<MessageSquare className="w-4 h-4 text-[var(--color-text-accent)]" />
|
|
37
|
+
{t("chat.title")}
|
|
38
|
+
{messages.length > 0 && (
|
|
39
|
+
<span className="ml-1 px-2 py-0.5 bg-[var(--color-accent)]/30 text-[var(--color-text-accent)] rounded text-[10px]">
|
|
40
|
+
{messages.length}
|
|
41
|
+
</span>
|
|
42
|
+
)}
|
|
43
|
+
</h2>
|
|
44
|
+
</div>
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
46
|
+
<div ref={parentRef} className="flex-1 overflow-y-auto">
|
|
47
|
+
{messages.length === 0 ? (
|
|
48
|
+
<div className="flex items-center justify-center h-full text-[var(--color-text-placeholder)] text-sm">
|
|
49
|
+
{t("chat.empty")}
|
|
50
|
+
</div>
|
|
51
|
+
) : (
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
height: virtualizer.getTotalSize(),
|
|
55
|
+
width: "100%",
|
|
56
|
+
position: "relative",
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
{virtualizer.getVirtualItems().map((virtualItem) => {
|
|
60
|
+
const msg = messages[virtualItem.index]!;
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
key={msg.id}
|
|
64
|
+
data-index={virtualItem.index}
|
|
65
|
+
ref={virtualizer.measureElement}
|
|
66
|
+
style={{
|
|
67
|
+
position: "absolute",
|
|
68
|
+
top: 0,
|
|
69
|
+
left: 0,
|
|
70
|
+
width: "100%",
|
|
71
|
+
transform: `translateY(${virtualItem.start}px)`,
|
|
72
|
+
padding: "6px 16px",
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<MessageBubble message={msg} />
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
})}
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
<div className="px-4 py-3 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border-primary)] flex gap-2 flex-shrink-0">
|
|
84
|
+
<input
|
|
85
|
+
type="text"
|
|
86
|
+
value={inputText}
|
|
87
|
+
onChange={(e) => setInputText(e.target.value)}
|
|
88
|
+
onKeyDown={(e) => e.key === "Enter" && !e.shiftKey && sendMessage()}
|
|
89
|
+
placeholder={t("chat.placeholder")}
|
|
90
|
+
className="flex-1 px-3 py-2 text-sm bg-[var(--color-bg-tertiary)] rounded-lg text-[var(--color-text-primary)] border border-[var(--color-border-secondary)] focus:border-[var(--color-accent)] focus:outline-none"
|
|
91
|
+
/>
|
|
92
|
+
<button
|
|
93
|
+
onClick={sendMessage}
|
|
94
|
+
className="px-4 py-2 text-sm bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] rounded-lg transition-colors flex items-center gap-1.5"
|
|
95
|
+
>
|
|
96
|
+
<Send className="w-4 h-4" />
|
|
97
|
+
{t("chat.send")}
|
|
98
|
+
</button>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
102
|
}
|
|
@@ -4,96 +4,120 @@ import { Highlight, themes } from "prism-react-renderer";
|
|
|
4
4
|
import { getLanguage } from "../../utils/file-utils";
|
|
5
5
|
|
|
6
6
|
interface VirtualizedCodeViewProps {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
code: string;
|
|
8
|
+
filename: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/** Lines longer than this skip syntax highlighting (plain text instead) */
|
|
12
12
|
const LONG_LINE_THRESHOLD = 5000;
|
|
13
13
|
|
|
14
14
|
export function VirtualizedCodeView({ code, filename }: VirtualizedCodeViewProps) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const parentRef = useRef<HTMLDivElement>(null);
|
|
16
|
+
const language = getLanguage(filename);
|
|
17
|
+
const lines = useMemo(() => code.split("\n"), [code]);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// Detect minified files: avg line length > 500 chars
|
|
20
|
+
const avgLineLength = code.length / Math.max(lines.length, 1);
|
|
21
|
+
const usePlainText = !language || avgLineLength > 500;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const virtualizer = useVirtualizer({
|
|
24
|
+
count: lines.length,
|
|
25
|
+
getScrollElement: () => parentRef.current,
|
|
26
|
+
estimateSize: () => 20,
|
|
27
|
+
overscan: 20,
|
|
28
|
+
});
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
30
|
+
// --- Plain text path: no Prism tokenization ---
|
|
31
|
+
if (usePlainText) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
ref={parentRef}
|
|
35
|
+
className="flex-1 min-h-0 overflow-auto"
|
|
36
|
+
style={{ background: "#011627" }}
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
style={{ height: `${virtualizer.getTotalSize()}px`, width: "100%", position: "relative" }}
|
|
40
|
+
>
|
|
41
|
+
{virtualizer.getVirtualItems().map((vr) => (
|
|
42
|
+
<div
|
|
43
|
+
key={vr.key}
|
|
44
|
+
style={{
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: `${vr.size}px`,
|
|
50
|
+
transform: `translateY(${vr.start}px)`,
|
|
51
|
+
}}
|
|
52
|
+
className="flex text-xs leading-5 font-mono"
|
|
53
|
+
>
|
|
54
|
+
<span className="inline-block w-10 text-right pr-4 text-gray-600 select-none shrink-0">
|
|
55
|
+
{vr.index + 1}
|
|
56
|
+
</span>
|
|
57
|
+
<span className="flex-1 text-[var(--color-text-secondary)] whitespace-pre">
|
|
58
|
+
{lines[vr.index]}
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
// --- Highlighted path: tokenize ONCE for the whole file, virtualize rendering ---
|
|
68
|
+
return (
|
|
69
|
+
<Highlight theme={themes.nightOwl} code={code} language={language}>
|
|
70
|
+
{({ tokens, getTokenProps }) => (
|
|
71
|
+
<div
|
|
72
|
+
ref={parentRef}
|
|
73
|
+
className="flex-1 min-h-0 overflow-auto"
|
|
74
|
+
style={{ background: "#011627" }}
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
style={{
|
|
78
|
+
height: `${virtualizer.getTotalSize()}px`,
|
|
79
|
+
width: "100%",
|
|
80
|
+
position: "relative",
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{virtualizer.getVirtualItems().map((vr) => {
|
|
84
|
+
const lineTokens = tokens[vr.index];
|
|
85
|
+
const lineText = lines[vr.index];
|
|
86
|
+
const isLongLine = (lineText?.length ?? 0) > LONG_LINE_THRESHOLD;
|
|
69
87
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
return (
|
|
89
|
+
<div
|
|
90
|
+
key={vr.key}
|
|
91
|
+
style={{
|
|
92
|
+
position: "absolute",
|
|
93
|
+
top: 0,
|
|
94
|
+
left: 0,
|
|
95
|
+
width: "100%",
|
|
96
|
+
height: `${vr.size}px`,
|
|
97
|
+
transform: `translateY(${vr.start}px)`,
|
|
98
|
+
}}
|
|
99
|
+
className="flex text-xs leading-5 font-mono"
|
|
100
|
+
>
|
|
101
|
+
<span className="inline-block w-10 text-right pr-4 text-gray-600 select-none shrink-0">
|
|
102
|
+
{vr.index + 1}
|
|
103
|
+
</span>
|
|
104
|
+
{isLongLine ? (
|
|
105
|
+
<span className="flex-1 text-[var(--color-text-secondary)] whitespace-pre">
|
|
106
|
+
{lineText}
|
|
107
|
+
</span>
|
|
108
|
+
) : (
|
|
109
|
+
<span className="flex-1">
|
|
110
|
+
{lineTokens!.map((token, key) => (
|
|
111
|
+
<span key={key} {...getTokenProps({ token })} />
|
|
112
|
+
))}
|
|
113
|
+
</span>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
})}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
)}
|
|
121
|
+
</Highlight>
|
|
122
|
+
);
|
|
99
123
|
}
|