@dyyz1993/create-agent 2.0.1 → 2.1.1

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.
Files changed (60) hide show
  1. package/package.json +1 -1
  2. package/src/commands/create.ts +31 -31
  3. package/src/commands/workspace.ts +112 -105
  4. package/src/lib/copy.ts +117 -12
  5. package/templates/agent/.prettierignore +6 -0
  6. package/templates/agent/.prettierrc +9 -0
  7. package/templates/agent/commitlint.config.js +8 -0
  8. package/templates/agent/electron/main.js +46 -0
  9. package/templates/agent/electron/preload.js +5 -0
  10. package/templates/agent/electron-builder.json +40 -0
  11. package/templates/agent/eslint.config.mjs +2 -0
  12. package/templates/agent/package.json +75 -2
  13. package/templates/agent/src/mainview/App.tsx +29 -26
  14. package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +88 -88
  15. package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +105 -81
  16. package/templates/agent/src/mainview/components/search/SearchPanel.tsx +427 -378
  17. package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +3 -3
  18. package/templates/agent/src/mainview/hooks/use-input-history.ts +70 -61
  19. package/templates/agent/src/mainview/lib/api-client.ts +1 -4
  20. package/templates/agent/src/mainview/main.tsx +4 -10
  21. package/templates/agent/src/mainview/stores/use-feed-store.ts +107 -107
  22. package/templates/agent/src/mainview/utils/drop-handler.ts +114 -115
  23. package/templates/agent/src/server-config.ts +1 -1
  24. package/templates/agent/src/server.ts +1 -2
  25. package/templates/agent/src/shared/handlers/chat.ts +5 -5
  26. package/templates/agent/src/shared/handlers/debug.ts +5 -1
  27. package/templates/agent/src/shared/handlers/git.ts +286 -243
  28. package/templates/agent/src/shared/http-routes.ts +1 -1
  29. package/templates/agent/src/shared/lib/bash-security.ts +43 -43
  30. package/templates/agent/tsconfig.ipc.json +5 -1
  31. package/templates/agent/tsconfig.json +3 -1
  32. package/templates/chat/package.json +3 -0
  33. package/templates/chat/src/mainview/hooks/use-input-history.ts +70 -61
  34. package/templates/chat/src/mainview/lib/api-client.ts +2 -5
  35. package/templates/chat/src/mainview/main.tsx +10 -7
  36. package/templates/chat/src/server-config.ts +1 -1
  37. package/templates/chat/src/server.ts +1 -2
  38. package/templates/chat/src/shared/handlers/chat.ts +5 -5
  39. package/templates/chat/src/shared/handlers/debug.ts +5 -1
  40. package/templates/chat/src/shared/http-routes.ts +1 -1
  41. package/templates/chat/tsconfig.ipc.json +5 -1
  42. package/templates/chat/tsconfig.json +12 -2
  43. package/templates/general/package.json +3 -0
  44. package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +101 -81
  45. package/templates/general/src/mainview/components/search/SearchPanel.tsx +429 -378
  46. package/templates/general/src/mainview/hooks/use-input-history.ts +70 -61
  47. package/templates/general/src/mainview/lib/api-client.ts +2 -5
  48. package/templates/general/src/mainview/main.tsx +10 -7
  49. package/templates/general/src/mainview/stores/use-feed-store.ts +107 -107
  50. package/templates/general/src/mainview/utils/drop-handler.ts +114 -115
  51. package/templates/general/src/server-config.ts +1 -1
  52. package/templates/general/src/server.ts +1 -2
  53. package/templates/general/src/shared/handlers/chat.ts +5 -5
  54. package/templates/general/src/shared/handlers/debug.ts +5 -1
  55. package/templates/general/src/shared/handlers/git.ts +286 -243
  56. package/templates/general/src/shared/http-routes.ts +1 -1
  57. package/templates/general/tsconfig.ipc.json +5 -1
  58. package/templates/general/tsconfig.json +12 -2
  59. package/templates/shared/components/ErrorBoundary.tsx +50 -49
  60. 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
- code: string;
8
- filename: string;
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
- const parentRef = useRef<HTMLDivElement>(null);
16
- const language = getLanguage(filename);
17
- const lines = useMemo(() => code.split("\n"), [code]);
15
+ const parentRef = useRef<HTMLDivElement>(null);
16
+ const language = getLanguage(filename);
17
+ const lines = useMemo(() => code.split("\n"), [code]);
18
18
 
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;
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
- const virtualizer = useVirtualizer({
24
- count: lines.length,
25
- getScrollElement: () => parentRef.current,
26
- estimateSize: () => 20,
27
- overscan: 20,
28
- });
23
+ const virtualizer = useVirtualizer({
24
+ count: lines.length,
25
+ getScrollElement: () => parentRef.current,
26
+ estimateSize: () => 20,
27
+ overscan: 20,
28
+ });
29
29
 
30
- // --- Plain text path: no Prism tokenization ---
31
- if (usePlainText) {
32
- return (
33
- <div ref={parentRef} className="flex-1 min-h-0 overflow-auto" style={{ background: "#011627" }}>
34
- <div
35
- style={{ height: `${virtualizer.getTotalSize()}px`, width: "100%", position: "relative" }}
36
- >
37
- {virtualizer.getVirtualItems().map((vr) => (
38
- <div
39
- key={vr.key}
40
- style={{
41
- position: "absolute", top: 0, left: 0, width: "100%",
42
- height: `${vr.size}px`, transform: `translateY(${vr.start}px)`,
43
- }}
44
- className="flex text-xs leading-5 font-mono"
45
- >
46
- <span className="inline-block w-10 text-right pr-4 text-gray-600 select-none shrink-0">
47
- {vr.index + 1}
48
- </span>
49
- <span className="flex-1 text-gray-300 whitespace-pre">{lines[vr.index]}</span>
50
- </div>
51
- ))}
52
- </div>
53
- </div>
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
- // --- Highlighted path: tokenize ONCE for the whole file, virtualize rendering ---
58
- return (
59
- <Highlight theme={themes.nightOwl} code={code} language={language}>
60
- {({ tokens, getTokenProps }) => (
61
- <div ref={parentRef} className="flex-1 min-h-0 overflow-auto" style={{ background: "#011627" }}>
62
- <div
63
- style={{ height: `${virtualizer.getTotalSize()}px`, width: "100%", position: "relative" }}
64
- >
65
- {virtualizer.getVirtualItems().map((vr) => {
66
- const lineTokens = tokens[vr.index];
67
- const lineText = lines[vr.index];
68
- const isLongLine = (lineText?.length ?? 0) > LONG_LINE_THRESHOLD;
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
- return (
71
- <div
72
- key={vr.key}
73
- style={{
74
- position: "absolute", top: 0, left: 0, width: "100%",
75
- height: `${vr.size}px`, transform: `translateY(${vr.start}px)`,
76
- }}
77
- className="flex text-xs leading-5 font-mono"
78
- >
79
- <span className="inline-block w-10 text-right pr-4 text-gray-600 select-none shrink-0">
80
- {vr.index + 1}
81
- </span>
82
- {isLongLine ? (
83
- <span className="flex-1 text-gray-300 whitespace-pre">{lineText}</span>
84
- ) : (
85
- <span className="flex-1">
86
- {lineTokens.map((token, key) => (
87
- <span key={key} {...getTokenProps({ token })} />
88
- ))}
89
- </span>
90
- )}
91
- </div>
92
- );
93
- })}
94
- </div>
95
- </div>
96
- )}
97
- </Highlight>
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
  }