@dyyz1993/create-agent 2.0.0 → 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.
Files changed (165) 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 +24 -1
  5. package/templates/agent/electron/main.js +46 -0
  6. package/templates/agent/electron/preload.js +5 -0
  7. package/templates/agent/electron-builder.json +40 -0
  8. package/templates/agent/eslint.config.mjs +17 -2
  9. package/templates/agent/package.json +69 -3
  10. package/templates/agent/src/__tests__/hybrid-mode.test.ts +126 -0
  11. package/templates/agent/src/__tests__/server-config-security.test.ts +55 -0
  12. package/templates/agent/src/bun/index.ts +96 -41
  13. package/templates/agent/src/bun/three.d.ts +1 -0
  14. package/templates/agent/src/gateway/__tests__/ws-handler-token.test.ts +118 -0
  15. package/templates/agent/src/gateway/http-routes.ts +1 -1
  16. package/templates/agent/src/gateway/ws-handler.ts +84 -56
  17. package/templates/agent/src/mainview/App.tsx +29 -26
  18. package/templates/agent/src/mainview/__tests__/i18n/i18n.test.ts +1 -0
  19. package/templates/agent/src/mainview/__tests__/setup.ts +32 -29
  20. package/templates/agent/src/mainview/__tests__/theme-variables.test.ts +36 -0
  21. package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +88 -88
  22. package/templates/agent/src/mainview/components/common/ErrorBoundary.tsx +1 -58
  23. package/templates/agent/src/mainview/components/common/LanguageSwitcher.tsx +1 -0
  24. package/templates/agent/src/mainview/components/common/ThemeToggle.tsx +1 -0
  25. package/templates/agent/src/mainview/components/feed/FeedPanel.tsx +232 -210
  26. package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +105 -81
  27. package/templates/agent/src/mainview/components/search/SearchPanel.tsx +427 -378
  28. package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +149 -122
  29. package/templates/agent/src/mainview/hooks/use-input-history.ts +70 -61
  30. package/templates/agent/src/mainview/lib/api-client.ts +179 -172
  31. package/templates/agent/src/mainview/main.tsx +4 -10
  32. package/templates/agent/src/mainview/stores/use-feed-store.ts +107 -107
  33. package/templates/agent/src/mainview/utils/drop-handler.ts +114 -115
  34. package/templates/agent/src/server-config.ts +34 -32
  35. package/templates/agent/src/server.ts +42 -54
  36. package/templates/agent/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
  37. package/templates/agent/src/shared/handlers/__tests__/handler-isolation.test.ts +244 -0
  38. package/templates/agent/src/shared/handlers/bash.ts +65 -65
  39. package/templates/agent/src/shared/handlers/chat.ts +189 -155
  40. package/templates/agent/src/shared/handlers/debug.ts +12 -0
  41. package/templates/agent/src/shared/handlers/feed.ts +31 -32
  42. package/templates/agent/src/shared/handlers/git.ts +286 -243
  43. package/templates/agent/src/shared/handlers/index.ts +1 -0
  44. package/templates/agent/src/shared/handlers/rules.ts +31 -31
  45. package/templates/agent/src/shared/handlers/todo.ts +31 -31
  46. package/templates/agent/src/shared/http-routes.ts +250 -0
  47. package/templates/agent/src/shared/lib/__tests__/web-server.test.ts +190 -0
  48. package/templates/agent/src/shared/lib/bash-security.ts +43 -43
  49. package/templates/agent/src/shared/lib/logger.ts +117 -95
  50. package/templates/agent/src/shared/lib/web-server.ts +128 -0
  51. package/templates/agent/src/shared/modules/debug.ts +8 -0
  52. package/templates/agent/src/shared/rpc-schema.ts +16 -3
  53. package/templates/agent/test-upload.txt +0 -0
  54. package/templates/agent/tsconfig.ipc.json +14 -0
  55. package/templates/agent/tsconfig.json +13 -3
  56. package/templates/chat/eslint.config.mjs +15 -2
  57. package/templates/chat/package.json +13 -2
  58. package/templates/chat/src/__tests__/hybrid-mode.test.ts +125 -0
  59. package/templates/chat/src/__tests__/server-config-security.test.ts +55 -0
  60. package/templates/chat/src/__tests__/server-config.test.ts +46 -44
  61. package/templates/chat/src/bun/index.ts +94 -44
  62. package/templates/chat/src/bun/three.d.ts +1 -0
  63. package/templates/chat/src/gateway/http-routes.ts +1 -1
  64. package/templates/chat/src/gateway/ws-handler.ts +84 -56
  65. package/templates/chat/src/mainview/App.tsx +6 -0
  66. package/templates/chat/src/mainview/__tests__/i18n/i18n.test.ts +1 -0
  67. package/templates/chat/src/mainview/__tests__/theme-variables.test.ts +36 -0
  68. package/templates/chat/src/mainview/components/common/LanguageSwitcher.tsx +1 -0
  69. package/templates/chat/src/mainview/components/common/ThemeToggle.tsx +1 -0
  70. package/templates/chat/src/mainview/hooks/use-input-history.ts +70 -61
  71. package/templates/chat/src/mainview/lib/api-client.ts +180 -156
  72. package/templates/chat/src/mainview/lib/rpc-cache.ts +84 -0
  73. package/templates/chat/src/mainview/main.tsx +10 -6
  74. package/templates/chat/src/server-config.ts +33 -31
  75. package/templates/chat/src/server.ts +42 -60
  76. package/templates/chat/src/shared/handlers/chat.ts +196 -162
  77. package/templates/chat/src/shared/handlers/debug.ts +12 -0
  78. package/templates/chat/src/shared/handlers/index.ts +1 -0
  79. package/templates/chat/src/shared/http-routes.ts +250 -0
  80. package/templates/chat/src/shared/lib/__tests__/logger.test.ts +92 -0
  81. package/templates/chat/src/shared/lib/logger.ts +108 -95
  82. package/templates/chat/src/shared/lib/web-server.ts +128 -0
  83. package/templates/chat/src/shared/modules/debug.ts +8 -0
  84. package/templates/chat/src/shared/rpc-schema.ts +3 -2
  85. package/templates/chat/test-upload.txt +0 -0
  86. package/templates/chat/tsconfig.ipc.json +14 -0
  87. package/templates/chat/tsconfig.json +12 -2
  88. package/templates/general/eslint.config.mjs +15 -2
  89. package/templates/general/package.json +13 -2
  90. package/templates/general/src/__tests__/hybrid-mode.test.ts +125 -0
  91. package/templates/general/src/__tests__/server-config-security.test.ts +55 -0
  92. package/templates/general/src/__tests__/server-config.test.ts +46 -44
  93. package/templates/general/src/bun/index.ts +94 -44
  94. package/templates/general/src/bun/three.d.ts +1 -0
  95. package/templates/general/src/gateway/http-routes.ts +1 -1
  96. package/templates/general/src/gateway/ws-handler.ts +84 -56
  97. package/templates/general/src/mainview/__tests__/i18n/i18n.test.ts +1 -0
  98. package/templates/general/src/mainview/__tests__/theme-variables.test.ts +36 -0
  99. package/templates/general/src/mainview/components/common/LanguageSwitcher.tsx +1 -0
  100. package/templates/general/src/mainview/components/common/ThemeToggle.tsx +1 -0
  101. package/templates/general/src/mainview/components/feed/FeedPanel.tsx +241 -219
  102. package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +101 -81
  103. package/templates/general/src/mainview/components/layout/AppLayout.tsx +6 -0
  104. package/templates/general/src/mainview/components/search/SearchPanel.tsx +429 -378
  105. package/templates/general/src/mainview/hooks/use-input-history.ts +70 -61
  106. package/templates/general/src/mainview/lib/api-client.ts +180 -156
  107. package/templates/general/src/mainview/lib/rpc-cache.ts +84 -0
  108. package/templates/general/src/mainview/main.tsx +10 -6
  109. package/templates/general/src/mainview/stores/use-feed-store.ts +107 -107
  110. package/templates/general/src/mainview/utils/drop-handler.ts +114 -115
  111. package/templates/general/src/server-config.ts +33 -31
  112. package/templates/general/src/server.ts +42 -60
  113. package/templates/general/src/shared/handlers/__tests__/chat.test.ts +165 -160
  114. package/templates/general/src/shared/handlers/chat.ts +189 -155
  115. package/templates/general/src/shared/handlers/debug.ts +12 -0
  116. package/templates/general/src/shared/handlers/feed.ts +38 -40
  117. package/templates/general/src/shared/handlers/git.ts +286 -243
  118. package/templates/general/src/shared/handlers/index.ts +1 -0
  119. package/templates/general/src/shared/http-routes.ts +250 -0
  120. package/templates/general/src/shared/lib/__tests__/logger.test.ts +92 -0
  121. package/templates/general/src/shared/lib/logger.ts +117 -95
  122. package/templates/general/src/shared/lib/web-server.ts +128 -0
  123. package/templates/general/src/shared/modules/debug.ts +8 -0
  124. package/templates/general/src/shared/rpc-schema.ts +12 -2
  125. package/templates/general/test-upload.txt +0 -0
  126. package/templates/general/tsconfig.ipc.json +14 -0
  127. package/templates/general/tsconfig.json +12 -2
  128. package/templates/shared/__tests__/cors-security.test.ts +165 -0
  129. package/templates/shared/__tests__/file-path-security.test.ts +260 -0
  130. package/templates/shared/__tests__/http-routes.test.ts +174 -0
  131. package/templates/shared/__tests__/logger.test.ts +186 -0
  132. package/templates/shared/components/ErrorBoundary.tsx +59 -0
  133. package/templates/shared/env.d.ts +11 -0
  134. package/templates/shared/http-routes.ts +250 -0
  135. package/templates/shared/logger.ts +129 -0
  136. package/templates/shared/test-upload.txt +0 -0
  137. package/templates/shared/vite-base.config.ts +92 -0
  138. package/templates/shared/vitest-base.config.ts +42 -0
  139. package/templates/agent/eslint-plugin-rpc/index.js +0 -50
  140. package/templates/agent/eslint-plugin-rpc/package.json +0 -6
  141. package/templates/agent/eslint-plugin-rpc/rules/module-file-naming.js +0 -99
  142. package/templates/agent/eslint-plugin-rpc/rules/no-bare-method.js +0 -78
  143. package/templates/agent/eslint-plugin-rpc/rules/no-direct-register.js +0 -65
  144. package/templates/agent/eslint-plugin-rpc/rules/no-hardcoded-strings.js +0 -69
  145. package/templates/agent/eslint-plugin-rpc/rules/require-api-client.js +0 -58
  146. package/templates/agent/eslint-plugin-rpc/rules/require-typed-register.js +0 -78
  147. package/templates/agent/eslint-plugin-rpc/rules/schema-merge-only.js +0 -55
  148. package/templates/chat/eslint-plugin-rpc/index.js +0 -50
  149. package/templates/chat/eslint-plugin-rpc/package.json +0 -6
  150. package/templates/chat/eslint-plugin-rpc/rules/module-file-naming.js +0 -99
  151. package/templates/chat/eslint-plugin-rpc/rules/no-bare-method.js +0 -78
  152. package/templates/chat/eslint-plugin-rpc/rules/no-direct-register.js +0 -65
  153. package/templates/chat/eslint-plugin-rpc/rules/no-hardcoded-strings.js +0 -69
  154. package/templates/chat/eslint-plugin-rpc/rules/require-api-client.js +0 -58
  155. package/templates/chat/eslint-plugin-rpc/rules/require-typed-register.js +0 -78
  156. package/templates/chat/eslint-plugin-rpc/rules/schema-merge-only.js +0 -55
  157. package/templates/general/eslint-plugin-rpc/index.js +0 -50
  158. package/templates/general/eslint-plugin-rpc/package.json +0 -6
  159. package/templates/general/eslint-plugin-rpc/rules/module-file-naming.js +0 -99
  160. package/templates/general/eslint-plugin-rpc/rules/no-bare-method.js +0 -78
  161. package/templates/general/eslint-plugin-rpc/rules/no-direct-register.js +0 -65
  162. package/templates/general/eslint-plugin-rpc/rules/no-hardcoded-strings.js +0 -69
  163. package/templates/general/eslint-plugin-rpc/rules/require-api-client.js +0 -58
  164. package/templates/general/eslint-plugin-rpc/rules/require-typed-register.js +0 -78
  165. package/templates/general/eslint-plugin-rpc/rules/schema-merge-only.js +0 -55
@@ -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
- 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-[var(--color-text-secondary)] 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-[var(--color-text-secondary)] whitespace-pre">
58
+ {lines[vr.index]}
59
+ </span>
60
+ </div>
61
+ ))}
62
+ </div>
63
+ </div>
64
+ );
65
+ }
56
66
 
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;
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
- 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-[var(--color-text-secondary)] 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
- );
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
  }