crewswarm-cli 0.1.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.
- package/LICENSE +21 -0
- package/README.md +209 -0
- package/bin/crew.js +94 -0
- package/dist/crew.mjs +22964 -0
- package/dist/crew.mjs.map +7 -0
- package/dist/engine.mjs +3381 -0
- package/dist/engine.mjs.map +7 -0
- package/dist/memory.mjs +850 -0
- package/dist/memory.mjs.map +7 -0
- package/package.json +113 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 crewswarm Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# crew-cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for CrewSwarm agent orchestration with local safety rails (sandbox diffs, session state, routing/cost logs), team sync, CI/browser helpers, and voice mode.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
**[OVERVIEW.md](docs/OVERVIEW.md)** - 🚀 1-minute summary of what this is and how it works.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Node.js 20+
|
|
12
|
+
- Git
|
|
13
|
+
- Optional for full integration: running CrewSwarm gateway (`http://127.0.0.1:5010`)
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
npm run build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Run the CLI:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
node bin/crew.js --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Core Commands
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
crew chat "refactor auth middleware"
|
|
32
|
+
crew chat "build auth API with tests" --modefast6
|
|
33
|
+
crew dispatch crew-coder "fix failing tests"
|
|
34
|
+
crew dispatch crew-coder "harden auth middleware" --preset quality
|
|
35
|
+
crew run -t "build auth API with tests" # unified pipeline (resumable)
|
|
36
|
+
crew run --resume pipeline-<trace-id> # resume/replay from checkpoint trace
|
|
37
|
+
crew run --resume pipeline-<trace-id> --from-phase execute
|
|
38
|
+
crew explore "refactor database layer" # parallel speculative execution
|
|
39
|
+
crew plan "add OAuth login" --parallel
|
|
40
|
+
crew preview
|
|
41
|
+
crew apply --check "npm test"
|
|
42
|
+
crew rollback
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Intelligence Commands
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
crew map --graph # visual dependency graph
|
|
49
|
+
crew shell "list large files" # NL to shell command translation
|
|
50
|
+
crew docs "how does auth work" # RAG search over docs/markdown
|
|
51
|
+
crew blast-radius # impact analysis of current changes
|
|
52
|
+
crew capabilities # runtime capability handshake
|
|
53
|
+
crew memory "auth login" # recall prior task memory
|
|
54
|
+
crew lsp check src/cli/index.ts # TypeScript diagnostics
|
|
55
|
+
crew lsp complete src/cli/index.ts 10 5
|
|
56
|
+
crew repl # interactive multi-agent REPL
|
|
57
|
+
crew tui # terminal UI adapter (same runtime as REPL)
|
|
58
|
+
crew github "list open issues" # NL GitHub flows
|
|
59
|
+
crew github doctor # GitHub CLI health check
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Advanced Commands
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
crew sync --status
|
|
66
|
+
crew privacy --show
|
|
67
|
+
crew serve --port 4317 # unified /v1 API + /mcp endpoint
|
|
68
|
+
crew exec "vim src/server.ts" # interactive terminal (PTY)
|
|
69
|
+
crew listen --duration-sec 6
|
|
70
|
+
crew browser-debug --url http://127.0.0.1:4319
|
|
71
|
+
crew ci-fix --check "npm test"
|
|
72
|
+
crew doctor
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Pipeline Runtime Flags
|
|
76
|
+
|
|
77
|
+
- `CREW_USE_UNIFIED_ROUTER=false` - force-disable UnifiedPipeline routing path
|
|
78
|
+
- `CREW_LEGACY_ROUTER=true` - use legacy router/legacy standalone execution path
|
|
79
|
+
- `CREW_DUAL_L2_ENABLED=true` - enable Dual-L2 planning/decomposition
|
|
80
|
+
- `CREW_QA_LOOP_ENABLED=true` - run QA -> fixer -> final QA gate before completion
|
|
81
|
+
- `CREW_QA_MAX_ROUNDS=2` - max fixer rounds in QA loop
|
|
82
|
+
- `CREW_CONTEXT_BUDGET_CHARS=7000` - per-worker retrieved artifact context budget
|
|
83
|
+
- `CREW_CONTEXT_MAX_CHUNKS=8` - max retrieved artifact chunks per worker
|
|
84
|
+
- `CREW_CONTEXT_PACK_TTL_HOURS=24` - TTL for persisted context-pack cache in `.crew/context-packs`
|
|
85
|
+
- `CREW_TOOL_MODE=auto|native|markers` - tool execution mode (default `auto`)
|
|
86
|
+
- `CREW_GEMINI_DYNAMIC_DECLARATIONS=true|false` - use dynamic Gemini declaration builder (default `true`)
|
|
87
|
+
- `CREW_ENABLE_ADVANCED_ADAPTER_TOOLS=true|false` - enable safe advanced adapter tools in default pipeline (default `true`)
|
|
88
|
+
- `CREW_NO_ROUTER=true|false` - skip router classification and force execute-parallel flow
|
|
89
|
+
|
|
90
|
+
CLI preset flags (chat/auto/dispatch):
|
|
91
|
+
- `--preset fast6|turbo6|balanced|quality`
|
|
92
|
+
- `--modefast6` shortcut for `fast6`
|
|
93
|
+
- `--new-task` (chat only) ignores pending clarification resume and starts fresh
|
|
94
|
+
|
|
95
|
+
Preset summary:
|
|
96
|
+
- `fast6`: 6 parallel workers, QA 2 rounds, no-router, speed-focused
|
|
97
|
+
- `turbo6`: 6 parallel workers, QA off, no-router, max throughput
|
|
98
|
+
- `balanced`: 4 workers, QA 1 round, no-router, mixed speed/quality
|
|
99
|
+
- `quality`: 3 workers, QA 2 rounds + stricter gates, no-router
|
|
100
|
+
|
|
101
|
+
## Diagnostics & Health
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
crew doctor # checks Node.js, Git, API keys, gateway, MCP, updates (~3s)
|
|
105
|
+
crew doctor --gateway http://custom:5010
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`crew doctor` validates your environment and suggests fixes:
|
|
109
|
+
- **API key detection** — shows which of 10 providers are configured
|
|
110
|
+
- **Cheapest-first hints** — when no keys found, recommends Gemini (free) and Groq (free)
|
|
111
|
+
- **Gateway health** — verifies crew-lead is reachable
|
|
112
|
+
- **MCP server health** — checks configured MCP servers
|
|
113
|
+
- **Update check** — shows if a newer version is available on npm
|
|
114
|
+
|
|
115
|
+
## Key Engine Features
|
|
116
|
+
|
|
117
|
+
| Feature | Status |
|
|
118
|
+
|---|---|
|
|
119
|
+
| **Streaming output** | ✅ All providers — Gemini, OpenAI, Anthropic, Grok, DeepSeek, Groq, OpenRouter |
|
|
120
|
+
| **Session continuity** | ✅ SessionManager persists history across REPL sessions |
|
|
121
|
+
| **Auto-approve mode** | ✅ `--always-approve` flag for unattended execution |
|
|
122
|
+
| **Turn compression** | ✅ Topic-Action-Summary keeps prompts lean on long sessions |
|
|
123
|
+
| **JIT context** | ✅ Files discovered by tools are indexed for subsequent turns |
|
|
124
|
+
| **Repo-map RAG** | ✅ TF-IDF semantic search injected before execution |
|
|
125
|
+
| **Auto-retry** | ✅ Failed tool calls retry up to 3 times with auto-correction |
|
|
126
|
+
| **Infinite loop detection** | ✅ Repeating-action detector stops stuck agents |
|
|
127
|
+
| **Multimodal vision** | ✅ `--image` flag for Gemini, Claude, GPT-4o, Grok Vision |
|
|
128
|
+
| **Cost tracking** | ✅ Per-session token costs for all providers |
|
|
129
|
+
|
|
130
|
+
Adaptive QA + reliability:
|
|
131
|
+
- `CREW_QA_SMALL_EDIT_THRESHOLD=1` and `CREW_QA_SMALL_EDIT_ROUNDS=1` reduce QA rounds for tiny edits
|
|
132
|
+
- `CREW_DECOMPOSE_MAX_ATTEMPTS=2` retries lightweight decomposition on failure
|
|
133
|
+
- `CREW_SELF_CONSISTENCY_GATE_ENABLED=true` validates synthesized final output against worker evidence
|
|
134
|
+
|
|
135
|
+
Standalone default:
|
|
136
|
+
- standalone mode now uses UnifiedPipeline by default.
|
|
137
|
+
- pass `--legacy-router` to any command for temporary legacy fallback.
|
|
138
|
+
|
|
139
|
+
## L1/L2/L3 Use Cases
|
|
140
|
+
|
|
141
|
+
- Use case 1 (Code engine path): command-driven execution (`dispatch`, `auto`, `run`) with full L2/L3 pipeline.
|
|
142
|
+
- Use case 2 (Chat-directed execution): user chats with L1 (`crew chat`), L2 decides/forces execution path, L3 runs workers/tools.
|
|
143
|
+
|
|
144
|
+
Clarification rule:
|
|
145
|
+
- L1 returns final completion when done.
|
|
146
|
+
- If L3 emits unresolved `ask_user`, L1 returns only clarification questions and waits for user input.
|
|
147
|
+
- Next `crew chat` message auto-resumes the pending trace using saved `traceId` and prior plan artifacts.
|
|
148
|
+
|
|
149
|
+
## Quick Benchmarking
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Compare latency/pass behavior of presets
|
|
153
|
+
node scripts/benchmark-presets.mjs
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`crew cost` now includes pipeline observability counters:
|
|
157
|
+
- `qa_approved`, `qa_rejected`, `qa_rounds_avg`
|
|
158
|
+
- `context_chunks_used`, `context_chars_saved_est`
|
|
159
|
+
|
|
160
|
+
## Context Flags
|
|
161
|
+
|
|
162
|
+
`chat` and `dispatch` accept these context injection flags:
|
|
163
|
+
|
|
164
|
+
- `--docs` — auto-retrieve relevant doc chunks via collections search
|
|
165
|
+
- `--cross-repo` — inject sibling repo context
|
|
166
|
+
- `--context-file <path>` — attach a file
|
|
167
|
+
- `--context-repo <path>` — attach git context from another repo
|
|
168
|
+
- `--stdin` — pipe stdin as context
|
|
169
|
+
|
|
170
|
+
## What Is Implemented
|
|
171
|
+
|
|
172
|
+
- Phase 1 (MVP): complete
|
|
173
|
+
- Phase 2 (Intelligence): complete
|
|
174
|
+
- Phase 3 (Polish/Launch): complete
|
|
175
|
+
- Phase 4 (Advanced): complete
|
|
176
|
+
- Phase 5 (3-Tier LLM Scale-Up): complete
|
|
177
|
+
|
|
178
|
+
See [ROADMAP.md](ROADMAP.md) for tracked completion.
|
|
179
|
+
|
|
180
|
+
## Testing
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npm run build
|
|
184
|
+
npm run check
|
|
185
|
+
npm test
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Latest local QA pass (2026-03-01):
|
|
189
|
+
- Build: passing
|
|
190
|
+
- Check: passing
|
|
191
|
+
- Tests: 178 passing, 0 failing
|
|
192
|
+
|
|
193
|
+
## Community
|
|
194
|
+
|
|
195
|
+
- 💬 [Join our Discord](https://discord.gg/crewswarm)
|
|
196
|
+
- 🐛 [Report a bug](https://github.com/crewswarm/crew-cli/issues)
|
|
197
|
+
- 💡 [Request a feature](https://github.com/crewswarm/crew-cli/discussions)
|
|
198
|
+
|
|
199
|
+
## Documentation
|
|
200
|
+
|
|
201
|
+
- [QUICKSTART.md](docs/QUICKSTART.md)
|
|
202
|
+
- [EXAMPLES.md](docs/EXAMPLES.md)
|
|
203
|
+
- [API.md](docs/API.md)
|
|
204
|
+
- [API-UNIFIED-v1.md](docs/API-UNIFIED-v1.md) — unified dashboard/CLI/headless contract
|
|
205
|
+
- [MCP-CLI-INTEGRATION.md](docs/MCP-CLI-INTEGRATION.md) — Codex/Cursor/Claude MCP setup
|
|
206
|
+
- [openapi.unified.v1.json](docs/openapi.unified.v1.json) — OpenAPI spec
|
|
207
|
+
- [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)
|
|
208
|
+
- [CONTRIBUTING.md](docs/CONTRIBUTING.md)
|
|
209
|
+
- [SECURITY.md](docs/SECURITY.md)
|
package/bin/crew.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
5
|
+
import { readFileSync, existsSync } from 'fs';
|
|
6
|
+
import { homedir } from 'os';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
|
|
12
|
+
// Load .env from crew-cli root (needed when spawned by studio or other processes)
|
|
13
|
+
const envPath = join(__dirname, '..', '.env');
|
|
14
|
+
if (existsSync(envPath)) {
|
|
15
|
+
for (const line of readFileSync(envPath, 'utf8').split('\n')) {
|
|
16
|
+
const trimmed = line.trim();
|
|
17
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
18
|
+
const eqIdx = trimmed.indexOf('=');
|
|
19
|
+
if (eqIdx > 0) {
|
|
20
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
21
|
+
const val = trimmed.slice(eqIdx + 1).trim();
|
|
22
|
+
if (!process.env[key]) process.env[key] = val;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Load API keys from ~/.crewswarm/crewswarm.json providers (only if not already set)
|
|
28
|
+
const swarmCfgPath = join(homedir(), '.crewswarm', 'crewswarm.json');
|
|
29
|
+
if (existsSync(swarmCfgPath)) {
|
|
30
|
+
try {
|
|
31
|
+
const cfg = JSON.parse(readFileSync(swarmCfgPath, 'utf8'));
|
|
32
|
+
const providers = cfg?.providers || {};
|
|
33
|
+
const keyMap = {
|
|
34
|
+
groq: 'GROQ_API_KEY',
|
|
35
|
+
xai: 'XAI_API_KEY',
|
|
36
|
+
google: 'GOOGLE_API_KEY',
|
|
37
|
+
gemini: 'GEMINI_API_KEY',
|
|
38
|
+
anthropic: 'ANTHROPIC_API_KEY',
|
|
39
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
40
|
+
openai: 'OPENAI_API_KEY',
|
|
41
|
+
mistral: 'MISTRAL_API_KEY',
|
|
42
|
+
};
|
|
43
|
+
for (const [provider, envVar] of Object.entries(keyMap)) {
|
|
44
|
+
const key = providers[provider]?.apiKey;
|
|
45
|
+
if (key && !process.env[envVar]) process.env[envVar] = key;
|
|
46
|
+
}
|
|
47
|
+
// Also load env block (CREW_CHAT_MODEL, CREW_EXECUTION_MODEL, etc.)
|
|
48
|
+
const envBlock = cfg?.env || {};
|
|
49
|
+
for (const [k, v] of Object.entries(envBlock)) {
|
|
50
|
+
if (v != null && v !== '' && !process.env[k]) process.env[k] = String(v);
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
// Non-fatal: config may be malformed or missing
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Fast path for --version/-V so lightweight checks do not slow/flake CLI version output.
|
|
58
|
+
if (args.length === 1 && (args[0] === '--version' || args[0] === '-V')) {
|
|
59
|
+
const pkgPath = join(__dirname, '..', 'package.json');
|
|
60
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
61
|
+
console.log(pkg.version || '0.0.0');
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Fast path for top-level help used by smoke/integration checks.
|
|
66
|
+
if (args.length === 1 && (args[0] === '--help' || args[0] === '-h')) {
|
|
67
|
+
console.log(`Usage: crew [options] [command]
|
|
68
|
+
|
|
69
|
+
Commands:
|
|
70
|
+
chat Chat with CrewSwarm (routed to best agent)
|
|
71
|
+
auto Autonomous mode (iterate until done)
|
|
72
|
+
exec Execute a task directly
|
|
73
|
+
repl Interactive REPL session
|
|
74
|
+
diff Show colored git diff
|
|
75
|
+
validate Blind AI code review
|
|
76
|
+
test-first TDD: tests -> implement -> validate
|
|
77
|
+
plan Plan a task
|
|
78
|
+
doctor Health check
|
|
79
|
+
|
|
80
|
+
Options:
|
|
81
|
+
-h, --help display help for command
|
|
82
|
+
-V, --version output the version number`);
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
(async () => {
|
|
87
|
+
try {
|
|
88
|
+
const { main } = await import('../dist/crew.mjs');
|
|
89
|
+
await main(args);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('Error:', error.message);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
})();
|