@ctxthuta/cxops 1.0.1 → 1.0.3

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/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
 
@@ -18,6 +19,36 @@ const VERIFY_SCRIPT = path.join(ROOT_DIR, 'verify_agents.py');
18
19
  const DASHBOARD_SCRIPT = path.join(ROOT_DIR, 'src', 'dashboard.py');
19
20
  const MAIN_SCRIPT = path.join(ROOT_DIR, 'src', 'main.py');
20
21
 
22
+ function loadEnvFile() {
23
+ const candidatePaths = [
24
+ path.join(process.cwd(), '.env'),
25
+ path.join(ROOT_DIR, '.env'),
26
+ path.join(os.homedir(), '.cortexops', '.env'),
27
+ ];
28
+
29
+ for (const envPath of candidatePaths) {
30
+ if (fs.existsSync(envPath)) {
31
+ try {
32
+ const content = fs.readFileSync(envPath, 'utf-8');
33
+ for (const line of content.split(/\r?\n/)) {
34
+ const trimmed = line.trim();
35
+ if (!trimmed || trimmed.startsWith('#')) continue;
36
+ const eqIdx = trimmed.indexOf('=');
37
+ if (eqIdx !== -1) {
38
+ const key = trimmed.substring(0, eqIdx).trim();
39
+ const val = trimmed.substring(eqIdx + 1).trim();
40
+ if (key && !(key in process.env)) {
41
+ process.env[key] = val;
42
+ }
43
+ }
44
+ }
45
+ } catch (_) {}
46
+ }
47
+ }
48
+ }
49
+
50
+ loadEnvFile();
51
+
21
52
  function getVenvPython() {
22
53
  const isWin = process.platform === 'win32';
23
54
  const venvPython = isWin
@@ -142,6 +173,7 @@ function unlinkPlugin() {
142
173
  }
143
174
 
144
175
  function executePythonScript(scriptPath, args = []) {
176
+ loadEnvFile();
145
177
  const python = getVenvPython();
146
178
  if (!python) {
147
179
  console.error('[ERROR] Python 3 not detected. Please install Python 3.10+ and run: cxops setup');
@@ -196,20 +228,30 @@ async function runSetup() {
196
228
  const keyInput = await rl.question(' Enter your GEMINI_API_KEY: ');
197
229
  const cleanKey = keyInput.trim().replace(/[\r\n]/g, '');
198
230
  if (cleanKey) {
199
- const envPath = path.join(ROOT_DIR, '.env');
200
- let content = '';
201
- if (fs.existsSync(envPath)) {
202
- content = fs.readFileSync(envPath, 'utf-8');
203
- if (content.includes('GEMINI_API_KEY=')) {
204
- content = content.replace(/GEMINI_API_KEY=.*(\r?\n|$)/g, `GEMINI_API_KEY=${cleanKey}\n`);
231
+ const savePaths = [
232
+ path.join(ROOT_DIR, '.env'),
233
+ path.join(os.homedir(), '.cortexops', '.env'),
234
+ ];
235
+ for (const envPath of savePaths) {
236
+ const envDir = path.dirname(envPath);
237
+ if (!fs.existsSync(envDir)) {
238
+ fs.mkdirSync(envDir, { recursive: true });
239
+ }
240
+ let content = '';
241
+ if (fs.existsSync(envPath)) {
242
+ content = fs.readFileSync(envPath, 'utf-8');
243
+ if (content.includes('GEMINI_API_KEY=')) {
244
+ content = content.replace(/GEMINI_API_KEY=.*(\r?\n|$)/g, `GEMINI_API_KEY=${cleanKey}\n`);
245
+ } else {
246
+ content += (content.endsWith('\n') ? '' : '\n') + `GEMINI_API_KEY=${cleanKey}\n`;
247
+ }
205
248
  } else {
206
- content += (content.endsWith('\n') ? '' : '\n') + `GEMINI_API_KEY=${cleanKey}\n`;
249
+ content = `GEMINI_API_KEY=${cleanKey}\n`;
207
250
  }
208
- } else {
209
- content = `GEMINI_API_KEY=${cleanKey}\n`;
251
+ fs.writeFileSync(envPath, content, { mode: 0o600 });
252
+ console.log(` * Saved GEMINI_API_KEY to ${envPath} (mode 0600)`);
210
253
  }
211
- fs.writeFileSync(envPath, content, { mode: 0o600 });
212
- console.log(` * Saved GEMINI_API_KEY to ${envPath} (mode 0600)`);
254
+ process.env.GEMINI_API_KEY = cleanKey;
213
255
  }
214
256
  } else {
215
257
  console.log(' * Skipping API key. Antigravity IDE sessions will use existing authenticated session.');
@@ -358,6 +400,82 @@ function runDoctor() {
358
400
  console.log('='.repeat(70));
359
401
  }
360
402
 
403
+ function getPackageVersion() {
404
+ try {
405
+ const pkgPath = path.join(ROOT_DIR, 'package.json');
406
+ if (fs.existsSync(pkgPath)) {
407
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
408
+ return pkg.version || '1.0.3';
409
+ }
410
+ } catch (_) {}
411
+ return '1.0.3';
412
+ }
413
+
414
+ function fetchLatestNpmVersion() {
415
+ return new Promise((resolve) => {
416
+ const req = https.get('https://registry.npmjs.org/@ctxthuta%2Fcxops/latest', {
417
+ headers: { 'User-Agent': 'cxops-cli' },
418
+ timeout: 2500,
419
+ }, (res) => {
420
+ if (res.statusCode !== 200) {
421
+ resolve(null);
422
+ return;
423
+ }
424
+ let data = '';
425
+ res.on('data', chunk => data += chunk);
426
+ res.on('end', () => {
427
+ try {
428
+ const parsed = JSON.parse(data);
429
+ resolve(parsed.version || null);
430
+ } catch (_) {
431
+ resolve(null);
432
+ }
433
+ });
434
+ });
435
+ req.on('error', () => resolve(null));
436
+ req.on('timeout', () => {
437
+ req.destroy();
438
+ resolve(null);
439
+ });
440
+ });
441
+ }
442
+
443
+ async function runVersion(detailed = false) {
444
+ const currentVer = getPackageVersion();
445
+ if (!detailed) {
446
+ console.log(`@ctxthuta/cxops v${currentVer}`);
447
+ return;
448
+ }
449
+
450
+ console.log('='.repeat(70));
451
+ console.log(`CORTEXOPS FRAMEWORK VERSION: v${currentVer}`);
452
+ console.log('='.repeat(70));
453
+ console.log(`Package Name: @ctxthuta/cxops`);
454
+ console.log(`Current Version: v${currentVer}`);
455
+ console.log(`Node.js Runtime: ${process.version}`);
456
+ console.log(`Platform: ${process.platform} (${process.arch})`);
457
+
458
+ const py = getVenvPython();
459
+ if (py) {
460
+ const pyVer = spawnSync(py, ['--version'], { encoding: 'utf-8' }).stdout.trim();
461
+ console.log(`Python Runtime: ${pyVer}`);
462
+ }
463
+
464
+ process.stdout.write('Checking npm registry for updates... ');
465
+ const latest = await fetchLatestNpmVersion();
466
+ if (latest) {
467
+ if (latest === currentVer) {
468
+ console.log(`[UP TO DATE] (v${latest} is latest)`);
469
+ } else {
470
+ console.log(`[UPDATE AVAILABLE] (Latest: v${latest})`);
471
+ console.log(`Run "npm install -g @ctxthuta/cxops@latest" to upgrade.`);
472
+ }
473
+ } else {
474
+ console.log('[SKIPPED] (Offline or registry unreachable)');
475
+ }
476
+ console.log('='.repeat(70));
477
+ }
478
+
361
479
  function printHelp() {
362
480
  console.log(`CortexOps Multi-Agent Framework CLI
363
481
 
@@ -371,6 +489,7 @@ Commands:
371
489
  watch Continuously monitor the dashboard (auto-refresh)
372
490
  verify Verify all 12 declarative subagent definitions
373
491
  run "<prompt>" Dispatch an autonomous multi-agent task via Python SDK
492
+ version, -v, --version Display framework version and check for updates
374
493
  link Link Antigravity global plugin symlink/junction
375
494
  unlink Remove Antigravity global plugin symlink/junction
376
495
  help, --help, -h Display this command reference
@@ -405,6 +524,13 @@ async function main() {
405
524
  case 'verify':
406
525
  executePythonScript(VERIFY_SCRIPT, args.slice(1));
407
526
  break;
527
+ case 'version':
528
+ case '--version':
529
+ case '-v':
530
+ case '-version':
531
+ const isDetailed = command === 'version' || args.includes('--check') || args.includes('-c');
532
+ await runVersion(isDetailed);
533
+ break;
408
534
  case 'run':
409
535
  if (args.length < 2) {
410
536
  console.error('[ERROR] Task prompt required. Usage: cxops run "<prompt>"');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctxthuta/cxops",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "CortexOps Multi-Agent Framework: Autonomous engineering and research operating system for Google Antigravity and Python SDK.",
5
5
  "main": "bin/cxops.js",
6
6
  "bin": {
@@ -14,7 +14,8 @@
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",
package/src/main.py CHANGED
@@ -1,18 +1,43 @@
1
1
  """CLI Entrypoint for CortexOps Multi-Agent Framework."""
2
2
 
3
3
  import asyncio
4
- import sys
5
4
  import os
5
+ import sys
6
6
  from pathlib import Path
7
7
 
8
8
  REPO_ROOT = Path(__file__).resolve().parent.parent
9
9
  if str(REPO_ROOT) not in sys.path:
10
10
  sys.path.insert(0, str(REPO_ROOT))
11
11
 
12
+ def load_environment() -> None:
13
+ """Discovers and loads environment variables from candidate .env files."""
14
+ candidate_paths = [
15
+ Path.cwd() / ".env",
16
+ REPO_ROOT / ".env",
17
+ Path.home() / ".cortexops" / ".env",
18
+ ]
19
+ for env_path in candidate_paths:
20
+ if env_path.is_file():
21
+ try:
22
+ with open(env_path, "r", encoding="utf-8") as f:
23
+ for line in f:
24
+ line = line.strip()
25
+ if line and not line.startswith("#") and "=" in line:
26
+ key, val = line.split("=", 1)
27
+ key, val = key.strip(), val.strip()
28
+ if key and key not in os.environ:
29
+ os.environ[key] = val
30
+ except Exception:
31
+ pass
32
+
33
+ load_environment()
34
+
12
35
  from google.antigravity import Agent
13
36
  from src.team import create_cortexops_team
14
37
 
15
- async def run_task(prompt: str, model: str = "gemini-2.0-flash"):
38
+ DEFAULT_MODEL = os.environ.get("GEMINI_MODEL", "gemini-3.8-flash")
39
+
40
+ async def run_task(prompt: str, model: str = DEFAULT_MODEL):
16
41
  """Runs a complete software engineering or research lifecycle task with the CortexOps team."""
17
42
  config = create_cortexops_team(model=model)
18
43
 
package/src/team.py CHANGED
@@ -65,7 +65,7 @@ SENIOR CODING & HYGIENE INVARIANTS:
65
65
  - Deterministic gates over agent opinions: test exit code == 0 is required.
66
66
  """
67
67
 
68
- def create_cortexops_team(model: str = "gemini-2.0-flash") -> LocalAgentConfig:
68
+ def create_cortexops_team(model: str = "gemini-3.8-flash") -> LocalAgentConfig:
69
69
  """Assembles the CortexOps autonomous engineering and research team.
70
70
 
71
71
  The Root Agent acts as the Lead Technical Product Manager & Engineering Director,
@@ -120,6 +120,6 @@ def create_cortexops_team(model: str = "gemini-2.0-flash") -> LocalAgentConfig:
120
120
  system_instructions=LEAD_PM_DIRECTOR_INSTRUCTIONS,
121
121
  )
122
122
 
123
- def create_thea_engineering_team(model: str = "gemini-2.0-flash") -> LocalAgentConfig:
123
+ def create_thea_engineering_team(model: str = "gemini-3.8-flash") -> LocalAgentConfig:
124
124
  """Backwards compatibility alias for create_cortexops_team."""
125
125
  return create_cortexops_team(model=model)