triflux 10.9.19 → 10.9.20

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.
Files changed (103) hide show
  1. package/CLAUDE.md +212 -0
  2. package/hub/lib/bash-path.mjs +73 -0
  3. package/hub/team/dashboard-open.mjs +1 -68
  4. package/hub/team/native-supervisor.mjs +9 -2
  5. package/hub/team/psmux.mjs +5 -13
  6. package/hub/team/session.mjs +6 -26
  7. package/hub/team/swarm-hypervisor.mjs +205 -27
  8. package/hub/team/synapse-http.mjs +1 -0
  9. package/hub/team/tui-core.mjs +292 -0
  10. package/hub/team/tui-lite.mjs +20 -154
  11. package/hub/team/tui-synapse.mjs +213 -0
  12. package/hub/team/tui-widgets.mjs +262 -0
  13. package/hub/team/tui.mjs +159 -255
  14. package/hub/workers/delegator-mcp.mjs +2 -2
  15. package/package.json +21 -62
  16. package/references/hosts.json +46 -0
  17. package/scripts/__tests__/keyword-detector.test.mjs +4 -4
  18. package/scripts/cross-review-gate.mjs +13 -0
  19. package/scripts/remote-spawn.mjs +11 -46
  20. package/scripts/session-spawn-helper.mjs +8 -21
  21. package/scripts/test-tfx-route-no-claude-native.mjs +4 -2
  22. package/scripts/tfx-route.sh +13 -0
  23. package/skills/tfx-workspace/async-tests/run-tests.sh +203 -0
  24. package/skills/tfx-workspace/evals/evals.json +79 -0
  25. package/skills/tfx-workspace/iteration-1/benchmark.json +524 -0
  26. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/eval_metadata.json +11 -0
  27. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/grading.json +25 -0
  28. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/outputs/analysis.md +154 -0
  29. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/timing.json +5 -0
  30. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/grading.json +25 -0
  31. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/outputs/analysis.md +126 -0
  32. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/timing.json +5 -0
  33. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/eval_metadata.json +11 -0
  34. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/grading.json +25 -0
  35. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/outputs/analysis.md +119 -0
  36. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/timing.json +5 -0
  37. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/grading.json +25 -0
  38. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/outputs/analysis.md +115 -0
  39. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/timing.json +5 -0
  40. package/skills/tfx-workspace/iteration-1/hub-start-sequence/eval_metadata.json +10 -0
  41. package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/grading.json +20 -0
  42. package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/outputs/analysis.md +86 -0
  43. package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/timing.json +5 -0
  44. package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/grading.json +20 -0
  45. package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/outputs/analysis.md +81 -0
  46. package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/timing.json +5 -0
  47. package/skills/tfx-workspace/iteration-1/multi-team-creation/eval_metadata.json +12 -0
  48. package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/grading.json +30 -0
  49. package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/outputs/analysis.md +316 -0
  50. package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/timing.json +5 -0
  51. package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/grading.json +30 -0
  52. package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/outputs/analysis.md +352 -0
  53. package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/timing.json +5 -0
  54. package/skills/tfx-workspace/iteration-1/review.html +1325 -0
  55. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/eval_metadata.json +12 -0
  56. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/grading.json +30 -0
  57. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/outputs/analysis.md +97 -0
  58. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/timing.json +5 -0
  59. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/grading.json +30 -0
  60. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/outputs/analysis.md +94 -0
  61. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/timing.json +5 -0
  62. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/eval_metadata.json +12 -0
  63. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/grading.json +30 -0
  64. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/outputs/analysis.md +209 -0
  65. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/timing.json +5 -0
  66. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/grading.json +30 -0
  67. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/outputs/analysis.md +193 -0
  68. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/timing.json +5 -0
  69. package/skills/tfx-workspace/iteration-2/benchmark.json +144 -0
  70. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/eval_metadata.json +13 -0
  71. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/grading.json +35 -0
  72. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/outputs/analysis.md +382 -0
  73. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/timing.json +5 -0
  74. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/grading.json +35 -0
  75. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/outputs/analysis.md +333 -0
  76. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/timing.json +5 -0
  77. package/skills/tfx-workspace/iteration-2/review.html +1325 -0
  78. package/skills/tfx-workspace/skill-snapshot/tfx-auto/SKILL.md +217 -0
  79. package/skills/tfx-workspace/skill-snapshot/tfx-auto-codex/SKILL.md +77 -0
  80. package/skills/tfx-workspace/skill-snapshot/tfx-codex/SKILL.md +65 -0
  81. package/skills/tfx-workspace/skill-snapshot/tfx-doctor/SKILL.md +94 -0
  82. package/skills/tfx-workspace/skill-snapshot/tfx-gemini/SKILL.md +82 -0
  83. package/skills/tfx-workspace/skill-snapshot/tfx-hub/SKILL.md +133 -0
  84. package/skills/tfx-workspace/skill-snapshot/tfx-multi/SKILL.md +426 -0
  85. package/skills/tfx-workspace/skill-snapshot/tfx-setup/SKILL.md +101 -0
  86. package/.claude-plugin/marketplace.json +0 -34
  87. package/.claude-plugin/plugin.json +0 -22
  88. package/config/mcp-registry.json +0 -29
  89. package/scripts/__tests__/release-governance.test.mjs +0 -148
  90. package/scripts/release/bump-version.mjs +0 -77
  91. package/scripts/release/check-sync.mjs +0 -51
  92. package/scripts/release/lib.mjs +0 -303
  93. package/scripts/release/prepare.mjs +0 -85
  94. package/scripts/release/publish.mjs +0 -87
  95. package/scripts/release/verify.mjs +0 -81
  96. package/scripts/release/version-manifest.json +0 -26
  97. package/tui/codex-profile.mjs +0 -457
  98. package/tui/core.mjs +0 -266
  99. package/tui/doctor.mjs +0 -375
  100. package/tui/gemini-profile.mjs +0 -299
  101. package/tui/monitor-data.mjs +0 -152
  102. package/tui/monitor.mjs +0 -339
  103. package/tui/setup.mjs +0 -598
