triflux 3.3.0-dev.7 → 4.0.0

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 (91) hide show
  1. package/README.ko.md +108 -199
  2. package/README.md +108 -199
  3. package/bin/triflux.mjs +2415 -1762
  4. package/hooks/keyword-rules.json +361 -354
  5. package/hooks/pipeline-stop.mjs +5 -2
  6. package/hub/assign-callbacks.mjs +136 -136
  7. package/hub/bridge.mjs +734 -708
  8. package/hub/delegator/contracts.mjs +38 -0
  9. package/hub/delegator/index.mjs +14 -0
  10. package/hub/delegator/schema/delegator-tools.schema.json +250 -0
  11. package/hub/delegator/service.mjs +302 -0
  12. package/hub/delegator/tool-definitions.mjs +35 -0
  13. package/hub/hitl.mjs +67 -67
  14. package/hub/paths.mjs +28 -0
  15. package/hub/pipe.mjs +589 -561
  16. package/hub/pipeline/state.mjs +23 -0
  17. package/hub/public/dashboard.html +349 -0
  18. package/hub/public/tray-icon.ico +0 -0
  19. package/hub/public/tray-icon.png +0 -0
  20. package/hub/router.mjs +782 -782
  21. package/hub/schema.sql +40 -40
  22. package/hub/server.mjs +810 -637
  23. package/hub/store.mjs +706 -706
  24. package/hub/team/cli/commands/attach.mjs +37 -0
  25. package/hub/team/cli/commands/control.mjs +43 -0
  26. package/hub/team/cli/commands/debug.mjs +74 -0
  27. package/hub/team/cli/commands/focus.mjs +53 -0
  28. package/hub/team/cli/commands/interrupt.mjs +36 -0
  29. package/hub/team/cli/commands/kill.mjs +37 -0
  30. package/hub/team/cli/commands/list.mjs +24 -0
  31. package/hub/team/cli/commands/send.mjs +37 -0
  32. package/hub/team/cli/commands/start/index.mjs +87 -0
  33. package/hub/team/cli/commands/start/parse-args.mjs +32 -0
  34. package/hub/team/cli/commands/start/start-in-process.mjs +40 -0
  35. package/hub/team/cli/commands/start/start-mux.mjs +73 -0
  36. package/hub/team/cli/commands/start/start-wt.mjs +69 -0
  37. package/hub/team/cli/commands/status.mjs +87 -0
  38. package/hub/team/cli/commands/stop.mjs +31 -0
  39. package/hub/team/cli/commands/task.mjs +30 -0
  40. package/hub/team/cli/commands/tasks.mjs +13 -0
  41. package/hub/team/{cli.mjs → cli/help.mjs} +38 -99
  42. package/hub/team/cli/index.mjs +39 -0
  43. package/hub/team/cli/manifest.mjs +28 -0
  44. package/hub/team/cli/render.mjs +30 -0
  45. package/hub/team/cli/services/attach-fallback.mjs +54 -0
  46. package/hub/team/cli/services/hub-client.mjs +171 -0
  47. package/hub/team/cli/services/member-selector.mjs +30 -0
  48. package/hub/team/cli/services/native-control.mjs +115 -0
  49. package/hub/team/cli/services/runtime-mode.mjs +60 -0
  50. package/hub/team/cli/services/state-store.mjs +34 -0
  51. package/hub/team/cli/services/task-model.mjs +30 -0
  52. package/hub/team/native-supervisor.mjs +69 -63
  53. package/hub/team/native.mjs +367 -266
  54. package/hub/team/nativeProxy.mjs +217 -173
  55. package/hub/team/pane.mjs +149 -149
  56. package/hub/team/psmux.mjs +946 -946
  57. package/hub/team/session.mjs +608 -608
  58. package/hub/team/staleState.mjs +369 -299
  59. package/hub/tools.mjs +107 -107
  60. package/hub/tray.mjs +332 -0
  61. package/hub/workers/claude-worker.mjs +446 -446
  62. package/hub/workers/codex-mcp.mjs +414 -414
  63. package/hub/workers/delegator-mcp.mjs +1045 -1045
  64. package/hub/workers/factory.mjs +21 -21
  65. package/hub/workers/gemini-worker.mjs +349 -349
  66. package/hub/workers/interface.mjs +41 -41
  67. package/package.json +61 -60
  68. package/scripts/__tests__/keyword-detector.test.mjs +234 -234
  69. package/scripts/hub-ensure.mjs +102 -101
  70. package/scripts/keyword-detector.mjs +272 -272
  71. package/scripts/keyword-rules-expander.mjs +521 -521
  72. package/scripts/lib/keyword-rules.mjs +168 -168
  73. package/scripts/lib/mcp-filter.mjs +642 -642
  74. package/scripts/lib/mcp-server-catalog.mjs +118 -118
  75. package/scripts/mcp-check.mjs +126 -126
  76. package/scripts/preflight-cache.mjs +19 -0
  77. package/scripts/run.cjs +62 -62
  78. package/scripts/setup.mjs +68 -31
  79. package/scripts/test-tfx-route-no-claude-native.mjs +57 -57
  80. package/scripts/tfx-route-worker.mjs +161 -161
  81. package/scripts/tfx-route.sh +1360 -1326
  82. package/skills/tfx-auto/SKILL.md +196 -196
  83. package/skills/tfx-auto-codex/SKILL.md +77 -77
  84. package/skills/tfx-multi/SKILL.md +378 -378
  85. package/hub/team/cli-team-common.mjs +0 -348
  86. package/hub/team/cli-team-control.mjs +0 -393
  87. package/hub/team/cli-team-start.mjs +0 -516
  88. package/hub/team/cli-team-status.mjs +0 -283
  89. package/skills/auto-verify/SKILL.md +0 -145
  90. package/skills/manage-skills/SKILL.md +0 -192
  91. package/skills/verify-implementation/SKILL.md +0 -138
