@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
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
export type TreeNode = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
name: string;
|
|
3
|
+
path: string;
|
|
4
|
+
type: 'file' | 'directory';
|
|
5
|
+
size?: number;
|
|
6
|
+
children?: TreeNode[];
|
|
7
|
+
expanded?: boolean;
|
|
8
|
+
loaded?: boolean;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export type DemoMethod =
|
|
11
|
+
export type DemoMethod = 'system.ping' | 'system.hello' | 'system.echo' | 'chat.send';
|
|
12
12
|
|
|
13
13
|
export type FilePreview = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
path: string;
|
|
15
|
+
name: string;
|
|
16
|
+
content: string | null;
|
|
17
|
+
imageUrl: string | null;
|
|
18
|
+
mimeType: string;
|
|
19
|
+
size: number;
|
|
20
|
+
isText: boolean;
|
|
21
|
+
isImage: boolean;
|
|
22
|
+
totalLines?: number;
|
|
23
|
+
scrollToLine?: number;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
export type ChatMessage = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
id: string;
|
|
28
|
+
role: 'user' | 'assistant';
|
|
29
|
+
content: string;
|
|
30
|
+
timestamp: number;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
export type EditingType =
|
|
33
|
+
export type EditingType = 'rename' | 'newFile' | 'newDir';
|
|
33
34
|
export type EditingNode = { path: string; type: EditingType };
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Folder,
|
|
4
|
-
FileText,
|
|
5
|
-
FileCode,
|
|
6
|
-
Image,
|
|
7
|
-
FileArchive,
|
|
8
|
-
} from "lucide-react";
|
|
9
|
-
import type { TreeNode } from "../types";
|
|
1
|
+
import { FolderOpen, Folder, FileText, FileCode, Image, FileArchive } from 'lucide-react';
|
|
2
|
+
import type { TreeNode } from '../types';
|
|
10
3
|
|
|
11
4
|
export function getFileIcon(node: TreeNode) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
if (node.type === 'directory') {
|
|
6
|
+
return node.expanded ? (
|
|
7
|
+
<FolderOpen className="w-4 h-4 text-yellow-400 shrink-0" />
|
|
8
|
+
) : (
|
|
9
|
+
<Folder className="w-4 h-4 text-yellow-400 shrink-0" />
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
const ext = node.name.split('.').pop()?.toLowerCase() || '';
|
|
13
|
+
if (['ts', 'tsx', 'js', 'jsx'].includes(ext))
|
|
14
|
+
return <FileCode className="w-4 h-4 text-blue-400 shrink-0" />;
|
|
15
|
+
if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'].includes(ext))
|
|
16
|
+
return <Image className="w-4 h-4 text-[var(--color-text-success)] shrink-0" />;
|
|
17
|
+
if (['zip', 'gz', 'tar', 'rar'].includes(ext))
|
|
18
|
+
return <FileArchive className="w-4 h-4 text-[var(--color-text-warning)] shrink-0" />;
|
|
19
|
+
return <FileText className="w-4 h-4 text-[var(--color-text-tertiary)] shrink-0" />;
|
|
24
20
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { RPCServer } from
|
|
2
|
-
import type { MethodParams, MethodResult } from
|
|
3
|
-
import type { RPCMethods, HandlerOptions } from
|
|
4
|
-
import { readFile, writeFile, mkdir } from
|
|
5
|
-
import { existsSync } from
|
|
6
|
-
import { join, dirname } from
|
|
7
|
-
import { homedir } from
|
|
8
|
-
import { createLogger } from
|
|
1
|
+
import type { RPCServer } from '@dyyz1993/rpc-core';
|
|
2
|
+
import type { MethodParams, MethodResult } from '@dyyz1993/rpc-core';
|
|
3
|
+
import type { RPCMethods, HandlerOptions } from '../rpc-schema';
|
|
4
|
+
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
5
|
+
import { existsSync } from 'fs';
|
|
6
|
+
import { join, dirname } from 'path';
|
|
7
|
+
import { homedir } from 'os';
|
|
8
|
+
import { createLogger } from '../lib/logger';
|
|
9
9
|
|
|
10
|
-
const log = createLogger(
|
|
10
|
+
const log = createLogger('chat');
|
|
11
11
|
|
|
12
|
-
type Platform =
|
|
12
|
+
type Platform = 'desktop' | 'web';
|
|
13
13
|
|
|
14
14
|
export function getStoragePathFor(platform: Platform): string {
|
|
15
|
-
const dir = join(homedir(),
|
|
16
|
-
if (platform ===
|
|
17
|
-
return join(dir,
|
|
15
|
+
const dir = join(homedir(), '.pi-agent');
|
|
16
|
+
if (platform === 'desktop') {
|
|
17
|
+
return join(dir, 'chat-history-desktop.json');
|
|
18
18
|
}
|
|
19
|
-
const sessionId = Date.now().toString(36) +
|
|
19
|
+
const sessionId = Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
|
|
20
20
|
return join(dir, `chat-history-web-${sessionId}.json`);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type ChatMessage = { id: string; role:
|
|
23
|
+
type ChatMessage = { id: string; role: 'user' | 'assistant'; content: string; timestamp: number };
|
|
24
24
|
|
|
25
25
|
function createMessageStore(filePath: string) {
|
|
26
26
|
async function load(): Promise<ChatMessage[]> {
|
|
@@ -29,12 +29,12 @@ function createMessageStore(filePath: string) {
|
|
|
29
29
|
log.info(`No history file at ${filePath}`);
|
|
30
30
|
return [];
|
|
31
31
|
}
|
|
32
|
-
const raw = await readFile(filePath,
|
|
32
|
+
const raw = await readFile(filePath, 'utf-8');
|
|
33
33
|
const msgs = JSON.parse(raw) as ChatMessage[];
|
|
34
34
|
log.info(`Loaded ${msgs.length} messages from ${filePath}`);
|
|
35
35
|
return msgs;
|
|
36
36
|
} catch (err) {
|
|
37
|
-
log.error(
|
|
37
|
+
log.error('Failed to load history', { error: err });
|
|
38
38
|
return [];
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -45,10 +45,10 @@ function createMessageStore(filePath: string) {
|
|
|
45
45
|
if (!existsSync(dir)) {
|
|
46
46
|
await mkdir(dir, { recursive: true });
|
|
47
47
|
}
|
|
48
|
-
await writeFile(filePath, JSON.stringify(messages, null, 2),
|
|
48
|
+
await writeFile(filePath, JSON.stringify(messages, null, 2), 'utf-8');
|
|
49
49
|
log.info(`Saved ${messages.length} messages to ${filePath}`);
|
|
50
50
|
} catch (err) {
|
|
51
|
-
log.error(
|
|
51
|
+
log.error('Failed to save history', { error: err });
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -57,16 +57,16 @@ function createMessageStore(filePath: string) {
|
|
|
57
57
|
|
|
58
58
|
type RegisterFn = <K extends keyof RPCMethods & string>(
|
|
59
59
|
method: K,
|
|
60
|
-
handler: (params: MethodParams<RPCMethods, K>) => Promise<MethodResult<RPCMethods, K
|
|
60
|
+
handler: (params: MethodParams<RPCMethods, K>) => Promise<MethodResult<RPCMethods, K>>,
|
|
61
61
|
) => void;
|
|
62
62
|
|
|
63
|
-
function generateReply(input: string): string {
|
|
63
|
+
export function generateReply(input: string): string {
|
|
64
64
|
const lower = input.toLowerCase().trim();
|
|
65
65
|
|
|
66
66
|
if (/^(hi|hello|hey|howdy|hola|yo|sup)\b/i.test(lower)) {
|
|
67
67
|
const greetings = [
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
'Hey there! How can I help you today?',
|
|
69
|
+
'Hello! Great to see you. What would you like to know?',
|
|
70
70
|
"Hi! I'm your desktop assistant. Ask me anything!",
|
|
71
71
|
];
|
|
72
72
|
return greetings[Math.floor(Math.random() * greetings.length)]!;
|
|
@@ -76,18 +76,18 @@ function generateReply(input: string): string {
|
|
|
76
76
|
/what('?s| is) the (time|date|day)|current (time|date)|what time|today'?s date/i.test(lower)
|
|
77
77
|
) {
|
|
78
78
|
const now = new Date();
|
|
79
|
-
const date = now.toLocaleDateString(
|
|
80
|
-
weekday:
|
|
81
|
-
year:
|
|
82
|
-
month:
|
|
83
|
-
day:
|
|
79
|
+
const date = now.toLocaleDateString('en-US', {
|
|
80
|
+
weekday: 'long',
|
|
81
|
+
year: 'numeric',
|
|
82
|
+
month: 'long',
|
|
83
|
+
day: 'numeric',
|
|
84
84
|
});
|
|
85
|
-
const time = now.toLocaleTimeString(
|
|
85
|
+
const time = now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
|
|
86
86
|
return `It's currently **${time}** on **${date}**.`;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const mathMatch = lower.match(
|
|
90
|
-
/(?:what(?:'s| is)\s+)?(\d+(?:\.\d+)?)\s*([+\-*/x×÷^])\s*(\d+(?:\.\d+)?)
|
|
90
|
+
/(?:what(?:'s| is)\s+)?(\d+(?:\.\d+)?)\s*([+\-*/x×÷^])\s*(\d+(?:\.\d+)?)/,
|
|
91
91
|
);
|
|
92
92
|
if (mathMatch) {
|
|
93
93
|
const a = parseFloat(mathMatch[1]!);
|
|
@@ -95,22 +95,22 @@ function generateReply(input: string): string {
|
|
|
95
95
|
const b = parseFloat(mathMatch[3]!);
|
|
96
96
|
let result: number;
|
|
97
97
|
switch (op) {
|
|
98
|
-
case
|
|
98
|
+
case '+':
|
|
99
99
|
result = a + b;
|
|
100
100
|
break;
|
|
101
|
-
case
|
|
101
|
+
case '-':
|
|
102
102
|
result = a - b;
|
|
103
103
|
break;
|
|
104
|
-
case
|
|
105
|
-
case
|
|
106
|
-
case
|
|
104
|
+
case '*':
|
|
105
|
+
case 'x':
|
|
106
|
+
case '×':
|
|
107
107
|
result = a * b;
|
|
108
108
|
break;
|
|
109
|
-
case
|
|
110
|
-
case
|
|
109
|
+
case '/':
|
|
110
|
+
case '÷':
|
|
111
111
|
result = b !== 0 ? a / b : NaN;
|
|
112
112
|
break;
|
|
113
|
-
case
|
|
113
|
+
case '^':
|
|
114
114
|
result = Math.pow(a, b);
|
|
115
115
|
break;
|
|
116
116
|
default:
|
|
@@ -121,23 +121,23 @@ function generateReply(input: string): string {
|
|
|
121
121
|
}
|
|
122
122
|
const niceResult = Number.isInteger(result)
|
|
123
123
|
? result.toString()
|
|
124
|
-
: result.toFixed(4).replace(/0+$/,
|
|
124
|
+
: result.toFixed(4).replace(/0+$/, '').replace(/\.$/, '');
|
|
125
125
|
return `That would be **${niceResult}**! Need help with anything else?`;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if (/file|folder|directory|browse|explorer|open file|read file/i.test(lower)) {
|
|
129
129
|
return (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
'To browse and manage files, use the **File Explorer** panel on the left sidebar. ' +
|
|
131
|
+
'You can navigate directories, preview files, and open them for editing. ' +
|
|
132
|
+
'Try typing a file path or asking me about a specific directory!'
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
if (/git|commit|branch|push|pull|merge|status|diff|log/i.test(lower)) {
|
|
137
137
|
return (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
'The **Git Panel** gives you full source control right inside the app. ' +
|
|
139
|
+
'You can view changes, stage files, commit, switch branches, push/pull, and see the commit log. ' +
|
|
140
|
+
'Look for the source control icon in the sidebar to get started.'
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -149,8 +149,8 @@ function generateReply(input: string): string {
|
|
|
149
149
|
'- **Math** - Give me an expression like "12 * 8" or "what is 100 / 4"\n' +
|
|
150
150
|
"- **Files** - Ask about file browsing and I'll explain the File Explorer\n" +
|
|
151
151
|
"- **Git** - Ask about version control and I'll walk you through it\n" +
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
'- **Help** - Show this message anytime!\n\n' +
|
|
153
|
+
'This is a demo assistant - try different things to see what sticks!'
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -170,7 +170,7 @@ export function register(server: RPCServer, options: HandlerOptions): void {
|
|
|
170
170
|
server.register(method, handler as (params: unknown) => Promise<unknown>);
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
r(
|
|
173
|
+
r('chat.list', async (params) => {
|
|
174
174
|
const all = await store.load();
|
|
175
175
|
const limit = params.limit ?? 50;
|
|
176
176
|
const messages = all.slice(-limit);
|
|
@@ -180,31 +180,31 @@ export function register(server: RPCServer, options: HandlerOptions): void {
|
|
|
180
180
|
};
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
r(
|
|
183
|
+
r('chat.send', async (params) => {
|
|
184
184
|
const all = await store.load();
|
|
185
185
|
|
|
186
186
|
const userMsg: ChatMessage = {
|
|
187
187
|
id: `msg-${Date.now()}-user`,
|
|
188
|
-
role:
|
|
188
|
+
role: 'user',
|
|
189
189
|
content: params.content,
|
|
190
190
|
timestamp: Date.now(),
|
|
191
191
|
};
|
|
192
192
|
all.push(userMsg);
|
|
193
193
|
|
|
194
|
-
server.emitEvent(
|
|
194
|
+
server.emitEvent('chat.message', userMsg, { role: userMsg.role });
|
|
195
195
|
|
|
196
196
|
const thinkDelay = 200 + Math.floor(Math.random() * 300);
|
|
197
197
|
await new Promise((r) => setTimeout(r, thinkDelay));
|
|
198
198
|
|
|
199
199
|
const reply: ChatMessage = {
|
|
200
200
|
id: `msg-${Date.now()}-assistant`,
|
|
201
|
-
role:
|
|
201
|
+
role: 'assistant',
|
|
202
202
|
content: generateReply(params.content),
|
|
203
203
|
timestamp: Date.now(),
|
|
204
204
|
};
|
|
205
205
|
all.push(reply);
|
|
206
206
|
|
|
207
|
-
server.emitEvent(
|
|
207
|
+
server.emitEvent('chat.message', reply, { role: reply.role });
|
|
208
208
|
|
|
209
209
|
await store.save(all);
|
|
210
210
|
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import type { RPCServer } from
|
|
2
|
-
import type {
|
|
1
|
+
import type { RPCServer } from '@dyyz1993/rpc-core';
|
|
2
|
+
import type { MethodParams, MethodResult } from '@dyyz1993/rpc-core';
|
|
3
|
+
import type { RPCMethods, HandlerOptions } from '../rpc-schema';
|
|
4
|
+
|
|
5
|
+
type RegisterFn = <K extends keyof RPCMethods & string>(
|
|
6
|
+
method: K,
|
|
7
|
+
handler: (params: MethodParams<RPCMethods, K>) => Promise<MethodResult<RPCMethods, K>>,
|
|
8
|
+
) => void;
|
|
3
9
|
|
|
4
10
|
export function register(server: RPCServer, _options: HandlerOptions): void {
|
|
5
|
-
|
|
11
|
+
const r: RegisterFn = (method, handler) => {
|
|
12
|
+
server.register(method, handler as (params: unknown) => Promise<unknown>);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
r('debug.subscriptions', async () => {
|
|
6
16
|
return {
|
|
7
17
|
subscriptions: (
|
|
8
18
|
server as unknown as { getActiveSubscriptions(): unknown }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Web server configuration
|
|
2
|
+
PORT=5200
|
|
3
|
+
VITE_PORT=7200
|
|
4
|
+
AUTH_TOKEN=your-secret-token-here
|
|
5
|
+
VITE_AUTH_TOKEN=your-secret-token-here
|
|
6
|
+
MAX_UPLOAD_SIZE=5242880
|
|
7
|
+
LOG_DIR=logs
|
|
8
|
+
CORS_ORIGIN=http://localhost:7200
|
|
9
|
+
|
|
10
|
+
# Browser Agent configuration
|
|
11
|
+
CDP_ENDPOINT=http://localhost:9221
|
|
12
|
+
CLOUD_PROXY_URL=http://localhost:9221
|
|
13
|
+
AGENT_MAX_TURNS=30
|
|
14
|
+
AGENT_TIMEOUT_MS=300000
|
|
15
|
+
XBROWSER_CMD=/usr/local/bin/xbrowser
|
|
16
|
+
|
|
17
|
+
# Mock 流式模式(演示/调试用)— 设为 true 后不连接真实 AI,
|
|
18
|
+
# 用脚本化流程模拟完整的 agent 流式输出(thinking → toolCall → textDelta → done)
|
|
19
|
+
ENABLE_MOCK_STREAM=false
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
# Secret detection
|
|
5
|
+
if git diff --cached --name-only --diff-filter=ACM -z | xargs -0 grep -ilE '(password|secret|api.key|private.key|token|credential).*=.*[A-Za-z0-9]{16,}' 2>/dev/null; then
|
|
6
|
+
echo "⚠️ Potential secrets detected in staged files!"
|
|
7
|
+
echo "Please review and remove any sensitive data before committing."
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
npx lint-staged
|