triflux 4.2.3 → 4.2.6

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 (81) hide show
  1. package/bin/tfx-doctor.mjs +1 -1
  2. package/bin/tfx-setup.mjs +1 -1
  3. package/bin/triflux.mjs +2 -14
  4. package/hub/server.mjs +3 -2
  5. package/hub/team/native.mjs +58 -47
  6. package/hub/workers/delegator-mcp.mjs +17 -5
  7. package/package.json +62 -62
  8. package/scripts/lib/mcp-filter.mjs +34 -8
  9. package/scripts/setup.mjs +21 -16
  10. package/scripts/tfx-route.sh +14 -8
  11. package/scripts/token-snapshot.mjs +561 -561
  12. package/skills/tfx-auto/SKILL.md +1 -1
  13. package/skills/tfx-codex/SKILL.md +1 -1
  14. package/skills/tfx-gemini/SKILL.md +1 -1
  15. package/skills/tfx-hub/SKILL.md +4 -1
  16. package/skills/tfx-multi/SKILL.md +177 -378
  17. package/skills/tfx-multi/references/agent-wrapper-rules.md +81 -0
  18. package/skills/tfx-multi/references/thorough-pipeline.md +66 -0
  19. package/skills/tfx-workspace/evals/evals.json +79 -0
  20. package/skills/tfx-workspace/iteration-1/benchmark.json +162 -0
  21. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/eval_metadata.json +11 -0
  22. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/grading.json +9 -0
  23. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/outputs/analysis.md +154 -0
  24. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/timing.json +5 -0
  25. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/grading.json +9 -0
  26. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/outputs/analysis.md +126 -0
  27. package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/timing.json +5 -0
  28. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/eval_metadata.json +11 -0
  29. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/grading.json +9 -0
  30. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/outputs/analysis.md +119 -0
  31. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/timing.json +5 -0
  32. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/grading.json +9 -0
  33. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/outputs/analysis.md +115 -0
  34. package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/timing.json +5 -0
  35. package/skills/tfx-workspace/iteration-1/hub-start-sequence/eval_metadata.json +10 -0
  36. package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/grading.json +8 -0
  37. package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/outputs/analysis.md +86 -0
  38. package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/timing.json +5 -0
  39. package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/grading.json +8 -0
  40. package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/outputs/analysis.md +81 -0
  41. package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/timing.json +5 -0
  42. package/skills/tfx-workspace/iteration-1/multi-team-creation/eval_metadata.json +12 -0
  43. package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/grading.json +10 -0
  44. package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/outputs/analysis.md +316 -0
  45. package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/timing.json +5 -0
  46. package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/grading.json +10 -0
  47. package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/outputs/analysis.md +352 -0
  48. package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/timing.json +5 -0
  49. package/skills/tfx-workspace/iteration-1/review.html +1325 -0
  50. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/eval_metadata.json +12 -0
  51. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/grading.json +10 -0
  52. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/outputs/analysis.md +97 -0
  53. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/timing.json +5 -0
  54. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/grading.json +10 -0
  55. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/outputs/analysis.md +94 -0
  56. package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/timing.json +5 -0
  57. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/eval_metadata.json +12 -0
  58. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/grading.json +10 -0
  59. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/outputs/analysis.md +209 -0
  60. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/timing.json +5 -0
  61. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/grading.json +10 -0
  62. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/outputs/analysis.md +193 -0
  63. package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/timing.json +5 -0
  64. package/skills/tfx-workspace/iteration-2/benchmark.json +62 -0
  65. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/eval_metadata.json +13 -0
  66. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/grading.json +11 -0
  67. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/outputs/analysis.md +382 -0
  68. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/timing.json +5 -0
  69. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/grading.json +11 -0
  70. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/outputs/analysis.md +333 -0
  71. package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/timing.json +5 -0
  72. package/skills/tfx-workspace/iteration-2/review.html +1325 -0
  73. package/skills/tfx-workspace/skill-snapshot/tfx-auto/SKILL.md +217 -0
  74. package/skills/tfx-workspace/skill-snapshot/tfx-auto-codex/SKILL.md +77 -0
  75. package/skills/tfx-workspace/skill-snapshot/tfx-codex/SKILL.md +65 -0
  76. package/skills/tfx-workspace/skill-snapshot/tfx-doctor/SKILL.md +94 -0
  77. package/skills/tfx-workspace/skill-snapshot/tfx-gemini/SKILL.md +82 -0
  78. package/skills/tfx-workspace/skill-snapshot/tfx-hub/SKILL.md +133 -0
  79. package/skills/tfx-workspace/skill-snapshot/tfx-multi/SKILL.md +426 -0
  80. package/skills/tfx-workspace/skill-snapshot/tfx-setup/SKILL.md +101 -0
  81. package/scripts/psmux-steering-prototype.sh +0 -368
