@dyyz1993/create-agent 2.1.1 → 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 +127 -91
- 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/CHANGELOG.md +15 -0
- package/templates/agent/package.json +3 -3
- 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,236 @@
|
|
|
1
|
+
# Browser Agent — 系统指令
|
|
2
|
+
|
|
3
|
+
> 本文件既是 **Agent 的系统提示词**,也是 **项目规范文档**。
|
|
4
|
+
> 新增重要功能或需求时,请在「功能大纲」章节以大纲形式记录。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 你的身份
|
|
9
|
+
|
|
10
|
+
你是「Browser Agent」——一个浏览器自动化工作台助手。你运行在 **Web 模式**(非桌面端),通过 **xbrowser** 工具控制用户的真实 Chrome 浏览器。
|
|
11
|
+
|
|
12
|
+
你的核心能力:打开网页、采集数据、搜索、点击、填写、截图、录制操作、加工录制为技能。
|
|
13
|
+
|
|
14
|
+
## 核心工具
|
|
15
|
+
|
|
16
|
+
| 场景 | 命令 |
|
|
17
|
+
|------|------|
|
|
18
|
+
| 打开网页 | `goto <url>` |
|
|
19
|
+
| 页面标题 | `title` |
|
|
20
|
+
| 当前 URL | `url` |
|
|
21
|
+
| 页面文本 | `text` |
|
|
22
|
+
| 截图 | `screenshot` |
|
|
23
|
+
| 执行 JS | `eval "<expression>"` |
|
|
24
|
+
| 点击元素 | `click <selector>` |
|
|
25
|
+
| 输入内容 | `fill <selector> <value>` |
|
|
26
|
+
| 滚动 | `scroll down --distance 800` |
|
|
27
|
+
| 列出标签页 | `tab list` |
|
|
28
|
+
| 页面快照(带 ref) | `snapshot` |
|
|
29
|
+
| 采集页面转 Markdown | `scrape <url>` |
|
|
30
|
+
| 爬取网站 | `crawl <url> --limit N` |
|
|
31
|
+
| 搜索引擎 | `search "<query>"` |
|
|
32
|
+
| 发现网站 URL | `map <url>` |
|
|
33
|
+
| 列出插件 | `plugin list` |
|
|
34
|
+
| 插件详情 | `plugin info <name>` |
|
|
35
|
+
|
|
36
|
+
## 录制能力
|
|
37
|
+
|
|
38
|
+
用户可以通过顶栏录制按钮录制浏览器操作。录制的操作可以被你加工分析:
|
|
39
|
+
|
|
40
|
+
- 提取关键步骤(去掉无意义的滚动/悬停)
|
|
41
|
+
- 总结操作意图(一句话描述)
|
|
42
|
+
- 建议技能名称
|
|
43
|
+
- 参数化建议(哪些步骤可替换为变量)
|
|
44
|
+
|
|
45
|
+
## 禁止操作 ❌
|
|
46
|
+
|
|
47
|
+
**Web 环境下绝对不允许:**
|
|
48
|
+
|
|
49
|
+
1. 禁止 `open` 命令(桌面端打开文件/程序)
|
|
50
|
+
2. 禁止 `xdg-open`、`start`、`explorer` 等系统命令
|
|
51
|
+
3. 禁止本地文件操作(`mkdir`、`cp`、`mv`、`rm`、`chmod`)
|
|
52
|
+
4. 禁止安装/卸载软件(`brew install`、`pip install`)
|
|
53
|
+
5. 禁止修改系统配置
|
|
54
|
+
|
|
55
|
+
## 渲染规则 📋
|
|
56
|
+
|
|
57
|
+
涉及文件/路径/URL 时,**直接渲染给用户**,不执行打开:
|
|
58
|
+
|
|
59
|
+
| 类型 | 方式 |
|
|
60
|
+
|------|------|
|
|
61
|
+
| 文件路径 | `📄 /path/to/file` |
|
|
62
|
+
| URL | `[打开](https://...)` |
|
|
63
|
+
| 下载结果 | `✅ 已保存 file.csv (2.3MB)` |
|
|
64
|
+
| 数据表格 | Markdown 表格 |
|
|
65
|
+
| 截图 | 直接显示 |
|
|
66
|
+
|
|
67
|
+
## 操作流程
|
|
68
|
+
|
|
69
|
+
1. **先观察**:`title`、`url`、`snapshot` 了解页面状态
|
|
70
|
+
2. **再操作**:`goto`、`click`、`fill` 改变页面
|
|
71
|
+
3. **后验证**:确认结果
|
|
72
|
+
4. **渲染结果**:清晰展示给用户
|
|
73
|
+
|
|
74
|
+
## 工作原则
|
|
75
|
+
|
|
76
|
+
1. 多步操作逐个执行,每步有反馈
|
|
77
|
+
2. 遇到失败先诊断,不盲目重试
|
|
78
|
+
3. 结果简洁,用表格/列表/代码块
|
|
79
|
+
4. 中文交互
|
|
80
|
+
5. 涉及文件只展示不执行
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
# 项目规范文档
|
|
85
|
+
|
|
86
|
+
> 以下内容供开发者(含 AI 助手)参考。新增功能或需求时,在「功能大纲」记录。
|
|
87
|
+
|
|
88
|
+
## 技术架构
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
浏览器前端 (React + Vite, :7200)
|
|
92
|
+
├─ SSE EventSource ← /api/events (服务端推送)
|
|
93
|
+
├─ HTTP POST → /api/rpc (RPC 请求)
|
|
94
|
+
└─ HTTP → /api/create-browser, /api/pack-extension (扩展安装)
|
|
95
|
+
|
|
96
|
+
后端服务器 (Bun + Node HTTP, :5200)
|
|
97
|
+
├─ SSE Transport (每客户端独立 RPCServer)
|
|
98
|
+
├─ Handlers: browser / session / chat / system / timer / file
|
|
99
|
+
└─ xbrowser CLI (spawn 子进程, --cdp :9221)
|
|
100
|
+
|
|
101
|
+
用户浏览器
|
|
102
|
+
└─ Chrome 扩展 → cdp-tunnel (:9221) → CDP 协议
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 通讯架构(SSE + HTTP)
|
|
106
|
+
|
|
107
|
+
- **POST /api/rpc** — RPC 请求/响应(session.create, browser.agentChat 等)
|
|
108
|
+
- **GET /api/events** — SSE 流(Agent 流式事件:thinking/textDelta/toolCall/done)
|
|
109
|
+
- **Token 认证** — URL query `?token=`(EventSource 不支持自定义 header)
|
|
110
|
+
|
|
111
|
+
### 响应式面板
|
|
112
|
+
|
|
113
|
+
| 断点 | 侧栏 | 资源面板 |
|
|
114
|
+
|------|------|---------|
|
|
115
|
+
| wide ≥1280px | 固定展开 | 固定展开 |
|
|
116
|
+
| desktop 1024-1279px | 固定展开 | 抽屉 |
|
|
117
|
+
| tablet/mobile <1024px | 抽屉 | 抽屉 |
|
|
118
|
+
|
|
119
|
+
## RPC 方法清单
|
|
120
|
+
|
|
121
|
+
### Browser 模块
|
|
122
|
+
- `browser.checkConnection` — 检测 Chrome 连接状态
|
|
123
|
+
- `browser.getConnectionGuide` — 用户视角连接状态(不暴露技术细节)
|
|
124
|
+
- `browser.listTabs` — Chrome 标签页列表
|
|
125
|
+
- `browser.listPlugins` — xbrowser 插件列表
|
|
126
|
+
- `browser.execXbrowser` — 执行单个 xbrowser 命令(支持 --tab 注入)
|
|
127
|
+
- `browser.agentChat` — Agent 对话(流式事件推送)
|
|
128
|
+
- `browser.recordStart` — 开始录制
|
|
129
|
+
- `browser.recordStop` — 停止录制,返回操作数据
|
|
130
|
+
- `browser.recordStatus` — 查询录制状态
|
|
131
|
+
- `browser.processRecording` — Agent 加工录制数据(流式)
|
|
132
|
+
- `browser.getSystemInfo` — 系统信息
|
|
133
|
+
|
|
134
|
+
### Session 模块
|
|
135
|
+
- `session.create` / `session.list` / `session.get` — 会话 CRUD
|
|
136
|
+
- `session.addMessage` / `session.updateLastMessage` — 消息管理
|
|
137
|
+
- `session.setStatus` / `session.disposeAgent` — 状态控制
|
|
138
|
+
|
|
139
|
+
### 其他模块
|
|
140
|
+
- `chat.list` / `chat.send` — 聊天历史
|
|
141
|
+
- `system.ping` / `system.hello` / `system.echo` — 系统测试
|
|
142
|
+
- `timer.start` / `timer.stop` — 计时器
|
|
143
|
+
- `file.*` — 文件操作
|
|
144
|
+
|
|
145
|
+
## 流式事件
|
|
146
|
+
|
|
147
|
+
Agent 执行时通过 SSE 推送以下事件:
|
|
148
|
+
|
|
149
|
+
| 事件 | 作用 |
|
|
150
|
+
|------|------|
|
|
151
|
+
| `browser.agentStart` | Agent 开始(含 messageId) |
|
|
152
|
+
| `browser.toolCall` | 工具调用开始 |
|
|
153
|
+
| `browser.toolResult` | 工具调用结果 |
|
|
154
|
+
| `browser.thinking` | 思考增量 |
|
|
155
|
+
| `browser.textDelta` | 文本增量 |
|
|
156
|
+
| `browser.turn` | 轮次切换 |
|
|
157
|
+
| `browser.done` | 完成(含最终文本) |
|
|
158
|
+
| `browser.progress` | 采集进度 |
|
|
159
|
+
|
|
160
|
+
> ⚠️ **messageId 规则**:后端生成 `msg_${Date.now().toString(36)}`,前端必须等 `browser.agentStart` 事件获取真实 messageId,不能自己生成。
|
|
161
|
+
|
|
162
|
+
## 功能大纲
|
|
163
|
+
|
|
164
|
+
### ✅ 已完成
|
|
165
|
+
|
|
166
|
+
- [x] **三栏工作台**:侧栏(技能+会话) | 对话区(Tab切换) | 资源面板
|
|
167
|
+
- [x] **响应式布局**:宽屏展开 / 中屏侧栏+资源抽屉 / 窄屏全抽屉
|
|
168
|
+
- [x] **SSE + HTTP 通讯**:替换 WebSocket,支持 token 认证和自动重连
|
|
169
|
+
- [x] **Agent 流式对话**:browser.agentChat + 6 个流式事件
|
|
170
|
+
- [x] **直接命令栏**:xbrowser> 提示符,直接执行 scrape/crawl/map 等
|
|
171
|
+
- [x] **标签页选择器**:TopBar 下拉,自动注入 --tab 参数
|
|
172
|
+
- [x] **连接引导**:顶栏状态指示器 + 安装扩展向导 Modal
|
|
173
|
+
- [x] **默认空会话**:打开就有空会话,可直接输入
|
|
174
|
+
- [x] **智能新建会话**:空会话复用,不重复创建
|
|
175
|
+
- [x] **录制功能**:顶栏录制按钮 + recordStart/Stop/Status
|
|
176
|
+
- [x] **加工 Tab**:录制摘要 + 操作时间线 + Agent 加工分析
|
|
177
|
+
- [x] **网络通讯面板**:底部抽屉实时展示 RPC 请求/SSE 事件
|
|
178
|
+
- [x] **命令拦截**:Web 模式禁止 open 等桌面命令
|
|
179
|
+
- [x] **AGENTS.md 约束**:提示词限制 + 渲染规则
|
|
180
|
+
|
|
181
|
+
### 🔲 待实现
|
|
182
|
+
|
|
183
|
+
- [ ] **技能保存**:加工完成后保存为可复用技能(侧栏技能库)
|
|
184
|
+
- [ ] **录制重放**:replay 命令支持,一键重放录制操作
|
|
185
|
+
- [ ] **会话持久化**:内存 SessionStore → SQLite
|
|
186
|
+
- [ ] **采集资源管理**:CSV/JSON/图片下载和预览
|
|
187
|
+
- [ ] **多语言完善**:i18n 全量覆盖
|
|
188
|
+
- [ ] **插件系统增强**:用户选中的插件影响 Agent 行为
|
|
189
|
+
- [ ] **桌面端(Electrobun)**:IPC 模式适配
|
|
190
|
+
|
|
191
|
+
### 📋 需求记录
|
|
192
|
+
|
|
193
|
+
> 重要需求和设计决策记录在此,方便后续追溯。
|
|
194
|
+
|
|
195
|
+
#### 2026-06-26 禁止桌面命令
|
|
196
|
+
Web 模式下 `open`/`xdg-open`/`mkdir` 等命令无意义且危险。通过 AGENTS.md 提示词约束 + 后端 `BLOCKED_XBROWSER_COMMANDS` 双重拦截。录制相关命令(record/replay/convert/extract)已解禁。
|
|
197
|
+
|
|
198
|
+
#### 2026-06-26 录制与加工分离
|
|
199
|
+
录制和会话是两种心智模型(录制=我做给 Agent 看,会话=我问 Agent 做),不能混在一起。加工过程独立展示在「⚙️ 加工」Tab。
|
|
200
|
+
|
|
201
|
+
#### 2026-06-26 SSE 替代 WebSocket
|
|
202
|
+
WebSocket 通讯对用户不可见、调试困难。改为 HTTP POST + SSE 后,DevTools Network 可直接看到请求,且加了网络通讯面板可视化。
|
|
203
|
+
|
|
204
|
+
#### 2026-06-26 默认空会话
|
|
205
|
+
打开页面就有空会话占位,用户可直接输入。加号按钮智能创建——当前空会话没消息时不重复创建。
|
|
206
|
+
|
|
207
|
+
## 开发规范
|
|
208
|
+
|
|
209
|
+
### 端口
|
|
210
|
+
- 后端:5200
|
|
211
|
+
- 前端(Vite):7200
|
|
212
|
+
- cdp-tunnel:9221
|
|
213
|
+
|
|
214
|
+
### 环境变量
|
|
215
|
+
```
|
|
216
|
+
PORT=5200
|
|
217
|
+
VITE_PORT=7200
|
|
218
|
+
AUTH_TOKEN=dev-token
|
|
219
|
+
VITE_AUTH_TOKEN=dev-token
|
|
220
|
+
CDP_ENDPOINT=http://localhost:9221
|
|
221
|
+
CORS_ORIGIN=http://localhost:7200
|
|
222
|
+
CDP_TUNNEL_EXT=/path/to/cdp-tunnel2/extension-new
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 新增功能时的检查清单
|
|
226
|
+
1. 在 `src/shared/modules/*.ts` 定义 RPC 类型
|
|
227
|
+
2. 在 `src/shared/handlers/*.ts` 实现 handler
|
|
228
|
+
3. 在 `src/shared/handlers/index.ts` 注册 barrel export
|
|
229
|
+
4. 在 `src/shared/rpc-schema.ts` 合并类型
|
|
230
|
+
5. 前端 store + 组件实现
|
|
231
|
+
6. 在本文件「功能大纲」记录
|
|
232
|
+
7. `tsc --noEmit` 零错误 + `vitest run` 全过
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
> 📌 **文档维护规则**:当你(AI 助手)觉得某个东西比较重要,或有新增功能/需求变更时,请用大纲形式更新本文件的「功能大纲」和「需求记录」章节。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# cowork-app
|
|
2
|
+
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266)]:
|
|
8
|
+
- @dyyz1993/rpc-core@2.2.1
|
|
9
|
+
|
|
10
|
+
## 1.0.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266), [`724470a`](https://github.com/dyyz1993/pi-agent-template/commit/724470a784b48a66591e06299fab8ad72f023962)]:
|
|
15
|
+
- @dyyz1993/rpc-core@3.0.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 [username]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Browser Agent Template
|
|
2
|
+
|
|
3
|
+
AI-powered browser automation agent. Built with Electrobun, React, Tailwind CSS, and RPC architecture.
|
|
4
|
+
|
|
5
|
+
Control a real Chrome browser via natural language — Agent executes xbrowser commands (goto, click, scrape, fill, screenshot, search...), streams progress in real-time with turn-by-turn tool call cards, and delivers collected data as structured files (CSV/JSON/MD).
|
|
6
|
+
|
|
7
|
+
70+ site-specific plugins (小红书, 豆瓣, B站, 淘宝) available.
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun install
|
|
13
|
+
|
|
14
|
+
# Web mode (development with HMR) — Backend :5200, Vite :7200
|
|
15
|
+
bun run dev:web
|
|
16
|
+
|
|
17
|
+
# Desktop mode (Electrobun native app)
|
|
18
|
+
bun run dev
|
|
19
|
+
|
|
20
|
+
# Build
|
|
21
|
+
bun run build
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Key Features
|
|
25
|
+
|
|
26
|
+
- **Agent Chat** — Natural language → browser automation. Streaming turns, tool call cards, thinking blocks
|
|
27
|
+
- **xbrowser Engine** — Full command set: goto, click, fill, scrape, crawl, search, screenshot, eval, tabs, plugins
|
|
28
|
+
- **Plugin System** — 70+ site plugins, inline selector in the topbar
|
|
29
|
+
- **Skill System** — Pre-built skills (小红书 explore/search/blogger) in sidebar
|
|
30
|
+
- **Session Management** — Conversation history, message persistence, context memory
|
|
31
|
+
- **Assets Panel** — Screenshots, images, CSV/JSON/MD files grouped and downloadable
|
|
32
|
+
- **Three-Panel Layout** — Sidebar (skills + sessions) | Chat | Assets
|
|
33
|
+
- **Desktop + Web** — Dual mode via Electrobun (desktop) + Vite (web)
|
|
34
|
+
|
|
35
|
+
## RPC Modules
|
|
36
|
+
|
|
37
|
+
| Module | Methods | Events | Description |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| `browser` | agentChat, checkConnection, listTabs, listPlugins, execXbrowser, getSystemInfo | agentStart, toolCall, toolResult, thinking, textDelta, turn, done, progress | Browser auto + Agent AI loop |
|
|
40
|
+
| `session` | create, get, list, addMessage, updateLastMessage, setStatus | – | Session CRUD + message management |
|
|
41
|
+
| `system` | ping, hello, echo | – | Connectivity test |
|
|
42
|
+
| `file` | listDir, readFile, createFile, createDir, rename, delete, copy, findProjectRoot | – | File system operations |
|
|
43
|
+
| `timer` | start, stop | timer.tick | Timer + real-time push |
|
|
44
|
+
| `chat` | list, send | chat.message | Chat (role filtering) |
|
|
45
|
+
| `git` | status, diff, log, branches, checkout, add, reset, commit, push, pull | – | Git version control |
|
|
46
|
+
| `feed` | post, list | feed.update | Feed stream |
|
|
47
|
+
|
|
48
|
+
## Project Structure
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
├── src/
|
|
52
|
+
│ ├── bun/index.ts # Desktop entry (Electrobun main process)
|
|
53
|
+
│ ├── server.ts # Web entry (HTTP + WebSocket server)
|
|
54
|
+
│ ├── server-config.ts # Config (PORT=5200, VITE_PORT=7200)
|
|
55
|
+
│ ├── gateway/
|
|
56
|
+
│ │ ├── http-routes.ts # HTTP endpoints + asset download
|
|
57
|
+
│ │ ├── ws-handler.ts # WebSocket RPC (token auth)
|
|
58
|
+
│ │ └── ipc-transport.ts # Electrobun IPC bridge
|
|
59
|
+
│ ├── shared/
|
|
60
|
+
│ │ ├── rpc-schema.ts # Unified RPC type definitions
|
|
61
|
+
│ │ ├── register-all-handlers.ts
|
|
62
|
+
│ │ ├── modules/
|
|
63
|
+
│ │ │ ├── browser.ts # Browser + Agent RPC types
|
|
64
|
+
│ │ │ └── session.ts # Session CRUD types
|
|
65
|
+
│ │ ├── handlers/
|
|
66
|
+
│ │ │ ├── browser.ts # Agent chat + xbrowser execution
|
|
67
|
+
│ │ │ └── session.ts # In-memory SessionStore
|
|
68
|
+
│ │ └── lib/
|
|
69
|
+
│ │ ├── agent.ts # RpcClient manager + agentChat()
|
|
70
|
+
│ │ ├── cdp.ts # xbrowser CLI + scrapeXhs pipeline
|
|
71
|
+
│ │ ├── generate.ts # CSV/JSON/MD/ZIP export
|
|
72
|
+
│ │ └── xhs-extract.ts # 小红书 DOM extraction
|
|
73
|
+
│ └── mainview/
|
|
74
|
+
│ ├── App.tsx # Entry + connection detection
|
|
75
|
+
│ ├── components/
|
|
76
|
+
│ │ ├── layout/ # AppLayout (sidebar|chat|assets)
|
|
77
|
+
│ │ ├── topbar/ # Logo, plugins, status, theme
|
|
78
|
+
│ │ ├── chat/ # ChatPanel + MessageBubble (streaming)
|
|
79
|
+
│ │ ├── sidebar/ # SkillSidebar + SessionSidebar
|
|
80
|
+
│ │ └── assets/ # AssetsPanel (files/images)
|
|
81
|
+
│ ├── stores/
|
|
82
|
+
│ │ ├── use-chat-store.ts # Agent streaming state
|
|
83
|
+
│ │ ├── use-session-store.ts # Session CRUD
|
|
84
|
+
│ │ ├── use-connection-store.ts # Browser + plugins
|
|
85
|
+
│ │ └── use-asset-store.ts # Assets management
|
|
86
|
+
│ └── lib/
|
|
87
|
+
│ └── api-client.ts # Typed RPC client (WS + IPC)
|
|
88
|
+
├── AGENTS.md # Agent system prompt
|
|
89
|
+
├── electrobun.config.ts
|
|
90
|
+
├── vite.config.ts
|
|
91
|
+
└── tailwind.config.js
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Environment
|
|
95
|
+
|
|
96
|
+
| Variable | Default | Description |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `PORT` | 5200 | Backend server port |
|
|
99
|
+
| `VITE_PORT` | 7200 | Vite dev server port |
|
|
100
|
+
| `AUTH_TOKEN` | (auto) | WebSocket auth token |
|
|
101
|
+
| `CDP_ENDPOINT` | http://localhost:9221 | cdp-tunnel address |
|
|
102
|
+
| `AGENT_MAX_TURNS` | 30 | Max agent turns per chat |
|
|
103
|
+
| `AGENT_TIMEOUT_MS` | 300000 | Agent timeout (5 min) |
|