@jingyi0605/codingns 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/bin/codingns.mjs +173 -0
- package/dist/public/assets/TerminalPage-6GBZ9nXN.css +32 -0
- package/dist/public/assets/TerminalPage-Dj_VDew3.js +54 -0
- package/dist/public/assets/index-C1GZV2wq.js +106 -0
- package/dist/public/assets/index-DU7f8NaZ.css +1 -0
- package/dist/public/index.html +13 -0
- package/dist/public/logo.png +0 -0
- package/dist/public/logo.svg +162 -0
- package/dist/server/config/env.d.ts +24 -0
- package/dist/server/config/env.js +152 -0
- package/dist/server/config/env.js.map +1 -0
- package/dist/server/config/opencode-base-url-resolver.d.ts +37 -0
- package/dist/server/config/opencode-base-url-resolver.js +422 -0
- package/dist/server/config/opencode-base-url-resolver.js.map +1 -0
- package/dist/server/main.d.ts +1 -0
- package/dist/server/main.js +3 -0
- package/dist/server/main.js.map +1 -0
- package/dist/server/middlewares/auth-guard.d.ts +4 -0
- package/dist/server/middlewares/auth-guard.js +35 -0
- package/dist/server/middlewares/auth-guard.js.map +1 -0
- package/dist/server/modules/auth/auth-controller.d.ts +15 -0
- package/dist/server/modules/auth/auth-controller.js +20 -0
- package/dist/server/modules/auth/auth-controller.js.map +1 -0
- package/dist/server/modules/auth/auth-service.d.ts +44 -0
- package/dist/server/modules/auth/auth-service.js +151 -0
- package/dist/server/modules/auth/auth-service.js.map +1 -0
- package/dist/server/modules/bootstrap/bootstrap-controller.d.ts +10 -0
- package/dist/server/modules/bootstrap/bootstrap-controller.js +13 -0
- package/dist/server/modules/bootstrap/bootstrap-controller.js.map +1 -0
- package/dist/server/modules/bootstrap/bootstrap-service.d.ts +20 -0
- package/dist/server/modules/bootstrap/bootstrap-service.js +71 -0
- package/dist/server/modules/bootstrap/bootstrap-service.js.map +1 -0
- package/dist/server/modules/client/client-controller.d.ts +9 -0
- package/dist/server/modules/client/client-controller.js +65 -0
- package/dist/server/modules/client/client-controller.js.map +1 -0
- package/dist/server/modules/client/client-service.d.ts +37 -0
- package/dist/server/modules/client/client-service.js +186 -0
- package/dist/server/modules/client/client-service.js.map +1 -0
- package/dist/server/modules/file/file-access-guard.d.ts +27 -0
- package/dist/server/modules/file/file-access-guard.js +99 -0
- package/dist/server/modules/file/file-access-guard.js.map +1 -0
- package/dist/server/modules/file/file-constants.d.ts +6 -0
- package/dist/server/modules/file/file-constants.js +7 -0
- package/dist/server/modules/file/file-constants.js.map +1 -0
- package/dist/server/modules/file/file-content-service.d.ts +65 -0
- package/dist/server/modules/file/file-content-service.js +239 -0
- package/dist/server/modules/file/file-content-service.js.map +1 -0
- package/dist/server/modules/file/file-context-controller.d.ts +29 -0
- package/dist/server/modules/file/file-context-controller.js +52 -0
- package/dist/server/modules/file/file-context-controller.js.map +1 -0
- package/dist/server/modules/file/file-context-service.d.ts +22 -0
- package/dist/server/modules/file/file-context-service.js +90 -0
- package/dist/server/modules/file/file-context-service.js.map +1 -0
- package/dist/server/modules/file/file-controller.d.ts +68 -0
- package/dist/server/modules/file/file-controller.js +111 -0
- package/dist/server/modules/file/file-controller.js.map +1 -0
- package/dist/server/modules/file/file-preview-service.d.ts +19 -0
- package/dist/server/modules/file/file-preview-service.js +60 -0
- package/dist/server/modules/file/file-preview-service.js.map +1 -0
- package/dist/server/modules/file/file-search-service.d.ts +13 -0
- package/dist/server/modules/file/file-search-service.js +62 -0
- package/dist/server/modules/file/file-search-service.js.map +1 -0
- package/dist/server/modules/file/file-tree-service.d.ts +7 -0
- package/dist/server/modules/file/file-tree-service.js +43 -0
- package/dist/server/modules/file/file-tree-service.js.map +1 -0
- package/dist/server/modules/file/file-version-checker.d.ts +10 -0
- package/dist/server/modules/file/file-version-checker.js +30 -0
- package/dist/server/modules/file/file-version-checker.js.map +1 -0
- package/dist/server/modules/file/path-normalizer.d.ts +2 -0
- package/dist/server/modules/file/path-normalizer.js +80 -0
- package/dist/server/modules/file/path-normalizer.js.map +1 -0
- package/dist/server/modules/file/recent-file-service.d.ts +10 -0
- package/dist/server/modules/file/recent-file-service.js +28 -0
- package/dist/server/modules/file/recent-file-service.js.map +1 -0
- package/dist/server/modules/git/commit-draft-service.d.ts +7 -0
- package/dist/server/modules/git/commit-draft-service.js +76 -0
- package/dist/server/modules/git/commit-draft-service.js.map +1 -0
- package/dist/server/modules/git/commit-orchestrator.d.ts +28 -0
- package/dist/server/modules/git/commit-orchestrator.js +47 -0
- package/dist/server/modules/git/commit-orchestrator.js.map +1 -0
- package/dist/server/modules/git/commit-rule-engine.d.ts +5 -0
- package/dist/server/modules/git/commit-rule-engine.js +22 -0
- package/dist/server/modules/git/commit-rule-engine.js.map +1 -0
- package/dist/server/modules/git/git-command-runner.d.ts +16 -0
- package/dist/server/modules/git/git-command-runner.js +102 -0
- package/dist/server/modules/git/git-command-runner.js.map +1 -0
- package/dist/server/modules/git/git-controller.d.ts +104 -0
- package/dist/server/modules/git/git-controller.js +140 -0
- package/dist/server/modules/git/git-controller.js.map +1 -0
- package/dist/server/modules/git/git-read-service.d.ts +15 -0
- package/dist/server/modules/git/git-read-service.js +393 -0
- package/dist/server/modules/git/git-read-service.js.map +1 -0
- package/dist/server/modules/git/git-rule-repository.d.ts +9 -0
- package/dist/server/modules/git/git-rule-repository.js +43 -0
- package/dist/server/modules/git/git-rule-repository.js.map +1 -0
- package/dist/server/modules/git/git-write-service.d.ts +28 -0
- package/dist/server/modules/git/git-write-service.js +330 -0
- package/dist/server/modules/git/git-write-service.js.map +1 -0
- package/dist/server/modules/git/types.d.ts +99 -0
- package/dist/server/modules/git/types.js +2 -0
- package/dist/server/modules/git/types.js.map +1 -0
- package/dist/server/modules/git/workspace-repo-guard.d.ts +17 -0
- package/dist/server/modules/git/workspace-repo-guard.js +124 -0
- package/dist/server/modules/git/workspace-repo-guard.js.map +1 -0
- package/dist/server/modules/preferences/quick-phrase-controller.d.ts +17 -0
- package/dist/server/modules/preferences/quick-phrase-controller.js +37 -0
- package/dist/server/modules/preferences/quick-phrase-controller.js.map +1 -0
- package/dist/server/modules/preferences/quick-phrase-service.d.ts +13 -0
- package/dist/server/modules/preferences/quick-phrase-service.js +67 -0
- package/dist/server/modules/preferences/quick-phrase-service.js.map +1 -0
- package/dist/server/modules/provider/claude-model-options.d.ts +5 -0
- package/dist/server/modules/provider/claude-model-options.js +116 -0
- package/dist/server/modules/provider/claude-model-options.js.map +1 -0
- package/dist/server/modules/provider/codex-model-options.d.ts +23 -0
- package/dist/server/modules/provider/codex-model-options.js +308 -0
- package/dist/server/modules/provider/codex-model-options.js.map +1 -0
- package/dist/server/modules/provider/opencode-model-options.d.ts +30 -0
- package/dist/server/modules/provider/opencode-model-options.js +362 -0
- package/dist/server/modules/provider/opencode-model-options.js.map +1 -0
- package/dist/server/modules/provider/provider-controller.d.ts +33 -0
- package/dist/server/modules/provider/provider-controller.js +50 -0
- package/dist/server/modules/provider/provider-controller.js.map +1 -0
- package/dist/server/modules/sessions/session-activity-inspector.d.ts +10 -0
- package/dist/server/modules/sessions/session-activity-inspector.js +271 -0
- package/dist/server/modules/sessions/session-activity-inspector.js.map +1 -0
- package/dist/server/modules/sessions/session-changed-file-service.d.ts +14 -0
- package/dist/server/modules/sessions/session-changed-file-service.js +175 -0
- package/dist/server/modules/sessions/session-changed-file-service.js.map +1 -0
- package/dist/server/modules/sessions/session-controller.d.ts +134 -0
- package/dist/server/modules/sessions/session-controller.js +253 -0
- package/dist/server/modules/sessions/session-controller.js.map +1 -0
- package/dist/server/modules/sessions/session-history-service.d.ts +128 -0
- package/dist/server/modules/sessions/session-history-service.js +1558 -0
- package/dist/server/modules/sessions/session-history-service.js.map +1 -0
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +191 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +1303 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -0
- package/dist/server/modules/sessions/session-message-attachment-service.d.ts +42 -0
- package/dist/server/modules/sessions/session-message-attachment-service.js +244 -0
- package/dist/server/modules/sessions/session-message-attachment-service.js.map +1 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.d.ts +2 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js +101 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -0
- package/dist/server/modules/terminal/command-template-service.d.ts +48 -0
- package/dist/server/modules/terminal/command-template-service.js +273 -0
- package/dist/server/modules/terminal/command-template-service.js.map +1 -0
- package/dist/server/modules/terminal/runtime/adapters/embedded-pty-runtime-adapter.d.ts +22 -0
- package/dist/server/modules/terminal/runtime/adapters/embedded-pty-runtime-adapter.js +30 -0
- package/dist/server/modules/terminal/runtime/adapters/embedded-pty-runtime-adapter.js.map +1 -0
- package/dist/server/modules/terminal/runtime/adapters/tmux-runtime-adapter.d.ts +31 -0
- package/dist/server/modules/terminal/runtime/adapters/tmux-runtime-adapter.js +199 -0
- package/dist/server/modules/terminal/runtime/adapters/tmux-runtime-adapter.js.map +1 -0
- package/dist/server/modules/terminal/runtime/pty-host-attachment-manager.d.ts +36 -0
- package/dist/server/modules/terminal/runtime/pty-host-attachment-manager.js +141 -0
- package/dist/server/modules/terminal/runtime/pty-host-attachment-manager.js.map +1 -0
- package/dist/server/modules/terminal/runtime/pty-runtime-manager.d.ts +29 -0
- package/dist/server/modules/terminal/runtime/pty-runtime-manager.js +138 -0
- package/dist/server/modules/terminal/runtime/pty-runtime-manager.js.map +1 -0
- package/dist/server/modules/terminal/runtime/terminal-log-file-store.d.ts +14 -0
- package/dist/server/modules/terminal/runtime/terminal-log-file-store.js +47 -0
- package/dist/server/modules/terminal/runtime/terminal-log-file-store.js.map +1 -0
- package/dist/server/modules/terminal/runtime/terminal-log-spooler.d.ts +28 -0
- package/dist/server/modules/terminal/runtime/terminal-log-spooler.js +162 -0
- package/dist/server/modules/terminal/runtime/terminal-log-spooler.js.map +1 -0
- package/dist/server/modules/terminal/runtime/terminal-output-buffer.d.ts +18 -0
- package/dist/server/modules/terminal/runtime/terminal-output-buffer.js +109 -0
- package/dist/server/modules/terminal/runtime/terminal-output-buffer.js.map +1 -0
- package/dist/server/modules/terminal/runtime/terminal-runtime-adapter.d.ts +34 -0
- package/dist/server/modules/terminal/runtime/terminal-runtime-adapter.js +2 -0
- package/dist/server/modules/terminal/runtime/terminal-runtime-adapter.js.map +1 -0
- package/dist/server/modules/terminal/runtime/terminal-runtime-manager.d.ts +41 -0
- package/dist/server/modules/terminal/runtime/terminal-runtime-manager.js +138 -0
- package/dist/server/modules/terminal/runtime/terminal-runtime-manager.js.map +1 -0
- package/dist/server/modules/terminal/template-port-runtime.d.ts +6 -0
- package/dist/server/modules/terminal/template-port-runtime.js +199 -0
- package/dist/server/modules/terminal/template-port-runtime.js.map +1 -0
- package/dist/server/modules/terminal/terminal-controller.d.ts +94 -0
- package/dist/server/modules/terminal/terminal-controller.js +236 -0
- package/dist/server/modules/terminal/terminal-controller.js.map +1 -0
- package/dist/server/modules/terminal/terminal-history.d.ts +18 -0
- package/dist/server/modules/terminal/terminal-history.js +2 -0
- package/dist/server/modules/terminal/terminal-history.js.map +1 -0
- package/dist/server/modules/terminal/terminal-paths.d.ts +1 -0
- package/dist/server/modules/terminal/terminal-paths.js +27 -0
- package/dist/server/modules/terminal/terminal-paths.js.map +1 -0
- package/dist/server/modules/terminal/terminal-service.d.ts +112 -0
- package/dist/server/modules/terminal/terminal-service.js +794 -0
- package/dist/server/modules/terminal/terminal-service.js.map +1 -0
- package/dist/server/modules/terminal/terminal-shell.d.ts +13 -0
- package/dist/server/modules/terminal/terminal-shell.js +293 -0
- package/dist/server/modules/terminal/terminal-shell.js.map +1 -0
- package/dist/server/modules/workbench/workbench-controller.d.ts +7 -0
- package/dist/server/modules/workbench/workbench-controller.js +22 -0
- package/dist/server/modules/workbench/workbench-controller.js.map +1 -0
- package/dist/server/modules/workbench/workbench-service.d.ts +19 -0
- package/dist/server/modules/workbench/workbench-service.js +46 -0
- package/dist/server/modules/workbench/workbench-service.js.map +1 -0
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +65 -0
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +176 -0
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -0
- package/dist/server/modules/workspace/workspace-controller.d.ts +57 -0
- package/dist/server/modules/workspace/workspace-controller.js +38 -0
- package/dist/server/modules/workspace/workspace-controller.js.map +1 -0
- package/dist/server/modules/workspace/workspace-service.d.ts +81 -0
- package/dist/server/modules/workspace/workspace-service.js +659 -0
- package/dist/server/modules/workspace/workspace-service.js.map +1 -0
- package/dist/server/routes/auth.d.ts +3 -0
- package/dist/server/routes/auth.js +6 -0
- package/dist/server/routes/auth.js.map +1 -0
- package/dist/server/routes/client.d.ts +3 -0
- package/dist/server/routes/client.js +6 -0
- package/dist/server/routes/client.js.map +1 -0
- package/dist/server/routes/files.d.ts +3 -0
- package/dist/server/routes/files.js +15 -0
- package/dist/server/routes/files.js.map +1 -0
- package/dist/server/routes/git.d.ts +3 -0
- package/dist/server/routes/git.js +18 -0
- package/dist/server/routes/git.js.map +1 -0
- package/dist/server/routes/preferences.d.ts +3 -0
- package/dist/server/routes/preferences.js +5 -0
- package/dist/server/routes/preferences.js.map +1 -0
- package/dist/server/routes/providers.d.ts +3 -0
- package/dist/server/routes/providers.js +6 -0
- package/dist/server/routes/providers.js.map +1 -0
- package/dist/server/routes/public.d.ts +3 -0
- package/dist/server/routes/public.js +5 -0
- package/dist/server/routes/public.js.map +1 -0
- package/dist/server/routes/session-contexts.d.ts +3 -0
- package/dist/server/routes/session-contexts.js +6 -0
- package/dist/server/routes/session-contexts.js.map +1 -0
- package/dist/server/routes/sessions.d.ts +3 -0
- package/dist/server/routes/sessions.js +24 -0
- package/dist/server/routes/sessions.js.map +1 -0
- package/dist/server/routes/terminals.d.ts +3 -0
- package/dist/server/routes/terminals.js +17 -0
- package/dist/server/routes/terminals.js.map +1 -0
- package/dist/server/routes/workbench.d.ts +3 -0
- package/dist/server/routes/workbench.js +4 -0
- package/dist/server/routes/workbench.js.map +1 -0
- package/dist/server/routes/workspaces.d.ts +3 -0
- package/dist/server/routes/workspaces.js +10 -0
- package/dist/server/routes/workspaces.js.map +1 -0
- package/dist/server/server/create-server.d.ts +103 -0
- package/dist/server/server/create-server.js +259 -0
- package/dist/server/server/create-server.js.map +1 -0
- package/dist/server/server/start-host.d.ts +8 -0
- package/dist/server/server/start-host.js +40 -0
- package/dist/server/server/start-host.js.map +1 -0
- package/dist/server/server/static-web.d.ts +2 -0
- package/dist/server/server/static-web.js +75 -0
- package/dist/server/server/static-web.js.map +1 -0
- package/dist/server/shared/errors/app-error.d.ts +13 -0
- package/dist/server/shared/errors/app-error.js +16 -0
- package/dist/server/shared/errors/app-error.js.map +1 -0
- package/dist/server/shared/http/error-handler.d.ts +9 -0
- package/dist/server/shared/http/error-handler.js +25 -0
- package/dist/server/shared/http/error-handler.js.map +1 -0
- package/dist/server/shared/utils/hash.d.ts +4 -0
- package/dist/server/shared/utils/hash.js +27 -0
- package/dist/server/shared/utils/hash.js.map +1 -0
- package/dist/server/shared/utils/id.d.ts +1 -0
- package/dist/server/shared/utils/id.js +5 -0
- package/dist/server/shared/utils/id.js.map +1 -0
- package/dist/server/shared/utils/perf-log.d.ts +6 -0
- package/dist/server/shared/utils/perf-log.js +40 -0
- package/dist/server/shared/utils/perf-log.js.map +1 -0
- package/dist/server/shared/utils/time.d.ts +2 -0
- package/dist/server/shared/utils/time.js +7 -0
- package/dist/server/shared/utils/time.js.map +1 -0
- package/dist/server/shared/utils/tokens.d.ts +1 -0
- package/dist/server/shared/utils/tokens.js +5 -0
- package/dist/server/shared/utils/tokens.js.map +1 -0
- package/dist/server/storage/repositories/auth-token-repository.d.ts +9 -0
- package/dist/server/storage/repositories/auth-token-repository.js +45 -0
- package/dist/server/storage/repositories/auth-token-repository.js.map +1 -0
- package/dist/server/storage/repositories/auth-user-repository.d.ts +11 -0
- package/dist/server/storage/repositories/auth-user-repository.js +61 -0
- package/dist/server/storage/repositories/auth-user-repository.js.map +1 -0
- package/dist/server/storage/repositories/bootstrap-state-repository.d.ts +8 -0
- package/dist/server/storage/repositories/bootstrap-state-repository.js +29 -0
- package/dist/server/storage/repositories/bootstrap-state-repository.js.map +1 -0
- package/dist/server/storage/repositories/commit-rule-profile-repository.d.ts +8 -0
- package/dist/server/storage/repositories/commit-rule-profile-repository.js +48 -0
- package/dist/server/storage/repositories/commit-rule-profile-repository.js.map +1 -0
- package/dist/server/storage/repositories/file-context-binding-repository.d.ts +12 -0
- package/dist/server/storage/repositories/file-context-binding-repository.js +130 -0
- package/dist/server/storage/repositories/file-context-binding-repository.js.map +1 -0
- package/dist/server/storage/repositories/recent-file-repository.d.ts +10 -0
- package/dist/server/storage/repositories/recent-file-repository.js +64 -0
- package/dist/server/storage/repositories/recent-file-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-binding-repository.d.ts +10 -0
- package/dist/server/storage/repositories/session-binding-repository.js +63 -0
- package/dist/server/storage/repositories/session-binding-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-changed-file-repository.d.ts +11 -0
- package/dist/server/storage/repositories/session-changed-file-repository.js +94 -0
- package/dist/server/storage/repositories/session-changed-file-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-index-repository.d.ts +11 -0
- package/dist/server/storage/repositories/session-index-repository.js +200 -0
- package/dist/server/storage/repositories/session-index-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-message-attachment-repository.d.ts +13 -0
- package/dist/server/storage/repositories/session-message-attachment-repository.js +139 -0
- package/dist/server/storage/repositories/session-message-attachment-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-send-queue-repository.d.ts +15 -0
- package/dist/server/storage/repositories/session-send-queue-repository.js +165 -0
- package/dist/server/storage/repositories/session-send-queue-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-state-repository.d.ts +8 -0
- package/dist/server/storage/repositories/session-state-repository.js +60 -0
- package/dist/server/storage/repositories/session-state-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-status-snapshot-repository.d.ts +8 -0
- package/dist/server/storage/repositories/session-status-snapshot-repository.js +49 -0
- package/dist/server/storage/repositories/session-status-snapshot-repository.js.map +1 -0
- package/dist/server/storage/repositories/terminal-command-template-repository.d.ts +11 -0
- package/dist/server/storage/repositories/terminal-command-template-repository.js +99 -0
- package/dist/server/storage/repositories/terminal-command-template-repository.js.map +1 -0
- package/dist/server/storage/repositories/terminal-instance-repository.d.ts +23 -0
- package/dist/server/storage/repositories/terminal-instance-repository.js +149 -0
- package/dist/server/storage/repositories/terminal-instance-repository.js.map +1 -0
- package/dist/server/storage/repositories/terminal-log-file-repository.d.ts +20 -0
- package/dist/server/storage/repositories/terminal-log-file-repository.js +106 -0
- package/dist/server/storage/repositories/terminal-log-file-repository.js.map +1 -0
- package/dist/server/storage/repositories/terminal-log-segment-repository.d.ts +11 -0
- package/dist/server/storage/repositories/terminal-log-segment-repository.js +110 -0
- package/dist/server/storage/repositories/terminal-log-segment-repository.js.map +1 -0
- package/dist/server/storage/repositories/terminal-runtime-session-repository.d.ts +24 -0
- package/dist/server/storage/repositories/terminal-runtime-session-repository.js +134 -0
- package/dist/server/storage/repositories/terminal-runtime-session-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-quick-phrase-preference-repository.d.ts +8 -0
- package/dist/server/storage/repositories/user-quick-phrase-preference-repository.js +37 -0
- package/dist/server/storage/repositories/user-quick-phrase-preference-repository.js.map +1 -0
- package/dist/server/storage/repositories/workspace-repository.d.ts +16 -0
- package/dist/server/storage/repositories/workspace-repository.js +71 -0
- package/dist/server/storage/repositories/workspace-repository.js.map +1 -0
- package/dist/server/storage/sqlite/client.d.ts +6 -0
- package/dist/server/storage/sqlite/client.js +446 -0
- package/dist/server/storage/sqlite/client.js.map +1 -0
- package/dist/server/storage/sqlite/schema.sql +357 -0
- package/dist/server/types/domain.d.ts +306 -0
- package/dist/server/types/domain.js +2 -0
- package/dist/server/types/domain.js.map +1 -0
- package/dist/server/ws/terminal-ws-hub.d.ts +32 -0
- package/dist/server/ws/terminal-ws-hub.js +181 -0
- package/dist/server/ws/terminal-ws-hub.js.map +1 -0
- package/dist/server/ws/workbench-ws-hub.d.ts +30 -0
- package/dist/server/ws/workbench-ws-hub.js +480 -0
- package/dist/server/ws/workbench-ws-hub.js.map +1 -0
- package/dist/server/ws/ws-auth-guard.d.ts +7 -0
- package/dist/server/ws/ws-auth-guard.js +28 -0
- package/dist/server/ws/ws-auth-guard.js.map +1 -0
- package/dist/server/ws/ws-server.d.ts +11 -0
- package/dist/server/ws/ws-server.js +218 -0
- package/dist/server/ws/ws-server.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +36 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +213 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/index.d.ts +12 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js +13 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +30 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +567 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +41 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +1365 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +41 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +280 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +53 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +745 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.d.ts +25 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js +284 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.d.ts +7 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.js +22 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +18 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +236 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +21 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +732 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +16 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +26 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +892 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.d.ts +31 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +626 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.d.ts +18 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +148 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +141 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/services.d.ts +26 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js +85 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +159 -0
- package/node_modules/@codingns/session-sync-core/dist/types.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/package.json +25 -0
- package/package.json +34 -0
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { AppError, isAppError } from "../../shared/errors/app-error.js";
|
|
5
|
+
import { createId } from "../../shared/utils/id.js";
|
|
6
|
+
import { nowIso } from "../../shared/utils/time.js";
|
|
7
|
+
const DIRECTORY_BROWSE_LIMIT = 200;
|
|
8
|
+
const GIT_CLONE_TIMEOUT_MS = 120_000;
|
|
9
|
+
const WORKSPACE_CODE_SCAN_LIMIT = 20_000;
|
|
10
|
+
const IGNORED_COMPOSITION_DIRECTORIES = new Set([
|
|
11
|
+
".git",
|
|
12
|
+
".idea",
|
|
13
|
+
".vscode",
|
|
14
|
+
".yarn",
|
|
15
|
+
".pnpm-store",
|
|
16
|
+
".turbo",
|
|
17
|
+
"node_modules",
|
|
18
|
+
"dist",
|
|
19
|
+
"build",
|
|
20
|
+
"coverage",
|
|
21
|
+
".next",
|
|
22
|
+
".nuxt",
|
|
23
|
+
"out",
|
|
24
|
+
"target",
|
|
25
|
+
"vendor",
|
|
26
|
+
"bin",
|
|
27
|
+
"obj"
|
|
28
|
+
]);
|
|
29
|
+
const COMPOSITION_TYPE_BY_NAME = {
|
|
30
|
+
dockerfile: "Dockerfile",
|
|
31
|
+
makefile: "Makefile",
|
|
32
|
+
justfile: "Justfile"
|
|
33
|
+
};
|
|
34
|
+
const COMPOSITION_TYPE_BY_EXTENSION = {
|
|
35
|
+
".ts": "TypeScript",
|
|
36
|
+
".tsx": "TypeScript",
|
|
37
|
+
".mts": "TypeScript",
|
|
38
|
+
".cts": "TypeScript",
|
|
39
|
+
".js": "JavaScript",
|
|
40
|
+
".jsx": "JavaScript",
|
|
41
|
+
".mjs": "JavaScript",
|
|
42
|
+
".cjs": "JavaScript",
|
|
43
|
+
".vue": "Vue",
|
|
44
|
+
".svelte": "Svelte",
|
|
45
|
+
".css": "CSS",
|
|
46
|
+
".scss": "SCSS",
|
|
47
|
+
".sass": "Sass",
|
|
48
|
+
".less": "Less",
|
|
49
|
+
".html": "HTML",
|
|
50
|
+
".xml": "XML",
|
|
51
|
+
".json": "JSON",
|
|
52
|
+
".jsonc": "JSON",
|
|
53
|
+
".yaml": "YAML",
|
|
54
|
+
".yml": "YAML",
|
|
55
|
+
".toml": "TOML",
|
|
56
|
+
".md": "Markdown",
|
|
57
|
+
".mdx": "Markdown",
|
|
58
|
+
".sh": "Shell",
|
|
59
|
+
".bash": "Shell",
|
|
60
|
+
".zsh": "Shell",
|
|
61
|
+
".ps1": "PowerShell",
|
|
62
|
+
".bat": "Batch",
|
|
63
|
+
".cmd": "Batch",
|
|
64
|
+
".py": "Python",
|
|
65
|
+
".go": "Go",
|
|
66
|
+
".rs": "Rust",
|
|
67
|
+
".java": "Java",
|
|
68
|
+
".kt": "Kotlin",
|
|
69
|
+
".kts": "Kotlin",
|
|
70
|
+
".swift": "Swift",
|
|
71
|
+
".php": "PHP",
|
|
72
|
+
".rb": "Ruby",
|
|
73
|
+
".sql": "SQL",
|
|
74
|
+
".c": "C",
|
|
75
|
+
".h": "C/C++ Header",
|
|
76
|
+
".cc": "C++",
|
|
77
|
+
".cpp": "C++",
|
|
78
|
+
".cxx": "C++",
|
|
79
|
+
".hpp": "C++ Header",
|
|
80
|
+
".cs": "C#"
|
|
81
|
+
};
|
|
82
|
+
export class WorkspaceService {
|
|
83
|
+
workspaceRepository;
|
|
84
|
+
gitCommandRunner;
|
|
85
|
+
constructor(workspaceRepository, gitCommandRunner) {
|
|
86
|
+
this.workspaceRepository = workspaceRepository;
|
|
87
|
+
this.gitCommandRunner = gitCommandRunner;
|
|
88
|
+
}
|
|
89
|
+
browseDirectories(requestedPath) {
|
|
90
|
+
const roots = listDirectoryRoots();
|
|
91
|
+
const fallbackPath = resolveDefaultBrowsePath(roots);
|
|
92
|
+
const currentPath = resolveBrowsePath(requestedPath, fallbackPath);
|
|
93
|
+
ensureExistingDirectory(currentPath, "path");
|
|
94
|
+
return {
|
|
95
|
+
currentPath,
|
|
96
|
+
parentPath: resolveParentPath(currentPath),
|
|
97
|
+
roots,
|
|
98
|
+
items: fs
|
|
99
|
+
.readdirSync(currentPath, {
|
|
100
|
+
withFileTypes: true
|
|
101
|
+
})
|
|
102
|
+
.filter((entry) => entry.isDirectory() && !entry.isSymbolicLink())
|
|
103
|
+
.slice(0, DIRECTORY_BROWSE_LIMIT)
|
|
104
|
+
.map((entry) => ({
|
|
105
|
+
path: path.join(currentPath, entry.name),
|
|
106
|
+
name: entry.name
|
|
107
|
+
}))
|
|
108
|
+
.sort((left, right) => left.name.localeCompare(right.name))
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
createDirectory(parentPath, directoryName) {
|
|
112
|
+
const normalizedParentPath = parentPath.trim();
|
|
113
|
+
if (!normalizedParentPath) {
|
|
114
|
+
throw new AppError({
|
|
115
|
+
statusCode: 400,
|
|
116
|
+
errorCode: "INVALID_INPUT",
|
|
117
|
+
detail: "父目录不能为空",
|
|
118
|
+
field: "parentPath"
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const resolvedParentPath = path.resolve(normalizedParentPath);
|
|
122
|
+
ensureExistingDirectory(resolvedParentPath, "parentPath");
|
|
123
|
+
const normalizedDirectoryName = normalizeSingleDirectoryName(directoryName, "directoryName");
|
|
124
|
+
const targetPath = path.join(resolvedParentPath, normalizedDirectoryName);
|
|
125
|
+
if (fs.existsSync(targetPath)) {
|
|
126
|
+
throw new AppError({
|
|
127
|
+
statusCode: 409,
|
|
128
|
+
errorCode: "WORKSPACE_DIRECTORY_EXISTS",
|
|
129
|
+
detail: "目标目录已经存在",
|
|
130
|
+
field: "directoryName"
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
fs.mkdirSync(targetPath);
|
|
134
|
+
return {
|
|
135
|
+
path: targetPath,
|
|
136
|
+
name: normalizedDirectoryName
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
importWorkspace(workspacePath, name) {
|
|
140
|
+
const resolvedPath = path.resolve(workspacePath);
|
|
141
|
+
ensureExistingDirectory(resolvedPath, "path");
|
|
142
|
+
return createWorkspaceRecord(this.workspaceRepository, resolvedPath, name);
|
|
143
|
+
}
|
|
144
|
+
async cloneWorkspace(input) {
|
|
145
|
+
const repositoryUrl = input.repositoryUrl.trim();
|
|
146
|
+
if (!repositoryUrl) {
|
|
147
|
+
throw new AppError({
|
|
148
|
+
statusCode: 400,
|
|
149
|
+
errorCode: "INVALID_INPUT",
|
|
150
|
+
detail: "Git 仓库地址不能为空",
|
|
151
|
+
field: "repositoryUrl"
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const parentPath = path.resolve(input.parentPath);
|
|
155
|
+
ensureExistingDirectory(parentPath, "parentPath");
|
|
156
|
+
const directoryName = normalizeCloneDirectoryName(input.directoryName, repositoryUrl);
|
|
157
|
+
const targetPath = path.join(parentPath, directoryName);
|
|
158
|
+
if (fs.existsSync(targetPath)) {
|
|
159
|
+
throw new AppError({
|
|
160
|
+
statusCode: 409,
|
|
161
|
+
errorCode: "WORKSPACE_TARGET_EXISTS",
|
|
162
|
+
detail: "目标路径已经存在,不能直接覆盖克隆",
|
|
163
|
+
field: "directoryName"
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const authContext = createGitAuthContext(input.auth);
|
|
167
|
+
try {
|
|
168
|
+
await this.gitCommandRunner.run(parentPath, ["clone", repositoryUrl, directoryName], {
|
|
169
|
+
timeoutMs: GIT_CLONE_TIMEOUT_MS,
|
|
170
|
+
env: authContext?.env,
|
|
171
|
+
operation: "workspace.cloneWorkspace"
|
|
172
|
+
});
|
|
173
|
+
return this.importWorkspace(targetPath, input.name?.trim());
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (fs.existsSync(targetPath)) {
|
|
177
|
+
// clone 失败会留下半成品目录,直接清掉,避免下一次重试被脏状态卡死。
|
|
178
|
+
fs.rmSync(targetPath, { recursive: true, force: true });
|
|
179
|
+
}
|
|
180
|
+
throw mapCloneError(error);
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
authContext?.cleanup();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
list() {
|
|
187
|
+
return this.workspaceRepository.list();
|
|
188
|
+
}
|
|
189
|
+
removeWorkspace(workspaceId) {
|
|
190
|
+
const workspace = this.getWorkspaceOrThrow(workspaceId);
|
|
191
|
+
const timestamp = nowIso();
|
|
192
|
+
return (this.workspaceRepository.markRemoved(workspace.id, timestamp, timestamp) ?? {
|
|
193
|
+
...workspace,
|
|
194
|
+
updatedAt: timestamp,
|
|
195
|
+
removedAt: timestamp
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
async getManagementSummary(workspaceId) {
|
|
199
|
+
const workspace = this.getWorkspaceOrThrow(workspaceId);
|
|
200
|
+
const [git, codeComposition] = await Promise.all([
|
|
201
|
+
this.readGitSummary(workspace),
|
|
202
|
+
Promise.resolve(readWorkspaceCodeComposition(workspace.path))
|
|
203
|
+
]);
|
|
204
|
+
return {
|
|
205
|
+
workspaceId: workspace.id,
|
|
206
|
+
name: workspace.name,
|
|
207
|
+
path: workspace.path,
|
|
208
|
+
git,
|
|
209
|
+
codeComposition
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
getWorkspaceOrThrow(workspaceId) {
|
|
213
|
+
const workspace = this.workspaceRepository.findById(workspaceId);
|
|
214
|
+
if (!workspace) {
|
|
215
|
+
throw new AppError({
|
|
216
|
+
statusCode: 404,
|
|
217
|
+
errorCode: "WORKSPACE_NOT_FOUND",
|
|
218
|
+
detail: "指定工作区不存在"
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return workspace;
|
|
222
|
+
}
|
|
223
|
+
findWorkspaceByPath(workspacePath) {
|
|
224
|
+
return this.workspaceRepository.findByPath(path.resolve(workspacePath));
|
|
225
|
+
}
|
|
226
|
+
async readGitSummary(workspace) {
|
|
227
|
+
const workspacePath = path.resolve(workspace.path);
|
|
228
|
+
if (!fs.existsSync(workspacePath) || !fs.statSync(workspacePath).isDirectory()) {
|
|
229
|
+
return {
|
|
230
|
+
isRepository: false,
|
|
231
|
+
repoRoot: null,
|
|
232
|
+
currentBranch: null,
|
|
233
|
+
commitCount: null,
|
|
234
|
+
remotes: [],
|
|
235
|
+
error: "工作区路径不存在,Git 信息不可用"
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
const repoRootResult = await this.gitCommandRunner.run(workspacePath, ["rev-parse", "--show-toplevel"], {
|
|
240
|
+
allowNonZeroExit: true,
|
|
241
|
+
workspaceId: workspace.id,
|
|
242
|
+
operation: "workspace.readGitSummary"
|
|
243
|
+
});
|
|
244
|
+
if (repoRootResult.exitCode !== 0) {
|
|
245
|
+
return {
|
|
246
|
+
isRepository: false,
|
|
247
|
+
repoRoot: null,
|
|
248
|
+
currentBranch: null,
|
|
249
|
+
commitCount: null,
|
|
250
|
+
remotes: [],
|
|
251
|
+
error: "当前工作区不是 Git 仓库"
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const repoRoot = repoRootResult.stdout.trim();
|
|
255
|
+
if (!repoRoot) {
|
|
256
|
+
return {
|
|
257
|
+
isRepository: false,
|
|
258
|
+
repoRoot: null,
|
|
259
|
+
currentBranch: null,
|
|
260
|
+
commitCount: null,
|
|
261
|
+
remotes: [],
|
|
262
|
+
error: "Git 仓库根目录解析失败"
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const [branchResult, commitCountResult, remoteResult] = await Promise.all([
|
|
266
|
+
this.gitCommandRunner.run(repoRoot, ["branch", "--show-current"], {
|
|
267
|
+
allowNonZeroExit: true,
|
|
268
|
+
workspaceId: workspace.id,
|
|
269
|
+
operation: "workspace.readGitSummary"
|
|
270
|
+
}),
|
|
271
|
+
this.gitCommandRunner.run(repoRoot, ["rev-list", "--count", "--all"], {
|
|
272
|
+
allowNonZeroExit: true,
|
|
273
|
+
workspaceId: workspace.id,
|
|
274
|
+
operation: "workspace.readGitSummary"
|
|
275
|
+
}),
|
|
276
|
+
this.gitCommandRunner.run(repoRoot, ["remote", "-v"], {
|
|
277
|
+
allowNonZeroExit: true,
|
|
278
|
+
workspaceId: workspace.id,
|
|
279
|
+
operation: "workspace.readGitSummary"
|
|
280
|
+
})
|
|
281
|
+
]);
|
|
282
|
+
return {
|
|
283
|
+
isRepository: true,
|
|
284
|
+
repoRoot,
|
|
285
|
+
currentBranch: normalizeGitOutput(branchResult.stdout),
|
|
286
|
+
commitCount: parseGitCommitCount(commitCountResult.stdout),
|
|
287
|
+
remotes: parseGitRemotes(remoteResult.stdout),
|
|
288
|
+
error: null
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
return {
|
|
293
|
+
isRepository: false,
|
|
294
|
+
repoRoot: null,
|
|
295
|
+
currentBranch: null,
|
|
296
|
+
commitCount: null,
|
|
297
|
+
remotes: [],
|
|
298
|
+
error: mapWorkspaceGitSummaryError(error)
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function createWorkspaceRecord(workspaceRepository, workspacePath, name) {
|
|
304
|
+
const existing = workspaceRepository.findByPath(workspacePath);
|
|
305
|
+
if (existing) {
|
|
306
|
+
if (!existing.removedAt) {
|
|
307
|
+
return existing;
|
|
308
|
+
}
|
|
309
|
+
const timestamp = nowIso();
|
|
310
|
+
return (workspaceRepository.restore(existing.id, {
|
|
311
|
+
name: name?.trim() || undefined,
|
|
312
|
+
repoRoot: workspacePath,
|
|
313
|
+
updatedAt: timestamp
|
|
314
|
+
}) ?? {
|
|
315
|
+
...existing,
|
|
316
|
+
name: name?.trim() || existing.name,
|
|
317
|
+
repoRoot: workspacePath,
|
|
318
|
+
updatedAt: timestamp,
|
|
319
|
+
removedAt: null
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
const timestamp = nowIso();
|
|
323
|
+
return workspaceRepository.create({
|
|
324
|
+
id: createId(),
|
|
325
|
+
name: name?.trim() || path.basename(workspacePath),
|
|
326
|
+
path: workspacePath,
|
|
327
|
+
repoRoot: workspacePath,
|
|
328
|
+
favorite: false,
|
|
329
|
+
createdAt: timestamp,
|
|
330
|
+
updatedAt: timestamp,
|
|
331
|
+
removedAt: null
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function ensureExistingDirectory(targetPath, field) {
|
|
335
|
+
if (!fs.existsSync(targetPath)) {
|
|
336
|
+
throw new AppError({
|
|
337
|
+
statusCode: 400,
|
|
338
|
+
errorCode: "INVALID_WORKSPACE_PATH",
|
|
339
|
+
detail: "工作区路径不存在",
|
|
340
|
+
field
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
if (!fs.statSync(targetPath).isDirectory()) {
|
|
344
|
+
throw new AppError({
|
|
345
|
+
statusCode: 400,
|
|
346
|
+
errorCode: "INVALID_WORKSPACE_PATH",
|
|
347
|
+
detail: "工作区路径必须是目录",
|
|
348
|
+
field
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function normalizeCloneDirectoryName(directoryName, repositoryUrl) {
|
|
353
|
+
const rawValue = directoryName?.trim() || deriveDirectoryNameFromRepository(repositoryUrl);
|
|
354
|
+
return normalizeSingleDirectoryName(rawValue, "directoryName");
|
|
355
|
+
}
|
|
356
|
+
function deriveDirectoryNameFromRepository(repositoryUrl) {
|
|
357
|
+
const normalized = repositoryUrl.trim().replace(/\\/g, "/").replace(/[\/]+$/, "");
|
|
358
|
+
const lastSlashIndex = Math.max(normalized.lastIndexOf("/"), normalized.lastIndexOf(":"));
|
|
359
|
+
const rawName = lastSlashIndex >= 0 ? normalized.slice(lastSlashIndex + 1) : normalized;
|
|
360
|
+
return rawName.replace(/\.git$/i, "");
|
|
361
|
+
}
|
|
362
|
+
function normalizeSingleDirectoryName(rawValue, field) {
|
|
363
|
+
const normalized = rawValue?.trim() || "";
|
|
364
|
+
if (!normalized) {
|
|
365
|
+
throw new AppError({
|
|
366
|
+
statusCode: 400,
|
|
367
|
+
errorCode: "INVALID_INPUT",
|
|
368
|
+
detail: "目标目录名不能为空",
|
|
369
|
+
field
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
if (normalized === "." ||
|
|
373
|
+
normalized === ".." ||
|
|
374
|
+
normalized.startsWith("-") ||
|
|
375
|
+
normalized.includes("/") ||
|
|
376
|
+
normalized.includes("\\") ||
|
|
377
|
+
path.isAbsolute(normalized)) {
|
|
378
|
+
throw new AppError({
|
|
379
|
+
statusCode: 400,
|
|
380
|
+
errorCode: "INVALID_INPUT",
|
|
381
|
+
detail: "目标目录名无效,必须是单层目录名",
|
|
382
|
+
field
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return normalized;
|
|
386
|
+
}
|
|
387
|
+
function createGitAuthContext(auth) {
|
|
388
|
+
if (!auth || !auth.mode || auth.mode === "none") {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
const mode = auth.mode;
|
|
392
|
+
let username = "";
|
|
393
|
+
let secret = "";
|
|
394
|
+
if (auth.mode === "basic") {
|
|
395
|
+
username = auth.username?.trim() || "";
|
|
396
|
+
secret = auth.password?.trim() || "";
|
|
397
|
+
}
|
|
398
|
+
else if (auth.mode === "token") {
|
|
399
|
+
username = auth.username?.trim() || "git";
|
|
400
|
+
secret = auth.token?.trim() || "";
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
if (!username) {
|
|
406
|
+
throw new AppError({
|
|
407
|
+
statusCode: 400,
|
|
408
|
+
errorCode: "INVALID_INPUT",
|
|
409
|
+
detail: "Git 用户名不能为空",
|
|
410
|
+
field: "username"
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
if (!secret) {
|
|
414
|
+
throw new AppError({
|
|
415
|
+
statusCode: 400,
|
|
416
|
+
errorCode: "INVALID_INPUT",
|
|
417
|
+
detail: mode === "basic" ? "Git 密码不能为空" : "Git token 不能为空",
|
|
418
|
+
field: mode === "basic" ? "password" : "token"
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "codingns-git-auth-"));
|
|
422
|
+
const helperRuntimePath = path.join(tempDir, "askpass.cjs");
|
|
423
|
+
const helperScriptPath = path.join(tempDir, process.platform === "win32" ? "askpass.cmd" : "askpass.sh");
|
|
424
|
+
fs.writeFileSync(helperRuntimePath, [
|
|
425
|
+
'const prompt = (process.argv.slice(2).join(" ") || "").toLowerCase();',
|
|
426
|
+
'const username = process.env.CODINGNS_GIT_AUTH_USERNAME || "";',
|
|
427
|
+
'const secret = process.env.CODINGNS_GIT_AUTH_SECRET || "";',
|
|
428
|
+
'if (prompt.includes("username")) {',
|
|
429
|
+
" process.stdout.write(username);",
|
|
430
|
+
'} else if (prompt.includes("password") || prompt.includes("passphrase")) {',
|
|
431
|
+
" process.stdout.write(secret);",
|
|
432
|
+
"} else {",
|
|
433
|
+
" process.stdout.write(secret || username);",
|
|
434
|
+
"}"
|
|
435
|
+
].join("\n"), "utf8");
|
|
436
|
+
if (process.platform === "win32") {
|
|
437
|
+
fs.writeFileSync(helperScriptPath, '@echo off\r\n"%CODINGNS_GIT_NODE%" "%~dp0askpass.cjs" %*\r\n', "utf8");
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
fs.writeFileSync(helperScriptPath, '#!/bin/sh\n"$CODINGNS_GIT_NODE" "$(dirname "$0")/askpass.cjs" "$@"\n', "utf8");
|
|
441
|
+
fs.chmodSync(helperScriptPath, 0o755);
|
|
442
|
+
}
|
|
443
|
+
return {
|
|
444
|
+
env: {
|
|
445
|
+
CODINGNS_GIT_NODE: process.execPath,
|
|
446
|
+
CODINGNS_GIT_AUTH_USERNAME: username,
|
|
447
|
+
CODINGNS_GIT_AUTH_SECRET: secret,
|
|
448
|
+
GIT_ASKPASS: helperScriptPath,
|
|
449
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
450
|
+
GCM_INTERACTIVE: "Never"
|
|
451
|
+
},
|
|
452
|
+
cleanup: () => {
|
|
453
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
function mapCloneError(error) {
|
|
458
|
+
if (isAppError(error)) {
|
|
459
|
+
if (error.errorCode === "GIT_COMMAND_FAILED") {
|
|
460
|
+
return mapGitCloneCommandError(error.message);
|
|
461
|
+
}
|
|
462
|
+
return error;
|
|
463
|
+
}
|
|
464
|
+
return mapGitCloneCommandError(error instanceof Error ? error.message : "Git clone 失败");
|
|
465
|
+
}
|
|
466
|
+
function mapGitCloneCommandError(detail) {
|
|
467
|
+
if (/authentication failed|fatal: could not read Username|fatal: could not read Password|permission denied/i.test(detail)) {
|
|
468
|
+
return new AppError({
|
|
469
|
+
statusCode: 401,
|
|
470
|
+
errorCode: "GIT_CLONE_AUTH_FAILED",
|
|
471
|
+
detail: "Git 仓库认证失败,请检查用户名、密码或 token"
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
if (/unable to access|failed to connect|connection timed out|operation timed out|could not resolve host|network is unreachable|connection reset/i.test(detail)) {
|
|
475
|
+
return new AppError({
|
|
476
|
+
statusCode: 502,
|
|
477
|
+
errorCode: "GIT_CLONE_NETWORK_FAILED",
|
|
478
|
+
detail: "连接 Git 仓库失败,请检查网络或仓库地址"
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
if (/repository .* not found|remote branch .* not found|repository not found|not found/i.test(detail)) {
|
|
482
|
+
return new AppError({
|
|
483
|
+
statusCode: 404,
|
|
484
|
+
errorCode: "GIT_REPOSITORY_NOT_FOUND",
|
|
485
|
+
detail: "Git 仓库不存在,或当前账号没有访问权限"
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
return new AppError({
|
|
489
|
+
statusCode: 500,
|
|
490
|
+
errorCode: "GIT_CLONE_FAILED",
|
|
491
|
+
detail: detail.trim() || "Git clone 失败"
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
function mapWorkspaceGitSummaryError(error) {
|
|
495
|
+
if (isAppError(error)) {
|
|
496
|
+
if (error.errorCode === "GIT_COMMAND_TIMEOUT") {
|
|
497
|
+
return "Git 信息读取超时,请稍后重试";
|
|
498
|
+
}
|
|
499
|
+
return error.message;
|
|
500
|
+
}
|
|
501
|
+
if (error instanceof Error && error.message.trim()) {
|
|
502
|
+
return error.message;
|
|
503
|
+
}
|
|
504
|
+
return "Git 信息读取失败";
|
|
505
|
+
}
|
|
506
|
+
function listDirectoryRoots() {
|
|
507
|
+
if (process.platform === "win32") {
|
|
508
|
+
const driveLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
509
|
+
return driveLetters
|
|
510
|
+
.map((letter) => `${letter}:\\`)
|
|
511
|
+
.filter((rootPath) => fs.existsSync(rootPath))
|
|
512
|
+
.map((rootPath) => ({
|
|
513
|
+
path: rootPath,
|
|
514
|
+
name: rootPath
|
|
515
|
+
}));
|
|
516
|
+
}
|
|
517
|
+
return [
|
|
518
|
+
{
|
|
519
|
+
path: "/",
|
|
520
|
+
name: "/"
|
|
521
|
+
}
|
|
522
|
+
];
|
|
523
|
+
}
|
|
524
|
+
function resolveDefaultBrowsePath(roots) {
|
|
525
|
+
const homePath = os.homedir();
|
|
526
|
+
if (homePath && fs.existsSync(homePath) && fs.statSync(homePath).isDirectory()) {
|
|
527
|
+
return path.resolve(homePath);
|
|
528
|
+
}
|
|
529
|
+
if (roots[0]?.path) {
|
|
530
|
+
return roots[0].path;
|
|
531
|
+
}
|
|
532
|
+
return path.resolve(process.cwd());
|
|
533
|
+
}
|
|
534
|
+
function resolveBrowsePath(requestedPath, fallbackPath) {
|
|
535
|
+
const trimmedPath = requestedPath?.trim();
|
|
536
|
+
if (!trimmedPath) {
|
|
537
|
+
return fallbackPath;
|
|
538
|
+
}
|
|
539
|
+
return path.resolve(trimmedPath);
|
|
540
|
+
}
|
|
541
|
+
function resolveParentPath(currentPath) {
|
|
542
|
+
const parentPath = path.dirname(currentPath);
|
|
543
|
+
const currentRoot = path.parse(currentPath).root;
|
|
544
|
+
if (parentPath === currentPath || currentPath === currentRoot) {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
return parentPath;
|
|
548
|
+
}
|
|
549
|
+
function readWorkspaceCodeComposition(workspacePath) {
|
|
550
|
+
const resolvedPath = path.resolve(workspacePath);
|
|
551
|
+
if (!fs.existsSync(resolvedPath) || !fs.statSync(resolvedPath).isDirectory()) {
|
|
552
|
+
return {
|
|
553
|
+
scannedFileCount: 0,
|
|
554
|
+
truncated: false,
|
|
555
|
+
items: [],
|
|
556
|
+
error: "工作区路径不存在,无法统计代码类型"
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
const typeCounts = new Map();
|
|
560
|
+
const directories = [resolvedPath];
|
|
561
|
+
let scannedFileCount = 0;
|
|
562
|
+
let truncated = false;
|
|
563
|
+
// 这里故意只做轻量扫描,避免为了一个信息面板把大仓库整棵树扫爆。
|
|
564
|
+
while (directories.length > 0 && !truncated) {
|
|
565
|
+
const currentDirectory = directories.pop();
|
|
566
|
+
if (!currentDirectory) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
let entries;
|
|
570
|
+
try {
|
|
571
|
+
entries = fs.readdirSync(currentDirectory, { withFileTypes: true });
|
|
572
|
+
}
|
|
573
|
+
catch {
|
|
574
|
+
continue;
|
|
575
|
+
}
|
|
576
|
+
for (const entry of entries) {
|
|
577
|
+
if (entry.isSymbolicLink()) {
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
const fullPath = path.join(currentDirectory, entry.name);
|
|
581
|
+
if (entry.isDirectory()) {
|
|
582
|
+
if (!IGNORED_COMPOSITION_DIRECTORIES.has(entry.name)) {
|
|
583
|
+
directories.push(fullPath);
|
|
584
|
+
}
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (!entry.isFile()) {
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
const detectedType = detectWorkspaceFileType(entry.name);
|
|
591
|
+
if (!detectedType) {
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
scannedFileCount += 1;
|
|
595
|
+
typeCounts.set(detectedType, (typeCounts.get(detectedType) ?? 0) + 1);
|
|
596
|
+
if (scannedFileCount >= WORKSPACE_CODE_SCAN_LIMIT) {
|
|
597
|
+
truncated = true;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const items = [...typeCounts.entries()]
|
|
603
|
+
.sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0]))
|
|
604
|
+
.map(([type, count]) => ({
|
|
605
|
+
type,
|
|
606
|
+
count,
|
|
607
|
+
ratio: scannedFileCount > 0 ? count / scannedFileCount : 0
|
|
608
|
+
}));
|
|
609
|
+
return {
|
|
610
|
+
scannedFileCount,
|
|
611
|
+
truncated,
|
|
612
|
+
items,
|
|
613
|
+
error: null
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function detectWorkspaceFileType(fileName) {
|
|
617
|
+
const normalizedName = fileName.trim().toLowerCase();
|
|
618
|
+
if (!normalizedName) {
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
const directMatch = COMPOSITION_TYPE_BY_NAME[normalizedName];
|
|
622
|
+
if (directMatch) {
|
|
623
|
+
return directMatch;
|
|
624
|
+
}
|
|
625
|
+
return COMPOSITION_TYPE_BY_EXTENSION[path.extname(normalizedName)] ?? null;
|
|
626
|
+
}
|
|
627
|
+
function normalizeGitOutput(value) {
|
|
628
|
+
const normalized = value.trim();
|
|
629
|
+
return normalized || null;
|
|
630
|
+
}
|
|
631
|
+
function parseGitCommitCount(value) {
|
|
632
|
+
const normalized = value.trim();
|
|
633
|
+
if (!normalized) {
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
const parsed = Number(normalized);
|
|
637
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
638
|
+
}
|
|
639
|
+
function parseGitRemotes(output) {
|
|
640
|
+
const remoteMap = new Map();
|
|
641
|
+
for (const line of output.split(/\r?\n/)) {
|
|
642
|
+
const trimmedLine = line.trim();
|
|
643
|
+
if (!trimmedLine) {
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const match = /^([^\s]+)\s+([^\s]+)\s+\((fetch|push)\)$/.exec(trimmedLine);
|
|
647
|
+
if (!match) {
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
const [, name, url, mode] = match;
|
|
651
|
+
const existing = remoteMap.get(name);
|
|
652
|
+
// 远程列表通常 fetch/push 会重复两次,这里优先保留 fetch 行,避免 UI 重复。
|
|
653
|
+
if (!existing || mode === "fetch") {
|
|
654
|
+
remoteMap.set(name, { name, url });
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return [...remoteMap.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
658
|
+
}
|
|
659
|
+
//# sourceMappingURL=workspace-service.js.map
|