@nexus-cortex/tui 4.56.3 → 4.56.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/bin/cli-full.js CHANGED
@@ -5,19 +5,16 @@
5
5
  * CHALK interactiveChat REPL; `ui` browsers; other subcommands delegate to the
6
6
  * headless @nexus-cortex/cli).
7
7
  */
8
- import { config } from 'dotenv';
8
+ import { bootstrapEnv } from '@nexus-cortex/core';
9
9
  import { fileURLToPath } from 'url';
10
10
  import { dirname, join } from 'path';
11
- import { existsSync, realpathSync } from 'fs';
11
+ import { realpathSync } from 'fs';
12
12
 
13
13
  const __filename = fileURLToPath(import.meta.url);
14
14
  const __dirname = dirname(realpathSync(__filename));
15
15
  const PKG_ROOT = join(__dirname, '..', '..', '..');
16
16
 
17
- const cwdEnv = join(process.cwd(), '.env');
18
- const pkgEnv = join(PKG_ROOT, '.env');
19
-
20
- if (existsSync(cwdEnv)) config({ path: cwdEnv, quiet: true });
21
- if (existsSync(pkgEnv)) config({ path: pkgEnv, quiet: true });
17
+ // Canonical .env bootstrap (one implementation in @nexus-cortex/core).
18
+ bootstrapEnv(PKG_ROOT);
22
19
 
23
20
  await import('../dist/index.js');
package/bin/cortex-ui.js CHANGED
@@ -6,18 +6,16 @@
6
6
  * Loads .env, then launches the lightweight cortex.tsx UI in direct mode.
7
7
  */
8
8
 
9
- import { config } from 'dotenv';
10
9
  import { fileURLToPath } from 'url';
11
10
  import { dirname, join } from 'path';
12
- import { existsSync, realpathSync } from 'fs';
11
+ import { realpathSync } from 'fs';
12
+ import { bootstrapEnv } from '@nexus-cortex/core';
13
13
 
14
14
  const __filename = fileURLToPath(import.meta.url);
15
15
  const __dirname = dirname(realpathSync(__filename));
16
16
  const ROOT_DIR = join(__dirname, '..', '..', '..');
17
- const ENV_FILE = join(ROOT_DIR, '.env');
18
- if (existsSync(ENV_FILE)) {
19
- config({ path: ENV_FILE, quiet: true });
20
- }
17
+ // Canonical .env bootstrap (one implementation in @nexus-cortex/core).
18
+ bootstrapEnv(ROOT_DIR);
21
19
 
22
20
  // cortex.tsx only understands direct/server — force direct mode
23
21
  // (CORTEX_MODE=stateless is a server-side concept)
package/bin/ink-ui.js CHANGED
@@ -7,10 +7,10 @@
7
7
  * The UI is adapted from Gemini CLI but wired to our core orchestrator.
8
8
  */
9
9
 
10
- import { config } from 'dotenv';
11
10
  import { fileURLToPath } from 'url';
12
11
  import { dirname, join } from 'path';
13
12
  import { existsSync, realpathSync } from 'fs';
13
+ import { bootstrapEnv } from '@nexus-cortex/core';
14
14
  import React from 'react';
15
15
  import { render } from 'ink';
16
16
  import { CortexApp } from '../dist/ink-ui/CortexApp.js';
@@ -25,15 +25,8 @@ const PKG_ROOT = join(__dirname, '..', '..', '..');
25
25
  // regardless of the cwd the user launches from. Honors a pre-set CORTEX_ROOT.
26
26
  process.env.CORTEX_ROOT = process.env.CORTEX_ROOT || PKG_ROOT;
27
27
 
28
- const cwdEnv = join(process.cwd(), '.env');
29
- const pkgEnv = join(PKG_ROOT, '.env');
30
- const cwdEnvLocal = join(process.cwd(), '.env.local');
31
- const pkgEnvLocal = join(PKG_ROOT, '.env.local');
32
-
33
- if (existsSync(cwdEnv)) config({ path: cwdEnv, quiet: true });
34
- if (existsSync(pkgEnv)) config({ path: pkgEnv, quiet: true });
35
- if (existsSync(cwdEnvLocal)) config({ path: cwdEnvLocal, override: true, quiet: true });
36
- if (existsSync(pkgEnvLocal)) config({ path: pkgEnvLocal, override: true, quiet: true });
28
+ // Canonical .env bootstrap (one implementation in @nexus-cortex/core).
29
+ bootstrapEnv(PKG_ROOT);
37
30
 
