heimdall-agent 1.2.0 → 1.4.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/README.md +99 -29
- package/README.pt-BR.md +100 -30
- package/agents/frontend-designer.md +6 -1
- package/agents/modernizer.md +4 -1
- package/agents/orchestrator.md +2 -1
- package/agents/reviewer.md +1 -1
- package/config/agents.json +166 -4
- package/config/mcp.resolved.json +74 -0
- package/config/mcp.template.json +85 -0
- package/config/models.json +70 -0
- package/config/profiles.json +4 -3
- package/config/skills.json +911 -762
- package/docs/SKILLS.md +82 -21
- package/docs/designs/old/2026-11-16 upstream-skill-sync-and-provenance-links.md +60 -0
- package/doctrine/AGENTS.md +3 -3
- package/hooks/heimdall-hook.cjs +16 -1
- package/hooks/hooks.json +11 -0
- package/lib/model-context.cjs +50 -1
- package/lib/model-router.cjs +294 -0
- package/package.json +1 -1
- package/playbooks/05-canonical-plan-template.md +5 -12
- package/playbooks/06-model-registry-matrix.md +27 -19
- package/readme.html +1006 -0
- package/setup.mjs +317 -206
- package/skills/communication-doctrine/SKILL.md +2 -2
- package/skills/handoff/SKILL.md +13 -0
- package/skills/mcp-cleanup/SKILL.md +61 -0
- package/skills/mcp-sync/SKILL.md +58 -0
- package/skills/modern-web-guidance/SKILL.md +90 -0
- package/skills/ruminate/SKILL.md +140 -0
- package/skills/taste-skill/SKILL.md +367 -534
- package/skills/upstream-skill-sync/SKILL.md +46 -0
- package/skills/writing-plans/SKILL.md +1 -1
package/setup.mjs
CHANGED
|
@@ -18,7 +18,8 @@ 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';
|
|
@@ -385,124 +386,143 @@ function resolveOpenDesignMcpConfig() {
|
|
|
385
386
|
}
|
|
386
387
|
|
|
387
388
|
/**
|
|
388
|
-
*
|
|
389
|
-
*
|
|
389
|
+
* Installs required MCP npm packages globally so configs use direct node.exe calls
|
|
390
|
+
* instead of npx (which spawns 4-5 orphan-prone processes per server on Windows).
|
|
390
391
|
*/
|
|
391
|
-
function
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
}
|
|
392
|
+
function installMcpPackages(options = {}) {
|
|
393
|
+
const requiredPackages = ['@upstash/context7-mcp', 'chrome-devtools-mcp'];
|
|
394
|
+
const missing = [];
|
|
422
395
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
396
|
+
try {
|
|
397
|
+
const npmRoot = execSync('npm root -g', { encoding: 'utf8' }).replace(/\r/g, '').trim();
|
|
398
|
+
for (const pkg of requiredPackages) {
|
|
399
|
+
const pkgDir = path.join(npmRoot, pkg);
|
|
400
|
+
if (!fs.existsSync(pkgDir)) missing.push(pkg);
|
|
427
401
|
}
|
|
402
|
+
} catch {
|
|
403
|
+
missing.push(...requiredPackages);
|
|
428
404
|
}
|
|
429
405
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
let deskConfig = { mcpServers: {} };
|
|
435
|
-
try { deskConfig = JSON.parse(fs.readFileSync(claudeDesktopFile, 'utf8')); } catch {}
|
|
436
|
-
if (!deskConfig.mcpServers) deskConfig.mcpServers = {};
|
|
406
|
+
if (missing.length === 0) {
|
|
407
|
+
console.log(` ${colors.green}✔${colors.reset} MCP packages already installed globally (${requiredPackages.join(', ')})`);
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
437
410
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (mcpRegistry.context7?.config && !deskConfig.mcpServers['context7']) {
|
|
444
|
-
deskConfig.mcpServers['context7'] = mcpRegistry.context7.config;
|
|
445
|
-
deskUpdated = true;
|
|
446
|
-
}
|
|
411
|
+
console.log(` ${colors.cyan}→${colors.reset} Installing MCP packages globally: ${missing.join(', ')}`);
|
|
412
|
+
if (options.dryRun) {
|
|
413
|
+
console.log(` ${colors.yellow}(dry run — would run: npm install -g ${missing.join(' ')})${colors.reset}`);
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
447
416
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
417
|
+
try {
|
|
418
|
+
execSync(`npm install -g ${missing.join(' ')}`, { stdio: ['pipe', 'pipe', 'pipe'], timeout: 120000 });
|
|
419
|
+
console.log(` ${colors.green}✔${colors.reset} Installed ${missing.join(', ')} globally`);
|
|
420
|
+
return true;
|
|
421
|
+
} catch (err) {
|
|
422
|
+
console.log(` ${colors.red}✘${colors.reset} Failed to install MCP packages: ${err.message}`);
|
|
423
|
+
console.log(` ${colors.yellow} Run manually: npm install -g ${missing.join(' ')}${colors.reset}`);
|
|
424
|
+
return false;
|
|
453
425
|
}
|
|
426
|
+
}
|
|
454
427
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
428
|
+
/**
|
|
429
|
+
* Synchronizes MCP servers across all harnesses (Gemini, Claude, Codex, Hermes)
|
|
430
|
+
* using the template-based resolver. Replaces legacy per-harness sync logic.
|
|
431
|
+
* Uses direct node.exe paths to avoid Windows npx process multiplication.
|
|
432
|
+
*/
|
|
433
|
+
function syncMcpServers(detected, options = {}) {
|
|
434
|
+
// Step 1: Ensure MCP packages are installed globally
|
|
435
|
+
installMcpPackages(options);
|
|
461
436
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
437
|
+
// Step 2: Run the resolver to generate resolved config and sync to all harnesses
|
|
438
|
+
const resolverScript = path.join(__dirname, 'scripts', 'resolve-mcp.mjs');
|
|
439
|
+
if (!fs.existsSync(resolverScript)) {
|
|
440
|
+
console.log(` ${colors.red}✘${colors.reset} MCP resolver not found at ${resolverScript}`);
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
467
443
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
syncedAny = true;
|
|
472
|
-
}
|
|
444
|
+
if (options.dryRun) {
|
|
445
|
+
console.log(` ${colors.yellow}(dry run — would run: node scripts/resolve-mcp.mjs --sync)${colors.reset}`);
|
|
446
|
+
return true;
|
|
473
447
|
}
|
|
474
448
|
|
|
475
|
-
|
|
449
|
+
try {
|
|
450
|
+
const output = execSync(`node "${resolverScript}" --sync`, {
|
|
451
|
+
encoding: 'utf8',
|
|
452
|
+
cwd: __dirname,
|
|
453
|
+
timeout: 60000
|
|
454
|
+
});
|
|
455
|
+
// Print resolver output lines prefixed with checkmarks
|
|
456
|
+
for (const line of output.split('\n')) {
|
|
457
|
+
const trimmed = line.trim();
|
|
458
|
+
if (trimmed.startsWith('✓')) {
|
|
459
|
+
console.log(` ${colors.green}✔${colors.reset} ${trimmed.slice(2).trim()}`);
|
|
460
|
+
} else if (trimmed.startsWith('⚠')) {
|
|
461
|
+
console.log(` ${colors.yellow}⚠${colors.reset} ${trimmed.slice(2).trim()}`);
|
|
462
|
+
} else if (trimmed) {
|
|
463
|
+
console.log(` ${colors.dim}${trimmed}${colors.reset}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return true;
|
|
467
|
+
} catch (err) {
|
|
468
|
+
console.log(` ${colors.red}✘${colors.reset} MCP resolver failed: ${err.message}`);
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
476
471
|
}
|
|
477
472
|
|
|
478
473
|
/**
|
|
479
|
-
* Audits registered and configured MCP servers across harnesses.
|
|
474
|
+
* Audits registered and configured MCP servers across all harnesses.
|
|
475
|
+
* Checks Gemini, Claude Code (settings.json), Codex (config.toml), and Hermes (config.yaml).
|
|
480
476
|
*/
|
|
481
477
|
function auditMcpServers() {
|
|
482
478
|
const results = [];
|
|
479
|
+
const serverNames = ['context7', 'chrome-devtools', 'open-design', 'rea', 'mobbin'];
|
|
480
|
+
|
|
481
|
+
// Gemini
|
|
483
482
|
const agyMcpFile = path.join(userHome, '.gemini', 'config', 'mcp_config.json');
|
|
484
483
|
if (fs.existsSync(agyMcpFile)) {
|
|
485
484
|
try {
|
|
486
485
|
const cfg = JSON.parse(fs.readFileSync(agyMcpFile, 'utf8'));
|
|
487
|
-
|
|
488
|
-
|
|
486
|
+
for (const s of serverNames) {
|
|
487
|
+
results.push({ harness: 'Google Antigravity', server: s, configured: Boolean(cfg.mcpServers?.[s]) });
|
|
488
|
+
}
|
|
489
489
|
} catch {}
|
|
490
490
|
}
|
|
491
|
-
|
|
492
|
-
|
|
491
|
+
|
|
492
|
+
// Claude Code (settings.json — correct location for MCP servers)
|
|
493
|
+
const claudeSettingsFile = path.join(userHome, '.claude', 'settings.json');
|
|
494
|
+
if (fs.existsSync(claudeSettingsFile)) {
|
|
495
|
+
try {
|
|
496
|
+
const cfg = JSON.parse(fs.readFileSync(claudeSettingsFile, 'utf8'));
|
|
497
|
+
for (const s of serverNames) {
|
|
498
|
+
results.push({ harness: 'Claude Code', server: s, configured: Boolean(cfg.mcpServers?.[s]) });
|
|
499
|
+
}
|
|
500
|
+
} catch {}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Codex CLI (config.toml)
|
|
504
|
+
const codexConfigFile = path.join(userHome, '.codex', 'config.toml');
|
|
505
|
+
if (fs.existsSync(codexConfigFile)) {
|
|
493
506
|
try {
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
507
|
+
const content = fs.readFileSync(codexConfigFile, 'utf8');
|
|
508
|
+
for (const s of serverNames) {
|
|
509
|
+
results.push({ harness: 'Codex CLI', server: s, configured: content.includes(`[mcp_servers.${s}]`) });
|
|
510
|
+
}
|
|
497
511
|
} catch {}
|
|
498
512
|
}
|
|
499
|
-
|
|
500
|
-
|
|
513
|
+
|
|
514
|
+
// Hermes (config.yaml)
|
|
515
|
+
const hermesConfigFile = path.join(getHermesDir(), 'config.yaml');
|
|
516
|
+
if (fs.existsSync(hermesConfigFile)) {
|
|
501
517
|
try {
|
|
502
|
-
const
|
|
503
|
-
|
|
518
|
+
const content = fs.readFileSync(hermesConfigFile, 'utf8');
|
|
519
|
+
const mcpSection = content.match(/^mcp_servers:[\s\S]*?(?=^[a-z_]+:|\s*$)/m);
|
|
520
|
+
for (const s of serverNames) {
|
|
521
|
+
results.push({ harness: 'Hermes', server: s, configured: Boolean(mcpSection && mcpSection[0].includes(` ${s}:`)) });
|
|
522
|
+
}
|
|
504
523
|
} catch {}
|
|
505
524
|
}
|
|
525
|
+
|
|
506
526
|
return results;
|
|
507
527
|
}
|
|
508
528
|
|
|
@@ -653,13 +673,10 @@ function configureHermesContextLimit(hermesDir, modelsList = null, dryRun = fals
|
|
|
653
673
|
}
|
|
654
674
|
}
|
|
655
675
|
|
|
656
|
-
// Ensure default fallbacks
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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;
|
|
676
|
+
// Ensure default fallbacks from canonical model context registry
|
|
677
|
+
for (const [id, tokens] of Object.entries(CANONICAL_MODEL_CONTEXTS)) {
|
|
678
|
+
if (!contextMap[id]) contextMap[id] = tokens;
|
|
679
|
+
}
|
|
663
680
|
|
|
664
681
|
return updateHermesConfigContext(hermesDir, contextMap, dryRun);
|
|
665
682
|
}
|
|
@@ -823,7 +840,7 @@ ${colors.bold}PRIMARY SUBCOMMANDS:${colors.reset}
|
|
|
823
840
|
${colors.green}help${colors.reset} (or ${colors.dim}--help, -h${colors.reset}) Display this parameter and command reference
|
|
824
841
|
|
|
825
842
|
${colors.bold}SETUP & BOOTSTRAP OPTIONS:${colors.reset}
|
|
826
|
-
${colors.yellow}--profile <name>${colors.reset} Skill profile tier: full (
|
|
843
|
+
${colors.yellow}--profile <name>${colors.reset} Skill profile tier: full (69), minimal (16), security (12), design (14) [default: full]
|
|
827
844
|
${colors.yellow}--agents <targets>${colors.reset} Comma-separated harnesses: claude, gemini, codex, hermes, openclaw, desktop, all [default: all]
|
|
828
845
|
${colors.yellow}--link / --no-link${colors.reset} Use live NTFS junctions / symlinks vs static copies [default: false in wizard, true recommended]
|
|
829
846
|
${colors.yellow}--clean${colors.reset} Wipe legacy skills from target directory before deploying
|
|
@@ -1085,112 +1102,194 @@ function deployGlobalShims(targetToolsDir, dryRun = false) {
|
|
|
1085
1102
|
}
|
|
1086
1103
|
}
|
|
1087
1104
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1105
|
+
/**
|
|
1106
|
+
* Probes a single model on /v1/messages with a 20s timeout and 1 retry on transient errors.
|
|
1107
|
+
* Definitive 4xx errors (except 408/429) or repeated 5xx mark the model 'dead'.
|
|
1108
|
+
* Timeouts / network hiccups after retry are marked 'slow' and preserved.
|
|
1109
|
+
*/
|
|
1110
|
+
async function probeModelHealth(messagesUrl, apiKey, modelId, timeoutMs = 20000) {
|
|
1111
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
1112
|
+
const controller = new AbortController();
|
|
1113
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
1114
|
+
try {
|
|
1115
|
+
const res = await fetch(messagesUrl, {
|
|
1116
|
+
method: 'POST',
|
|
1117
|
+
headers: {
|
|
1118
|
+
'x-api-key': apiKey,
|
|
1119
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
1120
|
+
'anthropic-version': '2023-06-01',
|
|
1121
|
+
'content-type': 'application/json'
|
|
1122
|
+
},
|
|
1123
|
+
body: JSON.stringify({
|
|
1124
|
+
model: modelId,
|
|
1125
|
+
max_tokens: 5,
|
|
1126
|
+
messages: [{ role: 'user', content: 'hi' }]
|
|
1127
|
+
}),
|
|
1128
|
+
signal: controller.signal
|
|
1129
|
+
});
|
|
1130
|
+
clearTimeout(timeout);
|
|
1131
|
+
if (res.ok) return 'alive';
|
|
1132
|
+
const isRetryable = res.status === 408 || res.status === 429 || res.status >= 500;
|
|
1133
|
+
if (!isRetryable || attempt === 1) return 'dead';
|
|
1134
|
+
} catch {
|
|
1135
|
+
clearTimeout(timeout);
|
|
1136
|
+
if (attempt === 1) return 'slow';
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
return 'slow';
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* Normalizes model IDs (stripping [1m] suffixes) and deduplicates entries,
|
|
1144
|
+
* retaining the highest context window for each canonical model ID.
|
|
1145
|
+
*/
|
|
1146
|
+
function deduplicateModelsByMaxContext(modelsList = []) {
|
|
1147
|
+
const byId = new Map();
|
|
1148
|
+
for (const m of modelsList) {
|
|
1149
|
+
if (!m || typeof m !== 'object') continue;
|
|
1150
|
+
const rawId = m.id || m.slug;
|
|
1151
|
+
if (!rawId || typeof rawId !== 'string') continue;
|
|
1152
|
+
|
|
1153
|
+
const id = rawId.replace(/\[1m\]$/i, '');
|
|
1154
|
+
const resolved = resolveModelMaxContext(m, { prioritizeMax: true });
|
|
1155
|
+
const displayName = (m.display_name || id).replace(/\s*\(1M\)$/i, '');
|
|
1156
|
+
const description = m.description || '';
|
|
1157
|
+
const isVariant = /\[1m\]$/i.test(rawId);
|
|
1158
|
+
|
|
1159
|
+
const existing = byId.get(id);
|
|
1160
|
+
if (!existing) {
|
|
1161
|
+
byId.set(id, {
|
|
1162
|
+
id,
|
|
1163
|
+
displayName,
|
|
1164
|
+
context: resolved.label,
|
|
1165
|
+
context_window_tokens: resolved.tokens,
|
|
1166
|
+
description
|
|
1167
|
+
});
|
|
1168
|
+
} else {
|
|
1169
|
+
if (resolved.tokens > existing.context_window_tokens) {
|
|
1170
|
+
existing.context_window_tokens = resolved.tokens;
|
|
1171
|
+
existing.context = resolved.label;
|
|
1172
|
+
}
|
|
1173
|
+
if (!isVariant && description) {
|
|
1174
|
+
existing.description = description;
|
|
1175
|
+
existing.displayName = displayName;
|
|
1176
|
+
} else if (!existing.description && description) {
|
|
1177
|
+
existing.description = description;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
return Array.from(byId.values());
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
async function syncModelsFromEndpoint({ quiet = false } = {}) {
|
|
1185
|
+
if (!quiet) console.log(`${colors.cyan}${colors.bold}=== Live Model Synchronization ===${colors.reset}\n`);
|
|
1090
1186
|
const detected = detectEnvironment();
|
|
1091
1187
|
const targetUrl = resolveCustomModelsEndpoint(detected.endpoints);
|
|
1092
1188
|
|
|
1093
1189
|
if (targetUrl) {
|
|
1094
|
-
console.log(`Probing Proxy / Vendor Models API: ${colors.yellow}${targetUrl}${colors.reset}...`);
|
|
1190
|
+
if (!quiet) console.log(`Probing Proxy / Vendor Models API: ${colors.yellow}${targetUrl}${colors.reset}...`);
|
|
1191
|
+
const rawApiKey = detected.endpoints.claude_key || detected.endpoints.codex_key || process.env.ANTHROPIC_API_KEY || process.env.GHOSTCLI_API_KEY || '';
|
|
1192
|
+
const apiKey = typeof rawApiKey === 'string' ? rawApiKey.trim() : '';
|
|
1193
|
+
const getHeaders = { Accept: 'application/json' };
|
|
1194
|
+
if (apiKey) {
|
|
1195
|
+
getHeaders['Authorization'] = `Bearer ${apiKey}`;
|
|
1196
|
+
getHeaders['x-api-key'] = apiKey;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1095
1199
|
try {
|
|
1096
|
-
const
|
|
1200
|
+
const probeController = new AbortController();
|
|
1201
|
+
const probeTimeout = setTimeout(() => probeController.abort(), 10000);
|
|
1202
|
+
const res = await fetch(targetUrl, { headers: getHeaders, signal: probeController.signal });
|
|
1203
|
+
clearTimeout(probeTimeout);
|
|
1097
1204
|
if (res.ok) {
|
|
1098
1205
|
const data = await res.json();
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1206
|
+
const rawModelsList = data.data || data.models || [];
|
|
1207
|
+
const modelsList = deduplicateModelsByMaxContext(rawModelsList);
|
|
1208
|
+
if (!quiet) console.log(`${colors.green}✔ Successfully discovered ${modelsList.length} unique live models from endpoint!${colors.reset}\n`);
|
|
1101
1209
|
|
|
1102
1210
|
let currentModels = {};
|
|
1103
1211
|
if (fs.existsSync(modelsPath)) {
|
|
1104
1212
|
currentModels = JSON.parse(fs.readFileSync(modelsPath, 'utf8'));
|
|
1105
1213
|
}
|
|
1106
1214
|
|
|
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 || '';
|
|
1215
|
+
if (!quiet) console.log(`Checking live health of discovered models...`);
|
|
1109
1216
|
const baseUrl = targetUrl.replace(/\/v1\/models\/?$/, '');
|
|
1110
1217
|
|
|
1111
|
-
const
|
|
1112
|
-
const modelId = m.id || m.slug;
|
|
1113
|
-
let isAlive = true;
|
|
1114
|
-
|
|
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
|
-
}
|
|
1218
|
+
const messagesUrl = `${baseUrl}/v1/messages`;
|
|
1139
1219
|
|
|
1140
|
-
|
|
1220
|
+
const testedModels = await Promise.all(modelsList.map(async m => {
|
|
1221
|
+
const status = apiKey ? await probeModelHealth(messagesUrl, apiKey, m.id, 20000) : 'alive';
|
|
1222
|
+
return { spec: m, modelId: m.id, status };
|
|
1141
1223
|
}));
|
|
1142
1224
|
|
|
1143
|
-
const liveModels = testedModels.filter(t => t.
|
|
1144
|
-
const deadModels = testedModels.filter(t =>
|
|
1225
|
+
const liveModels = testedModels.filter(t => t.status !== 'dead');
|
|
1226
|
+
const deadModels = testedModels.filter(t => t.status === 'dead');
|
|
1227
|
+
const slowModels = testedModels.filter(t => t.status === 'slow');
|
|
1145
1228
|
|
|
1146
|
-
if (deadModels.length > 0) {
|
|
1229
|
+
if (deadModels.length > 0 && !quiet) {
|
|
1147
1230
|
console.log(`${colors.yellow}⚠ Filtered out ${deadModels.length} unresponsive model(s): ${deadModels.map(d => d.modelId).join(', ')}${colors.reset}\n`);
|
|
1148
1231
|
}
|
|
1232
|
+
if (slowModels.length > 0 && !quiet) {
|
|
1233
|
+
console.log(`${colors.yellow}⚠ Slow / timed-out model(s) preserved: ${slowModels.map(s => s.modelId).join(', ')}${colors.reset}\n`);
|
|
1234
|
+
}
|
|
1149
1235
|
|
|
1150
|
-
const mapped = liveModels.map(({
|
|
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
|
-
});
|
|
1236
|
+
const mapped = liveModels.map(({ spec }) => spec);
|
|
1160
1237
|
|
|
1161
1238
|
currentModels.custom_proxies = mapped;
|
|
1162
1239
|
currentModels.ghostcli = mapped;
|
|
1163
1240
|
|
|
1164
1241
|
fs.writeFileSync(modelsPath, JSON.stringify(currentModels, null, 2));
|
|
1165
|
-
|
|
1242
|
+
if (!quiet) {
|
|
1243
|
+
console.log(`${colors.green}✔ Synchronized models catalog to config/models.json${colors.reset}\n`);
|
|
1244
|
+
console.log(`${colors.bold}Available Models Catalog (${mapped.length} models):${colors.reset}`);
|
|
1245
|
+
mapped.forEach(m => {
|
|
1246
|
+
const idStr = `${colors.cyan}${m.id.padEnd(24)}${colors.reset}`;
|
|
1247
|
+
const ctxStr = `${colors.yellow}[${m.context}]${colors.reset}`;
|
|
1248
|
+
const descStr = m.description ? `${colors.dim}— ${m.description}${colors.reset}` : '';
|
|
1249
|
+
console.log(` • ${idStr} ${ctxStr} ${descStr}`);
|
|
1250
|
+
});
|
|
1251
|
+
console.log('');
|
|
1252
|
+
}
|
|
1166
1253
|
|
|
1167
|
-
|
|
1168
|
-
|
|
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('');
|
|
1254
|
+
syncAgentsWithModels(__dirname, false);
|
|
1255
|
+
syncModelRegistryPlaybook(__dirname, false);
|
|
1175
1256
|
|
|
1176
1257
|
const hermesDir = getHermesDir();
|
|
1177
1258
|
if (fs.existsSync(hermesDir)) {
|
|
1178
1259
|
const hermesContextUpdated = configureHermesContextLimit(hermesDir, mapped);
|
|
1179
|
-
if (hermesContextUpdated) {
|
|
1260
|
+
if (hermesContextUpdated && !quiet) {
|
|
1180
1261
|
console.log(`${colors.green}✔ Enforced maximum context limits in Hermes config.yaml${colors.reset}\n`);
|
|
1181
1262
|
}
|
|
1182
1263
|
}
|
|
1183
|
-
} else {
|
|
1264
|
+
} else if (!quiet) {
|
|
1184
1265
|
console.log(`${colors.yellow}Notice: Endpoint returned HTTP ${res.status}. Preserving cached models.json.${colors.reset}\n`);
|
|
1185
1266
|
}
|
|
1186
1267
|
} catch (err) {
|
|
1187
|
-
console.log(`${colors.yellow}Notice: Could not reach remote models API (${err.message}). Using local models.json.${colors.reset}\n`);
|
|
1268
|
+
if (!quiet) console.log(`${colors.yellow}Notice: Could not reach remote models API (${err.message}). Using local models.json.${colors.reset}\n`);
|
|
1188
1269
|
}
|
|
1189
|
-
} else {
|
|
1270
|
+
} else if (!quiet) {
|
|
1190
1271
|
console.log(`Using configured models from ${modelsPath}.\n`);
|
|
1191
1272
|
}
|
|
1192
1273
|
}
|
|
1193
1274
|
|
|
1275
|
+
/**
|
|
1276
|
+
* Ensures config/agents.json and playbooks/06-model-registry-matrix.md converge
|
|
1277
|
+
* with live models from config/models.json during install or resync.
|
|
1278
|
+
*/
|
|
1279
|
+
async function convergeModelAwareArtifacts(options, detected) {
|
|
1280
|
+
if (!options.dryRun && resolveCustomModelsEndpoint(detected.endpoints)) {
|
|
1281
|
+
await syncModelsFromEndpoint({ quiet: true });
|
|
1282
|
+
}
|
|
1283
|
+
const agentsSync = syncAgentsWithModels(__dirname, options.dryRun);
|
|
1284
|
+
const playbookSync = syncModelRegistryPlaybook(__dirname, options.dryRun);
|
|
1285
|
+
if (agentsSync?.modified) {
|
|
1286
|
+
console.log(` ${colors.green}✔ Synchronized capability-based model routing in config/agents.json (${agentsSync.agentCount} agents)${colors.reset}`);
|
|
1287
|
+
}
|
|
1288
|
+
if (playbookSync?.modified) {
|
|
1289
|
+
console.log(` ${colors.green}✔ Synchronized live model matrix in playbooks/06-model-registry-matrix.md${colors.reset}`);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1194
1293
|
async function runSync(options, detected) {
|
|
1195
1294
|
console.log(`${colors.bold}${colors.cyan}=== Heimdall Auto-Sync Engine ===${colors.reset}\n`);
|
|
1196
1295
|
|
|
@@ -1199,6 +1298,8 @@ async function runSync(options, detected) {
|
|
|
1199
1298
|
console.log(` ${colors.green}✔ Synchronized documentation & catalog counts (${countSyncResult.suiteCount} suites / ${countSyncResult.skillCount} modules)${colors.reset}\n`);
|
|
1200
1299
|
}
|
|
1201
1300
|
|
|
1301
|
+
await convergeModelAwareArtifacts(options, detected);
|
|
1302
|
+
|
|
1202
1303
|
console.log(`Scanning for newly installed AI tools on PATH...\n`);
|
|
1203
1304
|
|
|
1204
1305
|
const allAvailableSkills = fs.readdirSync(skillsDir, { withFileTypes: true })
|
|
@@ -1478,11 +1579,11 @@ function isHeimdallInstalled(detected) {
|
|
|
1478
1579
|
};
|
|
1479
1580
|
}
|
|
1480
1581
|
|
|
1481
|
-
async function runUninstall(options, detected) {
|
|
1582
|
+
async function runUninstall(options, detected, existingRl = null) {
|
|
1482
1583
|
console.log(`${colors.bold}${colors.cyan}=== Heimdall Uninstallation ===${colors.reset}\n`);
|
|
1483
1584
|
|
|
1484
1585
|
if (!options.yes) {
|
|
1485
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1586
|
+
const rl = existingRl || readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1486
1587
|
try {
|
|
1487
1588
|
const confirm = await rl.question(`Are you sure you want to remove Heimdall skills and agents from all harnesses? (y/N): `);
|
|
1488
1589
|
const answer = confirm.trim().toLowerCase();
|
|
@@ -1491,7 +1592,7 @@ async function runUninstall(options, detected) {
|
|
|
1491
1592
|
return;
|
|
1492
1593
|
}
|
|
1493
1594
|
} finally {
|
|
1494
|
-
rl.close();
|
|
1595
|
+
if (!existingRl) rl.close();
|
|
1495
1596
|
}
|
|
1496
1597
|
}
|
|
1497
1598
|
|
|
@@ -1605,54 +1706,62 @@ async function runUninstall(options, detected) {
|
|
|
1605
1706
|
|
|
1606
1707
|
async function runPostInstallMenu(options, detected) {
|
|
1607
1708
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1608
|
-
|
|
1709
|
+
let currentDetected = detected;
|
|
1609
1710
|
try {
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1711
|
+
while (true) {
|
|
1712
|
+
const hasCustomApi = Boolean(resolveCustomModelsEndpoint(currentDetected.endpoints));
|
|
1713
|
+
console.log(`${colors.bold}${colors.cyan}=== Heimdall Management Hub ===${colors.reset}`);
|
|
1714
|
+
console.log(`Heimdall is currently installed and active across your environment.\n`);
|
|
1715
|
+
console.log(`What would you like to do?`);
|
|
1716
|
+
|
|
1717
|
+
const menuItems = [
|
|
1718
|
+
{ label: 'Audit Environment & Health Check', action: 'audit' },
|
|
1719
|
+
{ label: 'Fast Sync Skills & Agents (1-sec zero-drift)', action: 'sync' },
|
|
1720
|
+
...(hasCustomApi ? [{ label: 'Refresh Dynamic Models (sync-models)', action: 'sync-models' }] : []),
|
|
1721
|
+
{ label: 'Uninstall Heimdall', action: 'uninstall' },
|
|
1722
|
+
{ label: 'Reinstall / Reconfigure Profile & Targets', action: 'reinstall' },
|
|
1723
|
+
{ label: 'Exit', action: 'exit' }
|
|
1724
|
+
];
|
|
1725
|
+
|
|
1726
|
+
menuItems.forEach((item, idx) => {
|
|
1727
|
+
console.log(` ${idx + 1}. ${item.label}`);
|
|
1728
|
+
});
|
|
1729
|
+
console.log('');
|
|
1622
1730
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
});
|
|
1626
|
-
console.log('');
|
|
1731
|
+
const answer = await rl.question(`Choose an option [1-${menuItems.length}, default: 1]: `);
|
|
1732
|
+
const choice = answer.trim().toLowerCase();
|
|
1627
1733
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1734
|
+
if (choice === 'q' || choice === 'exit') {
|
|
1735
|
+
console.log('Goodbye!');
|
|
1736
|
+
process.exit(0);
|
|
1737
|
+
}
|
|
1630
1738
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1739
|
+
const idx = choice === '' ? 0 : parseInt(choice, 10) - 1;
|
|
1740
|
+
const selected = menuItems[idx] ? menuItems[idx].action : 'audit';
|
|
1741
|
+
|
|
1742
|
+
if (selected === 'audit') {
|
|
1743
|
+
runAudit(options);
|
|
1744
|
+
} else if (selected === 'sync') {
|
|
1745
|
+
await runSync(options, currentDetected);
|
|
1746
|
+
} else if (selected === 'sync-models') {
|
|
1747
|
+
await syncModelsFromEndpoint();
|
|
1748
|
+
} else if (selected === 'uninstall') {
|
|
1749
|
+
await runUninstall(options, currentDetected, rl);
|
|
1750
|
+
} else if (selected === 'reinstall') {
|
|
1751
|
+
return 'reinstall';
|
|
1752
|
+
} else if (selected === 'exit') {
|
|
1753
|
+
console.log('Goodbye!');
|
|
1754
|
+
process.exit(0);
|
|
1755
|
+
}
|
|
1635
1756
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
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);
|
|
1757
|
+
const next = await rl.question(`\nReturn to main menu? (y/n, default: y): `);
|
|
1758
|
+
const nextChoice = next.trim().toLowerCase();
|
|
1759
|
+
if (nextChoice === 'n' || nextChoice === 'no' || nextChoice === 'q' || nextChoice === 'exit') {
|
|
1760
|
+
console.log('Goodbye!');
|
|
1761
|
+
process.exit(0);
|
|
1762
|
+
}
|
|
1763
|
+
console.log('');
|
|
1764
|
+
currentDetected = detectEnvironment();
|
|
1656
1765
|
}
|
|
1657
1766
|
} finally {
|
|
1658
1767
|
rl.close();
|
|
@@ -1702,7 +1811,7 @@ async function runInteractive(options, detected) {
|
|
|
1702
1811
|
}
|
|
1703
1812
|
|
|
1704
1813
|
console.log(`\n${colors.yellow}Select Installation Profile Tier:${colors.reset}`);
|
|
1705
|
-
console.log(` 1. full - All
|
|
1814
|
+
console.log(` 1. full - All 69 curated skills (Complete Powerhouse)`);
|
|
1706
1815
|
console.log(` 2. minimal - 16 core skills (Planning, TDD, Anti-Slop, Taste, Hygiene)`);
|
|
1707
1816
|
console.log(` 3. security - 12 security skills (Differential HTTP probing, OWASP, Trail of Bits)`);
|
|
1708
1817
|
console.log(` 4. design - 14 frontend skills (Taste, GSAP motion, Brandkit, Tokens)`);
|
|
@@ -1969,6 +2078,8 @@ async function main() {
|
|
|
1969
2078
|
|
|
1970
2079
|
console.log(`\n${colors.bold}${colors.cyan}=== Executing Heimdall Installation ===${colors.reset}`);
|
|
1971
2080
|
console.log(`Profile: ${colors.bold}${selectedProfile.name}${colors.reset} (${options.profile})`);
|
|
2081
|
+
|
|
2082
|
+
await convergeModelAwareArtifacts(options, detected);
|
|
1972
2083
|
console.log(`Mode: ${options.link ? colors.cyan + 'Live Junctions (Single Source of Truth)' + colors.reset : 'Physical Copies'}`);
|
|
1973
2084
|
console.log(`Cleanup: ${options.clean ? colors.yellow + 'Wiping legacy skills before install' + colors.reset : 'Incremental update'}`);
|
|
1974
2085
|
console.log(`Targets: ${options.agents.join(', ')}`);
|