package/CLAUDE.md ADDED
@@ -0,0 +1,212 @@
1
+ <!-- prompt-hygiene:ignore line_count_warning -->
2
+ # triflux — Claude Code 운영 가이드
3
+
4
+ <core-systems>
5
+ ## 핵심 스킬 시스템 (항상 인지)
6
+
7
+ 이 프로젝트는 3개의 스킬 시스템을 동시에 사용한다. 어떤 작업이든 해당 시스템의 스킬이 있는지 먼저 확인한다.
8
+
9
+ | 시스템 | 접두사 | 용도 | 스킬 수 |
10
+ |--------|--------|------|---------|
11
+ | **triflux** | `/tfx-*` | CLI 라우팅, 멀티모델 오케스트레이션, 스웜, 원격 실행 | ~40개 |
12
+ | **gstack** | `/` (접두사 없음) | QA, ship, investigate, design, review, checkpoint | ~35개 |
13
+ | **omc** | `/oh-my-claudecode:*` | autopilot, ralph, team, ultrawork, ccg | ~25개 |
14
+
15
+ 스킬을 모르면 자연어 라우팅(아래)으로 자동 매핑된다.
16
+ 세션 종료 전 메모리 파일이 3개+ 변경됐으면 `/memory-hygiene` 제안을 검토한다.
17
+ </core-systems>
18
+
19
+ <psmux-wt>
20
+ ## psmux/WT 규칙
21
+
22
+ psmux 세션·WT 패인을 생성/조작/정리할 때 `tfx-psmux-rules` 스킬을 참조한다.
23
+ WT 프리징 방지: exit → sleep 2 → kill 순서. 바로 kill하지 않는다.
24
+
25
+ ### wt.exe → wt-manager 경유
26
+
27
+ safety-guard가 `wt.exe`, `wt new-tab`, `wt split-pane`, `Start-Process wt`를 차단한다.
28
+ `hub/team/wt-manager.mjs`의 API를 사용한다.
29
+
30
+ | 용도 | API |
31
+ |------|-----|
32
+ | 새 탭 | `createTab({ title, command, profile, cwd })` |
33
+ | 패인 분할 | `splitPane({ direction: 'H'\|'V', title, command })` |
34
+ | 다중 배치 | `applySplitLayout([{ title, command, direction }])` |
35
+ | 탭 정리 | `closeTab(title)` / `closeStale({ olderThanMs, titlePattern })` |
36
+
37
+ 차단과 대안은 항상 쌍으로 존재해야 한다. 차단만 추가하고 대안을 안 만들면 데드락.
38
+
39
+ ### psmux에서 Codex 실행
40
+
41
+ | 방식 | 동작 | 이유 |
42
+ |------|------|------|
43
+ | `codex` (interactive) | 불가 | psmux에서 TTY를 못 잡음 |
44
+ | `codex < prompt.md` | 불가 | "stdin is not a terminal" |
45
+ | `codex exec "$(cat prompt.md)" -s danger-full-access --dangerously-bypass-approvals-and-sandbox` | 사용 | 유일한 안전 경로 |
46
+
47
+ `codex exec`는 config.toml `approval_mode`를 무시하므로 `--dangerously-bypass-approvals-and-sandbox` 필수.
48
+ `-s` 유효값: read-only, workspace-write, danger-full-access.
49
+ </psmux-wt>
50
+
51
+ <codex-config>
52
+ ## Codex config.toml
53
+
54
+ config.toml에 이미 설정된 값은 CLI 플래그로 중복 지정하지 않는다.
55
+
56
+ | config.toml에 있으면 | CLI에서 생략 |
57
+ |---------------------|-------------|
58
+ | `approval_mode = "auto"` | `-a`, `--full-auto` |
59
+ | `sandbox = "workspace-write"` | `-s`, `--full-auto` |
60
+
61
+ 안전 패턴: config.toml에 기본값을 두고, CLI에서는 `--profile` 선택만 한다.
62
+ </codex-config>
63
+
64
+ <account-broker>
65
+ ## AccountBroker (계정 브로커)
66
+
67
+ conductor, headless, swarm-hypervisor가 하나의 AccountBroker 싱글턴을 공유한다.
68
+
69
+ | 항목 | 설명 |
70
+ |------|------|
71
+ | 계정별 CircuitBreaker | 장애 격리 — 한 계정 오류가 다른 계정에 전파되지 않음 |
72
+ | busy 플래그 | 동일 계정 이중 임대(double-lease) 방지 |
73
+ | `/broker/reload` | 장시간 세션 중 accounts.json 핫리로드 |
74
+ | EventEmitter 이벤트 | `lease`, `release`, `cooldown`, `tierFallback`, `circuitOpen`, `circuitClose`, `noAvailableAccounts` — HUD 연동용 |
75
+ </account-broker>
76
+
77
+ <remote>
78
+ ## 원격 실행
79
+
80
+ ### 스킬 구분
81
+
82
+ | 스킬 | 대상 | 방식 |
83
+ |------|------|------|
84
+ | tfx-codex-swarm | 로컬 전용 | 로컬 worktree + psmux |
85
+ | tfx-remote-spawn | Claude Code 원격 | SSH → Claude Code 세션 → 내부 tfx 라우팅 |
86
+
87
+ codex를 SSH 너머로 직접 실행하지 않는다. config.toml 충돌 + TTY 문제.
88
+ 원격에서 codex가 필요하면: remote-spawn → Claude Code → Claude가 내부에서 codex 호출.
89
+
90
+ ### SSH 패턴
91
+
92
+ hosts.json `os` 필드로 대상 셸을 판단한다. safety-guard도 이 필드를 참조.
93
+
94
+ | 대상 OS | 셸 | 패턴 |
95
+ |---------|-----|------|
96
+ | windows | PowerShell | scp + `pwsh -File` 필수. `$var` → `$env:VAR`, `2>/dev/null` → `2>$null` |
97
+ | darwin | zsh | 인라인 가능. brew PATH 주의 (`/opt/homebrew/bin`) |
98
+ | linux | bash | 인라인 가능. 표준 POSIX |
99
+
100
+ - `~` → `$HOME` 변환은 모든 OS 공통
101
+ </remote>
102
+
103
+ <headless-retrieval>
104
+ ## Headless 결과 회수
105
+
106
+ background로 실행한 headless 결과는 **반드시 task-notification 완료 후** 읽는다.
107
+
108
+ | 패턴 | 올바름 | 이유 |
109
+ |------|--------|------|
110
+ | task-notification 후 output 파일 읽기 | YES | 프로세스 종료 = 워커 전부 완료 |
111
+ | task-notification 전 output 파일 tail | NO | 시작 메시지만 보이고 "실패"로 오진 |
112
+ | psmux capture-pane으로 중간 체크 | NO | 워커 진행 중이면 빈 화면일 수 있음 |
113
+
114
+ 완료 마커: `=== HEADLESS_COMPLETE succeeded=N failed=N total=N ===`
115
+ 워커 상세: `$TMPDIR/tfx-headless/{sessionName}-worker-N.txt`
116
+ </headless-retrieval>
117
+
118
+ <cross-review>
119
+ ## 교차 검증
120
+
121
+ - Claude 작성 코드 → Codex 리뷰
122
+ - Codex 작성 코드 → Claude 리뷰
123
+ - 동일 모델 self-approve 하지 않는다
124
+ - git commit 전 미검증 파일 감지 시 nudge
125
+ </cross-review>
126
+
127
+ <session-context>
128
+ ## 맥락 이탈 판단
129
+
130
+ 현재 세션 맥락과 무관한 요청이 감지되면 psmux 격리를 제안한다.
131
+
132
+ | 확신도 | 신호 | 행동 |
133
+ |--------|------|------|
134
+ | 확실 | "새 탭", "별도로", "새 세션" | 바로 psmux spawn |
135
+ | 높음 | 다른 프로젝트/스택 언급 | 분리 제안 |
136
+ | 중간 | 작업 유형 전환 | 분리 제안 + 현재 세션 옵션 |
137
+ | 낮음 | 현재 작업 연장 | 세션 유지 |
138
+ </session-context>
139
+
140
+ <routing>
141
+ ## 자연어 → 스킬 라우팅
142
+
143
+ 사용자가 스킬명을 모르더라도 자연어로 요청하면 아래 규칙에 따라 적절한 스킬을 호출한다.
144
+
145
+ ### 행동 유형 → 스킬 매핑
146
+
147
+ | 의도 | 자연어 신호 | 스킬 |
148
+ |------|-----------|------|
149
+ | 구현/수정 | 만들어, 고쳐, 구현해, 짜줘, 수정해, 바꿔 | tfx-auto |
150
+ | 리뷰 | 봐줘, 리뷰해, 검토해, 괜찮아? | tfx-review |
151
+ | 분석 | 분석해, 어떻게 돌아가?, 구조가 뭐야 | tfx-analysis |
152
+ | 계획 | 계획, 어떻게 하지, 설계해 | tfx-plan |
153
+ | 검색 | 찾아, 어디있어, 파일 찾아 | tfx-find |
154
+ | 리서치 (빠른) | 검색해줘, 찾아봐, 공식문서, 이거 뭐야 | tfx-research |
155
+ | 리서치 (자율) | 자율 리서치, 검색하고 정리해, research and plan | tfx-autoresearch |
156
+ | 테스트 | 테스트, 검증, 돌려봐, QA | tfx-qa |
157
+ | 정리 | 정리해, 슬롭 제거, 클린업 | tfx-prune |
158
+ | 토론 | 뭐가 나을까, 비교해, A vs B | tfx-debate |
159
+
160
+ ### 깊이 수정자
161
+
162
+ | 수정자 | 신호 | 효과 |
163
+ |--------|------|------|
164
+ | 기본 | (없음), 빠르게, 간단히 | Light 스킬 |
165
+ | 깊이 | 제대로, 꼼꼼히, 철저히 | Deep 스킬 (tfx-deep-*). 예외: tfx-deep-interview는 Gemini 단독 |
166
+ | 합의 | 3자, 교차, 다각도 | consensus 프로토콜 |
167
+ | 반복 | 끝까지, 멈추지마, ralph | persist 모드 |
168
+ | 자율 | 알아서, 자동으로, autopilot | autopilot 모드 |
169
+
170
+ ### CLI 라우팅
171
+
172
+ headless-guard가 `codex exec` / `gemini -y -p` 직접 호출을 차단한다. tfx 스킬 경유 필수.
173
+
174
+ **Layer 1 — Light** (tfx-route.sh → 단일 CLI)
175
+
176
+ | 스킬 | CLI | 용도 |
177
+ |------|-----|------|
178
+ | tfx-auto | 자동 | 통합 진입점 |
179
+ | tfx-codex | Codex | Codex 전용 |
180
+ | tfx-gemini | Gemini | Gemini 전용 |
181
+ | tfx-autopilot | Codex→검증 | 단일 파일, 5분 이내 |
182
+ | tfx-autoroute | 자동 승격 | 실패→더 강한 모델 |
183
+
184
+ **Layer 2 — Deep** (headless 3-CLI 합의)
185
+
186
+ tfx-deep-review, tfx-deep-qa, tfx-deep-plan, tfx-deep-research, tfx-consensus, tfx-debate, tfx-panel, tfx-fullcycle, tfx-persist
187
+
188
+ **Layer 3 — Remote/병렬**
189
+
190
+ | 스킬 | 용도 |
191
+ |------|------|
192
+ | tfx-multi | 2+개 태스크 headless 병렬 |
193
+ | tfx-swarm | PRD별 worktree + 다중 모델(Codex/Gemini/Claude) + 다중 기기(로컬+원격) |
194
+ | tfx-remote-spawn | Claude Code 원격 세션 (SSH, setup 필수) |
195
+
196
+ **Claude 네이티브** (CLI 불필요): tfx-find, tfx-forge, tfx-prune, tfx-index, tfx-setup, tfx-doctor, tfx-hooks, tfx-hub
197
+
198
+ 자원 우선순위: remote-spawn > swarm > multi > Light > 로컬 단독
199
+
200
+ ### 충돌 해소
201
+
202
+ - ralph = persist alias
203
+ - "auto" 단독 → tfx-auto. "알아서 해" → tfx-autopilot
204
+ - "코드에서 찾아" → tfx-find. "알아봐" → tfx-research
205
+ - 복합 의도: "구현하고 리뷰까지" → tfx-auto → cross-review hook
206
+
207
+ ### Q-Learning 동적 라우팅 (실험적)
208
+
209
+ - `TRIFLUX_DYNAMIC_ROUTING=true` 또는 `1` 설정 시 Q-Learning 기반 동적 스킬 라우팅 활성화
210
+ - `routing-weights.json` + Q-table로 스킬 선택 최적화
211
+ - 기본 비활성
212
+ </routing>
@@ -0,0 +1,73 @@
1
+ import { existsSync } from "node:fs";
2
+
3
+ const GIT_BASH_PATHS = Object.freeze([
4
+ "C:/Program Files/Git/bin/bash.exe",
5
+ "C:/Program Files/Git/usr/bin/bash.exe",
6
+ "C:/Program Files (x86)/Git/bin/bash.exe",
7
+ "C:/Program Files (x86)/Git/usr/bin/bash.exe",
8
+ ]);
9
+
10
+ /**
11
+ * Resolve a concrete Git Bash executable on Windows.
12
+ *
13
+ * @param {object} [opts]
14
+ * @param {string} [opts.platform=process.platform]
15
+ * @param {(path: string) => boolean} [opts.exists=existsSync]
16
+ * @returns {string | null}
17
+ */
18
+ export function resolveGitBashExecutable(opts = {}) {
19
+ const { platform = process.platform, exists = existsSync } = opts;
20
+
21
+ if (platform !== "win32") {
22
+ return null;
23
+ }
24
+
25
+ return GIT_BASH_PATHS.find((candidate) => exists(candidate)) || null;
26
+ }
27
+
28
+ /**
29
+ * Resolve a Windows-safe bash executable.
30
+ * On Windows we prefer Git Bash over bare `bash`, which may resolve to WSL.
31
+ *
32
+ * @param {object} [opts]
33
+ * @param {string} [opts.platform=process.platform]
34
+ * @param {(path: string) => boolean} [opts.exists=existsSync]
35
+ * @returns {string}
36
+ */
37
+ export function resolveBashExecutable(opts = {}) {
38
+ return resolveGitBashExecutable(opts) || "bash";
39
+ }
40
+
41
+ function shellQuote(command) {
42
+ return `'${String(command).replace(/'/g, `'"'"'`)}'`;
43
+ }
44
+
45
+ /**
46
+ * Wrap .sh script command strings so Windows always runs them through Bash.
47
+ * This prevents shell:true child launches from treating a script path like an
48
+ * openable file association instead of an executable script.
49
+ *
50
+ * @param {string} command
51
+ * @param {object} [opts]
52
+ * @param {string} [opts.bashCommand]
53
+ * @returns {string}
54
+ */
55
+ export function ensureBashScriptExecution(command, opts = {}) {
56
+ const text = String(command || "").trim();
57
+ if (!text) return text;
58
+
59
+ if (!/\.sh(?:\s|$)/iu.test(text)) {
60
+ return text;
61
+ }
62
+
63
+ if (
64
+ /^(?:\s*[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|\S+)\s+)*(?:bash(?:\.exe)?|sh)\b/iu.test(
65
+ text,
66
+ )
67
+ ) {
68
+ return text;
69
+ }
70
+
71
+ const bashCommand = opts.bashCommand || resolveBashExecutable();
72
+ return `${bashCommand} -lc ${shellQuote(text)}`;
73
+ }
@@ -1,11 +1,5 @@
1
1
  import { psmuxExec } from "./psmux.mjs";