38
31
  // Parse CLI arguments
39
32
  const args = process.argv.slice(2);
package/bin/launcher.js CHANGED
@@ -16,7 +16,7 @@ import { fileURLToPath } from 'url';
16
16
  import { dirname, join } from 'path';
17
17
  import { existsSync, realpathSync } from 'fs';
18
18
  import http from 'http';
19
- import { config } from 'dotenv';
19
+ import { bootstrapEnv } from '@nexus-cortex/core';
20
20
 
21
21
  const __filename = fileURLToPath(import.meta.url);
22
22
  // Resolve symlinks to get actual path (important for npm link)
@@ -32,17 +32,10 @@ const PKG_ROOT = join(CLI_DIR, '..', '..');
32
32
  // Spawned children inherit this via process.env.
33
33
  process.env.CORTEX_ROOT = process.env.CORTEX_ROOT || PKG_ROOT;
34
34
 
35
- // Load .env: cwd first (user's project), then package root (dev/monorepo).
36
- // dotenv's default is "first wins" cwd values take priority.
37
- const cwdEnv = join(process.cwd(), '.env');
38
- const pkgEnv = join(PKG_ROOT, '.env');
39
- const cwdEnvLocal = join(process.cwd(), '.env.local');
40
- const pkgEnvLocal = join(PKG_ROOT, '.env.local');
41
-
42
- if (existsSync(cwdEnv)) config({ path: cwdEnv, quiet: true });
43
- if (existsSync(pkgEnv)) config({ path: pkgEnv, quiet: true });
44
- if (existsSync(cwdEnvLocal)) config({ path: cwdEnvLocal, override: true, quiet: true });
45
- if (existsSync(pkgEnvLocal)) config({ path: pkgEnvLocal, override: true, quiet: true });
35
+ // Canonical .env bootstrap (ONE implementation in @nexus-cortex/core) loads
36
+ // cwd/.env > packageRoot/.env > global ~/.cortex/.env (+ .local overrides), never
37
+ // clobbering real injected env. A change to the loader lives in core, not here.
38
+ const { loadedFrom: envLoadedFrom } = bootstrapEnv(PKG_ROOT);
46
39
 
47
40
  // Parse arguments
48
41
  const args = process.argv.slice(2);
@@ -456,14 +449,12 @@ async function main() {
456
449
  log(` Nexus Cortex - ${modeStr} DEV`, mode === 'direct' ? 'cyan' : 'magenta');
457
450
  log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n', 'cyan');
458
451
 
459
- if (existsSync(cwdEnv)) {
460
- log(`[OK] Configuration loaded from: ${cwdEnv}`, 'dim');
461
- } else if (existsSync(pkgEnv)) {
462
- log(`[OK] Configuration loaded from: ${pkgEnv}`, 'dim');
452
+ if (envLoadedFrom.length > 0) {
453
+ log(`[OK] Configuration loaded from: ${envLoadedFrom[0]}`, 'dim');
463
454
  } else {
464
455
  log(`[WARN] No .env file found`, 'yellow');
465
456
  }
466
- } else if (!existsSync(cwdEnv) && !existsSync(pkgEnv)) {
457
+ } else if (envLoadedFrom.length === 0) {
467
458
  log(`[WARN] No .env file found`, 'yellow');
468
459
  }
469
460
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexus-cortex/tui",
3
- "version": "4.56.3",
3
+ "version": "4.56.4",
4
4
  "description": "Nexus Cortex interactive terminal UI (React/Ink) — the polished cockpit + launchers over @nexus-cortex/cli",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -18,8 +18,8 @@
18
18
  "dev": "tsx watch src/index.ts"
19
19
  },
20
20
  "dependencies": {
21
- "@nexus-cortex/cli": "4.56.3",
22
- "@nexus-cortex/core": "4.56.3",
21
+ "@nexus-cortex/cli": "4.56.4",
22
+ "@nexus-cortex/core": "4.56.4",
23
23
  "chalk": "^4.1.2",
24
24
  "cli-spinners": "^2.9.0",
25
25
  "commander": "^11.0.0",