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,107 +0,0 @@
|
|
|
1
|
-
# Sunny Team Launcher
|
|
2
|
-
|
|
3
|
-
使用 Claude Code Agent Teams 功能啟動多 Agent 協作(實驗性)。
|
|
4
|
-
|
|
5
|
-
## 環境需求
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# 自動設定,無需手動配置
|
|
9
|
-
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## 快速開始
|
|
13
|
-
|
|
14
|
-
### Window Mode(互動式)
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# 啟動 debug 團隊(競爭假設)
|
|
18
|
-
node .system/sunny/teammates/tools/powershell/launcher.js --preset debug --task "找出記憶體洩漏原因"
|
|
19
|
-
|
|
20
|
-
# 啟動 developer 團隊
|
|
21
|
-
node .system/sunny/teammates/tools/powershell/launcher.js --preset developer --task "實作登入功能"
|
|
22
|
-
|
|
23
|
-
# 啟動 strategy 團隊
|
|
24
|
-
node .system/sunny/teammates/tools/powershell/launcher.js --preset strategy --task "設計快取架構"
|
|
25
|
-
|
|
26
|
-
# 啟動 review 團隊
|
|
27
|
-
node .system/sunny/teammates/tools/powershell/launcher.js --preset review --task "審查 src/api/"
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Headless Mode(無頭模式)
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# 不開視窗,輸出存到 log
|
|
34
|
-
node .system/sunny/teammates/tools/headless/launcher.js --preset debug --task "調查 crash"
|
|
35
|
-
|
|
36
|
-
# 自訂輸出路徑
|
|
37
|
-
node .system/sunny/teammates/tools/headless/launcher.js --preset developer --task "實作功能" --output ./output.log
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 預設團隊
|
|
41
|
-
|
|
42
|
-
| Preset | 成員 | 用途 |
|
|
43
|
-
|--------|------|------|
|
|
44
|
-
| `debug` | Investigator-A, B, C | 問題調查(競爭假設) |
|
|
45
|
-
| `developer` | Frontend + Backend + Reviewer | 功能開發 |
|
|
46
|
-
| `strategy` | Architect + Researcher + Critic | 架構分析 |
|
|
47
|
-
| `review` | Security + Performance + Testing | Code Review |
|
|
48
|
-
|
|
49
|
-
## 命令選項
|
|
50
|
-
|
|
51
|
-
### Window Mode
|
|
52
|
-
|
|
53
|
-
| 選項 | 說明 |
|
|
54
|
-
|------|------|
|
|
55
|
-
| `--preset <name>` | 使用預設團隊 (debug\|developer\|strategy\|review) |
|
|
56
|
-
| `--task <prompt>` | 任務描述 |
|
|
57
|
-
| `--mode <mode>` | 隊友顯示模式 (in-process\|tmux) |
|
|
58
|
-
| `--cwd <path>` | 工作目錄 |
|
|
59
|
-
| `--run` | 直接執行(不開新視窗) |
|
|
60
|
-
| `--list-presets` | 列出可用預設 |
|
|
61
|
-
|
|
62
|
-
### Headless Mode
|
|
63
|
-
|
|
64
|
-
| 選項 | 說明 |
|
|
65
|
-
|------|------|
|
|
66
|
-
| `--preset <name>` | 使用預設團隊 |
|
|
67
|
-
| `--task <prompt>` | 任務描述 |
|
|
68
|
-
| `--output <path>` | 輸出檔路徑(預設: `log/session/{session_id}.log`) |
|
|
69
|
-
| `--cwd <path>` | 工作目錄 |
|
|
70
|
-
|
|
71
|
-
## 操作快捷鍵
|
|
72
|
-
|
|
73
|
-
| 按鍵 | 功能 |
|
|
74
|
-
|------|------|
|
|
75
|
-
| `Shift+Up/Down` | 切換隊友 |
|
|
76
|
-
| `Ctrl+T` | 顯示/隱藏任務清單 |
|
|
77
|
-
| `Enter` | 查看隊友工作階段 |
|
|
78
|
-
| `Escape` | 中斷當前回合 |
|
|
79
|
-
|
|
80
|
-
## 目錄結構
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
.system/sunny/teammates/
|
|
84
|
-
├── tools/
|
|
85
|
-
│ ├── powershell/
|
|
86
|
-
│ │ ├── launcher.js # Window Mode 啟動器
|
|
87
|
-
│ │ └── start.bat # 批次啟動腳本
|
|
88
|
-
│ ├── headless/
|
|
89
|
-
│ │ └── launcher.js # Headless Mode 啟動器
|
|
90
|
-
│ └── utils/
|
|
91
|
-
│ ├── env.js # 環境變數設定
|
|
92
|
-
│ └── format-output.js # 輸出格式化
|
|
93
|
-
├── log/
|
|
94
|
-
│ └── session/ # Headless 執行日誌
|
|
95
|
-
├── how_to_use.yaml # 使用指南(YAML 格式)
|
|
96
|
-
└── README.md # 本文件
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## 注意事項
|
|
100
|
-
|
|
101
|
-
- 所有 teammates 預設使用 `sonnet` model 降低成本
|
|
102
|
-
- Team Lead 負責協調所有 teammates,需等待全部回報才結束
|
|
103
|
-
- 這是獨立系統,使用 Claude Code 官方 Agent Teams 功能
|
|
104
|
-
|
|
105
|
-
## 官方文檔
|
|
106
|
-
|
|
107
|
-
https://docs.anthropic.com/en/docs/claude-code/agent-teams
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# Sunny Team Launcher
|
|
2
|
-
# 使用 Claude Code Agent Teams 功能啟動多 Agent 協作
|
|
3
|
-
# 版本: 1.1.0
|
|
4
|
-
|
|
5
|
-
overview:
|
|
6
|
-
description: "Claude Code Agent Teams 啟動器(實驗性)"
|
|
7
|
-
requirement: "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1"
|
|
8
|
-
when_to_use:
|
|
9
|
-
- 需要多角度調查問題
|
|
10
|
-
- 平行開發多個功能
|
|
11
|
-
- 程式碼審查與安全檢測
|
|
12
|
-
- 技術決策與架構設計
|
|
13
|
-
|
|
14
|
-
modes:
|
|
15
|
-
window:
|
|
16
|
-
name: "Window Mode"
|
|
17
|
-
path: ".system/sunny/teammates/tools/powershell/launcher.js"
|
|
18
|
-
status: stable
|
|
19
|
-
description: "開啟新 CMD 視窗執行,支援互動式對話"
|
|
20
|
-
command: |
|
|
21
|
-
node .system/sunny/teammates/tools/powershell/launcher.js --preset <preset> --task "<task>"
|
|
22
|
-
options:
|
|
23
|
-
- "--preset <name> | 使用預設團隊"
|
|
24
|
-
- "--task <prompt> | 任務描述"
|
|
25
|
-
- "--mode <mode> | 隊友顯示模式 (in-process|tmux)"
|
|
26
|
-
- "--cwd <path> | 工作目錄"
|
|
27
|
-
- "--run | 直接執行(不開新視窗)"
|
|
28
|
-
- "--list-presets | 列出可用預設"
|
|
29
|
-
|
|
30
|
-
headless:
|
|
31
|
-
name: "Headless Mode"
|
|
32
|
-
path: ".system/sunny/teammates/tools/headless/launcher.js"
|
|
33
|
-
status: stable
|
|
34
|
-
description: "無頭模式,不開視窗,輸出存到 log 檔"
|
|
35
|
-
command: |
|
|
36
|
-
node .system/sunny/teammates/tools/headless/launcher.js --preset <preset> --task "<task>"
|
|
37
|
-
options:
|
|
38
|
-
- "--preset <name> | 使用預設團隊"
|
|
39
|
-
- "--task <prompt> | 任務描述"
|
|
40
|
-
- "--output <path> | 輸出檔路徑(預設: log/session/{session_id}.log)"
|
|
41
|
-
- "--cwd <path> | 工作目錄"
|
|
42
|
-
log_format: "YYYYMMDD-HHMMSS-XXXX.log"
|
|
43
|
-
|
|
44
|
-
presets:
|
|
45
|
-
debug:
|
|
46
|
-
description: "問題調查(競爭假設)"
|
|
47
|
-
members:
|
|
48
|
-
- "Investigator-A → 調查假設 A"
|
|
49
|
-
- "Investigator-B → 調查假設 B"
|
|
50
|
-
- "Investigator-C → 調查假設 C"
|
|
51
|
-
behavior: "各自調查不同角度,互相辯駁直到達成共識"
|
|
52
|
-
use_case: ["Bug 調查", "根因分析", "多角度驗證"]
|
|
53
|
-
example: |
|
|
54
|
-
node .../powershell/launcher.js --preset debug --task "為什麼 auth.js 會 crash"
|
|
55
|
-
|
|
56
|
-
developer:
|
|
57
|
-
description: "功能開發"
|
|
58
|
-
members:
|
|
59
|
-
- "Frontend → React/TypeScript UI 實作"
|
|
60
|
-
- "Backend → API 和資料庫"
|
|
61
|
-
- "Reviewer → 審查變更"
|
|
62
|
-
behavior: "前後端分工開發,Reviewer 審查品質"
|
|
63
|
-
use_case: ["新功能開發", "Bug 修復", "程式碼實現"]
|
|
64
|
-
example: |
|
|
65
|
-
node .../powershell/launcher.js --preset developer --task "實作用戶登入功能"
|
|
66
|
-
|
|
67
|
-
strategy:
|
|
68
|
-
description: "技術決策"
|
|
69
|
-
members:
|
|
70
|
-
- "Architect → 系統設計與技術決策"
|
|
71
|
-
- "Researcher → 調查選項、蒐集資訊"
|
|
72
|
-
- "Critic → 挑戰假設、找出漏洞"
|
|
73
|
-
behavior: "架構師設計,研究員調查,批評者挑戰"
|
|
74
|
-
use_case: ["架構設計", "技術選型", "方案評估"]
|
|
75
|
-
example: |
|
|
76
|
-
node .../powershell/launcher.js --preset strategy --task "評估是否應該用 GraphQL"
|
|
77
|
-
|
|
78
|
-
review:
|
|
79
|
-
description: "程式碼審查"
|
|
80
|
-
members:
|
|
81
|
-
- "Security → 漏洞檢測"
|
|
82
|
-
- "Performance → 效能瓶頸"
|
|
83
|
-
- "Testing → 測試覆蓋率"
|
|
84
|
-
behavior: "三個專家各自審查不同面向"
|
|
85
|
-
use_case: ["安全審計", "效能分析", "測試檢查"]
|
|
86
|
-
example: |
|
|
87
|
-
node .../powershell/launcher.js --preset review --task "審查 src/api/ 目錄"
|
|
88
|
-
|
|
89
|
-
shortcuts:
|
|
90
|
-
keyboard:
|
|
91
|
-
- "Shift+Up/Down | 切換隊友"
|
|
92
|
-
- "Ctrl+T | 顯示/隱藏任務清單"
|
|
93
|
-
- "Enter | 查看隊友工作階段"
|
|
94
|
-
- "Escape | 中斷當前回合"
|
|
95
|
-
|
|
96
|
-
tips:
|
|
97
|
-
- "複雜問題 → debug preset(多假設競爭)"
|
|
98
|
-
- "開發任務 → developer preset(分工高效)"
|
|
99
|
-
- "重大決策 → strategy preset(避免盲點)"
|
|
100
|
-
- "上線前 → review preset(全面檢查)"
|
|
101
|
-
- "所有 teammates 使用 sonnet model 降低成本"
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Sunny Team Launcher - Headless Mode
|
|
4
|
-
* 無頭模式:不開視窗,直接在終端執行,完成後自動退出
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { spawn } = require('child_process');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const crypto = require('crypto');
|
|
11
|
-
const { getClaudeEnv } = require('../utils/env');
|
|
12
|
-
const { formatEntry } = require('../utils/format-output');
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 生成 Session ID
|
|
16
|
-
* 格式: YYYYMMDD-HHMMSS-XXXX (時間戳 + 4字元隨機碼)
|
|
17
|
-
*/
|
|
18
|
-
function generateSessionId() {
|
|
19
|
-
const now = new Date();
|
|
20
|
-
const timestamp = now.toISOString()
|
|
21
|
-
.replace(/[-:T]/g, '')
|
|
22
|
-
.slice(0, 14); // YYYYMMDDHHMMSS
|
|
23
|
-
const random = crypto.randomBytes(2).toString('hex'); // 4 chars
|
|
24
|
-
return `${timestamp.slice(0, 8)}-${timestamp.slice(8, 14)}-${random}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 取得預設 log 路徑
|
|
29
|
-
*/
|
|
30
|
-
function getDefaultLogPath(sessionId) {
|
|
31
|
-
// 從 tools/headless/ 往上回到 teammates/log/session/
|
|
32
|
-
const logDir = path.join(__dirname, '..', '..', 'log', 'session');
|
|
33
|
-
if (!fs.existsSync(logDir)) {
|
|
34
|
-
fs.mkdirSync(logDir, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
return path.join(logDir, `${sessionId}.log`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const CONFIG = {
|
|
40
|
-
cwd: process.cwd(),
|
|
41
|
-
teammateMode: 'in-process'
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// 系統前置指示
|
|
45
|
-
const SYSTEM_PREFIX = `You are the TEAM LEAD using Claude Code's OFFICIAL "agent teams" feature.
|
|
46
|
-
|
|
47
|
-
YOUR ROLE: Team Lead
|
|
48
|
-
- You are RESPONSIBLE for this task's success or failure.
|
|
49
|
-
- You MUST coordinate teammates and ensure they complete their work.
|
|
50
|
-
- You CANNOT end the session until ALL teammates have reported back.
|
|
51
|
-
- If you end early, the task FAILS and it's YOUR fault.
|
|
52
|
-
|
|
53
|
-
This is NOT the project's .formation/ directory system. Do NOT read .formation/ files.
|
|
54
|
-
To create teammates, use natural language like: "Create a teammate named X who handles Y"
|
|
55
|
-
Each teammate is a separate Claude instance running in parallel.
|
|
56
|
-
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
// 共用後置指示
|
|
60
|
-
const AUTO_EXECUTE = `
|
|
61
|
-
|
|
62
|
-
BEFORE YOU START - OUTPUT YOUR PLAN:
|
|
63
|
-
First, explain exactly what you will do step by step:
|
|
64
|
-
1. What teammates will you create?
|
|
65
|
-
2. How will you wait for their results?
|
|
66
|
-
3. What tools will you use to poll for messages?
|
|
67
|
-
4. When will you know all teammates are done?
|
|
68
|
-
|
|
69
|
-
RULES:
|
|
70
|
-
1. Do NOT ask questions. Execute immediately after stating your plan.
|
|
71
|
-
2. Do NOT read CLAUDE.md - this is a separate system.
|
|
72
|
-
3. Create teammates using natural language descriptions.
|
|
73
|
-
4. IMPORTANT: Use "sonnet" model for ALL teammates to reduce cost.
|
|
74
|
-
|
|
75
|
-
WAITING FOR TEAMMATES - CRITICAL:
|
|
76
|
-
5. After spawning ALL teammates, you MUST enter a polling loop.
|
|
77
|
-
6. In the loop: call "sleep 5" with Bash, then check if teammates sent messages.
|
|
78
|
-
7. Teammates send results via SendMessage - you will see them as incoming user messages.
|
|
79
|
-
8. Keep looping (sleep + check) until you have received messages from ALL teammates.
|
|
80
|
-
9. Do NOT end until you have ACTUAL CONTENT from every single teammate.
|
|
81
|
-
10. If a teammate is slow, keep waiting - do NOT give up or timeout early.
|
|
82
|
-
11. Only after ALL teammates report back, synthesize their findings into final answer.`;
|
|
83
|
-
|
|
84
|
-
const TEAM_PRESETS = {
|
|
85
|
-
developer: {
|
|
86
|
-
prompt: `${SYSTEM_PREFIX}Create an agent team with 3 teammates for development:
|
|
87
|
-
1. "Frontend" - handles React/TypeScript UI implementation
|
|
88
|
-
2. "Backend" - handles API and database work
|
|
89
|
-
3. "Reviewer" - reviews changes and checks for issues
|
|
90
|
-
|
|
91
|
-
Start working on the task immediately.${AUTO_EXECUTE}`
|
|
92
|
-
},
|
|
93
|
-
strategy: {
|
|
94
|
-
prompt: `${SYSTEM_PREFIX}Create an agent team with 3 teammates for strategic analysis:
|
|
95
|
-
1. "Architect" - handles system design and technical decisions
|
|
96
|
-
2. "Researcher" - investigates options and gathers information
|
|
97
|
-
3. "Critic" - challenges assumptions and finds flaws
|
|
98
|
-
|
|
99
|
-
Analyze and discuss the task, then provide recommendations.${AUTO_EXECUTE}`
|
|
100
|
-
},
|
|
101
|
-
review: {
|
|
102
|
-
prompt: `${SYSTEM_PREFIX}Create an agent team with 3 teammates for code review:
|
|
103
|
-
1. "Security" - checks for vulnerabilities
|
|
104
|
-
2. "Performance" - checks for bottlenecks
|
|
105
|
-
3. "Testing" - validates test coverage
|
|
106
|
-
|
|
107
|
-
Review the codebase and report findings.${AUTO_EXECUTE}`
|
|
108
|
-
},
|
|
109
|
-
debug: {
|
|
110
|
-
prompt: `${SYSTEM_PREFIX}Create an agent team with 3 teammates for debugging:
|
|
111
|
-
1. "Investigator-A" - investigates hypothesis A
|
|
112
|
-
2. "Investigator-B" - investigates hypothesis B
|
|
113
|
-
3. "Investigator-C" - investigates hypothesis C
|
|
114
|
-
|
|
115
|
-
Each investigates a different angle. Debate and disprove each other's theories until consensus.${AUTO_EXECUTE}`
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 無頭模式執行 Claude + Agent Teams
|
|
121
|
-
* 輸出人類可讀的日誌格式
|
|
122
|
-
*/
|
|
123
|
-
function launchHeadless(options = {}) {
|
|
124
|
-
const sessionId = generateSessionId();
|
|
125
|
-
const {
|
|
126
|
-
task = null,
|
|
127
|
-
preset = 'developer',
|
|
128
|
-
cwd = CONFIG.cwd,
|
|
129
|
-
output = null // null 表示使用預設路徑
|
|
130
|
-
} = options;
|
|
131
|
-
|
|
132
|
-
const outputFile = output || getDefaultLogPath(sessionId);
|
|
133
|
-
|
|
134
|
-
const env = getClaudeEnv();
|
|
135
|
-
|
|
136
|
-
// 組裝 prompt
|
|
137
|
-
const presetConfig = TEAM_PRESETS[preset];
|
|
138
|
-
let prompt = presetConfig ? presetConfig.prompt : '';
|
|
139
|
-
if (task) {
|
|
140
|
-
prompt += ` Task: ${task}`;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// 處理換行符
|
|
144
|
-
const cleanPrompt = prompt
|
|
145
|
-
.replace(/\r?\n/g, ' ')
|
|
146
|
-
.replace(/\s+/g, ' ')
|
|
147
|
-
.trim();
|
|
148
|
-
|
|
149
|
-
console.log(`☀️ Launching Claude Agent Team (Headless)...`);
|
|
150
|
-
console.log(` Session: ${sessionId}`);
|
|
151
|
-
console.log(` Preset: ${preset}`);
|
|
152
|
-
console.log(` Task: ${task || '(none)'}`);
|
|
153
|
-
console.log(` Output: ${outputFile}`);
|
|
154
|
-
console.log(`----------------------------------------`);
|
|
155
|
-
|
|
156
|
-
// 即時寫入 log - 先寫 header
|
|
157
|
-
const logStream = fs.createWriteStream(outputFile, { flags: 'w' });
|
|
158
|
-
logStream.write('================================================================================\n');
|
|
159
|
-
logStream.write('SUNNY TEAM EXECUTION LOG\n');
|
|
160
|
-
logStream.write(`Session: ${sessionId}\n`);
|
|
161
|
-
logStream.write(`Started: ${new Date().toISOString()}\n`);
|
|
162
|
-
logStream.write('================================================================================\n\n');
|
|
163
|
-
|
|
164
|
-
// 顯示 debug 資訊
|
|
165
|
-
console.log(` [DEBUG] Prompt length: ${cleanPrompt.length} chars`);
|
|
166
|
-
console.log(` [DEBUG] CWD: ${cwd}`);
|
|
167
|
-
|
|
168
|
-
// 寫 prompt 到臨時檔案,避免 shell 引號解析問題
|
|
169
|
-
const promptFile = path.join(__dirname, '..', '..', '.prompt.tmp');
|
|
170
|
-
fs.writeFileSync(promptFile, cleanPrompt, 'utf8');
|
|
171
|
-
console.log(` [DEBUG] Prompt written to temp file`);
|
|
172
|
-
|
|
173
|
-
// 用 stdin 傳遞 prompt,不經過 shell 參數解析
|
|
174
|
-
const args = [
|
|
175
|
-
'-p', '-', // 從 stdin 讀取 prompt
|
|
176
|
-
'--dangerously-skip-permissions',
|
|
177
|
-
'--teammate-mode', 'in-process',
|
|
178
|
-
'--output-format', 'stream-json',
|
|
179
|
-
'--verbose',
|
|
180
|
-
'--allowedTools', 'Bash,Read,Edit,Write,Glob,Grep,Task'
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
console.log(` [DEBUG] Spawning claude with stdin...`);
|
|
184
|
-
|
|
185
|
-
// Windows 需要用 claude.cmd + shell
|
|
186
|
-
const claudeCmd = process.platform === 'win32' ? 'claude.cmd' : 'claude';
|
|
187
|
-
|
|
188
|
-
const child = spawn(claudeCmd, args, {
|
|
189
|
-
cwd,
|
|
190
|
-
env,
|
|
191
|
-
stdio: ['pipe', 'pipe', 'pipe'], // stdin 改成 pipe
|
|
192
|
-
windowsHide: true,
|
|
193
|
-
shell: true
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
// 透過 stdin 傳送 prompt
|
|
197
|
-
child.stdin.write(cleanPrompt);
|
|
198
|
-
child.stdin.end();
|
|
199
|
-
|
|
200
|
-
console.log(` [DEBUG] Process spawned, PID: ${child.pid}`);
|
|
201
|
-
|
|
202
|
-
// 收集輸出
|
|
203
|
-
let buffer = '';
|
|
204
|
-
|
|
205
|
-
child.stdout.on('data', (data) => {
|
|
206
|
-
const str = data.toString();
|
|
207
|
-
process.stdout.write(data);
|
|
208
|
-
buffer += str;
|
|
209
|
-
|
|
210
|
-
// 按行解析 JSON 並即時寫入 log
|
|
211
|
-
const lines = buffer.split('\n');
|
|
212
|
-
buffer = lines.pop(); // 保留不完整的最後一行
|
|
213
|
-
for (const line of lines) {
|
|
214
|
-
if (line.trim()) {
|
|
215
|
-
try {
|
|
216
|
-
const entry = JSON.parse(line);
|
|
217
|
-
const formatted = formatEntry(entry);
|
|
218
|
-
if (formatted) {
|
|
219
|
-
logStream.write(formatted + '\n');
|
|
220
|
-
}
|
|
221
|
-
} catch (e) {
|
|
222
|
-
// 非 JSON 行,忽略
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
child.stderr.on('data', (data) => {
|
|
229
|
-
process.stderr.write(data);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
child.on('error', (err) => {
|
|
233
|
-
console.error(` [ERROR] Process error: ${err.message}`);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
let closed = false;
|
|
237
|
-
const cleanup = (code) => {
|
|
238
|
-
if (closed) return;
|
|
239
|
-
closed = true;
|
|
240
|
-
|
|
241
|
-
// 處理剩餘的 buffer
|
|
242
|
-
if (buffer.trim()) {
|
|
243
|
-
try {
|
|
244
|
-
const entry = JSON.parse(buffer);
|
|
245
|
-
const formatted = formatEntry(entry);
|
|
246
|
-
if (formatted) {
|
|
247
|
-
logStream.write(formatted + '\n');
|
|
248
|
-
}
|
|
249
|
-
} catch (e) {
|
|
250
|
-
// 非 JSON 行,忽略
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// 寫入 footer 並關閉 stream
|
|
255
|
-
logStream.write('\n================================================================================\n');
|
|
256
|
-
logStream.write(`Finished: ${new Date().toISOString()}\n`);
|
|
257
|
-
logStream.write(`Exit Code: ${code}\n`);
|
|
258
|
-
logStream.write('================================================================================\n');
|
|
259
|
-
logStream.end();
|
|
260
|
-
|
|
261
|
-
console.log(`----------------------------------------`);
|
|
262
|
-
console.log(`☀️ Claude exited with code ${code}`);
|
|
263
|
-
console.log(` Session: ${sessionId}`);
|
|
264
|
-
console.log(` Output saved to: ${outputFile}`);
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
child.on('close', cleanup);
|
|
268
|
-
child.on('exit', cleanup);
|
|
269
|
-
|
|
270
|
-
return child;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// CLI 入口
|
|
274
|
-
if (require.main === module) {
|
|
275
|
-
const args = process.argv.slice(2);
|
|
276
|
-
|
|
277
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
278
|
-
console.log(`
|
|
279
|
-
☀️ Sunny Team Launcher - Headless Mode
|
|
280
|
-
|
|
281
|
-
Usage:
|
|
282
|
-
node launcher_headless.js [options]
|
|
283
|
-
|
|
284
|
-
Options:
|
|
285
|
-
--preset <name> Use preset team (developer|strategy|review|debug)
|
|
286
|
-
--task <prompt> Custom task description
|
|
287
|
-
--output <path> Output log file (default: team/log/session/{session_id}.log)
|
|
288
|
-
--cwd <path> Working directory
|
|
289
|
-
|
|
290
|
-
Session ID Format: YYYYMMDD-HHMMSS-XXXX (timestamp + 4-char random)
|
|
291
|
-
|
|
292
|
-
Examples:
|
|
293
|
-
node launcher_headless.js --preset debug --task "List files"
|
|
294
|
-
node launcher_headless.js --preset debug --task "List files" --output custom.log
|
|
295
|
-
`);
|
|
296
|
-
process.exit(0);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const getArg = (flag) => {
|
|
300
|
-
const idx = args.indexOf(flag);
|
|
301
|
-
return idx !== -1 && args[idx + 1] ? args[idx + 1] : null;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
const preset = getArg('--preset') || 'developer';
|
|
305
|
-
const task = getArg('--task');
|
|
306
|
-
const output = getArg('--output') || null; // null = 使用預設 session 路徑
|
|
307
|
-
const cwd = getArg('--cwd') || CONFIG.cwd;
|
|
308
|
-
|
|
309
|
-
if (!TEAM_PRESETS[preset]) {
|
|
310
|
-
console.log(`❌ Unknown preset: ${preset}`);
|
|
311
|
-
console.log(' Available: developer, strategy, review, debug');
|
|
312
|
-
process.exit(1);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
launchHeadless({ preset, task, output, cwd });
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
module.exports = { launchHeadless, TEAM_PRESETS, generateSessionId };
|