2
- import {
3
- detectMultiplexer,
4
- focusWtPane,
5
- hasWindowsTerminal,
6
- resolveAttachCommand,
7
- tmuxExec,
8
- } from "./session.mjs";
2
+ import { hasWindowsTerminal } from "./session.mjs";
9
3
  import { createWtManager } from "./wt-manager.mjs";
10
4
 
11
5
  function sanitizeWindowTitle(value, fallback = "triflux") {
@@ -81,26 +75,6 @@ async function spawnWindowsTerminal(spec, opts = {}) {
81
75
  }
82
76
  }
83
77
 
84
- export function focusManagedPane(target, opts = {}) {
85
- const { teammateMode = "", layout = "1xN" } = opts;
86
- const paneRef = String(target || "");
87
-
88
- if (teammateMode === "wt" || paneRef.startsWith("wt:")) {
89
- const paneIndex = parseWorkerNumber(paneRef);
90
- return paneIndex != null && focusWtPane(paneIndex, { layout });
91
- }
92
-
93
- if (!paneRef) return false;
94
- try {
95
- if (detectMultiplexer() === "psmux")
96
- psmuxExec(["select-pane", "-t", paneRef]);
97
- else tmuxExec(`select-pane -t ${paneRef}`);
98
- return true;
99
- } catch {
100
- return false;
101
- }
102
- }
103
-
104
78
  export function openHeadlessDashboardTarget(sessionName, opts = {}) {
105
79
  const { worker = null, openAll = false, cwd = process.cwd(), title } = opts;
106
80
 
@@ -126,44 +100,3 @@ export function openHeadlessDashboardTarget(sessionName, opts = {}) {
126
100
  );
127
101
  return true;
128
102
  }