package/README.md CHANGED
@@ -9,8 +9,8 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <strong>CLI-first multi-model orchestrator</strong><br>
13
- <em>Route tasks to Codex, Gemini, and Claude route tasks to the right model, save Claude tokens</em>
12
+ <strong>The Multi-Model Orchestration Hub for Claude Code</strong><br>
13
+ <em>Vanish Claude tokens. Route tasks to Codex and Gemini via high-performance Hub IPC.</em>
14
14
  </p>
15
15
 
16
16
  <p align="center">
@@ -19,7 +19,6 @@
19
19
  <a href="https://github.com/tellang/triflux/stargazers"><img src="https://img.shields.io/github/stars/tellang/triflux?style=flat-square&color=FFAF00" alt="GitHub stars"></a>
20
20
  <a href="https://github.com/tellang/triflux/actions"><img src="https://img.shields.io/github/actions/workflow/status/tellang/triflux/ci.yml?style=flat-square&label=CI" alt="CI"></a>
21
21
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-374151?style=flat-square" alt="License: MIT"></a>
22
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-374151?style=flat-square" alt="Node.js >= 18"></a>
23
22
  </p>
24
23
 
25
24
  <p align="center">
@@ -32,248 +31,158 @@
32
31
 
33
32
  <p align="center">
34
33
  <a href="#quick-start">Quick Start</a> ·
35
- <a href="#skills">Skills</a> ·
36
34
  <a href="#architecture">Architecture</a> ·
37
- <a href="#setup-guide">Setup Guide</a>
35
+ <a href="#pipeline-thorough">Pipeline</a> ·
36
+ <a href="#delegator-mcp">Delegator MCP</a> ·
37
+ <a href="#agent-types">Agent Types</a> ·
38
+ <a href="#security">Security</a>
38
39
  </p>
39
40
 
40
41
  ---
41
42
 
42
- ## Why triflux?
43
+ ## What's New in v4?
43
44
 
