heimdall-agent 1.2.0 → 1.5.0

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/setup.mjs CHANGED
@@ -18,10 +18,20 @@ import os from 'node:os';
18
18
  import readline from 'node:readline/promises';
19
19
  import { fileURLToPath } from 'node:url';
20
20
  import { execSync } from 'node:child_process';
21
- import { resolveModelMaxContext, resolveCustomModelsEndpoint } from './lib/model-context.cjs';
21
+ import { CANONICAL_MODEL_CONTEXTS, resolveModelMaxContext, resolveCustomModelsEndpoint } from './lib/model-context.cjs';
22
+ import { syncAgentsWithModels, syncModelRegistryPlaybook } from './lib/model-router.cjs';
22
23
  import { updateHermesConfigContext } from './lib/hermes-context.cjs';
23
24
  import { detectPathCandidates } from './lib/path-discovery.cjs';
24
25
  import { syncCatalogCounts } from './lib/catalog-sync.cjs';
26
+ import {
27
+ configureClaudeStatusLine,
28
+ configureAntigravityStatusLine,
29
+ configureCodexStatusLine,
30
+ disableClaudeStatusLine,
31
+ disableAntigravityStatusLine,
32
+ disableCodexStatusLine,
33
+ writeHudConfig
34
+ } from './lib/hud-sync.cjs';
25
35
 
26
36
  const __filename = fileURLToPath(import.meta.url);
27
37
  const __dirname = path.dirname(__filename);
@@ -86,13 +96,36 @@ function getOpenClawDir() {
86
96
  return homePath;
87
97
  }
88
98
 
99
+ /**
100
+ * Resolves the GitHub Copilot / VS Code user skills & agents directory (~/.copilot).
101
+ */
102
+ function getCopilotDir() {
103
+ return path.join(userHome, '.copilot');
104
+ }
105
+
106
+ /**
107
+ * Resolves the VS Code User configuration directory across Windows, macOS, and Linux.
108
+ */
109
+ function getVSCodeUserDir() {
110
+ const platform = os.platform();
111
+ if (platform === 'win32') {
112
+ const appData = process.env.APPDATA || path.join(userHome, 'AppData', 'Roaming');
113
+ return path.join(appData, 'Code', 'User');
114
+ }
115
+ if (platform === 'darwin') {
116
+ return path.join(userHome, 'Library', 'Application Support', 'Code', 'User');
117
+ }
118
+ return path.join(userHome, '.config', 'Code', 'User');
119
+ }
120
+
89
121
  const targetPaths = {
90
122
  claude: path.join(userHome, '.claude', 'skills'),
91
123
  gemini: path.join(userHome, '.gemini', 'skills'),
92
124
  codex: path.join(userHome, '.codex', 'skills'),
93
125
  agents: path.join(userHome, '.agents', 'skills'),
94
126
  hermes: path.join(getHermesDir(), 'skills'),
95
- openclaw: path.join(getOpenClawDir(), 'skills')
127
+ openclaw: path.join(getOpenClawDir(), 'skills'),
128
+ vscode: path.join(getCopilotDir(), 'skills')
96
129
  };
97
130
 
