@zachjxyz/moxie 0.2.5 → 0.3.1

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.
package/README.md ADDED
@@ -0,0 +1,280 @@
1
+ # moxie
2
+
3
+ Spec-driven multi-agent development with quorum convergence.
4
+
5
+ moxie runs multiple AI coding agents through a structured pipeline — RFC, audit, fix, plan, build — where every phase requires unanimous agreement before moving on. Agents independently verify each other's work, catching errors that single-agent workflows miss.
6
+
7
+ ## Why
8
+
9
+ A single AI agent reviewing its own work is self-evaluation. moxie forces cross-model verification: different models from different providers check each other's reasoning. When Claude and GPT-5.4 independently agree on an RFC, it's more trustworthy than either alone.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install -g @zachjxyz/moxie
15
+ ```
16
+
17
+ Requires Node.js >= 14, Python 3, and at least 2 agent CLIs or a [Vercel AI Gateway](https://vercel.com/ai-gateway) API key.
18
+
19
+ ## Quick start
20
+
21
+ ```bash
22
+ cd your-project
23
+ moxie init
24
+ ```
25
+
26
+ moxie scans for installed agent CLIs and shows available AI Gateway models. Select at least 2:
27
+
28
+ ```
29
+ Select agents (at least 2). CLI agents pre-selected, gateway models available below:
30
+
31
+ --- Detected CLI agents ---
32
+ > [x] Claude Code (2.1.91)
33
+ [x] Codex (0.118.0)
34
+ --- Vercel AI Gateway ---
35
+ [ ] Claude Opus 4.6 (anthropic/claude-opus-4-6)
36
+ [ ] GPT-5.4 (openai/gpt-5.4)
37
+ [ ] Qwen 3.6 Plus (qwen/qwen3.6-plus)
38
+ [ ] GLM 5.1 (zai/glm-5.1)
39
+ [ ] Kimi 2.5 (moonshotai/kimi-k2.5)
40
+ ---------------------------------------------------------
41
+ Submit (2 selected)
42
+
43
+ arrow keys navigate | space/enter toggle | enter submit (min 2)
44
+ ```
45
+
46
+ If you have a spec or RFC already, pass it in:
47
+
48
+ ```bash
49
+ moxie init --spec ./my-spec.md
50
+ ```
51
+
52
+ Then verify and start:
53
+
54
+ ```bash
55
+ moxie doctor
56
+ moxie start
57
+ ```
58
+
59
+ ```
60
+ moxie doctor
61
+
62
+ Dependencies:
63
+ [OK] python3
64
+ [OK] caffeinate
65
+ [OK] timeout
66
+
67
+ Agents (from .moxie/config.toml):
68
+ [OK] claude — 2.1.91 (Claude Code)
69
+ [OK] codex — codex-cli 0.118.0
70
+
71
+ Project:
72
+ [OK] .moxie/ directory found
73
+ [OK] spec.md present (720 lines)
74
+ [OK] All phase ledgers and prompts present
75
+
76
+ All checks passed. Ready to run.
77
+ ```
78
+
79
+ ```
80
+ Starting moxie pipeline in background...
81
+ Log: .moxie/moxie.log
82
+ Monitor: moxie status
83
+ Stop: moxie stop
84
+
85
+ Pipeline started (PID 48291).
86
+ Tail the log: tail -f .moxie/moxie.log
87
+ ```
88
+
89
+ ## Supported agents
90
+
91
+ ### CLI agents (detected on PATH)
92
+
93
+ | Agent | Binary | Install |
94
+ |-------|--------|---------|
95
+ | Claude Code | `claude` | [claude.ai/download](https://claude.ai/download) |
96
+ | Codex | `codex` | [github.com/openai/codex](https://github.com/openai/codex) |
97
+ | Qwen Code | `qwen` | [github.com/QwenLM/qwen-code](https://github.com/QwenLM/qwen-code) |
98
+ | Aider | `aider` | `pip install aider-chat` |
99
+ | Goose | `goose` | `brew install goose` |
100
+ | Amp | `amp` | [ampcode.com](https://ampcode.com) |
101
+ | Cline | `cline` | `npm install -g cline` |
102
+ | Roo Code | `roo` | [docs.roocode.com](https://docs.roocode.com) |
103
+
104
+ ### AI Gateway models (via Vercel AI Gateway)
105
+
106
+ No CLI install needed — moxie calls the API directly with full tool use. Every Vercel account gets [$5/month in free credits](https://vercel.com/docs/ai-gateway/pricing) with access to all models. Pay-as-you-go after that with zero markup.
107
+
108
+ | Model | Provider string |
109
+ |-------|----------------|
110
+ | Claude Opus 4.6 | `anthropic/claude-opus-4-6` |
111
+ | GPT-5.4 | `openai/gpt-5.4` |
112
+ | Qwen 3.6 Plus | `qwen/qwen3.6-plus` |
113
+ | GLM 5.1 | `zai/glm-5.1` |
114
+ | Kimi 2.5 | `moonshotai/kimi-k2.5` |
115
+
116
+ When you select a gateway model during `moxie init`, you'll be prompted to securely store your API key (macOS Keychain, encrypted file on Linux).
117
+
118
+ ## Pipeline
119
+
120
+ Every project goes through 5 phases, each requiring unanimous quorum:
121
+
122
+ ```
123
+ RFC -> Audit -> Fix -> Plan -> Build
124
+ ```
125
+
126
+ 1. **RFC** — Agents analyze the codebase and converge on a comprehensive specification
127
+ 2. **Audit** — Agents audit the RFC against the actual source code
128
+ 3. **Fix** — Agents fix discrepancies found during audit
129
+ 4. **Plan** — Agents produce an implementation plan from the finalized spec
130
+ 5. **Build** — Agents implement the plan, taking turns writing and reviewing code
131
+
132
+ Each phase uses round-robin rotation with randomized order. Agents independently review each other's work and must all sign off before the phase advances.
133
+
134
+ ```
135
+ ════════════════════════════════════════════════════════════
136
+ PHASE 1/5: RFC
137
+ ════════════════════════════════════════════════════════════
138
+
139
+ ╔══════════════════════════════════════════════════╗
140
+ ║ moxie: RFC phase ║
141
+ ║ Round-robin quorum convergence ║
142
+ ║ Max rounds: 15 ║
143
+ ║ Timeout/turn: 900s ║
144
+ ╚══════════════════════════════════════════════════╝
145
+
146
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
147
+ Turn 1/15 — claude
148
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
149
+ Log: claude-041126-142611.log
150
+ Tokens: 178,108
151
+
152
+ Quorum after claude's turn:
153
+ claude pending .moxie/phases/rfc/claude-041126-142611.md
154
+ codex pending .moxie/phases/rfc/codex-041126-141850.md
155
+ ── 0/2 agents reached quorum
156
+ ```
157
+
158
+ ## How quorum works
159
+
160
+ - Agents take turns in a randomized rotation
161
+ - After each turn, the agent marks whether it agrees with the current state (`reached: true`)
162
+ - If any agent finds issues, it resets all agents to `reached: false`
163
+ - A phase completes when all healthy agents simultaneously agree
164
+
165
+ ```
166
+ ╔════════════════════════════════════════════════════════════╗
167
+ ║ RFC phase complete — quorum reached ║
168
+ ║ Final: RFC-FINAL-041126-220315.md ║
169
+ ║ 2/2 agents signed off ║
170
+ ╚════════════════════════════════════════════════════════════╝
171
+ ```
172
+
173
+ ### Safeguards
174
+
175
+ **Dead agent detection** — If an agent fails 2 consecutive turns (timeout, empty output, quota exhaustion), it's automatically removed from rotation. Quorum adjusts to the remaining healthy agents.
176
+
177
+ ```
178
+ [DEGRADED] qwen failed 2 consecutive turns — removing from rotation
179
+ (possible quota exhaustion, auth failure, or CLI crash)
180
+ ```
181
+
182
+ **Convergence stall detection** — If agents argue about the same findings for 3 consecutive rotations without progress, moxie detects the loop and force-accepts the best available draft.
183
+
184
+ ```
185
+ [convergence] Findings unchanged for 3 rotation(s) (3 triggers force-accept)
186
+
187
+ ╔════════════════════════════════════════════════════════════╗
188
+ ║ RFC — force-accepting (convergence stall) ║
189
+ ║ Findings stabilized for 3 rotations. ║
190
+ ║ Accepting best available draft as FINAL. ║
191
+ ╚════════════════════════════════════════════════════════════╝
192
+ ```
193
+
194
+ **Minimum 2 agents** — Single-agent mode is not supported. moxie requires at least 2 healthy agents for cross-model verification.
195
+
196
+ ## Commands
197
+
198
+ ```
199
+ moxie init [--spec FILE] Scaffold .moxie/ with agent selection and config
200
+ moxie start [--phase NAME] Run pipeline in background
201
+ moxie stop Stop a running pipeline
202
+ moxie run [--phase NAME] Run pipeline in foreground
203
+ moxie status Show phase progress and quorum state
204
+ moxie cost Token usage and gateway cost breakdown
205
+ moxie logs [PHASE] View logs for a phase
206
+ moxie agents List configured agents
207
+ moxie doctor Check dependencies, agents, and project health
208
+ ```
209
+
210
+ ## Config
211
+
212
+ After `moxie init`, your `.moxie/config.toml` looks like:
213
+
214
+ ```toml
215
+ [spec]
216
+ path = "spec.md"
217
+
218
+ [gateway]
219
+ endpoint = "https://ai-gateway.vercel.sh"
220
+
221
+ [agents.claude]
222
+ command = "claude --dangerously-skip-permissions --effort max --output-format json -p"
223
+ order = 1
224
+
225
+ [agents.gpt-gw]
226
+ type = "gateway"
227
+ model = "openai/gpt-5.4"
228
+ order = 2
229
+
230
+ [settings]
231
+ max_rounds = 15
232
+ max_rounds_build = 50
233
+ turn_timeout = 900
234
+ ```
235
+
236
+ Edit this file to change agents, adjust timeouts, or add custom agent commands.
237
+
238
+ ## Cost tracking
239
+
240
+ `moxie cost` shows token usage per phase and agent:
241
+
242
+ ```
243
+ Token usage by phase:
244
+
245
+ RFC:
246
+ claude 12,655,300 tokens (+1 unknown)
247
+ codex 8,535,058 tokens
248
+ qwen 2,484,379 tokens (+2 unknown)
249
+ TOTAL 23,674,737 tokens
250
+
251
+ Grand total:
252
+ 23,674,737 tokens
253
+ ```
254
+
255
+ For gateway agents, moxie also pulls actual USD costs from the [Vercel AI Gateway Custom Reporting API](https://vercel.com/docs/ai-gateway/capabilities/custom-reporting) (requires Pro or Enterprise plan, currently in beta):
256
+
257
+ ```
258
+ Gateway cost (via Vercel AI Gateway):
259
+ claude-gw $4.82 (1,245,890 input + 389,201 output tokens)
260
+ gpt-gw $3.17 (987,654 input + 234,567 output tokens)
261
+ TOTAL $7.99
262
+
263
+ Dashboard: https://vercel.com/~/ai
264
+ ```
265
+
266
+ Gateway requests are automatically tagged with `project:moxie`, `phase:<name>`, and `agent:<name>` so you can filter and drill down in the [AI Gateway dashboard](https://vercel.com/docs/ai-gateway).
267
+
268
+ If you're on the free tier or the reporting API is unavailable, `moxie cost` shows token counts only — you can always check your spend in the AI Gateway dashboard directly.
269
+
270
+ ## Platform support
271
+
272
+ | Platform | Status |
273
+ |----------|--------|
274
+ | macOS | Fully supported |
275
+ | Linux | Fully supported |
276
+ | Windows | WSL required |
277
+
278
+ ## License
279
+
280
+ MIT
package/bin/moxie CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  set -euo pipefail
18
18
 
19
- MOXIE_VERSION="0.2.5"
19
+ MOXIE_VERSION="0.3.1"
20
20
  # Resolve symlinks (npm installs bin as a symlink)
21
21
  _self="$0"
22
22
  while [ -L "$_self" ]; do
@@ -27,8 +27,10 @@ done
27
27
  MOXIE_ROOT="$(cd "$(dirname "$_self")/.." && pwd)"
28
28
  MOXIE_LIB="$MOXIE_ROOT/lib"
29
29
 
30
- # Source core library
30
+ # Source core library (platform.sh first — sets MOXIE_PLATFORM for all other libs)
31
+ source "$MOXIE_LIB/platform.sh"
31
32
  source "$MOXIE_LIB/core.sh"
33
+ source "$MOXIE_LIB/gateway-keys.sh"
32
34
  source "$MOXIE_LIB/agents.sh"
33
35
  source "$MOXIE_LIB/phases.sh"
34
36
  source "$MOXIE_LIB/tokens.sh"