44
- - **Cost-intelligent routing** Automatically routes tasks to Codex and Gemini before spending Claude tokens
45
- - **DAG-based parallel execution** — Decomposes complex tasks into dependency graphs and runs them concurrently
46
- - **Auto-triage** — Codex classifies + Opus decomposes, no manual agent selection needed
47
- - **16 agent types** — From executor to architect, each mapped to the optimal CLI and effort level
48
- - **HUD status bar** — Real-time CLI health, token savings, and rate limit monitoring
49
- - **Zero config** — Install and start using slash commands in Claude Code immediately
45
+ **triflux v4** evolves from a simple router into a **high-performance orchestration hub**. It introduces resident services, named-pipe IPC, and advanced task pipelines to provide the most stable multi-model experience for [Claude Code](https://claude.ai/code).
50
46
 
51
- <details>
52
- <summary><strong>Install</strong></summary>
47
+ ### Key Features
53
48
 
54
- ### npm (recommended)
49
+ - **Hub IPC Architecture** — Lightning-fast resident Hub server with Named Pipe & HTTP MCP bridge.
50
+ - **Pipeline `--thorough`** — Multi-phase task lifecycle: `plan` → `prd` → `exec` → `verify` → `fix`.
51
+ - **Delegator MCP** — Native MCP tools (`delegate`, `reply`, `status`) for seamless agent interaction.
52
+ - **psmux / Windows Native** — Hybrid support for `tmux` (WSL) and `psmux` (Windows Terminal native).
53
+ - **QoS Dashboard** — Real-time health monitoring with AIMD-based dynamic batch sizing.
54
+ - **21+ specialized agents** — From `scientist-deep` to `spark_fast`, each optimized for specific tasks.
55
55
 
56
- ```bash
57
- npm install -g triflux
58
- ```
56
+ ---
59
57
 
60
- ### npx (one-off)
58
+ ## Architecture
61
59
 
62
- ```bash
63
- npx triflux doctor
60
+ triflux uses a **Hub-and-Spoke** architecture. The resident Hub manages state, authentication, and task routing via high-performance Named Pipes.
61
+
62
+ ```mermaid
63
+ graph TD
64
+ User([User / Claude Code]) <-->|Slash Commands| TFX_CLI[tfx CLI]
65
+ TFX_CLI <-->|Named Pipe / HTTP| HUB[triflux Hub Server]
66
+
67
+ subgraph "Orchestration Hub"
68
+ HUB <--> STORE[(SQLite Store)]
69
+ HUB <--> DASH[QoS Dashboard]
70
+ HUB <--> DELEGATOR[Delegator Service]
71
+ end
72
+
73
+ DELEGATOR <-->|Spawn| CODEX[Codex CLI]
74
+ DELEGATOR <-->|Spawn| GEMINI[Gemini CLI]
75
+ DELEGATOR <-->|Native| CLAUDE[Claude Code]
76
+
77
+ HUB -.->|MCP Bridge| External[External MCP Clients]
64
78
  ```
65
79
 
66
- ### Verify
80
+ ---
81
+
82
+ ## Quick Start
83
+
84
+ ### 1. Install
67
85
 
68
86
  ```bash
69
- tfx doctor
87
+ npm install -g triflux
70
88
  ```
71
89
 
72
- </details>
90
+ ### 2. Setup (Required)
73
91
 
74
- ## Quick Start
92
+ Synchronize scripts, register skills to Claude Code, and configure the HUD.
75
93
 
76
94
  ```bash
77
- # Auto mode — AI classifies + decomposes + executes in parallel
78
- /tfx-auto "refactor auth module + improve login UI + add tests"
79
-
80
- # Manual mode — specify agent count and type
81
- /tfx-auto 3:codex "review src/api, src/auth, src/payment"
82
-
83
- # Command shortcuts — single agent, instant execution
84
- /implement "add JWT auth middleware"
85
- /analyze "security review of payment module"
86
- /research "latest React Server Components patterns"
87
-
88
- # Single-CLI modes
89
- /tfx-auto-codex "refactor + test + review" # Codex lead + Gemini kept, no Claude-native roles
90
- /tfx-codex "refactor + review" # Codex only
91
- /tfx-gemini "implement + document" # Gemini only
92
- ```
93
-
94
- ## Docs
95
-
96
- - [docs/INDEX.md](docs/INDEX.md) — central documentation index
97
-
98
- ## Skills
99
-
100
- | Skill | Mode | Description |
101
- |-------|------|-------------|
102
- | `/tfx-auto` | Auto | Triage → decompose → parallel execute via DAG |
103
- | `/tfx-auto-codex` | Codex-lead | Replace Claude-native roles with Codex, keep Gemini path |
104
- | `/tfx-codex` | Codex-only | All CLI tasks routed to Codex |
105
- | `/tfx-gemini` | Gemini-only | All CLI tasks routed to Gemini |
106
- | `/tfx-setup` | Setup | File sync, HUD config, CLI diagnostics |
107
-
108
- ### Command Shortcuts
109
-
110
- Bypass triage — instant single-agent execution:
111
-
112
- | Command | Agent | CLI | Use Case |
113
- |---------|-------|-----|----------|
114
- | `/implement` | executor | Codex | Code implementation |
115
- | `/build` | build-fixer | Codex | Build/type error fixes |
116
- | `/research` | document-specialist | Codex | Documentation lookup |
117
- | `/brainstorm` | analyst | Codex | Requirements analysis |
118
- | `/design` | architect | Codex | Architecture design |
119
- | `/troubleshoot` | debugger | Codex | Bug analysis |
120
- | `/cleanup` | executor | Codex | Code cleanup |
121
- | `/analyze` | quality + security | Codex | Parallel review (2 agents) |
122
- | `/spec-panel` | architect + analyst + critic | Codex | Spec review (3 agents) |
123
- | `/explain` | writer | Gemini | Code explanation |
124
- | `/document` | writer | Gemini | Documentation |
125
- | `/test` | test-engineer | Claude | Test strategy |
126
- | `/reflect` | verifier | Claude | Verification |
127
-
128
- ## Architecture
129
-
130
- ```
131
- User: "/tfx-auto refactor auth + improve UI + add tests"
132
- |
133
- v
134
- [Phase 1: Parse] ─── Auto mode detected
135
- |
136
- v
137
- [Phase 2a: Classify] ─── Codex
138
- │ auth refactor → codex
139
- │ UI improvement → gemini
140
- │ test addition → claude
141
- |
142
- v
143
- [Phase 2b: Decompose] ─── Opus (inline, no agent spawn)
144
- │ t1: executor (implement, src/auth/) Level 0
145
- │ t2: designer (docs, src/components/) Level 0
146
- │ t3: test-engineer (Claude native) Level 1 ← depends on t1
147
- |
148
- v
149
- [Phase 3: Execute] ─── DAG parallel
150
- │ Level 0: t1(Codex) + t2(Gemini) ← parallel
151
- │ Level 1: t3(Claude) ← after t1 completes
152
- |
153
- v
154
- [Phase 4-6: Collect → Retry → Report]
95
+ tfx setup
155
96
  ```
156
97
 
157
- ### Agent Routing Table
158
-
159
- | Agent | CLI | Effort | Timeout | Mode |
160
- |-------|-----|--------|---------|------|
161
- | executor | Codex | high | 360s | fg |
162
- | build-fixer | Codex | fast | 180s | fg |
163
- | debugger | Codex | high | 300s | bg |
164
- | deep-executor | Codex | xhigh | 1200s | bg |
165
- | architect | Codex | xhigh | 1200s | bg |
166
- | planner | Codex | xhigh | 1200s | fg |
167
- | critic | Codex | xhigh | 1200s | bg |
168
- | analyst | Codex | xhigh | 1200s | fg |
169
- | code-reviewer | Codex | thorough | 600s | bg |
170
- | security-reviewer | Codex | thorough | 600s | bg |
171
- | quality-reviewer | Codex | thorough | 600s | bg |
172
- | scientist | Codex | high | 480s | bg |
173
- | document-specialist | Codex | high | 480s | bg |
174
- | designer | Gemini Pro 3.1 | — | 600s | bg |
175
- | writer | Gemini Flash 3 | — | 600s | bg |
176
- | explore | Claude Haiku | — | 300s | fg |
177
- | verifier | Claude Sonnet | — | 300s | fg |
178
- | test-engineer | Claude Sonnet | — | 300s | bg |
179
-
180
- ### Failure Handling
181
-
182
- 1. **First failure** → Claude native agent fallback
183
- 2. **Second failure** → Report failed subtask, continue with remaining results
184
- 3. **Timeout** → Partial results reported
185
-
186
- <details>
187
- <summary><strong>Setup Guide</strong></summary>
188
-
189
- ### Prerequisites
190
-
191
- - **Node.js** >= 18
192
- - **Claude Code** (required)
193
- - **Codex CLI** (optional): `npm install -g @openai/codex`
194
- - **Gemini CLI** (optional): `npm install -g @google/gemini-cli`
195
-
196
- > [!TIP]
197
- > **triflux is 100% standalone.** It does not require [oh-my-claudecode (OMC)](https://github.com/nicepkg/oh-my-claudecode) to function. It will automatically detect and provide optional integration only if OMC is present. Without Codex or Gemini, triflux falls back to Claude native agents.
198
-
199
- ### Post-install
98
+ ### 3. Usage
200
99
 
201
100
  ```bash
202
- # Sync files + configure HUD
203
- tfx setup
101
+ # Auto mode Parallel execution via Hub
102
+ /tfx-auto "refactor auth + update UI + add tests"
103
+
104
+ # Pipeline mode — Thorough multi-phase execution
105
+ /tfx-auto --thorough "implement complex data migration"
204
106
 
205
- # Run diagnostics
206
- tfx doctor
107
+ # Direct Delegation
108
+ /tfx-delegate "research latest React patterns" --provider gemini
207
109
  ```
208
110
 
209
- ### CLI Commands
111
+ ---
210
112
 
211
- | Command | Description |
212
- |---------|-------------|
213
- | `tfx setup` | Sync scripts + HUD + skills |
214
- | `tfx doctor` | CLI diagnostics + issue tracker |
215
- | `tfx update` | Update to latest stable version |
216
- | `tfx list` | List installed skills |
217
- | `tfx version` | Show version info |
218
-
219
- Shortcuts: `tfx` = `triflux`, `tfl` = `triflux`
220
-
221
- Dev channel update: `tfx update --dev` (`dev` alias supported)
113
+ ## Pipeline: `--thorough` Mode
222
114
 
223
- ### HUD Status Bar
115
+ The v4 Pipeline provides a robust execution loop designed for complex engineering tasks.
224
116
 
225
- Real-time monitoring in Claude Code's status line:
117
+ | Phase | Description |
118
+ |-------|-------------|
119
+ | **plan** | Architect the solution and identify dependencies. |
120
+ | **prd** | Generate a detailed Technical Specification / PRD. |
121
+ | **exec** | Perform the actual code implementation. |
122
+ | **verify** | Run tests and verify the implementation against the PRD. |
123
+ | **fix** | (Loop) Automatically fix failures identified in the verify phase (Max 3). |
124
+ | **ralph** | (Reset) If the fix loop fails, restart from `plan` with new insights (Max 10). |
226
125
 
227
- - Claude / Codex / Gemini token usage and rate limits
228
- - CLI health indicators (installed, API key status)
229
- - Session cost tracking and savings report
126
+ ---
230
127
 
231
- Configured automatically via `tfx setup`.
128
+ ## Delegator MCP
232
129
 
233
- </details>
130
+ Interact with the Hub directly through MCP tools.
234
131
 
235
- <details>
236
- <summary><strong>Optional: oh-my-claudecode (OMC) Integration</strong></summary>
132
+ - **`delegate`**: Route a prompt to a specific provider or let the Hub decide. Supports `sync` and `async` modes.
133
+ - **`reply`**: Continue multi-turn conversations with a running agent (currently Gemini direct).
134
+ - **`status`**: Check the progress of asynchronous background tasks.
237
135
 
238
- triflux is **100% independent** and does not require any external tools to function. However, it provides optional compatibility with [oh-my-claudecode](https://github.com/nicepkg/oh-my-claudecode) for users who prefer that ecosystem:
136
+ ---
239
137
 
240
- - **Full Independence**: Works standalone without OMC or any other wrappers.
241
- - **Cache Compatibility**: Detects and respects OMC cache paths (e.g., `~/.omc/state/`) if present, but maintains its own isolated state by default.
242
- - **Seamless Plugin**: Skills auto-registered via OMC's plugin system if OMC is installed.
243
- - **Extended HUD**: HUD automatically extends OMC's status line when detected.
244
- - **Mode Support**: Compatible with OMC autopilot, ralph, team, and ultrawork modes.
138
+ ## Agent Types (21+)
139
+
140
+ | Agent | CLI | Purpose |
141
+ |-------|-----|---------|
142
+ | **executor** | Codex | Standard implementation & refactoring. |
143
+ | **build-fixer** | Codex/Gemini | Instant fixes for build/type errors. |
144
+ | **architect** | Codex | High-level system design & planning. |
145
+ | **scientist-deep** | Codex | Exhaustive research & deep analysis. |
146
+ | **code-reviewer** | Codex | Security & Logic focused code review. |
147
+ | **security-reviewer**| Codex | Vulnerability & Permission audit. |
148
+ | **quality-reviewer** | Codex | Logic & Maintainability audit. |
149
+ | **designer** | Gemini | UI/UX & documentation design. |
150
+ | **writer** | Gemini | Technical writing & explanations. |
151
+ | **spark** | Gemini | Lightweight, fast prototyping. |
152
+ | **verifier** | Claude | Final verification & validation. |
153
+ | **test-engineer** | Claude | Comprehensive test suite generation. |
154
+ | *...and more* | | `debugger`, `planner`, `critic`, `analyst`, `scientist`, `explore`, `qa-tester` |
245
155
 
246
- </details>
156
+ ---
247
157
 
248
- <details>
249
- <summary><strong>Changelog</strong></summary>
158
+ ## Security
250
159
 
251
- ### 2.0.0
160
+ triflux v4 is designed for secure, professional environments:
252
161
 
253
- - Rebranded from `cx-skills` to `triflux`
254
- - New CLI commands: `tfx`, `triflux`, `tfl`
255
- - Updated skills: `/tfx-auto`, `/tfx-codex`, `/tfx-gemini`, `/tfx-setup`
256
- - Visual refresh with amber branding
257
- - All internal references updated (`CX_CLI_MODE` → `TFX_CLI_MODE`)
162
+ - **Hub Token Auth** — Secure IPC using `TFX_HUB_TOKEN` (Bearer Auth).
163
+ - **Localhost Only** Default Hub binding to `127.0.0.1` prevents external access.
164
+ - **CORS Lockdown** Strict origin checking for the QoS Dashboard.
165
+ - **Injection Protection** Sanitized shell command execution in `psmux` and `tmux`.
258
166
 
259
- ### Previous (cx-skills)
167
+ ---
168
+
169
+ ## QoS Dashboard
260
170
 
261
- See [cx-skills releases](https://github.com/tellang/cx-skills/releases) for v1.x history.
171
+ Monitor your orchestration health at `http://localhost:27888/dashboard`.
262
172
 
263
- </details>
173
+ - **AIMD Batch Sizing** — Automatically scales parallel tasks (3 → 10) based on success rates.
174
+ - **Token Savings** — Real-time tracking of Claude tokens saved by routing to Codex/Gemini.
175
+ - **Rate Limit Tracking** — Live monitoring of Codex and Gemini quotas.
264
176
 
265
177
  ---
266
178
 
267
- <p align="center">
268
- <a href="https://github.com/tellang/triflux">
269
- <picture>
270
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=tellang/triflux&type=Date&theme=dark">
271
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=tellang/triflux&type=Date">
272
- <img alt="Star History" src="https://api.star-history.com/svg?repos=tellang/triflux&type=Date" width="600">
273
- </picture>
274
- </a>
275
- </p>
179
+ ## Platform Support
180
+
181
+ - **Linux / macOS**: Native `tmux` integration.
182
+ - **Windows**: **psmux** (PowerShell Multiplexer) + Windows Terminal hybrid for a native Windows experience.
183
+
184
+ ---
276
185
 
277
186
  <p align="center">
278
- <sub>MIT License · Made by <a href="https://github.com/tellang">tellang</a></sub>
187
+ <sub>MIT License · Made with ❤️ by <a href="https://github.com/tellang">tellang</a></sub>
279
188
  </p>