triflux 7.1.4 → 7.2.2

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 (73) hide show
  1. package/.claude-plugin/marketplace.json +31 -31
  2. package/.claude-plugin/plugin.json +22 -23
  3. package/bin/triflux.mjs +18 -5
  4. package/hooks/keyword-rules.json +393 -361
  5. package/hub/bridge.mjs +799 -786
  6. package/hub/delegator/contracts.mjs +37 -38
  7. package/hub/delegator/schema/delegator-tools.schema.json +250 -250
  8. package/hub/delegator/service.mjs +307 -302
  9. package/hub/intent.mjs +108 -11
  10. package/hub/lib/process-utils.mjs +20 -0
  11. package/hub/pipe.mjs +589 -589
  12. package/hub/pipeline/gates/confidence.mjs +1 -1
  13. package/hub/pipeline/gates/selfcheck.mjs +2 -4
  14. package/hub/pipeline/state.mjs +191 -187
  15. package/hub/pipeline/transitions.mjs +124 -120
  16. package/hub/public/dashboard.html +355 -349
  17. package/hub/quality/deslop.mjs +5 -3
  18. package/hub/reflexion.mjs +5 -1
  19. package/hub/research.mjs +6 -1
  20. package/hub/router.mjs +791 -782
  21. package/hub/server.mjs +893 -822
  22. package/hub/store.mjs +807 -778
  23. package/hub/team/agent-map.json +10 -0
  24. package/hub/team/ansi.mjs +3 -4
  25. package/hub/team/cli/commands/control.mjs +43 -43
  26. package/hub/team/cli/commands/interrupt.mjs +36 -36
  27. package/hub/team/cli/commands/kill.mjs +3 -3
  28. package/hub/team/cli/commands/send.mjs +37 -37
  29. package/hub/team/cli/commands/start/index.mjs +18 -8
  30. package/hub/team/cli/commands/start/parse-args.mjs +3 -1
  31. package/hub/team/cli/commands/start/start-headless.mjs +4 -1
  32. package/hub/team/cli/commands/status.mjs +87 -87
  33. package/hub/team/cli/commands/stop.mjs +1 -1
  34. package/hub/team/cli/commands/task.mjs +1 -1
  35. package/hub/team/cli/index.mjs +41 -39
  36. package/hub/team/cli/manifest.mjs +29 -28
  37. package/hub/team/cli/services/hub-client.mjs +37 -0
  38. package/hub/team/cli/services/state-store.mjs +26 -12
  39. package/hub/team/dashboard.mjs +11 -4
  40. package/hub/team/handoff.mjs +12 -0
  41. package/hub/team/headless.mjs +202 -200
  42. package/hub/team/native-supervisor.mjs +386 -346
  43. package/hub/team/nativeProxy.mjs +680 -692
  44. package/hub/team/staleState.mjs +361 -369
  45. package/hub/team/tui-viewer.mjs +27 -3
  46. package/hub/team/tui.mjs +1 -0
  47. package/hub/token-mode.mjs +114 -24
  48. package/hub/workers/delegator-mcp.mjs +1059 -1057
  49. package/hud/colors.mjs +88 -0
  50. package/hud/constants.mjs +78 -0
  51. package/hud/hud-qos-status.mjs +206 -1872
  52. package/hud/providers/claude.mjs +309 -0
  53. package/hud/providers/codex.mjs +151 -0
  54. package/hud/providers/gemini.mjs +320 -0
  55. package/hud/renderers.mjs +424 -0
  56. package/hud/terminal.mjs +140 -0
  57. package/hud/utils.mjs +271 -0
  58. package/package.json +1 -2
  59. package/scripts/__tests__/keyword-detector.test.mjs +234 -234
  60. package/scripts/headless-guard-fast.sh +21 -0
  61. package/scripts/headless-guard.mjs +26 -6
  62. package/scripts/lib/keyword-rules.mjs +166 -168
  63. package/scripts/setup.mjs +725 -690
  64. package/scripts/tfx-route-post.mjs +424 -424
  65. package/scripts/tfx-route.sh +1671 -1650
  66. package/scripts/tmp-cleanup.mjs +74 -0
  67. package/skills/tfx-auto/SKILL.md +279 -278
  68. package/skills/tfx-auto-codex/SKILL.md +98 -77
  69. package/skills/tfx-codex/SKILL.md +65 -65
  70. package/skills/tfx-gemini/SKILL.md +83 -82
  71. package/skills/tfx-hub/SKILL.md +205 -136
  72. package/skills/tfx-multi/SKILL.md +11 -5
  73. package/.mcp.json +0 -8
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * tmp-cleanup.mjs — triflux 임시 파일 자동 정리
4
+ * 7일 이상 된 파일을 삭제한다.
5
+ * SessionStart 훅 또는 독립 실행으로 사용.
6
+ */
7
+ import { existsSync, readdirSync, statSync, rmSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { tmpdir } from "node:os";
10
+
11
+ const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7일
12
+
13
+ // tfx-psmux-check.json은 guard가 TTL을 직접 관리하므로 제외
14
+ const SKIP_FILES = new Set(["tfx-psmux-check.json"]);
15
+
16
+ /**
17
+ * 7일 이상 된 임시 파일/디렉터리를 정리한다.
18
+ * @returns {number} 삭제된 항목 수
19
+ */
20
+ export async function cleanupTmpFiles() {
21
+ const now = Date.now();
22
+ let cleaned = 0;
23
+ const tmp = tmpdir();
24
+
25
+ // 1) tmpdir() 직하위의 tfx-* 패턴 항목 정리
26
+ let topEntries;
27
+ try { topEntries = readdirSync(tmp); } catch { topEntries = []; }
28
+
29
+ for (const entry of topEntries) {
30
+ if (!entry.startsWith("tfx-")) continue;
31
+ if (SKIP_FILES.has(entry)) continue;
32
+
33
+ const full = join(tmp, entry);
34
+ try {
35
+ const stat = statSync(full);
36
+ if (now - stat.mtimeMs > MAX_AGE_MS) {
37
+ rmSync(full, { recursive: true, force: true });
38
+ cleaned++;
39
+ }
40
+ } catch { /* 권한 에러 등 무시 */ }
41
+ }
42
+
43
+ // 2) tfx-headless/ 내 오래된 결과 파일 정리 (디렉터리 자체는 유지)
44
+ const headlessDir = join(tmp, "tfx-headless");
45
+ if (existsSync(headlessDir)) {
46
+ let entries;
47
+ try { entries = readdirSync(headlessDir); } catch { entries = []; }
48
+
49
+ for (const entry of entries) {
50
+ if (SKIP_FILES.has(entry)) continue;
51
+ const full = join(headlessDir, entry);
52
+ try {
53
+ const stat = statSync(full);
54
+ if (now - stat.mtimeMs > MAX_AGE_MS) {
55
+ rmSync(full, { recursive: true, force: true });
56
+ cleaned++;
57
+ }
58
+ } catch { /* 권한 에러 등 무시 */ }
59
+ }
60
+ }
61
+
62
+ return cleaned;
63
+ }
64
+
65
+ // 독립 실행 시 결과를 stdout으로 출력 (SessionStart 훅 호환)
66
+ if (process.argv[1]) {
67
+ const { fileURLToPath } = await import("node:url");
68
+ if (fileURLToPath(import.meta.url) === process.argv[1]) {
69
+ const cleaned = await cleanupTmpFiles();
70
+ if (cleaned > 0) {
71
+ process.stdout.write(JSON.stringify({ message: `tfx-cleanup: ${cleaned} files removed` }));
72
+ }
73
+ }
74
+ }
@@ -1,278 +1,279 @@
1
- ---
2
- name: tfx-auto
3
- description: 통합 CLI 오케스트레이터. 커맨드 숏컷(단일) + 자동 분류/분해(병렬) + 수동 병렬. tfx-route.sh 기반.
4
- triggers:
5
- - tfx-auto
6
- - implement
7
- - build
8
- - research
9
- - brainstorm
10
- - design
11
- - test
12
- - analyze
13
- - troubleshoot
14
- - improve
15
- - cleanup
16
- - explain
17
- - document
18
- - pm
19
- - reflect
20
- - estimate
21
- - spec-panel
22
- - business-panel
23
- - index-repo
24
- argument-hint: "<command|task> [args...]"
25
- ---
26
-
27
- # tfx-auto — 통합 CLI 오케스트레이터
28
-
29
- > **MANDATORY RULES**
30
- >
31
- > 1. **실행**: CLI 에이전트는 반드시 `Bash("bash ~/.claude/scripts/tfx-route.sh ...")`. Claude 네이티브(explore/verifier/test-engineer/qa-tester)만 `Agent()`.
32
- > 2. **비용**: Codex 우선 → Gemini → Claude 최후 수단. `claude` 선택 전 "Codex로 가능한가?" 재확인.
33
- > 3. **DAG**: SEQUENTIAL/DAG이면 레벨 기반 순차 실행. `.omc/context/{sid}/` 생성, context_output 저장, 실패 시 후속 SKIP.
34
- > 4. **트리아지**: Codex `--full-auto` 분류 + Opus 인라인 분해. Agent 스폰 금지.
35
- > 5. **thorough**: `-t`/`--thorough` 시 파이프라인 init 필수. 커맨드 숏컷은 항상 quick.
36
-
37
- ## 모드
38
-
39
- | 입력 형식 | 모드 | 트리아지 |
40
- |-----------|------|----------|
41
- | `/implement JWT 추가` | 커맨드 숏컷 (quick) | 없음 (즉시 실행) |
42
- | `/tfx-auto "리팩터링 + UI"` | 자동 (quick) | Codex 분류 → Opus 분해 |
43
- | `/tfx-auto -t "리팩터링 + UI"` | 자동 (thorough) | Codex 분류 → Opus 분해 → Pipeline |
44
- | `/tfx-auto --thorough "리팩터링"` | 자동 (thorough) | `-t` 동일 |
45
- | `/tfx-auto 3:codex "리뷰"` | 수동 (quick) | Opus 분해만 |
46
-
47
- > **tfx-auto는 `--quick`이 기본.** 커맨드 숏컷·단일 실행에서 plan/verify 오버헤드가 불필요하기 때문.
48
- > 멀티 태스크 시 tfx-multi로 전환되면 tfx-multi의 기본값(`--thorough`)이 적용된다.
49
-
50
- ## 커맨드 숏컷
51
-
52
- 커맨드명 매칭 시 트리아지 없이 즉시 실행. 패턴: `Bash("bash ~/.claude/scripts/tfx-route.sh {에이전트} '{PROMPT}' {MCP}")`.
53
-
54
- ### Codex 직행
55
-
56
- | 커맨드 | 에이전트 | MCP |
57
- |--------|---------|-----|
58
- | `implement` | executor | implement |
59
- | `build` | build-fixer | implement |
60
- | `research` | document-specialist | analyze |
61
- | `brainstorm` | analyst | analyze |
62
- | `design` | architect | analyze |
63
- | `troubleshoot` | debugger | implement |
64
- | `cleanup` | executor | implement |
65
- | `pm` | planner | analyze |
66
-
67
- ### 2단계: `improve`
68
-
69
- 1단계 `code-reviewer '{PROMPT}' review` → 사용자 승인 → 2단계 `executor '리뷰 반영: {요약}' implement`
70
-
71
- ### 병렬
72
-
73
- | 커맨드 | 에이전트들 (병렬, run_in_background=true) | MCP |
74
- |--------|------------------------------------------|-----|
75
- | `analyze` | quality-reviewer + security-reviewer | review |
76
- | `spec-panel` | architect + analyst + critic | analyze |
77
- | `business-panel` | analyst + architect | analyze |
78
-
79
- ### Gemini 직행
80
-
81
- | 커맨드 | 에이전트 | MCP |
82
- |--------|---------|-----|
83
- | `explain` | writer | docs |
84
- | `document` | writer | docs |
85
-
86
- ### Claude 네이티브
87
-
88
- | 커맨드 | 실행 |
89
- |--------|------|
90
- | `test` | `Agent(subagent_type="oh-my-claudecode:test-engineer", model="sonnet")` |
91
- | `reflect` | `Agent(subagent_type="oh-my-claudecode:verifier", model="sonnet")` |
92
-
93
- ### 복합
94
-
95
- | 커맨드 | 흐름 |
96
- |--------|------|
97
- | `estimate` | explore(haiku) → analyst(codex): 영향범위, 복잡도(S/M/L/XL), 리스크 |
98
- | `index-repo` | explore(haiku) × 2 → Write(PROJECT_INDEX.md). mode=quick/update/full |
99
-
100
- ## 트리아지
101
-
102
- **자동 모드:**
103
- 1. Codex 분류: `codex exec --full-auto --skip-git-repo-check` → JSON `{parts: [{description, agent: "codex|gemini|claude"}]}`
104
- 2. Opus 인라인 분해: `{graph_type: "INDEPENDENT|SEQUENTIAL|DAG", subtasks: [{id, description, scope, agent, mcp_profile, depends_on, context_output, context_input}]}`
105
- 3. 실패 시 Opus가 직접 분류+분해
106
-
107
- **수동 모드 (`N:agent_type`):** Codex 분류 건너뜀 → Opus가 N개 서브태스크 분해. N > 10 거부.
108
-
109
- ## --thorough 모드
110
-
111
- `-t` 또는 `--thorough` 플래그 시 파이프라인 기반 실행. 커맨드 숏컷에서는 무시된다.
112
-
113
- ```
114
- 분기점은 "실행 전략"이지 "계획"이 아님:
115
-
116
- TRIAGE
117
-
118
- ├─ [thorough] → PIPELINE INIT(plan) → PLAN → PRD → [APPROVAL]
119
- │ │
120
- │ ┌───────────────┤
121
- │ │ │
122
- │ [1 task] [2+ tasks]
123
- │ │ │
124
- │ AUTO 직접 실행 TEAM EXEC (multi Phase 3)
125
- │ │ │
126
- │ └───────┬───────┘
127
- │ │
128
- │ VERIFY → FIX loop → COMPLETE
129
-
130
- └─ [quick] → [1 task] → fire-and-forget
131
- [2+ tasks] → TEAM EXEC → COLLECT → CLEANUP
132
- ```
133
-
134
- ### 단일 태스크 thorough
135
-
136
- 1. `Bash("node hub/bridge.mjs pipeline-init --team ${sid}")` — 파이프라인 초기화 (phase: plan)
137
- 2. Plan: Codex architect → 결과를 `pipeline.writePlanFile()` 저장
138
- 3. PRD: Codex analyst → acceptance criteria 확정
139
- 4. `pipeline_advance_gated` → [Approval Gate] → 사용자 승인 대기
140
- 5. Exec: tfx-auto 직접 실행 (아래 "실행" 섹션)
141
- 6. Verify: Codex verifier → 검증
142
- 7. 실패 시 Fix loop (최대 3회) → Exec 재실행
143
- 8. Complete
144
-
145
- ### 멀티 태스크 thorough
146
-
147
- Plan/PRD/Approval은 tfx-auto에서 실행, 그 후 tfx-multi Phase 3로 전환.
148
- 서브태스크 배열 + `thorough: true` 신호를 함께 전달하여 multi 측에서 verify/fix를 수행.
149
-
150
- ## 멀티 태스크 라우팅 (트리아지 후)
151
-
152
- > **트리아지 결과에 따라 실행 경로 결정.**
153
- > v6.0.0부터 CLI 워커는 **Lead-Direct Headless** (psmux)가 기본. Agent 래퍼 불필요.
154
-
155
- | 조건 | 실행 경로 | 엔진 |
156
- |------|----------|------|
157
- | 1개 + quick | tfx-auto 직접 실행 (fire-and-forget) | tfx-route.sh |
158
- | 1개 + thorough | tfx-auto 직접 실행 + verify/fix loop | tfx-route.sh |
159
- | 2개+ + quick | **headless 직접 실행** (WT 자동 팝업) | headless.mjs |
160
- | 2개+ + thorough | Plan/PRD/Approval 후 → headless + verify/fix | headless.mjs |
161
- | psmux 미설치 fallback | Native Teams (Agent slim wrapper) | native.mjs |
162
-
163
- > **MANDATORY: 2개+ 서브태스크 시 headless 엔진 필수**
164
- > `Agent()` 백그라운드나 `Bash(tfx-route.sh)` 개별 호출로 대체 금지.
165
- > 반드시 아래 `Bash("tfx multi ...")` 명령으로 headless 엔진에 위임한다.
166
-
167
- **전환 방법:**
168
-
169
- ```
170
- thorough = args에 -t 또는 --thorough 포함
171
-
172
- if subtasks.length >= 2:
173
- if psmux 설치됨:
174
- → Bash("tfx multi --teammate-mode headless --auto-attach --assign 'cli:prompt:role' ...")
175
- → if thorough: verify → fix loop
176
- else:
177
- → fallback: tfx-multi Phase 3 Native Teams (Agent slim wrapper)
178
- else:
179
- if thorough:
180
- → Pipeline init → Plan → PRD → Approval → 직접 실행 → Verify → Fix loop
181
- else:
182
- → tfx-auto 직접 실행 (아래)
183
- ```
184
-
185
- ## 실행
186
-
187
- ### CLI 에이전트 (Codex/Gemini)
188
-
189
- ```bash
190
- # Level 0 / INDEPENDENT
191
- Bash("bash ~/.claude/scripts/tfx-route.sh {agent} '{prompt}' {mcp_profile}", run_in_background=true)
192
-
193
- # Level 1+ (컨텍스트 의존) — 4번째=timeout(빈값), 5번째=context_file
194
- Bash("bash ~/.claude/scripts/tfx-route.sh {agent} '{prompt}' {mcp_profile} '' .omc/context/{sid}/combined-{tid}.md", run_in_background=true)
195
- ```
196
-
197
- ### Claude 네이티브
198
-
199
- ```
200
- Agent(subagent_type="oh-my-claudecode:{agent}", model="{model}", prompt="{prompt}", run_in_background=true)
201
- # 컨텍스트 있으면 prompt에 <prior_context>...</prior_context> 추가
202
- ```
203
-
204
- ### 에이전트 매핑
205
-
206
- | 입력 | CLI | MCP |
207
- |------|-----|-----|
208
- | codex / executor / debugger / deep-executor | Codex | implement |
209
- | architect / planner / critic / analyst | Codex (xhigh) | analyze |
210
- | scientist / document-specialist | Codex | analyze |
211
- | code-reviewer / security-reviewer / quality-reviewer | Codex (review) | review |
212
- | gemini / designer / writer | Gemini | docs |
213
- | claude / explore / verifier / test-engineer / qa-tester | Claude native | — |
214
-
215
- ### MCP 프로필 자동 결정
216
-
217
- | 에이전트 | MCP |
218
- |----------|-----|
219
- | executor, build-fixer, debugger, deep-executor | implement |
220
- | architect, planner, critic, analyst, scientist, document-specialist | analyze |
221
- | code-reviewer, security-reviewer, quality-reviewer | review |
222
- | designer, writer | docs |
223
-
224
- ### 결과 파싱
225
-
226
- 여기서 `failed`는 `tfx-route.sh`/CLI 종료 결과를 뜻한다. Claude Code `TaskUpdate` 상태값이 아니다.
227
-
228
- | exit_code + status | 사용할 출력 |
229
- |--------------------|-----------|
230
- | 0 + success | `=== OUTPUT ===` 섹션 |
231
- | 124 + timeout | `=== PARTIAL OUTPUT ===` |
232
- | ≠0 + failed | STDERR Claude fallback |
233
-
234
- OUTPUT 추출: `echo "$result" | sed -n '/^=== OUTPUT ===/,/^=== /{/^=== OUTPUT ===/d;/^=== /d;p}'`
235
-
236
- ### 실패 처리
237
-
238
- 1차 → `Agent(subagent_type="oh-my-claudecode:executor", model="sonnet")` fallback.
239
- 2연속 실패 실패 보고 + 성공 결과만 종합.
240
-
241
- ### 보고 형식
242
-
243
- ```markdown
244
- ## tfx-auto 완료
245
- **모드**: {auto|manual} | **그래프**: {type} | **레벨**: {N}
246
- | # | 서브태스크 | Agent | CLI | MCP | 레벨 | 상태 | 시간 |
247
- ### 워커 {n}: {제목}
248
- (출력 요약)
249
- ### Token Savings Report
250
- (node ~/.claude/scripts/token-snapshot.mjs report {session-id})
251
- ```
252
-
253
- ## 필수 조건
254
-
255
- - `~/.claude/scripts/tfx-route.sh` (필수)
256
- - codex: `npm install -g @openai/codex` | gemini: `npm install -g @google/gemini-cli`
257
-
258
- ## 에러 레퍼런스
259
-
260
- | 에러 | 처리 |
261
- |------|------|
262
- | `tfx-route.sh: not found` | tfx-route.sh 생성 |
263
- | `codex/gemini: not found` | npm install -g |
264
- | timeout / failed (`tfx-route.sh` 결과) | stderr Claude fallback |
265
- | N > 10 | 10 이하로 조정 |
266
- | 순환 의존 | 분해 재시도 |
267
- | 컨텍스트 > 32KB | 비례 절삭 |
268
-
269
- > Claude Code `TaskUpdate`를 사용할 때는 `status: "failed"`를 쓰지 않는다.
270
- > 실패 보고는 `status: "completed"` + `metadata.result: "failed"`로 표현한다.
271
-
272
- ## Troubleshooting
273
-
274
- `/tfx-doctor` 진단 | `/tfx-doctor --fix` 자동 수정 | `/tfx-doctor --reset` 캐시 초기화
275
-
276
- ## 상세 레퍼런스
277
-
278
- DAG 알고리즘, 컨텍스트 머지 규칙, 토큰 스냅샷, 보고서 상세는 `scripts/tfx-route.sh` 내부 주석 및 `hub/` 모듈 참조.
1
+ ---
2
+ name: tfx-auto
3
+ description: 통합 CLI 오케스트레이터. 커맨드 숏컷(단일) + 자동 분류/분해(병렬) + 수동 병렬. tfx-route.sh 기반.
4
+ triggers:
5
+ - tfx-auto
6
+ - implement
7
+ - build
8
+ - research
9
+ - brainstorm
10
+ - design
11
+ - test
12
+ - analyze
13
+ - troubleshoot
14
+ - improve
15
+ - cleanup
16
+ - explain
17
+ - document
18
+ - pm
19
+ - reflect
20
+ - estimate
21
+ - spec-panel
22
+ - business-panel
23
+ - index-repo
24
+ argument-hint: "<command|task> [args...]"
25
+ ---
26
+
27
+ # tfx-auto — 통합 CLI 오케스트레이터
28
+
29
+ > **MANDATORY RULES**
30
+ >
31
+ > 1. **실행**: CLI 에이전트는 반드시 `Bash("bash ~/.claude/scripts/tfx-route.sh ...")`. Claude 네이티브(explore/verifier/test-engineer/qa-tester)만 `Agent()`.
32
+ > 2. **비용**: Codex 우선 → Gemini → Claude 최후 수단. `claude` 선택 전 "Codex로 가능한가?" 재확인.
33
+ > 3. **DAG**: SEQUENTIAL/DAG이면 레벨 기반 순차 실행. `.omc/context/{sid}/` 생성, context_output 저장, 실패 시 후속 SKIP.
34
+ > 4. **트리아지**: Codex `--full-auto` 분류 + Opus 인라인 분해. Agent 스폰 금지.
35
+ > 5. **thorough**: `-t`/`--thorough` 시 파이프라인 init 필수. 커맨드 숏컷은 항상 quick.
36
+
37
+ ## 모드
38
+
39
+ | 입력 형식 | 모드 | 트리아지 |
40
+ |-----------|------|----------|
41
+ | `/implement JWT 추가` | 커맨드 숏컷 (quick) | 없음 (즉시 실행) |
42
+ | `/tfx-auto "리팩터링 + UI"` | 자동 (quick) | Codex 분류 → Opus 분해 |
43
+ | `/tfx-auto -t "리팩터링 + UI"` | 자동 (thorough) | Codex 분류 → Opus 분해 → Pipeline |
44
+ | `/tfx-auto --thorough "리팩터링"` | 자동 (thorough) | `-t` 동일 |
45
+ | `/tfx-auto 3:codex "리뷰"` | 수동 (quick) | Opus 분해만 |
46
+
47
+ > **tfx-auto는 `--quick`이 기본.** 커맨드 숏컷·단일 실행에서 plan/verify 오버헤드가 불필요하기 때문.
48
+ > 멀티 태스크 시 tfx-multi로 전환되면 tfx-multi의 기본값(`--thorough`)이 적용된다.
49
+
50
+ ## 커맨드 숏컷
51
+
52
+ 커맨드명 매칭 시 트리아지 없이 즉시 실행. 패턴: `Bash("bash ~/.claude/scripts/tfx-route.sh {에이전트} '{PROMPT}' {MCP}")`.
53
+
54
+ ### Codex 직행
55
+
56
+ | 커맨드 | 에이전트 | MCP |
57
+ |--------|---------|-----|
58
+ | `implement` | executor | implement |
59
+ | `build` | build-fixer | implement |
60
+ | `research` | document-specialist | analyze |
61
+ | `brainstorm` | analyst | analyze |
62
+ | `design` | architect | analyze |
63
+ | `troubleshoot` | debugger | implement |
64
+ | `cleanup` | executor | implement |
65
+ | `pm` | planner | analyze |
66
+
67
+ ### 2단계: `improve`
68
+
69
+ 1단계 `code-reviewer '{PROMPT}' review` → 사용자 승인 → 2단계 `executor '리뷰 반영: {요약}' implement`
70
+
71
+ ### 병렬
72
+
73
+ | 커맨드 | 에이전트들 (병렬, run_in_background=true) | MCP |
74
+ |--------|------------------------------------------|-----|
75
+ | `analyze` | quality-reviewer + security-reviewer | review |
76
+ | `spec-panel` | architect + analyst + critic | analyze |
77
+ | `business-panel` | analyst + architect | analyze |
78
+
79
+ ### Gemini 직행
80
+
81
+ | 커맨드 | 에이전트 | MCP |
82
+ |--------|---------|-----|
83
+ | `explain` | writer | docs |
84
+ | `document` | writer | docs |
85
+
86
+ ### Claude 네이티브
87
+
88
+ | 커맨드 | 실행 |
89
+ |--------|------|
90
+ | `test` | `Agent(subagent_type="oh-my-claudecode:test-engineer", model="sonnet")` |
91
+ | `reflect` | `Bash(tfx-route.sh verifier '{PROMPT}' review)` (기본) / `Agent(subagent_type="oh-my-claudecode:verifier", model="sonnet")` (TFX_VERIFIER_OVERRIDE=claude 시) |
92
+
93
+ ### 복합
94
+
95
+ | 커맨드 | 흐름 |
96
+ |--------|------|
97
+ | `estimate` | explore(haiku) → analyst(codex): 영향범위, 복잡도(S/M/L/XL), 리스크 |
98
+ | `index-repo` | explore(haiku) × 2 → Write(PROJECT_INDEX.md). mode=quick/update/full |
99
+
100
+ ## 트리아지
101
+
102
+ **자동 모드:**
103
+ 1. Codex 분류: `codex exec --full-auto --skip-git-repo-check` → JSON `{parts: [{description, agent: "codex|gemini|claude"}]}`
104
+ 2. Opus 인라인 분해: `{graph_type: "INDEPENDENT|SEQUENTIAL|DAG", subtasks: [{id, description, scope, agent, mcp_profile, depends_on, context_output, context_input}]}`
105
+ 3. 실패 시 Opus가 직접 분류+분해
106
+
107
+ **수동 모드 (`N:agent_type`):** Codex 분류 건너뜀 → Opus가 N개 서브태스크 분해. N > 10 거부.
108
+
109
+ ## --thorough 모드
110
+
111
+ `-t` 또는 `--thorough` 플래그 시 파이프라인 기반 실행. 커맨드 숏컷에서는 무시된다.
112
+
113
+ ```
114
+ 분기점은 "실행 전략"이지 "계획"이 아님:
115
+
116
+ TRIAGE
117
+
118
+ ├─ [thorough] → PIPELINE INIT(plan) → PLAN → PRD → [APPROVAL]
119
+ │ │
120
+ │ ┌───────────────┤
121
+ │ │ │
122
+ │ [1 task] [2+ tasks]
123
+ │ │ │
124
+ │ AUTO 직접 실행 TEAM EXEC (multi Phase 3)
125
+ │ │ │
126
+ │ └───────┬───────┘
127
+ │ │
128
+ │ VERIFY → FIX loop → COMPLETE
129
+
130
+ └─ [quick] → [1 task] → fire-and-forget
131
+ [2+ tasks] → TEAM EXEC → COLLECT → CLEANUP
132
+ ```
133
+
134
+ ### 단일 태스크 thorough
135
+
136
+ 1. `Bash("node hub/bridge.mjs pipeline-init --team ${sid}")` — 파이프라인 초기화 (phase: plan)
137
+ 2. Plan: Codex architect → 결과를 `pipeline.writePlanFile()` 저장
138
+ 3. PRD: Codex analyst → acceptance criteria 확정
139
+ 4. `pipeline_advance_gated` → [Approval Gate] → 사용자 승인 대기
140
+ 5. Exec: tfx-auto 직접 실행 (아래 "실행" 섹션)
141
+ 6. Verify: Codex verifier → 검증
142
+ 7. 실패 시 Fix loop (최대 3회) → Exec 재실행
143
+ 8. Complete
144
+
145
+ ### 멀티 태스크 thorough
146
+
147
+ Plan/PRD/Approval은 tfx-auto에서 실행, 그 후 tfx-multi Phase 3로 전환.
148
+ 서브태스크 배열 + `thorough: true` 신호를 함께 전달하여 multi 측에서 verify/fix를 수행.
149
+
150
+ ## 멀티 태스크 라우팅 (트리아지 후)
151
+
152
+ > **트리아지 결과에 따라 실행 경로 결정.**
153
+ > v6.0.0부터 CLI 워커는 **Lead-Direct Headless** (psmux)가 기본. Agent 래퍼 불필요.
154
+
155
+ | 조건 | 실행 경로 | 엔진 |
156
+ |------|----------|------|
157
+ | 1개 + quick | tfx-auto 직접 실행 (fire-and-forget) | tfx-route.sh |
158
+ | 1개 + thorough | tfx-auto 직접 실행 + verify/fix loop | tfx-route.sh |
159
+ | 2개+ + quick | **headless 직접 실행** (WT 자동 팝업) | headless.mjs |
160
+ | 2개+ + thorough | Plan/PRD/Approval 후 → headless + verify/fix | headless.mjs |
161
+ | psmux 미설치 fallback | Native Teams (Agent slim wrapper) | native.mjs |
162
+
163
+ > **MANDATORY: 2개+ 서브태스크 시 headless 엔진 필수**
164
+ > `Agent()` 백그라운드나 `Bash(tfx-route.sh)` 개별 호출로 대체 금지.
165
+ > 반드시 아래 `Bash("tfx multi ...")` 명령으로 headless 엔진에 위임한다.
166
+
167
+ **전환 방법:**
168
+
169
+ ```
170
+ thorough = args에 -t 또는 --thorough 포함
171
+
172
+ if subtasks.length >= 2:
173
+ if psmux 설치됨:
174
+ → Bash("tfx multi --teammate-mode headless --auto-attach --dashboard --assign 'cli:prompt:role' ...")
175
+ → if thorough: verify → fix loop
176
+ else:
177
+ → fallback: tfx-multi Phase 3 Native Teams (Agent slim wrapper)
178
+ else:
179
+ if thorough:
180
+ → Pipeline init → Plan → PRD → Approval → 직접 실행 → Verify → Fix loop
181
+ else:
182
+ → tfx-auto 직접 실행 (아래)
183
+ ```
184
+
185
+ ## 실행
186
+
187
+ ### CLI 에이전트 (Codex/Gemini)
188
+
189
+ ```bash
190
+ # Level 0 / INDEPENDENT
191
+ Bash("bash ~/.claude/scripts/tfx-route.sh {agent} '{prompt}' {mcp_profile}", run_in_background=true)
192
+
193
+ # Level 1+ (컨텍스트 의존) — 4번째=timeout(빈값), 5번째=context_file
194
+ Bash("bash ~/.claude/scripts/tfx-route.sh {agent} '{prompt}' {mcp_profile} '' .omc/context/{sid}/combined-{tid}.md", run_in_background=true)
195
+ ```
196
+
197
+ ### Claude 네이티브
198
+
199
+ ```
200
+ Agent(subagent_type="oh-my-claudecode:{agent}", model="{model}", prompt="{prompt}", run_in_background=true)
201
+ # 컨텍스트 있으면 prompt에 <prior_context>...</prior_context> 추가
202
+ ```
203
+
204
+ ### 에이전트 매핑
205
+
206
+ | 입력 | CLI | MCP |
207
+ |------|-----|-----|
208
+ | codex / executor / build-fixer / spark / debugger / deep-executor | Codex | implement |
209
+ | architect / planner / critic / analyst | Codex (xhigh) | analyze |
210
+ | scientist / document-specialist | Codex | analyze |
211
+ | code-reviewer / security-reviewer / quality-reviewer | Codex (review) | review |
212
+ | gemini / designer / writer | Gemini | docs |
213
+ | explore / test-engineer / qa-tester | Claude native | — |
214
+ | verifier | Codex review (기본) / Claude native (TFX_VERIFIER_OVERRIDE=claude 시) | review / — |
215
+
216
+ ### MCP 프로필 자동 결정
217
+
218
+ | 에이전트 | MCP |
219
+ |----------|-----|
220
+ | executor, build-fixer, spark, debugger, deep-executor | implement |
221
+ | architect, planner, critic, analyst, scientist, document-specialist | analyze |
222
+ | code-reviewer, security-reviewer, quality-reviewer | review |
223
+ | designer, writer | docs |
224
+
225
+ ### 결과 파싱
226
+
227
+ 여기서 `failed`는 `tfx-route.sh`/CLI 종료 결과를 뜻한다. Claude Code `TaskUpdate` 상태값이 아니다.
228
+
229
+ | exit_code + status | 사용할 출력 |
230
+ |--------------------|-----------|
231
+ | 0 + success | `=== OUTPUT ===` 섹션 |
232
+ | 124 + timeout | `=== PARTIAL OUTPUT ===` |
233
+ | ≠0 + failed | STDERR → Claude fallback |
234
+
235
+ OUTPUT 추출: `echo "$result" | sed -n '/^=== OUTPUT ===/,/^=== /{/^=== OUTPUT ===/d;/^=== /d;p}'`
236
+
237
+ ### 실패 처리
238
+
239
+ 1차 → `Agent(subagent_type="oh-my-claudecode:executor", model="sonnet")` fallback.
240
+ 2차 연속 실패 → 실패 보고 + 성공 결과만 종합.
241
+
242
+ ### 보고 형식
243
+
244
+ ```markdown
245
+ ## tfx-auto 완료
246
+ **모드**: {auto|manual} | **그래프**: {type} | **레벨**: {N}
247
+ | # | 서브태스크 | Agent | CLI | MCP | 레벨 | 상태 | 시간 |
248
+ ### 워커 {n}: {제목}
249
+ (출력 요약)
250
+ ### Token Savings Report
251
+ (node ~/.claude/scripts/token-snapshot.mjs report {session-id})
252
+ ```
253
+
254
+ ## 필수 조건
255
+
256
+ - `~/.claude/scripts/tfx-route.sh` (필수)
257
+ - codex: `npm install -g @openai/codex` | gemini: `npm install -g @google/gemini-cli`
258
+
259
+ ## 에러 레퍼런스
260
+
261
+ | 에러 | 처리 |
262
+ |------|------|
263
+ | `tfx-route.sh: not found` | tfx-route.sh 생성 |
264
+ | `codex/gemini: not found` | npm install -g |
265
+ | timeout / failed (`tfx-route.sh` 결과) | stderr Claude fallback |
266
+ | N > 10 | 10 이하로 조정 |
267
+ | 순환 의존 | 분해 재시도 |
268
+ | 컨텍스트 > 32KB | 비례 절삭 |
269
+
270
+ > Claude Code `TaskUpdate`를 사용할 때는 `status: "failed"`를 쓰지 않는다.
271
+ > 실패 보고는 `status: "completed"` + `metadata.result: "failed"`로 표현한다.
272
+
273
+ ## Troubleshooting
274
+
275
+ `/tfx-doctor` 진단 | `/tfx-doctor --fix` 자동 수정 | `/tfx-doctor --reset` 캐시 초기화
276
+
277
+ ## 상세 레퍼런스
278
+
279
+ DAG 알고리즘, 컨텍스트 머지 규칙, 토큰 스냅샷, 보고서 상세는 `scripts/tfx-route.sh` 내부 주석 및 `hub/` 모듈 참조.