@ctxthuta/cxops 1.0.1 → 1.0.2

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
@@ -18,6 +18,36 @@ const VERIFY_SCRIPT = path.join(ROOT_DIR, 'verify_agents.py');
18
18
  const DASHBOARD_SCRIPT = path.join(ROOT_DIR, 'src', 'dashboard.py');
19
19
  const MAIN_SCRIPT = path.join(ROOT_DIR, 'src', 'main.py');
20
20
 
21
+ function loadEnvFile() {
22
+ const candidatePaths = [
23
+ path.join(process.cwd(), '.env'),
24
+ path.join(ROOT_DIR, '.env'),
25
+ path.join(os.homedir(), '.cortexops', '.env'),
26
+ ];
27
+
28
+ for (const envPath of candidatePaths) {
29
+ if (fs.existsSync(envPath)) {
30
+ try {
31
+ const content = fs.readFileSync(envPath, 'utf-8');
32
+ for (const line of content.split(/\r?\n/)) {
33
+ const trimmed = line.trim();
34
+ if (!trimmed || trimmed.startsWith('#')) continue;
35
+ const eqIdx = trimmed.indexOf('=');
36
+ if (eqIdx !== -1) {
37
+ const key = trimmed.substring(0, eqIdx).trim();
38
+ const val = trimmed.substring(eqIdx + 1).trim();
39
+ if (key && !(key in process.env)) {
40
+ process.env[key] = val;
41
+ }
42
+ }
43
+ }
44
+ } catch (_) {}
45
+ }
46
+ }
47
+ }
48
+
49
+ loadEnvFile();
50
+
21
51
  function getVenvPython() {
22
52
  const isWin = process.platform === 'win32';
23
53
  const venvPython = isWin
@@ -142,6 +172,7 @@ function unlinkPlugin() {
142
172
  }
143
173
 
144
174
  function executePythonScript(scriptPath, args = []) {
175
+ loadEnvFile();
145
176
  const python = getVenvPython();
146
177
  if (!python) {
147
178
  console.error('[ERROR] Python 3 not detected. Please install Python 3.10+ and run: cxops setup');
@@ -196,20 +227,30 @@ async function runSetup() {
196
227
  const keyInput = await rl.question(' Enter your GEMINI_API_KEY: ');
197
228
  const cleanKey = keyInput.trim().replace(/[\r\n]/g, '');
198
229
  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`);
230
+ const savePaths = [
231
+ path.join(ROOT_DIR, '.env'),
232
+ path.join(os.homedir(), '.cortexops', '.env'),
233
+ ];
234
+ for (const envPath of savePaths) {
235
+ const envDir = path.dirname(envPath);
236
+ if (!fs.existsSync(envDir)) {
237
+ fs.mkdirSync(envDir, { recursive: true });
238
+ }
239
+ let content = '';
240
+ if (fs.existsSync(envPath)) {
241
+ content = fs.readFileSync(envPath, 'utf-8');
242
+ if (content.includes('GEMINI_API_KEY=')) {
243
+ content = content.replace(/GEMINI_API_KEY=.*(\r?\n|$)/g, `GEMINI_API_KEY=${cleanKey}\n`);
244
+ } else {
245
+ content += (content.endsWith('\n') ? '' : '\n') + `GEMINI_API_KEY=${cleanKey}\n`;
246
+ }
205
247
  } else {
206
- content += (content.endsWith('\n') ? '' : '\n') + `GEMINI_API_KEY=${cleanKey}\n`;
248
+ content = `GEMINI_API_KEY=${cleanKey}\n`;
207
249
  }
208
- } else {
209
- content = `GEMINI_API_KEY=${cleanKey}\n`;
250
+ fs.writeFileSync(envPath, content, { mode: 0o600 });
251
+ console.log(` * Saved GEMINI_API_KEY to ${envPath} (mode 0600)`);
210
252
  }
211
- fs.writeFileSync(envPath, content, { mode: 0o600 });
212
- console.log(` * Saved GEMINI_API_KEY to ${envPath} (mode 0600)`);
253
+ process.env.GEMINI_API_KEY = cleanKey;
213
254
  }
214
255
  } else {
215
256
  console.log(' * Skipping API key. Antigravity IDE sessions will use existing authenticated session.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctxthuta/cxops",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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": {
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)