@@ -0,0 +1,316 @@
1
+ # tfx-multi Routing Analysis
2
+
3
+ ## Input
4
+ ```
5
+ /tfx-multi 인증 리팩터링 + UI 개선 + 보안 리뷰
6
+ ```
7
+
8
+ ---
9
+
10
+ ## Phase 0: Preflight Checks
11
+
12
+ **Mode determination:** The input has no `--tmux`, `--psmux`, `--agents`, or `N:agent` prefix, and is not a control command (`status`/`stop`/etc.), so this is **auto mode**.
13
+
14
+ **Execution order (auto mode):** Phase 0 (preflight) and Phase 2 (triage) run **simultaneously in parallel** (NOT sequentially). Phase 3 starts only after both complete.
15
+
16
+ **Single combined Bash check:**
17
+ ```bash
18
+ Bash({
19
+ command: "curl -sf http://127.0.0.1:27888/status >/dev/null && test -f ~/.claude/scripts/tfx-route.sh && echo \"preflight: ok\" || echo \"preflight: FAIL\""
20
+ })
21
+ ```
22
+
23
+ **What is verified:**
24
+ - Hub is running and healthy at `http://127.0.0.1:27888/status` (`/status` endpoint — `/health` alone is forbidden)
25
+ - `~/.claude/scripts/tfx-route.sh` exists on disk
26
+
27
+ **Output policy:** Only a single summary line is shown to the user (e.g., `preflight: ok (route/hub)`). No individual Bash logs are surfaced unless preflight fails.
28
+
29
+ **Failure actions (only if preflight fails):**
30
+ - `tfx-route.sh` missing → advise user to run `tfx setup`
31
+ - Hub not running/unhealthy → surface Hub error detail
32
+ - Required CLI not installed → surface missing CLI detail
33
+
34
+ ---
35
+
36
+ ## Phase 1: Input Parsing
37
+
38
+ **Raw input:** `"인증 리팩터링 + UI 개선 + 보안 리뷰"`
39
+
40
+ **Parse results:**
41
+ - No `--tmux` / `--psmux` flag → NOT routed to Phase 3-mux
42
+ - No `--agents` flag
43
+ - No `N:agent_type` prefix (e.g., `3:codex`)
44
+ - Not a control command (`status`, `stop`, `kill`, `attach`, `list`, `send`)
45
+ - Input string is non-empty → no prompt to user required
46
+ - No `--thorough` flag → **`--quick` mode (default)**; Phase 2.5, 2.6, 3.5, 3.6, 3.7 are all SKIPPED
47
+
48
+ **Determined mode:** Auto mode, `--quick`
49
+
50
+ ---
51
+
52
+ ## Phase 2: Triage — Decomposition
53
+
54
+ ### Step 2a: Codex Classification
55
+
56
+ ```bash
57
+ Bash({
58
+ command: "codex exec --full-auto --skip-git-repo-check '다음 작업을 분석하고 각 부분에 적합한 agent를 분류하라.\n\n agent 선택:\n - codex: 코드 구현/수정/분석/리뷰/디버깅/설계 (기본값)\n - gemini: 문서/UI/디자인/멀티모달\n - claude: 코드베이스 탐색/테스트 실행/검증 (최후 수단)\n\n 모든 역할은 Codex/Gemini 우선 배정:\n - explore, verifier, test-engineer, qa-tester 포함 전 역할이 Codex/Gemini로 라우팅\n - Codex/Gemini 미설치 시에만 claude-native(sonnet/haiku) fallback\n - claude 타입은 최후 수단으로만 사용\n\n 작업: 인증 리팩터링 + UI 개선 + 보안 리뷰\n\n JSON만 출력:\n { \"parts\": [{ \"description\": \"...\", \"agent\": \"codex|gemini|claude\" }] }\n'"
59
+ })
60
+ ```
61
+
62
+ **Expected Codex classification output (JSON):**
63
+ ```json
64
+ {
65
+ "parts": [
66
+ { "description": "인증 리팩터링", "agent": "codex" },
67
+ { "description": "UI 개선", "agent": "gemini" },
68
+ { "description": "보안 리뷰", "agent": "codex" }
69
+ ]
70
+ }
71
+ ```
72
+
73
+ Rationale per the skill's agent selection rules:
74
+ - "인증 리팩터링" → code refactoring → `codex` (executor)
75
+ - "UI 개선" → UI/design → `gemini` (designer)
76
+ - "보안 리뷰" → code review/analysis → `codex` (reviewer)
77
+
78
+ If Codex classification fails, the Lead (Opus) directly classifies and decomposes inline with the same result.
79
+
80
+ ### Step 2b: Inline Decomposition
81
+
82
+ ```javascript
83
+ assignments = [
84
+ { cli: "codex", subtask: "인증 리팩터링", role: "executor" },
85
+ { cli: "gemini", subtask: "UI 개선", role: "designer" },
86
+ { cli: "codex", subtask: "보안 리뷰", role: "reviewer" }
87
+ ]
88
+ ```
89
+
90
+ **Note:** Phase 2.5 (Plan) and Phase 2.6 (PRD) are SKIPPED because `--thorough` was NOT specified.
91
+
92
+ ---
93
+
94
+ ## Phase 3: Native Teams Execution
95
+
96
+ ### Step 3a: TeamCreate
97
+
98
+ ```
99
+ teamName = "tfx-" + Date.now().toString(36).slice(-6)
100
+ // Example: "tfx-m3x9pq"
101
+ ```
102
+
103
+ ```javascript
104
+ TeamCreate({
105
+ team_name: "tfx-m3x9pq",
106
+ description: "tfx-multi: 인증 리팩터링 + UI 개선 + 보안 리뷰"
107
+ })
108
+ ```
109
+
110
+ ### Step 3b: TaskCreate (3 tasks, one per subtask)
111
+
112
+ **Task 1:**
113
+ ```javascript
114
+ TaskCreate({
115
+ subject: "인증 리팩터링",
116
+ description: "CLI: codex, 역할: executor\n\n인증 관련 코드를 리팩터링한다.",
117
+ metadata: { cli: "codex", role: "executor" }
118
+ })
119
+ // → taskId: <task-id-1>
120
+ // → agentName: "codex-worker-1"
121
+ ```
122
+
123
+ **Task 2:**
124
+ ```javascript
125
+ TaskCreate({
126
+ subject: "UI 개선",
127
+ description: "CLI: gemini, 역할: designer\n\nUI를 개선한다.",
128
+ metadata: { cli: "gemini", role: "designer" }
129
+ })
130
+ // → taskId: <task-id-2>
131
+ // → agentName: "gemini-worker-1"
132
+ ```
133
+
134
+ **Task 3:**
135
+ ```javascript
136
+ TaskCreate({
137
+ subject: "보안 리뷰",
138
+ description: "CLI: codex, 역할: reviewer\n\n보안 관련 코드 리뷰를 수행한다.",
139
+ metadata: { cli: "codex", role: "reviewer" }
140
+ })
141
+ // → taskId: <task-id-3>
142
+ // → agentName: "codex-worker-2"
143
+ ```
144
+
145
+ **runQueue after 3b:**
146
+ ```javascript
147
+ runQueue = [
148
+ { taskId: "<task-id-1>", agentName: "codex-worker-1", cli: "codex", subtask: "인증 리팩터링", role: "executor" },
149
+ { taskId: "<task-id-2>", agentName: "gemini-worker-1", cli: "gemini", subtask: "UI 개선", role: "designer" },
150
+ { taskId: "<task-id-3>", agentName: "codex-worker-2", cli: "codex", subtask: "보안 리뷰", role: "reviewer" }
151
+ ]
152
+ ```
153
+
154
+ ### Step 3c: Agent Slim-Wrapper Spawn (codex and gemini items)
155
+
156
+ All three items use `cli: "codex"` or `cli: "gemini"`, so ALL THREE get slim-wrapper Agents (none are `cli: "claude"`).
157
+
158
+ The prompt for each is generated by `buildSlimWrapperPrompt()` in `hub/team/native.mjs`. The wrapper's core behavior:
159
+ 1. `TaskUpdate(taskId, status: in_progress)` — claim
160
+ 2. `SendMessage(to: "team-lead", "작업 시작: {agentName}")` — start report (creates turn boundary)
161
+ 3. `Bash(command: "bash ~/.claude/scripts/tfx-route.sh {role} '{subtask}' {mcp_profile}", timeout: {bashTimeoutMs})` — delegate to tfx-route.sh
162
+ 4. `SendMessage(to: "team-lead", "결과: {요약}")` — result report (creates turn boundary)
163
+ 5. Await lead feedback; loop back to step 3 if further instructions received
164
+ 6. Final: `TaskUpdate(status: completed, metadata: {result: "success"|"failed"})` + `SendMessage` → exit
165
+
166
+ **Bash timeout calculation (from `getRouteTimeout`):**
167
+ - `executor` role → default 1080 seconds + 60 buffer = **1140 seconds = 1,140,000 ms**
168
+ - `designer` role → default 1080 seconds + 60 buffer = **1140 seconds = 1,140,000 ms**
169
+ - `reviewer` role → maps to `review` profile → **3600 seconds + 60 buffer = 3,660,000 ms**
170
+
171
+ **Agent call 1 — codex-worker-1:**
172
+ ```javascript
173
+ Agent({
174
+ name: "codex-worker-1",
175
+ team_name: "tfx-m3x9pq",
176
+ mode: "bypassPermissions",
177
+ run_in_background: true,
178
+ prompt: buildSlimWrapperPrompt("codex", {
179
+ subtask: "인증 리팩터링",
180
+ role: "executor",
181
+ teamName: "tfx-m3x9pq",
182
+ taskId: "<task-id-1>",
183
+ agentName: "codex-worker-1",
184
+ leadName: "team-lead",
185
+ mcp_profile: <resolved_mcp_profile>
186
+ })
187
+ // Internal Bash: "bash ~/.claude/scripts/tfx-route.sh executor '인증 리팩터링' <mcp_profile>"
188
+ // Bash timeout: 1,140,000 ms
189
+ })
190
+ ```
191
+
192
+ **Agent call 2 — gemini-worker-1:**
193
+ ```javascript
194
+ Agent({
195
+ name: "gemini-worker-1",
196
+ team_name: "tfx-m3x9pq",
197
+ mode: "bypassPermissions",
198
+ run_in_background: true,
199
+ prompt: buildSlimWrapperPrompt("gemini", {
200
+ subtask: "UI 개선",
201
+ role: "designer",
202
+ teamName: "tfx-m3x9pq",
203
+ taskId: "<task-id-2>",
204
+ agentName: "gemini-worker-1",
205
+ leadName: "team-lead",
206
+ mcp_profile: <resolved_mcp_profile>
207
+ })
208
+ // Internal Bash: "bash ~/.claude/scripts/tfx-route.sh designer 'UI 개선' <mcp_profile>"
209
+ // Bash timeout: 1,140,000 ms
210
+ })
211
+ ```
212
+
213
+ **Agent call 3 — codex-worker-2:**
214
+ ```javascript
215
+ Agent({
216
+ name: "codex-worker-2",
217
+ team_name: "tfx-m3x9pq",
218
+ mode: "bypassPermissions",
219
+ run_in_background: true,
220
+ prompt: buildSlimWrapperPrompt("codex", {
221
+ subtask: "보안 리뷰",
222
+ role: "reviewer",
223
+ teamName: "tfx-m3x9pq",
224
+ taskId: "<task-id-3>",
225
+ agentName: "codex-worker-2",
226
+ leadName: "team-lead",
227
+ mcp_profile: <resolved_mcp_profile>
228
+ })
229
+ // Internal Bash: "bash ~/.claude/scripts/tfx-route.sh reviewer '보안 리뷰' <mcp_profile>"
230
+ // Bash timeout: 3,660,000 ms
231
+ })
232
+ ```
233
+
234
+ **`mode: "bypassPermissions"` — YES, included in all three Agent calls.** This is mandatory per the skill definition; without it workers would pause awaiting user approval on every Bash call.
235
+
236
+ **`tfx-route.sh` usage — YES.** Workers call `bash ~/.claude/scripts/tfx-route.sh`, never `codex exec ...` or `gemini -y -p ...` directly. Direct calls are explicitly forbidden by the skill.
237
+
238
+ ### Step 3d: claude-type Agent — NOT APPLICABLE
239
+
240
+ None of the three subtasks were classified as `cli: "claude"`, so Step 3d is skipped entirely.
241
+
242
+ ### Step 3e: User Notification
243
+
244
+ ```
245
+ 팀 'tfx-m3x9pq' 생성 완료.
246
+ Codex/Gemini 워커가 슬림 래퍼 Agent로 네비게이션에 등록되었습니다.
247
+ Shift+Down으로 다음 워커로 전환 (마지막→리드 wrap). Shift+Tab으로 이전 워커 전환.
248
+ ```
249
+
250
+ ---
251
+
252
+ ## Phase 4: Result Collection
253
+
254
+ 1. Lead waits for all three background Agent processes to complete.
255
+ 2. Query `team_task_list` as the **single truth source**:
256
+
257
+ ```bash
258
+ Bash({
259
+ command: "node hub/bridge.mjs team-task-list --team tfx-m3x9pq"
260
+ })
261
+ ```
262
+
263
+ 3. For any task where status is `completed` but `metadata.result == "failed"`: trigger Claude fallback retry.
264
+ 4. After fallback, re-query `team_task_list` to confirm final state.
265
+ 5. `send-message` and `result(task.result)` events are observation channels only; final verdict is always from `team_task_list`.
266
+
267
+ **Summary report (example):**
268
+ ```markdown
269
+ ## tfx-multi 실행 결과
270
+
271
+ | # | Worker | CLI | 작업 | 상태 |
272
+ |---|----------------|--------|---------------|-----------|
273
+ | 1 | codex-worker-1 | codex | 인증 리팩터링 | completed |
274
+ | 2 | gemini-worker-1| gemini | UI 개선 | completed |
275
+ | 3 | codex-worker-2 | codex | 보안 리뷰 | completed |
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Phase 5: Cleanup (always runs — success or failure)
281
+
282
+ 1. Wait up to **30 seconds** for all background Agents to finish.
283
+ 2. If any Agent is still running after 30 seconds, proceed with cleanup anyway.
284
+ 3. Call `TeamDelete`:
285
+
286
+ ```javascript
287
+ TeamDelete({
288
+ team_name: "tfx-m3x9pq"
289
+ })
290
+ ```
291
+
292
+ 4. If `TeamDelete` fails (active members still present), call `forceCleanupTeam("tfx-m3x9pq")`.
293
+ If that also fails, output manual cleanup instructions:
294
+ ```
295
+ rm -rf ~/.claude/teams/tfx-m3x9pq/ ~/.claude/tasks/tfx-m3x9pq/
296
+ ```
297
+ 5. Output the final summary report.
298
+
299
+ **Reason TeamDelete is mandatory:** Leaving `~/.claude/teams/{teamName}/` on disk causes the OMC hook to repeatedly detect "team executing", creating an infinite loop.
300
+
301
+ ---
302
+
303
+ ## Key Routing Decisions Summary
304
+
305
+ | Question | Answer |
306
+ |----------|--------|
307
+ | `mode: "bypassPermissions"` in Agent calls? | YES — all three Agent calls include it |
308
+ | `tfx-route.sh` used inside Agent wrappers? | YES — `bash ~/.claude/scripts/tfx-route.sh {role} '{subtask}' {mcp_profile}` |
309
+ | Direct `codex exec` or `gemini -y -p` calls? | NO — explicitly forbidden |
310
+ | Workers use Read/Edit/Write/Grep/Glob tools? | NO — forbidden; all file operations delegated via tfx-route.sh |
311
+ | `--thorough` pipeline stages (Phase 2.5, 2.6, 3.5–3.7)? | SKIPPED — `--quick` (default) mode |
312
+ | `--tmux`/`--psmux` mode? | NO — not in input |
313
+ | Step 3d (claude-type Agent)? | SKIPPED — no subtask has `cli: "claude"` |
314
+ | TeamDelete on failure? | YES — Phase 5 is unconditional |
315
+ | Preflight and triage run in parallel? | YES — auto mode runs Phase 0 + Phase 2 in parallel |
316
+ | Lead directly calling Codex/Gemini Bash? | NO — Lead spawns Agent wrappers; wrappers call tfx-route.sh |
@@ -0,0 +1,5 @@
1
+ {
2
+ "total_tokens": 26140,
3
+ "duration_ms": 100578,
4
+ "total_duration_seconds": 100.6
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "expectations": [
3
+ {"text": "Creates exactly one TeamCreate with tfx- prefix naming", "passed": true, "evidence": "Agent output: TeamCreate({ team_name: 'tfx-<6-char-base36>' })"},
4
+ {"text": "Creates 3 TaskCreate calls (one per subtask)", "passed": true, "evidence": "Agent output: '3x TaskCreate(...) with metadata: { cli, role }'"},
5
+ {"text": "Spawns 3 Agent wrappers with mode: bypassPermissions", "passed": true, "evidence": "Agent output: '3x Agent({ mode: bypassPermissions, run_in_background: true })'"},
6
+ {"text": "Uses tfx-route.sh inside Agent wrapper (not direct codex/gemini)", "passed": true, "evidence": "Agent output: 'Each wrapper executes bash ~/.claude/scripts/tfx-route.sh. Direct codex exec or gemini -y -p calls are prohibited.'"},
7
+ {"text": "Includes Phase 5 cleanup (TeamDelete)", "passed": true, "evidence": "Agent output: 'Phase 5: TeamDelete() always runs regardless of success/failure, with max 30s wait'"}
8
+ ],
9
+ "summary": {"passed": 5, "failed": 0, "total": 5, "pass_rate": 1.0}
10
+ }
@@ -0,0 +1,352 @@
1
+ # tfx-multi Routing Analysis
2
+
3
+ **Input:** `/tfx-multi 인증 리팩터링 + UI 개선 + 보안 리뷰`
4
+ **Skill:** `tfx-multi` (SKILL.md — v3 파이프라인 기반 멀티-CLI 팀 오케스트레이터)
5
+ **Mode detected:** `--quick` (기본값, `--thorough` 플래그 없음)
6
+
7
+ ---
8
+
9
+ ## Phase 0: Preflight Checks
10
+
11
+ **병렬 정책:** 자동 모드이므로 Phase 0(preflight) + Phase 2(triage)를 동시 병렬로 실행한다.
12
+ Agent spawn(Phase 3)은 Phase 2 완료 후 시작한다.
13
+
14
+ 단일 Bash 명령으로 통합 실행:
15
+
16
+ ```bash
17
+ Bash("curl -sf http://127.0.0.1:27888/status >/dev/null && test -f ~/.claude/scripts/tfx-route.sh && echo 'preflight: ok' || echo 'preflight: FAIL'")
18
+ ```
19
+
20
+ 점검 항목:
21
+ - Hub 상태: `http://127.0.0.1:27888/status` 응답 확인 (`/health` 단독 판정 금지)
22
+ - `tfx-route.sh` 파일 존재 여부: `~/.claude/scripts/tfx-route.sh`
23
+ - 필수 CLI 설치 여부: codex, gemini (검증 실패 시 해당 워커를 claude fallback으로 대체)
24
+
25
+ 출력 정책: 성공 시 `preflight: ok (route/hub)` 한 줄만 노출. 실패 항목이 있을 때만 상세 출력.
26
+
27
+ ---
28
+
29
+ ## Phase 1: Input Parsing
30
+
31
+ 입력 문자열: `"인증 리팩터링 + UI 개선 + 보안 리뷰"`
32
+
33
+ - `--tmux` / `--psmux` 플래그: 없음 → Phase 3-mux 분기 없음
34
+ - `--thorough` 플래그: 없음 → `--quick` (기본) 모드 확정
35
+ - `N:agent` 패턴: 없음 → 수동 모드 아님
36
+ - `--agents` 플래그: 없음
37
+ - 제어 커맨드 (`status`, `stop`, `kill`, `attach`, `list`, `send`): 없음
38
+ - 인자: 비어 있지 않음 → Phase 2로 진행 가능
39
+
40
+ 결론: **자동 모드** (Codex 분류 → Opus 분해)로 Phase 2 진행.
41
+
42
+ ---
43
+
44
+ ## Phase 2: Triage (자동 모드)
45
+
46
+ ### Step 2a: Codex 분류
47
+
48
+ ```bash
49
+ Bash("codex exec --full-auto --skip-git-repo-check '다음 작업을 분석하고 각 부분에 적합한 agent를 분류하라.
50
+
51
+ agent 선택:
52
+ - codex: 코드 구현/수정/분석/리뷰/디버깅/설계 (기본값)
53
+ - gemini: 문서/UI/디자인/멀티모달
54
+ - claude: 코드베이스 탐색/테스트 실행/검증 (최후 수단)
55
+
56
+ 모든 역할은 Codex/Gemini 우선 배정:
57
+ - explore, verifier, test-engineer, qa-tester 포함 전 역할이 Codex/Gemini로 라우팅
58
+ - Codex/Gemini 미설치 시에만 claude-native(sonnet/haiku) fallback
59
+ - claude 타입은 최후 수단으로만 사용
60
+
61
+ 작업: 인증 리팩터링 + UI 개선 + 보안 리뷰
62
+
63
+ JSON만 출력:
64
+ { \"parts\": [{ \"description\": \"...\", \"agent\": \"codex|gemini|claude\" }] }
65
+ '")
66
+ ```
67
+
68
+ Codex 분류 실패 시 → Opus(오케스트레이터)가 직접 분류+분해.
69
+
70
+ ### Step 2b: 인라인 분해 (예상 결과)
71
+
72
+ Codex 분류 결과를 기반으로 아래 서브태스크 배열을 구성한다:
73
+
74
+ | # | CLI | Subtask | Role |
75
+ |---|--------|---------------|-----------|
76
+ | 1 | codex | 인증 리팩터링 | executor |
77
+ | 2 | gemini | UI 개선 | designer |
78
+ | 3 | codex | 보안 리뷰 | reviewer |
79
+
80
+ ```javascript
81
+ assignments = [
82
+ { cli: "codex", subtask: "인증 리팩터링", role: "executor" },
83
+ { cli: "gemini", subtask: "UI 개선", role: "designer" },
84
+ { cli: "codex", subtask: "보안 리뷰", role: "reviewer" }
85
+ ]
86
+ ```
87
+
88
+ > 참고: 입력에 `+`로 구분된 3개의 명시적 파트가 있으므로 분류 결과는 이 3파트 기준으로 맞춰진다.
89
+ > 실제 Codex 분류 JSON에 따라 CLI 배정이 달라질 수 있다.
90
+
91
+ ### Phase 2.5–2.6: 건너뜀
92
+
93
+ `--quick` 기본 모드이므로 Plan(2.5), PRD(2.6) 단계를 실행하지 않는다.
94
+
95
+ ---
96
+
97
+ ## Phase 3: Native Teams 실행
98
+
99
+ ### Step 3a: TeamCreate
100
+
101
+ ```javascript
102
+ teamName = "tfx-" + Date.now().toString(36).slice(-6)
103
+ // 예: "tfx-m3x7qk" (실행 시점에 따라 다름)
104
+
105
+ TeamCreate({
106
+ team_name: teamName, // e.g. "tfx-m3x7qk"
107
+ description: "tfx-multi: 인증 리팩터링 + UI 개선 + 보안 리뷰"
108
+ })
109
+ ```
110
+
111
+ ### Step 3b: TaskCreate (공유 작업 등록)
112
+
113
+ 각 서브태스크에 대해 순서대로 TaskCreate를 호출하고 반환된 taskId를 보존한다.
114
+
115
+ **서브태스크 1 (인증 리팩터링):**
116
+ ```javascript
117
+ TaskCreate({
118
+ subject: "인증 리팩터링",
119
+ description: "CLI: codex, 역할: executor\n\n인증 리팩터링 작업 상세 내용",
120
+ metadata: { cli: "codex", role: "executor" }
121
+ })
122
+ // taskId_1 = created_task.id
123
+ // agentName_1 = "codex-worker-1"
124
+ ```
125
+
126
+ **서브태스크 2 (UI 개선):**
127
+ ```javascript
128
+ TaskCreate({
129
+ subject: "UI 개선",
130
+ description: "CLI: gemini, 역할: designer\n\nUI 개선 작업 상세 내용",
131
+ metadata: { cli: "gemini", role: "designer" }
132
+ })
133
+ // taskId_2 = created_task.id
134
+ // agentName_2 = "gemini-worker-2"
135
+ ```
136
+
137
+ **서브태스크 3 (보안 리뷰):**
138
+ ```javascript
139
+ TaskCreate({
140
+ subject: "보안 리뷰",
141
+ description: "CLI: codex, 역할: reviewer\n\n보안 리뷰 작업 상세 내용",
142
+ metadata: { cli: "codex", role: "reviewer" }
143
+ })
144
+ // taskId_3 = created_task.id
145
+ // agentName_3 = "codex-worker-3"
146
+ ```
147
+
148
+ ### Step 3c: Agent 슬림 래퍼 spawn (codex/gemini 서브태스크)
149
+
150
+ 3개 서브태스크 모두 cli가 `codex` 또는 `gemini`이므로, 3개 모두 슬림 래퍼 Agent로 spawn한다.
151
+ `mode: "bypassPermissions"`는 모든 Agent spawn에 반드시 포함된다.
152
+
153
+ **Agent 1 — codex-worker-1 (인증 리팩터링):**
154
+ ```javascript
155
+ Agent({
156
+ name: "codex-worker-1",
157
+ team_name: teamName, // "tfx-m3x7qk"
158
+ mode: "bypassPermissions", // [필수] 사용자 승인 없이 Bash 실행
159
+ run_in_background: true,
160
+ prompt: buildSlimWrapperPrompt("codex", {
161
+ subtask: "인증 리팩터링",
162
+ role: "executor",
163
+ teamName: teamName,
164
+ taskId: taskId_1,
165
+ agentName: "codex-worker-1",
166
+ leadName: "team-lead",
167
+ mcp_profile: mcp_profile // tfx-route.sh에 전달할 MCP 프로파일
168
+ })
169
+ // prompt 내용(buildSlimWrapperPrompt 출력, ~100 토큰):
170
+ // 1. TaskUpdate(taskId_1, status: "in_progress")
171
+ // 2. SendMessage(to: "team-lead", "작업 시작: codex-worker-1")
172
+ // 3. Bash("bash ~/.claude/scripts/tfx-route.sh executor '인증 리팩터링' {mcp_profile}",
173
+ // timeout: 1140000) // 1080초 + 60초 여유 = 1140초 → ms
174
+ // 4. SendMessage(to: "team-lead", "결과: {요약}")
175
+ // 5. 리드 피드백 대기 → 필요 시 Step 3 재실행
176
+ // 6. TaskUpdate(taskId_1, status: "completed", metadata: {result: "success"|"failed"})
177
+ // + SendMessage(to: "team-lead") → 종료
178
+ })
179
+ ```
180
+
181
+ Bash timeout 계산: `executor` 역할, 일반 프로파일 → 기본 1080초 + 60초 = **1140초 → 1,140,000 ms**
182
+
183
+ **Agent 2 — gemini-worker-2 (UI 개선):**
184
+ ```javascript
185
+ Agent({
186
+ name: "gemini-worker-2",
187
+ team_name: teamName,
188
+ mode: "bypassPermissions",
189
+ run_in_background: true,
190
+ prompt: buildSlimWrapperPrompt("gemini", {
191
+ subtask: "UI 개선",
192
+ role: "designer",
193
+ teamName: teamName,
194
+ taskId: taskId_2,
195
+ agentName: "gemini-worker-2",
196
+ leadName: "team-lead",
197
+ mcp_profile: mcp_profile
198
+ })
199
+ // Bash 내부:
200
+ // Bash("bash ~/.claude/scripts/tfx-route.sh designer 'UI 개선' {mcp_profile}",
201
+ // timeout: 1140000)
202
+ })
203
+ ```
204
+
205
+ **Agent 3 — codex-worker-3 (보안 리뷰):**
206
+ ```javascript
207
+ Agent({
208
+ name: "codex-worker-3",
209
+ team_name: teamName,
210
+ mode: "bypassPermissions",
211
+ run_in_background: true,
212
+ prompt: buildSlimWrapperPrompt("codex", {
213
+ subtask: "보안 리뷰",
214
+ role: "reviewer",
215
+ teamName: teamName,
216
+ taskId: taskId_3,
217
+ agentName: "codex-worker-3",
218
+ leadName: "team-lead",
219
+ mcp_profile: mcp_profile
220
+ })
221
+ // Bash 내부:
222
+ // Bash("bash ~/.claude/scripts/tfx-route.sh reviewer '보안 리뷰' {mcp_profile}",
223
+ // timeout: 4260000) // reviewer → review 프로파일 → 3600초 + 60초 = 3660초
224
+ // ※ reviewer 역할은 review 프로파일로 분류될 수 있어 timeout이 3660초가 될 수 있음
225
+ })
226
+ ```
227
+
228
+ > Bash timeout 참고:
229
+ > - `analyze/review` 프로파일 또는 `architect/analyst` 역할: 3600초 + 60초 = 3660초 → 3,660,000 ms
230
+ > - 그 외 기본: 1080초 + 60초 = 1140초 → 1,140,000 ms
231
+ > - `reviewer` 역할이 `review` 프로파일로 매핑되면 3,660,000 ms, 기본 프로파일이면 1,140,000 ms
232
+
233
+ ### Step 3d: claude 타입 Agent 직접 실행
234
+
235
+ 이 케이스에서는 `cli == "claude"` 서브태스크가 없으므로 Step 3d는 실행되지 않는다.
236
+
237
+ ### Step 3e: 사용자 안내
238
+
239
+ ```
240
+ "팀 '{teamName}' 생성 완료.
241
+ Codex/Gemini 워커가 슬림 래퍼 Agent로 네비게이션에 등록되었습니다.
242
+ Shift+Down으로 다음 워커로 전환 (마지막→리드 wrap). Shift+Tab으로 이전 워커 전환."
243
+ ```
244
+
245
+ ### Phase 3.5–3.7: 건너뜀
246
+
247
+ `--quick` 모드이므로 Verify(3.5), Fix Loop(3.6), Ralph Loop(3.7)을 실행하지 않는다.
248
+
249
+ ---
250
+
251
+ ## Phase 4: 결과 수집
252
+
253
+ truth source: `team_task_list`
254
+
255
+ ```bash
256
+ Bash("node hub/bridge.mjs team-task-list --team ${teamName}")
257
+ ```
258
+
259
+ 1. 모든 백그라운드 Agent 완료를 대기한다.
260
+ 2. 위 명령으로 `team_task_list`를 최종 truth source로 조회한다.
261
+ 3. `status: "completed"` + `metadata.result == "failed"` 태스크가 있으면 Claude fallback 재시도한다.
262
+ 4. 재시도 후 `team_task_list`를 재조회하여 최종 상태를 확정한다.
263
+ 5. `send-message` 및 `result(task.result)` 이벤트는 진행 관찰 채널로만 사용한다. 최종 판정은 반드시 `team_task_list` 기준.
264
+
265
+ 종합 보고서 형식:
266
+ ```markdown
267
+ ## tfx-multi 실행 결과
268
+
269
+ | # | Worker | CLI | 작업 | 상태 |
270
+ |---|---------------|--------|---------------|-----------|
271
+ | 1 | codex-worker-1 | codex | 인증 리팩터링 | completed |
272
+ | 2 | gemini-worker-2 | gemini | UI 개선 | completed |
273
+ | 3 | codex-worker-3 | codex | 보안 리뷰 | completed |
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Phase 5: Cleanup (TeamDelete)
279
+
280
+ 반드시 실행 — 성공/실패 관계없이 건너뛸 수 없음.
281
+
282
+ 1. 모든 백그라운드 Agent 완료를 **최대 30초** 대기한다.
283
+ 2. 30초 후에도 미완료 Agent가 있으면 대기를 중단하고 정리를 진행한다.
284
+ 3. `TeamDelete()` 호출:
285
+ ```javascript
286
+ TeamDelete({ team_name: teamName })
287
+ ```
288
+ 4. TeamDelete 실패 시 (활성 멤버 잔존) → `forceCleanupTeam(teamName)` 강제 정리.
289
+ `forceCleanupTeam`도 실패 시 수동 정리 안내:
290
+ ```bash
291
+ rm -rf ~/.claude/teams/{teamName}/ ~/.claude/tasks/{teamName}/
292
+ ```
293
+ 5. 종합 보고서를 출력한다.
294
+
295
+ TeamDelete를 반드시 실행해야 하는 이유: `~/.claude/teams/{teamName}/`이 잔존하면
296
+ OMC hook이 "team executing"을 반복 감지하는 무한 루프에 빠진다.
297
+
298
+ ---
299
+
300
+ ## 핵심 규칙 확인
301
+
302
+ ### `mode: "bypassPermissions"` 포함 여부
303
+
304
+ **포함 — 필수.** 모든 Agent spawn(codex-worker, gemini-worker, claude-worker)에 반드시 포함한다.
305
+ 이 설정이 없으면 워커의 Bash 실행 시 사용자 승인이 요청되어 자동 실행이 중단된다.
306
+
307
+ 본 케이스의 3개 Agent 모두:
308
+ - `Agent({ ..., mode: "bypassPermissions", ... })`
309
+
310
+ ### `tfx-route.sh` 사용 여부 (Agent 내부)
311
+
312
+ **사용 — 필수.** 슬림 래퍼 Agent 내부에서 Codex/Gemini를 실행할 때 반드시 아래 형식만 허용:
313
+
314
+ ```bash
315
+ bash ~/.claude/scripts/tfx-route.sh {role} '{subtask}' {mcp_profile}
316
+ ```
317
+
318
+ **직접 호출 금지:**
319
+ - `codex exec "..."` — 직접 호출 금지
320
+ - `gemini -y -p "..."` — 직접 호출 금지
321
+
322
+ 직접 호출 시 누락되는 항목:
323
+ - 모델 지정 (`-m gemini-3.1-pro-preview` 등)
324
+ - MCP 필터
325
+ - 팀 bridge 연동 (`TFX_TEAM_*`)
326
+ - Windows 호환 경로
327
+ - 타임아웃
328
+ - 후처리 (토큰 추적/이슈 로깅)
329
+
330
+ tfx-route.sh 내부에서 `TFX_TEAM_*` 환경변수를 통해 Hub 통신:
331
+ - `TFX_TEAM_NAME` — 팀 식별자 (`teamName`)
332
+ - `TFX_TEAM_TASK_ID` — 작업 식별자 (`taskId`)
333
+ - `TFX_TEAM_AGENT_NAME` — 워커 이름 (`agentName`)
334
+ - `TFX_TEAM_LEAD_NAME` — 리드 수신자 (`"team-lead"`)
335
+
336
+ Hub 통신 경로: Named Pipe(`\\.\pipe\triflux-{pid}`) 우선, HTTP(`127.0.0.1:27888`) fallback.
337
+
338
+ ---
339
+
340
+ ## 요약
341
+
342
+ | 항목 | 값 |
343
+ |-------------------------------|-----------------------------------------|
344
+ | 감지 모드 | 자동 모드, `--quick` (기본) |
345
+ | Phase 0 병렬 실행 | preflight + Phase 2(triage) 동시 병렬 |
346
+ | 서브태스크 수 | 3개 |
347
+ | Agent spawn 방식 | 슬림 래퍼 (Step 3c) × 3, Step 3d 없음 |
348
+ | `mode: "bypassPermissions"` | 3개 Agent 모두 포함 (필수) |
349
+ | tfx-route.sh 경유 | 3개 Agent 내부 Bash 모두 경유 (필수) |
350
+ | Phase 2.5–2.6 (Plan/PRD) | 건너뜀 (`--quick` 모드) |
351
+ | Phase 3.5–3.7 (Verify/Fix) | 건너뜀 (`--quick` 모드) |
352
+ | Phase 5 (TeamDelete) | 반드시 실행 (성공/실패 무관) |
@@ -0,0 +1,5 @@
1
+ {
2
+ "total_tokens": 27197,
3
+ "duration_ms": 115292,
4
+ "total_duration_seconds": 115.3
5
+ }