kenaz 0.3.17 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/.claude/commands/agent-worker.md +1 -1
- package/core/.claude/commands/architect.md +1 -2
- package/core/.claude/commands/spec.md +1 -1
- package/core/.claude/commands//347/224/242/345/223/201.md +1 -1
- package/core/.claude/hooks/__tests__/task-1977-dedupe-guard.test.js +8 -8
- package/core/.claude/hooks/synapse-first-investigation.js +15 -0
- package/core/.claude/skills/architect_agent/SKILL.md +11 -92
- package/core/.claude/skills/assessment_agent/SKILL.md +0 -1
- package/core/.claude/skills/backend_engineer/SKILL.md +3 -6
- package/core/.claude/skills/code_reviewer/SKILL.md +1 -1
- package/core/.claude/skills/code_reviewer/patterns.yaml +1 -1
- package/core/.claude/skills/designer/SKILL.md +3 -6
- package/core/.claude/skills/dev_agent/SKILL.md +30 -491
- package/core/.claude/skills/developer/SKILL.md +3 -6
- package/core/.claude/skills/feature_agent/SKILL.md +3 -17
- package/core/.claude/skills/product_manager/SKILL.md +29 -1064
- package/core/.claude/skills/qa_engineer/SKILL.md +12 -17
- package/core/.claude/skills/spec_optimizer/SKILL.md +25 -275
- package/core/.claude/skills/sre_agent/SKILL.md +3 -6
- package/core/.collaboration/README.md +2 -3
- package/core/.collaboration/core/task-api.js +5 -138
- package/core/.collaboration/docs/CLI.md +0 -2
- package/core/.failure/INDEX.yaml +6 -40
- package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +1 -1
- package/core/.failure/tools/README.md +9 -227
- package/core/.formation/bifrost/exec.js +29 -4
- package/core/.formation/bifrost/launch.js +1 -6
- package/core/.formation/bifrost/launch.test.js +1 -1
- package/core/.formation/bifrost/provider-launch.js +18 -11
- package/core/.formation/bifrost/provider-launch.test.js +26 -2
- package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
- package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +1 -2
- package/core/.formation/tools/__tests__/dispatch-cwd-project.test.js +42 -0
- package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
- package/core/.formation/tools/__tests__/subagent-executor.test.js +3 -2
- package/core/.formation/tools/dispatch.js +15 -2
- package/core/.formation/tools/loader.js +17 -140
- package/core/.formation/tools/post-complete.js +0 -31
- package/core/.rule/INDEX.yaml +0 -18
- package/core/.rule/general/agent-workflow.yaml +14 -164
- package/core/.rule/general/project-self-containment.yaml +8 -19
- package/core/.rule/general/rust-verify-target.yaml +6 -5
- package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
- package/core/.specialist/Amelia/capability.yaml +12 -12
- package/core/.specialist/Amelia/workflow.yaml +2 -2
- package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
- package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
- package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
- package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
- package/core/.specialist/Ansuz/core.yaml +6 -108
- package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
- package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
- package/core/.specialist/Ansuz/knowledge.yaml +0 -4
- package/core/.specialist/Ansuz/rule.yaml +0 -1
- package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
- package/core/.specialist/tests/runtime-discovery/README.md +1 -1
- package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
- package/core/.specialist/tools/prompt-files.test.js +1 -0
- package/core/.specialist/tools/task-bridge.js +1 -66
- package/core/.system/README.md +11 -552
- package/core/.system/collaboration/README.md +10 -174
- package/core/CLAUDE.md +1 -6
- package/core/KENAZ_CORE_VERSION +1 -1
- package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
- package/core/dev/scripts/run-rust-tests.js +30 -46
- package/core/dev/scripts/run-rust-tests.test.js +17 -0
- package/core/dev/scripts/rust-verify-worktree.js +4 -4
- package/core/dev/scripts/verify-target-dir.js +6 -6
- package/core/plugins/kenaz/INVENTORY.md +8 -8
- package/core/plugins/kenaz/commands/architect.md +1 -2
- package/core/plugins/kenaz/commands/spec.md +1 -1
- package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
- package/core/plugins/kenaz/guidance.md +1 -1
- package/core/plugins/kenaz/scripts/sync.js +1 -1
- package/core/plugins/kenaz/scripts/ygg.js +6 -0
- package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
- package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
- package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
- package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
- package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
- package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
- package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
- package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
- package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
- package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
- package/package.json +6 -6
- package/core/.claude/commands/archive.md +0 -24
- package/core/.claude/commands/init.md +0 -112
- package/core/.claude/commands/legacy_dev.md +0 -18
- package/core/.claude/commands/product-review.md +0 -131
- package/core/.claude/commands/strategy.md +0 -141
- package/core/.claude/commands/sunny.md +0 -1
- package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
- package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
- package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
- package/core/.claude/hooks/_substrate-paths.js +0 -95
- package/core/.claude/hooks/context-check.js +0 -51
- package/core/.claude/hooks/fatigue-check.js +0 -52
- package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
- package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
- package/core/.claude/hooks/handoff-staleness.js +0 -197
- package/core/.claude/hooks/jev-thalamus-context.js +0 -17
- package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
- package/core/.claude/hooks/lease-release.js +0 -119
- package/core/.claude/hooks/lease-touch.js +0 -96
- package/core/.claude/hooks/reflex-feedback.js +0 -5
- package/core/.claude/hooks/session-init.ps1 +0 -49
- package/core/.claude/hooks/sound-event.js +0 -70
- package/core/.claude/hooks/sound-event.sh +0 -37
- package/core/.claude/hooks/stream-delta.js +0 -169
- package/core/.claude/no-hooks.settings.json +0 -3
- package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
- package/core/.claude/skills/sunny/SKILL.md +0 -74
- package/core/.collaboration/cli/commands/assign.js +0 -39
- package/core/.collaboration/cli/commands/claim.js +0 -33
- package/core/.collaboration/cli/commands/complete.js +0 -44
- package/core/.collaboration/cli/commands/create.js +0 -110
- package/core/.collaboration/cli/commands/get.js +0 -83
- package/core/.collaboration/cli/commands/index.js +0 -52
- package/core/.collaboration/cli/commands/list.js +0 -51
- package/core/.collaboration/cli/commands/lock.js +0 -45
- package/core/.collaboration/cli/commands/rebuild.js +0 -39
- package/core/.collaboration/cli/commands/search.js +0 -61
- package/core/.collaboration/cli/commands/stats.js +0 -61
- package/core/.collaboration/cli/commands/transfer.js +0 -41
- package/core/.collaboration/cli/commands/unlock.js +0 -48
- package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
- package/core/.collaboration/cli/formatters/index.js +0 -7
- package/core/.collaboration/cli/task-cli.js +0 -46
- package/core/.collaboration/cli/utils/arg-parser.js +0 -74
- package/core/.collaboration/cli/utils/git-user.js +0 -25
- package/core/.collaboration/cli/utils/index.js +0 -9
- package/core/.collaboration/cli/utils/output.js +0 -10
- package/core/.collaboration/config/default.yaml +0 -189
- package/core/.collaboration/core/conflict-resolver.js +0 -461
- package/core/.collaboration/core/conflict-resolver.test.js +0 -389
- package/core/.collaboration/core/migrate-legacy.js +0 -260
- package/core/.collaboration/docs/API.md +0 -787
- package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
- package/core/.collaboration/docs/FAQ.md +0 -695
- package/core/.collaboration/docs/MIGRATION.md +0 -804
- package/core/.collaboration/docs/examples/README.md +0 -320
- package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
- package/core/.collaboration/docs/examples/basic-usage.js +0 -184
- package/core/.collaboration/docs/examples/team-workflow.js +0 -352
- package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
- package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
- package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
- package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
- package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
- package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
- package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
- package/core/.failure/pipeline/README.md +0 -95
- package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
- package/core/.failure/tools/USAGE_GUIDE.md +0 -323
- package/core/.failure/tools/check_failures.ps1 +0 -387
- package/core/.failure/tools/log_failure.ps1 +0 -474
- package/core/.formation/.episode-input.json +0 -10
- package/core/.formation/.merge-lock +0 -1
- package/core/.formation/lead.yaml +0 -118
- package/core/.formation/legacy.bak/designer.yaml +0 -57
- package/core/.formation/legacy.bak/pm.yaml +0 -57
- package/core/.formation/legacy.bak/qa.yaml +0 -57
- package/core/.formation/legacy.bak/review.yaml +0 -62
- package/core/.formation/legacy.bak/scheduler.yaml +0 -129
- package/core/.formation/legacy.bak/sre.yaml +0 -57
- package/core/.formation/role-map.yaml +0 -274
- package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
- package/core/.formation/roles/_shared/modules/security.yaml +0 -103
- package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
- package/core/.formation/roles/backend/role.yaml +0 -93
- package/core/.formation/roles/code_reviewer/role.yaml +0 -102
- package/core/.formation/roles/database_optimizer/role.yaml +0 -107
- package/core/.formation/roles/designer/role.yaml +0 -66
- package/core/.formation/roles/developer/role.yaml +0 -75
- package/core/.formation/roles/frontend/role.yaml +0 -134
- package/core/.formation/roles/incident_response/role.yaml +0 -89
- package/core/.formation/roles/qa/role.yaml +0 -89
- package/core/.formation/roles/security/role.yaml +0 -87
- package/core/.formation/roles/sre/role.yaml +0 -66
- package/core/.formation/skills/coordinator.yaml +0 -52
- package/core/.formation/solo/diagnosis.yaml +0 -78
- package/core/.formation/solo/strategy.yaml +0 -121
- package/core/.formation/tests/hello.txt +0 -2
- package/core/.formation/tools/coordinator.js +0 -350
- package/core/.formation/tools/jev-correction.js +0 -214
- package/core/.formation/tools/jev-correction.test.js +0 -178
- package/core/.formation/tools/log-reader.js +0 -232
- package/core/.formation/tools/revert-daemon-state.js +0 -162
- package/core/.formation/tools/test-drift.js +0 -148
- package/core/.formation/unit/heimdall.yaml +0 -96
- package/core/.formation/unit/plan.yaml +0 -67
- package/core/.formation/unit/think.yaml +0 -58
- package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
- package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
- package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
- package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
- package/core/.kenaz/muninn_episode_write.ps1 +0 -17
- package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
- package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
- package/core/.kenaz/runes_TASK_1428.json +0 -57
- package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
- package/core/.kenaz/tmp_props.json +0 -1
- package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
- package/core/.rule/MECHANIZED.md +0 -61
- package/core/.rule/general/cortex-memory-recall.yaml +0 -446
- package/core/.rule/general/pipeline.yaml +0 -246
- package/core/.rule/general/sunny-access-control.yaml +0 -60
- package/core/.rule/general/system-invariants.yaml +0 -231
- package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
- package/core/.rule/pipeline/auto-update.yaml +0 -282
- package/core/.rule/pipeline/task-execution.yaml +0 -365
- package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
- package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
- package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
- package/core/.specialist/Ansuz/workflow.yaml +0 -1225
- package/core/.specialist/experiments/rg_benchmark.js +0 -523
- package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
- package/core/.specialist/tools/jev-optional-context.js +0 -107
- package/core/.specialist/tools/jev-optional-context.test.js +0 -152
- package/core/.specialist/tools/memory-action-log.js +0 -839
- package/core/.specialist/tools/phase-gate.js +0 -3534
- package/core/.specialist/tools/phase-gate.test.js +0 -85
- package/core/.specialist/tools/precompute-runner.js +0 -444
- package/core/.specialist/tools/rule-engine.js +0 -621
- package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
- package/core/.synapse/memory-shared.json.sync +0 -1
- package/core/.system/agent-skills/README.md +0 -724
- package/core/.system/cli-tools/README.md +0 -724
- package/core/.system/cortex/MODULES.md +0 -1046
- package/core/.system/dashboard/FRONTEND.md +0 -812
- package/core/.system/dashboard/README.md +0 -737
- package/core/.system/failure/README.md +0 -723
- package/core/.system/formation/LEGACY_SKILLS.md +0 -974
- package/core/.system/formation/POST_COMPLETE.md +0 -602
- package/core/.system/formation/README.md +0 -1094
- package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
- package/core/.system/kenaz/README.md +0 -787
- package/core/.system/memory/README.md +0 -719
- package/core/.system/pipeline/README.md +0 -712
- package/core/.system/rule/README.md +0 -794
- package/core/.system/sunny/README.md +0 -476
- package/core/.system/sunny/RULES.json +0 -89
- package/core/.system/sunny/knowledge/INDEX.md +0 -37
- package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
- package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
- package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
- package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
- package/core/.system/sunny/teammates/README.md +0 -107
- package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
- package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
- package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
- package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
- package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
- package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
- package/core/.system/sunny/tools.json +0 -101
- package/core/dev/scripts/cleanup-queue.js +0 -184
- package/core/dev/scripts/cleanup_queue.js +0 -86
- package/core/dev/scripts/legacy/README.md +0 -39
- package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
- package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
- package/core/dev/scripts/matrix/CLI_README.md +0 -214
- package/core/dev/scripts/matrix/README.md +0 -310
- package/core/dev/scripts/matrix/package-lock.json +0 -4266
- package/core/dev/scripts/matrix/package.json +0 -55
- package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
- package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
- package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
- package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
- package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
- package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
- package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
- package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
- package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
- package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
- package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
- package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
- package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
- package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
- package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
- package/core/dev/scripts/matrix/src/index.ts +0 -62
- package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
- package/core/dev/scripts/matrix/src/parser.ts +0 -281
- package/core/dev/scripts/matrix/src/serializer.ts +0 -151
- package/core/dev/scripts/matrix/src/validator.ts +0 -301
- package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
- package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
- package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
- package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
- package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
- package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
- package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
- package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
- package/core/dev/scripts/matrix/tsconfig.json +0 -20
- package/core/dev/scripts/matrix/types/index.d.ts +0 -111
- package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
- package/core/dev/scripts/matrix/types/index.js +0 -8
- package/core/dev/scripts/matrix/types/index.js.map +0 -1
- package/core/dev/scripts/matrix/types/index.ts +0 -124
- package/core/dev/scripts/memory-usage-report.js +0 -152
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
- package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
- package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
- package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
- package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
- package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
- package/core/dev/scripts/validate_pipeline.js +0 -197
- package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
- package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
- package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
- package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
- package/core/plugins/kenaz/commands/strategy.md +0 -141
|
@@ -1,812 +0,0 @@
|
|
|
1
|
-
# Dashboard 前端架構 (React/Next.js)
|
|
2
|
-
|
|
3
|
-
**Kenaz Dashboard** 前端採用 **Next.js 16.1.6 (App Router)** 構建,提供跨平台 UI 能力,支援 **Web**、**Tauri** 和 **Electron** 三種運行模式。本文檔涵蓋前端的目錄結構、核心組件、狀態管理、hooks 系統、平台抽象層、以及與 Tauri 後端的 IPC 通訊機制。
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 技術棧
|
|
8
|
-
|
|
9
|
-
| 技術 | 版本 | 用途 |
|
|
10
|
-
|------|------|------|
|
|
11
|
-
| **Next.js** | 16.1.6 | React 框架 (App Router) |
|
|
12
|
-
| **React** | 19.2.3 | UI 函式庫 |
|
|
13
|
-
| **TypeScript** | ^5 | 型別系統 |
|
|
14
|
-
| **Tailwind CSS** | ^4 | 樣式框架 |
|
|
15
|
-
| **Tauri** | ^2.9.1 | 桌面應用整合 |
|
|
16
|
-
| **Electron** | ^40.1.0 | 桌面應用 (備用方案) |
|
|
17
|
-
| **Socket.IO** | ^4.8.3 | 即時通訊 (WebSocket) |
|
|
18
|
-
| **@tanstack/react-query** | ^5.90.20 | 資料狀態管理 |
|
|
19
|
-
| **xterm.js** | ^6.0.0 | 終端模擬器 |
|
|
20
|
-
| **lucide-react** | ^0.563.0 | Icon 庫 |
|
|
21
|
-
| **shaders** | ^2.3.61 | 背景特效 |
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 目錄結構
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
dashboard/src/
|
|
29
|
-
├── app/ # Next.js App Router 路由
|
|
30
|
-
│ ├── layout.tsx # 根 Layout(Providers、字體、全局樣式)
|
|
31
|
-
│ ├── page.tsx # 主頁(Dashboard 主畫面)
|
|
32
|
-
│ ├── globals.css # 全局 CSS(TailwindCSS、自定義樣式)
|
|
33
|
-
│ ├── agent-coordination/ # Agent 協作頁面
|
|
34
|
-
│ ├── agents/ # Agents 管理頁面
|
|
35
|
-
│ ├── api/ # API Routes(Next.js 後端端點)
|
|
36
|
-
│ ├── docs/ # 文檔頁面
|
|
37
|
-
│ ├── poc-shaders/ # Shader 特效 PoC
|
|
38
|
-
│ └── spec/ # Spec 編輯頁面
|
|
39
|
-
│
|
|
40
|
-
├── components/ # React 組件
|
|
41
|
-
│ ├── agent-monitor/ # Agent 監控面板
|
|
42
|
-
│ ├── agents-page/ # Agents 頁面組件
|
|
43
|
-
│ ├── cli-status/ # CLI 狀態指示器
|
|
44
|
-
│ ├── connection-status/ # 連線狀態指示器
|
|
45
|
-
│ ├── cortex-control/ # Cortex 控制面板
|
|
46
|
-
│ ├── docs/ # 文檔組件
|
|
47
|
-
│ ├── mobile/ # 移動端專用組件
|
|
48
|
-
│ ├── optimization/ # 優化建議面板
|
|
49
|
-
│ ├── project-selector/ # 專案選擇器
|
|
50
|
-
│ ├── providers.tsx # Context Providers 包裝器
|
|
51
|
-
│ ├── quick-actions/ # 快速操作面板
|
|
52
|
-
│ │ ├── QuickActionsPanel.tsx # 主面板(包含所有卡片)
|
|
53
|
-
│ │ ├── ScriptCard.tsx # 單一腳本卡片
|
|
54
|
-
│ │ ├── ConfirmDialog.tsx # 確認對話框
|
|
55
|
-
│ │ ├── OutputViewer.tsx # 腳本輸出檢視器
|
|
56
|
-
│ │ └── SchedulerControlCard.tsx # 排程器控制卡片
|
|
57
|
-
│ ├── session-manager/ # CLI Session 管理
|
|
58
|
-
│ ├── setup-wizard/ # 首次設置精靈
|
|
59
|
-
│ ├── ShaderBackground.tsx # Shader 背景(動態載入)
|
|
60
|
-
│ ├── ShaderBackgroundLayer.tsx # Shader 圖層(靜態渲染)
|
|
61
|
-
│ ├── spec/ # Spec 編輯組件
|
|
62
|
-
│ ├── system-update/ # 系統更新組件
|
|
63
|
-
│ ├── task-board/ # 任務看板
|
|
64
|
-
│ │ ├── TaskBoard.tsx # 看板主體(Kanban 風格)
|
|
65
|
-
│ │ ├── TaskCard.tsx # 單一任務卡片
|
|
66
|
-
│ │ ├── TaskColumn.tsx # 看板欄位(Pending/Active/Done)
|
|
67
|
-
│ │ ├── TaskDetailModal.tsx # 任務詳情 Modal
|
|
68
|
-
│ │ ├── AgentBadge.tsx # Agent 標籤
|
|
69
|
-
│ │ ├── LockIndicator.tsx # 鎖定狀態指示器
|
|
70
|
-
│ │ └── PriorityBadge.tsx # 優先級標籤
|
|
71
|
-
│ ├── terminal/ # 終端模擬器組件
|
|
72
|
-
│ ├── ui/ # UI 基礎組件(按鈕、輸入等)
|
|
73
|
-
│ └── VersionFooter.tsx # 版本資訊頁尾
|
|
74
|
-
│
|
|
75
|
-
├── hooks/ # React Hooks
|
|
76
|
-
│ ├── useAgentCoordination.ts # Agent 協作狀態
|
|
77
|
-
│ ├── use-auto-updater.ts # 自動更新
|
|
78
|
-
│ ├── use-cli-settings.ts # CLI 設定
|
|
79
|
-
│ ├── use-directory-autocomplete.ts # 目錄自動補全
|
|
80
|
-
│ ├── use-heartbeat.ts # Dashboard 心跳(保持 Agent 存活)
|
|
81
|
-
│ ├── useKeyboardShortcuts.ts # 鍵盤快捷鍵
|
|
82
|
-
│ ├── use-media-query.ts # 響應式媒體查詢(isMobile、isTablet)
|
|
83
|
-
│ ├── use-polling.ts # 輪詢 Hook
|
|
84
|
-
│ ├── use-proposals.ts # 優化建議
|
|
85
|
-
│ ├── use-recent-directories.ts # 最近目錄
|
|
86
|
-
│ ├── use-scheduler.ts # Multi-Agent Scheduler 控制
|
|
87
|
-
│ ├── use-scheduler-events.ts # Scheduler 事件監聽
|
|
88
|
-
│ ├── use-scheduler-heartbeat.ts # Scheduler 心跳
|
|
89
|
-
│ ├── use-self-enhancement.ts # 自我增強狀態
|
|
90
|
-
│ ├── use-setup-wizard.ts # 設置精靈狀態
|
|
91
|
-
│ ├── use-socket.ts # WebSocket 連線
|
|
92
|
-
│ ├── use-socket-state.ts # WebSocket 狀態(任務、指標)
|
|
93
|
-
│ └── use-viewport-height.ts # Viewport 高度(iOS Safari 修正)
|
|
94
|
-
│
|
|
95
|
-
├── contexts/ # React Contexts
|
|
96
|
-
│ ├── ProjectContext.tsx # 專案狀態(當前專案、專案列表)
|
|
97
|
-
│ └── SocketContext.tsx # WebSocket 全局狀態
|
|
98
|
-
│
|
|
99
|
-
├── lib/ # 工具函式庫
|
|
100
|
-
│ ├── api.ts # HTTP API 呼叫(Web 模式)
|
|
101
|
-
│ ├── api-adapter.ts # API 適配器(統一 Tauri/Web API)
|
|
102
|
-
│ ├── agents-parser.ts # Agent 狀態解析
|
|
103
|
-
│ ├── agent-coordination/ # Agent 協作相關工具
|
|
104
|
-
│ ├── cli/ # CLI 工具
|
|
105
|
-
│ ├── cortex-cli.ts # Cortex CLI 包裝器
|
|
106
|
-
│ ├── cortex-client.ts # Cortex 客戶端
|
|
107
|
-
│ ├── platform/ # 平台抽象層 ⭐
|
|
108
|
-
│ │ ├── index.ts # 平台檢測與 Adapter 導出
|
|
109
|
-
│ │ ├── types.ts # 平台接口定義(PlatformAdapter、PtyConnection)
|
|
110
|
-
│ │ ├── tauri-adapter.ts # Tauri 平台實作
|
|
111
|
-
│ │ └── web-adapter.ts # Web 平台實作
|
|
112
|
-
│ ├── scripts/ # 腳本工具
|
|
113
|
-
│ ├── socket/ # WebSocket 工具
|
|
114
|
-
│ ├── system/ # 系統工具
|
|
115
|
-
│ ├── tauri/ # Tauri 專用工具
|
|
116
|
-
│ ├── tauri-commands.ts # Tauri IPC 指令包裝器
|
|
117
|
-
│ └── utils.ts # 通用工具函式
|
|
118
|
-
│
|
|
119
|
-
└── types/ # TypeScript 型別定義
|
|
120
|
-
├── index.ts # 主型別定義(TaskQueue、AgentState、MetricsResponse、CLISession 等)
|
|
121
|
-
├── agent-section/ # Agent 區域型別
|
|
122
|
-
├── scheduler-events.ts # Scheduler 事件型別
|
|
123
|
-
├── shaders-react.d.ts # Shaders 函式庫型別聲明
|
|
124
|
-
├── socket.ts # WebSocket 型別
|
|
125
|
-
└── spec.ts # Spec 型別
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## 核心組件架構
|
|
131
|
-
|
|
132
|
-
### 1. 主頁佈局 (`app/page.tsx`)
|
|
133
|
-
|
|
134
|
-
**職責**:Dashboard 主畫面,整合所有核心功能面板。
|
|
135
|
-
|
|
136
|
-
**佈局模式**:
|
|
137
|
-
- **桌面版**(Desktop):三欄佈局 + 可調整終端面板
|
|
138
|
-
- **左側**:Session Manager、Agent Monitor、Cortex Control
|
|
139
|
-
- **中間**:任務統計卡片 + Task Board(Kanban 風格)
|
|
140
|
-
- **右側**:Quick Actions、Optimization Panel
|
|
141
|
-
- **底部**:Terminal Panel(可透過拖曳調整高度)
|
|
142
|
-
- **移動/平板版**(Mobile/Tablet):Tab 式佈局
|
|
143
|
-
- **Tab 1: Tasks** - 任務統計 + Task Board
|
|
144
|
-
- **Tab 2: Agents** - Sessions + Agent Monitor
|
|
145
|
-
- **Tab 3: Tools** - Quick Actions + Optimization
|
|
146
|
-
- **Tab 4: Terminal** - 全螢幕終端 Modal
|
|
147
|
-
|
|
148
|
-
**關鍵功能**:
|
|
149
|
-
- **專案切換**:透過 `ProjectContext` 切換專案,自動清除 Sessions、重新載入任務/Agents/Proposals
|
|
150
|
-
- **響應式設計**:使用 `useIsMobile()` / `useIsTablet()` 自動切換佈局
|
|
151
|
-
- **Shader 背景**:動態載入 `DynamicShaderBackground`(支援 None/Grain/Wave/Mesh 四種模式)
|
|
152
|
-
- **終端拖曳調整**:支援滑鼠拖曳調整終端高度(最小 150px,最大 85vh)
|
|
153
|
-
- **Heartbeat 機制**:每 10 秒發送心跳,保持 Agents 存活,Dashboard 關閉時通知 Agents 停止
|
|
154
|
-
|
|
155
|
-
**關鍵依賴**:
|
|
156
|
-
- `useProject()`:專案狀態
|
|
157
|
-
- `useTasksSocketState()`:任務 + WebSocket 即時更新
|
|
158
|
-
- `useMetricsSocketState()`:Token 指標 + 即時更新
|
|
159
|
-
- `useHeartbeat()`:Dashboard 心跳
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
### 2. Task Board (`components/task-board/`)
|
|
164
|
-
|
|
165
|
-
**職責**:Kanban 風格的任務看板,顯示任務狀態流轉。
|
|
166
|
-
|
|
167
|
-
**組件結構**:
|
|
168
|
-
- **TaskBoard.tsx**:主容器,渲染三欄(Pending/Active/Done)
|
|
169
|
-
- **TaskColumn.tsx**:單一狀態欄位(支援折疊/展開、任務計數)
|
|
170
|
-
- **TaskCard.tsx**:任務卡片(顯示 ID、標題、優先級、Agent、鎖定狀態)
|
|
171
|
-
- **TaskDetailModal.tsx**:任務詳情 Modal(YAML 格式、需求、驗收標準、依賴關係)
|
|
172
|
-
|
|
173
|
-
**特性**:
|
|
174
|
-
- **狀態分類**:`pending` / `in_progress` / `completed` / `blocked` / `cancelled`
|
|
175
|
-
- **優先級標示**:P0(紅)/ P1(橙)/ P2(黃)/ P3(綠)
|
|
176
|
-
- **依賴關係可視化**:顯示任務依賴 ID 列表
|
|
177
|
-
- **路徑鎖定指示**:顯示 `scope_paths` 是否被鎖定
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
### 3. Quick Actions Panel (`components/quick-actions/`)
|
|
182
|
-
|
|
183
|
-
**職責**:快速執行腳本與排程器控制。
|
|
184
|
-
|
|
185
|
-
**組件結構**:
|
|
186
|
-
- **QuickActionsPanel.tsx**:主面板,整合所有卡片
|
|
187
|
-
- **ScriptCard**:顯示單一腳本(名稱、描述、執行按鈕)
|
|
188
|
-
- **SchedulerControlCard**:Multi-Agent Scheduler 控制(啟動/停止、狀態監控)
|
|
189
|
-
- **Formation Sections**(Unit/Solo/Squad/Legion):Formation 系統快捷操作
|
|
190
|
-
- **ConfirmDialog.tsx**:執行前確認對話框
|
|
191
|
-
- **OutputViewer.tsx**:腳本輸出檢視器(即時串流、錯誤高亮)
|
|
192
|
-
|
|
193
|
-
**腳本分類**:
|
|
194
|
-
| 類別 | 說明 | 範例 |
|
|
195
|
-
|------|------|------|
|
|
196
|
-
| **initialization** | 初始化腳本 | INIT_GIT、SETUP_RAG、INIT_PROJECT |
|
|
197
|
-
| **development** | 開發腳本 | START_DEV_AGENT(自我增強)、START_MULTI_AGENT |
|
|
198
|
-
| **tools** | 工具腳本 | - |
|
|
199
|
-
|
|
200
|
-
**Scheduler 控制**:
|
|
201
|
-
- **啟動**:配置 `maxAgents`、`pollInterval`、`taskTimeout` 並啟動 Multi-Agent Scheduler
|
|
202
|
-
- **停止**:停止排程器,釋放所有路徑鎖定
|
|
203
|
-
- **狀態監控**:即時顯示運行狀態、Active Agents、Path Locks
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
### 4. Shader Background (`components/ShaderBackground.tsx`)
|
|
208
|
-
|
|
209
|
-
**職責**:提供動態背景特效(支援多種模式)。
|
|
210
|
-
|
|
211
|
-
**模式**:
|
|
212
|
-
- **None**:無特效
|
|
213
|
-
- **Grain**:顆粒雜訊
|
|
214
|
-
- **Wave**:波浪動畫
|
|
215
|
-
- **Mesh**:網格漸變(預設)
|
|
216
|
-
|
|
217
|
-
**實作方式**:
|
|
218
|
-
- **DynamicShaderBackground**:使用 `dynamic` 動態載入(避免 SSR 錯誤)
|
|
219
|
-
- **ShaderBackgroundLayer**:實際渲染層(使用 `shaders` 套件)
|
|
220
|
-
- **ShaderToggle**:切換按鈕(儲存到 localStorage)
|
|
221
|
-
|
|
222
|
-
**效能優化**:
|
|
223
|
-
- 使用 `next/dynamic` 延遲載入
|
|
224
|
-
- 支援 `mounted` 狀態避免 hydration mismatch
|
|
225
|
-
- 自動偵測 GPU 性能(低性能裝置自動降級)
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
## Hooks 系統
|
|
230
|
-
|
|
231
|
-
### 1. `use-scheduler.ts` ⭐
|
|
232
|
-
|
|
233
|
-
**職責**:Multi-Agent Scheduler 控制 Hook。
|
|
234
|
-
|
|
235
|
-
**API**:
|
|
236
|
-
```typescript
|
|
237
|
-
const {
|
|
238
|
-
state, // 當前狀態(isRunning、agents、locks、lastHeartbeat)
|
|
239
|
-
start, // 啟動排程器(接受 SchedulerConfig)
|
|
240
|
-
stop, // 停止排程器
|
|
241
|
-
refresh, // 手動重新整理狀態
|
|
242
|
-
unlock, // 手動解鎖路徑
|
|
243
|
-
terminateAgent, // 終止特定 Agent
|
|
244
|
-
isAvailable, // 是否可用(Tauri 模式限定)
|
|
245
|
-
isLoading // 是否正在操作
|
|
246
|
-
} = useScheduler({
|
|
247
|
-
pollInterval: 5000, // 輪詢間隔(預設 5 秒)
|
|
248
|
-
autoPoll: true, // 自動輪詢
|
|
249
|
-
projectPath: '...', // 專案路徑
|
|
250
|
-
onStart: () => {}, // 啟動回調
|
|
251
|
-
onStop: () => {}, // 停止回調
|
|
252
|
-
onError: (err) => {}, // 錯誤回調
|
|
253
|
-
onWarning: (warn) => {}// 警告回調
|
|
254
|
-
});
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
**特性**:
|
|
258
|
-
- **跨平台**:自動偵測 Tauri/Web 模式,呼叫對應 API
|
|
259
|
-
- **即時事件**:整合 `useSchedulerEvents`,監聽 `heartbeat`、`state_changed`、`warning` 事件
|
|
260
|
-
- **自動輪詢**:當 `isRunning=true` 時自動輪詢狀態
|
|
261
|
-
|
|
262
|
-
---
|
|
263
|
-
|
|
264
|
-
### 2. `use-socket-state.ts`
|
|
265
|
-
|
|
266
|
-
**職責**:整合 WebSocket 即時更新與 React Query 資料管理。
|
|
267
|
-
|
|
268
|
-
**API**:
|
|
269
|
-
```typescript
|
|
270
|
-
// 任務資料 + WebSocket 即時更新
|
|
271
|
-
const { data, isLoading, error, refetch, isConnected } = useTasksSocketState(
|
|
272
|
-
{ projectPath, pipelinePath },
|
|
273
|
-
enabled
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
// Token 指標 + WebSocket 即時更新
|
|
277
|
-
const { data, refetch } = useMetricsSocketState(enabled);
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
**工作原理**:
|
|
281
|
-
1. **初始載入**:透過 `useQuery` 載入初始資料
|
|
282
|
-
2. **WebSocket 訂閱**:監聽 `task:update` / `metrics:update` 事件
|
|
283
|
-
3. **自動重新整理**:收到事件後呼叫 `queryClient.invalidateQueries` 更新資料
|
|
284
|
-
|
|
285
|
-
---
|
|
286
|
-
|
|
287
|
-
### 3. `use-heartbeat.ts`
|
|
288
|
-
|
|
289
|
-
**職責**:Dashboard 心跳機制,保持 Agents 存活。
|
|
290
|
-
|
|
291
|
-
**API**:
|
|
292
|
-
```typescript
|
|
293
|
-
useHeartbeat({
|
|
294
|
-
enabled: true,
|
|
295
|
-
interval: 10000 // 10 秒
|
|
296
|
-
});
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
**行為**:
|
|
300
|
-
- **存活信號**:定期呼叫 `api.system.updateHeartbeat()`,通知 Agents Dashboard 仍在運行
|
|
301
|
-
- **關閉通知**:當 Dashboard 關閉(`beforeunload` 事件),呼叫 `api.system.sendSchedulerStopSignal()` 通知 Agents 停止
|
|
302
|
-
|
|
303
|
-
---
|
|
304
|
-
|
|
305
|
-
### 4. `use-media-query.ts`
|
|
306
|
-
|
|
307
|
-
**職責**:響應式媒體查詢(避免 hydration mismatch)。
|
|
308
|
-
|
|
309
|
-
**API**:
|
|
310
|
-
```typescript
|
|
311
|
-
const isMobile = useIsMobile(); // < 768px
|
|
312
|
-
const isTablet = useIsTablet(); // 768px ~ 1024px
|
|
313
|
-
const isDesktop = useIsDesktop(); // > 1024px
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
**實作方式**:
|
|
317
|
-
- 使用 `useSyncExternalStore` 同步 `window.matchMedia` 狀態
|
|
318
|
-
- SSR 時回傳 `false`,避免 hydration 錯誤
|
|
319
|
-
|
|
320
|
-
---
|
|
321
|
-
|
|
322
|
-
## Contexts
|
|
323
|
-
|
|
324
|
-
### 1. `ProjectContext.tsx` ⭐
|
|
325
|
-
|
|
326
|
-
**職責**:管理專案列表與當前專案狀態。
|
|
327
|
-
|
|
328
|
-
**API**:
|
|
329
|
-
```typescript
|
|
330
|
-
const {
|
|
331
|
-
projects, // 專案列表
|
|
332
|
-
currentProject, // 當前專案
|
|
333
|
-
currentProjectId, // 當前專案 ID
|
|
334
|
-
isLoading, // 是否正在載入
|
|
335
|
-
addProject, // 新增專案
|
|
336
|
-
removeProject, // 移除專案
|
|
337
|
-
setCurrentProject, // 切換專案
|
|
338
|
-
updateProject // 更新專案資訊
|
|
339
|
-
} = useProject();
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
**資料同步**:
|
|
343
|
-
- **localStorage**:本地儲存(`kenaz-projects-config`)
|
|
344
|
-
- **Server API**:`/api/projects` 端點(Next.js API Route)
|
|
345
|
-
- **跨平台路徑遷移**:自動偵測 Windows/Mac/Linux,遷移不相容路徑
|
|
346
|
-
|
|
347
|
-
**專案結構**:
|
|
348
|
-
```typescript
|
|
349
|
-
interface Project {
|
|
350
|
-
id: string; // 唯一 ID
|
|
351
|
-
name: string; // 專案名稱
|
|
352
|
-
path: string; // 絕對路徑
|
|
353
|
-
pipelinePath: string; // Pipeline 相對路徑(如 "dev/pipeline")
|
|
354
|
-
createdAt: string; // 建立時間
|
|
355
|
-
}
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
---
|
|
359
|
-
|
|
360
|
-
### 2. `SocketContext.tsx`
|
|
361
|
-
|
|
362
|
-
**職責**:WebSocket 全局連線管理。
|
|
363
|
-
|
|
364
|
-
**API**:
|
|
365
|
-
```typescript
|
|
366
|
-
const {
|
|
367
|
-
socket, // Socket.IO 實例
|
|
368
|
-
isConnected, // 是否已連線
|
|
369
|
-
setProject, // 設定當前專案路徑
|
|
370
|
-
subscribe, // 訂閱事件
|
|
371
|
-
unsubscribe, // 取消訂閱
|
|
372
|
-
emit // 發送事件
|
|
373
|
-
} = useSocketContext();
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
**事件訂閱**:
|
|
377
|
-
```typescript
|
|
378
|
-
useEffect(() => {
|
|
379
|
-
const handler = (data: TaskQueue) => { /* ... */ };
|
|
380
|
-
subscribe('task:update', handler);
|
|
381
|
-
return () => unsubscribe('task:update', handler);
|
|
382
|
-
}, [subscribe, unsubscribe]);
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
---
|
|
386
|
-
|
|
387
|
-
## 平台抽象層 (`lib/platform/`)
|
|
388
|
-
|
|
389
|
-
### 設計目標
|
|
390
|
-
|
|
391
|
-
統一 **Tauri(IPC)** 和 **Web(HTTP + WebSocket)** 兩種運行模式的 API 呼叫方式。
|
|
392
|
-
|
|
393
|
-
### 目錄結構
|
|
394
|
-
|
|
395
|
-
```
|
|
396
|
-
lib/platform/
|
|
397
|
-
├── index.ts # 平台檢測與 Adapter 導出
|
|
398
|
-
├── types.ts # PlatformAdapter 接口定義
|
|
399
|
-
├── tauri-adapter.ts # Tauri 平台實作
|
|
400
|
-
└── web-adapter.ts # Web 平台實作
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
### 接口定義 (`types.ts`)
|
|
404
|
-
|
|
405
|
-
**PlatformAdapter** 定義了所有模組的統一接口:
|
|
406
|
-
|
|
407
|
-
```typescript
|
|
408
|
-
interface PlatformAdapter {
|
|
409
|
-
readonly platform: 'tauri' | 'web';
|
|
410
|
-
|
|
411
|
-
pty: { /* PTY 終端操作 */ };
|
|
412
|
-
tasks: { getTasks, getTaskDetail };
|
|
413
|
-
agents: { getAgents };
|
|
414
|
-
metrics: { getMetrics };
|
|
415
|
-
scripts: { list, execute, getProcessStatus, stop, ... };
|
|
416
|
-
fs: { readJsonFile, writeJsonFile, listDirectory, ... };
|
|
417
|
-
scheduler: { start, stop, getStatus, unlock, terminateAgent, ... };
|
|
418
|
-
singleAgent: { start, stop, getStatus, getLogs, ... };
|
|
419
|
-
system: { getVersion, getSystemInfo, checkEnvironment, ... };
|
|
420
|
-
config: { load, save };
|
|
421
|
-
spec: { parse, validate, save };
|
|
422
|
-
proposals: { getAll, accept, ignore, create };
|
|
423
|
-
cli: { getSessions, spawn, close, getSession };
|
|
424
|
-
cortex: { getStatus, toggle, exportChunks, ... };
|
|
425
|
-
}
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
### 使用方式
|
|
429
|
-
|
|
430
|
-
```typescript
|
|
431
|
-
import { api } from '@/lib/platform';
|
|
432
|
-
|
|
433
|
-
// 自動偵測平台並呼叫對應 API
|
|
434
|
-
const result = await api.tasks.getTasks({ projectPath });
|
|
435
|
-
const agents = await api.agents.getAgents({ projectPath });
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
### 平台檢測邏輯 (`index.ts`)
|
|
439
|
-
|
|
440
|
-
```typescript
|
|
441
|
-
export const api: PlatformAdapter = isTauri()
|
|
442
|
-
? new TauriAdapter()
|
|
443
|
-
: new WebAdapter();
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
**`isTauri()` 判斷**:檢查 `window.__TAURI_INTERNALS__` 是否存在。
|
|
447
|
-
|
|
448
|
-
---
|
|
449
|
-
|
|
450
|
-
### PTY Connection 抽象
|
|
451
|
-
|
|
452
|
-
**問題**:Tauri 和 Web 模式的終端 I/O 機制不同:
|
|
453
|
-
- **Tauri**:IPC 指令 + Event 推送(`pty-data` / `pty-exit`)
|
|
454
|
-
- **Web**:WebSocket 雙向串流
|
|
455
|
-
|
|
456
|
-
**解決方案**:`PtyConnection` 接口統一兩種模式。
|
|
457
|
-
|
|
458
|
-
```typescript
|
|
459
|
-
interface PtyConnection {
|
|
460
|
-
onData(callback: (data: Uint8Array) => void): void;
|
|
461
|
-
onExit(callback: (status: string) => void): void;
|
|
462
|
-
write(data: string): Promise<void>;
|
|
463
|
-
resize(cols: number, rows: number): Promise<void>;
|
|
464
|
-
disconnect(): void;
|
|
465
|
-
}
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
**使用範例**:
|
|
469
|
-
```typescript
|
|
470
|
-
const conn = await api.pty.connect({ cmd: 'bash', cwd: '...' });
|
|
471
|
-
conn.onData((data) => terminal.write(data));
|
|
472
|
-
conn.onExit((status) => console.log('Exit:', status));
|
|
473
|
-
await conn.write('ls -la\n');
|
|
474
|
-
conn.disconnect();
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
---
|
|
478
|
-
|
|
479
|
-
## Tauri 後端通訊
|
|
480
|
-
|
|
481
|
-
### IPC 指令包裝器 (`lib/tauri-commands.ts`)
|
|
482
|
-
|
|
483
|
-
**職責**:包裝所有 Tauri IPC 指令(`invoke`)與事件監聽(`listen`)。
|
|
484
|
-
|
|
485
|
-
**範例**:
|
|
486
|
-
```typescript
|
|
487
|
-
import { tauriCommands } from '@/lib/tauri-commands';
|
|
488
|
-
|
|
489
|
-
// Scheduler 控制
|
|
490
|
-
const status = await tauriCommands.scheduler.getStatus(projectPath);
|
|
491
|
-
await tauriCommands.scheduler.start(projectPath, config);
|
|
492
|
-
await tauriCommands.scheduler.stop(projectPath);
|
|
493
|
-
|
|
494
|
-
// Task 查詢
|
|
495
|
-
const tasks = await tauriCommands.tasks.getTasks(projectPath);
|
|
496
|
-
|
|
497
|
-
// PTY 操作
|
|
498
|
-
const session = await tauriCommands.pty.spawn({ cmd: 'bash' });
|
|
499
|
-
await tauriCommands.pty.write(session.id, 'ls\n');
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
### Tauri Event 監聽
|
|
503
|
-
|
|
504
|
-
**Scheduler 事件**:
|
|
505
|
-
```typescript
|
|
506
|
-
import { listen } from '@tauri-apps/api/event';
|
|
507
|
-
|
|
508
|
-
// Scheduler 心跳事件
|
|
509
|
-
const unlisten = await listen<SchedulerHeartbeatPayload>(
|
|
510
|
-
'scheduler:heartbeat',
|
|
511
|
-
(event) => {
|
|
512
|
-
console.log('Heartbeat:', event.payload);
|
|
513
|
-
}
|
|
514
|
-
);
|
|
515
|
-
|
|
516
|
-
// 清理
|
|
517
|
-
unlisten();
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
**PTY 事件**:
|
|
521
|
-
```typescript
|
|
522
|
-
const unlisten = await listen<PtyDataEvent>('pty-data', (event) => {
|
|
523
|
-
if (event.payload.session_id === sessionId) {
|
|
524
|
-
terminal.write(event.payload.data);
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
---
|
|
530
|
-
|
|
531
|
-
## API Routes (`app/api/`)
|
|
532
|
-
|
|
533
|
-
**職責**:Next.js API Routes,提供 HTTP 端點(Web 模式使用)。
|
|
534
|
-
|
|
535
|
-
**範例端點**:
|
|
536
|
-
- `POST /api/tasks` - 取得任務列表
|
|
537
|
-
- `GET /api/agents` - 取得 Agent 狀態
|
|
538
|
-
- `POST /api/scripts/execute` - 執行腳本
|
|
539
|
-
- `POST /api/scheduler/start` - 啟動 Scheduler
|
|
540
|
-
- `GET /api/projects` - 取得專案配置
|
|
541
|
-
|
|
542
|
-
**實作**:透過 `lib/api-adapter.ts` 呼叫後端 API(如 FastAPI)。
|
|
543
|
-
|
|
544
|
-
---
|
|
545
|
-
|
|
546
|
-
## 型別定義 (`types/index.ts`)
|
|
547
|
-
|
|
548
|
-
**核心型別**:
|
|
549
|
-
|
|
550
|
-
```typescript
|
|
551
|
-
// 任務佇列
|
|
552
|
-
interface TaskQueue {
|
|
553
|
-
tasks: TaskSummary[];
|
|
554
|
-
statistics: TaskStatistics;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
interface TaskSummary {
|
|
558
|
-
id: string;
|
|
559
|
-
title: string;
|
|
560
|
-
status: 'pending' | 'in_progress' | 'completed' | 'blocked' | 'cancelled';
|
|
561
|
-
priority: 'P0' | 'P1' | 'P2' | 'P3';
|
|
562
|
-
role?: string;
|
|
563
|
-
dependencies: string[];
|
|
564
|
-
scope_paths: string[];
|
|
565
|
-
is_locked?: boolean;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
// Agent 狀態
|
|
569
|
-
interface AgentState {
|
|
570
|
-
active_agents: AgentInfo[];
|
|
571
|
-
locks: LockInfo[];
|
|
572
|
-
queue_summary: { total: number; pending: number; in_progress: number; completed: number };
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
// CLI Session
|
|
576
|
-
interface CLISession {
|
|
577
|
-
id: string;
|
|
578
|
-
name?: string;
|
|
579
|
-
status: 'active' | 'idle' | 'error';
|
|
580
|
-
created_at: string;
|
|
581
|
-
last_active: string;
|
|
582
|
-
project_path?: string;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// Metrics
|
|
586
|
-
interface MetricsResponse {
|
|
587
|
-
total_input_tokens: number;
|
|
588
|
-
total_output_tokens: number;
|
|
589
|
-
total_cost: number;
|
|
590
|
-
history: TokenUsageEntry[];
|
|
591
|
-
}
|
|
592
|
-
```
|
|
593
|
-
|
|
594
|
-
---
|
|
595
|
-
|
|
596
|
-
## 樣式系統
|
|
597
|
-
|
|
598
|
-
### Tailwind CSS 配置
|
|
599
|
-
|
|
600
|
-
**自定義主題**:
|
|
601
|
-
```javascript
|
|
602
|
-
// tailwind.config.ts
|
|
603
|
-
theme: {
|
|
604
|
-
extend: {
|
|
605
|
-
colors: {
|
|
606
|
-
cyber: {
|
|
607
|
-
cyan: '#00ffff',
|
|
608
|
-
purple: '#9d00ff',
|
|
609
|
-
pink: '#ff006e',
|
|
610
|
-
}
|
|
611
|
-
},
|
|
612
|
-
fontFamily: {
|
|
613
|
-
display: ['Orbitron', 'sans-serif'],
|
|
614
|
-
tech: ['Share Tech Mono', 'monospace'],
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
### 全局樣式 (`app/globals.css`)
|
|
621
|
-
|
|
622
|
-
**Grid 背景**:
|
|
623
|
-
```css
|
|
624
|
-
.grid-background {
|
|
625
|
-
background-image:
|
|
626
|
-
linear-gradient(rgba(0, 255, 255, 0.05) 1px, transparent 1px),
|
|
627
|
-
linear-gradient(90deg, rgba(0, 255, 255, 0.05) 1px, transparent 1px);
|
|
628
|
-
background-size: 50px 50px;
|
|
629
|
-
}
|
|
630
|
-
```
|
|
631
|
-
|
|
632
|
-
**HUD 卡片**:
|
|
633
|
-
```css
|
|
634
|
-
.hud-card {
|
|
635
|
-
@apply border border-cyan-400/30 bg-[#0a1628]/80 rounded backdrop-blur-sm;
|
|
636
|
-
}
|
|
637
|
-
```
|
|
638
|
-
|
|
639
|
-
---
|
|
640
|
-
|
|
641
|
-
## 響應式設計
|
|
642
|
-
|
|
643
|
-
### 斷點
|
|
644
|
-
|
|
645
|
-
| 斷點 | 寬度 | 使用場景 |
|
|
646
|
-
|------|------|---------|
|
|
647
|
-
| **Mobile** | < 768px | 手機裝置 |
|
|
648
|
-
| **Tablet** | 768px ~ 1024px | 平板裝置 |
|
|
649
|
-
| **Desktop** | > 1024px | 桌面裝置 |
|
|
650
|
-
|
|
651
|
-
### 適配策略
|
|
652
|
-
|
|
653
|
-
**桌面版**:
|
|
654
|
-
- 三欄佈局(280px / 1fr / 300px)
|
|
655
|
-
- 可調整終端高度
|
|
656
|
-
- 完整功能面板
|
|
657
|
-
|
|
658
|
-
**移動/平板版**:
|
|
659
|
-
- Tab 式佈局(Tasks/Agents/Tools/Terminal)
|
|
660
|
-
- 全螢幕終端 Modal
|
|
661
|
-
- 簡化卡片樣式(`compact` prop)
|
|
662
|
-
|
|
663
|
-
---
|
|
664
|
-
|
|
665
|
-
## 效能優化
|
|
666
|
-
|
|
667
|
-
### 1. 動態載入
|
|
668
|
-
|
|
669
|
-
```typescript
|
|
670
|
-
// ShaderBackground 動態載入(避免 SSR 錯誤)
|
|
671
|
-
const DynamicShaderBackground = dynamic(
|
|
672
|
-
() => import('./ShaderBackgroundLayer'),
|
|
673
|
-
{ ssr: false }
|
|
674
|
-
);
|
|
675
|
-
```
|
|
676
|
-
|
|
677
|
-
### 2. React Query 快取
|
|
678
|
-
|
|
679
|
-
```typescript
|
|
680
|
-
const { data } = useQuery({
|
|
681
|
-
queryKey: ['tasks', projectPath],
|
|
682
|
-
queryFn: () => api.tasks.getTasks({ projectPath }),
|
|
683
|
-
staleTime: 30000, // 30 秒內不重新請求
|
|
684
|
-
refetchInterval: 60000 // 每分鐘自動重新整理
|
|
685
|
-
});
|
|
686
|
-
```
|
|
687
|
-
|
|
688
|
-
### 3. WebSocket 自動重連
|
|
689
|
-
|
|
690
|
-
```typescript
|
|
691
|
-
// SocketContext 自動重連機制
|
|
692
|
-
socket.on('disconnect', () => {
|
|
693
|
-
console.log('Socket disconnected, reconnecting...');
|
|
694
|
-
socket.connect();
|
|
695
|
-
});
|
|
696
|
-
```
|
|
697
|
-
|
|
698
|
-
### 4. 防抖與節流
|
|
699
|
-
|
|
700
|
-
```typescript
|
|
701
|
-
// 終端拖曳使用 requestAnimationFrame 節流
|
|
702
|
-
const handleMouseMove = (e: MouseEvent) => {
|
|
703
|
-
rafId = requestAnimationFrame(() => {
|
|
704
|
-
setTerminalHeight(newHeight);
|
|
705
|
-
});
|
|
706
|
-
};
|
|
707
|
-
```
|
|
708
|
-
|
|
709
|
-
---
|
|
710
|
-
|
|
711
|
-
## 開發指南
|
|
712
|
-
|
|
713
|
-
### 新增組件
|
|
714
|
-
|
|
715
|
-
1. 在 `components/` 建立資料夾
|
|
716
|
-
2. 使用 TypeScript + Tailwind CSS
|
|
717
|
-
3. 導出 `index.ts` 方便引用
|
|
718
|
-
|
|
719
|
-
```typescript
|
|
720
|
-
// components/my-component/MyComponent.tsx
|
|
721
|
-
export function MyComponent({ title }: { title: string }) {
|
|
722
|
-
return <div className="hud-card">{title}</div>;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// components/my-component/index.ts
|
|
726
|
-
export { MyComponent } from './MyComponent';
|
|
727
|
-
```
|
|
728
|
-
|
|
729
|
-
### 新增 Hook
|
|
730
|
-
|
|
731
|
-
```typescript
|
|
732
|
-
// hooks/use-my-hook.ts
|
|
733
|
-
export function useMyHook() {
|
|
734
|
-
const [state, setState] = useState(false);
|
|
735
|
-
|
|
736
|
-
useEffect(() => {
|
|
737
|
-
// 初始化邏輯
|
|
738
|
-
}, []);
|
|
739
|
-
|
|
740
|
-
return { state, setState };
|
|
741
|
-
}
|
|
742
|
-
```
|
|
743
|
-
|
|
744
|
-
### 新增 API 端點
|
|
745
|
-
|
|
746
|
-
```typescript
|
|
747
|
-
// app/api/my-endpoint/route.ts
|
|
748
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
749
|
-
|
|
750
|
-
export async function GET(req: NextRequest) {
|
|
751
|
-
const data = await fetchData();
|
|
752
|
-
return NextResponse.json({ data });
|
|
753
|
-
}
|
|
754
|
-
```
|
|
755
|
-
|
|
756
|
-
---
|
|
757
|
-
|
|
758
|
-
## 測試
|
|
759
|
-
|
|
760
|
-
### 單元測試(Jest)
|
|
761
|
-
|
|
762
|
-
```bash
|
|
763
|
-
npm test
|
|
764
|
-
npm run test:watch
|
|
765
|
-
npm run test:coverage
|
|
766
|
-
```
|
|
767
|
-
|
|
768
|
-
**範例**:
|
|
769
|
-
```typescript
|
|
770
|
-
// components/TaskCard.test.tsx
|
|
771
|
-
import { render, screen } from '@testing-library/react';
|
|
772
|
-
import { TaskCard } from './TaskCard';
|
|
773
|
-
|
|
774
|
-
test('renders task card', () => {
|
|
775
|
-
render(<TaskCard task={{ id: 'TASK_001', title: 'Test' }} />);
|
|
776
|
-
expect(screen.getByText('TASK_001')).toBeInTheDocument();
|
|
777
|
-
});
|
|
778
|
-
```
|
|
779
|
-
|
|
780
|
-
---
|
|
781
|
-
|
|
782
|
-
## 部署
|
|
783
|
-
|
|
784
|
-
### 開發模式
|
|
785
|
-
|
|
786
|
-
```bash
|
|
787
|
-
npm run dev # Next.js 開發伺服器 (http://localhost:3000)
|
|
788
|
-
npm run tauri:dev # Tauri 開發模式(桌面應用)
|
|
789
|
-
npm run electron:dev # Electron 開發模式
|
|
790
|
-
```
|
|
791
|
-
|
|
792
|
-
### 生產建置
|
|
793
|
-
|
|
794
|
-
```bash
|
|
795
|
-
npm run build # Next.js 靜態建置
|
|
796
|
-
npm run tauri:build # Tauri 打包(Windows/Mac/Linux)
|
|
797
|
-
npm run electron:build:win # Electron 打包(Windows)
|
|
798
|
-
```
|
|
799
|
-
|
|
800
|
-
---
|
|
801
|
-
|
|
802
|
-
## 相關文檔
|
|
803
|
-
|
|
804
|
-
- [Dashboard Tauri 後端架構](./.system/dashboard/BACKEND.md)
|
|
805
|
-
- [Tauri IPC 通訊機制](./.system/dashboard/IPC.md)
|
|
806
|
-
- [Formation 系統](./.system/formation/README.md)
|
|
807
|
-
- [Task Board 設計規格](./docs/specs/task-board.md)
|
|
808
|
-
|
|
809
|
-
---
|
|
810
|
-
|
|
811
|
-
**最後更新**:2026-02-19
|
|
812
|
-
**維護者**:Kenaz AI Team
|