@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
|
@@ -9,307 +9,324 @@ import { useConnectionStore } from "./use-connection-store";
|
|
|
9
9
|
import { uploadEntriesWeb, importFilesDesktop, type DropEntry } from "../utils/drop-handler";
|
|
10
10
|
|
|
11
11
|
interface ExplorerState {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
treeNodes: TreeNode[];
|
|
13
|
+
currentPath: string;
|
|
14
|
+
selectedPath: string | null;
|
|
15
|
+
filePreview: FilePreview | null;
|
|
16
|
+
loadingFile: boolean;
|
|
17
|
+
editingNode: EditingNode | null;
|
|
18
|
+
scrollToLine: number | null;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
setCurrentPath: (path: string) => void;
|
|
21
|
+
listRootDir: () => Promise<void>;
|
|
22
|
+
toggleNode: (nodePath: string) => Promise<void>;
|
|
23
|
+
openFile: (node: TreeNode) => Promise<void>;
|
|
24
|
+
openFileAtLine: (node: TreeNode, line: number) => Promise<void>;
|
|
25
|
+
clearScrollToLine: () => void;
|
|
26
|
+
closePreview: () => void;
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
createFile: (dirPath: string, name: string) => Promise<void>;
|
|
29
|
+
createDir: (dirPath: string, name: string) => Promise<void>;
|
|
30
|
+
renameNode: (oldPath: string, newName: string) => Promise<void>;
|
|
31
|
+
deleteNode: (path: string) => Promise<void>;
|
|
32
|
+
refreshDir: (dirPath: string) => Promise<void>;
|
|
33
|
+
startEditing: (path: string, type: EditingNode["type"]) => void;
|
|
34
|
+
cancelEditing: () => void;
|
|
35
|
+
importFiles: (entries: DropEntry[], destDir: string) => Promise<number>;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
function entriesToTreeNodes(entries: RPCMethods["file.listDir"]["result"]["entries"]): TreeNode[] {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
return entries.map((e) => ({
|
|
40
|
+
name: e.name,
|
|
41
|
+
path: e.path,
|
|
42
|
+
type: e.type,
|
|
43
|
+
size: e.size,
|
|
44
|
+
children: e.type === "directory" ? [] : undefined,
|
|
45
|
+
expanded: false,
|
|
46
|
+
loaded: false,
|
|
47
|
+
}));
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
function getFileUrl(filePath: string): string {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const mode = useConnectionStore.getState().mode;
|
|
52
|
+
if (mode === "desktop") return `file://${filePath}`;
|
|
53
|
+
const baseUrl = apiClient.getBaseUrl();
|
|
54
|
+
const token = apiClient.getAuthToken();
|
|
55
|
+
return `${baseUrl}/file/${encodeURIComponent(filePath)}?token=${token}`;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
function findNode(nodes: TreeNode[], path: string): TreeNode | null {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
for (const n of nodes) {
|
|
60
|
+
if (n.path === path) return n;
|
|
61
|
+
if (n.children) {
|
|
62
|
+
const found = findNode(n.children, path);
|
|
63
|
+
if (found) return found;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
function updateExpanded(nodes: TreeNode[], path: string, expanded: boolean): TreeNode[] {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
return nodes.map((n) => {
|
|
71
|
+
if (n.path === path) return { ...n, expanded };
|
|
72
|
+
if (n.children) return { ...n, children: updateExpanded(n.children, path, expanded) };
|
|
73
|
+
return n;
|
|
74
|
+
});
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
function loadChildren(nodes: TreeNode[], nodePath: string, children: TreeNode[]): TreeNode[] {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
return nodes.map((n) => {
|
|
79
|
+
if (n.path === nodePath) return { ...n, children, expanded: true, loaded: true };
|
|
80
|
+
if (n.children) return { ...n, children: loadChildren(n.children, nodePath, children) };
|
|
81
|
+
return n;
|
|
82
|
+
});
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
function removeNode(nodes: TreeNode[], path: string): TreeNode[] {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
return nodes
|
|
87
|
+
.filter((n) => n.path !== path)
|
|
88
|
+
.map((n) => {
|
|
89
|
+
if (n.children) return { ...n, children: removeNode(n.children, path) };
|
|
90
|
+
return n;
|
|
91
|
+
});
|
|
89
92
|
}
|
|
90
93
|
|
|
91
|
-
function renameInTree(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
function renameInTree(
|
|
95
|
+
nodes: TreeNode[],
|
|
96
|
+
oldPath: string,
|
|
97
|
+
newPath: string,
|
|
98
|
+
newName: string
|
|
99
|
+
): TreeNode[] {
|
|
100
|
+
return nodes.map((n) => {
|
|
101
|
+
if (n.path === oldPath) {
|
|
102
|
+
return { ...n, name: newName, path: newPath };
|
|
103
|
+
}
|
|
104
|
+
if (n.children) {
|
|
105
|
+
return { ...n, children: renameInTree(n.children, oldPath, newPath, newName) };
|
|
106
|
+
}
|
|
107
|
+
return n;
|
|
108
|
+
});
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
export const useExplorerStore = create<ExplorerState>((set, get) => ({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
treeNodes: [],
|
|
113
|
+
currentPath: "",
|
|
114
|
+
selectedPath: null,
|
|
115
|
+
filePreview: null,
|
|
116
|
+
loadingFile: false,
|
|
117
|
+
editingNode: null,
|
|
118
|
+
scrollToLine: null,
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
setCurrentPath: (path) => set({ currentPath: path }),
|
|
112
121
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
listRootDir: async () => {
|
|
123
|
+
const { currentPath } = get();
|
|
124
|
+
const addLog = useLogStore.getState().addLog;
|
|
125
|
+
addLog(`ListDir: ${currentPath}`);
|
|
126
|
+
try {
|
|
127
|
+
const res = await apiClient.call("file.listDir", { path: currentPath });
|
|
128
|
+
set({
|
|
129
|
+
treeNodes: entriesToTreeNodes(res.entries),
|
|
130
|
+
// Update currentPath to the resolved absolute path
|
|
131
|
+
currentPath: res.basePath,
|
|
132
|
+
});
|
|
133
|
+
addLog(`Found ${res.entries.length} items`);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
addLog(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
129
138
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
toggleNode: async (nodePath: string) => {
|
|
140
|
+
const { treeNodes } = get();
|
|
141
|
+
const addLog = useLogStore.getState().addLog;
|
|
142
|
+
const target = findNode(treeNodes, nodePath);
|
|
143
|
+
if (!target) return;
|
|
135
144
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
if (target.expanded) {
|
|
146
|
+
set({ treeNodes: updateExpanded(treeNodes, nodePath, false) });
|
|
147
|
+
} else if (target.loaded) {
|
|
148
|
+
set({ treeNodes: updateExpanded(treeNodes, nodePath, true) });
|
|
149
|
+
} else {
|
|
150
|
+
addLog(`ListDir: ${nodePath}`);
|
|
151
|
+
try {
|
|
152
|
+
const res = await apiClient.call("file.listDir", { path: nodePath });
|
|
153
|
+
const children = entriesToTreeNodes(res.entries);
|
|
154
|
+
addLog(`Found ${res.entries.length} items`);
|
|
155
|
+
set({ treeNodes: loadChildren(treeNodes, nodePath, children) });
|
|
156
|
+
} catch (err) {
|
|
157
|
+
addLog(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
152
161
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
openFile: async (node: TreeNode) => {
|
|
163
|
+
if (node.type === "directory") return;
|
|
164
|
+
const addLog = useLogStore.getState().addLog;
|
|
165
|
+
set({ selectedPath: node.path, loadingFile: true });
|
|
157
166
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
const fileSize = node.size || 0;
|
|
168
|
+
const preview: FilePreview = {
|
|
169
|
+
path: node.path,
|
|
170
|
+
name: node.name,
|
|
171
|
+
content: null,
|
|
172
|
+
imageUrl: null,
|
|
173
|
+
mimeType: "",
|
|
174
|
+
size: fileSize,
|
|
175
|
+
isText: isTextFile(node.name),
|
|
176
|
+
isImage: isImageFile(node.name),
|
|
177
|
+
};
|
|
169
178
|
|
|
170
|
-
|
|
171
|
-
|
|
179
|
+
try {
|
|
180
|
+
const mode = useConnectionStore.getState().mode;
|
|
172
181
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
if (preview.isImage) {
|
|
183
|
+
preview.imageUrl = getFileUrl(node.path);
|
|
184
|
+
} else if (preview.isText) {
|
|
185
|
+
if (fileSize > MAX_PREVIEW_SIZE) {
|
|
186
|
+
preview.content = `[File too large to preview: ${formatSize(fileSize)}]\n\nThis file exceeds the 500KB preview limit.\nUse an external editor to view this file.`;
|
|
187
|
+
set({ filePreview: preview, loadingFile: false });
|
|
188
|
+
addLog(`Skipped large file: ${node.name} (${formatSize(fileSize)})`);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
182
191
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
192
|
+
let text: string;
|
|
193
|
+
if (mode === "desktop") {
|
|
194
|
+
// Desktop: read file via RPC (file:// blocked by webview)
|
|
195
|
+
const res = await apiClient.call("file.readFile", { path: node.path });
|
|
196
|
+
text = res.content;
|
|
197
|
+
preview.mimeType = "text/plain";
|
|
198
|
+
} else {
|
|
199
|
+
// Web: fetch via HTTP file server
|
|
200
|
+
const url = getFileUrl(node.path);
|
|
201
|
+
const res = await fetch(url);
|
|
202
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
203
|
+
text = await res.text();
|
|
204
|
+
preview.mimeType = res.headers.get("content-type") || "text/plain";
|
|
205
|
+
}
|
|
206
|
+
preview.content = text;
|
|
207
|
+
preview.totalLines = text.split("\n").length;
|
|
208
|
+
} else {
|
|
209
|
+
preview.content = `[Binary file: ${node.name} (${formatSize(preview.size)})]`;
|
|
210
|
+
preview.isText = true;
|
|
211
|
+
}
|
|
212
|
+
addLog(`Opened: ${node.name}`);
|
|
213
|
+
} catch (err) {
|
|
214
|
+
preview.content = `Failed to load: ${err instanceof Error ? err.message : String(err)}`;
|
|
215
|
+
preview.isText = true;
|
|
216
|
+
addLog(`Error opening ${node.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
217
|
+
}
|
|
209
218
|
|
|
210
|
-
|
|
211
|
-
|
|
219
|
+
set({ filePreview: preview, loadingFile: false });
|
|
220
|
+
},
|
|
212
221
|
|
|
213
|
-
|
|
222
|
+
openFileAtLine: async (node: TreeNode, line: number) => {
|
|
223
|
+
await get().openFile(node);
|
|
224
|
+
set({ scrollToLine: line });
|
|
225
|
+
},
|
|
214
226
|
|
|
215
|
-
|
|
216
|
-
const addLog = useLogStore.getState().addLog;
|
|
217
|
-
try {
|
|
218
|
-
await apiClient.call("file.createFile", { dirPath, name });
|
|
219
|
-
addLog(`Created file: ${name}`);
|
|
220
|
-
set({ editingNode: null });
|
|
221
|
-
await get().refreshDir(dirPath);
|
|
222
|
-
} catch (err) {
|
|
223
|
-
addLog(`Error creating file: ${err instanceof Error ? err.message : String(err)}`);
|
|
224
|
-
set({ editingNode: null });
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
+
clearScrollToLine: () => set({ scrollToLine: null }),
|
|
227
228
|
|
|
228
|
-
|
|
229
|
-
const addLog = useLogStore.getState().addLog;
|
|
230
|
-
try {
|
|
231
|
-
await apiClient.call("file.createDir", { dirPath, name });
|
|
232
|
-
addLog(`Created directory: ${name}`);
|
|
233
|
-
set({ editingNode: null });
|
|
234
|
-
await get().refreshDir(dirPath);
|
|
235
|
-
} catch (err) {
|
|
236
|
-
addLog(`Error creating directory: ${err instanceof Error ? err.message : String(err)}`);
|
|
237
|
-
set({ editingNode: null });
|
|
238
|
-
}
|
|
239
|
-
},
|
|
229
|
+
closePreview: () => set({ filePreview: null, selectedPath: null, scrollToLine: null }),
|
|
240
230
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
addLog(`Error renaming: ${err instanceof Error ? err.message : String(err)}`);
|
|
254
|
-
set({ editingNode: null });
|
|
255
|
-
}
|
|
256
|
-
},
|
|
231
|
+
createFile: async (dirPath: string, name: string) => {
|
|
232
|
+
const addLog = useLogStore.getState().addLog;
|
|
233
|
+
try {
|
|
234
|
+
await apiClient.call("file.createFile", { dirPath, name });
|
|
235
|
+
addLog(`Created file: ${name}`);
|
|
236
|
+
set({ editingNode: null });
|
|
237
|
+
await get().refreshDir(dirPath);
|
|
238
|
+
} catch (err) {
|
|
239
|
+
addLog(`Error creating file: ${err instanceof Error ? err.message : String(err)}`);
|
|
240
|
+
set({ editingNode: null });
|
|
241
|
+
}
|
|
242
|
+
},
|
|
257
243
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const { selectedPath } = get();
|
|
271
|
-
if (selectedPath === path) {
|
|
272
|
-
set({ selectedPath: null, filePreview: null });
|
|
273
|
-
}
|
|
274
|
-
await get().refreshDir(parentPath);
|
|
275
|
-
} catch (err) {
|
|
276
|
-
addLog(`Error deleting: ${err instanceof Error ? err.message : String(err)}`);
|
|
277
|
-
}
|
|
278
|
-
},
|
|
244
|
+
createDir: async (dirPath: string, name: string) => {
|
|
245
|
+
const addLog = useLogStore.getState().addLog;
|
|
246
|
+
try {
|
|
247
|
+
await apiClient.call("file.createDir", { dirPath, name });
|
|
248
|
+
addLog(`Created directory: ${name}`);
|
|
249
|
+
set({ editingNode: null });
|
|
250
|
+
await get().refreshDir(dirPath);
|
|
251
|
+
} catch (err) {
|
|
252
|
+
addLog(`Error creating directory: ${err instanceof Error ? err.message : String(err)}`);
|
|
253
|
+
set({ editingNode: null });
|
|
254
|
+
}
|
|
255
|
+
},
|
|
279
256
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
257
|
+
renameNode: async (oldPath: string, newName: string) => {
|
|
258
|
+
const { treeNodes } = get();
|
|
259
|
+
const addLog = useLogStore.getState().addLog;
|
|
260
|
+
try {
|
|
261
|
+
const res = await apiClient.call("file.rename", { oldPath, newName });
|
|
262
|
+
addLog(`Renamed to: ${newName}`);
|
|
263
|
+
set({
|
|
264
|
+
treeNodes: renameInTree(treeNodes, oldPath, res.newPath, newName),
|
|
265
|
+
editingNode: null,
|
|
266
|
+
selectedPath: res.newPath,
|
|
267
|
+
});
|
|
268
|
+
} catch (err) {
|
|
269
|
+
addLog(`Error renaming: ${err instanceof Error ? err.message : String(err)}`);
|
|
270
|
+
set({ editingNode: null });
|
|
271
|
+
}
|
|
272
|
+
},
|
|
296
273
|
|
|
297
|
-
|
|
298
|
-
|
|
274
|
+
deleteNode: async (path: string) => {
|
|
275
|
+
const { treeNodes } = get();
|
|
276
|
+
const addLog = useLogStore.getState().addLog;
|
|
277
|
+
try {
|
|
278
|
+
await apiClient.call("file.delete", { path });
|
|
279
|
+
addLog(`Deleted: ${path}`);
|
|
280
|
+
// Find parent dir to refresh
|
|
281
|
+
const pathParts = path.split("/");
|
|
282
|
+
pathParts.pop();
|
|
283
|
+
const parentPath = pathParts.join("/") || get().currentPath;
|
|
284
|
+
set({ treeNodes: removeNode(treeNodes, path) });
|
|
285
|
+
// Clear preview if the deleted file was being previewed
|
|
286
|
+
const { selectedPath } = get();
|
|
287
|
+
if (selectedPath === path) {
|
|
288
|
+
set({ selectedPath: null, filePreview: null });
|
|
289
|
+
}
|
|
290
|
+
await get().refreshDir(parentPath);
|
|
291
|
+
} catch (err) {
|
|
292
|
+
addLog(`Error deleting: ${err instanceof Error ? err.message : String(err)}`);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
299
295
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
296
|
+
refreshDir: async (dirPath: string) => {
|
|
297
|
+
const { treeNodes, currentPath } = get();
|
|
298
|
+
const addLog = useLogStore.getState().addLog;
|
|
299
|
+
// If refreshing root
|
|
300
|
+
if (dirPath === currentPath) {
|
|
301
|
+
await get().listRootDir();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
const res = await apiClient.call("file.listDir", { path: dirPath });
|
|
306
|
+
const children = entriesToTreeNodes(res.entries);
|
|
307
|
+
set({ treeNodes: loadChildren(treeNodes, dirPath, children) });
|
|
308
|
+
} catch (err) {
|
|
309
|
+
addLog(`Error refreshing: ${err instanceof Error ? err.message : String(err)}`);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
startEditing: (path, type) => set({ editingNode: { path, type } }),
|
|
314
|
+
cancelEditing: () => set({ editingNode: null }),
|
|
315
|
+
|
|
316
|
+
importFiles: async (entries, destDir) => {
|
|
317
|
+
const addLog = useLogStore.getState().addLog;
|
|
318
|
+
const mode = useConnectionStore.getState().mode;
|
|
319
|
+
try {
|
|
320
|
+
const count =
|
|
321
|
+
mode === "desktop"
|
|
322
|
+
? await importFilesDesktop(entries, destDir)
|
|
323
|
+
: await uploadEntriesWeb(entries, destDir);
|
|
324
|
+
addLog(`Imported ${count} items to ${destDir}`);
|
|
325
|
+
await get().refreshDir(destDir);
|
|
326
|
+
return count;
|
|
327
|
+
} catch (err) {
|
|
328
|
+
addLog(`Import error: ${err instanceof Error ? err.message : String(err)}`);
|
|
329
|
+
throw err;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
315
332
|
}));
|
|
@@ -1,32 +1,33 @@
|
|
|
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
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
33
|
export type EditingType = "rename" | "newFile" | "newDir";
|
|
@@ -60,7 +60,7 @@ type RegisterFn = <K extends keyof RPCMethods & string>(
|
|
|
60
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)) {
|