triflux 6.0.2 → 6.0.4

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.
@@ -128,7 +128,9 @@ export async function runHeadless(sessionName, assignments, opts = {}) {
128
128
  } else {
129
129
  // ─── 기존 모드: 모든 pane을 한 번에 생성 ───
130
130
  const paneCount = assignments.length + 1;
131
- const session = createPsmuxSession(sessionName, { layout, paneCount });
131
+ // A2b fix: 2x2 레이아웃은 최대 4 pane — 초과 시 tiled로 자동 전환
132
+ const effectiveLayout = (layout === "2x2" && paneCount > 4) ? "tiled" : layout;
133
+ const session = createPsmuxSession(sessionName, { layout: effectiveLayout, paneCount });
132
134
  applyTrifluxTheme(sessionName);
133
135
  if (safeProgress) safeProgress({ type: "session_created", sessionName, panes: session.panes });
134
136
 
package/package.json CHANGED
@@ -1,66 +1,66 @@
1
- {
2
- "name": "triflux",
3
- "version": "6.0.2",
4
- "description": "CLI-first multi-model orchestrator for Claude Code — route tasks to Codex, Gemini, and Claude",
5
- "type": "module",
6
- "bin": {
7
- "triflux": "bin/triflux.mjs",
8
- "tfx": "bin/triflux.mjs",
9
- "tfl": "bin/triflux.mjs",
10
- "tfx-setup": "bin/tfx-setup.mjs",
11
- "tfx-doctor": "bin/tfx-doctor.mjs"
12
- },
13
- "files": [
14
- "bin",
15
- "hub",
16
- "skills",
17
- "!skills/tfx-workspace",
18
- "!**/failure-reports",
19
- "scripts",
20
- "hooks",
21
- "hud",
22
- ".claude-plugin",
23
- ".mcp.json",
24
- "README.md",
25
- "README.ko.md",
26
- "LICENSE"
27
- ],
28
- "scripts": {
29
- "setup": "node scripts/setup.mjs",
30
- "preinstall": "node scripts/preinstall.mjs",
31
- "postinstall": "node scripts/setup.mjs",
32
- "test": "node --test --test-force-exit --test-concurrency=1 \"tests/**/*.test.mjs\" \"scripts/__tests__/**/*.test.mjs\"",
33
- "test:unit": "node --test --test-force-exit --test-concurrency=1 tests/unit/**/*.test.mjs",
34
- "test:integration": "node --test --test-force-exit --test-concurrency=1 tests/integration/**/*.test.mjs",
35
- "test:route-smoke": "node --test scripts/test-tfx-route-no-claude-native.mjs"
36
- },
37
- "engines": {
38
- "node": ">=18.0.0"
39
- },
40
- "repository": {
41
- "type": "git",
42
- "url": "git+https://github.com/tellang/triflux.git"
43
- },
44
- "homepage": "https://github.com/tellang/triflux#readme",
45
- "author": "tellang",
46
- "license": "MIT",
47
- "dependencies": {
48
- "@modelcontextprotocol/sdk": "^1.27.1",
49
- "better-sqlite3": "^12.6.2",
50
- "pino": "^10.3.1",
51
- "pino-pretty": "^13.1.3",
52
- "systray2": "^2.1.4",
53
- "zod": "^4.0.0"
54
- },
55
- "keywords": [
56
- "claude-code",
57
- "plugin",
58
- "codex",
59
- "gemini",
60
- "cli-routing",
61
- "orchestration",
62
- "multi-model",
63
- "triflux",
64
- "tfx"
65
- ]
66
- }
1
+ {
2
+ "name": "triflux",
3
+ "version": "6.0.4",
4
+ "description": "CLI-first multi-model orchestrator for Claude Code — route tasks to Codex, Gemini, and Claude",
5
+ "type": "module",
6
+ "bin": {
7
+ "triflux": "bin/triflux.mjs",
8
+ "tfx": "bin/triflux.mjs",
9
+ "tfl": "bin/triflux.mjs",
10
+ "tfx-setup": "bin/tfx-setup.mjs",
11
+ "tfx-doctor": "bin/tfx-doctor.mjs"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "hub",
16
+ "skills",
17
+ "!skills/tfx-workspace",
18
+ "!**/failure-reports",
19
+ "scripts",
20
+ "hooks",
21
+ "hud",
22
+ ".claude-plugin",
23
+ ".mcp.json",
24
+ "README.md",
25
+ "README.ko.md",
26
+ "LICENSE"
27
+ ],
28
+ "scripts": {
29
+ "setup": "node scripts/setup.mjs",
30
+ "preinstall": "node scripts/preinstall.mjs",
31
+ "postinstall": "node scripts/setup.mjs",
32
+ "test": "node --test --test-force-exit --test-concurrency=1 \"tests/**/*.test.mjs\" \"scripts/__tests__/**/*.test.mjs\"",
33
+ "test:unit": "node --test --test-force-exit --test-concurrency=1 tests/unit/**/*.test.mjs",
34
+ "test:integration": "node --test --test-force-exit --test-concurrency=1 tests/integration/**/*.test.mjs",
35
+ "test:route-smoke": "node --test scripts/test-tfx-route-no-claude-native.mjs"
36
+ },
37
+ "engines": {
38
+ "node": ">=18.0.0"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/tellang/triflux.git"
43
+ },
44
+ "homepage": "https://github.com/tellang/triflux#readme",
45
+ "author": "tellang",
46
+ "license": "MIT",
47
+ "dependencies": {
48
+ "@modelcontextprotocol/sdk": "^1.27.1",
49
+ "better-sqlite3": "^12.6.2",
50
+ "pino": "^10.3.1",
51
+ "pino-pretty": "^13.1.3",
52
+ "systray2": "^2.1.4",
53
+ "zod": "^4.0.0"
54
+ },
55
+ "keywords": [
56
+ "claude-code",
57
+ "plugin",
58
+ "codex",
59
+ "gemini",
60
+ "cli-routing",
61
+ "orchestration",
62
+ "multi-model",
63
+ "triflux",
64
+ "tfx"
65
+ ]
66
+ }
@@ -36,6 +36,22 @@ function stopHub() {
36
36
 
37
37
  const pid = Number(info.pid);
38
38
 
39
+ // D4 fix: PID 소유자 검증 — node 프로세스인지 확인 (PID 재사용 보호)
40
+ if (process.platform === "win32") {
41
+ try {
42
+ const taskInfo = execFileSync("tasklist", ["/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"], {
43
+ encoding: "utf8", stdio: ["pipe", "pipe", "ignore"], timeout: 5000, windowsHide: true,
44
+ }).trim();
45
+ if (!taskInfo.toLowerCase().includes("node")) {
46
+ console.log(`[triflux preinstall] PID ${pid}은 node 프로세스가 아님 — kill 건너뜀`);
47
+ try { unlinkSync(HUB_PID_FILE); } catch {}
48
+ return;
49
+ }
50
+ } catch {
51
+ // tasklist 실패 — 안전하게 진행 (프로세스가 이미 죽었을 수 있음)
52
+ }
53
+ }
54
+
39
55
  // 1단계: 프로세스 종료 — Windows는 taskkill, Unix는 SIGTERM
40
56
  try {
41
57
  if (process.platform === "win32") {
@@ -150,28 +150,32 @@ Plan/PRD/Approval은 tfx-auto에서 실행, 그 후 tfx-multi Phase 3로 전환.
150
150
  ## 멀티 태스크 라우팅 (트리아지 후)
151
151
 
152
152
  > **트리아지 결과에 따라 실행 경로 결정.**
153
+ > v6.0.0부터 CLI 워커는 **Lead-Direct Headless** (psmux)가 기본. Agent 래퍼 불필요.
153
154
 
154
- | 조건 | 실행 경로 | 이유 |
155
+ | 조건 | 실행 경로 | 엔진 |
155
156
  |------|----------|------|
156
- | 1개 + quick | tfx-auto 직접 실행 (fire-and-forget) | 오버헤드 불필요 |
157
- | 1개 + thorough | tfx-auto 직접 실행 + verify/fix loop | plan→exec→verify 단일 경로 |
158
- | 2개+ + quick | tfx-multi Phase 3 (TeamCreate 직행) | Shift+Down, 상태 추적 |
159
- | 2개+ + thorough | Plan/PRD/Approval 후 → tfx-multi Phase 3 + verify/fix | 전체 파이프라인 |
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 |
160
162
 
161
- **전환 방법:** 트리아지 완료 후 서브태스크 배열 + thorough 플래그를 tfx-multi Phase 3에 전달.
162
- tfx-multi의 Phase 2(트리아지)는 건너뛰고, thorough Phase 2.5-2.6도 건너뛴다 (auto에서 이미 수행).
163
+ **전환 방법:** 트리아지 완료 후 서브태스크 배열을 headless.runHeadlessInteractive()에 전달.
164
+ Windows Terminal에 psmux 세션이 자동 팝업되어 사용자가 실시간으로 CLI 출력 확인.
163
165
 
164
166
  ```
165
167
  thorough = args에 -t 또는 --thorough 포함
166
168
 
167
169
  if subtasks.length >= 2:
168
- if thorough:
169
- Pipeline init → Plan → PRD → Approval (tfx-auto에서 수행)
170
- tfx-multi Phase 3 실행 ({ subtasks, thorough: true })
171
- Phase 3.5 verify → Phase 3.6 fix loop → Phase 5 정리
170
+ if psmux 설치됨:
171
+ headless.runHeadlessInteractive(assignments, {
172
+ autoAttach: true, // WT 자동 팝업
173
+ progressive: true, // 실시간 스플릿
174
+ progressIntervalSec: 10,
175
+ })
176
+ → if thorough: verify → fix loop
172
177
  else:
173
- → tfx-multi Phase 3 실행 ({ subtasks, thorough: false })
174
- → Phase 4 결과 수집 → Phase 5 정리
178
+ fallback: tfx-multi Phase 3 Native Teams (Agent slim wrapper)
175
179
  else:
176
180
  if thorough:
177
181
  → Pipeline init → Plan → PRD → Approval → 직접 실행 → Verify → Fix loop
@@ -73,82 +73,7 @@ preflight와 Agent 생성을 병렬로 실행하여 사용자 체감 지연을
73
73
  > `--thorough`(기본) 모드에서 실행된다. `--quick` 플래그 시 건너뛴다.
74
74
  > 상세는 → [`references/thorough-pipeline.md`](references/thorough-pipeline.md) 참조.
75
75
 
76
- ### Phase 3: Native Teams 실행
77
-
78
- #### Step 3a: 팀 생성
79
-
80
- ```
81
- teamName = "tfx-" + Date.now().toString(36).slice(-6)
82
- TeamCreate({ team_name: teamName, description: "tfx-multi: {원본 작업 요약}" })
83
- ```
84
-
85
- #### Step 3b: 공유 작업 등록
86
-
87
- ```
88
- for each assignment (index i):
89
- TaskCreate({ subject: assignment.subtask, metadata: { cli, role } })
90
- agentName = "{cli}-worker-{i+1}"
91
- ```
92
-
93
- #### Step 3c: 슬림 래퍼 Agent 실행
94
-
95
- Codex/Gemini 서브태스크마다 슬림 래퍼 Agent를 spawn하여 Shift+Down 네비게이션에 등록한다.
96
- 래퍼 내부에서 `tfx-route.sh`로 CLI를 실행하고, 리드 피드백을 받아 재실행하는 구조이다.
97
-
98
- ```
99
- for each item where item.cli in ["codex", "gemini"]:
100
- Agent({
101
- name: item.agentName,
102
- team_name: teamName,
103
- mode: "bypassPermissions",
104
- run_in_background: true,
105
- prompt: buildSlimWrapperPrompt(item.cli, { subtask, role, teamName, taskId, agentName, leadName: "team-lead", mcp_profile })
106
- })
107
- ```
108
-
109
- 슬림 래퍼 프롬프트의 단일 truth source: `hub/team/native.mjs`의 `buildSlimWrapperPrompt()`.
110
- 핵심 동작: Bash(tfx-route.sh) → SendMessage(보고) → 피드백 대기 → 재실행(N회) → TaskUpdate(completed) → 종료.
111
-
112
- **핵심 규칙 요약:**
113
- - Agent 래퍼 생략 금지 — 단일 워커도 반드시 Agent로 spawn (네비게이션 등록)
114
- - `mode: "bypassPermissions"` 필수 — 모든 Agent에 포함
115
- - `tfx-route.sh` 경유 필수 — 직접 `codex exec`/`gemini -y -p` 호출 금지
116
- - 코드 직접 조작 금지 — 워커가 Read/Edit/Write 등 도구 직접 사용 금지
117
-
118
- > 래퍼 규칙의 상세 이유와 인터럽트 프로토콜 → [`references/agent-wrapper-rules.md`](references/agent-wrapper-rules.md) 참조.
119
-
120
- #### Step 3d: claude 타입만 Agent 직접 실행
121
-
122
- ```
123
- Agent({
124
- name: "claude-worker-{n}", team_name: teamName, mode: "bypassPermissions",
125
- run_in_background: true, subagent_type: "{role}",
126
- prompt: "TaskGet → TaskUpdate(in_progress) → 작업 수행 → TaskUpdate(completed, metadata: {result}) + SendMessage(to: team-lead)"
127
- })
128
- ```
129
-
130
- status는 "completed"만 사용. 실패 여부는 `metadata.result`로 구분.
131
-
132
- #### Step 3e: 사용자 안내
133
-
134
- "팀 생성 완료. Shift+Down으로 워커 전환, Shift+Tab으로 이전 워커."
135
-
136
- ### Phase 4: 결과 수집
137
-
138
- `team_task_list`가 최종 truth source: `Bash("node hub/bridge.mjs team-task-list --team ${teamName}")`
139
- - `metadata.result == "failed"` → Claude fallback 재시도
140
- - Hub `task-update`에서는 `"failed"` 사용 가능. Claude Code `TaskUpdate`만 `"completed"` + `metadata.result`로 구분.
141
-
142
- ### Phase 5: 정리 (반드시 실행)
143
-
144
- 성공/실패에 관계없이 반드시 실행. TeamDelete를 건너뛰면 `~/.claude/teams/{teamName}/`이 잔존하여 무한 루프 발생.
145
-
146
- 1. 백그라운드 Agent 완료를 **최대 30초** 대기
147
- 2. `TeamDelete()` 호출
148
- 3. 실패 시 `forceCleanupTeam(teamName)` → 그래도 실패 시 `rm -rf ~/.claude/teams/{teamName}/` 안내
149
- 4. 종합 보고서 출력
150
-
151
- ### Phase 3-direct: Lead-Direct Headless 실행 (v6.0.0, 기본)
76
+ ### Phase 3: Lead-Direct Headless 실행 (v6.0.0, 기본)
152
77
 
153
78
  CLI 워커(Codex/Gemini/Claude)를 Agent 래퍼 없이 Lead가 headless.mjs로 직접 실행.
154
79
  Windows Terminal에 psmux 세션이 자동 팝업되어 사용자가 실시간으로 CLI 출력을 확인.
@@ -201,6 +126,18 @@ Phase 3 선택:
201
126
  **시각적 확인:** Windows Terminal 자동 팝업 + pane 타이틀 `codex (reviewer)` + triflux 테마.
202
127
  **실수로 닫아도:** psmux 세션은 독립적. `psmux attach -t 세션이름`으로 재연결.
203
128
 
129
+ ### Phase 4: 결과 수집 + 정리
130
+
131
+ headless 완료 후 `handle.results`에서 직접 수집. `handle.kill()`로 세션 정리.
132
+ 실패 워커(`exitCode !== 0`)는 Claude fallback 재시도.
133
+
134
+ ### Phase 3-fallback: Native Teams (psmux 미설치 시)
135
+
136
+ psmux가 없는 환경에서만 사용. Agent slim wrapper로 CLI를 실행.
137
+ `hub/team/native.mjs`의 `buildSlimWrapperPrompt()` 기반.
138
+
139
+ > 래퍼 규칙 상세 → [`references/agent-wrapper-rules.md`](references/agent-wrapper-rules.md)
140
+
204
141
  **레거시 인터랙티브 모드:** `Bash("node {PKG_ROOT}/bin/triflux.mjs multi --no-attach --agents {agents} \\\"{task}\\\"")`
205
142
 
206
143
  ## 전제 조건