@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
|
@@ -4,96 +4,116 @@ 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-gray-300 whitespace-pre">{lines[vr.index]}</span>
|
|
58
|
+
</div>
|
|
59
|
+
))}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
// --- Highlighted path: tokenize ONCE for the whole file, virtualize rendering ---
|
|
66
|
+
return (
|
|
67
|
+
<Highlight theme={themes.nightOwl} code={code} language={language}>
|
|
68
|
+
{({ tokens, getTokenProps }) => (
|
|
69
|
+
<div
|
|
70
|
+
ref={parentRef}
|
|
71
|
+
className="flex-1 min-h-0 overflow-auto"
|
|
72
|
+
style={{ background: "#011627" }}
|
|
73
|
+
>
|
|
74
|
+
<div
|
|
75
|
+
style={{
|
|
76
|
+
height: `${virtualizer.getTotalSize()}px`,
|
|
77
|
+
width: "100%",
|
|
78
|
+
position: "relative",
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{virtualizer.getVirtualItems().map((vr) => {
|
|
82
|
+
const lineTokens = tokens[vr.index];
|
|
83
|
+
const lineText = lines[vr.index];
|
|
84
|
+
const isLongLine = (lineText?.length ?? 0) > LONG_LINE_THRESHOLD;
|
|
69
85
|
|
|
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
|
-
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
key={vr.key}
|
|
89
|
+
style={{
|
|
90
|
+
position: "absolute",
|
|
91
|
+
top: 0,
|
|
92
|
+
left: 0,
|
|
93
|
+
width: "100%",
|
|
94
|
+
height: `${vr.size}px`,
|
|
95
|
+
transform: `translateY(${vr.start}px)`,
|
|
96
|
+
}}
|
|
97
|
+
className="flex text-xs leading-5 font-mono"
|
|
98
|
+
>
|
|
99
|
+
<span className="inline-block w-10 text-right pr-4 text-gray-600 select-none shrink-0">
|
|
100
|
+
{vr.index + 1}
|
|
101
|
+
</span>
|
|
102
|
+
{isLongLine ? (
|
|
103
|
+
<span className="flex-1 text-gray-300 whitespace-pre">{lineText}</span>
|
|
104
|
+
) : (
|
|
105
|
+
<span className="flex-1">
|
|
106
|
+
{lineTokens!.map((token, key) => (
|
|
107
|
+
<span key={key} {...getTokenProps({ token })} />
|
|
108
|
+
))}
|
|
109
|
+
</span>
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
)}
|
|
117
|
+
</Highlight>
|
|
118
|
+
);
|
|
99
119
|
}
|