@gokulvenkatareddy/cortex 0.1.9 → 0.1.11

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.
Files changed (3) hide show
  1. package/bin/cortex +25 -44
  2. package/dist/cli.mjs +30 -22
  3. package/package.json +1 -1
package/bin/cortex CHANGED
@@ -1,19 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * CORTEX — Global CLI entry point
4
- *
5
- * Works anywhere even when installed via:
6
- * npm install -g @gokulvenkatareddy/cortex
7
- * npx @gokulvenkatareddy/cortex
8
- *
9
- * Config lives in ~/.cortex/.env (the user's machine, NOT this package).
10
- * API keys are NEVER stored in the npm package folder.
4
+ * Works anywhere: npm install -g @gokulvenkatareddy/cortex
5
+ * Config lives in ~/.cortex/.env
11
6
  */
12
7
 
13
8
  import { execFileSync, spawn } from 'child_process';
14
- import * as fs from 'fs';
15
- import * as os from 'os';
16
- import * as path from 'path';
9
+ import fs from 'fs';
10
+ import os from 'os';
11
+ import path from 'path';
17
12
  import { fileURLToPath } from 'url';
18
13
 
19
14
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -21,89 +16,75 @@ const ROOT = path.resolve(__dirname, '..');
21
16
  const CLI_PATH = path.join(ROOT, 'dist', 'cli.mjs');
22
17
  const WIZARD = path.join(ROOT, 'scripts', 'setup-wizard.ts');
23
18
 
24
- // Config lives in the user's home dir, NOT the package folder
25
19
  const CONFIG_DIR = path.join(os.homedir(), '.cortex');
26
20
  const CONFIG_ENV = path.join(CONFIG_DIR, '.env');
27
21
 
28
22
  const args = process.argv.slice(2);
29
23
 
30
- // ─── Load ~/.cortex/.env into the environment ──────────────────────────────
31
24
  function loadUserConfig() {
32
25
  if (!fs.existsSync(CONFIG_ENV)) return {};
33
- const lines = fs.readFileSync(CONFIG_ENV, 'utf8').split('\n');
34
- const env = {};
35
- for (const line of lines) {
36
- const m = line.match(/^([A-Z_]+)=(.+)$/);
37
- if (m) env[m[1]] = m[2];
26
+ var lines = fs.readFileSync(CONFIG_ENV, 'utf8').split('\n');
27
+ var env = {};
28
+ for (var i = 0; i < lines.length; i++) {
29
+ var m = lines[i].match(/^([A-Z_][A-Z0-9_]*)=(.+)$/);
30
+ if (m) env[m[1]] = m[2].trim();
38
31
  }
39
32
  return env;
40
33
  }
41
34
 
42
35
  function isConfigured() {
43
- const env = loadUserConfig();
36
+ var env = loadUserConfig();
44
37
  return !!(
45
38
  env['NVIDIA_API_KEY'] ||
46
39
  env['OPENAI_API_KEY'] ||
47
40
  env['GEMINI_API_KEY'] ||
48
41
  env['GROQ_API_KEY'] ||
49
42
  env['HUGGINGFACE_API_KEY'] ||
43
+ env['HF_TOKEN'] ||
44
+ env['ANTHROPIC_API_KEY'] ||
50
45
  env['CORTEX_PROVIDER'] === 'ollama'
51
- )
46
+ );
52
47
  }
53
48
 
54
- // ─── Run the setup wizard ──────────────────────────────────────────────────
55
49
  function runWizard() {
56
- // Try bun first (fastest), fall back to npx tsx
57
- const runners = [
50
+ var runners = [
58
51
  ['bun', [WIZARD]],
59
52
  ['npx', ['--yes', 'tsx', WIZARD]],
60
- ['node', ['--loader', 'ts-node/esm', WIZARD]],
61
53
  ];
62
-
63
- for (const [cmd, cmdArgs] of runners) {
54
+ for (var i = 0; i < runners.length; i++) {
64
55
  try {
65
- execFileSync(cmd, cmdArgs, { stdio: 'inherit', cwd: ROOT });
56
+ execFileSync(runners[i][0], runners[i][1], { stdio: 'inherit', cwd: ROOT });
66
57
  return;
67
58
  } catch (e) {
68
59
  continue;
69
60
  }
70
61
  }
71
-
72
- console.error('\n❌ Could not run setup wizard.');
73
- console.error(' Install bun first: https://bun.sh\n');
62
+ console.error('\n❌ Could not run setup wizard. Install bun: https://bun.sh\n');
74
63
  process.exit(1);
75
64
  }
76
65
 
77
- // ─── Launch CORTEX with user config injected ───────────────────────────────
78
- function launchCortex(extraEnv = {}) {
66
+ function launchCortex(extraEnv) {
79
67
  if (!fs.existsSync(CLI_PATH)) {
80
- console.error(`\n❌ dist/cli.mjs not found.\n`);
68
+ console.error('\n❌ dist/cli.mjs not found.\n');
81
69
  process.exit(1);
82
70
  }
83
-
84
- const userConfig = loadUserConfig();
85
- const mergedEnv = { ...process.env, ...userConfig, ...extraEnv };
86
-
87
- const proc = spawn('node', [CLI_PATH, ...args], {
71
+ var userConfig = loadUserConfig();
72
+ var mergedEnv = Object.assign({}, process.env, userConfig, extraEnv || {});
73
+ var proc = spawn('node', [CLI_PATH].concat(args), {
88
74
  stdio: 'inherit',
89
75
  cwd: ROOT,
90
76
  env: mergedEnv,
91
77
  });
92
-
93
- proc.on('exit', code => process.exit(code ?? 0));
78
+ proc.on('exit', function(code) { process.exit(code || 0); });
94
79
  }
95
80
 
96
- // ─── Entry point ───────────────────────────────────────────────────────────
97
- if (args[0] === 'setup' || args[0] === 'init' || args[0] === 'configure' || args[0] === 'login') {
98
- // Force re-run wizard
81
+ if (args[0] === 'setup' || args[0] === 'init' || args[0] === 'configure') {
99
82
  runWizard();
100
83
  launchCortex();
101
84
  } else if (!isConfigured()) {
102
- // First time — run wizard then launch
103
85
  console.log('\n Welcome to CORTEX! Running first-time setup...\n');
104
86
  runWizard();
105
87
  launchCortex();
106
88
  } else {
107
- // Already configured — launch directly
108
89
  launchCortex();
109
90
  }
package/dist/cli.mjs CHANGED
@@ -108086,6 +108086,7 @@ __export(exports_StartupScreen, {
108086
108086
  printStartupScreen: () => printStartupScreen
108087
108087
  });
108088
108088
  import fs2 from "fs";
108089
+ import os3 from "os";
108089
108090
  import path9 from "path";
108090
108091
  function lerp(a2, b, t) {
108091
108092
  return [
@@ -108112,7 +108113,9 @@ function paintLine(text, stops, lineT) {
108112
108113
  return out + RESET;
108113
108114
  }
108114
108115
  function getMissionsFromEnv() {
108115
- const envPath = path9.resolve(process.cwd(), ".env");
108116
+ const homeCortexEnv = path9.join(os3.homedir(), ".cortex", ".env");
108117
+ const cwdEnv = path9.resolve(process.cwd(), ".env");
108118
+ const envPath = fs2.existsSync(homeCortexEnv) ? homeCortexEnv : cwdEnv;
108116
108119
  if (!fs2.existsSync(envPath))
108117
108120
  return [];
108118
108121
  const content = fs2.readFileSync(envPath, "utf8");
@@ -108214,6 +108217,11 @@ async function printStartupScreen() {
108214
108217
  const nvMission = missions.find((m) => m.provider === "nvidia");
108215
108218
  const hfMission = missions.find((m) => m.provider === "huggingface");
108216
108219
  const choice = isNvidiaOnly && nvMission?.apiKey ? nvMission : hfMission ?? missions[missions.length - 1];
108220
+ if (!choice) {
108221
+ process.stdout.write(`⚠ No provider configured. Run: cortex setup
108222
+ `);
108223
+ return;
108224
+ }
108217
108225
  process.stdout.write(`✔ Initialize Mission Engine Interface: ${choice.name}
108218
108226
 
108219
108227
  `);
@@ -251978,7 +251986,7 @@ var init_IdeOnboardingDialog = __esm(() => {
251978
251986
 
251979
251987
  // src/utils/ide.ts
251980
251988
  import { createConnection } from "net";
251981
- import * as os3 from "os";
251989
+ import * as os4 from "os";
251982
251990
  import { basename as basename11, join as join49, sep as pathSeparator, resolve as resolve18 } from "path";
251983
251991
  function isProcessRunning2(pid) {
251984
251992
  try {
@@ -252622,7 +252630,7 @@ async function installFromArtifactory(command) {
252622
252630
  throw new Error("Internal artifactory base URL is not configured");
252623
252631
  }
252624
252632
  const npmrcAuthPrefix = `//${artifactoryBaseUrl.replace(/^https?:\/\//, "")}/api/npm/npm-all/:_authToken=`;
252625
- const npmrcPath = join49(os3.homedir(), ".npmrc");
252633
+ const npmrcPath = join49(os4.homedir(), ".npmrc");
252626
252634
  let authToken = null;
252627
252635
  const fs3 = getFsImplementation();
252628
252636
  try {
@@ -252656,7 +252664,7 @@ async function installFromArtifactory(command) {
252656
252664
  throw new Error("No version found in artifactory response");
252657
252665
  }
252658
252666
  const vsixUrl = `${artifactoryBaseUrl}/armorcode-claude-code-internal/claude-vscode-releases/${version2}/claude-code.vsix`;
252659
- const tempVsixPath = join49(os3.tmpdir(), `claude-code-${version2}-${Date.now()}.vsix`);
252667
+ const tempVsixPath = join49(os4.tmpdir(), `claude-code-${version2}-${Date.now()}.vsix`);
252660
252668
  try {
252661
252669
  const vsixResponse = await axios_default.get(vsixUrl, {
252662
252670
  headers: {
@@ -269473,17 +269481,17 @@ import {
269473
269481
  import { homedir as homedir21 } from "os";
269474
269482
  import { basename as basename14, delimiter as delimiter3, dirname as dirname24, join as join60, resolve as resolve20 } from "path";
269475
269483
  function getPlatform2() {
269476
- const os4 = env2.platform;
269484
+ const os5 = env2.platform;
269477
269485
  const arch = process.arch === "x64" ? "x64" : process.arch === "arm64" ? "arm64" : null;
269478
269486
  if (!arch) {
269479
269487
  const error40 = new Error(`Unsupported architecture: ${process.arch}`);
269480
269488
  logForDebugging2(`Native installer does not support architecture: ${process.arch}`, { level: "error" });
269481
269489
  throw error40;
269482
269490
  }
269483
- if (os4 === "linux" && envDynamic.isMuslEnvironment()) {
269491
+ if (os5 === "linux" && envDynamic.isMuslEnvironment()) {
269484
269492
  return `linux-${arch}-musl`;
269485
269493
  }
269486
- return `${os4}-${arch}`;
269494
+ return `${os5}-${arch}`;
269487
269495
  }
269488
269496
  function getBinaryName(platform4) {
269489
269497
  return platform4.startsWith("win32") ? "cortex.exe" : "anthropic";
@@ -303317,7 +303325,7 @@ var require_main = __commonJS((exports) => {
303317
303325
  var ril_1 = require_ril();
303318
303326
  ril_1.default.install();
303319
303327
  var path12 = __require("path");
303320
- var os4 = __require("os");
303328
+ var os5 = __require("os");
303321
303329
  var crypto_1 = __require("crypto");
303322
303330
  var net_1 = __require("net");
303323
303331
  var api_1 = require_api2();
@@ -303460,7 +303468,7 @@ var require_main = __commonJS((exports) => {
303460
303468
  if (XDG_RUNTIME_DIR) {
303461
303469
  result = path12.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
303462
303470
  } else {
303463
- result = path12.join(os4.tmpdir(), `vscode-${randomSuffix}.sock`);
303471
+ result = path12.join(os5.tmpdir(), `vscode-${randomSuffix}.sock`);
303464
303472
  }
303465
303473
  const limit = safeIpcPathLengths.get(process.platform);
303466
303474
  if (limit !== undefined && result.length > limit) {
@@ -305274,7 +305282,7 @@ var init_bashPipeCommand = __esm(() => {
305274
305282
  // src/utils/bash/ShellSnapshot.ts
305275
305283
  import { execFile as execFile4 } from "child_process";
305276
305284
  import { mkdir as mkdir16, stat as stat23 } from "fs/promises";
305277
- import * as os4 from "os";
305285
+ import * as os5 from "os";
305278
305286
  import { join as join71 } from "path";
305279
305287
  function createArgv0ShellFunction(funcName, argv0, binaryPath, prependArgs = []) {
305280
305288
  const quotedPath = quote([binaryPath]);
@@ -305331,7 +305339,7 @@ function createFindGrepShellIntegration() {
305331
305339
  }
305332
305340
  function getConfigFile(shellPath) {
305333
305341
  const fileName = shellPath.includes("zsh") ? ".zshrc" : shellPath.includes("bash") ? ".bashrc" : ".profile";
305334
- const configPath = join71(os4.homedir(), fileName);
305342
+ const configPath = join71(os5.homedir(), fileName);
305335
305343
  return configPath;
305336
305344
  }
305337
305345
  function getUserSnapshotContent(configFile) {
@@ -305529,7 +305537,7 @@ ${stdout}`);
305529
305537
  logForDebugging2(`No stderr output captured`);
305530
305538
  }
305531
305539
  logError(new Error(`Failed to create shell snapshot: ${error40.message}`));
305532
- const signalNumber = execError?.signal ? os4.constants.signals[execError.signal] : undefined;
305540
+ const signalNumber = execError?.signal ? os5.constants.signals[execError.signal] : undefined;
305533
305541
  logEvent("tengu_shell_snapshot_failed", {
305534
305542
  stderr_length: stderr?.length || 0,
305535
305543
  has_error_code: !!execError?.code,
@@ -367806,7 +367814,7 @@ function getCORTEXEnvMetadata() {
367806
367814
  function getBuildAgeMinutes() {
367807
367815
  if (false)
367808
367816
  ;
367809
- const buildTime = new Date("2026-05-07T10:32:20.024Z").getTime();
367817
+ const buildTime = new Date("2026-05-07T10:44:08.571Z").getTime();
367810
367818
  if (isNaN(buildTime))
367811
367819
  return;
367812
367820
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -394597,7 +394605,7 @@ function buildPrimarySection() {
394597
394605
  }, undefined, false, undefined, this);
394598
394606
  return [{
394599
394607
  label: "Version",
394600
- value: "0.1.9"
394608
+ value: "0.1.11"
394601
394609
  }, {
394602
394610
  label: "Session name",
394603
394611
  value: nameValue
@@ -460176,7 +460184,7 @@ var init_bridge_kick = __esm(() => {
460176
460184
  var call60 = async () => {
460177
460185
  return {
460178
460186
  type: "text",
460179
- value: `${"99.0.0"} (built ${"2026-05-07T10:32:20.024Z"})`
460187
+ value: `${"99.0.0"} (built ${"2026-05-07T10:44:08.571Z"})`
460180
460188
  };
460181
460189
  }, version2, version_default;
460182
460190
  var init_version = __esm(() => {
@@ -534306,7 +534314,7 @@ function WelcomeV2() {
534306
534314
  dimColor: true,
534307
534315
  children: [
534308
534316
  "v",
534309
- "0.1.9",
534317
+ "0.1.11",
534310
534318
  " "
534311
534319
  ]
534312
534320
  }, undefined, true, undefined, this)
@@ -534506,7 +534514,7 @@ function WelcomeV2() {
534506
534514
  dimColor: true,
534507
534515
  children: [
534508
534516
  "v",
534509
- "0.1.9",
534517
+ "0.1.11",
534510
534518
  " "
534511
534519
  ]
534512
534520
  }, undefined, true, undefined, this)
@@ -534732,7 +534740,7 @@ function AppleTerminalWelcomeV2(t0) {
534732
534740
  dimColor: true,
534733
534741
  children: [
534734
534742
  "v",
534735
- "0.1.9",
534743
+ "0.1.11",
534736
534744
  " "
534737
534745
  ]
534738
534746
  }, undefined, true, undefined, this);
@@ -534986,7 +534994,7 @@ function AppleTerminalWelcomeV2(t0) {
534986
534994
  dimColor: true,
534987
534995
  children: [
534988
534996
  "v",
534989
- "0.1.9",
534997
+ "0.1.11",
534990
534998
  " "
534991
534999
  ]
534992
535000
  }, undefined, true, undefined, this);
@@ -554867,7 +554875,7 @@ Usage: cortex --remote "your task description"`, () => gracefulShutdown(1));
554867
554875
  pendingHookMessages
554868
554876
  }, renderAndRun);
554869
554877
  }
554870
- }).version("0.1.9 (CORTEX)", "-v, --version", "Output the version number");
554878
+ }).version("0.1.11 (CORTEX)", "-v, --version", "Output the version number");
554871
554879
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
554872
554880
  program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
554873
554881
  if (canUserConfigureAdvisor()) {
@@ -555462,7 +555470,7 @@ if (false) {}
555462
555470
  async function main2() {
555463
555471
  const args = process.argv.slice(2);
555464
555472
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
555465
- const v = typeof MACRO !== "undefined" ? "0.1.9" : "99.0.0-dev";
555473
+ const v = typeof MACRO !== "undefined" ? "0.1.11" : "99.0.0-dev";
555466
555474
  console.log(`${v} (CORTEX)`);
555467
555475
  return;
555468
555476
  }
@@ -555647,4 +555655,4 @@ ${DIM4} session id:${RESET4} ${BOLD2}${handle.sessionId}${RESET4} ${DIM4}(rotat
555647
555655
  }
555648
555656
  main2();
555649
555657
 
555650
- //# debugId=980A0E66F60E322964756E2164756E21
555658
+ //# debugId=805ACAE77880D8DA64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gokulvenkatareddy/cortex",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "CORTEX — Autonomous AGI Terminal. Any LLM, one command. NVIDIA, OpenAI, Gemini, Groq, Ollama and more.",
5
5
  "type": "module",
6
6
  "bin": {