129
-
130
- export function openDashboardRuntimeTarget(runtime, opts = {}) {
131
- const {
132
- teammateMode = "",
133
- sessionName = "",
134
- targetPane = "",
135
- layout = "1xN",
136
- openAll = false,
137
- cwd = process.cwd(),
138
- title = "",
139
- } = { ...runtime, ...opts };
140
-
141
- if (teammateMode === "headless") {
142
- return openHeadlessDashboardTarget(sessionName, {
143
- worker: openAll ? null : targetPane,
144
- openAll,
145
- cwd,
146
- title,
147
- });
148
- }
149
-
150
- if (
151
- (teammateMode === "wt" || String(targetPane).startsWith("wt:")) &&
152
- !openAll
153
- ) {
154
- return focusManagedPane(targetPane, { teammateMode: "wt", layout });
155
- }
156
-
157
- try {
158
- if (!openAll && targetPane)
159
- focusManagedPane(targetPane, { teammateMode, layout });
160
- void spawnWindowsTerminal(resolveAttachCommand(sessionName), {
161
- mode: decideDashboardOpenMode({ openAll }),
162
- title: title || `▲ ${sanitizeSessionName(sessionName)}`,
163
- cwd,
164
- });
165
- return true;
166
- } catch {
167
- return false;
168
- }
169
- }
@@ -9,6 +9,10 @@ import {
9
9
  } from "node:fs";
