@ctxthuta/cxops 1.0.2 → 1.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.
- package/README.md +18 -4
- package/bin/cxops.js +258 -58
- package/package.json +8 -3
- package/src/engines.py +178 -0
- package/src/main.py +89 -27
package/README.md
CHANGED
|
@@ -82,15 +82,29 @@ When working inside Google Antigravity (IDE or CLI):
|
|
|
82
82
|
- Subagents execute directly through Antigravity's authenticated session.
|
|
83
83
|
- Mention individual specialists directly (`@backend_engineer`, `@system_architect`, `@code_reviewer`), or mention `@cxagents` to mobilize the entire relevant team concurrently.
|
|
84
84
|
|
|
85
|
-
### Mode B: Standalone
|
|
85
|
+
### Mode B: Standalone Multi-Engine Framework (Terminal / CI / Headless)
|
|
86
86
|
When running outside Antigravity as an automated background process:
|
|
87
|
-
- Configure your
|
|
87
|
+
- Configure your preferred engine (default: `antigravity`):
|
|
88
88
|
```bash
|
|
89
|
+
# Antigravity (Google DeepMind SDK, default)
|
|
89
90
|
export GEMINI_API_KEY="your-gemini-api-key"
|
|
91
|
+
|
|
92
|
+
# Claude (Anthropic)
|
|
93
|
+
export ANTHROPIC_API_KEY="your-anthropic-api-key"
|
|
94
|
+
|
|
95
|
+
# Codex (OpenAI)
|
|
96
|
+
export OPENAI_API_KEY="your-openai-api-key"
|
|
90
97
|
```
|
|
91
|
-
- Run tasks
|
|
98
|
+
- Run tasks with your preferred execution harness:
|
|
92
99
|
```bash
|
|
93
|
-
|
|
100
|
+
# Default Antigravity engine (Gemini 3.8 models)
|
|
101
|
+
cxops run "Research streaming anomaly detection and implement an in-memory detector with unit tests."
|
|
102
|
+
|
|
103
|
+
# Anthropic Claude engine (Claude 3.7 / 3.5 Sonnet)
|
|
104
|
+
cxops run -e claude "Design high-throughput event sourcing microservice."
|
|
105
|
+
|
|
106
|
+
# OpenAI Codex engine (GPT-4o / o3-mini)
|
|
107
|
+
cxops run -e codex "Generate relational PostgreSQL DDL with composite indexes."
|
|
94
108
|
```
|
|
95
109
|
|
|
96
110
|
---
|
package/bin/cxops.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const os = require('os');
|
|
11
|
+
const https = require('https');
|
|
11
12
|
const { spawn, spawnSync } = require('child_process');
|
|
12
13
|
const readline = require('readline/promises');
|
|
13
14
|
|
|
@@ -48,6 +49,53 @@ function loadEnvFile() {
|
|
|
48
49
|
|
|
49
50
|
loadEnvFile();
|
|
50
51
|
|
|
52
|
+
function saveEnvKey(key, value) {
|
|
53
|
+
const cleanKey = key.trim();
|
|
54
|
+
const cleanVal = (value || '').trim().replace(/[\r\n]/g, '');
|
|
55
|
+
const savePaths = [
|
|
56
|
+
path.join(ROOT_DIR, '.env'),
|
|
57
|
+
path.join(os.homedir(), '.cortexops', '.env'),
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
for (const envPath of savePaths) {
|
|
61
|
+
try {
|
|
62
|
+
const envDir = path.dirname(envPath);
|
|
63
|
+
if (!fs.existsSync(envDir)) {
|
|
64
|
+
fs.mkdirSync(envDir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
let content = '';
|
|
67
|
+
if (fs.existsSync(envPath)) {
|
|
68
|
+
content = fs.readFileSync(envPath, 'utf-8');
|
|
69
|
+
const regex = new RegExp(`^${cleanKey}=.*$`, 'm');
|
|
70
|
+
if (regex.test(content)) {
|
|
71
|
+
content = content.replace(regex, `${cleanKey}=${cleanVal}`);
|
|
72
|
+
} else {
|
|
73
|
+
content += (content.endsWith('\n') ? '' : '\n') + `${cleanKey}=${cleanVal}\n`;
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
content = `${cleanKey}=${cleanVal}\n`;
|
|
77
|
+
}
|
|
78
|
+
fs.writeFileSync(envPath, content, { mode: 0o600 });
|
|
79
|
+
} catch (_) {}
|
|
80
|
+
}
|
|
81
|
+
process.env[cleanKey] = cleanVal;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function normalizeEngine(input) {
|
|
85
|
+
if (!input) return null;
|
|
86
|
+
const clean = input.trim().toLowerCase();
|
|
87
|
+
if (['antigravity', 'gemini', 'ag'].includes(clean)) {
|
|
88
|
+
return 'antigravity';
|
|
89
|
+
}
|
|
90
|
+
if (['claude', 'anthropic'].includes(clean)) {
|
|
91
|
+
return 'claude';
|
|
92
|
+
}
|
|
93
|
+
if (['codex', 'openai', 'chatgpt'].includes(clean)) {
|
|
94
|
+
return 'codex';
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
51
99
|
function getVenvPython() {
|
|
52
100
|
const isWin = process.platform === 'win32';
|
|
53
101
|
const venvPython = isWin
|
|
@@ -217,53 +265,75 @@ async function runSetup() {
|
|
|
217
265
|
console.log(' Warning: Python 3.10+ is required for subagents and telemetry.');
|
|
218
266
|
}
|
|
219
267
|
|
|
220
|
-
console.log('\n[2]
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
content += (content.endsWith('\n') ? '' : '\n') + `GEMINI_API_KEY=${cleanKey}\n`;
|
|
246
|
-
}
|
|
247
|
-
} else {
|
|
248
|
-
content = `GEMINI_API_KEY=${cleanKey}\n`;
|
|
249
|
-
}
|
|
250
|
-
fs.writeFileSync(envPath, content, { mode: 0o600 });
|
|
251
|
-
console.log(` * Saved GEMINI_API_KEY to ${envPath} (mode 0600)`);
|
|
268
|
+
console.log('\n[2] Execution Engine & Platform Selection:');
|
|
269
|
+
const defaultEngine = (process.env.CORTEXOPS_ENGINE || 'antigravity').toLowerCase();
|
|
270
|
+
console.log(' Available Execution Harnesses:');
|
|
271
|
+
console.log(' - antigravity: Google Antigravity SDK with Gemini 3.8 models (Default)');
|
|
272
|
+
console.log(' - claude: Anthropic Claude models (Claude 3.7 / 3.5 Sonnet)');
|
|
273
|
+
console.log(' - codex: OpenAI Codex / GPT-4o / o3-mini models');
|
|
274
|
+
|
|
275
|
+
const enginePrompt = await rl.question(` Select default engine [antigravity | claude | codex] (default: ${defaultEngine}): `);
|
|
276
|
+
const resolvedEngine = normalizeEngine(enginePrompt) || defaultEngine || 'antigravity';
|
|
277
|
+
saveEnvKey('CORTEXOPS_ENGINE', resolvedEngine);
|
|
278
|
+
console.log(` * Configured execution engine: ${resolvedEngine}`);
|
|
279
|
+
|
|
280
|
+
console.log('\n[3] Authentication & API Keys:');
|
|
281
|
+
if (resolvedEngine === 'antigravity') {
|
|
282
|
+
const existingKey = process.env.GEMINI_API_KEY;
|
|
283
|
+
if (existingKey) {
|
|
284
|
+
console.log(' * GEMINI_API_KEY is already configured.');
|
|
285
|
+
} else {
|
|
286
|
+
const hasKey = await rl.question(' Configure GEMINI_API_KEY for Antigravity engine? (y/n) [y]: ');
|
|
287
|
+
if (hasKey.trim().toLowerCase() !== 'n') {
|
|
288
|
+
const keyInput = await rl.question(' Enter your GEMINI_API_KEY: ');
|
|
289
|
+
const cleanKey = keyInput.trim().replace(/[\r\n]/g, '');
|
|
290
|
+
if (cleanKey) {
|
|
291
|
+
saveEnvKey('GEMINI_API_KEY', cleanKey);
|
|
292
|
+
console.log(' * Saved GEMINI_API_KEY to configuration files (mode 0600)');
|
|
252
293
|
}
|
|
253
|
-
|
|
294
|
+
} else {
|
|
295
|
+
console.log(' * Skipping API key. Antigravity IDE sessions will authenticate automatically.');
|
|
254
296
|
}
|
|
297
|
+
}
|
|
298
|
+
} else if (resolvedEngine === 'claude') {
|
|
299
|
+
const existingKey = process.env.ANTHROPIC_API_KEY;
|
|
300
|
+
if (existingKey) {
|
|
301
|
+
console.log(' * ANTHROPIC_API_KEY is already configured.');
|
|
255
302
|
} else {
|
|
256
|
-
|
|
303
|
+
const hasKey = await rl.question(' Configure ANTHROPIC_API_KEY for Claude engine? (y/n) [y]: ');
|
|
304
|
+
if (hasKey.trim().toLowerCase() !== 'n') {
|
|
305
|
+
const keyInput = await rl.question(' Enter your ANTHROPIC_API_KEY: ');
|
|
306
|
+
const cleanKey = keyInput.trim().replace(/[\r\n]/g, '');
|
|
307
|
+
if (cleanKey) {
|
|
308
|
+
saveEnvKey('ANTHROPIC_API_KEY', cleanKey);
|
|
309
|
+
console.log(' * Saved ANTHROPIC_API_KEY to configuration files (mode 0600)');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
} else if (resolvedEngine === 'codex') {
|
|
314
|
+
const existingKey = process.env.OPENAI_API_KEY;
|
|
315
|
+
if (existingKey) {
|
|
316
|
+
console.log(' * OPENAI_API_KEY is already configured.');
|
|
317
|
+
} else {
|
|
318
|
+
const hasKey = await rl.question(' Configure OPENAI_API_KEY for Codex engine? (y/n) [y]: ');
|
|
319
|
+
if (hasKey.trim().toLowerCase() !== 'n') {
|
|
320
|
+
const keyInput = await rl.question(' Enter your OPENAI_API_KEY: ');
|
|
321
|
+
const cleanKey = keyInput.trim().replace(/[\r\n]/g, '');
|
|
322
|
+
if (cleanKey) {
|
|
323
|
+
saveEnvKey('OPENAI_API_KEY', cleanKey);
|
|
324
|
+
console.log(' * Saved OPENAI_API_KEY to configuration files (mode 0600)');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
257
327
|
}
|
|
258
328
|
}
|
|
259
329
|
|
|
260
|
-
console.log('\n[
|
|
330
|
+
console.log('\n[4] Antigravity Global Plugin Registration:');
|
|
261
331
|
const linkChoice = await rl.question(' Register CortexOps global plugin for Antigravity sessions? (y/n) [y]: ');
|
|
262
332
|
if (linkChoice.trim().toLowerCase() !== 'n') {
|
|
263
333
|
linkPlugin();
|
|
264
334
|
}
|
|
265
335
|
|
|
266
|
-
console.log('\n[
|
|
336
|
+
console.log('\n[5] Second Brain Integration (ThutaCortex):');
|
|
267
337
|
const defaultVault = path.join(os.homedir(), 'Documents', 'ThutaCortex');
|
|
268
338
|
const vaultChoice = await rl.question(` ThutaCortex vault path [${defaultVault}]: `);
|
|
269
339
|
const resolvedVault = vaultChoice.trim() || defaultVault;
|
|
@@ -275,7 +345,7 @@ async function runSetup() {
|
|
|
275
345
|
console.log(' The framework will operate in local-only mode until the vault is initialized.');
|
|
276
346
|
}
|
|
277
347
|
|
|
278
|
-
console.log('\n[
|
|
348
|
+
console.log('\n[6] Python Virtual Environment & Dependencies:');
|
|
279
349
|
const venvDir = path.join(ROOT_DIR, '.venv');
|
|
280
350
|
if (fs.existsSync(venvDir)) {
|
|
281
351
|
console.log(' * Virtual environment already exists at .venv/');
|
|
@@ -302,7 +372,7 @@ async function runSetup() {
|
|
|
302
372
|
}
|
|
303
373
|
}
|
|
304
374
|
|
|
305
|
-
console.log('\n[
|
|
375
|
+
console.log('\n[7] Subagent Definition Verification:');
|
|
306
376
|
const py = getVenvPython();
|
|
307
377
|
if (py && fs.existsSync(VERIFY_SCRIPT)) {
|
|
308
378
|
spawnSync(py, [VERIFY_SCRIPT], { stdio: 'inherit', env: { ...process.env, PYTHONPATH: ROOT_DIR } });
|
|
@@ -310,10 +380,12 @@ async function runSetup() {
|
|
|
310
380
|
|
|
311
381
|
console.log('\n' + '='.repeat(70));
|
|
312
382
|
console.log('Setup complete. You can now use:');
|
|
313
|
-
console.log(' cxops status Display
|
|
383
|
+
console.log(' cxops status Display operational & token telemetry dashboard');
|
|
314
384
|
console.log(' cxops watch Continuously monitor the live dashboard');
|
|
315
385
|
console.log(' cxops verify Verify all 12 subagent definitions');
|
|
316
|
-
console.log(' cxops run "<goal>" Dispatch autonomous tasks
|
|
386
|
+
console.log(' cxops run "<goal>" Dispatch autonomous tasks (Default: antigravity)');
|
|
387
|
+
console.log(' cxops run -e claude "<goal>" Dispatch tasks using Claude');
|
|
388
|
+
console.log(' cxops run -e codex "<goal>" Dispatch tasks using Codex');
|
|
317
389
|
console.log('='.repeat(70));
|
|
318
390
|
} finally {
|
|
319
391
|
rl.close();
|
|
@@ -348,6 +420,44 @@ function runDoctor() {
|
|
|
348
420
|
console.log('[WARN] Virtual Environment: .venv not found. Run "cxops setup" to create.');
|
|
349
421
|
}
|
|
350
422
|
|
|
423
|
+
// Execution engine configuration
|
|
424
|
+
const activeEngine = (process.env.CORTEXOPS_ENGINE || 'antigravity').toLowerCase();
|
|
425
|
+
const isDefaultEngine = !process.env.CORTEXOPS_ENGINE || activeEngine === 'antigravity';
|
|
426
|
+
console.log(`[PASS] Execution Engine: ${activeEngine} ${isDefaultEngine ? '(Default)' : ''}`);
|
|
427
|
+
|
|
428
|
+
// Engine-specific authentication diagnostics
|
|
429
|
+
const geminiKey = process.env.GEMINI_API_KEY;
|
|
430
|
+
const anthropicKey = process.env.ANTHROPIC_API_KEY;
|
|
431
|
+
const openaiKey = process.env.OPENAI_API_KEY;
|
|
432
|
+
|
|
433
|
+
if (activeEngine === 'antigravity') {
|
|
434
|
+
if (geminiKey) {
|
|
435
|
+
console.log('[PASS] Antigravity Auth: GEMINI_API_KEY is configured.');
|
|
436
|
+
} else {
|
|
437
|
+
console.log('[INFO] Antigravity Auth: GEMINI_API_KEY not in environment. Antigravity IDE sessions will authenticate automatically.');
|
|
438
|
+
}
|
|
439
|
+
} else if (activeEngine === 'claude') {
|
|
440
|
+
if (anthropicKey) {
|
|
441
|
+
console.log('[PASS] Claude Auth: ANTHROPIC_API_KEY is configured.');
|
|
442
|
+
} else {
|
|
443
|
+
console.log('[WARN] Claude Auth: ANTHROPIC_API_KEY not configured. Run "cxops setup" to set.');
|
|
444
|
+
}
|
|
445
|
+
} else if (activeEngine === 'codex') {
|
|
446
|
+
if (openaiKey) {
|
|
447
|
+
console.log('[PASS] Codex Auth: OPENAI_API_KEY is configured.');
|
|
448
|
+
} else {
|
|
449
|
+
console.log('[WARN] Codex Auth: OPENAI_API_KEY not configured. Run "cxops setup" to set.');
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const secondaryKeys = [];
|
|
454
|
+
if (activeEngine !== 'antigravity' && geminiKey) secondaryKeys.push('GEMINI_API_KEY');
|
|
455
|
+
if (activeEngine !== 'claude' && anthropicKey) secondaryKeys.push('ANTHROPIC_API_KEY');
|
|
456
|
+
if (activeEngine !== 'codex' && openaiKey) secondaryKeys.push('OPENAI_API_KEY');
|
|
457
|
+
if (secondaryKeys.length > 0) {
|
|
458
|
+
console.log(`[PASS] Additional Keys Configured: ${secondaryKeys.join(', ')}`);
|
|
459
|
+
}
|
|
460
|
+
|
|
351
461
|
// Antigravity global plugin link status
|
|
352
462
|
const { targets } = getPluginTargets();
|
|
353
463
|
let linkFound = false;
|
|
@@ -381,14 +491,6 @@ function runDoctor() {
|
|
|
381
491
|
console.log(`[INFO] ThutaCortex Second Brain: Not present at ${vaultPath} (Local fallback mode)`);
|
|
382
492
|
}
|
|
383
493
|
|
|
384
|
-
// Gemini API key authentication
|
|
385
|
-
const apiKey = process.env.GEMINI_API_KEY;
|
|
386
|
-
if (apiKey) {
|
|
387
|
-
console.log('[PASS] Authentication: GEMINI_API_KEY is configured.');
|
|
388
|
-
} else {
|
|
389
|
-
console.log('[INFO] Authentication: GEMINI_API_KEY not in environment. Antigravity IDE sessions will authenticate automatically.');
|
|
390
|
-
}
|
|
391
|
-
|
|
392
494
|
// Subagent declarative definitions check
|
|
393
495
|
const pluginAgentsDir = path.join(PLUGIN_SOURCE, 'agents');
|
|
394
496
|
if (fs.existsSync(pluginAgentsDir)) {
|
|
@@ -399,6 +501,86 @@ function runDoctor() {
|
|
|
399
501
|
console.log('='.repeat(70));
|
|
400
502
|
}
|
|
401
503
|
|
|
504
|
+
function getPackageVersion() {
|
|
505
|
+
try {
|
|
506
|
+
const pkgPath = path.join(ROOT_DIR, 'package.json');
|
|
507
|
+
if (fs.existsSync(pkgPath)) {
|
|
508
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
509
|
+
return pkg.version || '1.0.4';
|
|
510
|
+
}
|
|
511
|
+
} catch (_) {}
|
|
512
|
+
return '1.0.4';
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function fetchLatestNpmVersion() {
|
|
516
|
+
return new Promise((resolve) => {
|
|
517
|
+
const req = https.get('https://registry.npmjs.org/@ctxthuta%2Fcxops/latest', {
|
|
518
|
+
headers: { 'User-Agent': 'cxops-cli' },
|
|
519
|
+
timeout: 2500,
|
|
520
|
+
}, (res) => {
|
|
521
|
+
if (res.statusCode !== 200) {
|
|
522
|
+
resolve(null);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
let data = '';
|
|
526
|
+
res.on('data', chunk => data += chunk);
|
|
527
|
+
res.on('end', () => {
|
|
528
|
+
try {
|
|
529
|
+
const parsed = JSON.parse(data);
|
|
530
|
+
resolve(parsed.version || null);
|
|
531
|
+
} catch (_) {
|
|
532
|
+
resolve(null);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
req.on('error', () => resolve(null));
|
|
537
|
+
req.on('timeout', () => {
|
|
538
|
+
req.destroy();
|
|
539
|
+
resolve(null);
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
async function runVersion(detailed = false) {
|
|
545
|
+
const currentVer = getPackageVersion();
|
|
546
|
+
if (!detailed) {
|
|
547
|
+
console.log(`@ctxthuta/cxops v${currentVer}`);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const activeEngine = (process.env.CORTEXOPS_ENGINE || 'antigravity').toLowerCase();
|
|
552
|
+
const isDefaultEngine = !process.env.CORTEXOPS_ENGINE || activeEngine === 'antigravity';
|
|
553
|
+
|
|
554
|
+
console.log('='.repeat(70));
|
|
555
|
+
console.log(`CORTEXOPS FRAMEWORK VERSION: v${currentVer}`);
|
|
556
|
+
console.log('='.repeat(70));
|
|
557
|
+
console.log(`Package Name: @ctxthuta/cxops`);
|
|
558
|
+
console.log(`Current Version: v${currentVer}`);
|
|
559
|
+
console.log(`Active Engine: ${activeEngine} ${isDefaultEngine ? '(Default)' : ''}`);
|
|
560
|
+
console.log(`Node.js Runtime: ${process.version}`);
|
|
561
|
+
console.log(`Platform: ${process.platform} (${process.arch})`);
|
|
562
|
+
|
|
563
|
+
const py = getVenvPython();
|
|
564
|
+
if (py) {
|
|
565
|
+
const pyVer = spawnSync(py, ['--version'], { encoding: 'utf-8' }).stdout.trim();
|
|
566
|
+
console.log(`Python Runtime: ${pyVer}`);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
process.stdout.write('Checking npm registry for updates... ');
|
|
570
|
+
const latest = await fetchLatestNpmVersion();
|
|
571
|
+
if (latest) {
|
|
572
|
+
if (latest === currentVer) {
|
|
573
|
+
console.log(`[UP TO DATE] (v${latest} is latest)`);
|
|
574
|
+
} else {
|
|
575
|
+
console.log(`[UPDATE AVAILABLE] (Latest: v${latest})`);
|
|
576
|
+
console.log(`Run "npm install -g @ctxthuta/cxops@latest" to upgrade.`);
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
console.log('[SKIPPED] (Offline or registry unreachable)');
|
|
580
|
+
}
|
|
581
|
+
console.log('='.repeat(70));
|
|
582
|
+
}
|
|
583
|
+
|
|
402
584
|
function printHelp() {
|
|
403
585
|
console.log(`CortexOps Multi-Agent Framework CLI
|
|
404
586
|
|
|
@@ -406,15 +588,25 @@ Usage:
|
|
|
406
588
|
cxops [command]
|
|
407
589
|
|
|
408
590
|
Commands:
|
|
409
|
-
setup, init
|
|
410
|
-
doctor
|
|
411
|
-
status, dashboard
|
|
412
|
-
watch
|
|
413
|
-
verify
|
|
414
|
-
run "<prompt>"
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
591
|
+
setup, init Run interactive cross-platform setup wizard
|
|
592
|
+
doctor Run system diagnostics and prerequisite health check
|
|
593
|
+
status, dashboard Display operational & token telemetry dashboard
|
|
594
|
+
watch Continuously monitor the dashboard (auto-refresh)
|
|
595
|
+
verify Verify all 12 declarative subagent definitions
|
|
596
|
+
run [options] "<prompt>" Dispatch an autonomous multi-agent task via Python SDK
|
|
597
|
+
version, -v, --version Display framework version and check for updates
|
|
598
|
+
link Link Antigravity global plugin symlink/junction
|
|
599
|
+
unlink Remove Antigravity global plugin symlink/junction
|
|
600
|
+
help, --help, -h Display this command reference
|
|
601
|
+
|
|
602
|
+
Run Options:
|
|
603
|
+
-e, --engine <engine> Select execution harness: antigravity (default), claude, codex
|
|
604
|
+
-m, --model <model> Override model identifier for the selected engine
|
|
605
|
+
|
|
606
|
+
Supported Engines:
|
|
607
|
+
antigravity Google Antigravity SDK with Gemini 3.8 models (Default)
|
|
608
|
+
claude Anthropic Claude models (Claude 3.7 / 3.5 Sonnet)
|
|
609
|
+
codex OpenAI Codex / GPT-4o / o3-mini models
|
|
418
610
|
`);
|
|
419
611
|
}
|
|
420
612
|
|
|
@@ -446,9 +638,17 @@ async function main() {
|
|
|
446
638
|
case 'verify':
|
|
447
639
|
executePythonScript(VERIFY_SCRIPT, args.slice(1));
|
|
448
640
|
break;
|
|
641
|
+
case 'version':
|
|
642
|
+
case '--version':
|
|
643
|
+
case '-v':
|
|
644
|
+
case '-version':
|
|
645
|
+
const isDetailed = command === 'version' || args.includes('--check') || args.includes('-c');
|
|
646
|
+
await runVersion(isDetailed);
|
|
647
|
+
break;
|
|
449
648
|
case 'run':
|
|
450
649
|
if (args.length < 2) {
|
|
451
|
-
console.error('[ERROR] Task prompt required.
|
|
650
|
+
console.error('[ERROR] Task prompt required.');
|
|
651
|
+
console.error('Usage: cxops run [--engine antigravity|claude|codex] "<prompt>"');
|
|
452
652
|
process.exit(1);
|
|
453
653
|
}
|
|
454
654
|
executePythonScript(MAIN_SCRIPT, args.slice(1));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctxthuta/cxops",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "CortexOps Multi-Agent Framework: Autonomous engineering and research operating system for Google Antigravity and Python SDK.",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "CortexOps Multi-Agent Framework: Autonomous engineering and research operating system for Google Antigravity, Claude, and Codex with Python SDK.",
|
|
5
5
|
"main": "bin/cxops.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cxops": "bin/cxops.js",
|
|
@@ -14,12 +14,17 @@
|
|
|
14
14
|
"dashboard": "node ./bin/cxops.js dashboard",
|
|
15
15
|
"watch": "node ./bin/cxops.js watch",
|
|
16
16
|
"verify": "node ./bin/cxops.js verify",
|
|
17
|
-
"doctor": "node ./bin/cxops.js doctor"
|
|
17
|
+
"doctor": "node ./bin/cxops.js doctor",
|
|
18
|
+
"version": "node ./bin/cxops.js version"
|
|
18
19
|
},
|
|
19
20
|
"keywords": [
|
|
20
21
|
"cortexops",
|
|
21
22
|
"multi-agent",
|
|
22
23
|
"antigravity",
|
|
24
|
+
"claude",
|
|
25
|
+
"codex",
|
|
26
|
+
"openai",
|
|
27
|
+
"anthropic",
|
|
23
28
|
"subagents",
|
|
24
29
|
"aiops",
|
|
25
30
|
"orchestrator",
|
package/src/engines.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""CortexOps Multi-Engine Execution Dispatcher.
|
|
2
|
+
|
|
3
|
+
Provides polymorphic engine runners for Antigravity (default), Claude, and Codex.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
from abc import ABC, abstractmethod
|
|
10
|
+
from typing import Optional
|
|
11
|
+
import httpx
|
|
12
|
+
|
|
13
|
+
from src.team import LEAD_PM_DIRECTOR_INSTRUCTIONS, create_cortexops_team
|
|
14
|
+
|
|
15
|
+
DEFAULT_GEMINI_MODEL = os.environ.get("GEMINI_MODEL", "gemini-3.8-flash")
|
|
16
|
+
DEFAULT_CLAUDE_MODEL = os.environ.get("ANTHROPIC_MODEL", "claude-3-7-sonnet-20250219")
|
|
17
|
+
DEFAULT_CODEX_MODEL = os.environ.get("OPENAI_MODEL", "gpt-4o")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BaseEngine(ABC):
|
|
21
|
+
"""Abstract execution harness interface for CortexOps tasks."""
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
async def run(self, prompt: str, model: Optional[str] = None) -> None:
|
|
25
|
+
"""Executes the task prompt and streams the engineering outcome to stdout."""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AntigravityEngine(BaseEngine):
|
|
30
|
+
"""Native Google Antigravity SDK engine harness utilizing Gemini models."""
|
|
31
|
+
|
|
32
|
+
async def run(self, prompt: str, model: Optional[str] = None) -> None:
|
|
33
|
+
from google.antigravity import Agent
|
|
34
|
+
|
|
35
|
+
target_model = model or DEFAULT_GEMINI_MODEL
|
|
36
|
+
config = create_cortexops_team(model=target_model)
|
|
37
|
+
|
|
38
|
+
async with Agent(config) as team:
|
|
39
|
+
response = await team.chat(prompt)
|
|
40
|
+
async for chunk in response:
|
|
41
|
+
print(chunk, end="", flush=True)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ClaudeEngine(BaseEngine):
|
|
45
|
+
"""Anthropic Claude execution harness with real-time SSE streaming."""
|
|
46
|
+
|
|
47
|
+
async def run(self, prompt: str, model: Optional[str] = None) -> None:
|
|
48
|
+
api_key = os.environ.get("ANTHROPIC_API_KEY", "").strip()
|
|
49
|
+
if not api_key:
|
|
50
|
+
raise ValueError(
|
|
51
|
+
"ANTHROPIC_API_KEY is not configured.\n"
|
|
52
|
+
"Please set ANTHROPIC_API_KEY in your environment, .env file, or run 'cxops setup'."
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
target_model = model or DEFAULT_CLAUDE_MODEL
|
|
56
|
+
headers = {
|
|
57
|
+
"x-api-key": api_key,
|
|
58
|
+
"anthropic-version": "2023-06-01",
|
|
59
|
+
"content-type": "application/json",
|
|
60
|
+
}
|
|
61
|
+
payload = {
|
|
62
|
+
"model": target_model,
|
|
63
|
+
"max_tokens": 4096,
|
|
64
|
+
"system": LEAD_PM_DIRECTOR_INSTRUCTIONS,
|
|
65
|
+
"messages": [
|
|
66
|
+
{"role": "user", "content": prompt}
|
|
67
|
+
],
|
|
68
|
+
"stream": True,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async with httpx.AsyncClient(timeout=120.0) as client:
|
|
72
|
+
async with client.stream(
|
|
73
|
+
"POST",
|
|
74
|
+
"https://api.anthropic.com/v1/messages",
|
|
75
|
+
headers=headers,
|
|
76
|
+
json=payload
|
|
77
|
+
) as response:
|
|
78
|
+
if response.status_code != 200:
|
|
79
|
+
err_body = await response.aread()
|
|
80
|
+
sys.stderr.write(
|
|
81
|
+
f"[ERROR] Anthropic API returned HTTP {response.status_code}: "
|
|
82
|
+
f"{err_body.decode('utf-8', errors='replace')}\n"
|
|
83
|
+
)
|
|
84
|
+
sys.exit(1)
|
|
85
|
+
|
|
86
|
+
async for line in response.aiter_lines():
|
|
87
|
+
if line.startswith("data: "):
|
|
88
|
+
data_str = line[6:].strip()
|
|
89
|
+
if not data_str or data_str == "[DONE]":
|
|
90
|
+
continue
|
|
91
|
+
try:
|
|
92
|
+
event = json.loads(data_str)
|
|
93
|
+
if event.get("type") == "content_block_delta":
|
|
94
|
+
text = event.get("delta", {}).get("text", "")
|
|
95
|
+
print(text, end="", flush=True)
|
|
96
|
+
except json.JSONDecodeError:
|
|
97
|
+
pass
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class CodexEngine(BaseEngine):
|
|
101
|
+
"""OpenAI Codex / ChatGPT execution harness with real-time SSE streaming."""
|
|
102
|
+
|
|
103
|
+
async def run(self, prompt: str, model: Optional[str] = None) -> None:
|
|
104
|
+
api_key = os.environ.get("OPENAI_API_KEY", "").strip()
|
|
105
|
+
if not api_key:
|
|
106
|
+
raise ValueError(
|
|
107
|
+
"OPENAI_API_KEY is not configured.\n"
|
|
108
|
+
"Please set OPENAI_API_KEY in your environment, .env file, or run 'cxops setup'."
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
target_model = model or DEFAULT_CODEX_MODEL
|
|
112
|
+
headers = {
|
|
113
|
+
"Authorization": f"Bearer {api_key}",
|
|
114
|
+
"Content-Type": "application/json",
|
|
115
|
+
}
|
|
116
|
+
payload = {
|
|
117
|
+
"model": target_model,
|
|
118
|
+
"messages": [
|
|
119
|
+
{"role": "system", "content": LEAD_PM_DIRECTOR_INSTRUCTIONS},
|
|
120
|
+
{"role": "user", "content": prompt},
|
|
121
|
+
],
|
|
122
|
+
"stream": True,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async with httpx.AsyncClient(timeout=120.0) as client:
|
|
126
|
+
async with client.stream(
|
|
127
|
+
"POST",
|
|
128
|
+
"https://api.openai.com/v1/chat/completions",
|
|
129
|
+
headers=headers,
|
|
130
|
+
json=payload
|
|
131
|
+
) as response:
|
|
132
|
+
if response.status_code != 200:
|
|
133
|
+
err_body = await response.aread()
|
|
134
|
+
sys.stderr.write(
|
|
135
|
+
f"[ERROR] OpenAI API returned HTTP {response.status_code}: "
|
|
136
|
+
f"{err_body.decode('utf-8', errors='replace')}\n"
|
|
137
|
+
)
|
|
138
|
+
sys.exit(1)
|
|
139
|
+
|
|
140
|
+
async for line in response.aiter_lines():
|
|
141
|
+
if line.startswith("data: "):
|
|
142
|
+
data_str = line[6:].strip()
|
|
143
|
+
if not data_str or data_str == "[DONE]":
|
|
144
|
+
continue
|
|
145
|
+
try:
|
|
146
|
+
event = json.loads(data_str)
|
|
147
|
+
choices = event.get("choices", [])
|
|
148
|
+
if choices:
|
|
149
|
+
delta = choices[0].get("delta", {})
|
|
150
|
+
content = delta.get("content", "")
|
|
151
|
+
if content:
|
|
152
|
+
print(content, end="", flush=True)
|
|
153
|
+
except json.JSONDecodeError:
|
|
154
|
+
pass
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def resolve_engine(engine_name: Optional[str]) -> BaseEngine:
|
|
158
|
+
"""Normalizes and instantiates the target execution engine harness."""
|
|
159
|
+
normalized = (engine_name or "").strip().lower()
|
|
160
|
+
|
|
161
|
+
if normalized in ("claude", "anthropic"):
|
|
162
|
+
return ClaudeEngine()
|
|
163
|
+
if normalized in ("codex", "openai", "chatgpt"):
|
|
164
|
+
return CodexEngine()
|
|
165
|
+
|
|
166
|
+
return AntigravityEngine()
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def get_default_model(engine_name: str) -> str:
|
|
170
|
+
"""Returns the default model identifier for the selected engine harness."""
|
|
171
|
+
normalized = (engine_name or "").strip().lower()
|
|
172
|
+
|
|
173
|
+
if normalized in ("claude", "anthropic"):
|
|
174
|
+
return DEFAULT_CLAUDE_MODEL
|
|
175
|
+
if normalized in ("codex", "openai", "chatgpt"):
|
|
176
|
+
return DEFAULT_CODEX_MODEL
|
|
177
|
+
|
|
178
|
+
return DEFAULT_GEMINI_MODEL
|
package/src/main.py
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"""CLI Entrypoint for CortexOps Multi-Agent Framework."""
|
|
2
2
|
|
|
3
|
+
import argparse
|
|
3
4
|
import asyncio
|
|
4
5
|
import os
|
|
5
6
|
import sys
|
|
6
7
|
from pathlib import Path
|
|
8
|
+
from typing import Optional
|
|
7
9
|
|
|
8
10
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
9
11
|
if str(REPO_ROOT) not in sys.path:
|
|
10
12
|
sys.path.insert(0, str(REPO_ROOT))
|
|
11
13
|
|
|
14
|
+
|
|
12
15
|
def load_environment() -> None:
|
|
13
16
|
"""Discovers and loads environment variables from candidate .env files."""
|
|
14
17
|
candidate_paths = [
|
|
@@ -30,45 +33,104 @@ def load_environment() -> None:
|
|
|
30
33
|
except Exception:
|
|
31
34
|
pass
|
|
32
35
|
|
|
36
|
+
|
|
33
37
|
load_environment()
|
|
34
38
|
|
|
35
|
-
from
|
|
36
|
-
|
|
39
|
+
from src.engines import resolve_engine, get_default_model
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def parse_arguments():
|
|
43
|
+
"""Parses command-line arguments for engine, model, and task prompt."""
|
|
44
|
+
parser = argparse.ArgumentParser(
|
|
45
|
+
description="CortexOps Multi-Agent Framework Task Runner",
|
|
46
|
+
add_help=False,
|
|
47
|
+
)
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
"-e",
|
|
50
|
+
"--engine",
|
|
51
|
+
dest="engine",
|
|
52
|
+
default=os.environ.get("CORTEXOPS_ENGINE", "antigravity"),
|
|
53
|
+
help="Target execution harness: antigravity (default), claude, codex",
|
|
54
|
+
)
|
|
55
|
+
parser.add_argument(
|
|
56
|
+
"-m",
|
|
57
|
+
"--model",
|
|
58
|
+
dest="model",
|
|
59
|
+
default=None,
|
|
60
|
+
help="Model identifier override for selected execution engine",
|
|
61
|
+
)
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
"-h",
|
|
64
|
+
"--help",
|
|
65
|
+
action="help",
|
|
66
|
+
help="Display this task runner help reference and exit",
|
|
67
|
+
)
|
|
68
|
+
parser.add_argument(
|
|
69
|
+
"prompt",
|
|
70
|
+
nargs="*",
|
|
71
|
+
help="Engineering task prompt or project goal",
|
|
72
|
+
)
|
|
73
|
+
return parser.parse_args()
|
|
74
|
+
|
|
37
75
|
|
|
38
|
-
|
|
76
|
+
async def run_task(prompt: str, engine_name: str, model_override: Optional[str] = None):
|
|
77
|
+
"""Executes a complete engineering or research lifecycle task via the selected engine."""
|
|
78
|
+
engine = resolve_engine(engine_name)
|
|
79
|
+
resolved_model = model_override or get_default_model(engine_name)
|
|
80
|
+
normalized_engine = "antigravity"
|
|
81
|
+
if engine_name.lower() in ("claude", "anthropic"):
|
|
82
|
+
normalized_engine = "claude"
|
|
83
|
+
elif engine_name.lower() in ("codex", "openai", "chatgpt"):
|
|
84
|
+
normalized_engine = "codex"
|
|
85
|
+
|
|
86
|
+
engine_tag = normalized_engine.upper()
|
|
87
|
+
is_default = normalized_engine == "antigravity"
|
|
39
88
|
|
|
40
|
-
async def run_task(prompt: str, model: str = DEFAULT_MODEL):
|
|
41
|
-
"""Runs a complete software engineering or research lifecycle task with the CortexOps team."""
|
|
42
|
-
config = create_cortexops_team(model=model)
|
|
43
|
-
|
|
44
89
|
print("=" * 70)
|
|
45
|
-
print("CORTEXOPS MULTI-AGENT FRAMEWORK - ACTIVE")
|
|
90
|
+
print(f"CORTEXOPS MULTI-AGENT FRAMEWORK - ACTIVE [{engine_tag} ENGINE]")
|
|
46
91
|
print("Roles: TPM Director | Staff R&D | Principal Architect | UI/UX | Frontend | Backend | DevOps | ML | QA | Reviewer | Academic Researcher | Software Engineer | cxagents")
|
|
47
|
-
print(f"
|
|
48
|
-
print(f"
|
|
92
|
+
print(f"Engine: {normalized_engine} {'(Default)' if is_default else ''}")
|
|
93
|
+
print(f"Model: {resolved_model}")
|
|
94
|
+
print(f"Goal: {prompt}")
|
|
49
95
|
print("=" * 70 + "\n")
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
print("\n")
|
|
96
|
+
|
|
97
|
+
print("=" * 70)
|
|
98
|
+
print("ENGINEERING OUTCOME:")
|
|
99
|
+
print("=" * 70)
|
|
100
|
+
|
|
101
|
+
await engine.run(prompt=prompt, model=resolved_model)
|
|
102
|
+
print("\n")
|
|
103
|
+
|
|
59
104
|
|
|
60
105
|
def main():
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
106
|
+
args = parse_arguments()
|
|
107
|
+
prompt = " ".join(args.prompt).strip() if args.prompt else ""
|
|
108
|
+
|
|
109
|
+
if not prompt:
|
|
64
110
|
print("Enter the engineering project or feature request:")
|
|
65
|
-
|
|
66
|
-
|
|
111
|
+
try:
|
|
112
|
+
prompt = input("> ").strip()
|
|
113
|
+
except (KeyboardInterrupt, EOFError):
|
|
114
|
+
print("\nAborted.")
|
|
115
|
+
sys.exit(0)
|
|
116
|
+
|
|
67
117
|
if not prompt:
|
|
68
|
-
print("No task provided. Exiting.")
|
|
118
|
+
print("No task prompt provided. Exiting.")
|
|
119
|
+
sys.exit(1)
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
asyncio.run(run_task(
|
|
123
|
+
prompt=prompt,
|
|
124
|
+
engine_name=args.engine,
|
|
125
|
+
model_override=args.model,
|
|
126
|
+
))
|
|
127
|
+
except (ValueError, RuntimeError) as err:
|
|
128
|
+
sys.stderr.write(f"\n[ERROR] {err}\n")
|
|
69
129
|
sys.exit(1)
|
|
70
|
-
|
|
71
|
-
|
|
130
|
+
except KeyboardInterrupt:
|
|
131
|
+
print("\nOperation cancelled by user.")
|
|
132
|
+
sys.exit(0)
|
|
133
|
+
|
|
72
134
|
|
|
73
135
|
if __name__ == "__main__":
|
|
74
136
|
main()
|