@gokulvenkatareddy/cortex 0.1.9 → 0.1.10
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/cortex +18 -38
- package/dist/cli.mjs +30 -22
- package/package.json +1 -1
package/bin/cortex
CHANGED
|
@@ -1,40 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
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
|
-
*
|
|
3
|
+
* CORTEX — Global CLI entry point (CommonJS compatible)
|
|
4
|
+
* Works anywhere: npm install -g @gokulvenkatareddy/cortex
|
|
9
5
|
* Config lives in ~/.cortex/.env (the user's machine, NOT this package).
|
|
10
|
-
* API keys are NEVER stored in the npm package folder.
|
|
11
6
|
*/
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import { fileURLToPath } from 'url';
|
|
8
|
+
const { execFileSync, spawn } = require('child_process');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
const path = require('path');
|
|
18
12
|
|
|
19
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
20
13
|
const ROOT = path.resolve(__dirname, '..');
|
|
21
14
|
const CLI_PATH = path.join(ROOT, 'dist', 'cli.mjs');
|
|
22
15
|
const WIZARD = path.join(ROOT, 'scripts', 'setup-wizard.ts');
|
|
23
16
|
|
|
24
|
-
// Config lives in the user's home dir, NOT the package folder
|
|
25
17
|
const CONFIG_DIR = path.join(os.homedir(), '.cortex');
|
|
26
18
|
const CONFIG_ENV = path.join(CONFIG_DIR, '.env');
|
|
27
19
|
|
|
28
20
|
const args = process.argv.slice(2);
|
|
29
21
|
|
|
30
|
-
// ─── Load ~/.cortex/.env into the environment ──────────────────────────────
|
|
31
22
|
function loadUserConfig() {
|
|
32
23
|
if (!fs.existsSync(CONFIG_ENV)) return {};
|
|
33
24
|
const lines = fs.readFileSync(CONFIG_ENV, 'utf8').split('\n');
|
|
34
25
|
const env = {};
|
|
35
26
|
for (const line of lines) {
|
|
36
|
-
const m = line.match(/^([A-Z_]+)=(.+)$/);
|
|
37
|
-
if (m) env[m[1]] = m[2];
|
|
27
|
+
const m = line.match(/^([A-Z_]+[A-Z0-9_]*)=(.+)$/);
|
|
28
|
+
if (m) env[m[1]] = m[2].trim();
|
|
38
29
|
}
|
|
39
30
|
return env;
|
|
40
31
|
}
|
|
@@ -47,19 +38,17 @@ function isConfigured() {
|
|
|
47
38
|
env['GEMINI_API_KEY'] ||
|
|
48
39
|
env['GROQ_API_KEY'] ||
|
|
49
40
|
env['HUGGINGFACE_API_KEY'] ||
|
|
41
|
+
env['HF_TOKEN'] ||
|
|
42
|
+
env['ANTHROPIC_API_KEY'] ||
|
|
50
43
|
env['CORTEX_PROVIDER'] === 'ollama'
|
|
51
|
-
)
|
|
44
|
+
);
|
|
52
45
|
}
|
|
53
46
|
|
|
54
|
-
// ─── Run the setup wizard ──────────────────────────────────────────────────
|
|
55
47
|
function runWizard() {
|
|
56
|
-
// Try bun first (fastest), fall back to npx tsx
|
|
57
48
|
const runners = [
|
|
58
49
|
['bun', [WIZARD]],
|
|
59
50
|
['npx', ['--yes', 'tsx', WIZARD]],
|
|
60
|
-
['node', ['--loader', 'ts-node/esm', WIZARD]],
|
|
61
51
|
];
|
|
62
|
-
|
|
63
52
|
for (const [cmd, cmdArgs] of runners) {
|
|
64
53
|
try {
|
|
65
54
|
execFileSync(cmd, cmdArgs, { stdio: 'inherit', cwd: ROOT });
|
|
@@ -68,42 +57,33 @@ function runWizard() {
|
|
|
68
57
|
continue;
|
|
69
58
|
}
|
|
70
59
|
}
|
|
71
|
-
|
|
72
|
-
console.error('\n❌ Could not run setup wizard.');
|
|
73
|
-
console.error(' Install bun first: https://bun.sh\n');
|
|
60
|
+
console.error('\n❌ Could not run setup wizard. Install bun: https://bun.sh\n');
|
|
74
61
|
process.exit(1);
|
|
75
62
|
}
|
|
76
63
|
|
|
77
|
-
|
|
78
|
-
function launchCortex(extraEnv = {}) {
|
|
64
|
+
function launchCortex(extraEnv) {
|
|
79
65
|
if (!fs.existsSync(CLI_PATH)) {
|
|
80
|
-
console.error(
|
|
66
|
+
console.error('\n❌ dist/cli.mjs not found.\n');
|
|
81
67
|
process.exit(1);
|
|
82
68
|
}
|
|
83
|
-
|
|
84
69
|
const userConfig = loadUserConfig();
|
|
85
|
-
const mergedEnv = {
|
|
86
|
-
|
|
87
|
-
const proc = spawn('node', [CLI_PATH, ...args], {
|
|
70
|
+
const mergedEnv = Object.assign({}, process.env, userConfig, extraEnv || {});
|
|
71
|
+
const proc = spawn('node', [CLI_PATH].concat(args), {
|
|
88
72
|
stdio: 'inherit',
|
|
89
73
|
cwd: ROOT,
|
|
90
74
|
env: mergedEnv,
|
|
91
75
|
});
|
|
92
|
-
|
|
93
|
-
proc.on('exit', code => process.exit(code ?? 0));
|
|
76
|
+
proc.on('exit', function(code) { process.exit(code || 0); });
|
|
94
77
|
}
|
|
95
78
|
|
|
96
79
|
// ─── Entry point ───────────────────────────────────────────────────────────
|
|
97
|
-
if (args[0] === 'setup' || args[0] === 'init' || args[0] === 'configure'
|
|
98
|
-
// Force re-run wizard
|
|
80
|
+
if (args[0] === 'setup' || args[0] === 'init' || args[0] === 'configure') {
|
|
99
81
|
runWizard();
|
|
100
82
|
launchCortex();
|
|
101
83
|
} else if (!isConfigured()) {
|
|
102
|
-
// First time — run wizard then launch
|
|
103
84
|
console.log('\n Welcome to CORTEX! Running first-time setup...\n');
|
|
104
85
|
runWizard();
|
|
105
86
|
launchCortex();
|
|
106
87
|
} else {
|
|
107
|
-
// Already configured — launch directly
|
|
108
88
|
launchCortex();
|
|
109
89
|
}
|
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
|
|
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
|
|
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(
|
|
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(
|
|
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
|
|
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 (
|
|
269491
|
+
if (os5 === "linux" && envDynamic.isMuslEnvironment()) {
|
|
269484
269492
|
return `linux-${arch}-musl`;
|
|
269485
269493
|
}
|
|
269486
|
-
return `${
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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 ?
|
|
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:
|
|
367817
|
+
const buildTime = new Date("2026-05-07T10:37:38.396Z").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.
|
|
394608
|
+
value: "0.1.10"
|
|
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:
|
|
460187
|
+
value: `${"99.0.0"} (built ${"2026-05-07T10:37:38.396Z"})`
|
|
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.
|
|
534317
|
+
"0.1.10",
|
|
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.
|
|
534517
|
+
"0.1.10",
|
|
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.
|
|
534743
|
+
"0.1.10",
|
|
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.
|
|
534997
|
+
"0.1.10",
|
|
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.
|
|
554878
|
+
}).version("0.1.10 (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.
|
|
555473
|
+
const v = typeof MACRO !== "undefined" ? "0.1.10" : "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=
|
|
555658
|
+
//# debugId=AAB29BFC16F3829C64756E2164756E21
|
package/package.json
CHANGED