10
10
  import { createServer } from "node:http";
11
11
  import { dirname, join } from "node:path";
12
+ import {
13
+ ensureBashScriptExecution,
14
+ resolveBashExecutable,
15
+ } from "../lib/bash-path.mjs";
12
16
  import { verifySlimWrapperRouteExecution } from "./native.mjs";
13
17
  import { forceCleanupTeam } from "./nativeProxy.mjs";
14
18
 
@@ -149,7 +153,10 @@ function validateMemberCommand(command, memberName) {
149
153
  }
150
154
 
151
155
  function spawnMember(member) {
152
- validateMemberCommand(member.command, member.name);
156
+ const command = ensureBashScriptExecution(member.command, {
157
+ bashCommand: resolveBashExecutable(),
158
+ });
159
+ validateMemberCommand(command, member.name);
153
160
 
154
161
  const outPath = join(logsDir, `${member.name}.out.log`);
155
162
  const errPath = join(logsDir, `${member.name}.err.log`);
@@ -157,7 +164,7 @@ function spawnMember(member) {
157
164
  const outWs = createWriteStream(outPath, { flags: "a" });
158
165
  const errWs = createWriteStream(errPath, { flags: "a" });
159
166
 
160
- const child = spawn(member.command, {
167
+ const child = spawn(command, {
161
168
  shell: true,
162
169
  env: {
163
170
  ...process.env,
@@ -1,10 +1,12 @@
1
1
  // hub/team/psmux.mjs — Windows psmux 세션/키바인딩/캡처/steering 관리
2
2
  // 의존성: child_process, fs, os, path (Node.js 내장)만 사용
3
- import * as childProcess from "../lib/spawn-trace.mjs";
3
+
4
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { homedir, tmpdir } from "node:os";
6
6
  import { join } from "node:path";
7
7
  import { formatPsmuxInstallGuidance } from "../../scripts/lib/psmux-info.mjs";
8
+ import { resolveGitBashExecutable } from "../lib/bash-path.mjs";
9
+ import childProcess from "../lib/spawn-trace.mjs";
8
10
  import { IS_WINDOWS } from "../platform.mjs";
9
11
 
10
12
  const PSMUX_BIN = (() => {
@@ -35,7 +37,7 @@ const PSMUX_BIN = (() => {
35
37
  return "psmux"; // 최종 fallback — 원래대로
36
38
  })();
37
39
  const GIT_BASH =
38
- process.env.GIT_BASH_PATH || "C:\\Program Files\\Git\\bin\\bash.exe";
40
+ process.env.GIT_BASH_PATH || resolveGitBashExecutable() || "bash";
39
41
 
40
42
  /** Windows psmux 세션의 기본 셸을 PowerShell로 강제한다 (pwsh7 우선, ps5 fallback). */
41
43
  const PWSH_BIN = (() => {
@@ -1041,17 +1043,7 @@ export function startCapture(sessionName, paneNameOrTarget) {
1041
1043
  // WSL bash에서는 /c/Users/... 경로가 유효하지 않아 exit 127 발생.
1042
1044
  // psmux pane 용 (PowerShell → bash 실행): & "path" 형식
1043
1045
  // Node.js execSync 용 (직접 실행): "path" 형식
1044
- const _gitBashPath = (() => {
1045
- if (!IS_WINDOWS) return null;
1046
- const candidates = [
1047
- "C:\\Program Files\\Git\\usr\\bin\\bash.exe",
1048
- "C:\\Program Files (x86)\\Git\\usr\\bin\\bash.exe",
1049
- ];
1050
- for (const p of candidates) {
1051
- if (existsSync(p)) return p;
1052
- }
1053
- return null;
1054
- })();
1046
+ const _gitBashPath = IS_WINDOWS ? resolveGitBashExecutable() : null;
1055
1047
  // PowerShell call operator(&)가 필요: & "C:\...\bash.exe" -c '...'
1056
1048
  const GIT_BASH_BIN_PS = _gitBashPath ? `& "${_gitBashPath}"` : "bash";
1057
1049
  // Node.js execSync에서 직접 실행할 때는 따옴표만
@@ -1,8 +1,8 @@
1
1
  // hub/team/session.mjs — tmux/psmux/wt 세션 생명주기 관리
2
2
  // 의존성: child_process (Node.js 내장)만 사용
3
3
  import { execSync, spawnSync } from "node:child_process";
4
+ import { resolveGitBashExecutable } from "../lib/bash-path.mjs";
4
5
  import { getEnvironment } from "../lib/env-detect.mjs";
5
- import { createWtManager } from "./wt-manager.mjs";
6
6
  import {
7
7
  attachPsmuxSession,
8
8
  capturePsmuxPane,
@@ -15,27 +15,7 @@ import {
15
15
  psmuxExec,
16
16
  psmuxSessionExists,
17
17
  } from "./psmux.mjs";
18
-
19
- const GIT_BASH_CANDIDATES = [
20
- "C:/Program Files/Git/bin/bash.exe",
21
- "C:/Program Files/Git/usr/bin/bash.exe",
22
- ];
23
-
24
- function findGitBashExe() {
25
- for (const p of GIT_BASH_CANDIDATES) {
26
- try {
27
- execSync(`"${p}" --version`, {
28
- stdio: "ignore",
29
- timeout: 3000,
30
- windowsHide: true,
31
- });
32
- return p;
33
- } catch {
34
- // 다음 후보
35
- }
36
- }
37
- return null;
38
- }
18
+ import { createWtManager } from "./wt-manager.mjs";
39
19
 
40
20
  /** Windows Terminal 실행 파일 존재 여부 */
41
21
  export function hasWindowsTerminal() {
@@ -73,7 +53,7 @@ function hasWslTmux() {
73
53
 
74
54
  /** Git Bash 내 tmux 사용 가능 여부 (Windows 전용) */
75
55
  function hasGitBashTmux() {
76
- const bash = findGitBashExe();
56
+ const bash = resolveGitBashExecutable();
77
57
  if (!bash) return false;
78
58
  try {
79
59
  const r = spawnSync(bash, ["-lc", "tmux -V"], {
@@ -184,8 +164,8 @@ export function tmuxExec(args, opts = {}) {
184
164
  * @param {string} sessionName
185
165
  * @returns {{ command: string, args: string[] }}
186
166
  */
187
- export function resolveAttachCommand(sessionName) {
188
- const mux = detectMultiplexer();
167
+ export function resolveAttachCommand(sessionName, opts = {}) {
168
+ const mux = opts.mux || detectMultiplexer();
189
169
  if (!mux) {
190
170
  throw new Error("tmux/psmux 미발견");
191
171
  }
@@ -198,7 +178,7 @@ export function resolveAttachCommand(sessionName) {
198
178
  }
199
179
 
200
180
  if (mux === "git-bash-tmux") {
201
- const bash = findGitBashExe();
181
+ const bash = opts.bashCommand || resolveGitBashExecutable();
202
182
  if (!bash) throw new Error("git-bash-tmux 감지 실패");
203
183
  return {
204
184
  command: bash,