98
131
  const targetAgentPaths = {
@@ -101,7 +134,8 @@ const targetAgentPaths = {
101
134
  codex: path.join(userHome, '.codex', 'agents'),
102
135
  agents: path.join(userHome, '.agents', 'agents'),
103
136
  hermes: path.join(getHermesDir(), 'agents'),
104
- openclaw: path.join(getOpenClawDir(), 'agents')
137
+ openclaw: path.join(getOpenClawDir(), 'agents'),
138
+ vscode: path.join(getCopilotDir(), 'agents')
105
139
  };
106
140
 
107
141
  const targetDoctrinePaths = {
@@ -110,7 +144,8 @@ const targetDoctrinePaths = {
110
144
  codex: path.join(userHome, '.codex', 'AGENTS.md'),
111
145
  agents: path.join(userHome, '.agents', 'AGENTS.md'),
112
146
  hermes: path.join(getHermesDir(), 'AGENTS.md'),
113
- openclaw: path.join(getOpenClawDir(), 'AGENTS.md')
147
+ openclaw: path.join(getOpenClawDir(), 'AGENTS.md'),
148
+ vscode: path.join(getCopilotDir(), 'copilot-instructions.md')
114
149
  };
115
150
 
116
151
  const targetPlaybookPaths = {
@@ -118,7 +153,8 @@ const targetPlaybookPaths = {
118
153
  gemini: path.join(userHome, '.gemini', 'playbooks'),
119
154
  agents: path.join(userHome, '.agents', 'playbooks'),
120
155
  hermes: path.join(getHermesDir(), 'playbooks'),
121
- openclaw: path.join(getOpenClawDir(), 'playbooks')
156
+ openclaw: path.join(getOpenClawDir(), 'playbooks'),
157
+ vscode: path.join(getCopilotDir(), 'playbooks')
122
158
  };
123
159
 
124
160
  const targetCommandPaths = {
@@ -139,6 +175,7 @@ function getAgentRootDir(agent) {
139
175
  if (agent === 'agents') return path.join(userHome, '.agents');
140
176
  if (agent === 'hermes') return getHermesDir();
141
177
  if (agent === 'openclaw') return getOpenClawDir();
178
+ if (agent === 'vscode') return getCopilotDir();
142
179
  if (agent === 'desktop') return getClaudeDesktopDir();
143
180
  return null;
144
181
  }
@@ -152,6 +189,9 @@ function isAgentConfigurable(agent) {
152
189
  const status = detectClaudeDesktop();
153
190
  return Boolean(status.configExists);
154
191
  }
192
+ if (agent === 'vscode') {
193
+ return Boolean(fs.existsSync(getCopilotDir()) || fs.existsSync(getVSCodeUserDir()) || detectVSCodeBinary());
194
+ }
155
195
  const rootDir = getAgentRootDir(agent);
156
196
  return Boolean(rootDir && fs.existsSync(rootDir));
157
197
  }
@@ -385,124 +425,154 @@ function resolveOpenDesignMcpConfig() {
385
425
  }
386
426
 
387
427
  /**
388
- * Synchronizes curated and dynamic MCP servers (including OpenDesign and Context7)
389
- * across Antigravity, Claude Desktop, and Claude Code.
428
+ * Installs required MCP npm packages globally so configs use direct node.exe calls
429
+ * instead of npx (which spawns 4-5 orphan-prone processes per server on Windows).
390
430
  */
391
- function syncMcpServers(detected, options = {}) {
392
- let syncedAny = false;
393
- let mcpRegistry = {};
394
- if (fs.existsSync(mcpConfigPath)) {
395
- try {
396
- mcpRegistry = JSON.parse(fs.readFileSync(mcpConfigPath, 'utf8')).mcpServers || {};
397
- } catch {}
398
- }
399
-
400
- const odConfig = resolveOpenDesignMcpConfig();
401
-
402
- // 1. Antigravity (AGY)
403
- const agyMcpFile = path.join(userHome, '.gemini', 'config', 'mcp_config.json');
404
- if (fs.existsSync(path.dirname(agyMcpFile))) {
405
- let agyConfig = { mcpServers: {} };
406
- try {
407
- if (fs.existsSync(agyMcpFile)) {
408
- agyConfig = JSON.parse(fs.readFileSync(agyMcpFile, 'utf8'));
409
- }
410
- } catch {}
411
- if (!agyConfig.mcpServers) agyConfig.mcpServers = {};
412
-
413
- let agyUpdated = false;
414
- if (odConfig && JSON.stringify(agyConfig.mcpServers['open-design']) !== JSON.stringify(odConfig)) {
415
- agyConfig.mcpServers['open-design'] = odConfig;
416
- agyUpdated = true;
417
- }
418
- if (mcpRegistry.context7?.config && !agyConfig.mcpServers['context7']) {
419
- agyConfig.mcpServers['context7'] = mcpRegistry.context7.config;
420
- agyUpdated = true;
421
- }
431
+ function installMcpPackages(options = {}) {
432
+ const requiredPackages = ['@upstash/context7-mcp', 'chrome-devtools-mcp'];
433
+ const missing = [];
422
434
 
423
- if (agyUpdated && !options.dryRun) {
424
- fs.writeFileSync(agyMcpFile, JSON.stringify(agyConfig, null, 2), 'utf8');
425
- console.log(` ${colors.green}✔${colors.reset} Synchronized OpenDesign MCP for Google Antigravity`);
426
- syncedAny = true;
435
+ try {
436
+ const npmRoot = execSync('npm root -g', { encoding: 'utf8' }).replace(/\r/g, '').trim();
437
+ for (const pkg of requiredPackages) {
438
+ const pkgDir = path.join(npmRoot, pkg);
439
+ if (!fs.existsSync(pkgDir)) missing.push(pkg);
427
440
  }
441
+ } catch {
442
+ missing.push(...requiredPackages);
428
443
  }
429
444
 
430
- // 2. Claude Desktop
431
- const claudeDesktopDir = getClaudeDesktopDir();
432
- const claudeDesktopFile = path.join(claudeDesktopDir, 'claude_desktop_config.json');
433
- if (fs.existsSync(claudeDesktopFile)) {
434
- let deskConfig = { mcpServers: {} };
435
- try { deskConfig = JSON.parse(fs.readFileSync(claudeDesktopFile, 'utf8')); } catch {}
436
- if (!deskConfig.mcpServers) deskConfig.mcpServers = {};
445
+ if (missing.length === 0) {
446
+ console.log(` ${colors.green}✔${colors.reset} MCP packages already installed globally (${requiredPackages.join(', ')})`);
447
+ return true;
448
+ }
437
449
 
438
- let deskUpdated = false;
439
- if (odConfig && JSON.stringify(deskConfig.mcpServers['open-design']) !== JSON.stringify(odConfig)) {
440
- deskConfig.mcpServers['open-design'] = odConfig;
441
- deskUpdated = true;
442
- }
443
- if (mcpRegistry.context7?.config && !deskConfig.mcpServers['context7']) {
444
- deskConfig.mcpServers['context7'] = mcpRegistry.context7.config;
445
- deskUpdated = true;
446
- }
450
+ console.log(` ${colors.cyan}→${colors.reset} Installing MCP packages globally: ${missing.join(', ')}`);
451
+ if (options.dryRun) {
452
+ console.log(` ${colors.yellow}(dry run — would run: npm install -g ${missing.join(' ')})${colors.reset}`);
453
+ return true;
454
+ }
447
455
 
448
- if (deskUpdated && !options.dryRun) {
449
- fs.writeFileSync(claudeDesktopFile, JSON.stringify(deskConfig, null, 2), 'utf8');
450
- console.log(` ${colors.green}✔${colors.reset} Synchronized OpenDesign & Context7 MCP for Claude Desktop`);
451
- syncedAny = true;
452
- }
456
+ try {
457
+ execSync(`npm install -g ${missing.join(' ')}`, { stdio: ['pipe', 'pipe', 'pipe'], timeout: 120000 });
458
+ console.log(` ${colors.green}✔${colors.reset} Installed ${missing.join(', ')} globally`);
459
+ return true;
460
+ } catch (err) {
461
+ console.log(` ${colors.red}✘${colors.reset} Failed to install MCP packages: ${err.message}`);
462
+ console.log(` ${colors.yellow} Run manually: npm install -g ${missing.join(' ')}${colors.reset}`);
463
+ return false;
453
464
  }
465
+ }
454
466
 
455
- // 3. Claude Code CLI
456
- const claudeConfigFile = path.join(userHome, '.claude.json');
457
- if (fs.existsSync(claudeConfigFile)) {
458
- let claudeConfig = {};
459
- try { claudeConfig = JSON.parse(fs.readFileSync(claudeConfigFile, 'utf8')); } catch {}
460
- if (!claudeConfig.mcpServers) claudeConfig.mcpServers = {};
467
+ /**
468
+ * Synchronizes MCP servers across all harnesses (Gemini, Claude, Codex, Hermes)
469
+ * using the template-based resolver. Replaces legacy per-harness sync logic.
470
+ * Uses direct node.exe paths to avoid Windows npx process multiplication.
471
+ */
472
+ function syncMcpServers(detected, options = {}) {
473
+ // Step 1: Ensure MCP packages are installed globally
474
+ installMcpPackages(options);
461
475
 
462
- let claudeUpdated = false;
463
- if (odConfig && JSON.stringify(claudeConfig.mcpServers['open-design']) !== JSON.stringify(odConfig)) {
464
- claudeConfig.mcpServers['open-design'] = odConfig;
465
- claudeUpdated = true;
466
- }
476
+ // Step 2: Run the resolver to generate resolved config and sync to all harnesses
477
+ const resolverScript = path.join(__dirname, 'scripts', 'resolve-mcp.mjs');
478
+ if (!fs.existsSync(resolverScript)) {
479
+ console.log(` ${colors.red}✘${colors.reset} MCP resolver not found at ${resolverScript}`);
480
+ return false;
481
+ }
467
482
 
468
- if (claudeUpdated && !options.dryRun) {
469
- fs.writeFileSync(claudeConfigFile, JSON.stringify(claudeConfig, null, 2), 'utf8');
470
- console.log(` ${colors.green}✔${colors.reset} Synchronized OpenDesign MCP for Claude Code`);
471
- syncedAny = true;
472
- }
483
+ if (options.dryRun) {
484
+ console.log(` ${colors.yellow}(dry run — would run: node scripts/resolve-mcp.mjs --sync)${colors.reset}`);
485
+ return true;
473
486
  }
474
487
 
475
- return syncedAny;
488
+ try {
489
+ const output = execSync(`node "${resolverScript}" --sync`, {
490
+ encoding: 'utf8',
491
+ cwd: __dirname,
492
+ timeout: 60000
493
+ });
494
+ // Print resolver output lines prefixed with checkmarks
495
+ for (const line of output.split('\n')) {
496
+ const trimmed = line.trim();
497
+ if (trimmed.startsWith('✓')) {
498
+ console.log(` ${colors.green}✔${colors.reset} ${trimmed.slice(2).trim()}`);
499
+ } else if (trimmed.startsWith('⚠')) {
500
+ console.log(` ${colors.yellow}⚠${colors.reset} ${trimmed.slice(2).trim()}`);
501
+ } else if (trimmed) {
502
+ console.log(` ${colors.dim}${trimmed}${colors.reset}`);
503
+ }
504
+ }
505
+ return true;
506
+ } catch (err) {
507
+ console.log(` ${colors.red}✘${colors.reset} MCP resolver failed: ${err.message}`);
508
+ return false;
509
+ }
476
510
  }
477
511
 
478
512
  /**
479
- * Audits registered and configured MCP servers across harnesses.
513
+ * Audits registered and configured MCP servers across all harnesses.
514
+ * Checks Gemini, Claude Code (settings.json), Codex (config.toml), and Hermes (config.yaml).
480
515
  */
481
516
  function auditMcpServers() {
482
517
  const results = [];
518
+ const serverNames = ['context7', 'chrome-devtools', 'open-design', 'rea', 'mobbin'];
519
+
520
+ // Gemini
483
521
  const agyMcpFile = path.join(userHome, '.gemini', 'config', 'mcp_config.json');
484
522
  if (fs.existsSync(agyMcpFile)) {
485
523
  try {
486
524
  const cfg = JSON.parse(fs.readFileSync(agyMcpFile, 'utf8'));
487
- results.push({ harness: 'Google Antigravity', server: 'open-design', configured: Boolean(cfg.mcpServers?.['open-design']) });
488
- results.push({ harness: 'Google Antigravity', server: 'context7', configured: Boolean(cfg.mcpServers?.['context7']) });
525
+ for (const s of serverNames) {
526
+ results.push({ harness: 'Google Antigravity', server: s, configured: Boolean(cfg.mcpServers?.[s]) });
527
+ }
489
528
  } catch {}
490
529
  }
491
- const claudeDesktopFile = path.join(getClaudeDesktopDir(), 'claude_desktop_config.json');
492
- if (fs.existsSync(claudeDesktopFile)) {
530
+
531
+ // Claude Code (settings.json — correct location for MCP servers)
532
+ const claudeSettingsFile = path.join(userHome, '.claude', 'settings.json');
533
+ if (fs.existsSync(claudeSettingsFile)) {
493
534
  try {
494
- const cfg = JSON.parse(fs.readFileSync(claudeDesktopFile, 'utf8'));
495
- results.push({ harness: 'Claude Desktop', server: 'open-design', configured: Boolean(cfg.mcpServers?.['open-design']) });
496
- results.push({ harness: 'Claude Desktop', server: 'context7', configured: Boolean(cfg.mcpServers?.['context7']) });
535
+ const cfg = JSON.parse(fs.readFileSync(claudeSettingsFile, 'utf8'));
536
+ for (const s of serverNames) {
537
+ results.push({ harness: 'Claude Code', server: s, configured: Boolean(cfg.mcpServers?.[s]) });
538
+ }
497
539
  } catch {}
498
540
  }
499
- const claudeConfigFile = path.join(userHome, '.claude.json');
500
- if (fs.existsSync(claudeConfigFile)) {
541
+
542
+ // Codex CLI (config.toml)
543
+ const codexConfigFile = path.join(userHome, '.codex', 'config.toml');
544
+ if (fs.existsSync(codexConfigFile)) {
501
545
  try {
502
- const cfg = JSON.parse(fs.readFileSync(claudeConfigFile, 'utf8'));
503
- results.push({ harness: 'Claude Code', server: 'open-design', configured: Boolean(cfg.mcpServers?.['open-design']) });
546
+ const content = fs.readFileSync(codexConfigFile, 'utf8');
547
+ for (const s of serverNames) {
548
+ results.push({ harness: 'Codex CLI', server: s, configured: content.includes(`[mcp_servers.${s}]`) });
549
+ }
504
550
  } catch {}
505
551
  }
552
+
553
+ // Hermes (config.yaml)
554
+ const hermesConfigFile = path.join(getHermesDir(), 'config.yaml');
555
+ if (fs.existsSync(hermesConfigFile)) {
556
+ try {
557
+ const content = fs.readFileSync(hermesConfigFile, 'utf8');
558
+ const mcpSection = content.match(/^mcp_servers:[\s\S]*?(?=^[a-z_]+:|\s*$)/m);
559
+ for (const s of serverNames) {
560
+ results.push({ harness: 'Hermes', server: s, configured: Boolean(mcpSection && mcpSection[0].includes(` ${s}:`)) });
561
+ }
562
+ } catch {}
563
+ }
564
+
565
+ // VS Code (User/mcp.json)
566
+ const vscodeMcpFile = path.join(getVSCodeUserDir(), 'mcp.json');
567
+ if (fs.existsSync(vscodeMcpFile)) {
568
+ try {
569
+ const cfg = JSON.parse(fs.readFileSync(vscodeMcpFile, 'utf8'));
570
+ for (const s of serverNames) {
571
+ results.push({ harness: 'VS Code', server: s, configured: Boolean(cfg.servers?.[s]) });
572
+ }
573
+ } catch {}
574
+ }
575
+
506
576
  return results;
507
577
  }
508
578
 
@@ -597,6 +667,31 @@ function detectOpenClawBinary() {
597
667
  return null;
598
668
  }
599
669
 
670
+ /**
671
+ * Resiliently discovers the VS Code CLI binary on PATH and standard Windows/POSIX install paths.
672
+ */
673
+ function detectVSCodeBinary() {
674
+ const onPath = checkCommand('code');
675
+ if (onPath) return onPath;
676
+
677
+ if (os.platform() === 'win32') {
678
+ const candidates = [
679
+ path.join(process.env.LOCALAPPDATA || '', 'Programs', 'Microsoft VS Code', 'bin', 'code.cmd'),
680
+ path.join(process.env['ProgramFiles'] || 'C:\\Program Files', 'Microsoft VS Code', 'bin', 'code.cmd')
681
+ ];
682
+ for (const cand of candidates) {
683
+ if (cand && fs.existsSync(cand)) return cand;
684
+ }
685
+ } else if (os.platform() === 'darwin') {
686
+ const macCand = '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code';
687
+ if (fs.existsSync(macCand)) return macCand;
688
+ } else {
689
+ const linuxCand = '/usr/bin/code';
690
+ if (fs.existsSync(linuxCand)) return linuxCand;
691
+ }
692
+ return null;
693
+ }
694
+
600
695
  /**
601
696
  * Ensures ~/.agents/skills is registered under external_dirs in Hermes's config.yaml.
602
697
  */
@@ -653,13 +748,10 @@ function configureHermesContextLimit(hermesDir, modelsList = null, dryRun = fals
653
748
  }
654
749
  }
655
750
 
656
- // Ensure default fallbacks for common models
657
- if (!contextMap['claude-opus-5-5']) contextMap['claude-opus-5-5'] = 1000000;
658
- if (!contextMap['claude-sonnet-5']) contextMap['claude-sonnet-5'] = 1000000;
659
- if (!contextMap['claude-fable-5.1']) contextMap['claude-fable-5.1'] = 1000000;
660
- if (!contextMap['gpt-6-astra']) contextMap['gpt-6-astra'] = 1000000;
661
- if (!contextMap['z-ai/glm-5.3']) contextMap['z-ai/glm-5.3'] = 1000000;
662
- if (!contextMap['z-ai/glm-5.3-flash']) contextMap['z-ai/glm-5.3-flash'] = 1000000;
751
+ // Ensure default fallbacks from canonical model context registry
752
+ for (const [id, tokens] of Object.entries(CANONICAL_MODEL_CONTEXTS)) {
753
+ if (!contextMap[id]) contextMap[id] = tokens;
754
+ }
663
755
 
664
756
  return updateHermesConfigContext(hermesDir, contextMap, dryRun);
665
757
  }
@@ -710,6 +802,7 @@ function detectEnvironment() {
710
802
  detected.tools.codex = detectCodexBinary();
711
803
  detected.tools.hermes = detectHermesBinary();
712
804
  detected.tools.openclaw = detectOpenClawBinary();
805
+ detected.tools.vscode = detectVSCodeBinary();
713
806
  detected.tools.cursor = checkCommand('cursor');
714
807
  detected.tools.windsurf = checkCommand('windsurf');
715
808
 
@@ -799,9 +892,106 @@ function detectEnvironment() {
799
892
  detected.endpoints.openclaw = 'Not Installed / Unconfigured';
800
893
  }
801
894
 
895
+ // 8. Check VS Code / Copilot endpoint
896
+ const vscodeSettingsPath = path.join(getVSCodeUserDir(), 'settings.json');
897
+ if (fs.existsSync(vscodeSettingsPath)) {
898
+ try {
899
+ const raw = fs.readFileSync(vscodeSettingsPath, 'utf8');
900
+ const envMatch = raw.match(/"ANTHROPIC_BASE_URL"\s*:\s*"([^"]+)"/) || raw.match(/"OPENAI_BASE_URL"\s*:\s*"([^"]+)"/);
901
+ if (envMatch) detected.endpoints.vscode = envMatch[1];
902
+ } catch {}
903
+ }
904
+ if (!detected.endpoints.vscode && (detected.tools.vscode || fs.existsSync(getVSCodeUserDir()) || fs.existsSync(getCopilotDir()))) {
905
+ detected.endpoints.vscode = 'GitHub Copilot / Local User Config';
906
+ } else if (!detected.endpoints.vscode) {
907
+ detected.endpoints.vscode = 'Not Installed / Unconfigured';
908
+ }
909
+
802
910
  return detected;
803
911
  }
804
912
 
913
+ function syncHud(dryRun = false, hudOptions = {}) {
914
+ const hudScript = path.join(toolsDir, 'heimdall-hud.mjs');
915
+ if (!fs.existsSync(hudScript)) return false;
916
+ let updated = false;
917
+
918
+ if (hudOptions.off) {
919
+ if (disableClaudeStatusLine(dryRun)) {
920
+ console.log(` ${colors.yellow}✔ Disabled Heimdall HUD statusLine in Claude Code (~/.claude/settings.json)${colors.reset}`);
921
+ updated = true;
922
+ }
923
+ if (disableAntigravityStatusLine(dryRun)) {
924
+ console.log(` ${colors.yellow}✔ Disabled Heimdall HUD statusLine in Antigravity (~/.gemini/antigravity-cli/settings.json)${colors.reset}`);
925
+ updated = true;
926
+ }
927
+ if (disableCodexStatusLine(dryRun)) {
928
+ console.log(` ${colors.yellow}✔ Disabled [tui] status_line in Codex CLI (~/.codex/config.toml)${colors.reset}`);
929
+ updated = true;
930
+ }
931
+ return updated;
932
+ }
933
+
934
+ if (hudOptions.theme || hudOptions.lines) {
935
+ writeHudConfig({ theme: hudOptions.theme, lines: hudOptions.lines }, dryRun);
936
+ console.log(` ${colors.green}✔ Saved HUD preferences (~/.heimdall-hud.json): theme=${hudOptions.theme || 'night-blue'}, lines=${hudOptions.lines || 2}${colors.reset}`);
937
+ updated = true;
938
+ }
939
+
940
+ if (configureClaudeStatusLine(hudScript, dryRun)) {
941
+ console.log(` ${colors.green}✔ Configured Heimdall HUD statusLine in Claude Code (~/.claude/settings.json)${colors.reset}`);
942
+ updated = true;
943
+ }
944
+ if (configureAntigravityStatusLine(hudScript, dryRun)) {
945
+ console.log(` ${colors.green}✔ Configured Heimdall HUD statusLine in Antigravity (~/.gemini/antigravity-cli/settings.json)${colors.reset}`);
946
+ updated = true;
947
+ }
948
+ if (configureCodexStatusLine(dryRun)) {
949
+ console.log(` ${colors.green}✔ Configured native [tui] status_line in Codex CLI (~/.codex/config.toml)${colors.reset}`);
950
+ updated = true;
951
+ }
952
+ return updated;
953
+ }
954
+
955
+ const HUD_THEMES = ['night-blue', 'heimdall', 'claude-warm', 'titanium'];
956
+
957
+ async function runHudInteractive(options, existingRl = null) {
958
+ const rl = existingRl || readline.createInterface({ input: process.stdin, output: process.stdout });
959
+ try {
960
+ console.log(`${colors.bold}${colors.cyan}=== Heimdall HUD Statusline Configuration ===${colors.reset}\n`);
961
+ console.log(` 1. Enable / Update HUD (Claude Code, Antigravity, Codex)`);
962
+ console.log(` 2. Disable HUD across all harnesses`);
963
+ console.log(` 3. Choose HUD Theme only (night-blue, heimdall, claude-warm, titanium)`);
964
+ const action = (await rl.question(`Choose an option [1-3, default: 1]: `)).trim();
965
+
966
+ if (action === '2') {
967
+ const updated = syncHud(options.dryRun, { off: true });
968
+ if (!updated) console.log(` ${colors.dim}HUD was not active in any harness.${colors.reset}`);
969
+ return;
970
+ }
971
+
972
+ console.log(`\n${colors.yellow}Select HUD Color Theme:${colors.reset}`);
973
+ console.log(` 1. night-blue [Default]`);
974
+ console.log(` 2. heimdall`);
975
+ console.log(` 3. claude-warm`);
976
+ console.log(` 4. titanium`);
977
+ const tChoice = (await rl.question(`Choose theme [1-4, default: 1]: `)).trim();
978
+ const themeIdx = parseInt(tChoice, 10);
979
+ const chosenTheme = (themeIdx >= 1 && themeIdx <= HUD_THEMES.length) ? HUD_THEMES[themeIdx - 1] : 'night-blue';
980
+
981
+ const lChoice = (await rl.question(`Layout lines? [1 or 2, default: 2]: `)).trim();
982
+ const chosenLines = lChoice === '1' ? 1 : 2;
983
+
984
+ if (action === '3') {
985
+ writeHudConfig({ theme: chosenTheme, lines: chosenLines }, options.dryRun);
986
+ console.log(` ${colors.green}✔ Updated ~/.heimdall-hud.json (theme=${chosenTheme}, lines=${chosenLines})${colors.reset}`);
987
+ } else {
988
+ syncHud(options.dryRun, { theme: chosenTheme, lines: chosenLines });
989
+ }
990
+ } finally {
991
+ if (!existingRl) rl.close();
992
+ }
993
+ }
994
+
805
995
  function printHelp() {
806
996
  console.log(`
807
997
  ${colors.bold}${colors.cyan}Heimdall Agent CLI${colors.reset} — Intelligent Multi-Agent Sentinel & Quality Bootstrapper
@@ -818,13 +1008,14 @@ ${colors.bold}PRIMARY SUBCOMMANDS:${colors.reset}
818
1008
  ${colors.green}audit${colors.reset} (or ${colors.dim}--audit${colors.reset}) Audit installed harnesses, active API endpoints, and skill counts
819
1009
  ${colors.green}uninstall${colors.reset} (or ${colors.dim}--uninstall${colors.reset}) Safely remove Heimdall skills and agent personas from all harnesses
820
1010
  ${colors.green}sync-models${colors.reset} (or ${colors.dim}--sync-models${colors.reset}) Probe active proxy/endpoint (e.g. Custom Proxies / API or Custom Vendors) and refresh models.json
1011
+ ${colors.green}hud${colors.reset} (or ${colors.dim}--hud${colors.reset}) Enable, disable, or theme Heimdall HUD (--on | --off | --theme <name> | --lines <1|2>)
821
1012
  ${colors.green}skills${colors.reset} (or ${colors.dim}--skills${colors.reset}) List all canonical skills, categories, and upstream provenance
822
1013
  ${colors.green}update-skill <name|all>${colors.reset} Inspect upstream repository, updates, and bounded review protocol
823
1014
  ${colors.green}help${colors.reset} (or ${colors.dim}--help, -h${colors.reset}) Display this parameter and command reference
824
1015
 
825
1016
  ${colors.bold}SETUP & BOOTSTRAP OPTIONS:${colors.reset}
826
- ${colors.yellow}--profile <name>${colors.reset} Skill profile tier: full (64), minimal (16), security (12), design (14) [default: full]
827
- ${colors.yellow}--agents <targets>${colors.reset} Comma-separated harnesses: claude, gemini, codex, hermes, openclaw, desktop, all [default: all]
1017
+ ${colors.yellow}--profile <name>${colors.reset} Skill profile tier: full (69), minimal (16), security (12), design (14) [default: full]
1018
+ ${colors.yellow}--agents <targets>${colors.reset} Comma-separated harnesses: claude, gemini, codex, hermes, openclaw, vscode, desktop, all [default: all]
828
1019
  ${colors.yellow}--link / --no-link${colors.reset} Use live NTFS junctions / symlinks vs static copies [default: false in wizard, true recommended]
829
1020
  ${colors.yellow}--clean${colors.reset} Wipe legacy skills from target directory before deploying
830
1021
  ${colors.yellow}-y, --yes${colors.reset} Non-interactive mode (use defaults or provided CLI arguments)
@@ -833,6 +1024,8 @@ ${colors.bold}SETUP & BOOTSTRAP OPTIONS:${colors.reset}
833
1024
  ${colors.yellow}--doctrine-path <file>${colors.reset} Custom file destination for AGENTS.md universal doctrine
834
1025
  ${colors.yellow}--no-tools${colors.reset} Skip deploying bridge tools and CLI shims
835
1026
  ${colors.yellow}--no-doctrine${colors.reset} Skip deploying AGENTS.md universal doctrine
1027
+ ${colors.yellow}--no-hud${colors.reset} Skip configuring Heimdall HUD statusline during install/sync
1028
+ ${colors.yellow}--theme <name>${colors.reset} HUD color theme: night-blue [default], heimdall, claude-warm, titanium
836
1029
 
837
1030
  ${colors.bold}EXAMPLES:${colors.reset}
838
1031
  heimdall # Interactive management hub (audit, sync, uninstall)
@@ -865,6 +1058,11 @@ function parseArgs() {
865
1058
  dryRun: false,
866
1059
  audit: false,
867
1060
  syncModels: false,
1061
+ hud: false,
1062
+ hudEnabled: true,
1063
+ hudOff: false,
1064
+ hudTheme: null,
1065
+ hudLines: null,
868
1066
  listSkills: false,
869
1067
  updateSkill: null,
870
1068
  help: false,
@@ -882,6 +1080,15 @@ function parseArgs() {
882
1080
  else if (arg === 'sync-docs' || arg === '--sync-docs' || arg === 'syncdocs') options.syncDocs = true;
883
1081
  else if (arg === 'uninstall' || arg === '--uninstall') options.uninstall = true;
884
1082
  else if (arg === 'sync-models' || arg === '--sync-models' || arg === 'syncmodels') options.syncModels = true;
1083
+ else if (arg === 'hud' || arg === '--hud') options.hud = true;
1084
+ else if (arg === '--on') options.hudOff = false;
1085
+ else if (arg === '--off') options.hudOff = true;
1086
+ else if (arg === '--no-hud') options.hudEnabled = false;
1087
+ else if ((arg === '--theme' || arg === '--hud-theme') && args[i + 1]) {
1088
+ options.hudTheme = args[++i].toLowerCase();
1089
+ } else if (arg === '--lines' && args[i + 1]) {
1090
+ options.hudLines = parseInt(args[++i], 10);
1091
+ }
885
1092
  else if (arg === 'skills' || arg === '--skills') options.listSkills = true;
886
1093
  else if (arg === 'update-skill' || arg === '--update-skill' || arg === 'updateskill') {
887
1094
  options.updateSkill = args[i + 1] && !args[i + 1].startsWith('-') ? args[++i] : 'all';
@@ -1085,112 +1292,194 @@ function deployGlobalShims(targetToolsDir, dryRun = false) {
1085
1292
  }
1086
1293
  }
1087
1294
 
1088
- async function syncModelsFromEndpoint() {
1089
- console.log(`${colors.cyan}${colors.bold}=== Live Model Synchronization ===${colors.reset}\n`);
1295
+ /**
1296
+ * Probes a single model on /v1/messages with a 20s timeout and 1 retry on transient errors.
1297
+ * Definitive 4xx errors (except 408/429) or repeated 5xx mark the model 'dead'.
1298
+ * Timeouts / network hiccups after retry are marked 'slow' and preserved.
1299
+ */
1300
+ async function probeModelHealth(messagesUrl, apiKey, modelId, timeoutMs = 20000) {
1301
+ for (let attempt = 0; attempt < 2; attempt++) {
1302
+ const controller = new AbortController();
1303
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
1304
+ try {
1305
+ const res = await fetch(messagesUrl, {
1306
+ method: 'POST',
1307
+ headers: {
1308
+ 'x-api-key': apiKey,
1309
+ 'Authorization': `Bearer ${apiKey}`,
1310
+ 'anthropic-version': '2023-06-01',
1311
+ 'content-type': 'application/json'
1312
+ },
1313
+ body: JSON.stringify({
1314
+ model: modelId,
1315
+ max_tokens: 5,
1316
+ messages: [{ role: 'user', content: 'hi' }]
1317
+ }),
1318
+ signal: controller.signal
1319
+ });
1320
+ clearTimeout(timeout);
1321
+ if (res.ok) return 'alive';
1322
+ const isRetryable = res.status === 408 || res.status === 429 || res.status >= 500;
1323
+ if (!isRetryable || attempt === 1) return 'dead';
1324
+ } catch {
1325
+ clearTimeout(timeout);
1326
+ if (attempt === 1) return 'slow';
1327
+ }
1328
+ }
1329
+ return 'slow';
1330
+ }
1331
+
1332
+ /**
1333
+ * Normalizes model IDs (stripping [1m] suffixes) and deduplicates entries,
1334
+ * retaining the highest context window for each canonical model ID.
1335
+ */
1336
+ function deduplicateModelsByMaxContext(modelsList = []) {
1337
+ const byId = new Map();
1338
+ for (const m of modelsList) {
1339
+ if (!m || typeof m !== 'object') continue;
1340
+ const rawId = m.id || m.slug;
1341
+ if (!rawId || typeof rawId !== 'string') continue;
1342
+
1343
+ const id = rawId.replace(/\[1m\]$/i, '');
1344
+ const resolved = resolveModelMaxContext(m, { prioritizeMax: true });
1345
+ const displayName = (m.display_name || id).replace(/\s*\(1M\)$/i, '');
1346
+ const description = m.description || '';
1347
+ const isVariant = /\[1m\]$/i.test(rawId);
1348
+
1349
+ const existing = byId.get(id);
1350
+ if (!existing) {
1351
+ byId.set(id, {
1352
+ id,
1353
+ displayName,
1354
+ context: resolved.label,
1355
+ context_window_tokens: resolved.tokens,
1356
+ description
1357
+ });
1358
+ } else {
1359
+ if (resolved.tokens > existing.context_window_tokens) {
1360
+ existing.context_window_tokens = resolved.tokens;
1361
+ existing.context = resolved.label;
1362
+ }
1363
+ if (!isVariant && description) {
1364
+ existing.description = description;
1365
+ existing.displayName = displayName;
1366
+ } else if (!existing.description && description) {
1367
+ existing.description = description;
1368
+ }
1369
+ }
1370
+ }
1371
+ return Array.from(byId.values());
1372
+ }
1373
+
1374
+ async function syncModelsFromEndpoint({ quiet = false } = {}) {
1375
+ if (!quiet) console.log(`${colors.cyan}${colors.bold}=== Live Model Synchronization ===${colors.reset}\n`);
1090
1376
  const detected = detectEnvironment();
1091
1377
  const targetUrl = resolveCustomModelsEndpoint(detected.endpoints);
1092
1378
 
1093
1379
  if (targetUrl) {
1094
- console.log(`Probing Proxy / Vendor Models API: ${colors.yellow}${targetUrl}${colors.reset}...`);
1380
+ if (!quiet) console.log(`Probing Proxy / Vendor Models API: ${colors.yellow}${targetUrl}${colors.reset}...`);
1381
+ const rawApiKey = detected.endpoints.claude_key || detected.endpoints.codex_key || process.env.ANTHROPIC_API_KEY || process.env.GHOSTCLI_API_KEY || '';
1382
+ const apiKey = typeof rawApiKey === 'string' ? rawApiKey.trim() : '';
1383
+ const getHeaders = { Accept: 'application/json' };
1384
+ if (apiKey) {
1385
+ getHeaders['Authorization'] = `Bearer ${apiKey}`;
1386
+ getHeaders['x-api-key'] = apiKey;
1387
+ }
1388
+
1095
1389
  try {
1096
- const res = await fetch(targetUrl);
1390
+ const probeController = new AbortController();
1391
+ const probeTimeout = setTimeout(() => probeController.abort(), 10000);
1392
+ const res = await fetch(targetUrl, { headers: getHeaders, signal: probeController.signal });
1393
+ clearTimeout(probeTimeout);
1097
1394
  if (res.ok) {
1098
1395
  const data = await res.json();
1099
- const modelsList = data.data || data.models || [];
1100
- console.log(`${colors.green}✔ Successfully discovered ${modelsList.length} live models from endpoint!${colors.reset}\n`);
1396
+ const rawModelsList = data.data || data.models || [];
1397
+ const modelsList = deduplicateModelsByMaxContext(rawModelsList);
1398
+ if (!quiet) console.log(`${colors.green}✔ Successfully discovered ${modelsList.length} unique live models from endpoint!${colors.reset}\n`);
1101
1399
 
1102
1400
  let currentModels = {};
1103
1401
  if (fs.existsSync(modelsPath)) {
1104
1402
  currentModels = JSON.parse(fs.readFileSync(modelsPath, 'utf8'));
1105
1403
  }
1106
1404
 
1107
- console.log(`Checking live health of discovered models...`);
1108
- const apiKey = detected.endpoints.claude_key || detected.endpoints.codex_key || process.env.ANTHROPIC_API_KEY || process.env.GHOSTCLI_API_KEY || '';
1405
+ if (!quiet) console.log(`Checking live health of discovered models...`);
1109
1406
  const baseUrl = targetUrl.replace(/\/v1\/models\/?$/, '');
1110
1407
 
1111
- const testedModels = await Promise.all(modelsList.map(async m => {
1112
- const modelId = m.id || m.slug;
1113
- let isAlive = true;
1408
+ const messagesUrl = `${baseUrl}/v1/messages`;
1114
1409
 
1115
- if (apiKey) {
1116
- try {
1117
- const controller = new AbortController();
1118
- const timeout = setTimeout(() => controller.abort(), 8000);
1119
- const testRes = await fetch(`${baseUrl}/v1/messages`, {
1120
- method: 'POST',
1121
- headers: {
1122
- 'x-api-key': apiKey,
1123
- 'anthropic-version': '2023-06-01',
1124
- 'content-type': 'application/json'
1125
- },
1126
- body: JSON.stringify({
1127
- model: modelId,
1128
- max_tokens: 5,
1129
- messages: [{ role: 'user', content: 'hi' }]
1130
- }),
1131
- signal: controller.signal
1132
- });
1133
- clearTimeout(timeout);
1134
- isAlive = testRes.ok;
1135
- } catch {
1136
- isAlive = false;
1137
- }
1138
- }
1139
-
1140
- return { raw: m, modelId, isAlive };
1410
+ const testedModels = await Promise.all(modelsList.map(async m => {
1411
+ const status = apiKey ? await probeModelHealth(messagesUrl, apiKey, m.id, 20000) : 'alive';
1412
+ return { spec: m, modelId: m.id, status };
1141
1413
  }));
1142
1414
 
1143
- const liveModels = testedModels.filter(t => t.isAlive);
1144
- const deadModels = testedModels.filter(t => !t.isAlive);
1415
+ const liveModels = testedModels.filter(t => t.status !== 'dead');
1416
+ const deadModels = testedModels.filter(t => t.status === 'dead');
1417
+ const slowModels = testedModels.filter(t => t.status === 'slow');
1145
1418
 
1146
- if (deadModels.length > 0) {
1419
+ if (deadModels.length > 0 && !quiet) {
1147
1420
  console.log(`${colors.yellow}⚠ Filtered out ${deadModels.length} unresponsive model(s): ${deadModels.map(d => d.modelId).join(', ')}${colors.reset}\n`);
1148
1421
  }
1422
+ if (slowModels.length > 0 && !quiet) {
1423
+ console.log(`${colors.yellow}⚠ Slow / timed-out model(s) preserved: ${slowModels.map(s => s.modelId).join(', ')}${colors.reset}\n`);
1424
+ }
1149
1425
 
1150
- const mapped = liveModels.map(({ raw: m }) => {
1151
- const resolved = resolveModelMaxContext(m, { prioritizeMax: true });
1152
- return {
1153
- id: m.id || m.slug,
1154
- displayName: m.display_name || m.id,
1155
- context: resolved.label,
1156
- context_window_tokens: resolved.tokens,
1157
- description: m.description || ''
1158
- };
1159
- });
1426
+ const mapped = liveModels.map(({ spec }) => spec);
1160
1427
 
1161
1428
  currentModels.custom_proxies = mapped;
1162
1429
  currentModels.ghostcli = mapped;
1163
1430
 
1164
1431
  fs.writeFileSync(modelsPath, JSON.stringify(currentModels, null, 2));
1165
- console.log(`${colors.green}✔ Synchronized models catalog to config/models.json${colors.reset}\n`);
1432
+ if (!quiet) {
1433
+ console.log(`${colors.green}✔ Synchronized models catalog to config/models.json${colors.reset}\n`);
1434
+ console.log(`${colors.bold}Available Models Catalog (${mapped.length} models):${colors.reset}`);
1435
+ mapped.forEach(m => {
1436
+ const idStr = `${colors.cyan}${m.id.padEnd(24)}${colors.reset}`;
1437
+ const ctxStr = `${colors.yellow}[${m.context}]${colors.reset}`;
1438
+ const descStr = m.description ? `${colors.dim}— ${m.description}${colors.reset}` : '';
1439
+ console.log(` • ${idStr} ${ctxStr} ${descStr}`);
1440
+ });
1441
+ console.log('');
1442
+ }
1166
1443
 
1167
- console.log(`${colors.bold}Available Models Catalog (${mapped.length} models):${colors.reset}`);
1168
- mapped.forEach(m => {
1169
- const idStr = `${colors.cyan}${m.id.padEnd(24)}${colors.reset}`;
1170
- const ctxStr = `${colors.yellow}[${m.context}]${colors.reset}`;
1171
- const descStr = m.description ? `${colors.dim}— ${m.description}${colors.reset}` : '';
1172
- console.log(` • ${idStr} ${ctxStr} ${descStr}`);
1173
- });
1174
- console.log('');
1444
+ syncAgentsWithModels(__dirname, false);
1445
+ syncModelRegistryPlaybook(__dirname, false);
1175
1446
 
1176
1447
  const hermesDir = getHermesDir();
1177
1448
  if (fs.existsSync(hermesDir)) {
1178
1449
  const hermesContextUpdated = configureHermesContextLimit(hermesDir, mapped);
1179
- if (hermesContextUpdated) {
1450
+ if (hermesContextUpdated && !quiet) {
1180
1451
  console.log(`${colors.green}✔ Enforced maximum context limits in Hermes config.yaml${colors.reset}\n`);
1181
1452
  }
1182
1453
  }
1183
- } else {
1454
+ } else if (!quiet) {
1184
1455
  console.log(`${colors.yellow}Notice: Endpoint returned HTTP ${res.status}. Preserving cached models.json.${colors.reset}\n`);
1185
1456
  }
1186
1457
  } catch (err) {
1187
- console.log(`${colors.yellow}Notice: Could not reach remote models API (${err.message}). Using local models.json.${colors.reset}\n`);
1458
+ if (!quiet) console.log(`${colors.yellow}Notice: Could not reach remote models API (${err.message}). Using local models.json.${colors.reset}\n`);
1188
1459
  }
1189
- } else {
1460
+ } else if (!quiet) {
1190
1461
  console.log(`Using configured models from ${modelsPath}.\n`);
1191
1462
  }
1192
1463
  }
1193
1464
 
1465
+ /**
1466
+ * Ensures config/agents.json and playbooks/06-model-registry-matrix.md converge
1467
+ * with live models from config/models.json during install or resync.
1468
+ */
1469
+ async function convergeModelAwareArtifacts(options, detected) {
1470
+ if (!options.dryRun && resolveCustomModelsEndpoint(detected.endpoints)) {
1471
+ await syncModelsFromEndpoint({ quiet: true });
1472
+ }
1473
+ const agentsSync = syncAgentsWithModels(__dirname, options.dryRun);
1474
+ const playbookSync = syncModelRegistryPlaybook(__dirname, options.dryRun);
1475
+ if (agentsSync?.modified) {
1476
+ console.log(` ${colors.green}✔ Synchronized capability-based model routing in config/agents.json (${agentsSync.agentCount} agents)${colors.reset}`);
1477
+ }
1478
+ if (playbookSync?.modified) {
1479
+ console.log(` ${colors.green}✔ Synchronized live model matrix in playbooks/06-model-registry-matrix.md${colors.reset}`);
1480
+ }
1481
+ }
1482
+
1194
1483
  async function runSync(options, detected) {
1195
1484
  console.log(`${colors.bold}${colors.cyan}=== Heimdall Auto-Sync Engine ===${colors.reset}\n`);
1196
1485
 
@@ -1199,6 +1488,8 @@ async function runSync(options, detected) {
1199
1488
  console.log(` ${colors.green}✔ Synchronized documentation & catalog counts (${countSyncResult.suiteCount} suites / ${countSyncResult.skillCount} modules)${colors.reset}\n`);
1200
1489
  }
1201
1490
 
1491
+ await convergeModelAwareArtifacts(options, detected);
1492
+
1202
1493
  console.log(`Scanning for newly installed AI tools on PATH...\n`);
1203
1494
 
1204
1495
  const allAvailableSkills = fs.readdirSync(skillsDir, { withFileTypes: true })
@@ -1293,6 +1584,11 @@ async function runSync(options, detected) {
1293
1584
  const mcpSynced = syncMcpServers(detected, options);
1294
1585
  if (mcpSynced) syncedAny = true;
1295
1586
 
1587
+ // Synchronize Heimdall HUD statusline across Claude Code, Antigravity (agy), and Codex CLI
1588
+ if (options.hudEnabled !== false) {
1589
+ if (syncHud(options.dryRun, { theme: options.hudTheme, lines: options.hudLines })) syncedAny = true;
1590
+ }
1591
+
1296
1592
  // Refresh bridge tools & shims
1297
1593
  const activeToolsDir = options.toolsDir || detected.pathCandidates[0];
1298
1594
  if (activeToolsDir && fs.existsSync(activeToolsDir)) {
@@ -1335,6 +1631,10 @@ function runAudit(options) {
1335
1631
  console.log(` OpenClaw Agent: ${detected.tools.openclaw ? colors.green + detected.tools.openclaw + colors.reset : colors.dim + getOpenClawDir() + colors.reset}`);
1336
1632
  console.log(` Endpoint: ${colors.cyan}${detected.endpoints.openclaw}${colors.reset}`);
1337
1633
  }
1634
+ if (detected.tools.vscode || fs.existsSync(getVSCodeUserDir()) || fs.existsSync(getCopilotDir())) {
1635
+ console.log(` VS Code (Copilot): ${detected.tools.vscode ? colors.green + detected.tools.vscode + colors.reset : colors.dim + getVSCodeUserDir() + colors.reset}`);
1636
+ console.log(` Endpoint: ${colors.cyan}${detected.endpoints.vscode}${colors.reset}`);
1637
+ }
1338
1638
  console.log(` Claude Desktop: ${detected.tools.claudeDesktop ? colors.green + detected.tools.claudeDesktop + colors.reset : colors.dim + 'Not found' + colors.reset}`);
1339
1639
  console.log('');
1340
1640
 
@@ -1478,11 +1778,11 @@ function isHeimdallInstalled(detected) {
1478
1778
  };
1479
1779
  }
1480
1780
 
1481
- async function runUninstall(options, detected) {
1781
+ async function runUninstall(options, detected, existingRl = null) {
1482
1782
  console.log(`${colors.bold}${colors.cyan}=== Heimdall Uninstallation ===${colors.reset}\n`);
1483
1783
 
1484
1784
  if (!options.yes) {
1485
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1785
+ const rl = existingRl || readline.createInterface({ input: process.stdin, output: process.stdout });
1486
1786
  try {
1487
1787
  const confirm = await rl.question(`Are you sure you want to remove Heimdall skills and agents from all harnesses? (y/N): `);
1488
1788
  const answer = confirm.trim().toLowerCase();
@@ -1491,7 +1791,7 @@ async function runUninstall(options, detected) {
1491
1791
  return;
1492
1792
  }
1493
1793
  } finally {
1494
- rl.close();
1794
+ if (!existingRl) rl.close();
1495
1795
  }
1496
1796
  }
1497
1797
 
@@ -1600,59 +1900,75 @@ async function runUninstall(options, detected) {
1600
1900
  } catch {}
1601
1901
  }
1602
1902
 
1903
+ // Unregister HUD statuslines if present
1904
+ disableClaudeStatusLine(options.dryRun);
1905
+ disableAntigravityStatusLine(options.dryRun);
1906
+ disableCodexStatusLine(options.dryRun);
1907
+
1603
1908
  console.log(`\n${colors.bold}${colors.green}Uninstallation Complete:${colors.reset} Removed ${totalRemovedSkills} skill bindings and ${totalRemovedAgents} agent personas across harnesses.\n`);
1604
1909
  }
1605
1910
 
1606
1911
  async function runPostInstallMenu(options, detected) {
1607
1912
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1608
- const hasCustomApi = Boolean(resolveCustomModelsEndpoint(detected.endpoints));
1913
+ let currentDetected = detected;
1609
1914
  try {
1610
- console.log(`${colors.bold}${colors.cyan}=== Heimdall Management Hub ===${colors.reset}`);
1611
- console.log(`Heimdall is currently installed and active across your environment.\n`);
1612
- console.log(`What would you like to do?`);
1613
-
1614
- const menuItems = [
1615
- { label: 'Audit Environment & Health Check', action: 'audit' },
1616
- { label: 'Fast Sync Skills & Agents (1-sec zero-drift)', action: 'sync' },
1617
- ...(hasCustomApi ? [{ label: 'Refresh Dynamic Models (sync-models)', action: 'sync-models' }] : []),
1618
- { label: 'Uninstall Heimdall', action: 'uninstall' },
1619
- { label: 'Reinstall / Reconfigure Profile & Targets', action: 'reinstall' },
1620
- { label: 'Exit', action: 'exit' }
1621
- ];
1915
+ while (true) {
1916
+ const hasCustomApi = Boolean(resolveCustomModelsEndpoint(currentDetected.endpoints));
1917
+ console.log(`${colors.bold}${colors.cyan}=== Heimdall Management Hub ===${colors.reset}`);
1918
+ console.log(`Heimdall is currently installed and active across your environment.\n`);
1919
+ console.log(`What would you like to do?`);
1920
+
1921
+ const menuItems = [
1922
+ { label: 'Audit Environment & Health Check', action: 'audit' },
1923
+ { label: 'Fast Sync Skills & Agents (1-sec zero-drift)', action: 'sync' },
1924
+ ...(hasCustomApi ? [{ label: 'Refresh Dynamic Models (sync-models)', action: 'sync-models' }] : []),
1925
+ { label: 'Configure / Toggle Heimdall HUD Statusline', action: 'hud' },
1926
+ { label: 'Uninstall Heimdall', action: 'uninstall' },
1927
+ { label: 'Reinstall / Reconfigure Profile & Targets', action: 'reinstall' },
1928
+ { label: 'Exit', action: 'exit' }
1929
+ ];
1930
+
1931
+ menuItems.forEach((item, idx) => {
1932
+ console.log(` ${idx + 1}. ${item.label}`);
1933
+ });
1934
+ console.log('');
1622
1935
 
1623
- menuItems.forEach((item, idx) => {
1624
- console.log(` ${idx + 1}. ${item.label}`);
1625
- });
1626
- console.log('');
1936
+ const answer = await rl.question(`Choose an option [1-${menuItems.length}, default: 1]: `);
1937
+ const choice = answer.trim().toLowerCase();
1627
1938
 
1628
- const answer = await rl.question(`Choose an option [1-${menuItems.length}, default: 1]: `);
1629
- const choice = answer.trim().toLowerCase();
1630
-
1631
- if (choice === 'q' || choice === 'exit') {
1632
- console.log('Goodbye!');
1633
- process.exit(0);
1634
- }
1635
-
1636
- const idx = choice === '' ? 0 : parseInt(choice, 10) - 1;
1637
- const selected = menuItems[idx] ? menuItems[idx].action : 'audit';
1638
-
1639
- if (selected === 'audit') {
1640
- runAudit(options);
1641
- process.exit(0);
1642
- } else if (selected === 'sync') {
1643
- await runSync(options, detected);
1644
- process.exit(0);
1645
- } else if (selected === 'sync-models') {
1646
- await syncModelsFromEndpoint();
1647
- process.exit(0);
1648
- } else if (selected === 'uninstall') {
1649
- await runUninstall(options, detected);
1650
- process.exit(0);
1651
- } else if (selected === 'reinstall') {
1652
- return 'reinstall';
1653
- } else if (selected === 'exit') {
1654
- console.log('Goodbye!');
1655
- process.exit(0);
1939
+ if (choice === 'q' || choice === 'exit') {
1940
+ console.log('Goodbye!');
1941
+ process.exit(0);
1942
+ }
1943
+
1944
+ const idx = choice === '' ? 0 : parseInt(choice, 10) - 1;
1945
+ const selected = menuItems[idx] ? menuItems[idx].action : 'audit';
1946
+
1947
+ if (selected === 'audit') {
1948
+ runAudit(options);
1949
+ } else if (selected === 'sync') {
1950
+ await runSync(options, currentDetected);
1951
+ } else if (selected === 'sync-models') {
1952
+ await syncModelsFromEndpoint();
1953
+ } else if (selected === 'hud') {
1954
+ await runHudInteractive(options, rl);
1955
+ } else if (selected === 'uninstall') {
1956
+ await runUninstall(options, currentDetected, rl);
1957
+ } else if (selected === 'reinstall') {
1958
+ return 'reinstall';
1959
+ } else if (selected === 'exit') {
1960
+ console.log('Goodbye!');
1961
+ process.exit(0);
1962
+ }
1963
+
1964
+ const next = await rl.question(`\nReturn to main menu? (y/n, default: y): `);
1965
+ const nextChoice = next.trim().toLowerCase();
1966
+ if (nextChoice === 'n' || nextChoice === 'no' || nextChoice === 'q' || nextChoice === 'exit') {
1967
+ console.log('Goodbye!');
1968
+ process.exit(0);
1969
+ }
1970
+ console.log('');
1971
+ currentDetected = detectEnvironment();
1656
1972
  }
1657
1973
  } finally {
1658
1974
  rl.close();
@@ -1674,6 +1990,8 @@ async function runInteractive(options, detected) {
1674
1990
  console.log(` ${colors.dim}Endpoint: ${detected.endpoints.hermes}${colors.reset}`);
1675
1991
  console.log(` [${detected.tools.openclaw ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] OpenClaw ${detected.tools.openclaw ? '(' + detected.tools.openclaw + ')' : '(Not found)'}`);
1676
1992
  console.log(` ${colors.dim}Endpoint: ${detected.endpoints.openclaw}${colors.reset}`);
1993
+ console.log(` [${detected.tools.vscode ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] VS Code (Copilot) ${detected.tools.vscode ? '(' + detected.tools.vscode + ')' : '(Not found)'}`);
1994
+ console.log(` ${colors.dim}Endpoint: ${detected.endpoints.vscode}${colors.reset}`);
1677
1995
  console.log(` [${detected.tools.claudeDesktop ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] Claude Desktop ${detected.tools.claudeDesktop ? '(' + detected.tools.claudeDesktop + ')' : '(Not found)'}`);
1678
1996
  console.log('');
1679
1997
 
@@ -1684,25 +2002,27 @@ async function runInteractive(options, detected) {
1684
2002
  console.log(` 4. OpenAI Codex CLI only`);
1685
2003
  console.log(` 5. Hermes Agent only`);
1686
2004
  console.log(` 6. OpenClaw only`);
1687
- console.log(` 7. Claude Desktop only (MCP & Playbooks)`);
1688
- console.log(` 8. Custom Multi-Selection (e.g. Claude + Hermes)`);
2005
+ console.log(` 7. VS Code (Copilot) only`);
2006
+ console.log(` 8. Claude Desktop only (MCP & Playbooks)`);
2007
+ console.log(` 9. Custom Multi-Selection (e.g. Claude + VS Code)`);
1689
2008
 
1690
- const tChoice = await rl.question(`Choose installation targets [1-8, default: 1]: `);
2009
+ const tChoice = await rl.question(`Choose installation targets [1-9, default: 1]: `);
1691
2010
  if (tChoice === '2') options.agents = ['claude'];
1692
2011
  else if (tChoice === '3') options.agents = ['gemini'];
1693
2012
  else if (tChoice === '4') options.agents = ['codex'];
1694
2013
  else if (tChoice === '5') options.agents = ['hermes'];
1695
2014
  else if (tChoice === '6') options.agents = ['openclaw'];
1696
- else if (tChoice === '7') options.agents = ['desktop'];
1697
- else if (tChoice === '8') {
1698
- const custom = await rl.question(`Enter comma-separated targets (claude, gemini, codex, hermes, openclaw, desktop): `);
2015
+ else if (tChoice === '7') options.agents = ['vscode'];
2016
+ else if (tChoice === '8') options.agents = ['desktop'];
2017
+ else if (tChoice === '9') {
2018
+ const custom = await rl.question(`Enter comma-separated targets (claude, gemini, codex, hermes, openclaw, vscode, desktop): `);
1699
2019
  options.agents = custom.split(',').map(s => s.trim().toLowerCase());
1700
2020
  } else {
1701
2021
  options.agents = ['all'];
1702
2022
  }
1703
2023
 
1704
2024
  console.log(`\n${colors.yellow}Select Installation Profile Tier:${colors.reset}`);
1705
- console.log(` 1. full - All 64 curated skills (Complete Powerhouse)`);
2025
+ console.log(` 1. full - All 69 curated skills (Complete Powerhouse)`);
1706
2026
  console.log(` 2. minimal - 16 core skills (Planning, TDD, Anti-Slop, Taste, Hygiene)`);
1707
2027
  console.log(` 3. security - 12 security skills (Differential HTTP probing, OWASP, Trail of Bits)`);
1708
2028
  console.log(` 4. design - 14 frontend skills (Taste, GSAP motion, Brandkit, Tokens)`);
@@ -1770,6 +2090,17 @@ async function runInteractive(options, detected) {
1770
2090
  options.doctrinePath = detected.doctrineCandidates[0];
1771
2091
  options.doctrine = true;
1772
2092
  }
2093
+
2094
+ // Optional Heimdall HUD statusline prompt
2095
+ console.log(`\n${colors.yellow}Heimdall HUD Statusline (Claude Code, Antigravity, Codex):${colors.reset}`);
2096
+ const hudChoice = (await rl.question(`Enable Heimdall HUD statusline? (y/n, default: y): `)).trim().toLowerCase();
2097
+ options.hudEnabled = hudChoice !== 'n' && hudChoice !== 'no';
2098
+ if (options.hudEnabled) {
2099
+ console.log(` 1. night-blue [Default] 2. heimdall 3. claude-warm 4. titanium`);
2100
+ const htChoice = (await rl.question(`Choose HUD theme [1-4, default: 1]: `)).trim();
2101
+ const htIdx = parseInt(htChoice, 10);
2102
+ options.hudTheme = (htIdx >= 1 && htIdx <= HUD_THEMES.length) ? HUD_THEMES[htIdx - 1] : 'night-blue';
2103
+ }
1773
2104
  } finally {
1774
2105
  rl.close();
1775
2106
  }
@@ -1920,6 +2251,23 @@ async function main() {
1920
2251
  process.exit(0);
1921
2252
  }
1922
2253
 
2254
+ if (options.hud) {
2255
+ if (!options.hudOff && !options.hudTheme && !options.hudLines && !options.yes && process.stdin.isTTY && !process.argv.includes('--on')) {
2256
+ await runHudInteractive(options);
2257
+ } else {
2258
+ console.log(`${colors.bold}${colors.cyan}=== Heimdall HUD Statusline Sync ===${colors.reset}\n`);
2259
+ const updated = syncHud(options.dryRun, {
2260
+ off: options.hudOff,
2261
+ theme: options.hudTheme,
2262
+ lines: options.hudLines
2263
+ });
2264
+ if (!updated) {
2265
+ console.log(` ${colors.green}✔${colors.reset} HUD statusline already up to date across detected harnesses.`);
2266
+ }
2267
+ }
2268
+ process.exit(0);
2269
+ }
2270
+
1923
2271
  if (options.syncDocs) {
1924
2272
  const res = syncCatalogCounts(__dirname, options.dryRun);
1925
2273
  if (res) {
@@ -1969,6 +2317,8 @@ async function main() {
1969
2317
 
1970
2318
  console.log(`\n${colors.bold}${colors.cyan}=== Executing Heimdall Installation ===${colors.reset}`);
1971
2319
  console.log(`Profile: ${colors.bold}${selectedProfile.name}${colors.reset} (${options.profile})`);
2320
+
2321
+ await convergeModelAwareArtifacts(options, detected);
1972
2322
  console.log(`Mode: ${options.link ? colors.cyan + 'Live Junctions (Single Source of Truth)' + colors.reset : 'Physical Copies'}`);
1973
2323
  console.log(`Cleanup: ${options.clean ? colors.yellow + 'Wiping legacy skills before install' + colors.reset : 'Incremental update'}`);
1974
2324
  console.log(`Targets: ${options.agents.join(', ')}`);
@@ -2007,7 +2357,14 @@ async function main() {
2007
2357
  // 3. Clean and deploy skills
2008
2358
  for (const [agent, targetDir] of activeDestinations) {
2009
2359
  const rootDir = getAgentRootDir(agent);
2010
- if (!rootDir || !fs.existsSync(rootDir)) continue;
2360
+ if (!rootDir) continue;
2361
+ if (!fs.existsSync(rootDir)) {
2362
+ if (agent === 'vscode' && !options.dryRun) {
2363
+ fs.mkdirSync(rootDir, { recursive: true });
2364
+ } else if (agent !== 'vscode') {
2365
+ continue;
2366
+ }
2367
+ }
2011
2368
 
2012
2369
  console.log(`\n-> Deploying to ${colors.bold}${agent.toUpperCase()}${colors.reset} (${targetDir})...`);
2013
2370
  if (!options.dryRun && !fs.existsSync(targetDir)) {
@@ -2175,6 +2532,12 @@ async function main() {
2175
2532
  }
2176
2533
  }
2177
2534
 
2535
+ // 7. Configure Heimdall HUD Statusline if enabled
2536
+ if (options.hudEnabled !== false) {
2537
+ console.log(`\n-> Configuring Heimdall HUD Statusline...`);
2538
+ syncHud(options.dryRun, { theme: options.hudTheme, lines: options.hudLines });
2539
+ }
2540
+
2178
2541
  console.log(`\n${colors.bold}${colors.green}=== Heimdall Installation Complete! ===${colors.reset}\n`);
2179
2542
  }
2180
2543