From 04a70859b7657de6a03f857d1e52fc4c081c7c0d Mon Sep 17 00:00:00 2001 From: Sycun <165354365+Sycun@users.noreply.github.com> Date: Thu, 19 Nov 2026 09:09:11 +0800 Subject: [PATCH] feat(frontend): migrate to Semi Design and refresh workspace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一 React + Semi Design 页面与视觉体系,保留既有业务接口、权限和深链接;补齐构建产物、SPA 入口校验及浏览器回归,减少旧模板与全局脚本的维护成本。 --- .github/workflows/deep-assessments.yml | 10 +- .github/workflows/frontend-build.yml | 41 + .github/workflows/self-update.yml | 11 +- .github/workflows/task-ui.yml | 24 - .gitignore | 2 + CHANGELOG.md | 14 + docs/en-US/frontend-i18n.md | 57 +- docs/en-US/plugin-development.md | 2 +- docs/en-US/testing.md | 2 +- docs/en-US/workflow-graph.md | 2 +- docs/ui-design-system.md | 80 +- docs/zh-CN/architecture.md | 8 +- docs/zh-CN/developer-guide.md | 4 +- docs/zh-CN/frontend-i18n.md | 348 +- docs/zh-CN/pi-runtime.md | 2 +- docs/zh-CN/plugin-development.md | 2 +- docs/zh-CN/testing.md | 16 +- docs/zh-CN/workflow-graph.md | 2 +- internal/app/app.go | 20 +- internal/app/spa_test.go | 57 + internal/app/template_render_test.go | 19 - scripts/assessment-findings-browser.test.cjs | 153 - scripts/batch-tasks-browser.test.cjs | 71 - scripts/chat-scroll-browser.test.cjs | 147 - scripts/check-ui-design-system.cjs | 378 - scripts/deep-assessments-browser.test.cjs | 743 - scripts/helpers/batch-task-ui-fixture.cjs | 71 - scripts/mobile-shot.mjs | 184 - scripts/mobile-tap-audit.mjs | 460 - scripts/mobile-tap-baseline.json | 1 - scripts/project-mobile-layout.test.cjs | 265 - scripts/ui-extra-drawers.cjs | 209 - scripts/ui-realistic-scenarios.cjs | 601 - web/frontend/CONTRACT.md | 80 + web/frontend/README.md | 55 + web/frontend/index.html | 26 + web/frontend/package-lock.json | 4804 ++ web/frontend/package.json | 30 + web/frontend/playwright.config.mjs | 44 + web/frontend/src/App.jsx | 77 + web/frontend/src/components/hooks.js | 68 + web/frontend/src/components/ui.jsx | 255 + web/frontend/src/layout/AppLayout.jsx | 370 + web/frontend/src/layout/LoginPage.jsx | 81 + web/frontend/src/lib/auth.jsx | 118 + web/frontend/src/lib/format.js | 130 + web/frontend/src/lib/http.js | 223 + web/frontend/src/lib/i18n.jsx | 102 + web/frontend/src/lib/nav.js | 100 + web/frontend/src/lib/theme.jsx | 75 + web/frontend/src/main.jsx | 40 + .../src/pages/agents-management/index.jsx | 167 + web/frontend/src/pages/api-docs/index.jsx | 263 + web/frontend/src/pages/api-docs/page.css | 28 + .../asset-library/components/AssetBits.jsx | 64 + .../components/AssetBulkEditModal.jsx | 128 + .../components/AssetDetailDrawer.jsx | 119 + .../components/AssetEditorModal.jsx | 301 + .../components/AssetFilterBar.jsx | 163 + .../components/AssetImportModal.jsx | 216 + .../components/AssetMergeModal.jsx | 84 + .../components/AssetProjectModal.jsx | 89 + .../asset-library/components/AssetTable.jsx | 124 + .../components/assetConstants.js | 159 + .../asset-library/components/assetCsv.js | 257 + .../asset-library/components/assetTarget.js | 154 + .../asset-library/components/fofaImport.js | 78 + .../components/useAssetProjects.js | 21 + .../src/pages/asset-library/index.jsx | 422 + web/frontend/src/pages/asset-library/page.css | 58 + .../src/pages/asset-overview/index.jsx | 274 + .../src/pages/asset-overview/page.css | 42 + web/frontend/src/pages/c2-events/index.jsx | 258 + web/frontend/src/pages/c2-events/page.css | 31 + .../src/pages/c2-listeners/ListenerForm.jsx | 154 + web/frontend/src/pages/c2-listeners/index.jsx | 245 + web/frontend/src/pages/c2-listeners/page.css | 25 + web/frontend/src/pages/c2-payloads/index.jsx | 270 + web/frontend/src/pages/c2-payloads/page.css | 35 + .../src/pages/c2-profiles/ProfileForm.jsx | 126 + web/frontend/src/pages/c2-profiles/index.jsx | 183 + web/frontend/src/pages/c2-profiles/page.css | 20 + .../src/pages/c2-sessions/SessionDetail.jsx | 171 + .../src/pages/c2-sessions/SessionFiles.jsx | 174 + .../src/pages/c2-sessions/SessionInfo.jsx | 67 + .../src/pages/c2-sessions/SessionTasks.jsx | 138 + .../src/pages/c2-sessions/SessionTerminal.jsx | 137 + .../pages/c2-sessions/components/c2-api.js | 60 + .../src/pages/c2-sessions/components/c2-ls.js | 74 + .../c2-sessions/components/c2-shared.css | 149 + .../c2-sessions/components/c2-shared.jsx | 159 + web/frontend/src/pages/c2-sessions/index.jsx | 194 + web/frontend/src/pages/c2-sessions/page.css | 240 + .../src/pages/c2-tasks/CreateTaskModal.jsx | 91 + web/frontend/src/pages/c2-tasks/index.jsx | 330 + web/frontend/src/pages/c2-tasks/page.css | 23 + .../src/pages/chat-files/PreviewDrawer.jsx | 125 + web/frontend/src/pages/chat-files/api.js | 46 + web/frontend/src/pages/chat-files/index.jsx | 424 + web/frontend/src/pages/chat-files/page.css | 116 + web/frontend/src/pages/chat/ChatHeader.jsx | 65 + web/frontend/src/pages/chat/Composer.jsx | 168 + .../src/pages/chat/ConversationList.jsx | 250 + web/frontend/src/pages/chat/HitlCard.jsx | 114 + web/frontend/src/pages/chat/HitlDock.jsx | 32 + web/frontend/src/pages/chat/MessageList.jsx | 237 + web/frontend/src/pages/chat/Sheets.jsx | 200 + web/frontend/src/pages/chat/TurnBody.jsx | 135 + web/frontend/src/pages/chat/index.jsx | 549 + web/frontend/src/pages/chat/page.css | 409 + web/frontend/src/pages/chat/stream.js | 485 + web/frontend/src/pages/chat/useAgentRun.js | 170 + .../src/pages/chat/useConversationActions.js | 99 + web/frontend/src/pages/dashboard/index.jsx | 418 + web/frontend/src/pages/dashboard/page.css | 333 + .../dashboard/vulnerability-overview.jsx | 278 + .../pages/deep-assessments/AcceptanceTab.jsx | 408 + .../src/pages/deep-assessments/AssetsTab.jsx | 280 + .../pages/deep-assessments/CreateModal.jsx | 175 + .../pages/deep-assessments/EvidenceTab.jsx | 425 + .../src/pages/deep-assessments/FactsTab.jsx | 151 + .../pages/deep-assessments/FindingsTab.jsx | 171 + .../src/pages/deep-assessments/GraphTab.jsx | 383 + .../src/pages/deep-assessments/IntentsTab.jsx | 246 + .../src/pages/deep-assessments/List.jsx | 259 + .../pages/deep-assessments/OverviewTab.jsx | 168 + .../src/pages/deep-assessments/ReportTab.jsx | 61 + .../src/pages/deep-assessments/Workbench.jsx | 385 + .../src/pages/deep-assessments/index.jsx | 68 + .../src/pages/deep-assessments/labels.js | 243 + .../src/pages/deep-assessments/page.css | 300 + web/frontend/src/pages/hitl/blocks.jsx | 24 + web/frontend/src/pages/hitl/index.jsx | 128 + web/frontend/src/pages/hitl/logs-panel.jsx | 290 + web/frontend/src/pages/hitl/page.css | 158 + web/frontend/src/pages/hitl/pending-panel.jsx | 245 + .../src/pages/hitl/strategy-panel.jsx | 308 + web/frontend/src/pages/hitl/utils.js | 140 + .../src/pages/hitl/whitelist-panel.jsx | 100 + .../components/FofaParseModal.jsx | 102 + .../components/FofaResultTable.jsx | 78 + .../info-collect/components/providers.js | 124 + web/frontend/src/pages/info-collect/index.jsx | 388 + web/frontend/src/pages/info-collect/page.css | 37 + .../src/pages/knowledge-management/index.jsx | 218 + .../pages/knowledge-retrieval-logs/index.jsx | 114 + .../src/pages/mcp-management/external-mcp.jsx | 321 + .../src/pages/mcp-management/index.jsx | 80 + .../src/pages/mcp-management/page.css | 102 + .../src/pages/mcp-management/tools-panel.jsx | 230 + .../src/pages/mcp-management/utils.js | 36 + web/frontend/src/pages/mcp-monitor/detail.jsx | 128 + .../src/pages/mcp-monitor/executions.jsx | 140 + web/frontend/src/pages/mcp-monitor/index.jsx | 290 + web/frontend/src/pages/mcp-monitor/page.css | 141 + web/frontend/src/pages/mcp-monitor/stats.jsx | 140 + .../src/pages/mcp-monitor/timeline.jsx | 115 + web/frontend/src/pages/mcp-monitor/utils.js | 132 + .../src/pages/platform-rbac/ResourceGrant.jsx | 84 + .../src/pages/platform-rbac/index.jsx | 311 + .../pages/projects/conversations-panel.jsx | 153 + web/frontend/src/pages/projects/detail.jsx | 175 + .../src/pages/projects/fact-detail.jsx | 105 + web/frontend/src/pages/projects/fact-form.jsx | 209 + .../src/pages/projects/fact-graph.jsx | 387 + .../src/pages/projects/facts-panel.jsx | 256 + web/frontend/src/pages/projects/helpers.js | 120 + web/frontend/src/pages/projects/index.jsx | 340 + web/frontend/src/pages/projects/page.css | 250 + .../src/pages/projects/project-form.jsx | 64 + .../src/pages/projects/settings-panel.jsx | 214 + web/frontend/src/pages/registry.js | 36 + .../src/pages/roles-management/index.jsx | 153 + web/frontend/src/pages/settings/index.jsx | 77 + web/frontend/src/pages/settings/lib/yaml.js | 430 + web/frontend/src/pages/settings/page.css | 123 + .../settings/sections/AppearanceSection.jsx | 54 + .../pages/settings/sections/AuditSection.jsx | 395 + .../pages/settings/sections/BasicSection.jsx | 288 + .../pages/settings/sections/ModelsSection.jsx | 34 + .../pages/settings/sections/ProbePanel.jsx | 375 + .../settings/sections/StorageSection.jsx | 408 + .../settings/sections/TokenUsageSection.jsx | 199 + .../pages/settings/sections/ToolsPanel.jsx | 316 + .../pages/settings/sections/UpdateSection.jsx | 263 + .../src/pages/settings/sections/common.jsx | 39 + .../src/pages/skills-management/index.jsx | 214 + .../src/pages/skills-monitor/index.jsx | 88 + web/frontend/src/pages/tasks/helpers.js | 121 + web/frontend/src/pages/tasks/index.jsx | 362 + web/frontend/src/pages/tasks/live-tasks.jsx | 109 + web/frontend/src/pages/tasks/page.css | 114 + web/frontend/src/pages/tasks/queue-detail.jsx | 414 + web/frontend/src/pages/tasks/queue-form.jsx | 219 + .../src/pages/tool-guard/RuleCard.jsx | 99 + .../src/pages/tool-guard/TestPanel.jsx | 168 + web/frontend/src/pages/tool-guard/index.jsx | 327 + web/frontend/src/pages/tool-guard/page.css | 97 + web/frontend/src/pages/tool-guard/utils.js | 89 + .../pages/vulnerabilities/DetailDrawer.jsx | 341 + .../src/pages/vulnerabilities/EditModal.jsx | 288 + .../src/pages/vulnerabilities/FilterBar.jsx | 113 + .../src/pages/vulnerabilities/List.jsx | 177 + .../src/pages/vulnerabilities/index.jsx | 486 + .../src/pages/vulnerabilities/page.css | 270 + .../src/pages/vulnerabilities/shared.js | 146 + web/frontend/src/pages/webshell/AiTab.jsx | 113 + .../src/pages/webshell/ConnectionForm.jsx | 167 + web/frontend/src/pages/webshell/FilesTab.jsx | 347 + .../src/pages/webshell/HistoryTab.jsx | 69 + .../src/pages/webshell/TerminalTab.jsx | 122 + web/frontend/src/pages/webshell/api.js | 97 + web/frontend/src/pages/webshell/fileList.js | 163 + web/frontend/src/pages/webshell/index.jsx | 358 + web/frontend/src/pages/webshell/page.css | 397 + web/frontend/src/pages/workflows/helpers.js | 146 + web/frontend/src/pages/workflows/index.jsx | 304 + .../src/pages/workflows/package-import.jsx | 335 + web/frontend/src/pages/workflows/page.css | 114 + .../src/pages/workflows/run-detail.jsx | 176 + .../src/pages/workflows/runs-panel.jsx | 121 + .../src/pages/workflows/workflow-detail.jsx | 180 + .../src/pages/workflows/workflow-form.jsx | 240 + web/frontend/src/styles/app.css | 223 + web/frontend/tests/fixtures.mjs | 318 + web/frontend/tests/regressions.spec.mjs | 188 + web/frontend/tests/ui.spec.mjs | 525 + web/frontend/tests/yaml.test.mjs | 11 + web/frontend/vite.config.mjs | 49 + .../app/assets/agents-management-BijMkB4k.js | 1 + web/static/app/assets/api-docs-B_T3BEfL.css | 1 + web/static/app/assets/api-docs-D-0KAm3Z.js | 3 + .../app/assets/asset-library-Cg-4PzE3.js | 3 + .../app/assets/asset-library-Cj3Xw0tX.css | 1 + .../app/assets/asset-overview-B2rxkwiK.js | 1 + .../app/assets/asset-overview-DEMYiRVr.css | 1 + web/static/app/assets/assetTarget-DdKyGY0h.js | 1 + web/static/app/assets/c2-events-B5k87enE.js | 1 + web/static/app/assets/c2-events-BVd4qqKy.css | 1 + .../app/assets/c2-listeners-B8kVMdaO.js | 1 + .../app/assets/c2-listeners-KjhK45yg.css | 1 + web/static/app/assets/c2-payloads-BBmnfdjy.js | 1 + .../app/assets/c2-payloads-CnRJmaJm.css | 1 + .../app/assets/c2-profiles-BpNJlhDC.css | 1 + web/static/app/assets/c2-profiles-C8rKD-rq.js | 2 + .../app/assets/c2-sessions-DLf_n8Eq.css | 1 + web/static/app/assets/c2-sessions-_uK2gRwZ.js | 1 + web/static/app/assets/c2-shared-BRGOsG9Y.css | 1 + web/static/app/assets/c2-shared-BbPfxKDp.js | 1 + web/static/app/assets/c2-shared-wejevSRm.js | 1 + web/static/app/assets/c2-tasks-B5H34xZF.css | 1 + web/static/app/assets/c2-tasks-BWlTS7Rx.js | 1 + web/static/app/assets/chat-Bl-sf4y5.css | 1 + web/static/app/assets/chat-ChCzmlGT.js | 4 + web/static/app/assets/chat-files-BeSf7TU2.js | 1 + web/static/app/assets/chat-files-wKL7Vwmw.css | 1 + .../app/assets/cytoscape.esm-BPjn7guX.js | 321 + web/static/app/assets/dashboard-D9e788e7.css | 1 + web/static/app/assets/dashboard-DwuM6IKj.js | 1 + .../app/assets/deep-assessments-BozGnBS7.css | 1 + .../app/assets/deep-assessments-CWzwsD0L.js | 2 + web/static/app/assets/hitl-BRrMuBJV.js | 7 + web/static/app/assets/hitl-ChWaPsj1.css | 1 + web/static/app/assets/index-BZm3l2iX.js | 64 + web/static/app/assets/index-B_jDLAQv.css | 1 + .../app/assets/info-collect-BsMxD3us.js | 1 + .../app/assets/info-collect-S9i-bIJW.css | 1 + .../assets/knowledge-management-BCMgFhNg.js | 1 + .../knowledge-retrieval-logs-B3QWeEx6.js | 1 + .../app/assets/mcp-management-CEr7J00D.css | 1 + .../app/assets/mcp-management-CMz2N4on.js | 1 + .../app/assets/mcp-monitor-8VvqmnVY.css | 1 + web/static/app/assets/mcp-monitor-DMLW3Yhw.js | 1 + .../app/assets/platform-rbac-BZqQ5sri.js | 1 + web/static/app/assets/projects-BRYkixPD.js | 4 + web/static/app/assets/projects-DtTkHn99.css | 1 + web/static/app/assets/react-QV7DAAIx.js | 13 + .../app/assets/roles-management-BWWff4ru.js | 1 + .../app/assets/rolldown-runtime-WkwZ5CU-.js | 1 + web/static/app/assets/semi-BUXPdXzR.css | 1 + web/static/app/assets/semi-DxL3rPNO.js | 15 + web/static/app/assets/settings-DKYR_7wR.css | 1 + web/static/app/assets/settings-GxM6DzdK.js | 20 + .../app/assets/skills-management-N8W55nVM.js | 1 + .../app/assets/skills-monitor-C_F3nXES.js | 1 + web/static/app/assets/tasks-BtBBHKoW.css | 1 + web/static/app/assets/tasks-DtQtgNIr.js | 2 + web/static/app/assets/tool-guard-D6hmN10I.js | 1 + web/static/app/assets/tool-guard-DKIWLN1V.css | 1 + .../app/assets/vulnerabilities-BeZxXUTs.js | 1 + .../app/assets/vulnerabilities-C_yXB8Qo.css | 1 + web/static/app/assets/webshell-BVuBPlfW.css | 1 + web/static/app/assets/webshell-gpZyod8-.js | 2 + web/static/app/assets/workflows-BVTMvnsK.js | 1 + web/static/app/assets/workflows-EsKm07MV.css | 1 + web/static/app/index.html | 31 + web/static/css/api-docs-mobile.css | 301 - web/static/css/c2.css | 4482 -- web/static/css/chat-plan-progress.css | 203 - web/static/css/deep-assessments.css | 466 - web/static/css/design-system.css | 343 - web/static/css/mobile.css | 3737 -- web/static/css/style.css | 47870 ---------------- web/static/css/tool-guard.css | 279 - web/static/css/vulnerability-download.css | 18 - web/static/css/vulnerability-list.css | 157 - web/static/css/vulnerability-workspace.css | 324 - web/static/js/agents.js | 232 - web/static/js/api-docs.js | 1041 - web/static/js/assessment-acceptance.js | 205 - web/static/js/assessment-exploration-views.js | 135 - web/static/js/assessment-finding-links.js | 50 - web/static/js/assessment-node-panel.js | 44 - web/static/js/assessment-provenance.js | 170 - web/static/js/assessment-workbench.js | 45 - web/static/js/asset-export-language.test.cjs | 74 - web/static/js/asset-scan-prompt.test.cjs | 20 - web/static/js/assets.js | 1842 - web/static/js/attack-chain-context.js | 127 - web/static/js/attack-chain-context.test.cjs | 292 - web/static/js/audit-datetime-picker.js | 433 - web/static/js/audit-reset.test.cjs | 35 - web/static/js/audit.js | 912 - web/static/js/auth.js | 1030 - web/static/js/batch-outcome-display.test.cjs | 18 - web/static/js/builtin-tools.js | 27 - web/static/js/c2-listener-form.test.cjs | 66 - web/static/js/c2-profile-save.test.cjs | 43 - web/static/js/c2.js | 4644 -- web/static/js/chat-codex-layout.test.cjs | 51 - web/static/js/chat-files.js | 1956 - web/static/js/chat-input-keyboard.test.cjs | 83 - web/static/js/chat-message-copy.test.cjs | 35 - web/static/js/chat-plan-progress.js | 356 - web/static/js/chat-plan-progress.test.cjs | 74 - web/static/js/chat-scroll-refresh.test.cjs | 580 - web/static/js/chat-scroll.js | 837 - web/static/js/chat.js | 11329 ---- .../js/conversation-actions-sync.test.cjs | 79 - web/static/js/dashboard.js | 2525 - web/static/js/deep-assessment-graph.js | 215 - web/static/js/deep-assessment-graph.test.cjs | 49 - web/static/js/deep-assessments.js | 661 - web/static/js/fact-graph.js | 818 - web/static/js/fofa-fields.test.cjs | 41 - web/static/js/form-validation.test.cjs | 62 - web/static/js/hitl-approval-ui.test.cjs | 407 - .../js/hitl-conversation-isolation.test.cjs | 49 - web/static/js/hitl.js | 2032 - web/static/js/i18n.js | 285 - web/static/js/info-collect.js | 1737 - web/static/js/iteration-divider-ui.test.cjs | 31 - web/static/js/knowledge-index-error.test.cjs | 15 - web/static/js/knowledge.js | 2343 - web/static/js/mobile-ui-i18n.test.cjs | 87 - web/static/js/mobile-ui.js | 1270 - web/static/js/modal.js | 214 - web/static/js/monitor-blocked-stats.test.cjs | 81 - web/static/js/monitor.js | 9724 ---- web/static/js/notification-view-read.test.cjs | 37 - web/static/js/notifications.js | 357 - web/static/js/pagination-select.test.cjs | 59 - web/static/js/password-feedback.test.cjs | 79 - web/static/js/permission-gate-state.test.cjs | 133 - web/static/js/pi-usage-summary-ui.test.cjs | 90 - web/static/js/progress-done-outcome.test.cjs | 18 - web/static/js/project-folder-preview.test.cjs | 163 - web/static/js/project-related-facts.test.cjs | 36 - web/static/js/projects.js | 4188 -- web/static/js/proxy-settings.js | 43 - web/static/js/proxy-settings.test.cjs | 35 - web/static/js/rbac-admin-guard.test.cjs | 84 - web/static/js/rbac-guards.js | 280 - web/static/js/rbac.js | 1575 - web/static/js/roles.js | 1927 - web/static/js/router-hash-form.test.cjs | 48 - web/static/js/router.js | 717 - web/static/js/sanitize-markdown.js | 208 - .../js/settings-header-boundaries.test.cjs | 23 - web/static/js/settings-pi-resilience.test.cjs | 160 - web/static/js/settings.js | 5091 -- web/static/js/skill-description-save.test.cjs | 33 - web/static/js/skills.js | 1124 - web/static/js/storage.js | 367 - web/static/js/tasks.js | 3021 - web/static/js/terminal.js | 544 - web/static/js/theme.js | 145 - web/static/js/token-usage-analysis.test.cjs | 93 - web/static/js/token-usage.js | 291 - web/static/js/tool-blocked-display.test.cjs | 164 - web/static/js/tool-guard.js | 738 - web/static/js/tool-guard.test.cjs | 903 - .../js/tool-result-args-backfill.test.cjs | 25 - web/static/js/turn-duration-refresh.test.cjs | 226 - web/static/js/update-ui.test.cjs | 1540 - web/static/js/update.js | 1074 - web/static/js/vulnerability-create.test.cjs | 48 - web/static/js/vulnerability-download.js | 61 - .../js/vulnerability-host-view.test.cjs | 41 - web/static/js/vulnerability-retest.test.cjs | 154 - web/static/js/vulnerability-workspace.js | 226 - web/static/js/vulnerability.js | 2710 - web/static/js/webshell-file-path.test.cjs | 53 - web/static/js/webshell-probe.test.cjs | 60 - web/static/js/webshell.js | 5335 -- web/static/js/wechat-robot.js | 418 - web/static/js/workflow-package-client.js | 117 - .../js/workflow-package-client.test.cjs | 51 - web/static/js/workflow-package-ui.test.cjs | 112 - web/static/js/workflow-save.test.cjs | 114 - web/static/js/workflow-validity.test.cjs | 37 - web/static/js/workflows.js | 3122 - web/static/vendor/cytoscape.min.js | 32 - web/static/vendor/elk.bundled.js | 6696 --- web/static/vendor/i18next.min.js | 1 - web/static/vendor/marked.min.js | 6 - web/static/vendor/purify.min.js | 2 - web/static/vendor/xlsx.full.min.js | 22 - web/static/vendor/xterm-addon-fit.js | 2 - web/static/vendor/xterm.css | 190 - web/static/vendor/xterm.js | 2 - web/templates/api-docs.html | 1085 - web/templates/index.html | 7162 --- 423 files changed, 41559 insertions(+), 164972 deletions(-) create mode 100644 .github/workflows/frontend-build.yml delete mode 100644 .github/workflows/task-ui.yml create mode 100644 internal/app/spa_test.go delete mode 100644 internal/app/template_render_test.go delete mode 100644 scripts/assessment-findings-browser.test.cjs delete mode 100644 scripts/batch-tasks-browser.test.cjs delete mode 100644 scripts/chat-scroll-browser.test.cjs delete mode 100644 scripts/check-ui-design-system.cjs delete mode 100644 scripts/deep-assessments-browser.test.cjs delete mode 100644 scripts/helpers/batch-task-ui-fixture.cjs delete mode 100644 scripts/mobile-shot.mjs delete mode 100644 scripts/mobile-tap-audit.mjs delete mode 100644 scripts/mobile-tap-baseline.json delete mode 100644 scripts/project-mobile-layout.test.cjs delete mode 100644 scripts/ui-extra-drawers.cjs delete mode 100644 scripts/ui-realistic-scenarios.cjs create mode 100644 web/frontend/CONTRACT.md create mode 100644 web/frontend/README.md create mode 100644 web/frontend/index.html create mode 100644 web/frontend/package-lock.json create mode 100644 web/frontend/package.json create mode 100644 web/frontend/playwright.config.mjs create mode 100644 web/frontend/src/App.jsx create mode 100644 web/frontend/src/components/hooks.js create mode 100644 web/frontend/src/components/ui.jsx create mode 100644 web/frontend/src/layout/AppLayout.jsx create mode 100644 web/frontend/src/layout/LoginPage.jsx create mode 100644 web/frontend/src/lib/auth.jsx create mode 100644 web/frontend/src/lib/format.js create mode 100644 web/frontend/src/lib/http.js create mode 100644 web/frontend/src/lib/i18n.jsx create mode 100644 web/frontend/src/lib/nav.js create mode 100644 web/frontend/src/lib/theme.jsx create mode 100644 web/frontend/src/main.jsx create mode 100644 web/frontend/src/pages/agents-management/index.jsx create mode 100644 web/frontend/src/pages/api-docs/index.jsx create mode 100644 web/frontend/src/pages/api-docs/page.css create mode 100644 web/frontend/src/pages/asset-library/components/AssetBits.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetBulkEditModal.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetDetailDrawer.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetEditorModal.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetFilterBar.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetImportModal.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetMergeModal.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetProjectModal.jsx create mode 100644 web/frontend/src/pages/asset-library/components/AssetTable.jsx create mode 100644 web/frontend/src/pages/asset-library/components/assetConstants.js create mode 100644 web/frontend/src/pages/asset-library/components/assetCsv.js create mode 100644 web/frontend/src/pages/asset-library/components/assetTarget.js create mode 100644 web/frontend/src/pages/asset-library/components/fofaImport.js create mode 100644 web/frontend/src/pages/asset-library/components/useAssetProjects.js create mode 100644 web/frontend/src/pages/asset-library/index.jsx create mode 100644 web/frontend/src/pages/asset-library/page.css create mode 100644 web/frontend/src/pages/asset-overview/index.jsx create mode 100644 web/frontend/src/pages/asset-overview/page.css create mode 100644 web/frontend/src/pages/c2-events/index.jsx create mode 100644 web/frontend/src/pages/c2-events/page.css create mode 100644 web/frontend/src/pages/c2-listeners/ListenerForm.jsx create mode 100644 web/frontend/src/pages/c2-listeners/index.jsx create mode 100644 web/frontend/src/pages/c2-listeners/page.css create mode 100644 web/frontend/src/pages/c2-payloads/index.jsx create mode 100644 web/frontend/src/pages/c2-payloads/page.css create mode 100644 web/frontend/src/pages/c2-profiles/ProfileForm.jsx create mode 100644 web/frontend/src/pages/c2-profiles/index.jsx create mode 100644 web/frontend/src/pages/c2-profiles/page.css create mode 100644 web/frontend/src/pages/c2-sessions/SessionDetail.jsx create mode 100644 web/frontend/src/pages/c2-sessions/SessionFiles.jsx create mode 100644 web/frontend/src/pages/c2-sessions/SessionInfo.jsx create mode 100644 web/frontend/src/pages/c2-sessions/SessionTasks.jsx create mode 100644 web/frontend/src/pages/c2-sessions/SessionTerminal.jsx create mode 100644 web/frontend/src/pages/c2-sessions/components/c2-api.js create mode 100644 web/frontend/src/pages/c2-sessions/components/c2-ls.js create mode 100644 web/frontend/src/pages/c2-sessions/components/c2-shared.css create mode 100644 web/frontend/src/pages/c2-sessions/components/c2-shared.jsx create mode 100644 web/frontend/src/pages/c2-sessions/index.jsx create mode 100644 web/frontend/src/pages/c2-sessions/page.css create mode 100644 web/frontend/src/pages/c2-tasks/CreateTaskModal.jsx create mode 100644 web/frontend/src/pages/c2-tasks/index.jsx create mode 100644 web/frontend/src/pages/c2-tasks/page.css create mode 100644 web/frontend/src/pages/chat-files/PreviewDrawer.jsx create mode 100644 web/frontend/src/pages/chat-files/api.js create mode 100644 web/frontend/src/pages/chat-files/index.jsx create mode 100644 web/frontend/src/pages/chat-files/page.css create mode 100644 web/frontend/src/pages/chat/ChatHeader.jsx create mode 100644 web/frontend/src/pages/chat/Composer.jsx create mode 100644 web/frontend/src/pages/chat/ConversationList.jsx create mode 100644 web/frontend/src/pages/chat/HitlCard.jsx create mode 100644 web/frontend/src/pages/chat/HitlDock.jsx create mode 100644 web/frontend/src/pages/chat/MessageList.jsx create mode 100644 web/frontend/src/pages/chat/Sheets.jsx create mode 100644 web/frontend/src/pages/chat/TurnBody.jsx create mode 100644 web/frontend/src/pages/chat/index.jsx create mode 100644 web/frontend/src/pages/chat/page.css create mode 100644 web/frontend/src/pages/chat/stream.js create mode 100644 web/frontend/src/pages/chat/useAgentRun.js create mode 100644 web/frontend/src/pages/chat/useConversationActions.js create mode 100644 web/frontend/src/pages/dashboard/index.jsx create mode 100644 web/frontend/src/pages/dashboard/page.css create mode 100644 web/frontend/src/pages/dashboard/vulnerability-overview.jsx create mode 100644 web/frontend/src/pages/deep-assessments/AcceptanceTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/AssetsTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/CreateModal.jsx create mode 100644 web/frontend/src/pages/deep-assessments/EvidenceTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/FactsTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/FindingsTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/GraphTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/IntentsTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/List.jsx create mode 100644 web/frontend/src/pages/deep-assessments/OverviewTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/ReportTab.jsx create mode 100644 web/frontend/src/pages/deep-assessments/Workbench.jsx create mode 100644 web/frontend/src/pages/deep-assessments/index.jsx create mode 100644 web/frontend/src/pages/deep-assessments/labels.js create mode 100644 web/frontend/src/pages/deep-assessments/page.css create mode 100644 web/frontend/src/pages/hitl/blocks.jsx create mode 100644 web/frontend/src/pages/hitl/index.jsx create mode 100644 web/frontend/src/pages/hitl/logs-panel.jsx create mode 100644 web/frontend/src/pages/hitl/page.css create mode 100644 web/frontend/src/pages/hitl/pending-panel.jsx create mode 100644 web/frontend/src/pages/hitl/strategy-panel.jsx create mode 100644 web/frontend/src/pages/hitl/utils.js create mode 100644 web/frontend/src/pages/hitl/whitelist-panel.jsx create mode 100644 web/frontend/src/pages/info-collect/components/FofaParseModal.jsx create mode 100644 web/frontend/src/pages/info-collect/components/FofaResultTable.jsx create mode 100644 web/frontend/src/pages/info-collect/components/providers.js create mode 100644 web/frontend/src/pages/info-collect/index.jsx create mode 100644 web/frontend/src/pages/info-collect/page.css create mode 100644 web/frontend/src/pages/knowledge-management/index.jsx create mode 100644 web/frontend/src/pages/knowledge-retrieval-logs/index.jsx create mode 100644 web/frontend/src/pages/mcp-management/external-mcp.jsx create mode 100644 web/frontend/src/pages/mcp-management/index.jsx create mode 100644 web/frontend/src/pages/mcp-management/page.css create mode 100644 web/frontend/src/pages/mcp-management/tools-panel.jsx create mode 100644 web/frontend/src/pages/mcp-management/utils.js create mode 100644 web/frontend/src/pages/mcp-monitor/detail.jsx create mode 100644 web/frontend/src/pages/mcp-monitor/executions.jsx create mode 100644 web/frontend/src/pages/mcp-monitor/index.jsx create mode 100644 web/frontend/src/pages/mcp-monitor/page.css create mode 100644 web/frontend/src/pages/mcp-monitor/stats.jsx create mode 100644 web/frontend/src/pages/mcp-monitor/timeline.jsx create mode 100644 web/frontend/src/pages/mcp-monitor/utils.js create mode 100644 web/frontend/src/pages/platform-rbac/ResourceGrant.jsx create mode 100644 web/frontend/src/pages/platform-rbac/index.jsx create mode 100644 web/frontend/src/pages/projects/conversations-panel.jsx create mode 100644 web/frontend/src/pages/projects/detail.jsx create mode 100644 web/frontend/src/pages/projects/fact-detail.jsx create mode 100644 web/frontend/src/pages/projects/fact-form.jsx create mode 100644 web/frontend/src/pages/projects/fact-graph.jsx create mode 100644 web/frontend/src/pages/projects/facts-panel.jsx create mode 100644 web/frontend/src/pages/projects/helpers.js create mode 100644 web/frontend/src/pages/projects/index.jsx create mode 100644 web/frontend/src/pages/projects/page.css create mode 100644 web/frontend/src/pages/projects/project-form.jsx create mode 100644 web/frontend/src/pages/projects/settings-panel.jsx create mode 100644 web/frontend/src/pages/registry.js create mode 100644 web/frontend/src/pages/roles-management/index.jsx create mode 100644 web/frontend/src/pages/settings/index.jsx create mode 100644 web/frontend/src/pages/settings/lib/yaml.js create mode 100644 web/frontend/src/pages/settings/page.css create mode 100644 web/frontend/src/pages/settings/sections/AppearanceSection.jsx create mode 100644 web/frontend/src/pages/settings/sections/AuditSection.jsx create mode 100644 web/frontend/src/pages/settings/sections/BasicSection.jsx create mode 100644 web/frontend/src/pages/settings/sections/ModelsSection.jsx create mode 100644 web/frontend/src/pages/settings/sections/ProbePanel.jsx create mode 100644 web/frontend/src/pages/settings/sections/StorageSection.jsx create mode 100644 web/frontend/src/pages/settings/sections/TokenUsageSection.jsx create mode 100644 web/frontend/src/pages/settings/sections/ToolsPanel.jsx create mode 100644 web/frontend/src/pages/settings/sections/UpdateSection.jsx create mode 100644 web/frontend/src/pages/settings/sections/common.jsx create mode 100644 web/frontend/src/pages/skills-management/index.jsx create mode 100644 web/frontend/src/pages/skills-monitor/index.jsx create mode 100644 web/frontend/src/pages/tasks/helpers.js create mode 100644 web/frontend/src/pages/tasks/index.jsx create mode 100644 web/frontend/src/pages/tasks/live-tasks.jsx create mode 100644 web/frontend/src/pages/tasks/page.css create mode 100644 web/frontend/src/pages/tasks/queue-detail.jsx create mode 100644 web/frontend/src/pages/tasks/queue-form.jsx create mode 100644 web/frontend/src/pages/tool-guard/RuleCard.jsx create mode 100644 web/frontend/src/pages/tool-guard/TestPanel.jsx create mode 100644 web/frontend/src/pages/tool-guard/index.jsx create mode 100644 web/frontend/src/pages/tool-guard/page.css create mode 100644 web/frontend/src/pages/tool-guard/utils.js create mode 100644 web/frontend/src/pages/vulnerabilities/DetailDrawer.jsx create mode 100644 web/frontend/src/pages/vulnerabilities/EditModal.jsx create mode 100644 web/frontend/src/pages/vulnerabilities/FilterBar.jsx create mode 100644 web/frontend/src/pages/vulnerabilities/List.jsx create mode 100644 web/frontend/src/pages/vulnerabilities/index.jsx create mode 100644 web/frontend/src/pages/vulnerabilities/page.css create mode 100644 web/frontend/src/pages/vulnerabilities/shared.js create mode 100644 web/frontend/src/pages/webshell/AiTab.jsx create mode 100644 web/frontend/src/pages/webshell/ConnectionForm.jsx create mode 100644 web/frontend/src/pages/webshell/FilesTab.jsx create mode 100644 web/frontend/src/pages/webshell/HistoryTab.jsx create mode 100644 web/frontend/src/pages/webshell/TerminalTab.jsx create mode 100644 web/frontend/src/pages/webshell/api.js create mode 100644 web/frontend/src/pages/webshell/fileList.js create mode 100644 web/frontend/src/pages/webshell/index.jsx create mode 100644 web/frontend/src/pages/webshell/page.css create mode 100644 web/frontend/src/pages/workflows/helpers.js create mode 100644 web/frontend/src/pages/workflows/index.jsx create mode 100644 web/frontend/src/pages/workflows/package-import.jsx create mode 100644 web/frontend/src/pages/workflows/page.css create mode 100644 web/frontend/src/pages/workflows/run-detail.jsx create mode 100644 web/frontend/src/pages/workflows/runs-panel.jsx create mode 100644 web/frontend/src/pages/workflows/workflow-detail.jsx create mode 100644 web/frontend/src/pages/workflows/workflow-form.jsx create mode 100644 web/frontend/src/styles/app.css create mode 100644 web/frontend/tests/fixtures.mjs create mode 100644 web/frontend/tests/regressions.spec.mjs create mode 100644 web/frontend/tests/ui.spec.mjs create mode 100644 web/frontend/tests/yaml.test.mjs create mode 100644 web/frontend/vite.config.mjs create mode 100644 web/static/app/assets/agents-management-BijMkB4k.js create mode 100644 web/static/app/assets/api-docs-B_T3BEfL.css create mode 100644 web/static/app/assets/api-docs-D-0KAm3Z.js create mode 100644 web/static/app/assets/asset-library-Cg-4PzE3.js create mode 100644 web/static/app/assets/asset-library-Cj3Xw0tX.css create mode 100644 web/static/app/assets/asset-overview-B2rxkwiK.js create mode 100644 web/static/app/assets/asset-overview-DEMYiRVr.css create mode 100644 web/static/app/assets/assetTarget-DdKyGY0h.js create mode 100644 web/static/app/assets/c2-events-B5k87enE.js create mode 100644 web/static/app/assets/c2-events-BVd4qqKy.css create mode 100644 web/static/app/assets/c2-listeners-B8kVMdaO.js create mode 100644 web/static/app/assets/c2-listeners-KjhK45yg.css create mode 100644 web/static/app/assets/c2-payloads-BBmnfdjy.js create mode 100644 web/static/app/assets/c2-payloads-CnRJmaJm.css create mode 100644 web/static/app/assets/c2-profiles-BpNJlhDC.css create mode 100644 web/static/app/assets/c2-profiles-C8rKD-rq.js create mode 100644 web/static/app/assets/c2-sessions-DLf_n8Eq.css create mode 100644 web/static/app/assets/c2-sessions-_uK2gRwZ.js create mode 100644 web/static/app/assets/c2-shared-BRGOsG9Y.css create mode 100644 web/static/app/assets/c2-shared-BbPfxKDp.js create mode 100644 web/static/app/assets/c2-shared-wejevSRm.js create mode 100644 web/static/app/assets/c2-tasks-B5H34xZF.css create mode 100644 web/static/app/assets/c2-tasks-BWlTS7Rx.js create mode 100644 web/static/app/assets/chat-Bl-sf4y5.css create mode 100644 web/static/app/assets/chat-ChCzmlGT.js create mode 100644 web/static/app/assets/chat-files-BeSf7TU2.js create mode 100644 web/static/app/assets/chat-files-wKL7Vwmw.css create mode 100644 web/static/app/assets/cytoscape.esm-BPjn7guX.js create mode 100644 web/static/app/assets/dashboard-D9e788e7.css create mode 100644 web/static/app/assets/dashboard-DwuM6IKj.js create mode 100644 web/static/app/assets/deep-assessments-BozGnBS7.css create mode 100644 web/static/app/assets/deep-assessments-CWzwsD0L.js create mode 100644 web/static/app/assets/hitl-BRrMuBJV.js create mode 100644 web/static/app/assets/hitl-ChWaPsj1.css create mode 100644 web/static/app/assets/index-BZm3l2iX.js create mode 100644 web/static/app/assets/index-B_jDLAQv.css create mode 100644 web/static/app/assets/info-collect-BsMxD3us.js create mode 100644 web/static/app/assets/info-collect-S9i-bIJW.css create mode 100644 web/static/app/assets/knowledge-management-BCMgFhNg.js create mode 100644 web/static/app/assets/knowledge-retrieval-logs-B3QWeEx6.js create mode 100644 web/static/app/assets/mcp-management-CEr7J00D.css create mode 100644 web/static/app/assets/mcp-management-CMz2N4on.js create mode 100644 web/static/app/assets/mcp-monitor-8VvqmnVY.css create mode 100644 web/static/app/assets/mcp-monitor-DMLW3Yhw.js create mode 100644 web/static/app/assets/platform-rbac-BZqQ5sri.js create mode 100644 web/static/app/assets/projects-BRYkixPD.js create mode 100644 web/static/app/assets/projects-DtTkHn99.css create mode 100644 web/static/app/assets/react-QV7DAAIx.js create mode 100644 web/static/app/assets/roles-management-BWWff4ru.js create mode 100644 web/static/app/assets/rolldown-runtime-WkwZ5CU-.js create mode 100644 web/static/app/assets/semi-BUXPdXzR.css create mode 100644 web/static/app/assets/semi-DxL3rPNO.js create mode 100644 web/static/app/assets/settings-DKYR_7wR.css create mode 100644 web/static/app/assets/settings-GxM6DzdK.js create mode 100644 web/static/app/assets/skills-management-N8W55nVM.js create mode 100644 web/static/app/assets/skills-monitor-C_F3nXES.js create mode 100644 web/static/app/assets/tasks-BtBBHKoW.css create mode 100644 web/static/app/assets/tasks-DtQtgNIr.js create mode 100644 web/static/app/assets/tool-guard-D6hmN10I.js create mode 100644 web/static/app/assets/tool-guard-DKIWLN1V.css create mode 100644 web/static/app/assets/vulnerabilities-BeZxXUTs.js create mode 100644 web/static/app/assets/vulnerabilities-C_yXB8Qo.css create mode 100644 web/static/app/assets/webshell-BVuBPlfW.css create mode 100644 web/static/app/assets/webshell-gpZyod8-.js create mode 100644 web/static/app/assets/workflows-BVTMvnsK.js create mode 100644 web/static/app/assets/workflows-EsKm07MV.css create mode 100644 web/static/app/index.html delete mode 100644 web/static/css/api-docs-mobile.css delete mode 100644 web/static/css/c2.css delete mode 100644 web/static/css/chat-plan-progress.css delete mode 100644 web/static/css/deep-assessments.css delete mode 100644 web/static/css/design-system.css delete mode 100644 web/static/css/mobile.css delete mode 100644 web/static/css/style.css delete mode 100644 web/static/css/tool-guard.css delete mode 100644 web/static/css/vulnerability-download.css delete mode 100644 web/static/css/vulnerability-list.css delete mode 100644 web/static/css/vulnerability-workspace.css delete mode 100644 web/static/js/agents.js delete mode 100644 web/static/js/api-docs.js delete mode 100644 web/static/js/assessment-acceptance.js delete mode 100644 web/static/js/assessment-exploration-views.js delete mode 100644 web/static/js/assessment-finding-links.js delete mode 100644 web/static/js/assessment-node-panel.js delete mode 100644 web/static/js/assessment-provenance.js delete mode 100644 web/static/js/assessment-workbench.js delete mode 100644 web/static/js/asset-export-language.test.cjs delete mode 100644 web/static/js/asset-scan-prompt.test.cjs delete mode 100644 web/static/js/assets.js delete mode 100644 web/static/js/attack-chain-context.js delete mode 100644 web/static/js/attack-chain-context.test.cjs delete mode 100644 web/static/js/audit-datetime-picker.js delete mode 100644 web/static/js/audit-reset.test.cjs delete mode 100644 web/static/js/audit.js delete mode 100644 web/static/js/auth.js delete mode 100644 web/static/js/batch-outcome-display.test.cjs delete mode 100644 web/static/js/builtin-tools.js delete mode 100644 web/static/js/c2-listener-form.test.cjs delete mode 100644 web/static/js/c2-profile-save.test.cjs delete mode 100644 web/static/js/c2.js delete mode 100644 web/static/js/chat-codex-layout.test.cjs delete mode 100644 web/static/js/chat-files.js delete mode 100644 web/static/js/chat-input-keyboard.test.cjs delete mode 100644 web/static/js/chat-message-copy.test.cjs delete mode 100644 web/static/js/chat-plan-progress.js delete mode 100644 web/static/js/chat-plan-progress.test.cjs delete mode 100644 web/static/js/chat-scroll-refresh.test.cjs delete mode 100644 web/static/js/chat-scroll.js delete mode 100644 web/static/js/chat.js delete mode 100644 web/static/js/conversation-actions-sync.test.cjs delete mode 100644 web/static/js/dashboard.js delete mode 100644 web/static/js/deep-assessment-graph.js delete mode 100644 web/static/js/deep-assessment-graph.test.cjs delete mode 100644 web/static/js/deep-assessments.js delete mode 100644 web/static/js/fact-graph.js delete mode 100644 web/static/js/fofa-fields.test.cjs delete mode 100644 web/static/js/form-validation.test.cjs delete mode 100644 web/static/js/hitl-approval-ui.test.cjs delete mode 100644 web/static/js/hitl-conversation-isolation.test.cjs delete mode 100644 web/static/js/hitl.js delete mode 100644 web/static/js/i18n.js delete mode 100644 web/static/js/info-collect.js delete mode 100644 web/static/js/iteration-divider-ui.test.cjs delete mode 100644 web/static/js/knowledge-index-error.test.cjs delete mode 100644 web/static/js/knowledge.js delete mode 100644 web/static/js/mobile-ui-i18n.test.cjs delete mode 100644 web/static/js/mobile-ui.js delete mode 100644 web/static/js/modal.js delete mode 100644 web/static/js/monitor-blocked-stats.test.cjs delete mode 100644 web/static/js/monitor.js delete mode 100644 web/static/js/notification-view-read.test.cjs delete mode 100644 web/static/js/notifications.js delete mode 100644 web/static/js/pagination-select.test.cjs delete mode 100644 web/static/js/password-feedback.test.cjs delete mode 100644 web/static/js/permission-gate-state.test.cjs delete mode 100644 web/static/js/pi-usage-summary-ui.test.cjs delete mode 100644 web/static/js/progress-done-outcome.test.cjs delete mode 100644 web/static/js/project-folder-preview.test.cjs delete mode 100644 web/static/js/project-related-facts.test.cjs delete mode 100644 web/static/js/projects.js delete mode 100644 web/static/js/proxy-settings.js delete mode 100644 web/static/js/proxy-settings.test.cjs delete mode 100644 web/static/js/rbac-admin-guard.test.cjs delete mode 100644 web/static/js/rbac-guards.js delete mode 100644 web/static/js/rbac.js delete mode 100644 web/static/js/roles.js delete mode 100644 web/static/js/router-hash-form.test.cjs delete mode 100644 web/static/js/router.js delete mode 100644 web/static/js/sanitize-markdown.js delete mode 100644 web/static/js/settings-header-boundaries.test.cjs delete mode 100644 web/static/js/settings-pi-resilience.test.cjs delete mode 100644 web/static/js/settings.js delete mode 100644 web/static/js/skill-description-save.test.cjs delete mode 100644 web/static/js/skills.js delete mode 100644 web/static/js/storage.js delete mode 100644 web/static/js/tasks.js delete mode 100644 web/static/js/terminal.js delete mode 100644 web/static/js/theme.js delete mode 100644 web/static/js/token-usage-analysis.test.cjs delete mode 100644 web/static/js/token-usage.js delete mode 100644 web/static/js/tool-blocked-display.test.cjs delete mode 100644 web/static/js/tool-guard.js delete mode 100644 web/static/js/tool-guard.test.cjs delete mode 100644 web/static/js/tool-result-args-backfill.test.cjs delete mode 100644 web/static/js/turn-duration-refresh.test.cjs delete mode 100644 web/static/js/update-ui.test.cjs delete mode 100644 web/static/js/update.js delete mode 100644 web/static/js/vulnerability-create.test.cjs delete mode 100644 web/static/js/vulnerability-download.js delete mode 100644 web/static/js/vulnerability-host-view.test.cjs delete mode 100644 web/static/js/vulnerability-retest.test.cjs delete mode 100644 web/static/js/vulnerability-workspace.js delete mode 100644 web/static/js/vulnerability.js delete mode 100644 web/static/js/webshell-file-path.test.cjs delete mode 100644 web/static/js/webshell-probe.test.cjs delete mode 100644 web/static/js/webshell.js delete mode 100644 web/static/js/wechat-robot.js delete mode 100644 web/static/js/workflow-package-client.js delete mode 100644 web/static/js/workflow-package-client.test.cjs delete mode 100644 web/static/js/workflow-package-ui.test.cjs delete mode 100644 web/static/js/workflow-save.test.cjs delete mode 100644 web/static/js/workflow-validity.test.cjs delete mode 100644 web/static/js/workflows.js delete mode 100644 web/static/vendor/cytoscape.min.js delete mode 100644 web/static/vendor/elk.bundled.js delete mode 100644 web/static/vendor/i18next.min.js delete mode 100644 web/static/vendor/marked.min.js delete mode 100644 web/static/vendor/purify.min.js delete mode 100644 web/static/vendor/xlsx.full.min.js delete mode 100644 web/static/vendor/xterm-addon-fit.js delete mode 100644 web/static/vendor/xterm.css delete mode 100644 web/static/vendor/xterm.js delete mode 100644 web/templates/api-docs.html delete mode 100644 web/templates/index.html diff --git a/.github/workflows/deep-assessments.yml b/.github/workflows/deep-assessments.yml index 8407b76a..6e589c5d 100644 --- a/.github/workflows/deep-assessments.yml +++ b/.github/workflows/deep-assessments.yml @@ -1,9 +1,9 @@ name: Deep assessments on: push: - paths: ['internal/deepassessment/**', 'internal/database/vulnerability*', 'internal/database/assessment*', 'internal/database/asset*', 'internal/database/schemas/application.sql', 'internal/app/vulnerability_tools.go', 'internal/app/assessment_finding_test.go', 'internal/handler/vulnerability*', 'internal/handler/deep_assessment*', 'internal/multiagent/**', 'internal/agentruntime/**', 'runtime/pi/**', 'web/static/js/deep-assessments.js', 'web/static/js/deep-assessment-graph.js', 'web/static/js/assessment-finding-links.js', 'web/static/js/assessment-exploration-views.js', 'web/static/js/assessment-node-panel.js', 'web/static/js/assessment-workbench.js', 'web/static/js/vulnerability*.js', 'web/static/css/deep-assessments.css', 'web/templates/index.html', 'scripts/deep-assessments-browser.test.cjs', 'scripts/assessment-findings-browser.test.cjs', '.github/workflows/deep-assessments.yml'] + paths: ['internal/deepassessment/**', 'internal/database/vulnerability*', 'internal/database/assessment*', 'internal/database/asset*', 'internal/database/schemas/application.sql', 'internal/app/vulnerability_tools.go', 'internal/app/assessment_finding_test.go', 'internal/handler/vulnerability*', 'internal/handler/deep_assessment*', 'internal/multiagent/**', 'internal/agentruntime/**', 'runtime/pi/**', 'web/frontend/**', '.github/workflows/deep-assessments.yml'] pull_request: - paths: ['internal/deepassessment/**', 'internal/database/vulnerability*', 'internal/database/assessment*', 'internal/database/asset*', 'internal/database/schemas/application.sql', 'internal/app/vulnerability_tools.go', 'internal/app/assessment_finding_test.go', 'internal/handler/vulnerability*', 'internal/handler/deep_assessment*', 'internal/multiagent/**', 'internal/agentruntime/**', 'runtime/pi/**', 'web/static/js/deep-assessments.js', 'web/static/js/deep-assessment-graph.js', 'web/static/js/assessment-finding-links.js', 'web/static/js/assessment-exploration-views.js', 'web/static/js/assessment-node-panel.js', 'web/static/js/assessment-workbench.js', 'web/static/js/vulnerability*.js', 'web/static/css/deep-assessments.css', 'web/templates/index.html', 'scripts/deep-assessments-browser.test.cjs', 'scripts/assessment-findings-browser.test.cjs', '.github/workflows/deep-assessments.yml'] + paths: ['internal/deepassessment/**', 'internal/database/vulnerability*', 'internal/database/assessment*', 'internal/database/asset*', 'internal/database/schemas/application.sql', 'internal/app/vulnerability_tools.go', 'internal/app/assessment_finding_test.go', 'internal/handler/vulnerability*', 'internal/handler/deep_assessment*', 'internal/multiagent/**', 'internal/agentruntime/**', 'runtime/pi/**', 'web/frontend/**', '.github/workflows/deep-assessments.yml'] permissions: contents: read jobs: @@ -24,9 +24,3 @@ jobs: - run: go test ./internal/app -run TestRecordVulnerabilityAssessmentEvidence - run: go test -race ./internal/deepassessment - run: go test -race ./internal/handler -run TestDeepAssessment - - name: Browser fixture dependencies - run: | - npm install --prefix "$RUNNER_TEMP/assessment-ui-deps" --no-save --ignore-scripts --package-lock=false playwright@1.65.0 - "$RUNNER_TEMP/assessment-ui-deps/node_modules/.bin/playwright" install --with-deps chromium - - name: Independent assessment and unchanged batch UI - run: NODE_PATH="$RUNNER_TEMP/assessment-ui-deps/node_modules" node --test scripts/deep-assessments-browser.test.cjs scripts/assessment-findings-browser.test.cjs scripts/batch-tasks-browser.test.cjs diff --git a/.github/workflows/frontend-build.yml b/.github/workflows/frontend-build.yml new file mode 100644 index 00000000..62be5d0f --- /dev/null +++ b/.github/workflows/frontend-build.yml @@ -0,0 +1,41 @@ +name: Frontend build + +on: + push: + paths: ['web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'internal/app/app.go', 'internal/app/spa_test.go', '.github/workflows/frontend-build.yml'] + pull_request: + paths: ['web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'internal/app/app.go', 'internal/app/spa_test.go', '.github/workflows/frontend-build.yml'] + +permissions: + contents: read +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Build React + Semi Design bundle + run: | + npm ci --prefix web/frontend + npm run --prefix web/frontend build + - name: Committed bundle matches sources + run: | + if [ -n "$(git status --porcelain web/static/app)" ]; then + echo "web/static/app is out of date; run: npm run --prefix web/frontend build" >&2 + git status --porcelain web/static/app >&2 + exit 1 + fi + - name: SPA entry and build artifacts + run: go test ./internal/app -run TestSPA -count=1 + - run: node --test web/frontend/tests/*.test.mjs + - name: Install Chromium for isolated UI tests + working-directory: web/frontend + run: npx playwright install --with-deps chromium + - name: Browser regression tests + run: npm run --prefix web/frontend test:ui -- --reporter=line diff --git a/.github/workflows/self-update.yml b/.github/workflows/self-update.yml index 2c693472..1f707f3a 100644 --- a/.github/workflows/self-update.yml +++ b/.github/workflows/self-update.yml @@ -1,9 +1,9 @@ name: Self-update on: push: - paths: ['internal/update/**', 'internal/app/update_restart*', 'internal/security/auth*', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/static/js/**', 'web/static/i18n/**', 'web/static/css/style.css', 'web/templates/index.html', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml'] + paths: ['internal/update/**', 'internal/app/update_restart*', 'internal/security/auth*', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml'] pull_request: - paths: ['internal/update/**', 'internal/app/update_restart*', 'internal/security/auth*', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/static/js/**', 'web/static/i18n/**', 'web/static/css/style.css', 'web/templates/index.html', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml'] + paths: ['internal/update/**', 'internal/app/update_restart*', 'internal/security/auth*', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml'] permissions: contents: read jobs: @@ -27,9 +27,12 @@ jobs: - name: Authentication and update session handoff run: go test -race ./internal/security -run '^(TestAuthManager|TestAttachRBACStore|TestRevokeRoleSessions|TestPublishSession|TestRestartHandoff)' - run: go build ./... - - name: Frontend regression tests + - name: Frontend build and SPA artifacts shell: bash - run: node --test web/static/js/*.test.cjs + run: | + npm ci --prefix web/frontend + npm run --prefix web/frontend build + go test ./internal/app -run TestSPA -count=1 - name: Shell syntax shell: bash run: bash -n run.sh upgrade.sh diff --git a/.github/workflows/task-ui.yml b/.github/workflows/task-ui.yml deleted file mode 100644 index 5090a58d..00000000 --- a/.github/workflows/task-ui.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Task management UI -on: - push: - paths: ['web/templates/index.html', 'web/static/js/tasks.js', 'web/static/js/router.js', 'web/static/js/auth.js', 'web/static/js/modal.js', 'web/static/js/rbac-guards.js', 'web/static/css/**', 'web/static/i18n/**', 'scripts/batch-tasks-browser.test.cjs', 'scripts/helpers/batch-task-ui-fixture.cjs', '.github/workflows/task-ui.yml'] - pull_request: - paths: ['web/templates/index.html', 'web/static/js/tasks.js', 'web/static/js/router.js', 'web/static/js/auth.js', 'web/static/js/modal.js', 'web/static/js/rbac-guards.js', 'web/static/css/**', 'web/static/i18n/**', 'scripts/batch-tasks-browser.test.cjs', 'scripts/helpers/batch-task-ui-fixture.cjs', '.github/workflows/task-ui.yml'] -permissions: - contents: read -jobs: - browser: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '22' - - name: Install isolated browser test dependencies - run: | - npm install --prefix "$RUNNER_TEMP/task-ui-deps" --no-save --ignore-scripts --package-lock=false playwright@1.65.0 - "$RUNNER_TEMP/task-ui-deps/node_modules/.bin/playwright" install --with-deps chromium - - name: Test real task page entrypoints and controls - run: | - NODE_PATH="$RUNNER_TEMP/task-ui-deps/node_modules" node --test scripts/batch-tasks-browser.test.cjs diff --git a/.gitignore b/.gitignore index 5356779a..b7d3c996 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,8 @@ __pycache__/ # Node / browser extension node_modules/ +/web/frontend/test-results/ +/web/frontend/playwright-report/ # macOS / Windows / editors .DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index 62b0e5d8..4c2fd2e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 2026-11-19 · 前端整体迁移到 React + Semi Design + +- Web 界面重写为 Vite 构建的 React 19 单页应用,组件统一使用 Semi Design;页面按 `#/<页面 id>` 路由, + 深链接(会话、漏洞、项目、测评、设置分区、MCP 执行、HITL 审批)保持可分享。 +- 服务端不再渲染业务模板:`GET /` 直接返回 `web/static/app/index.html`,`/api-docs` 302 到 `/#/api-docs`, + API 文档改为应用内 OpenAPI 浏览器(含在线调试)。 +- 复用既有 REST 接口、`cyberstrike-auth` 会话令牌、`cyberstrike-theme` 主题偏好与 `web/static/i18n` 词条; + 新增 `src/lib/http.js` 统一注入令牌、错误与 SSE 解析,`components/ui.jsx` 统一页面骨架、表格、指标卡、 + Markdown/JSON 视图与抽屉。 +- 30 个业务页面 + API 文档全部由 React 组件实现,覆盖对话流式回复与内联审批、深度测评图谱与验收、 + 资产/漏洞/项目/任务/工作流、WebShell 与 C2、MCP 与 HITL、知识与技能、角色与平台权限、系统设置。 +- 新增 `internal/app/spa_test.go` 校验构建产物与入口路由;CI 增加 `frontend-build.yml`, + `self-update.yml` 的前端回归改为构建校验,移除依赖旧模板的 `task-ui.yml` 与浏览器夹具测试。 + ## 2026-11-15 · 深度测评工作台与完整链路 - 探索图增加主链路/执行记录两种视图,跨页引用和原始上下游分页导航;归档按真实分支分组,重新引用后重新计冷却轮次,漏洞与人工线索保持可见,旧归档链接继续可读。 diff --git a/docs/en-US/frontend-i18n.md b/docs/en-US/frontend-i18n.md index e9b65533..d8a53376 100644 --- a/docs/en-US/frontend-i18n.md +++ b/docs/en-US/frontend-i18n.md @@ -2,53 +2,38 @@ [中文](../zh-CN/frontend-i18n.md) -CyberStrikeAI frontend i18n is static and lightweight. Text is organized in JSON files and applied through `data-i18n` attributes plus JavaScript helper functions. +The web UI is a React + Semi Design single-page app. Translations come from +`web/frontend/src/lib/i18n.jsx`, backed by the same JSON files the backend ships. ## Files ```text web/static/i18n/zh-CN.json web/static/i18n/en-US.json -web/static/js/i18n.js +web/static/i18n/ru-RU.json +web/static/i18n/ar-SA.json +web/frontend/src/lib/i18n.jsx ``` -## Key Principles +## Runtime behavior -- Keep keys stable and semantic. -- Update Chinese and English together. -- Do not hardcode new visible text in JS when it should be localized. -- Preserve default HTML text as fallback before JS initialization. +- Preference is stored in `localStorage['csai_lang']`; otherwise it follows `navigator.language`, defaulting to `zh-CN`. +- The provider loads the active language plus `zh-CN` and `en-US` fallbacks; lookups fall back `active → zh-CN → en-US → caller default`. +- Switching language updates ``, sets `dir="rtl"` for Arabic, and swaps Semi's `ConfigProvider` locale. +- No page reload is required; `useT()` re-renders consumers. -## HTML Usage +## Usage -```html - +```jsx +const t = useT(); +t('vulnerability.title'); +t('common.minutesAgo', { n: 5 }); // {{n}} interpolation +t('chat.unknownKey', null, '中文兜底'); // explicit Chinese fallback ``` -For attributes, follow the existing `i18n.js` conventions. +Rules: -## JavaScript Usage - -Use the global translation helper where available: - -```javascript -const label = t('common.save'); -``` - -When adding dynamic UI, make sure language switching refreshes the text or re-renders the component. - -## Migration Workflow - -1. Add or update UI text. -2. Add keys to `zh-CN.json`. -3. Add matching keys to `en-US.json`. -4. Replace hardcoded text with `data-i18n` or `t()`. -5. Test both languages and browser console. - -## Common Pitfalls - -- Missing keys only in one language. -- Dynamic text built from hardcoded fragments. -- Button labels too long in English. -- HTML fallback text diverges from JSON text. -- Adding new page text without updating language switch behavior. +1. Every visible string goes through `t(...)` with a Chinese fallback as the third argument. +2. Add new keys to `zh-CN.json` and `en-US.json` together; `ru-RU`/`ar-SA` may lag and rely on the fallback chain. +3. Format dates with `formatDateTime`/`relativeTime` from `src/lib/format.js`. +4. Keep keys two levels deep (`.`) and stable across releases. diff --git a/docs/en-US/plugin-development.md b/docs/en-US/plugin-development.md index 262ea2e8..b5a92574 100644 --- a/docs/en-US/plugin-development.md +++ b/docs/en-US/plugin-development.md @@ -117,4 +117,4 @@ Plugins should not bypass platform controls: - Capture: `devtools.js`, `background/service-worker.js` - OpenAPI: `internal/handler/openapi.go` - External MCP: `internal/handler/external_mcp.go` -- Web auth reference: `web/static/js/auth.js` +- Web auth reference: `web/frontend/src/lib/auth.jsx` diff --git a/docs/en-US/testing.md b/docs/en-US/testing.md index 6b4c62d2..495d6abf 100644 --- a/docs/en-US/testing.md +++ b/docs/en-US/testing.md @@ -40,7 +40,7 @@ Expand testing when changing: - `internal/multiagent/`: streaming, tool calls, summarization, retry, HITL; - `internal/security/`: auth, shell, timeout, no-output; - `internal/database/`: old data compatibility; -- `web/static/js/chat.js`: chat, process details, attack chain, groups. +- `web/frontend/src/pages/chat/`: chat, process details, attack chain, groups. ## Test Data diff --git a/docs/en-US/workflow-graph.md b/docs/en-US/workflow-graph.md index 64fb51f4..371eaf7f 100644 --- a/docs/en-US/workflow-graph.md +++ b/docs/en-US/workflow-graph.md @@ -580,6 +580,6 @@ On save, the system checks: | Graph validation | `internal/workflow/validation.go` | | Expressions / JSONPath / joins | `internal/workflow/expression.go`, `jsonpath.go`, `join.go` | | Dry-run / replay data | `internal/workflow/dry_run.go`, `internal/handler/workflow_run.go` | -| Canvas UI | `web/static/js/workflows.js` | +| Canvas UI | `web/frontend/src/pages/workflows/` | | Workflow API | `internal/handler/workflow.go` | | Role binding | `internal/config/config.go` (`workflow_id` field) | diff --git a/docs/ui-design-system.md b/docs/ui-design-system.md index 7193bf27..35904c58 100644 --- a/docs/ui-design-system.md +++ b/docs/ui-design-system.md @@ -1,68 +1,34 @@ -# 界面样式约定 +# 前端设计系统 -主应用的公共样式位于 `web/static/css/design-system.css`,在模块与移动端 CSS 后加载。 -颜色沿用现有主题变量;抽屉外框统一为直角,卡片圆角 16px,控件圆角 10px,桌面正文内边距 24px,移动端 16px。 -状态色、选中态、图表、终端和工作流画布保留各自的业务语义。 +主应用前端已统一迁移到 [Semi Design](https://semi.design/zh-CN/)(React 19 + Vite), +不再维护手写 HTML/CSS/JS 的组件体系。 -## 容器选择 +## 结构 -- 详情、日志、长表单:右侧抽屉,默认 720px;代码、长文本等宽编辑面板 960px;标题栏可展开至 1440px。 -- 手机(小于 768px):抽屉全屏,适配安全区,正文单独滚动,底部操作保持可见。 -- 确认、重命名、简短绑定:居中短弹窗,手机上同样保持紧凑。 -- 数据比较和批量操作继续使用表格;终端、工作流、会话工作区不强制改成卡片列表。 +- 页面:`web/frontend/src/pages/<页面 id>/index.jsx`,路由 `#/<页面 id>`。 +- 共享组件:`web/frontend/src/components/ui.jsx`(PageHeader、SectionCard、DataTable、StatGrid、ErrorBanner、MarkdownView、JsonViewer、Drawer 等)。 +- 外壳样式:`web/frontend/src/styles/app.css`,只放布局与共享排版;颜色一律用 Semi 变量。 +- 构建产物:`web/static/app/`,由 Go 直接提供。 -`web/static/js/modal.js` 的 `DRAWER_IDS` 和 `WIDE_IDS` 管理既有模块迁移清单。 -新模块应通过 `openAppModal` / `closeAppModal` 开关容器,关闭时保留原有清理和未保存提示逻辑。 -共用生命周期负责嵌套层级、背景滚动锁定、焦点返回、Tab 焦点约束和 Escape 触发原关闭按钮。 -异步更新的标题栏会自动补齐展开按钮。短 C2 休眠设置仍为弹窗。 +## 颜色与主题 -不要再为单个抽屉添加独立的定位、遮罩、圆角或主题色覆盖。 -现阶段公共布局中少量 `!important` 用于覆盖历史内联宽高和移动端旧规则;后续修改这些模块时可逐步去除对应历史声明。 +品牌主色 `#3266e3`(暗色 `#81a7ff`),通过覆盖 `--semi-color-primary` 等变量接入 Semi 主题, +暗色由 `body[theme-mode="dark"]` 驱动,偏好保存在 `localStorage['cyberstrike-theme']`(system/light/dark)。 -## 验证 +## 组件约定 -前端回归: +- 列表页用 `DataTable` + `useResource`,统一 loading / 空态 / 错误态(`ErrorBanner`)。 +- 指标卡用 `StatGrid`/`StatCard`;详情抽屉用 `Drawer`(封装 Semi `SideSheet`)。 +- 危险操作用 `confirmAction`;反馈用 `toastSuccess`/`toastError`。 +- Markdown 统一走 `MarkdownView`(marked + DOMPurify),不要自行插入 HTML。 + +## 校验 ```sh -node --test web/static/js/*.test.cjs +npm ci --prefix web/frontend +npm run --prefix web/frontend build +go test ./internal/app -run TestSPA -count=1 ``` -浏览器验证需要外部安装的 Playwright 和 Chromium,例如: - -```sh -npm install --prefix /tmp/csai-ui-tools playwright -/tmp/csai-ui-tools/node_modules/.bin/playwright install chromium -NODE_PATH=/tmp/csai-ui-tools/node_modules node scripts/check-ui-design-system.cjs -``` - -脚本使用真实模板、样式和选定模块的真实渲染函数,配以合成数据;不启动后端或访问测试目标。 -检查 1440、1024、390、360px 四档屏宽和深浅主题,验证抽屉边界、内部横向溢出、底栏、嵌套层级、展开、键盘关闭、焦点返回,以及主页面横向溢出。 -截图与结果默认写入系统临时目录,也可通过 `CSAI_UI_ARTIFACTS` 指定目录。 -这覆盖界面布局和公共交互,不等同于真实后端数据、保存操作、所有下拉菜单状态或物理手机软键盘的完整验收。 - -### 真实数据形态回归(Kali 界面验收后补充) - -`check-ui-design-system.cjs` 现在调用 `ui-realistic-scenarios.cjs`,并加载真实 i18next/翻译实现。 -回归数据依据实际页面的数量、文本长度和按钮状态匿名构造,不复制目标地址、凭据或业务证据。 - -- 365 条队列任务,分别渲染暂停、运行、完成状态;验证真实操作按钮不会挤压标题或越界。 -- 626 个工具、614 个已启用工具及长描述;使用真实角色编辑入口检查统计换行和正文滚动。 -- 角色与多文件 Skill 的新增/编辑切换,以及打开编辑后跨越桌面/手机断点;验证翻译刷新不改变编辑标题。 -- 深度测评的原生 dialog 创建和详情入口:公共样式、宽度展开、Escape 关闭、展开状态重置和稳定的可访问名称。 -- 50 条长漏洞记录和三页分页:验证手机整页滚动,标题与分页不会固定占用记录区。 - -所有场景都在四档屏宽与两种主题下运行;夹具请求拒绝非 GET 操作。 -需要定位单个断点时可设置 `CSAI_UI_WIDTHS=390`;提交前省略该变量运行完整矩阵。 - -### 队列动态文案与按钮对比度 - -队列标题将可翻译的前缀与原样保留的队列名称分开渲染;执行按钮的 `data-i18n` 随暂停、待执行及 Cron 状态更新。 -主要操作的小号按钮明确使用强调色背景和配套文字色,避免旧尺寸样式把背景改灰后仍保留深色文字。 - -回归增加了:暂停/待执行/运行/完成/取消、Cron 开关、中英文切换、桌面与手机断点切换、空标题和含特殊字符的标题。 -针对可见的开始/继续/重跑按钮,检查正常、悬停和键盘焦点状态下的计算颜色,要求文字与不透明背景的对比度不低于 4.5:1;每档尺寸和主题的计算结果保存为 `queue-contrast-*.json`。 -浏览器回归使用真实 i18next 翻译函数,不再用固定中文替代函数覆盖它。 - -Skill 的“查看”入口动态创建 `skill-view-modal`,与编辑入口共用宽抽屉。回归同时验证摘要展示、按需加载全文、展开、Escape 清理以及“查看 → 编辑”切换,防止只验证编辑表单而遗漏只读详情入口。 - -信息收集的字段全文、AI 查询解析结果,以及 WebShell 数据库连接配置也使用公共抽屉。信息收集动态节点采用标准 header/body/footer 类和公共关闭逻辑;回归使用长文本、警告说明与离线数据库配置夹具,检查滚动、重复打开、复制、仅应用查询语法和关闭清理,不执行外部查询或数据库连接。 +`internal/app/spa_test.go` 会检查 `web/static/app/index.html` 引用的哈希资源是否存在, +防止构建产物缺失或未提交。页面开发契约见 `web/frontend/CONTRACT.md`。 diff --git a/docs/zh-CN/architecture.md b/docs/zh-CN/architecture.md index 72a2c0a7..9b775baf 100644 --- a/docs/zh-CN/architecture.md +++ b/docs/zh-CN/architecture.md @@ -24,10 +24,10 @@ flowchart LR 入口在 `cmd/server/`,应用组装在 `internal/app/`。Web 使用 Gin: -- `web/templates/index.html`:主页面。 -- `web/templates/api-docs.html`:API 文档页面。 -- `web/static/js/`:各业务模块前端逻辑。 -- `web/static/css/`:样式。 +- `web/frontend/`:前端源码(React 19 + Semi Design,Vite 构建),页面位于 `src/pages/<页面 id>/`。 +- `web/static/app/`:前端构建产物,`GET /` 直接返回其中的 `index.html`,`/api-docs` 跳转到 `/#/api-docs`。 +- `web/static/i18n/`:多语言词条,前端与后端共用。 +- `web/static/`:Logo、favicon 与多语言等公共静态资源。 路由注册集中在 `internal/app/app.go`。 diff --git a/docs/zh-CN/developer-guide.md b/docs/zh-CN/developer-guide.md index 025cf680..7e7add17 100644 --- a/docs/zh-CN/developer-guide.md +++ b/docs/zh-CN/developer-guide.md @@ -41,7 +41,7 @@ go run ./cmd/server --config config.yaml 2. 在 `internal/database/` 增加必要的数据访问。 3. 在 `internal/app/app.go` 构造并注册路由。 4. 如需对外文档,更新 `internal/handler/openapi.go`。 -5. 如需前端调用,更新 `web/static/js/`。 +5. 如需前端调用,更新 `web/frontend/src/pages/`。 ## 一键更新:让安装目录更新它自己的源码 @@ -203,7 +203,7 @@ Skill 放在 `skills//SKILL.md`。用于提供专题能力、流程说明 ## 前端开发 -前端代码按功能拆分在 `web/static/js/`。新增页面或模块时: +前端代码按功能拆分在 `web/frontend/src/pages/`。新增页面或模块时: - 复用现有 `apiFetch`、modal、通知、i18n 工具。 - 同步更新 `web/static/i18n/zh-CN.json` 和 `en-US.json`。 diff --git a/docs/zh-CN/frontend-i18n.md b/docs/zh-CN/frontend-i18n.md index 7a9f832f..d1509a30 100644 --- a/docs/zh-CN/frontend-i18n.md +++ b/docs/zh-CN/frontend-i18n.md @@ -1,335 +1,33 @@ -## CyberStrikeAI 前端国际化方案 +# 前端国际化 -本文档说明 CyberStrikeAI Web 前端(`web/templates/index.html` + `web/static/js/*.js`)的国际化设计与开发规范,确保在不引入打包工具和不改动后端路由的前提下,实现可扩展、低返工的多语言支持。 +前端已迁移为 React + Semi Design 单页应用,国际化由 `web/frontend/src/lib/i18n.jsx` 提供, +词条继续复用后端同目录 `web/static/i18n/*.json`(zh-CN / en-US / ru-RU / ar-SA)。 -当前目标: +## 运行时行为 -- **支持中英文切换(zh-CN / en-US)** -- 后续可方便扩展更多语言(如 ja-JP、ko-KR 等) +- 语言偏好保存在 `localStorage['csai_lang']`,未设置时按 `navigator.language` 推断,默认 `zh-CN`。 +- 启动时并行加载当前语言、`zh-CN` 兜底与 `en-US`(第三兜底)三份词条;缺失的键按「当前语言 → zh-CN → en-US → 调用方兜底中文」回退。 +- 切换语言会更新 ``,阿拉伯语自动把 `` 设为 `rtl`,并通过 Semi `ConfigProvider` 切换组件语言包。 +- 语言切换不会刷新页面;`useT()` 返回的 `t` 会随 Provider 重新渲染。 ---- +## 在页面里使用 -## 一、总体设计原则 - -- **前端主导的客户端国际化**:所有 UI 文案在浏览器端根据当前语言动态渲染,后端 Go 仅负责结构和数据,不参与语言分发。 -- **单一 HTML 模板**:继续使用一份 `index.html` 模板,不为不同语言复制模板文件。 -- **文案与逻辑分离**:所有可见文本通过「键值表」管理(多语言 JSON),HTML / JS 只写 key,不直接写中文/英文常量。 -- **渐进式改造**:先覆盖 header / 登录 / 侧边栏 / 系统设置等关键区域,其他页面按模块逐步迁移,避免一次性大改动。 -- **可回退默认语言**:即使目标语言未完全翻译,也能回退到默认中文,不出现原始 key。 - ---- - -## 二、技术选型与目录结构 - -### 2.1 技术选型 - -- **i18n 引擎**:使用 [i18next](https://www.i18next.com/) 的浏览器 UMD 版本(通过 CDN 引入),无需打包器。 -- **资源格式**:每种语言一份 JSON 文件,采用「域 + 语义」的层级 key 方案,例如: - - `common.ok` - - `nav.dashboard` - - `header.apiDocs` - - `settings.robot.wecom.token` - -### 2.2 目录结构 - -- `web/templates/index.html` - - 页面骨架 + 所有静态文案位置,将逐步改为 `data-i18n` 标记。 -- `web/static/js/i18n.js` - - 前端 i18n 初始化与 DOM 应用逻辑(本方案新增)。 -- `web/static/i18n/`(新增目录) - - `zh-CN.json`:中文文案(默认语言) - - `en-US.json`:英文文案 - - 未来可新增:`ja-JP.json`、`ko-KR.json` 等。 - ---- - -## 三、文案组织规范 - -### 3.1 Key 命名约定 - -- 采用「**模块.语义**」形式,最多 2–3 级,确保可读性: - - 导航:`nav.dashboard`、`nav.chat`、`nav.settings` - - 头部:`header.title`、`header.apiDocs`、`header.logout` - - 登录:`login.title`、`login.subtitle`、`login.passwordLabel`、`login.submit` - - 仪表盘:`dashboard.title`、`dashboard.refresh`、`dashboard.runningTasks` - - 系统设置:`settings.title`、`settings.nav.basic`、`settings.nav.robot`、`settings.apply` - - 机器人配置:`settings.robot.wecom.enabled`、`settings.robot.wecom.token` 等。 -- 尽量按「界面区域」而不是「文件名」划分域,便于非开发人员理解。 - -### 3.2 JSON 示例 - -`web/static/i18n/zh-CN.json` 示例: - -```json -{ - "common": { - "ok": "确定", - "cancel": "取消" - }, - "nav": { - "dashboard": "仪表盘", - "chat": "对话", - "infoCollect": "信息收集", - "tasks": "任务管理", - "vulnerabilities": "漏洞管理", - "settings": "系统设置" - }, - "header": { - "title": "CyberStrikeAI", - "apiDocs": "API 文档", - "logout": "退出登录", - "language": "界面语言" - }, - "login": { - "title": "登录 CyberStrikeAI", - "subtitle": "请输入配置中的访问密码", - "passwordLabel": "密码", - "passwordPlaceholder": "输入登录密码", - "submit": "登录" - } -} +```jsx +const t = useT(); +t('vulnerability.title'); // 词条里存在键 +t('common.minutesAgo', { n: 5 }); // 支持 {{n}} 插值 +t('chat.unknownKey', null, '中文兜底'); // 键缺失时用第三参数 ``` -英文文件 `en-US.json` 保持相同 key,不同 value: +要求: -```json -{ - "common": { - "ok": "OK", - "cancel": "Cancel" - }, - "nav": { - "dashboard": "Dashboard", - "chat": "Chat", - "infoCollect": "Recon", - "tasks": "Tasks", - "vulnerabilities": "Vulnerabilities", - "settings": "Settings" - }, - "header": { - "title": "CyberStrikeAI", - "apiDocs": "API Docs", - "logout": "Sign out", - "language": "Interface language" - }, - "login": { - "title": "Sign in to CyberStrikeAI", - "subtitle": "Enter the access password from config", - "passwordLabel": "Password", - "passwordPlaceholder": "Enter password", - "submit": "Sign in" - } -} -``` +1. 可见文案统一走 `t(...)`,第三个参数写中文兜底,避免出现原始 key。 +2. 新增词条时同时更新 `web/static/i18n/zh-CN.json` 与 `en-US.json`;`ru-RU`/`ar-SA` 可暂时缺失,靠回退链。 +3. 表单校验、Toast、空态文案同样走 `t(...)`。 +4. 时间格式化使用 `src/lib/format.js` 的 `formatDateTime/relativeTime`,不要手拼日期。 -> 约定:**新增界面时,必须先定义 i18n key,再在 HTML/JS 中使用 key**,禁止直接写死中文/英文。 - ---- - -## 四、HTML 标记规范(data-i18n) - -### 4.1 基本规则 - -- 使用 `data-i18n` 将元素文本与某个 key 绑定: - -```html -仪表盘 -``` - -- 默认行为:脚本会替换元素的 `textContent`。 -- 同时翻译属性时,额外使用 `data-i18n-attr`,逗号分隔多个属性名: - -```html - -``` - -### 4.2 默认文本的作用 - -- HTML 内的中文默认值作为「**无 JS / 初始化前**」的占位内容: - - 页面在 JS 尚未加载完成时不会出现空白或 key。 - - JS 初始化后会用当前语言覆盖这些文本。 - ---- - -## 五、JavaScript 中的文案规范 - -### 5.1 全局翻译函数 `t()` - -由 `i18n.js` 暴露以下全局函数: - -- `window.t(key: string): string` - - 返回当前语言下的翻译文本,若缺失则回退到默认语言,再不行则返回 key 本身。 -- `window.changeLanguage(lang: string): Promise` - - 切换语言并刷新页面文案(不会刷新整页)。 - -示例(以 `web/static/js/settings.js` 为例): - -```js -// 之前 -alert('加载配置失败: ' + error.message); - -// 之后 -alert(t('settings.loadConfigFailed') + ': ' + error.message); -``` - -> 规范:**JS 内所有面向用户的提示、按钮文字、对话框标题都应通过 `t()` 获取**,不直接写死中文/英文。 - -### 5.2 渐进迁移建议 - -- 优先改造: - - 频繁弹出的错误提示 / 成功提示; - - 登录相关、系统设置相关文案。 -- 低优先级: - - 仅面向运维人员的调试提示,可以暂时保留英文/中文常量。 - ---- - -## 六、i18n 初始化与语言切换实现 - -### 6.1 语言选择策略 - -- 默认语言:`zh-CN`。 -- 优先级(从高到低): - 1. `localStorage` 中的用户选择(key:`csai_lang`)。 - 2. 浏览器 `navigator.language`(`zh` 开头 → `zh-CN`,否则 `en-US`)。 - 3. 默认 `zh-CN`。 - -### 6.2 初始化流程(`i18n.js`) - -1. 读取初始语言。 -2. 初始化 i18next: - - `lng` 为当前语言; - - `fallbackLng` 为 `zh-CN`; - - 资源先留空,采用按需加载。 -3. 通过 `fetch` 拉取 `/static/i18n/{lng}.json` 并 `i18next.addResources`。 -4. 更新: - - `` 属性; - - 所有带 `data-i18n` / `data-i18n-attr` 的元素。 -5. 暴露 `window.t` 与 `window.changeLanguage`。 - -### 6.3 DOM 应用逻辑 - -伪代码: - -```js -function applyTranslations(root = document) { - const elements = root.querySelectorAll('[data-i18n]'); - elements.forEach(el => { - const key = el.getAttribute('data-i18n'); - if (!key) return; - const text = i18next.t(key); - if (text) { - el.textContent = text; - } - - const attrList = el.getAttribute('data-i18n-attr'); - if (attrList) { - attrList.split(',').map(s => s.trim()).forEach(attr => { - if (!attr) return; - const val = i18next.t(key); - if (val) el.setAttribute(attr, val); - }); - } - }); -} -``` - -> 对于由 JS 动态插入的元素,需要在插入后再次调用 `applyTranslations(新容器)`。 - ---- - -## 七、语言切换 UI 规范 - -### 7.1 位置与形态 - -- 位置:`index.html` header 右侧 `API 文档` 按钮附近(靠近用户头像)。 -- 交互形式: - - 一个紧凑的语言切换组件,例如: - - `🌐` 图标 + 当前语言文本(`中文` / `English`)的下拉按钮; - - 下拉内容列出所有可用语言。 - -### 7.2 示例结构 - -```html -
- - -
-``` - -对应 JS(在 `i18n.js` 中): - -```js -function onLanguageSelect(lang) { - changeLanguage(lang).then(updateLangLabel).catch(console.error); - closeLangDropdown(); -} - -function updateLangLabel() { - const labelEl = document.getElementById('current-lang-label'); - if (!labelEl) return; - const lang = i18next.language || 'zh-CN'; - labelEl.textContent = lang.startsWith('zh') ? '中文' : 'English'; -} -``` - -> 规范:**语言切换只更新文案,不刷新整页,也不修改 URL hash**。 - ---- - -## 八、开发流程建议 - -### 8.1 新增 / 修改界面的流程 - -1. 设计界面时,先列出所有文案。 -2. 在对应语言 JSON 中补充/修改 key 与翻译。 -3. 在 HTML 中使用 `data-i18n`,在 JS 中使用 `t('...')`。 -4. 在浏览器中切换中英文,确认两种语言显示都正确。 - -### 8.2 渐进式改造顺序(推荐) - -1. **阶段 1(已规划)** - - 引入 i18next 与 `i18n.js`。 - - 新建 `zh-CN.json` / `en-US.json`(先覆盖 header / 登录 / 左侧导航)。 - - 实现 header 区域语言切换组件。 -2. **阶段 2**(已完成) - - 系统设置页面(包括机器人配置页面)全部文案 i18n 化。 - - `settings.js` 中的提示与错误信息改用 `t()`。 -3. **阶段 3**(进行中) - - 仪表盘、任务管理、漏洞管理、MCP、Skills、Roles 等页面按模块逐步迁移。 -4. **阶段 4** - - 清理 JS / HTML 中残留的硬编码中文,统一通过 i18n。 - ---- - -## 九、后续扩展新语言 - -当需要新增语言时: - -1. 在 `web/static/i18n/` 中新增 `{lang}.json`,复制现有英文/中文文件结构,补充对应翻译。 -2. 在语言切换下拉中添加对应选项,例如: - - `data-lang="ja-JP"` / 文本 `日本語` -3. 无需修改 `i18n.js` 或现有 HTML/JS 逻辑,即可支持新语言。 - ---- - -## 十、注意事项与坑点 - -- **不要复制多份 HTML 模板** 来做多语言,那样维护成本极高,本方案统一由前端 i18n 控制。 -- **避免 key 直接用中文/英文句子**,统一采用「模块.语义」短 key,便于 diff 与搜索。 -- 避免在 CSS 中写死文本(如 `content: "xxx"`),如确有需要,应通过 JS 设置并走 i18n。 -- 对于后端返回的可本地化错误文本(未来可能支持),优先由后端根据 `Accept-Language` 返回对应语言,前端只负责展示。 +## 词条组织 +`web/static/i18n/zh-CN.json` 按业务域分组:`common`、`nav`、`dashboard`、`vulnerability`、`chat`、 +`settings`、`knowledge`、`skills`、`roles`、`auth`、`apiDocs` 等。新增分组时保持两级键名 +(`.`),避免深层嵌套影响可读性。 diff --git a/docs/zh-CN/pi-runtime.md b/docs/zh-CN/pi-runtime.md index 772cfdca..b86dcc5a 100644 --- a/docs/zh-CN/pi-runtime.md +++ b/docs/zh-CN/pi-runtime.md @@ -66,7 +66,7 @@ npm test cd ../.. go test -race ./internal/agentruntime ./internal/multiagent ./internal/workflow ./internal/knowledge go test ./... -node --test web/static/js/*.test.cjs +npm run --prefix web/frontend build ``` SDK 集成测试使用本地模拟模型和无副作用的工具夹具,覆盖 OpenAI/Claude 动作建议、审批编辑、子代理工具边界、流式输出、取消、进程中断及备用模型切换。 diff --git a/docs/zh-CN/plugin-development.md b/docs/zh-CN/plugin-development.md index 3e082407..381fccf1 100644 --- a/docs/zh-CN/plugin-development.md +++ b/docs/zh-CN/plugin-development.md @@ -213,4 +213,4 @@ schema 越具体,HITL 越容易判断风险,Agent 也越不容易发散。 - 捕获:`devtools.js`、`background/service-worker.js` - OpenAPI:`internal/handler/openapi.go` - 外部 MCP:`internal/handler/external_mcp.go` -- Web 端认证参考:`web/static/js/auth.js` +- Web 端认证参考:`web/frontend/src/lib/auth.jsx` diff --git a/docs/zh-CN/testing.md b/docs/zh-CN/testing.md index 4fc06add..370b2e06 100644 --- a/docs/zh-CN/testing.md +++ b/docs/zh-CN/testing.md @@ -108,6 +108,15 @@ go build -o cyberstrike-ai ./cmd/server ## 前端冒烟 +前端是 React 19 + Semi Design 单页应用(`web/frontend`)。构建与产物校验: + +```sh +npm ci --prefix web/frontend +npm run --prefix web/frontend build +git status --porcelain web/static/app # 应为空,产物需随源码提交 +go test ./internal/app -run TestSPA -count=1 +``` + 修改前端后至少验证: - 登录和退出。 @@ -115,8 +124,9 @@ go build -o cyberstrike-ai ./cmd/server - 新建对话和流式回复。 - 设置页面保存。 - 相关业务页面增删改查。 -- 中英文切换。 -- 浏览器控制台无明显错误。 +- 中英文切换与暗色主题。 +- 逐个访问 `#/<页面 id>`(清单见 `web/frontend/src/lib/nav.js`),浏览器控制台无 error、无页面异常。 +- 深链接可直接打开:`#/chat?conversation=…`、`#/vulnerabilities?id=…`、`#/projects?id=…`、`#/settings?section=…`。 ## 高风险模块测试 @@ -149,7 +159,7 @@ C2、WebShell、终端、批量任务只能在授权测试环境验证。测试 - `internal/multiagent/`:测流式、工具调用、摘要、重试、HITL。 - `internal/security/`:测认证、Shell、超时、无输出。 - `internal/database/`:测旧数据兼容。 -- `web/static/js/chat.js`:测对话、过程详情、攻击链、分组。 +- `web/frontend/src/pages/chat/`:测对话、过程详情、攻击链、分组。 ## 测试数据管理 diff --git a/docs/zh-CN/workflow-graph.md b/docs/zh-CN/workflow-graph.md index 1e4f8306..fe3bcd63 100644 --- a/docs/zh-CN/workflow-graph.md +++ b/docs/zh-CN/workflow-graph.md @@ -580,6 +580,6 @@ token 与成本是否存在取决于底层模型/Agent 事件是否上报 usage | 图校验 | `internal/workflow/validation.go` | | 表达式 / JSONPath / 汇聚 | `internal/workflow/expression.go`、`jsonpath.go`、`join.go` | | dry-run / replay 数据 | `internal/workflow/dry_run.go`、`internal/handler/workflow_run.go` | -| 画布前端 | `web/static/js/workflows.js` | +| 画布前端 | `web/frontend/src/pages/workflows/` | | 流程 API | `internal/handler/workflow.go` | | 角色绑定 | `internal/config/config.go`(`workflow_id` 字段) | diff --git a/internal/app/app.go b/internal/app/app.go index 207adf98..8b3cc6b4 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -1542,22 +1542,18 @@ func setupRoutes( // OpenAPI规范(需要认证,避免暴露API结构信息) protected.GET("/openapi/spec", openAPIHandler.GetOpenAPISpec) - // API文档页面(公开访问,但需要登录后才能使用API) - router.GET("/api-docs", func(c *gin.Context) { - c.HTML(http.StatusOK, "api-docs.html", nil) - }) - - // 静态文件 + // 静态文件(前端为 React + Semi Design 单页应用,构建产物在 web/static/app) router.Static("/static", "./web/static") - router.LoadHTMLGlob("web/templates/*") + + // API 文档已并入单页应用路由(#/api-docs),保留旧地址跳转 + router.GET("/api-docs", func(c *gin.Context) { + c.Redirect(http.StatusFound, "/#/api-docs") + }) // 前端页面 router.GET("/", func(c *gin.Context) { - version := app.config.Version - if version == "" { - version = "v1.0.0" - } - c.HTML(http.StatusOK, "index.html", gin.H{"Version": version}) + c.Header("Cache-Control", "no-cache") + c.File("./web/static/app/index.html") }) } diff --git a/internal/app/spa_test.go b/internal/app/spa_test.go new file mode 100644 index 00000000..a3f844cd --- /dev/null +++ b/internal/app/spa_test.go @@ -0,0 +1,57 @@ +package app + +import ( + "os" + "path/filepath" + "regexp" + "strings" + "testing" +) + +// TestSPABuildArtifacts 校验前端构建产物已随仓库提交: +// 首页必须引用 /static/app/assets/ 下的哈希资源,且这些文件真实存在。 +// 前端源码在 web/frontend,构建命令:npm run --prefix web/frontend build。 +func TestSPABuildArtifacts(t *testing.T) { + root := filepath.Join("..", "..", "web", "static", "app") + indexPath := filepath.Join(root, "index.html") + index, err := os.ReadFile(indexPath) + if err != nil { + t.Fatalf("前端构建产物缺失 %s: %v", indexPath, err) + } + html := string(index) + if !strings.Contains(html, `
`) { + t.Fatalf("index.html 缺少 React 挂载点: %s", indexPath) + } + + assetPattern := regexp.MustCompile(`(?:src|href)="(/static/app/[^"]+)"`) + matches := assetPattern.FindAllStringSubmatch(html, -1) + if len(matches) == 0 { + t.Fatalf("index.html 未引用任何构建资源: %s", indexPath) + } + staticRoot := filepath.Join("..", "..", "web", "static") + for _, match := range matches { + relative := strings.TrimPrefix(match[1], "/static/") + if strings.HasPrefix(relative, "favicon") || strings.HasPrefix(relative, "site.webmanifest") { + continue + } + assetPath := filepath.Join(staticRoot, filepath.FromSlash(relative)) + if _, err := os.Stat(assetPath); err != nil { + t.Fatalf("index.html 引用的资源不存在: %s", assetPath) + } + } +} + +// TestSPAEntryDoesNotDependOnLegacyTemplates 防止页面回退到 Go 模板渲染。 +func TestSPAEntryDoesNotDependOnLegacyTemplates(t *testing.T) { + source, err := os.ReadFile("app.go") + if err != nil { + t.Fatal(err) + } + code := string(source) + if strings.Contains(code, "LoadHTMLGlob") { + t.Fatal("app.go 仍在加载 Go 模板,前端应统一由 web/static/app 提供") + } + if !strings.Contains(code, `c.File("./web/static/app/index.html")`) { + t.Fatal("app.go 未通过 c.File 提供前端入口") + } +} diff --git a/internal/app/template_render_test.go b/internal/app/template_render_test.go deleted file mode 100644 index c09373e7..00000000 --- a/internal/app/template_render_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package app - -import ( - "bytes" - "html/template" - "path/filepath" - "testing" -) - -func TestFrontendTemplatesRender(t *testing.T) { - templates, err := template.ParseGlob(filepath.Join("..", "..", "web", "templates", "*")) - if err != nil { - t.Fatalf("server template initialization fails: %v", err) - } - var output bytes.Buffer - if err = templates.ExecuteTemplate(&output, "index.html", map[string]interface{}{"Version": "test"}); err != nil { - t.Fatal(err) - } -} diff --git a/scripts/assessment-findings-browser.test.cjs b/scripts/assessment-findings-browser.test.cjs deleted file mode 100644 index 30074d83..00000000 --- a/scripts/assessment-findings-browser.test.cjs +++ /dev/null @@ -1,153 +0,0 @@ -const {test}=require('node:test'); -const assert=require('node:assert/strict'); -const fs=require('node:fs'); -const path=require('node:path'); -const http=require('node:http'); -const {chromium}=require('playwright'); -const root=path.join(__dirname,'..'); -const read=file=>fs.readFileSync(path.join(root,file),'utf8'); -const template=read('web/templates/index.html'); -function div(id){ - const start=template.indexOf(`
=0,id); - const tags=/<\/?div\b[^>]*>/g;tags.lastIndex=start;let depth=0,m; - while((m=tags.exec(template))){depth+=m[0].startsWith('',impact:'fixture impact',recommendation:'fixture fix',created_at:now,updated_at:now,targets:[{host:'example.test',raw:'https://example.test/account',domain:'example.test'}]}; - const batch={id:'batch-finding',title:'批量任务原有漏洞',severity:'medium',status:'open',description:'batch fixture',target:'https://batch.example.test',task_id:'same-id',task_queue_id:'batch-queue',task_queue_title:'原批量队列',created_at:now,updated_at:now}; - const state={task,sourceStep,finding,batch,requests:[],errors:[],canOpen:true}; - const locale=JSON.stringify(JSON.parse(read('web/static/i18n/zh-CN.json'))).replaceAll('<','\\u003c'); - const scripts=['router','auth','modal','vulnerability','assessment-finding-links','vulnerability-workspace','assessment-workbench','assessment-node-panel','assessment-exploration-views','deep-assessment-graph','deep-assessments'].map(x=>``).join(''); - const styles=['style','mobile','vulnerability-workspace','vulnerability-list','deep-assessments','design-system'].map(x=>``).join(''); - const html=`${styles}
${div('page-deep-assessments')}${div('page-vulnerabilities')}
${div('vulnerability-inspector')}${scripts}`; - const server=http.createServer(async(req,res)=>{ - const url=new URL(req.url,'http://fixture'); - const send=(code,data)=>{res.statusCode=code;res.setHeader('Content-Type','application/json; charset=utf-8');res.end(JSON.stringify(data));}; - try{ - if(url.pathname.startsWith('/static/')){res.setHeader('Content-Type',url.pathname.endsWith('.css')?'text/css':'text/javascript');return res.end(read('web'+url.pathname));} - if(url.pathname==='/'){res.setHeader('Content-Type','text/html; charset=utf-8');return res.end(html);} - if(url.pathname==='/favicon.ico'){res.statusCode=204;return res.end();} - state.requests.push({path:url.pathname,query:Object.fromEntries(url.searchParams),method:req.method}); - if(req.headers.authorization!=='Bearer fixture-token')return send(401,{error:'authentication missing'}); - if(url.pathname==='/api/projects')return send(200,{projects:[]}); - if(url.pathname==='/api/deep-assessments')return send(200,{tasks:[task],has_more:false}); - if(url.pathname==='/api/deep-assessments/same-id')return send(200,{task,step_total:101,step_next_offset:50,step_has_more:true}); - if(url.pathname==='/api/deep-assessments/same-id/graph')return send(200,{nodes:[{id:'goal',kind:'goal',state:'completed',title:task.name,body:'',source:{}}],edges:[],total:0,folded:0,has_more:false}); - if(url.pathname==='/api/deep-assessments/same-id/steps/review-step')return send(200,{step:{...sourceStep,id:'review-step',title:'Independent review step'}}); - if(url.pathname==='/api/deep-assessments/same-id/receipts'&&url.searchParams.get('step_id')==='review-step')return send(200,{receipts:[{id:'review-receipt',execution_id:'review-execution',step_id:'review-step',tool:'fixture_recheck',arguments:'{}',result:'independent-review-evidence',status:'completed'}],next_offset:1,has_more:false}); - if(url.pathname==='/api/deep-assessments/same-id/steps/early-step')return send(200,{step:sourceStep}); - if(url.pathname==='/api/deep-assessments/same-id/vulnerabilities')return send(200,{vulnerabilities:[finding],total:1,next_offset:1,has_more:false}); - if(url.pathname==='/api/deep-assessments/same-id/vulnerabilities/finding-1')return send(200,{vulnerability:finding,step:sourceStep}); - if(url.pathname==='/api/deep-assessments/same-id/receipts')return send(200,{receipts:[{id:'receipt-1',execution_id:'execution-1',step_id:'early-step',tool:'fixture_read',arguments:'{}',result:'original-execution-evidence',status:'completed'}],next_offset:1,has_more:false}); - if(url.pathname==='/api/deep-assessments/same-id/events')return send(200,{events:[]}); - if(url.pathname==='/api/vulnerabilities/filter-options')return send(200,{vulnerability_ids:['finding-1','batch-finding'],task_ids:['same-id'],queue_ids:['batch-queue'],assessment_ids:['same-id'],conversation_ids:[],conversation_tags:[],task_tags:[]}); - let items=[finding,batch];if(url.searchParams.get('assessment_id'))items=items.filter(v=>v.assessment_id===url.searchParams.get('assessment_id'));if(url.searchParams.get('id'))items=items.filter(v=>v.id===url.searchParams.get('id')); - if(url.pathname==='/api/vulnerabilities/stats')return send(200,{total:items.length,by_severity:{high:items.filter(v=>v.severity==='high').length,medium:items.filter(v=>v.severity==='medium').length},by_status:{open:items.length}}); - if(url.pathname==='/api/vulnerabilities'){ - // Full navigation is separate from the selected page of finding records. - const navigation=items.map(v=>v.assessment_id - ? {key:'assessment:'+v.assessment_id,label:v.assessment_name,count:1,severities:{[v.severity]:1}} - : {key:'queue:'+v.task_queue_id,label:v.task_queue_title,count:1,severities:{[v.severity]:1},children:[{key:'task:'+v.task_id,label:v.task_id,count:1,severities:{[v.severity]:1}}]}); - const selection=url.searchParams.get('selection')||''; - if(selection)items=items.filter(v=>selection==='assessment:'+v.assessment_id||selection==='queue:'+v.task_queue_id||selection==='task:'+v.task_id); - return send(200,{vulnerabilities:items,total:items.length,page:1,page_size:20,total_pages:1,navigation,selection}); - } - if(url.pathname==='/api/vulnerabilities/finding-1/context')return send(200,{vulnerability:{...finding,assessment_can_open:state.canOpen},history:[],members:[],assets:[]}); - if(url.pathname==='/api/vulnerabilities/finding-1')return send(200,{...finding,assessment_can_open:state.canOpen}); - return send(404,{error:'unhandled fixture route '+url.pathname}); - }catch(error){send(500,{error:error.message});} - }); - await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve)); - const executablePath=process.env.CHROME_PATH||(process.platform==='darwin'?'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome':undefined); - const browser=await chromium.launch(executablePath?{executablePath}:{}); - t.after(async()=>{await browser.close();server.closeAllConnections();await new Promise(resolve=>server.close(resolve));}); - const page=await browser.newPage({viewport:{width:1440,height:1000}});page.setDefaultTimeout(6000);page.on('pageerror',e=>state.errors.push(e.message));page.on('dialog',d=>d.accept()); - await page.goto(`http://127.0.0.1:${server.address().port}/#deep-assessments`);await page.locator('[data-da-action="select"]').waitFor(); - return {page,state}; -} - -test('assessment findings round-trip through vulnerability management to exact evidence',async t=>{ - const {page,state}=await fixture(t); - await page.locator('[data-da-action="select"]').click();await page.locator('[data-da-action="tab"][data-tab="findings"]').click(); - await page.locator('.da-finding').waitFor();assert.match(await page.locator('.da-finding').innerText(),/权限校验问题/); - await page.locator('.da-finding [data-da-action="open-finding"]').click(); - await page.locator('#vulnerability-inspector a[data-assessment-jump]').first().waitFor(); - assert.match(await page.locator('.vulnerability-assessment-source').innerText(),/域名深度测评/); - await page.locator('#vulnerability-inspector a[data-assessment-jump]').first().click(); - await page.locator('#da-workspace .da-step[data-step="early-step"][open]').waitFor(); - assert.match(page.url(),/assessment_id=same-id/);assert.match(page.url(),/step_id=early-step/); - assert.match(await page.locator('.da-source-banner').innerText(),/权限校验问题/); - await page.reload();await page.locator('#da-workspace .da-step[data-step="early-step"][open]').waitFor(); - await page.locator('.da-source-banner [data-da-action="open-finding"]').click(); - await page.locator('#vulnerability-inspector a[data-assessment-jump]').last().waitFor();await page.locator('#vulnerability-inspector a[data-assessment-jump]').last().click(); - await page.waitForFunction(()=>document.querySelector('.da-source-banner')?.textContent.includes('original-proof')); - assert.match(page.url(),/tab=evidence/);assert.equal(await page.locator('.da-source-banner img').count(),0);assert.equal(await page.evaluate(()=>window.injected),undefined); - assert.ok(state.requests.some(r=>r.path.endsWith('/receipts')&&r.query.step_id==='early-step')); - await page.setViewportSize({width:390,height:844});assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1)); - await page.waitForFunction(()=>document.getElementById('da-workspace').getAnimations().every(a=>a.playState==='finished')); - assert.equal(await page.locator('#vulnerability-inspector').isVisible(),false);assert.equal(await page.locator('dialog[open]').count(),0); - const box=await page.locator('#da-workspace').boundingBox();assert.ok(box.x>=0&&box.x+box.width<=391); - assert.ok(state.requests.every(r=>r.method==='GET')); - assert.deepEqual(state.errors,[]); - const dir=process.env.CSAI_SCREENSHOT_DIR;if(dir){fs.mkdirSync(dir,{recursive:true});await page.screenshot({path:path.join(dir,'assessment-finding-evidence.png'),fullPage:true});} -}); - -test('task grouping separates assessment IDs from batch IDs and disabled source links',async t=>{ - const {page,state}=await fixture(t); - await page.evaluate(()=>{location.hash='vulnerabilities?view=task';}); - await page.locator('#vulnerabilities-list [data-host-key="assessment:same-id"]').waitFor(); - assert.match(await page.locator('[data-host-key="assessment:same-id"]').innerText(),/域名深度测评/); - assert.match(await page.locator('[data-host-key="queue:batch-queue"]').innerText(),/原批量队列/); - await page.locator('[data-host-key="assessment:same-id"]').click(); - await page.waitForFunction(()=>document.querySelector('[data-host-key="assessment:same-id"]').getAttribute('aria-pressed')==='true' && document.getElementById('vulnerability-card-finding-1') && !document.getElementById('vulnerability-card-batch-finding')); - assert.equal(await page.locator('#vulnerability-host-table #vulnerability-card-batch-finding').count(),0); - state.canOpen=false; - await page.locator('#vulnerability-host-table #vulnerability-card-finding-1 .vulnerability-record-main').click(); - await page.locator('.vulnerability-assessment-source').waitFor();assert.equal(await page.locator('.vulnerability-assessment-source a').count(),0); - assert.deepEqual(state.errors,[]); -}); - - -test('independent review links remain usable after assessment polling refreshes',async t=>{ - const {page,state}=await fixture(t); - state.finding.assessment_reviews=[{id:'review-1',step_id:'review-step',verdict:'confirmed',reason:'Independent fixture review',evidence:['review-receipt']}]; - await page.locator('[data-da-action="select"]').click(); - await page.locator('[data-da-action="tab"][data-tab="findings"]').click(); - await page.locator('.da-finding [data-da-action="open-finding"]').click(); - await page.getByRole('link',{name:'查看步骤与复现证据',exact:true}).click(); - const review=page.locator('#da-workspace .da-review-records details'); - await review.locator('summary').click(); - await page.evaluate(()=>window.DeepAssessments.refresh()); - await page.evaluate(()=>window.DeepAssessments.refresh()); - assert.equal(await review.getAttribute('open'),''); - await review.getByRole('link',{name:'查看复核意图与回执',exact:true}).click(); - await page.locator('#da-workspace .da-step[data-step="review-receipt"]').waitFor(); - assert.match(page.url(),/step_id=review-step/); - assert.match(await page.locator('.da-source-banner').innerText(),/Independent review step/); - await page.locator('#da-workspace .da-step[data-step="review-receipt"] summary').click(); - assert.match(await page.locator('#da-body').innerText(),/independent-review-evidence/); - assert.doesNotMatch(await page.locator('#da-body').innerText(),/original-execution-evidence/); - assert.ok(state.requests.every(r=>r.method==='GET')); - assert.deepEqual(state.errors,[]); -}); - - -test('authenticated refresh restores the requested assessment and write controls',async t=>{ - const {page,state}=await fixture(t); - await page.evaluate(async()=>{ - document.querySelector('[data-da-action="create"]').remove(); - history.replaceState(null,'','#deep-assessments?assessment_id=same-id&step_id=review-step&tab=evidence'); - window.loadConversations=async()=>{}; - window.loadActiveTasks=async()=>{}; - await refreshAppData(); - }); - await page.locator('#da-workspace .da-step[data-step="review-receipt"]').waitFor(); - assert.match(await page.locator('.da-source-banner').innerText(),/Independent review step/); - assert.equal(await page.locator('[data-da-action="create"]').count(),1); - assert.ok(state.requests.every(r=>r.method==='GET')); - assert.deepEqual(state.errors,[]); -}); diff --git a/scripts/batch-tasks-browser.test.cjs b/scripts/batch-tasks-browser.test.cjs deleted file mode 100644 index c3f0c69e..00000000 --- a/scripts/batch-tasks-browser.test.cjs +++ /dev/null @@ -1,71 +0,0 @@ -const { test } = require('node:test'); -const assert = require('node:assert/strict'); -const { fixture, queue } = require('./helpers/batch-task-ui-fixture.cjs'); - -test('original batch task page loads, filters and paginates existing queues', async t => { - const { page, state, refresh } = await fixture(t); - for (let i = 0; i < 22; i++) state.queues.set('q-' + i, { ...queue('q-' + i), title: 'Fixture ' + i, status: 'paused' }); - await refresh(); - assert.equal(await page.locator('#batch-queues-list .batch-queue-item').count(), 10); - await page.locator('#batch-queues-pagination button[onclick="goBatchQueuesPage(2)"]').first().click(); - await page.waitForFunction(() => document.querySelector('#batch-queues-pagination .pagination-page').textContent.includes('2')); - await page.locator('#batch-queues-page-size-pagination').selectOption('20'); - await page.waitForFunction(() => document.querySelectorAll('#batch-queues-list .batch-queue-item').length === 20); - await page.locator('.tasks-filter-select-trigger').click(); - await page.locator('.tasks-filter-select-option[data-value="pending"]').click(); - await page.waitForFunction(() => document.querySelectorAll('#batch-queues-list .batch-queue-item').length === 1); - await page.locator('.tasks-filter-select-trigger').click(); - await page.locator('.tasks-filter-select-option[data-value="all"]').click(); - await page.locator('#batch-queues-search').fill('Fixture 21'); - await page.waitForFunction(() => document.querySelectorAll('#batch-queues-list .batch-queue-item').length === 1 && document.querySelector('#batch-queues-list').textContent.includes('Fixture 21')); - assert.ok(state.requests.every(r => !r.path.startsWith('/api/long-tasks') && r.path !== '/api/tasks')); - assert.equal(await page.locator('#long-task-workspace, #page-assessments').count(), 0); - assert.deepEqual(state.pageErrors, []); -}); - -test('original creation and detail dialogs retain batch controls without automatically starting work', async t => { - const { page, state } = await fixture(t); - await page.locator('#page-tasks button[onclick="showBatchImportModal()"]').click(); - // The existing modal focuses its initial field on the next animation frame. - // Wait for that frame before filling another field, especially in parallel CI. - await page.waitForFunction(() => document.activeElement === document.getElementById('batch-tasks-input')); - await page.locator('#batch-tasks-input').fill('Read local fixture A\nRead local fixture B'); - await page.locator('#batch-queue-title').fill('Restored batch workflow'); - assert.equal(await page.locator('#batch-queue-execute-now').isChecked(), false); - await page.locator('#batch-import-modal button[onclick="createBatchQueue()"]').click(); - await page.locator('#batch-queue-detail-content [data-bq-detail-for="new-queue"]').waitFor(); - const created = state.requests.find(r => r.method === 'POST' && r.path === '/api/batch-tasks'); - assert.deepEqual(created.body.tasks, ['Read local fixture A', 'Read local fixture B']); - assert.equal(created.body.executeNow, false); - assert.equal(created.body.scheduleMode, 'manual'); - assert.equal(await page.locator('#batch-queue-detail-content .batch-task-item').count(), 2); - await page.locator('#batch-queue-add-task-btn').click(); - await page.locator('#add-task-message').fill('Read local fixture C'); - await page.locator('#add-batch-task-modal button[onclick="saveAddBatchTask()"]').click(); - await page.waitForFunction(() => document.querySelectorAll('#batch-queue-detail-content .batch-task-item').length === 3); - await page.locator('#batch-queue-start-btn').click(); - await page.locator('#batch-queue-pause-btn').waitFor({ state: 'visible' }); - await page.locator('#batch-queue-pause-btn').click(); - await page.locator('#batch-queue-start-btn').waitFor({ state: 'visible' }); - assert.equal(state.queues.get('new-queue').status, 'paused'); - await page.locator('#batch-queue-delete-btn').click(); - await page.waitForFunction(() => !document.querySelector('#batch-queues-list [data-queue-id="new-queue"]')); - assert.equal(state.queues.has('new-queue'), false); - assert.deepEqual(state.pageErrors, []); -}); - -test('restored task list and creation modal fit desktop, dark mode and mobile', async t => { - const { page, state } = await fixture(t); - for (const width of [1440, 390]) { - await page.setViewportSize({ width, height: 900 }); - await page.evaluate(() => document.documentElement.setAttribute('data-theme', 'dark')); - assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)); - await page.locator('#page-tasks button[onclick="showBatchImportModal()"]').click(); - const modal = page.locator('#batch-import-modal .modal-content'); - await page.locator('#batch-tasks-input').waitFor({ state: 'visible' }); - const rect = await modal.boundingBox(); - assert.ok(rect && rect.width <= width && rect.x >= 0); - await page.locator('#batch-import-modal button[onclick="closeBatchImportModal()"]').last().click(); - } - assert.deepEqual(state.pageErrors, []); -}); diff --git a/scripts/chat-scroll-browser.test.cjs b/scripts/chat-scroll-browser.test.cjs deleted file mode 100644 index 7750295a..00000000 --- a/scripts/chat-scroll-browser.test.cjs +++ /dev/null @@ -1,147 +0,0 @@ -/* Offline regression. Requires Playwright and Chrome (or CHROME_PATH). - * Run: node --test scripts/chat-scroll-browser.test.cjs - */ -const assert = require('node:assert/strict'); -const fs = require('node:fs'); -const path = require('node:path'); -const { test } = require('node:test'); -const { chromium } = require('playwright'); - -const read = file => fs.readFileSync(path.join(__dirname, '..', 'web/static', file), 'utf8'); - -async function scrollState(page) { - return page.evaluate(() => { - const chat = document.getElementById('chat-messages'); - const timeline = document.querySelector('.progress-timeline'); - return { - outerGap: chat.scrollHeight - chat.clientHeight - chat.scrollTop, - innerGap: timeline.scrollHeight - timeline.clientHeight - timeline.scrollTop, - innerTop: timeline.scrollTop, - outerFollowing: window.captureScrollPinState(), - pruned: !!timeline.querySelector('.timeline-live-pruned-marker') - }; - }); -} - -test('long live and restored conversations stay at the latest iteration without stealing manual scroll', async () => { - const browser = await chromium.launch({ - ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}), - }); - try { - for (const width of [1440, 390]) { - for (const restored of [false, true]) { - const label = `${width}px ${restored ? 'restored' : 'live'}`; - const page = await browser.newPage({ viewport: { width, height: 820 } }); - try { - await page.route('**/*', route => route.request().url() === 'http://chat.test/' - ? route.fulfill({ - contentType: 'text/html', - body: ` -
-
- -
` - }) - : route.abort()); - await page.goto('http://chat.test/'); - for (const file of ['style.css', 'mobile.css']) { - await page.addStyleTag({ content: read('css/' + file) }); - } - // Supply only the chat globals required by the real progress renderer. - await page.addScriptTag({ content: ` - let messageCounter = 0, currentConversationId = ''; - const escapeHtml = text => escapeHtmlLocal(text); - ` }); - for (const file of ['chat-scroll.js', 'monitor.js']) { - await page.addScriptTag({ content: read('js/' + file) }); - } - await page.evaluate(async restored => { - const chat = document.getElementById('chat-messages'); - for (let i = 0; i < 30; i++) { - const row = document.createElement('div'); - row.className = 'message user'; - row.innerHTML = '
Synthetic history
'; - chat.append(row); - } - if (restored) { - chat.insertAdjacentHTML('beforeend', ` -
-
-
-
-
-
-
`); - startProcessDetailsLatestFollow('restored'); - } else { - addProgressMessage(); - } - const timeline = document.querySelector('.progress-timeline'); - for (let i = 0; i < (restored ? 50 : 156); i++) { - addTimelineItem(timeline, 'reasoning_chain', { - title: 'Synthetic reasoning ' + i, - message: 'Example reasoning text.\n'.repeat(i % 11 === 0 ? 65 : i % 9 + 1) - }); - if (i % 10 === 0) await new Promise(requestAnimationFrame); - } - }, restored); - await page.waitForFunction(() => { - const tl = document.querySelector('.progress-timeline'); - const chat = document.getElementById('chat-messages'); - return tl.scrollHeight - tl.clientHeight - tl.scrollTop <= 2 && - chat.scrollHeight - chat.clientHeight - chat.scrollTop <= 2; - }, null, { timeout: 2000 }); - const latest = await scrollState(page); - assert.equal(latest.pruned, !restored, label); - - const box = await page.locator('.progress-timeline').boundingBox(); - await page.mouse.move(box.x + 40, box.y + box.height / 2); - await page.mouse.wheel(0, -420); - await page.waitForFunction(() => processDetailsDistanceFromLatest( - document.querySelector('.progress-timeline')) > 100); - const reading = await scrollState(page); - assert.equal(reading.outerFollowing, true, label); - assert.ok(reading.outerGap <= 2, label); - - if (restored) { - // Upgrading the restore follower to the live subscription preserves reading position. - await page.evaluate(() => startProcessDetailsLatestFollow('restored', { persistent: true })); - } - await page.evaluate(async () => { - const row = document.querySelector('.progress-timeline .timeline-item:last-child .timeline-item-content'); - scheduleStreamPlainTextUpdate(row, row.textContent + 'A new line.\n'.repeat(20)); - await new Promise(requestAnimationFrame); - await new Promise(requestAnimationFrame); - await new Promise(requestAnimationFrame); - }); - const afterUpdate = await scrollState(page); - assert.equal(afterUpdate.innerTop, reading.innerTop, label); - assert.ok(afterUpdate.innerGap > reading.innerGap, label); - - if (restored) { - await page.locator('.process-details-return-latest').click(); - } else { - await page.mouse.wheel(0, 100000); - } - await page.waitForFunction(() => processDetailsDistanceFromLatest( - document.querySelector('.progress-timeline')) <= 2); - await page.evaluate(async () => { - const timeline = document.querySelector('.progress-timeline'); - addTimelineItem(timeline, 'reasoning_chain', { - title: 'Latest iteration', message: 'More output.\n'.repeat(50) - }); - await new Promise(requestAnimationFrame); - await new Promise(requestAnimationFrame); - await new Promise(requestAnimationFrame); - }); - const atBottom = await scrollState(page); - assert.ok(atBottom.innerGap <= 2 && atBottom.outerGap <= 2, label); - } finally { - await page.close(); - } - } - } - } finally { - await browser.close(); - } -}); diff --git a/scripts/check-ui-design-system.cjs b/scripts/check-ui-design-system.cjs deleted file mode 100644 index 811859a2..00000000 --- a/scripts/check-ui-design-system.cjs +++ /dev/null @@ -1,378 +0,0 @@ -/** Offline Chromium layout/keyboard regression checks using production HTML/CSS/renderers. - * Install Playwright outside the source tree; run with NODE_PATH pointing to that node_modules. - * Uses synthetic records; never starts the backend or sends requests to assessment targets. - */ -const { chromium } = require("playwright"); -const fs = require("fs"), - http = require("http"), - path = require("path"); -const root = path.resolve(__dirname, ".."); -const out = - process.env.CSAI_UI_ARTIFACTS || - fs.mkdtempSync(path.join(require("os").tmpdir(), "csai-ui-")); -fs.mkdirSync(out, { recursive: true }); -const html = fs - .readFileSync(root + "/web/templates/index.html", "utf8") - .replace(/]*>[\s\S]*?<\/script>/g, "") - .replace(/\{\{\.Version\}\}/g, "UI preview") - .replace( - "", - '', - ); -const server = http.createServer((req, res) => { - const p = req.url.split("?")[0]; - if (p.startsWith("/api/")) { - res.setHeader("Content-Type", "application/json"); - return res.end("{}"); - } - if (p === "/") { - res.setHeader("Content-Type", "text/html"); - return res.end(html); - } - const f = path.join(root, "web", p); - if (!f.startsWith(root + "/web/") || !fs.existsSync(f)) { - res.statusCode = 404; - return res.end(); - } - res.setHeader( - "Content-Type", - p.endsWith(".css") - ? "text/css" - : p.endsWith(".js") - ? "application/javascript" - : "application/octet-stream", - ); - res.end(fs.readFileSync(f)); -}); -(async () => { - await new Promise((r) => server.listen(0, "127.0.0.1", r)); - const browser = await chromium.launch({ headless: true }); - const findings = []; - let count = 0; - for (const width of process.env.CSAI_UI_WIDTHS - ? process.env.CSAI_UI_WIDTHS.split(",").map(Number) - : [1440, 1024, 390, 360]) - for (const theme of ["light", "dark"]) { - const height = - width === 360 ? 640 : width === 390 ? 844 : width === 1024 ? 768 : 900; - const page = await browser.newPage({ - viewport: { width, height }, - colorScheme: theme, - locale: "zh-CN", - }); - page.on("pageerror", (e) => - findings.push({ width, theme, issue: e.message }), - ); - await page.goto("http://127.0.0.1:" + server.address().port); - await page.evaluate(() => window.i18nReady); - await page.evaluate((t) => { - document.documentElement.dataset.theme = t; - document - .querySelectorAll(".page") - .forEach((e) => e.classList.remove("active")); - document - .getElementById("page-roles-management") - .classList.add("active"); - }, theme); - const ids = await page - .locator('[data-ui-surface="drawer"]') - .evaluateAll((els) => els.map((e) => e.id)); - for (const id of ids) { - // A drawer nested in a page is visible only while that page is active. - await page.evaluate((id) => { - const e = document.getElementById(id); - e.closest(".settings-section-content")?.classList.add("active"); - const parent = e.closest(".page"); - if (parent) { - document - .querySelectorAll(".page") - .forEach((p) => p.classList.remove("active")); - parent.classList.add("active"); - } - openAppModal(id); - }, id); - await page.locator('#' + id).evaluate(async (element) => { - element.getBoundingClientRect(); - const animations = element.getAnimations({ subtree: true }).filter( - animation => animation.effect?.getComputedTiming().iterations !== Infinity, - ); - await Promise.all(animations.map(animation => animation.finished.catch(() => {}))); - }); - const info = await page.evaluate((id) => { - const e = document.getElementById(id), - p = e.firstElementChild, - r = p.getBoundingClientRect(), - s = getComputedStyle(p), - b = p.querySelector( - ".modal-body,.projects-modal-body,.c2-modal-body,#vulnerability-inspector-body", - ); - return { - id, - x: r.x, - y: r.y, - w: r.width, - h: r.height, - bg: s.backgroundColor, - corners: [ - s.borderTopLeftRadius, - s.borderTopRightRadius, - s.borderBottomRightRadius, - s.borderBottomLeftRadius, - ], - overflow: b ? b.scrollWidth > b.clientWidth + 2 : false, - footer: p - .querySelector( - ".modal-footer,.projects-modal-footer,.c2-modal-footer", - ) - ?.getBoundingClientRect().bottom, - }; - }, id); - count++; - const channel = Number(info.bg.match(/\d+/)?.[0]); - if ( - (theme === "dark" && channel > 100) || - (theme === "light" && channel < 200) - ) - findings.push({ - width, - theme, - id, - issue: "surface theme mismatch", - bg: info.bg, - }); - if ( - info.x < -0.5 || - info.y < -0.5 || - Math.abs(info.x + info.w - width) > 2 || - Math.abs(info.h - height) > 2 || - info.footer > height + 1 || - info.overflow || - info.corners.some((radius) => radius !== "0px") - ) - findings.push({ width, theme, ...info }); - if ( - [ - "role-modal", - "asset-editor-modal", - "vulnerability-modal", - "skill-modal", - ].includes(id) - ) - await page.screenshot({ - animations: "disabled", - path: out + "/" + id + "-" + width + "-" + theme + ".png", - }); - await page.evaluate((id) => closeAppModal(id), id); - } - // Compact actions should remain short on mobile; test nested layer and restoration. - await page.evaluate(() => { - openAppModal("fact-detail-modal"); - openAppModal("fact-modal"); - }); - const nested = await page.evaluate( - () => - Number( - getComputedStyle(document.getElementById("fact-modal")).zIndex, - ) > - Number( - getComputedStyle(document.getElementById("fact-detail-modal")) - .zIndex, - ), - ); - if (!nested) throw new Error("nested stacking"); - await page.evaluate(() => { - closeAppModal("fact-modal"); - closeAppModal("fact-detail-modal"); - openAppModal("project-modal"); - }); - const small = await page.locator("#project-modal > div").boundingBox(); - if (small.height >= height - 10) - throw new Error("short dialog is full screen"); - await page.evaluate(() => closeAppModal("project-modal")); - if (width === 1440) { - await page.evaluate(() => openAppModal("role-modal")); - await page.locator("#role-modal .app-drawer-expand").click(); - const expanded = await page.locator("#role-modal > div").boundingBox(); - if (expanded.width < 1200) throw new Error("expand failed"); - await page.evaluate(() => closeAppModal("role-modal")); - } - // Load production renderers with synthetic data; no backend or target execution. - await page.evaluate(() => { - window.apiFetch = async () => ({ - ok: true, - json: async () => ({ - log: { - createdAt: "2026-11-15T08:00:00Z", - category: "config", - action: "apply", - result: "success", - message: "配置已保存", - detail: { source: "UI fixture" }, - }, - }), - }); - window.showToast = (m) => console.log("TOAST", m); - }); - for (const script of ["knowledge", "audit", "roles", "c2"]) - await page.addScriptTag({ url: "/static/js/" + script + ".js" }); - await page.evaluate(() => showAuditLogDetail("fixture")); - await page.waitForTimeout(100); - if ( - (await page - .locator("#audit-detail-modal .app-drawer-expand") - .count()) !== 1 - ) { - console.log( - await page - .locator("#audit-detail-modal") - .evaluateAll((es) => es.map((e) => e.outerHTML)), - ); - throw new Error("deferred audit header missing"); - } - await page.screenshot({ - animations: "disabled", - path: out + "/audit-" + width + "-" + theme + ".png", - }); - await page.keyboard.press("Escape"); - if (await page.locator("#audit-detail-modal").count()) - throw new Error("Escape did not run audit cleanup"); - await page.evaluate(() => - showRetrievalLogDetailsModal( - { - createdAt: "2026-11-15T08:00:00Z", - query: "查找接口鉴权检查方法", - riskType: "鉴权", - }, - [ - { - title: "接口鉴权检查", - category: "Web", - content: "验证不同角色之间的数据访问边界。", - }, - ], - ), - ); - await page.waitForTimeout(100); - await page.screenshot({ - animations: "disabled", - path: out + "/retrieval-" + width + "-" + theme + ".png", - }); - await page.evaluate(() => closeRetrievalLogDetailsModal()); - await page.route("**/api/**", (route) => - route.fulfill({ json: { profiles: [], projects: [], listeners: [] } }), - ); - await page.evaluate(() => C2.showCreateListenerModal()); - await page.waitForTimeout(200); - if ((await page.locator("#c2-modal .app-drawer-expand").count()) !== 1) - throw new Error("C2 header missing"); - await page.screenshot({ - animations: "disabled", - path: out + "/c2-" + width + "-" + theme + ".png", - }); - await page.evaluate(() => C2.closeModal()); - // Test focus wrap, native close cleanup and restoration through real role handlers. - await page.evaluate(() => { - const b = document.createElement("button"); - b.textContent = "Open editor"; - document.body.appendChild(b); - b.focus(); - window.fixtureFocus = b; - openAppModal("role-modal"); - }); - await page.waitForTimeout(30); - await page.locator("#role-modal .modal-footer .btn-primary").focus(); - await page.keyboard.press("Tab"); - if ( - !(await page.evaluate(() => - document - .getElementById("role-modal") - .contains(document.activeElement), - )) - ) - throw new Error("focus escaped"); - await page.keyboard.press("Escape"); - if ( - !(await page.evaluate( - () => - !isAppModalOpen("role-modal") && - document.activeElement === window.fixtureFocus, - )) - ) - throw new Error("close/focus restore failed"); - await page.evaluate(() => { - window.fixtureFocus.remove(); - roles = [ - { - name: "安全审计", - description: "检查授权范围内的代码与配置,整理可复核的证据。", - tools: ["read_file", "search_code"], - enabled: true, - }, - { - name: "报告整理", - description: "汇总已验证发现,生成清晰的报告。", - tools: [], - enabled: true, - }, - ]; - renderRolesList(); - }); - const pageIds = await page - .locator(".page[id]") - .evaluateAll((es) => es.map((e) => e.id)); - for (const id of pageIds) { - await page.evaluate((id) => { - document - .querySelectorAll(".page") - .forEach((e) => e.classList.toggle("active", e.id === id)); - if (window.CSAMobile) - CSAMobile.wrapTables(document.getElementById(id)); - }, id); - const overflow = await page.evaluate( - () => document.documentElement.scrollWidth > innerWidth + 2, - ); - if (overflow) - findings.push({ width, theme, id, issue: "page overflow" }); - if ( - [ - "page-dashboard", - "page-roles-management", - "page-asset-library", - "page-workflows", - "page-settings", - ].includes(id) - ) - await page.screenshot({ - animations: "disabled", - path: out + "/" + id + "-" + width + "-" + theme + ".png", - }); - } - await require("./ui-realistic-scenarios.cjs")({ - page, - width, - height, - theme, - out, - }); - await require("./ui-extra-drawers.cjs")({ - page, - width, - height, - theme, - out, - }); - await page.close(); - } - fs.writeFileSync( - out + "/results.json", - JSON.stringify({ count, findings }, null, 2), - ); - console.log(JSON.stringify({ count, findings, artifacts: out }, null, 2)); - if (findings.length) process.exitCode = 1; - await browser.close(); - server.close(); -})().catch((e) => { - console.error(e); - server.close(); - process.exit(1); -}); diff --git a/scripts/deep-assessments-browser.test.cjs b/scripts/deep-assessments-browser.test.cjs deleted file mode 100644 index 88eb5dd3..00000000 --- a/scripts/deep-assessments-browser.test.cjs +++ /dev/null @@ -1,743 +0,0 @@ -const { test } = require('node:test'); -const assert = require('node:assert/strict'); -const fs = require('node:fs'); -const path = require('node:path'); -const http = require('node:http'); -const { chromium } = require('playwright'); -const root = path.join(__dirname, '..'); -const read = file => fs.readFileSync(path.join(root, file), 'utf8'); -const template = read('web/templates/index.html'); -const region = template.match(/
]*>
<\/div><\/div>/)?.[0]; -assert.ok(region, 'independent page missing'); -const navOrder = [...template.slice(template.indexOf('', template.indexOf('