@dyyz1993/create-agent 2.1.0 → 2.1.2
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 +5 -4
- package/src/__tests__/cli.test.ts +2 -0
- package/src/__tests__/copy.test.ts +110 -122
- package/src/__tests__/create-args.test.ts +113 -0
- package/src/__tests__/templates.test.ts +29 -3
- package/src/__tests__/update.test.ts +129 -0
- package/src/cli.ts +30 -32
- package/src/commands/create.ts +83 -24
- package/src/commands/update.ts +174 -0
- package/src/commands/workspace.ts +26 -6
- package/src/lib/copy.ts +233 -93
- package/src/lib/templates.ts +12 -0
- package/templates/agent/.husky/commit-msg +4 -0
- package/templates/agent/.husky/pre-commit +11 -0
- package/templates/agent/.husky/pre-push +6 -0
- package/templates/agent/.prettierignore +6 -0
- package/templates/agent/.prettierrc +9 -0
- package/templates/agent/CHANGELOG.md +15 -0
- package/templates/agent/commitlint.config.js +8 -0
- package/templates/agent/package.json +19 -4
- package/templates/agent/src/gateway/__tests__/ws-handler-token.test.ts +53 -39
- package/templates/agent/src/mainview/App.tsx +14 -12
- package/templates/agent/src/mainview/__tests__/hooks/use-rpc-init.test.ts +194 -190
- package/templates/agent/src/mainview/components/bash/BashPanel.tsx +210 -189
- package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +45 -20
- package/templates/agent/src/mainview/components/common/ThemeToggle.tsx +41 -21
- package/templates/agent/src/mainview/components/debug/DebugPanel.tsx +181 -114
- package/templates/agent/src/mainview/components/debug/__tests__/DebugPanel.test.tsx +80 -80
- package/templates/agent/src/mainview/components/diff/__tests__/DiffViewerPanel.test.tsx +61 -58
- package/templates/agent/src/mainview/components/feed/FeedPanel.tsx +43 -41
- package/templates/agent/src/mainview/components/file-preview/FilePreviewOverlay.tsx +69 -50
- package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +31 -18
- package/templates/agent/src/mainview/components/git/GitPanel.tsx +731 -490
- package/templates/agent/src/mainview/components/git/__tests__/GitPanel.test.tsx +157 -139
- package/templates/agent/src/mainview/components/layout/AppLayout.tsx +210 -161
- package/templates/agent/src/mainview/components/layout/__tests__/AppLayout.test.tsx +130 -122
- package/templates/agent/src/mainview/components/rules/RulesPanel.tsx +119 -109
- package/templates/agent/src/mainview/components/search/SearchPanel.tsx +123 -117
- package/templates/agent/src/mainview/components/search/__tests__/SearchPanel.test.tsx +64 -44
- package/templates/agent/src/mainview/components/sidebar/__tests__/PinButton.test.tsx +38 -38
- package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +40 -38
- package/templates/agent/src/mainview/components/todo/__tests__/TodoPanel.test.tsx +72 -72
- package/templates/agent/src/mainview/lib/i18n/locales/en.json +175 -155
- package/templates/agent/src/mainview/lib/i18n/locales/zh.json +173 -155
- package/templates/agent/src/mainview/stores/use-app-store.ts +96 -86
- package/templates/agent/src/mainview/stores/use-explorer-store.ts +292 -275
- package/templates/agent/src/mainview/types/index.ts +23 -22
- package/templates/agent/src/mainview/utils/file-icon.tsx +17 -21
- package/templates/agent/src/shared/handlers/chat.ts +53 -53
- package/templates/agent/src/shared/handlers/debug.ts +13 -3
- package/templates/browser-agent/.env.example +19 -0
- package/templates/browser-agent/.husky/commit-msg +4 -0
- package/templates/browser-agent/.husky/pre-commit +11 -0
- package/templates/browser-agent/.husky/pre-push +6 -0
- package/templates/browser-agent/.prettierignore +6 -0
- package/templates/browser-agent/.prettierrc +9 -0
- package/templates/browser-agent/AGENTS.md +396 -0
- package/templates/browser-agent/CHANGELOG.md +15 -0
- package/templates/browser-agent/LICENSE +21 -0
- package/templates/browser-agent/README.md +103 -0
- package/templates/browser-agent/commitlint.config.js +8 -0
- package/templates/browser-agent/electrobun.config.ts +27 -0
- package/templates/browser-agent/electron/main.js +46 -0
- package/templates/browser-agent/electron/preload.js +5 -0
- package/templates/browser-agent/electron-builder.json +40 -0
- package/templates/browser-agent/eslint.config.mjs +79 -0
- package/templates/browser-agent/llms.txt +24 -0
- package/templates/browser-agent/package.json +140 -0
- package/templates/browser-agent/postcss.config.js +6 -0
- package/templates/browser-agent/scripts/dev.ts +138 -0
- package/templates/browser-agent/src/__tests__/hybrid-mode.test.ts +126 -0
- package/templates/browser-agent/src/__tests__/server-config-security.test.ts +55 -0
- package/templates/browser-agent/src/__tests__/server-config.test.ts +59 -0
- package/templates/browser-agent/src/bun/index.ts +130 -0
- package/templates/browser-agent/src/bun/three.d.ts +1 -0
- package/templates/browser-agent/src/gateway/http-routes.ts +1 -0
- package/templates/browser-agent/src/gateway/ipc-transport.ts +68 -0
- package/templates/browser-agent/src/gateway/sse-transport.ts +221 -0
- package/templates/browser-agent/src/mainview/App.tsx +45 -0
- package/templates/browser-agent/src/mainview/__tests__/hooks/use-rpc-init.test.ts +202 -0
- package/templates/browser-agent/src/mainview/__tests__/hooks/use-sidebar-resize.test.ts +127 -0
- package/templates/browser-agent/src/mainview/__tests__/i18n/i18n.test.ts +49 -0
- package/templates/browser-agent/src/mainview/__tests__/setup.ts +40 -0
- package/templates/browser-agent/src/mainview/__tests__/stores/use-chat-store.test.ts +73 -0
- package/templates/browser-agent/src/mainview/__tests__/stores/use-sidebar-store.test.ts +61 -0
- package/templates/browser-agent/src/mainview/__tests__/theme-variables.test.ts +36 -0
- package/templates/browser-agent/src/mainview/components/assets/AssetsPanel.tsx +139 -0
- package/templates/browser-agent/src/mainview/components/chat/ChatPanel.tsx +219 -0
- package/templates/browser-agent/src/mainview/components/chat/CommandBar.tsx +184 -0
- package/templates/browser-agent/src/mainview/components/chat/MessageBubble.tsx +249 -0
- package/templates/browser-agent/src/mainview/components/chat/ToolPicker.tsx +115 -0
- package/templates/browser-agent/src/mainview/components/common/ErrorBoundary.tsx +1 -0
- package/templates/browser-agent/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
- package/templates/browser-agent/src/mainview/components/common/ThemeToggle.tsx +45 -0
- package/templates/browser-agent/src/mainview/components/common/__tests__/ErrorBoundary.test.tsx +74 -0
- package/templates/browser-agent/src/mainview/components/common/__tests__/LanguageSwitcher.test.tsx +44 -0
- package/templates/browser-agent/src/mainview/components/common/__tests__/ThemeToggle.test.tsx +41 -0
- package/templates/browser-agent/src/mainview/components/dev/NetworkPanel.tsx +155 -0
- package/templates/browser-agent/src/mainview/components/layout/AppLayout.tsx +311 -0
- package/templates/browser-agent/src/mainview/components/onboarding/SetupWizard.tsx +310 -0
- package/templates/browser-agent/src/mainview/components/process/ProcessPanel.tsx +329 -0
- package/templates/browser-agent/src/mainview/components/sidebar/SessionSidebar.tsx +122 -0
- package/templates/browser-agent/src/mainview/components/sidebar/SkillSidebar.tsx +115 -0
- package/templates/browser-agent/src/mainview/components/topbar/TopBar.tsx +350 -0
- package/templates/browser-agent/src/mainview/global.d.ts +13 -0
- package/templates/browser-agent/src/mainview/hooks/__tests__/use-breakpoint.test.ts +151 -0
- package/templates/browser-agent/src/mainview/hooks/use-agent-chat.ts +157 -0
- package/templates/browser-agent/src/mainview/hooks/use-breakpoint.ts +68 -0
- package/templates/browser-agent/src/mainview/hooks/use-rpc-init.ts +71 -0
- package/templates/browser-agent/src/mainview/hooks/use-sidebar-resize.ts +40 -0
- package/templates/browser-agent/src/mainview/index.css +71 -0
- package/templates/browser-agent/src/mainview/index.html +12 -0
- package/templates/browser-agent/src/mainview/lib/api-client.ts +397 -0
- package/templates/browser-agent/src/mainview/lib/i18n/index.ts +30 -0
- package/templates/browser-agent/src/mainview/lib/i18n/locales/en.json +130 -0
- package/templates/browser-agent/src/mainview/lib/i18n/locales/zh.json +128 -0
- package/templates/browser-agent/src/mainview/lib/network-bus.ts +92 -0
- package/templates/browser-agent/src/mainview/lib/rpc-cache.ts +94 -0
- package/templates/browser-agent/src/mainview/main.tsx +18 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-connection-store.test.ts +26 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-log-store.test.ts +28 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
- package/templates/browser-agent/src/mainview/stores/message-batcher.ts +25 -0
- package/templates/browser-agent/src/mainview/stores/use-asset-store.ts +65 -0
- package/templates/browser-agent/src/mainview/stores/use-chat-store.ts +200 -0
- package/templates/browser-agent/src/mainview/stores/use-connection-store.ts +173 -0
- package/templates/browser-agent/src/mainview/stores/use-locale-store.ts +27 -0
- package/templates/browser-agent/src/mainview/stores/use-log-store.ts +16 -0
- package/templates/browser-agent/src/mainview/stores/use-network-panel-store.ts +18 -0
- package/templates/browser-agent/src/mainview/stores/use-record-store.ts +147 -0
- package/templates/browser-agent/src/mainview/stores/use-session-store.ts +151 -0
- package/templates/browser-agent/src/mainview/stores/use-sidebar-store.ts +161 -0
- package/templates/browser-agent/src/mainview/stores/use-theme-store.ts +46 -0
- package/templates/browser-agent/src/mainview/stores/use-view-store.ts +20 -0
- package/templates/browser-agent/src/mainview/types/index.ts +6 -0
- package/templates/browser-agent/src/server-config.ts +45 -0
- package/templates/browser-agent/src/server.ts +78 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/chat-handler.test.ts +77 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/file-handler.test.ts +100 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/system-handler.test.ts +55 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/timer-handler.test.ts +77 -0
- package/templates/browser-agent/src/shared/handlers/browser.ts +596 -0
- package/templates/browser-agent/src/shared/handlers/chat.ts +213 -0
- package/templates/browser-agent/src/shared/handlers/file.ts +99 -0
- package/templates/browser-agent/src/shared/handlers/index.ts +7 -0
- package/templates/browser-agent/src/shared/handlers/session.ts +167 -0
- package/templates/browser-agent/src/shared/handlers/system.ts +27 -0
- package/templates/browser-agent/src/shared/handlers/timer.ts +34 -0
- package/templates/browser-agent/src/shared/http-routes.ts +437 -0
- package/templates/browser-agent/src/shared/lib/__tests__/logger.test.ts +92 -0
- package/templates/browser-agent/src/shared/lib/__tests__/path-security.test.ts +77 -0
- package/templates/browser-agent/src/shared/lib/__tests__/web-server.test.ts +203 -0
- package/templates/browser-agent/src/shared/lib/agent.ts +384 -0
- package/templates/browser-agent/src/shared/lib/cdp.ts +448 -0
- package/templates/browser-agent/src/shared/lib/generate.ts +111 -0
- package/templates/browser-agent/src/shared/lib/logger.ts +152 -0
- package/templates/browser-agent/src/shared/lib/mock-stream.ts +147 -0
- package/templates/browser-agent/src/shared/lib/path-security.ts +38 -0
- package/templates/browser-agent/src/shared/lib/port-registry.ts +103 -0
- package/templates/browser-agent/src/shared/lib/web-server.ts +127 -0
- package/templates/browser-agent/src/shared/lib/xhs-extract.ts +71 -0
- package/templates/browser-agent/src/shared/modules/browser.ts +86 -0
- package/templates/browser-agent/src/shared/modules/chat.ts +20 -0
- package/templates/browser-agent/src/shared/modules/file.ts +40 -0
- package/templates/browser-agent/src/shared/modules/session.ts +55 -0
- package/templates/browser-agent/src/shared/modules/system.ts +8 -0
- package/templates/browser-agent/src/shared/modules/timer.ts +11 -0
- package/templates/browser-agent/src/shared/register-all-handlers.ts +36 -0
- package/templates/browser-agent/src/shared/rpc-schema.ts +34 -0
- package/templates/browser-agent/tailwind.config.js +15 -0
- package/templates/browser-agent/tsconfig.ipc.json +14 -0
- package/templates/browser-agent/tsconfig.json +36 -0
- package/templates/browser-agent/vite.config.ts +3 -0
- package/templates/browser-agent/vitest.config.ts +3 -0
- package/templates/chat/.husky/commit-msg +4 -0
- package/templates/chat/.husky/pre-commit +11 -0
- package/templates/chat/.husky/pre-push +6 -0
- package/templates/chat/CHANGELOG.md +15 -0
- package/templates/chat/commitlint.config.js +8 -0
- package/templates/chat/package.json +19 -4
- package/templates/chat/src/mainview/__tests__/hooks/use-input-history.test.ts +125 -0
- package/templates/chat/src/mainview/__tests__/setup.ts +32 -29
- package/templates/chat/src/mainview/components/chat/ChatPanel.tsx +80 -55
- package/templates/chat/src/mainview/components/common/ThemeToggle.tsx +40 -20
- package/templates/chat/src/mainview/lib/i18n/locales/en.json +175 -155
- package/templates/chat/src/mainview/lib/i18n/locales/zh.json +173 -155
- package/templates/chat/src/shared/handlers/chat.ts +17 -19
- package/templates/chat/src/shared/handlers/debug.ts +12 -2
- package/templates/cowork/.env.example +8 -0
- package/templates/cowork/.prettierignore +6 -0
- package/templates/cowork/.prettierrc +9 -0
- package/templates/cowork/AGENTS.md +236 -0
- package/templates/cowork/CHANGELOG.md +15 -0
- package/templates/cowork/LICENSE +21 -0
- package/templates/cowork/README.md +103 -0
- package/templates/cowork/commitlint.config.js +8 -0
- package/templates/cowork/docs/CODE-VIEW-PLAN.md +637 -0
- package/templates/cowork/docs/CODE-VIEW-V2.md +196 -0
- package/templates/cowork/docs/CODE-VIEW-V4.md +150 -0
- package/templates/cowork/electrobun.config.ts +27 -0
- package/templates/cowork/eslint.config.mjs +79 -0
- package/templates/cowork/llms.txt +24 -0
- package/templates/cowork/package.json +87 -0
- package/templates/cowork/postcss.config.js +6 -0
- package/templates/cowork/scripts/dev.ts +138 -0
- package/templates/cowork/src/__tests__/hybrid-mode.test.ts +126 -0
- package/templates/cowork/src/__tests__/server-config-security.test.ts +55 -0
- package/templates/cowork/src/__tests__/server-config.test.ts +59 -0
- package/templates/cowork/src/bun/index.ts +130 -0
- package/templates/cowork/src/bun/three.d.ts +1 -0
- package/templates/cowork/src/gateway/http-routes.ts +1 -0
- package/templates/cowork/src/gateway/ipc-transport.ts +68 -0
- package/templates/cowork/src/gateway/sse-transport.ts +231 -0
- package/templates/cowork/src/mainview/App.tsx +45 -0
- package/templates/cowork/src/mainview/__tests__/hooks/use-rpc-init.test.ts +202 -0
- package/templates/cowork/src/mainview/__tests__/hooks/use-sidebar-resize.test.ts +127 -0
- package/templates/cowork/src/mainview/__tests__/i18n/i18n.test.ts +49 -0
- package/templates/cowork/src/mainview/__tests__/setup.ts +40 -0
- package/templates/cowork/src/mainview/__tests__/stores/use-chat-store.test.ts +73 -0
- package/templates/cowork/src/mainview/__tests__/stores/use-sidebar-store.test.ts +61 -0
- package/templates/cowork/src/mainview/__tests__/theme-variables.test.ts +36 -0
- package/templates/cowork/src/mainview/components/chat/TaskChat.tsx +311 -0
- package/templates/cowork/src/mainview/components/chat/__tests__/localhost-links.test.ts +76 -0
- package/templates/cowork/src/mainview/components/common/ErrorBoundary.tsx +1 -0
- package/templates/cowork/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
- package/templates/cowork/src/mainview/components/common/ThemeToggle.tsx +45 -0
- package/templates/cowork/src/mainview/components/common/__tests__/ErrorBoundary.test.tsx +74 -0
- package/templates/cowork/src/mainview/components/common/__tests__/LanguageSwitcher.test.tsx +44 -0
- package/templates/cowork/src/mainview/components/common/__tests__/ThemeToggle.test.tsx +41 -0
- package/templates/cowork/src/mainview/components/dev/NetworkPanel.tsx +155 -0
- package/templates/cowork/src/mainview/components/layout/AppLayout.tsx +216 -0
- package/templates/cowork/src/mainview/components/right/ArtifactsPanel.tsx +54 -0
- package/templates/cowork/src/mainview/components/right/ContextPanel.tsx +133 -0
- package/templates/cowork/src/mainview/components/right/ElementPicker.tsx +206 -0
- package/templates/cowork/src/mainview/components/right/PreviewBlock.tsx +155 -0
- package/templates/cowork/src/mainview/components/right/ProgressPanel.tsx +85 -0
- package/templates/cowork/src/mainview/components/sidebar/TaskSidebar.tsx +211 -0
- package/templates/cowork/src/mainview/components/topbar/TopBar.tsx +86 -0
- package/templates/cowork/src/mainview/global.d.ts +13 -0
- package/templates/cowork/src/mainview/hooks/__tests__/use-breakpoint.test.ts +123 -0
- package/templates/cowork/src/mainview/hooks/use-breakpoint.ts +53 -0
- package/templates/cowork/src/mainview/hooks/use-rpc-init.ts +26 -0
- package/templates/cowork/src/mainview/hooks/use-sidebar-resize.ts +40 -0
- package/templates/cowork/src/mainview/index.css +89 -0
- package/templates/cowork/src/mainview/index.html +12 -0
- package/templates/cowork/src/mainview/lib/api-client.ts +404 -0
- package/templates/cowork/src/mainview/lib/i18n/index.ts +30 -0
- package/templates/cowork/src/mainview/lib/i18n/locales/en.json +130 -0
- package/templates/cowork/src/mainview/lib/i18n/locales/zh.json +128 -0
- package/templates/cowork/src/mainview/lib/network-bus.ts +92 -0
- package/templates/cowork/src/mainview/lib/rpc-cache.ts +94 -0
- package/templates/cowork/src/mainview/main.tsx +18 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-connection-store.test.ts +26 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-log-store.test.ts +28 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-preview-store.test.ts +193 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-sidebar-store.test.ts +81 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
- package/templates/cowork/src/mainview/stores/message-batcher.ts +25 -0
- package/templates/cowork/src/mainview/stores/use-chat-store.ts +198 -0
- package/templates/cowork/src/mainview/stores/use-connection-store.ts +168 -0
- package/templates/cowork/src/mainview/stores/use-context-store.ts +68 -0
- package/templates/cowork/src/mainview/stores/use-locale-store.ts +27 -0
- package/templates/cowork/src/mainview/stores/use-log-store.ts +16 -0
- package/templates/cowork/src/mainview/stores/use-network-panel-store.ts +18 -0
- package/templates/cowork/src/mainview/stores/use-output-store.ts +47 -0
- package/templates/cowork/src/mainview/stores/use-preview-store.ts +97 -0
- package/templates/cowork/src/mainview/stores/use-sidebar-store.ts +272 -0
- package/templates/cowork/src/mainview/stores/use-task-store.ts +86 -0
- package/templates/cowork/src/mainview/stores/use-theme-store.ts +46 -0
- package/templates/cowork/src/mainview/stores/use-view-store.ts +29 -0
- package/templates/cowork/src/mainview/types/index.ts +6 -0
- package/templates/cowork/src/server-config.ts +44 -0
- package/templates/cowork/src/server.ts +78 -0
- package/templates/cowork/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
- package/templates/cowork/src/shared/handlers/__tests__/chat-handler.test.ts +77 -0
- package/templates/cowork/src/shared/handlers/__tests__/file-handler.test.ts +100 -0
- package/templates/cowork/src/shared/handlers/__tests__/preview-handler.test.ts +172 -0
- package/templates/cowork/src/shared/handlers/__tests__/system-handler.test.ts +55 -0
- package/templates/cowork/src/shared/handlers/__tests__/timer-handler.test.ts +77 -0
- package/templates/cowork/src/shared/handlers/chat.ts +213 -0
- package/templates/cowork/src/shared/handlers/context.ts +72 -0
- package/templates/cowork/src/shared/handlers/file.ts +99 -0
- package/templates/cowork/src/shared/handlers/index.ts +9 -0
- package/templates/cowork/src/shared/handlers/output.ts +59 -0
- package/templates/cowork/src/shared/handlers/preview.ts +81 -0
- package/templates/cowork/src/shared/handlers/system.ts +27 -0
- package/templates/cowork/src/shared/handlers/task.ts +101 -0
- package/templates/cowork/src/shared/handlers/timer.ts +34 -0
- package/templates/cowork/src/shared/http-routes.ts +444 -0
- package/templates/cowork/src/shared/lib/__tests__/logger.test.ts +92 -0
- package/templates/cowork/src/shared/lib/__tests__/path-security.test.ts +77 -0
- package/templates/cowork/src/shared/lib/__tests__/web-server.test.ts +203 -0
- package/templates/cowork/src/shared/lib/logger.ts +152 -0
- package/templates/cowork/src/shared/lib/path-security.ts +38 -0
- package/templates/cowork/src/shared/lib/port-registry.ts +103 -0
- package/templates/cowork/src/shared/lib/web-server.ts +127 -0
- package/templates/cowork/src/shared/modules/chat.ts +20 -0
- package/templates/cowork/src/shared/modules/context.ts +32 -0
- package/templates/cowork/src/shared/modules/file.ts +40 -0
- package/templates/cowork/src/shared/modules/output.ts +20 -0
- package/templates/cowork/src/shared/modules/preview.ts +44 -0
- package/templates/cowork/src/shared/modules/system.ts +8 -0
- package/templates/cowork/src/shared/modules/task.ts +31 -0
- package/templates/cowork/src/shared/modules/timer.ts +11 -0
- package/templates/cowork/src/shared/register-all-handlers.ts +36 -0
- package/templates/cowork/src/shared/rpc-schema.ts +38 -0
- package/templates/cowork/tailwind.config.js +15 -0
- package/templates/cowork/test-upload.txt +0 -0
- package/templates/cowork/tsconfig.ipc.json +14 -0
- package/templates/cowork/tsconfig.json +36 -0
- package/templates/cowork/vite.config.ts +3 -0
- package/templates/cowork/vitest.config.ts +3 -0
- package/templates/general/.husky/commit-msg +4 -0
- package/templates/general/.husky/pre-commit +11 -0
- package/templates/general/.husky/pre-push +6 -0
- package/templates/general/CHANGELOG.md +15 -0
- package/templates/general/commitlint.config.js +8 -0
- package/templates/general/package.json +19 -4
- package/templates/general/src/mainview/__tests__/hooks/use-input-history.test.ts +125 -0
- package/templates/general/src/mainview/__tests__/setup.ts +32 -29
- package/templates/general/src/mainview/components/chat/ChatPanel.tsx +80 -55
- package/templates/general/src/mainview/components/common/ThemeToggle.tsx +40 -20
- package/templates/general/src/mainview/components/debug/DebugPanel.tsx +170 -156
- package/templates/general/src/mainview/components/debug/__tests__/DebugPanel.test.tsx +169 -0
- package/templates/general/src/mainview/components/explorer/ConfirmDialog.tsx +42 -42
- package/templates/general/src/mainview/components/explorer/ContextMenu.tsx +72 -67
- package/templates/general/src/mainview/components/feed/FeedPanel.tsx +7 -5
- package/templates/general/src/mainview/components/file-preview/FilePreviewOverlay.tsx +64 -45
- package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +24 -7
- package/templates/general/src/mainview/components/git/GitPanel.tsx +700 -473
- package/templates/general/src/mainview/components/layout/AppLayout.tsx +123 -114
- package/templates/general/src/mainview/components/search/SearchPanel.tsx +15 -19
- package/templates/general/src/mainview/lib/i18n/locales/en.json +175 -155
- package/templates/general/src/mainview/lib/i18n/locales/zh.json +173 -155
- package/templates/general/src/mainview/stores/__tests__/use-explorer-store.test.ts +259 -0
- package/templates/general/src/mainview/stores/__tests__/use-feed-store.test.ts +160 -0
- package/templates/general/src/mainview/stores/__tests__/use-git-store.test.ts +313 -0
- package/templates/general/src/mainview/stores/__tests__/use-notification-store.test.ts +115 -0
- package/templates/general/src/mainview/stores/__tests__/use-sidebar-store.test.ts +120 -0
- package/templates/general/src/mainview/stores/use-explorer-store.ts +277 -260
- package/templates/general/src/mainview/types/index.ts +21 -20
- package/templates/general/src/shared/handlers/chat.ts +1 -1
- package/templates/general/src/shared/handlers/debug.ts +12 -2
- package/templates/shared/components/ErrorBoundary.tsx +0 -1
- package/templates/shared/vite-base.config.ts +8 -7
- /package/templates/{shared → browser-agent}/test-upload.txt +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"title": "Browser Agent",
|
|
4
|
+
"connecting": "Connecting to RPC server...",
|
|
5
|
+
"online": "Online",
|
|
6
|
+
"offline": "Offline",
|
|
7
|
+
"mode": {
|
|
8
|
+
"desktop": "Desktop (IPC)",
|
|
9
|
+
"web": "Web (WebSocket)"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"sidebar": {
|
|
13
|
+
"explorer": "Explorer",
|
|
14
|
+
"git": "Source Control",
|
|
15
|
+
"search": "Search"
|
|
16
|
+
},
|
|
17
|
+
"tabs": {
|
|
18
|
+
"chat": "Chat",
|
|
19
|
+
"debug": "Debug"
|
|
20
|
+
},
|
|
21
|
+
"chat": {
|
|
22
|
+
"title": "Agent Chat",
|
|
23
|
+
"placeholder": "Type your request...",
|
|
24
|
+
"send": "Send",
|
|
25
|
+
"empty": "Start a conversation...",
|
|
26
|
+
"welcome": "Start your first collection"
|
|
27
|
+
},
|
|
28
|
+
"session": {
|
|
29
|
+
"new": "New Session",
|
|
30
|
+
"history": "History"
|
|
31
|
+
},
|
|
32
|
+
"skills": {
|
|
33
|
+
"title": "Skills",
|
|
34
|
+
"xhsExplore": "Xiaohongshu Explore",
|
|
35
|
+
"xhsSearch": "Keyword Search",
|
|
36
|
+
"xhsBlogger": "Blogger Profile"
|
|
37
|
+
},
|
|
38
|
+
"explorer": {
|
|
39
|
+
"title": "Explorer",
|
|
40
|
+
"pathPlaceholder": "Path",
|
|
41
|
+
"refresh": "Refresh",
|
|
42
|
+
"listDirectory": "List directory",
|
|
43
|
+
"newFile": "New File",
|
|
44
|
+
"newFolder": "New Folder",
|
|
45
|
+
"rename": "Rename",
|
|
46
|
+
"delete": "Delete",
|
|
47
|
+
"copyPath": "Copy Path",
|
|
48
|
+
"confirmDelete": "Confirm Delete",
|
|
49
|
+
"confirmDeleteMessage": "Are you sure you want to delete \"{{name}}\"? This action cannot be undone.",
|
|
50
|
+
"emptyHint": "Enter path and click refresh"
|
|
51
|
+
},
|
|
52
|
+
"git": {
|
|
53
|
+
"title": "Source Control",
|
|
54
|
+
"staged": "Staged Changes",
|
|
55
|
+
"changes": "Changes",
|
|
56
|
+
"untracked": "Untracked",
|
|
57
|
+
"noChanges": "No changes detected",
|
|
58
|
+
"commits": "Commits",
|
|
59
|
+
"noCommits": "No commits",
|
|
60
|
+
"noFiles": "No files",
|
|
61
|
+
"loadingFiles": "Loading files...",
|
|
62
|
+
"commitPlaceholder": "Commit message (Ctrl+Enter to commit)",
|
|
63
|
+
"committing": "Committing...",
|
|
64
|
+
"commit": "Commit",
|
|
65
|
+
"openDiff": "Open Diff",
|
|
66
|
+
"openFile": "Open File",
|
|
67
|
+
"copyHash": "Copy Hash",
|
|
68
|
+
"copyMessage": "Copy Message",
|
|
69
|
+
"copyPath": "Copy Path",
|
|
70
|
+
"pull": "Pull",
|
|
71
|
+
"push": "Push",
|
|
72
|
+
"refresh": "Refresh",
|
|
73
|
+
"stage": "Stage",
|
|
74
|
+
"unstage": "Unstage",
|
|
75
|
+
"stageAll": "Stage all",
|
|
76
|
+
"unstageAll": "Unstage all",
|
|
77
|
+
"worktrees": "Worktrees",
|
|
78
|
+
"close": "Close",
|
|
79
|
+
"justNow": "just now",
|
|
80
|
+
"minutesAgo": "{{count}}m ago",
|
|
81
|
+
"hoursAgo": "{{count}}h ago",
|
|
82
|
+
"daysAgo": "{{count}}d ago"
|
|
83
|
+
},
|
|
84
|
+
"debug": {
|
|
85
|
+
"rpcCalls": "RPC Calls",
|
|
86
|
+
"call": "Call",
|
|
87
|
+
"subscriptions": "Subscriptions",
|
|
88
|
+
"subscribe": "Subscribe",
|
|
89
|
+
"unsubscribe": "Unsubscribe",
|
|
90
|
+
"events": "{{count}} events",
|
|
91
|
+
"noEvents": "No events yet",
|
|
92
|
+
"logs": "Logs",
|
|
93
|
+
"clear": "Clear",
|
|
94
|
+
"clearAll": "Clear all debug data",
|
|
95
|
+
"expandPanel": "Expand Debug Panel",
|
|
96
|
+
"collapsePanel": "Collapse Debug Panel"
|
|
97
|
+
},
|
|
98
|
+
"search": {
|
|
99
|
+
"noResults": "No results found",
|
|
100
|
+
"noResultsFor": "No results for \"{{query}}\"",
|
|
101
|
+
"resultsIn": "{{count}} result in {{fileCount}} file",
|
|
102
|
+
"resultsIn_plural": "{{count}} results in {{fileCount}} files",
|
|
103
|
+
"filesSearched": "({{count}} file searched)",
|
|
104
|
+
"filesSearched_plural": "({{count}} files searched)",
|
|
105
|
+
"typeToSearch": "Type a search term and press Enter",
|
|
106
|
+
"focusShortcut": "...{{key}}+F to focus search",
|
|
107
|
+
"tryDifferent": "Try different search terms"
|
|
108
|
+
},
|
|
109
|
+
"error": {
|
|
110
|
+
"title": "Something went wrong",
|
|
111
|
+
"unexpected": "An unexpected error occurred",
|
|
112
|
+
"retry": "Retry"
|
|
113
|
+
},
|
|
114
|
+
"theme": {
|
|
115
|
+
"light": "Light",
|
|
116
|
+
"dark": "Dark",
|
|
117
|
+
"toggle": "Toggle theme"
|
|
118
|
+
},
|
|
119
|
+
"locale": {
|
|
120
|
+
"en": "English",
|
|
121
|
+
"zh": "中文"
|
|
122
|
+
},
|
|
123
|
+
"common": {
|
|
124
|
+
"loading": "Loading...",
|
|
125
|
+
"cancel": "Cancel",
|
|
126
|
+
"confirm": "Confirm",
|
|
127
|
+
"save": "Save",
|
|
128
|
+
"delete": "Delete"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"title": "Browser Agent",
|
|
4
|
+
"connecting": "正在连接 RPC 服务器...",
|
|
5
|
+
"online": "在线",
|
|
6
|
+
"offline": "离线",
|
|
7
|
+
"mode": {
|
|
8
|
+
"desktop": "桌面 (IPC)",
|
|
9
|
+
"web": "Web (WebSocket)"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"sidebar": {
|
|
13
|
+
"explorer": "资源管理器",
|
|
14
|
+
"git": "源代码管理",
|
|
15
|
+
"search": "搜索"
|
|
16
|
+
},
|
|
17
|
+
"tabs": {
|
|
18
|
+
"chat": "聊天",
|
|
19
|
+
"debug": "调试"
|
|
20
|
+
},
|
|
21
|
+
"chat": {
|
|
22
|
+
"title": "Agent 对话",
|
|
23
|
+
"placeholder": "输入需求...",
|
|
24
|
+
"send": "发送",
|
|
25
|
+
"empty": "开始对话...",
|
|
26
|
+
"welcome": "开始你的第一次采集"
|
|
27
|
+
},
|
|
28
|
+
"session": {
|
|
29
|
+
"new": "新建会话",
|
|
30
|
+
"history": "历史会话"
|
|
31
|
+
},
|
|
32
|
+
"skills": {
|
|
33
|
+
"title": "技能库",
|
|
34
|
+
"xhsExplore": "小红书首页采集",
|
|
35
|
+
"xhsSearch": "关键词搜索采集",
|
|
36
|
+
"xhsBlogger": "博主主页采集"
|
|
37
|
+
},
|
|
38
|
+
"explorer": {
|
|
39
|
+
"title": "资源管理器",
|
|
40
|
+
"pathPlaceholder": "路径",
|
|
41
|
+
"refresh": "刷新",
|
|
42
|
+
"listDirectory": "列出目录",
|
|
43
|
+
"newFile": "新建文件",
|
|
44
|
+
"newFolder": "新建文件夹",
|
|
45
|
+
"rename": "重命名",
|
|
46
|
+
"delete": "删除",
|
|
47
|
+
"copyPath": "复制路径",
|
|
48
|
+
"confirmDelete": "确认删除",
|
|
49
|
+
"confirmDeleteMessage": "确定要删除 \"{{name}}\" 吗?此操作无法撤销。",
|
|
50
|
+
"emptyHint": "输入路径并点击刷新"
|
|
51
|
+
},
|
|
52
|
+
"git": {
|
|
53
|
+
"title": "源代码管理",
|
|
54
|
+
"staged": "已暂存更改",
|
|
55
|
+
"changes": "更改",
|
|
56
|
+
"untracked": "未跟踪",
|
|
57
|
+
"noChanges": "未检测到更改",
|
|
58
|
+
"commits": "提交记录",
|
|
59
|
+
"noCommits": "暂无提交",
|
|
60
|
+
"noFiles": "暂无文件",
|
|
61
|
+
"loadingFiles": "加载文件中...",
|
|
62
|
+
"commitPlaceholder": "提交信息 (Ctrl+Enter 提交)",
|
|
63
|
+
"committing": "提交中...",
|
|
64
|
+
"commit": "提交",
|
|
65
|
+
"openDiff": "打开差异",
|
|
66
|
+
"openFile": "打开文件",
|
|
67
|
+
"copyHash": "复制哈希",
|
|
68
|
+
"copyMessage": "复制信息",
|
|
69
|
+
"copyPath": "复制路径",
|
|
70
|
+
"pull": "拉取",
|
|
71
|
+
"push": "推送",
|
|
72
|
+
"refresh": "刷新",
|
|
73
|
+
"stage": "暂存",
|
|
74
|
+
"unstage": "取消暂存",
|
|
75
|
+
"stageAll": "全部暂存",
|
|
76
|
+
"unstageAll": "全部取消暂存",
|
|
77
|
+
"worktrees": "工作树",
|
|
78
|
+
"close": "关闭",
|
|
79
|
+
"justNow": "刚刚",
|
|
80
|
+
"minutesAgo": "{{count}}分钟前",
|
|
81
|
+
"hoursAgo": "{{count}}小时前",
|
|
82
|
+
"daysAgo": "{{count}}天前"
|
|
83
|
+
},
|
|
84
|
+
"debug": {
|
|
85
|
+
"rpcCalls": "RPC 调用",
|
|
86
|
+
"call": "调用",
|
|
87
|
+
"subscriptions": "订阅",
|
|
88
|
+
"subscribe": "订阅",
|
|
89
|
+
"unsubscribe": "取消订阅",
|
|
90
|
+
"events": "{{count}} 个事件",
|
|
91
|
+
"noEvents": "暂无事件",
|
|
92
|
+
"logs": "日志",
|
|
93
|
+
"clear": "清空",
|
|
94
|
+
"clearAll": "清空所有调试数据",
|
|
95
|
+
"expandPanel": "展开调试面板",
|
|
96
|
+
"collapsePanel": "折叠调试面板"
|
|
97
|
+
},
|
|
98
|
+
"search": {
|
|
99
|
+
"noResults": "未找到结果",
|
|
100
|
+
"noResultsFor": "未找到 \"{{query}}\" 的结果",
|
|
101
|
+
"resultsIn": "{{count}} 个结果在 {{fileCount}} 个文件中",
|
|
102
|
+
"filesSearched": "(已搜索 {{count}} 个文件)",
|
|
103
|
+
"typeToSearch": "输入搜索词并按回车",
|
|
104
|
+
"focusShortcut": "...{{key}}+F 聚焦搜索",
|
|
105
|
+
"tryDifferent": "尝试不同的搜索词"
|
|
106
|
+
},
|
|
107
|
+
"error": {
|
|
108
|
+
"title": "出了点问题",
|
|
109
|
+
"unexpected": "发生了意外错误",
|
|
110
|
+
"retry": "重试"
|
|
111
|
+
},
|
|
112
|
+
"theme": {
|
|
113
|
+
"light": "浅色",
|
|
114
|
+
"dark": "深色",
|
|
115
|
+
"toggle": "切换主题"
|
|
116
|
+
},
|
|
117
|
+
"locale": {
|
|
118
|
+
"en": "English",
|
|
119
|
+
"zh": "中文"
|
|
120
|
+
},
|
|
121
|
+
"common": {
|
|
122
|
+
"loading": "加载中...",
|
|
123
|
+
"cancel": "取消",
|
|
124
|
+
"confirm": "确认",
|
|
125
|
+
"save": "保存",
|
|
126
|
+
"delete": "删除"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Bus — lightweight event emitter for RPC/SSE communication logging.
|
|
3
|
+
*
|
|
4
|
+
* The api-client emits events here on every request/response/SSE-event.
|
|
5
|
+
* The NetworkPanel subscribes to render a live activity feed, giving the
|
|
6
|
+
* user visibility into the transport layer (solving the "I can't see any
|
|
7
|
+
* RPC activity" problem with the old silent WebSocket transport).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface NetworkLogEntry {
|
|
11
|
+
id: string;
|
|
12
|
+
time: number;
|
|
13
|
+
kind: "request" | "response" | "event" | "status";
|
|
14
|
+
label: string;
|
|
15
|
+
detail?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type NetworkListener = (entry: NetworkLogEntry) => void;
|
|
19
|
+
|
|
20
|
+
class NetworkBus {
|
|
21
|
+
private listeners = new Set<NetworkListener>();
|
|
22
|
+
private entries: NetworkLogEntry[] = [];
|
|
23
|
+
private maxEntries = 200;
|
|
24
|
+
private counter = 0;
|
|
25
|
+
|
|
26
|
+
subscribe(listener: NetworkListener): () => void {
|
|
27
|
+
this.listeners.add(listener);
|
|
28
|
+
return () => {
|
|
29
|
+
this.listeners.delete(listener);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getEntries(): NetworkLogEntry[] {
|
|
34
|
+
return [...this.entries];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private emit(entry: Omit<NetworkLogEntry, "id" | "time">): void {
|
|
38
|
+
const full: NetworkLogEntry = {
|
|
39
|
+
...entry,
|
|
40
|
+
id: `net_${++this.counter}`,
|
|
41
|
+
time: Date.now(),
|
|
42
|
+
};
|
|
43
|
+
this.entries.push(full);
|
|
44
|
+
if (this.entries.length > this.maxEntries) {
|
|
45
|
+
this.entries.shift();
|
|
46
|
+
}
|
|
47
|
+
for (const listener of [...this.listeners]) {
|
|
48
|
+
listener(full);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
emitRequest(method: string, params: unknown): void {
|
|
53
|
+
const paramSummary = this.summarize(params);
|
|
54
|
+
this.emit({
|
|
55
|
+
kind: "request",
|
|
56
|
+
label: `POST /api/rpc → ${method}`,
|
|
57
|
+
detail: paramSummary,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
emitResponse(method: string, elapsedMs: number): void {
|
|
62
|
+
this.emit({
|
|
63
|
+
kind: "response",
|
|
64
|
+
label: `← ${method}`,
|
|
65
|
+
detail: `${elapsedMs}ms`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
emitEvent(eventType: string, metadata?: Record<string, unknown>): void {
|
|
70
|
+
this.emit({
|
|
71
|
+
kind: "event",
|
|
72
|
+
label: `← SSE ${eventType}`,
|
|
73
|
+
detail: metadata ? JSON.stringify(metadata) : undefined,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
emitStatus(message: string): void {
|
|
78
|
+
this.emit({
|
|
79
|
+
kind: "status",
|
|
80
|
+
label: message,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private summarize(value: unknown): string {
|
|
85
|
+
if (value === null || value === undefined) return "";
|
|
86
|
+
const str = JSON.stringify(value);
|
|
87
|
+
if (!str) return "";
|
|
88
|
+
return str.length > 120 ? str.slice(0, 117) + "..." : str;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const networkBus = new NetworkBus();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
interface CacheEntry<T> {
|
|
2
|
+
data: T;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
class RpcCache {
|
|
7
|
+
private cache = new Map<string, CacheEntry<unknown>>();
|
|
8
|
+
private defaultTTL: number;
|
|
9
|
+
private pruneTimer: ReturnType<typeof setInterval> | null = null;
|
|
10
|
+
|
|
11
|
+
constructor(defaultTTL = 2000) {
|
|
12
|
+
this.defaultTTL = defaultTTL;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private key(method: string, params: unknown): string {
|
|
16
|
+
return `${method}:${JSON.stringify(params)}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get<T>(method: string, params: unknown, ttl?: number): T | null {
|
|
20
|
+
const k = this.key(method, params);
|
|
21
|
+
const entry = this.cache.get(k);
|
|
22
|
+
if (!entry) return null;
|
|
23
|
+
|
|
24
|
+
const effectiveTTL = ttl ?? this.defaultTTL;
|
|
25
|
+
if (Date.now() - entry.timestamp > effectiveTTL) {
|
|
26
|
+
this.cache.delete(k);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return entry.data as T;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
set<T>(method: string, params: unknown, data: T): void {
|
|
34
|
+
const k = this.key(method, params);
|
|
35
|
+
this.cache.set(k, { data, timestamp: Date.now() });
|
|
36
|
+
if (!this.pruneTimer) this.startPruneTimer();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
invalidate(method: string): void {
|
|
40
|
+
const prefix = `${method}:`;
|
|
41
|
+
for (const key of this.cache.keys()) {
|
|
42
|
+
if (key.startsWith(prefix)) {
|
|
43
|
+
this.cache.delete(key);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
invalidateAll(methods: string[]): void {
|
|
49
|
+
for (const m of methods) {
|
|
50
|
+
this.invalidate(m);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
clear(): void {
|
|
55
|
+
this.cache.clear();
|
|
56
|
+
if (this.pruneTimer) {
|
|
57
|
+
clearInterval(this.pruneTimer);
|
|
58
|
+
this.pruneTimer = null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
prune(): void {
|
|
63
|
+
const threshold = this.defaultTTL * 10;
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
for (const [key, entry] of this.cache) {
|
|
66
|
+
if (now - entry.timestamp > threshold) {
|
|
67
|
+
this.cache.delete(key);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (this.cache.size === 0 && this.pruneTimer) {
|
|
71
|
+
clearInterval(this.pruneTimer);
|
|
72
|
+
this.pruneTimer = null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private startPruneTimer(): void {
|
|
77
|
+
if (this.pruneTimer) return;
|
|
78
|
+
this.pruneTimer = setInterval(() => this.prune(), this.defaultTTL * 5);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const CACHEABLE_METHODS: Record<string, number> = {
|
|
83
|
+
"file.listDir": 2000,
|
|
84
|
+
"file.readFile": 3000,
|
|
85
|
+
"git.status": 2000,
|
|
86
|
+
"git.branches": 5000,
|
|
87
|
+
"git.log": 3000,
|
|
88
|
+
"git.diff": 3000,
|
|
89
|
+
"git.commitFiles": 3000,
|
|
90
|
+
"git.commitFileDiff": 3000,
|
|
91
|
+
"git.worktreeList": 5000,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const rpcCache = new RpcCache(2000);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./lib/i18n";
|
|
2
|
+
import { StrictMode } from "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { apiClient } from "./lib/api-client";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
import App from "./App";
|
|
7
|
+
|
|
8
|
+
const isElectrobun = typeof window !== "undefined" && !!window.__electrobunBunBridge;
|
|
9
|
+
|
|
10
|
+
if (isElectrobun) {
|
|
11
|
+
apiClient.initSyncForDesktop();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
createRoot(document.getElementById("root")!).render(
|
|
15
|
+
<StrictMode>
|
|
16
|
+
<App />
|
|
17
|
+
</StrictMode>
|
|
18
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("useConnectionStore", () => {
|
|
4
|
+
beforeEach(async () => {
|
|
5
|
+
vi.resetModules();
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("should have initial state", async () => {
|
|
9
|
+
const { useConnectionStore } = await import("../use-connection-store");
|
|
10
|
+
const state = useConnectionStore.getState();
|
|
11
|
+
expect(state.mode).toBe("web");
|
|
12
|
+
expect(state.ready).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should set ready state", async () => {
|
|
16
|
+
const { useConnectionStore } = await import("../use-connection-store");
|
|
17
|
+
useConnectionStore.getState().setReady(true);
|
|
18
|
+
expect(useConnectionStore.getState().ready).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should set mode", async () => {
|
|
22
|
+
const { useConnectionStore } = await import("../use-connection-store");
|
|
23
|
+
useConnectionStore.getState().setMode("desktop");
|
|
24
|
+
expect(useConnectionStore.getState().mode).toBe("desktop");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("useLocaleStore", () => {
|
|
4
|
+
beforeEach(async () => {
|
|
5
|
+
vi.resetModules();
|
|
6
|
+
localStorage.clear();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should default to English", async () => {
|
|
10
|
+
const { useLocaleStore } = await import("../use-locale-store");
|
|
11
|
+
expect(useLocaleStore.getState().locale).toBe("en");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should change locale", async () => {
|
|
15
|
+
const { useLocaleStore } = await import("../use-locale-store");
|
|
16
|
+
useLocaleStore.getState().setLocale("zh");
|
|
17
|
+
expect(useLocaleStore.getState().locale).toBe("zh");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should persist locale to localStorage", async () => {
|
|
21
|
+
const { useLocaleStore } = await import("../use-locale-store");
|
|
22
|
+
useLocaleStore.getState().setLocale("zh");
|
|
23
|
+
expect(localStorage.getItem("locale")).toBe("zh");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should restore locale from localStorage", async () => {
|
|
27
|
+
localStorage.setItem("locale", "zh");
|
|
28
|
+
vi.resetModules();
|
|
29
|
+
const { useLocaleStore } = await import("../use-locale-store");
|
|
30
|
+
expect(useLocaleStore.getState().locale).toBe("zh");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("useLogStore", () => {
|
|
4
|
+
beforeEach(async () => {
|
|
5
|
+
vi.resetModules();
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("should start with empty logs", async () => {
|
|
9
|
+
const { useLogStore } = await import("../use-log-store");
|
|
10
|
+
expect(useLogStore.getState().logs).toEqual([]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should add log entries", async () => {
|
|
14
|
+
const { useLogStore } = await import("../use-log-store");
|
|
15
|
+
useLogStore.getState().addLog("test message");
|
|
16
|
+
const logs = useLogStore.getState().logs;
|
|
17
|
+
expect(logs).toHaveLength(1);
|
|
18
|
+
expect(logs[0]).toContain("test message");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should limit log entries", async () => {
|
|
22
|
+
const { useLogStore } = await import("../use-log-store");
|
|
23
|
+
for (let i = 0; i < 200; i++) {
|
|
24
|
+
useLogStore.getState().addLog(`log ${i}`);
|
|
25
|
+
}
|
|
26
|
+
expect(useLogStore.getState().logs.length).toBeLessThanOrEqual(100);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("useThemeStore", () => {
|
|
4
|
+
beforeEach(async () => {
|
|
5
|
+
vi.resetModules();
|
|
6
|
+
localStorage.clear();
|
|
7
|
+
document.documentElement.classList.remove("dark");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should default to dark theme", async () => {
|
|
11
|
+
const { useThemeStore } = await import("../use-theme-store");
|
|
12
|
+
const state = useThemeStore.getState();
|
|
13
|
+
expect(state.theme).toBe("dark");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should toggle between light and dark", async () => {
|
|
17
|
+
const { useThemeStore } = await import("../use-theme-store");
|
|
18
|
+
const store = useThemeStore.getState();
|
|
19
|
+
|
|
20
|
+
expect(store.theme).toBe("dark");
|
|
21
|
+
store.toggleTheme();
|
|
22
|
+
expect(useThemeStore.getState().theme).toBe("light");
|
|
23
|
+
|
|
24
|
+
useThemeStore.getState().toggleTheme();
|
|
25
|
+
expect(useThemeStore.getState().theme).toBe("dark");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should set theme explicitly", async () => {
|
|
29
|
+
const { useThemeStore } = await import("../use-theme-store");
|
|
30
|
+
useThemeStore.getState().setTheme("light");
|
|
31
|
+
expect(useThemeStore.getState().theme).toBe("light");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should persist theme to localStorage", async () => {
|
|
35
|
+
const { useThemeStore } = await import("../use-theme-store");
|
|
36
|
+
useThemeStore.getState().setTheme("light");
|
|
37
|
+
|
|
38
|
+
expect(localStorage.getItem("theme")).toBe("light");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should restore theme from localStorage", async () => {
|
|
42
|
+
localStorage.setItem("theme", "light");
|
|
43
|
+
|
|
44
|
+
vi.resetModules();
|
|
45
|
+
const { useThemeStore } = await import("../use-theme-store");
|
|
46
|
+
|
|
47
|
+
expect(useThemeStore.getState().theme).toBe("light");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should apply dark class to document element", async () => {
|
|
51
|
+
const { useThemeStore } = await import("../use-theme-store");
|
|
52
|
+
useThemeStore.getState().setTheme("dark");
|
|
53
|
+
|
|
54
|
+
expect(document.documentElement.classList.contains("dark")).toBe(true);
|
|
55
|
+
|
|
56
|
+
useThemeStore.getState().setTheme("light");
|
|
57
|
+
expect(document.documentElement.classList.contains("dark")).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type Update = { sessionId: string; apply: () => void };
|
|
2
|
+
|
|
3
|
+
let queue: Update[] = [];
|
|
4
|
+
let rafId: number | null = null;
|
|
5
|
+
|
|
6
|
+
function flush() {
|
|
7
|
+
rafId = null;
|
|
8
|
+
const batch = queue;
|
|
9
|
+
queue = [];
|
|
10
|
+
for (const u of batch) u.apply();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function batchMessageUpdate(sessionId: string, apply: () => void) {
|
|
14
|
+
queue.push({ sessionId, apply });
|
|
15
|
+
if (!rafId) {
|
|
16
|
+
rafId = requestAnimationFrame(flush);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function flushNow() {
|
|
21
|
+
if (rafId) {
|
|
22
|
+
cancelAnimationFrame(rafId);
|
|
23
|
+
flush();
|
|
24
|
+
}
|
|
25
|
+
}
|