heimdall-agent 0.0.0-stage → 1.0.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 +398 -2
- package/agents/code-sentinel.md +46 -0
- package/agents/database-architect.md +32 -0
- package/agents/frontend-designer.md +42 -0
- package/agents/mobile-designer.md +32 -0
- package/agents/orchestrator.md +93 -0
- package/agents/reviewer.md +82 -0
- package/agents/security-auditor.md +38 -0
- package/agents/tester.md +100 -0
- package/commands/grill-me.md +10 -0
- package/commands/orchestrate.md +21 -0
- package/commands/orchestrator.md +21 -0
- package/commands/plan.md +14 -0
- package/config/agents.json +165 -0
- package/config/models.json +105 -0
- package/config/profiles.json +88 -0
- package/config/skills.json +573 -0
- package/docs/SKILLS.md +282 -0
- package/doctrine/AGENTS.md +92 -0
- package/hooks/git/pre-push +26 -0
- package/hooks/heimdall-hook.cjs +152 -0
- package/hooks/hooks.json +47 -0
- package/package.json +54 -4
- package/playbooks/01-interactive-grilling-gate.md +41 -0
- package/playbooks/02-fast-code-deep-verification.md +31 -0
- package/playbooks/03-adversarial-code-review.md +56 -0
- package/playbooks/04-design-system-and-taste.md +27 -0
- package/playbooks/05-canonical-plan-template.md +90 -0
- package/playbooks/06-model-registry-matrix.md +72 -0
- package/setup.mjs +1764 -0
- package/skills/antislop/SKILL.md +680 -0
- package/skills/antislop-code/SKILL.md +128 -0
- package/skills/antislop-copywriting/SKILL.md +372 -0
- package/skills/antislop-human/SKILL.md +147 -0
- package/skills/antislop-human/contrast-check.py +165 -0
- package/skills/antislop-human/contrast-mcp.py +118 -0
- package/skills/antislop-layoutmobile/SKILL.md +170 -0
- package/skills/antislop-ui/SKILL.md +304 -0
- package/skills/brainstorming/SKILL.md +285 -0
- package/skills/brainstorming/scripts/frame-template.html +213 -0
- package/skills/brainstorming/scripts/helper.js +167 -0
- package/skills/brainstorming/scripts/server.cjs +723 -0
- package/skills/brainstorming/scripts/start-server.sh +209 -0
- package/skills/brainstorming/scripts/stop-server.sh +120 -0
- package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/skills/brainstorming/visual-companion.md +299 -0
- package/skills/brandkit/SKILL.md +798 -0
- package/skills/brutalist-skill/SKILL.md +92 -0
- package/skills/caveman/SKILL.md +54 -0
- package/skills/claude-collaborator/SKILL.md +73 -0
- package/skills/cloudflare-security-audit/AI-AND-LLM.md +83 -0
- package/skills/cloudflare-security-audit/ATTACK-CLASSES.md +130 -0
- package/skills/cloudflare-security-audit/CLIENT-SIDE.md +83 -0
- package/skills/cloudflare-security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
- package/skills/cloudflare-security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
- package/skills/cloudflare-security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
- package/skills/cloudflare-security-audit/HUNTING.md +251 -0
- package/skills/cloudflare-security-audit/LICENSE +21 -0
- package/skills/cloudflare-security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
- package/skills/cloudflare-security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
- package/skills/cloudflare-security-audit/README.md +106 -0
- package/skills/cloudflare-security-audit/RECONNAISSANCE.md +156 -0
- package/skills/cloudflare-security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
- package/skills/cloudflare-security-audit/SKILL.md +192 -0
- package/skills/cloudflare-security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
- package/skills/cloudflare-security-audit/VALIDATION-AND-REPORTING.md +186 -0
- package/skills/cloudflare-security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
- package/skills/cloudflare-security-audit/report-schema.json +461 -0
- package/skills/cloudflare-security-audit/validate-coverage-ledger.cjs +872 -0
- package/skills/cloudflare-security-audit/validate-coverage-ledger.test.cjs +740 -0
- package/skills/cloudflare-security-audit/validate-findings.cjs +773 -0
- package/skills/cloudflare-security-audit/validate-findings.test.cjs +652 -0
- package/skills/codex-collaborator/SKILL.md +86 -0
- package/skills/diagnosing-superpowers/SKILL.md +120 -0
- package/skills/diagnosing-superpowers/prompts/analyst-common.md +38 -0
- package/skills/diagnosing-superpowers/prompts/cost-and-time.md +28 -0
- package/skills/diagnosing-superpowers/prompts/plan-adherence.md +29 -0
- package/skills/diagnosing-superpowers/prompts/quality-evidence.md +26 -0
- package/skills/diagnosing-superpowers/prompts/repeated-work.md +30 -0
- package/skills/diagnosing-superpowers/prompts/request-conflicts.md +20 -0
- package/skills/diagnosing-superpowers/prompts/scrub-audit.md +33 -0
- package/skills/diagnosing-superpowers/prompts/scrub.md +29 -0
- package/skills/diagnosing-superpowers/prompts/similar-session.md +38 -0
- package/skills/diagnosing-superpowers/prompts/skill-timeline.md +30 -0
- package/skills/diagnosing-superpowers/prompts/stumbles.md +28 -0
- package/skills/diagnosing-superpowers/references/context-safety.md +22 -0
- package/skills/diagnosing-superpowers/references/github-issues.md +47 -0
- package/skills/diagnosing-superpowers/references/redaction-policy.md +34 -0
- package/skills/diagnosing-superpowers/references/session-discovery.md +31 -0
- package/skills/diagnosing-superpowers/templates/bundle-README.md +77 -0
- package/skills/diagnosing-superpowers/templates/case.md +64 -0
- package/skills/diagnosing-superpowers/templates/issue.md +51 -0
- package/skills/diagnosing-superpowers/templates/report.md +82 -0
- package/skills/dispatching-parallel-agents/SKILL.md +167 -0
- package/skills/executing-plans/SKILL.md +373 -0
- package/skills/executing-plans/scripts/task-done +52 -0
- package/skills/executing-plans/scripts/task-start +28 -0
- package/skills/finishing-a-development-branch/SKILL.md +225 -0
- package/skills/gemini-collaborator/SKILL.md +85 -0
- package/skills/gpt-tasteskill/SKILL.md +74 -0
- package/skills/image-to-code-skill/SKILL.md +1228 -0
- package/skills/imagegen-frontend-mobile/SKILL.md +1465 -0
- package/skills/imagegen-frontend-web/SKILL.md +987 -0
- package/skills/karpathy-guidelines/SKILL.md +67 -0
- package/skills/minimalist-skill/SKILL.md +85 -0
- package/skills/output-skill/SKILL.md +49 -0
- package/skills/owasp-security/SKILL.md +206 -0
- package/skills/owasp-security/reference/config-and-supply-chain.md +344 -0
- package/skills/owasp-security/reference/languages.md +372 -0
- package/skills/owasp-security/reference/owasp-report.md +1140 -0
- package/skills/owasp-security/reference/review-checklist.md +132 -0
- package/skills/ponytail/SKILL.md +68 -0
- package/skills/postgres-best-practices/SKILL.md +64 -0
- package/skills/postgres-best-practices/references/_contributing.md +170 -0
- package/skills/postgres-best-practices/references/_sections.md +39 -0
- package/skills/postgres-best-practices/references/_template.md +34 -0
- package/skills/postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/skills/postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/skills/postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/skills/postgres-best-practices/references/conn-limits.md +44 -0
- package/skills/postgres-best-practices/references/conn-pooling.md +41 -0
- package/skills/postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/skills/postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/skills/postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/skills/postgres-best-practices/references/data-pagination.md +50 -0
- package/skills/postgres-best-practices/references/data-upsert.md +50 -0
- package/skills/postgres-best-practices/references/lock-advisory.md +56 -0
- package/skills/postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/skills/postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/skills/postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/skills/postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/skills/postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/skills/postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/skills/postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/skills/postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/skills/postgres-best-practices/references/query-index-types.md +48 -0
- package/skills/postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/skills/postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/skills/postgres-best-practices/references/schema-constraints.md +80 -0
- package/skills/postgres-best-practices/references/schema-data-types.md +46 -0
- package/skills/postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/skills/postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/skills/postgres-best-practices/references/schema-partitioning.md +55 -0
- package/skills/postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/skills/postgres-best-practices/references/security-privileges.md +54 -0
- package/skills/postgres-best-practices/references/security-rls-basics.md +50 -0
- package/skills/postgres-best-practices/references/security-rls-performance.md +63 -0
- package/skills/project-hygiene/SKILL.md +48 -0
- package/skills/receiving-code-review/SKILL.md +226 -0
- package/skills/redesign-skill/SKILL.md +178 -0
- package/skills/requesting-code-review/SKILL.md +124 -0
- package/skills/requesting-code-review/code-reviewer.md +198 -0
- package/skills/security-audit-sweep/SKILL.md +44 -0
- package/skills/snyk-agent-scan/SKILL.md +25 -0
- package/skills/soft-skill/SKILL.md +98 -0
- package/skills/stitch-skill/DESIGN.md +121 -0
- package/skills/stitch-skill/SKILL.md +184 -0
- package/skills/strix-security/SKILL.md +65 -0
- package/skills/subagent-driven-development/SKILL.md +568 -0
- package/skills/subagent-driven-development/adversarial-reviewer-prompt.md +18 -0
- package/skills/subagent-driven-development/designer-prompt.md +15 -0
- package/skills/subagent-driven-development/hygiene-checker-prompt.md +15 -0
- package/skills/subagent-driven-development/implementer-prompt.md +154 -0
- package/skills/subagent-driven-development/re-review-prompt.md +115 -0
- package/skills/subagent-driven-development/scripts/review-package +53 -0
- package/skills/subagent-driven-development/scripts/sdd-workspace +82 -0
- package/skills/subagent-driven-development/scripts/task-brief +43 -0
- package/skills/subagent-driven-development/security-auditor-prompt.md +15 -0
- package/skills/subagent-driven-development/task-reviewer-prompt.md +207 -0
- package/skills/subagent-driven-development/tester-prompt.md +17 -0
- package/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/skills/systematic-debugging/SKILL.md +306 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +72 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/test-academic.md +14 -0
- package/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/skills/taste-skill/SKILL.md +1206 -0
- package/skills/taste-skill-v1/SKILL.md +226 -0
- package/skills/test-driven-development/SKILL.md +337 -0
- package/skills/test-driven-development/writing-good-tests.md +198 -0
- package/skills/trailofbits-audit-context/SKILL.md +72 -0
- package/skills/trailofbits-audit-context/agents/openai.yaml +6 -0
- package/skills/trailofbits-audit-context/assets/trail-of-bits-mark.svg +1 -0
- package/skills/trailofbits-audit-context/resources/ANALYSIS_FORMAT.md +68 -0
- package/skills/trailofbits-audit-context/resources/DOMAIN_NOTES.md +73 -0
- package/skills/trailofbits-audit-context/resources/FUNCTION_MICRO_ANALYSIS_EXAMPLE.md +174 -0
- package/skills/trailofbits-insecure-defaults/README.md +104 -0
- package/skills/trailofbits-insecure-defaults/SKILL.md +21 -0
- package/skills/trailofbits-insecure-defaults/references/debug-features.json +13 -0
- package/skills/trailofbits-insecure-defaults/references/debug-features.md +75 -0
- package/skills/trailofbits-insecure-defaults/references/default-credentials.json +12 -0
- package/skills/trailofbits-insecure-defaults/references/default-credentials.md +76 -0
- package/skills/trailofbits-insecure-defaults/references/fail-open-security.json +11 -0
- package/skills/trailofbits-insecure-defaults/references/fail-open-security.md +70 -0
- package/skills/trailofbits-insecure-defaults/references/fallback-secrets.json +11 -0
- package/skills/trailofbits-insecure-defaults/references/fallback-secrets.md +70 -0
- package/skills/trailofbits-insecure-defaults/references/permissive-access.json +13 -0
- package/skills/trailofbits-insecure-defaults/references/permissive-access.md +62 -0
- package/skills/trailofbits-insecure-defaults/references/weak-crypto.json +13 -0
- package/skills/trailofbits-insecure-defaults/references/weak-crypto.md +71 -0
- package/skills/trailofbits-triage-brocards/SKILL.md +208 -0
- package/skills/trailofbits-triage-brocards/references/brocards-detail.md +220 -0
- package/skills/using-git-worktrees/SKILL.md +167 -0
- package/skills/using-superpowers/SKILL.md +65 -0
- package/skills/using-superpowers/references/antigravity-tools.md +23 -0
- package/skills/using-superpowers/references/claude-code-tools.md +29 -0
- package/skills/using-superpowers/references/codex-tools.md +108 -0
- package/skills/using-superpowers/references/gemini-tools.md +63 -0
- package/skills/using-superpowers/references/hermes-tools.md +56 -0
- package/skills/using-superpowers/references/muse-tools.md +35 -0
- package/skills/using-superpowers/references/pi-tools.md +16 -0
- package/skills/verification-before-completion/SKILL.md +134 -0
- package/skills/writing-plans/SKILL.md +211 -0
- package/skills/writing-skills/SKILL.md +681 -0
- package/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/skills/writing-skills/persuasion-principles.md +187 -0
- package/skills/writing-skills/render-graphs.js +169 -0
- package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/tools/claude-bridge.cmd +2 -0
- package/tools/claude-bridge.ps1 +490 -0
- package/tools/claude-bridge.sh +17 -0
- package/tools/codex-bridge.cmd +2 -0
- package/tools/codex-bridge.ps1 +518 -0
- package/tools/codex-bridge.sh +17 -0
- package/tools/codexcli-bridge.cmd +2 -0
- package/tools/codexcli-bridge.ps1 +5 -0
- package/tools/gemini-bridge.cmd +2 -0
- package/tools/gemini-bridge.ps1 +471 -0
- package/tools/gemini-bridge.sh +17 -0
package/setup.mjs
ADDED
|
@@ -0,0 +1,1764 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ==============================================================================
|
|
5
|
+
* Heimdall Agent — Intelligent Multi-Agent Sentinel & Environment Bootstrapper
|
|
6
|
+
* ==============================================================================
|
|
7
|
+
* Detects installed tools (Claude Code, Antigravity, Codex CLI, Claude Desktop),
|
|
8
|
+
* inspects active API endpoints (Custom Proxies / API or Custom Vendors, Google OAuth, or Official APIs),
|
|
9
|
+
* dynamically discovers user PATH & doctrine directories (zero hardcoded paths),
|
|
10
|
+
* provides 1-second auto-sync ('heimdall sync') for newly installed AI tools,
|
|
11
|
+
* and deploys skills via native live junctions (--link) or isolated copies.
|
|
12
|
+
* ==============================================================================
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import os from 'node:os';
|
|
18
|
+
import readline from 'node:readline/promises';
|
|
19
|
+
import { fileURLToPath } from 'node:url';
|
|
20
|
+
import { execSync } from 'node:child_process';
|
|
21
|
+
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = path.dirname(__filename);
|
|
24
|
+
|
|
25
|
+
// Terminal color formatting
|
|
26
|
+
const colors = {
|
|
27
|
+
reset: '\x1b[0m',
|
|
28
|
+
bold: '\x1b[1m',
|
|
29
|
+
dim: '\x1b[2m',
|
|
30
|
+
cyan: '\x1b[36m',
|
|
31
|
+
green: '\x1b[32m',
|
|
32
|
+
yellow: '\x1b[33m',
|
|
33
|
+
red: '\x1b[31m',
|
|
34
|
+
magenta: '\x1b[35m'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const userHome = os.homedir();
|
|
38
|
+
const skillsDir = path.join(__dirname, 'skills');
|
|
39
|
+
const agentsDir = path.join(__dirname, 'agents');
|
|
40
|
+
const playbooksDir = path.join(__dirname, 'playbooks');
|
|
41
|
+
const toolsDir = path.join(__dirname, 'tools');
|
|
42
|
+
const doctrineDir = path.join(__dirname, 'doctrine');
|
|
43
|
+
const commandsDir = path.join(__dirname, 'commands');
|
|
44
|
+
const hooksDir = path.join(__dirname, 'hooks');
|
|
45
|
+
const profilesPath = path.join(__dirname, 'config', 'profiles.json');
|
|
46
|
+
const modelsPath = path.join(__dirname, 'config', 'models.json');
|
|
47
|
+
const agentsConfigPath = path.join(__dirname, 'config', 'agents.json');
|
|
48
|
+
const skillsConfigPath = path.join(__dirname, 'config', 'skills.json');
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the platform-specific Hermes Agent directory:
|
|
52
|
+
* - Windows: %LOCALAPPDATA%\hermes or ~/.hermes
|
|
53
|
+
* - macOS/Linux: ~/.hermes
|
|
54
|
+
*/
|
|
55
|
+
function getHermesDir() {
|
|
56
|
+
const platform = os.platform();
|
|
57
|
+
if (platform === 'win32') {
|
|
58
|
+
const localAppData = process.env.LOCALAPPDATA || path.join(userHome, 'AppData', 'Local');
|
|
59
|
+
const winPath = path.join(localAppData, 'hermes');
|
|
60
|
+
if (fs.existsSync(winPath)) return winPath;
|
|
61
|
+
}
|
|
62
|
+
const homePath = path.join(userHome, '.hermes');
|
|
63
|
+
if (fs.existsSync(homePath)) return homePath;
|
|
64
|
+
return platform === 'win32'
|
|
65
|
+
? path.join(process.env.LOCALAPPDATA || path.join(userHome, 'AppData', 'Local'), 'hermes')
|
|
66
|
+
: homePath;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Resolves the platform-specific OpenClaw directory:
|
|
71
|
+
* - Windows/macOS/Linux: ~/.openclaw (or %LOCALAPPDATA%\openclaw on Windows if present)
|
|
72
|
+
*/
|
|
73
|
+
function getOpenClawDir() {
|
|
74
|
+
const homePath = path.join(userHome, '.openclaw');
|
|
75
|
+
if (fs.existsSync(homePath)) return homePath;
|
|
76
|
+
if (os.platform() === 'win32') {
|
|
77
|
+
const localAppData = process.env.LOCALAPPDATA || path.join(userHome, 'AppData', 'Local');
|
|
78
|
+
const winPath = path.join(localAppData, 'openclaw');
|
|
79
|
+
if (fs.existsSync(winPath)) return winPath;
|
|
80
|
+
}
|
|
81
|
+
return homePath;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const targetPaths = {
|
|
85
|
+
claude: path.join(userHome, '.claude', 'skills'),
|
|
86
|
+
gemini: path.join(userHome, '.gemini', 'skills'),
|
|
87
|
+
codex: path.join(userHome, '.codex', 'skills'),
|
|
88
|
+
agents: path.join(userHome, '.agents', 'skills'),
|
|
89
|
+
hermes: path.join(getHermesDir(), 'skills'),
|
|
90
|
+
openclaw: path.join(getOpenClawDir(), 'skills')
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const targetAgentPaths = {
|
|
94
|
+
claude: path.join(userHome, '.claude', 'agents'),
|
|
95
|
+
gemini: path.join(userHome, '.gemini', 'agents'),
|
|
96
|
+
codex: path.join(userHome, '.codex', 'agents'),
|
|
97
|
+
agents: path.join(userHome, '.agents', 'agents'),
|
|
98
|
+
hermes: path.join(getHermesDir(), 'agents'),
|
|
99
|
+
openclaw: path.join(getOpenClawDir(), 'agents')
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const targetDoctrinePaths = {
|
|
103
|
+
claude: path.join(userHome, '.claude', 'CLAUDE.md'),
|
|
104
|
+
gemini: path.join(userHome, '.gemini', 'GEMINI.md'),
|
|
105
|
+
codex: path.join(userHome, '.codex', 'AGENTS.md'),
|
|
106
|
+
agents: path.join(userHome, '.agents', 'AGENTS.md'),
|
|
107
|
+
hermes: path.join(getHermesDir(), 'AGENTS.md'),
|
|
108
|
+
openclaw: path.join(getOpenClawDir(), 'AGENTS.md')
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const targetPlaybookPaths = {
|
|
112
|
+
claude: path.join(userHome, '.claude', 'playbooks'),
|
|
113
|
+
gemini: path.join(userHome, '.gemini', 'playbooks'),
|
|
114
|
+
agents: path.join(userHome, '.agents', 'playbooks'),
|
|
115
|
+
hermes: path.join(getHermesDir(), 'playbooks'),
|
|
116
|
+
openclaw: path.join(getOpenClawDir(), 'playbooks')
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const targetCommandPaths = {
|
|
120
|
+
claude: path.join(userHome, '.claude', 'commands')
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const targetHookPaths = {
|
|
124
|
+
claude: path.join(userHome, '.claude', 'hooks')
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function printBanner() {
|
|
128
|
+
console.log(`
|
|
129
|
+
${colors.cyan}${colors.bold} ██╗ ██╗███████╗██╗███╗ ███╗██████╗ █████╗ ██╗ ██╗
|
|
130
|
+
██║ ██║██╔════╝██║████╗ ████║██╔══██╗██╔══██╗██║ ██║
|
|
131
|
+
███████║█████╗ ██║██╔████╔██║██║ ██║███████║██║ ██║
|
|
132
|
+
██╔══██║██╔══╝ ██║██║╚██╔╝██║██║ ██║██╔══██║██║ ██║
|
|
133
|
+
██║ ██║███████╗██║██║ ╚═╝ ██║██████╔╝██║ ██║███████╗███████╗
|
|
134
|
+
╚═╝ ╚═╝╚══════╝╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝${colors.reset}
|
|
135
|
+
${colors.dim}Intelligent Multi-Agent Sentinel & Quality Bootstrapper${colors.reset}
|
|
136
|
+
`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function checkCommand(cmd) {
|
|
140
|
+
try {
|
|
141
|
+
const isWin = os.platform() === 'win32';
|
|
142
|
+
const checkCmd = isWin ? `where.exe ${cmd}` : `which ${cmd}`;
|
|
143
|
+
const result = execSync(checkCmd, { stdio: ['pipe', 'pipe', 'ignore'], encoding: 'utf8' });
|
|
144
|
+
return result.split('\r\n')[0].split('\n')[0].trim();
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Resolves the platform-specific Claude Desktop configuration directory:
|
|
152
|
+
* - Windows: %APPDATA%\Claude
|
|
153
|
+
* - macOS: ~/Library/Application Support/Claude
|
|
154
|
+
* - Linux: $XDG_CONFIG_HOME/Claude or ~/.config/Claude
|
|
155
|
+
*/
|
|
156
|
+
function getClaudeDesktopDir() {
|
|
157
|
+
const platform = os.platform();
|
|
158
|
+
if (platform === 'darwin') {
|
|
159
|
+
return path.join(userHome, 'Library', 'Application Support', 'Claude');
|
|
160
|
+
}
|
|
161
|
+
if (platform === 'win32') {
|
|
162
|
+
const appData = process.env.APPDATA || path.join(userHome, 'AppData', 'Roaming');
|
|
163
|
+
return path.join(appData, 'Claude');
|
|
164
|
+
}
|
|
165
|
+
const configHome = process.env.XDG_CONFIG_HOME || path.join(userHome, '.config');
|
|
166
|
+
return path.join(configHome, 'Claude');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Resiliently discovers the OpenAI Codex CLI binary on PATH and standard Windows/POSIX install paths.
|
|
171
|
+
*/
|
|
172
|
+
function detectCodexBinary() {
|
|
173
|
+
const onPath = checkCommand('codex');
|
|
174
|
+
if (onPath) return onPath;
|
|
175
|
+
|
|
176
|
+
if (os.platform() === 'win32') {
|
|
177
|
+
const candidates = [
|
|
178
|
+
path.join(process.env.LOCALAPPDATA || '', 'Programs', 'OpenAI', 'Codex', 'bin', 'codex.exe'),
|
|
179
|
+
path.join(userHome, '.codex', 'packages', 'standalone', 'current', 'bin', 'codex.exe'),
|
|
180
|
+
path.join(userHome, '.local', 'bin', 'codex.exe'),
|
|
181
|
+
'C:\\Program Files\\OpenAI\\Codex\\bin\\codex.exe',
|
|
182
|
+
'C:\\Apps\\codex\\codex.exe'
|
|
183
|
+
];
|
|
184
|
+
for (const cand of candidates) {
|
|
185
|
+
if (cand && fs.existsSync(cand)) return cand;
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
const posixCandidates = [
|
|
189
|
+
path.join(userHome, '.local', 'bin', 'codex'),
|
|
190
|
+
path.join(userHome, '.codex', 'bin', 'codex'),
|
|
191
|
+
'/usr/local/bin/codex'
|
|
192
|
+
];
|
|
193
|
+
for (const cand of posixCandidates) {
|
|
194
|
+
if (cand && fs.existsSync(cand)) return cand;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Resiliently discovers the Hermes Agent CLI binary on PATH and standard Windows/POSIX install paths.
|
|
202
|
+
*/
|
|
203
|
+
function detectHermesBinary() {
|
|
204
|
+
const onPath = checkCommand('hermes');
|
|
205
|
+
if (onPath) return onPath;
|
|
206
|
+
|
|
207
|
+
if (os.platform() === 'win32') {
|
|
208
|
+
const candidates = [
|
|
209
|
+
path.join(process.env.LOCALAPPDATA || '', 'hermes', 'bin', 'hermes.cmd'),
|
|
210
|
+
path.join(process.env.LOCALAPPDATA || '', 'hermes', 'bin', 'hermes.exe'),
|
|
211
|
+
path.join(userHome, '.hermes', 'bin', 'hermes.cmd'),
|
|
212
|
+
path.join(userHome, '.local', 'bin', 'hermes.cmd')
|
|
213
|
+
];
|
|
214
|
+
for (const cand of candidates) {
|
|
215
|
+
if (cand && fs.existsSync(cand)) return cand;
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
const posixCandidates = [
|
|
219
|
+
path.join(userHome, '.local', 'bin', 'hermes'),
|
|
220
|
+
path.join(userHome, '.hermes', 'bin', 'hermes'),
|
|
221
|
+
'/usr/local/bin/hermes'
|
|
222
|
+
];
|
|
223
|
+
for (const cand of posixCandidates) {
|
|
224
|
+
if (cand && fs.existsSync(cand)) return cand;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Resiliently discovers the OpenClaw binary on PATH and standard Windows/POSIX install paths.
|
|
232
|
+
*/
|
|
233
|
+
function detectOpenClawBinary() {
|
|
234
|
+
const onPath = checkCommand('openclaw');
|
|
235
|
+
if (onPath) return onPath;
|
|
236
|
+
|
|
237
|
+
if (os.platform() === 'win32') {
|
|
238
|
+
const candidates = [
|
|
239
|
+
path.join(userHome, '.openclaw', 'bin', 'openclaw.exe'),
|
|
240
|
+
path.join(userHome, '.openclaw', 'bin', 'openclaw.cmd'),
|
|
241
|
+
path.join(process.env.LOCALAPPDATA || '', 'openclaw', 'bin', 'openclaw.exe'),
|
|
242
|
+
path.join(userHome, '.local', 'bin', 'openclaw.cmd')
|
|
243
|
+
];
|
|
244
|
+
for (const cand of candidates) {
|
|
245
|
+
if (cand && fs.existsSync(cand)) return cand;
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
const posixCandidates = [
|
|
249
|
+
path.join(userHome, '.local', 'bin', 'openclaw'),
|
|
250
|
+
path.join(userHome, '.openclaw', 'bin', 'openclaw'),
|
|
251
|
+
'/usr/local/bin/openclaw'
|
|
252
|
+
];
|
|
253
|
+
for (const cand of posixCandidates) {
|
|
254
|
+
if (cand && fs.existsSync(cand)) return cand;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Ensures ~/.agents/skills is registered under external_dirs in Hermes's config.yaml.
|
|
262
|
+
*/
|
|
263
|
+
function configureHermesExternalDirs(hermesDir, dryRun = false) {
|
|
264
|
+
const configPath = path.join(hermesDir, 'config.yaml');
|
|
265
|
+
if (!fs.existsSync(configPath)) return false;
|
|
266
|
+
try {
|
|
267
|
+
const content = fs.readFileSync(configPath, 'utf8');
|
|
268
|
+
if (content.includes('.agents/skills') || content.includes('.agents\\skills')) {
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
if (/^\s*external_dirs:\s*$/m.test(content)) {
|
|
272
|
+
const updated = content.replace(/(external_dirs:\s*[\r\n]+)/m, `$1 - ~/.agents/skills\r\n`);
|
|
273
|
+
if (!dryRun) fs.writeFileSync(configPath, updated, 'utf8');
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
if (content.includes('# external_dirs:')) {
|
|
277
|
+
const updated = content.replace(/#\s*external_dirs:\s*[\r\n]+#\s*-\s*~\/\.agents\/skills/, ` external_dirs:\r\n - ~/.agents/skills`);
|
|
278
|
+
if (!dryRun) fs.writeFileSync(configPath, updated, 'utf8');
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
} catch {}
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Dynamically discovers candidate tools/bin directories registered in the user's PATH.
|
|
287
|
+
* Never assumes a hardcoded system path.
|
|
288
|
+
*/
|
|
289
|
+
function detectPathCandidates() {
|
|
290
|
+
const pathEnv = process.env.PATH || '';
|
|
291
|
+
const delimiter = path.delimiter;
|
|
292
|
+
const rawDirs = pathEnv.split(delimiter).map(d => d.trim()).filter(Boolean);
|
|
293
|
+
const candidates = [];
|
|
294
|
+
const seen = new Set();
|
|
295
|
+
|
|
296
|
+
for (const raw of rawDirs) {
|
|
297
|
+
try {
|
|
298
|
+
const resolved = path.resolve(raw);
|
|
299
|
+
const lower = resolved.toLowerCase();
|
|
300
|
+
if (seen.has(lower)) continue;
|
|
301
|
+
seen.add(lower);
|
|
302
|
+
|
|
303
|
+
if (fs.existsSync(resolved)) {
|
|
304
|
+
// Exclude system directories
|
|
305
|
+
const isSystem = lower.includes('\\windows\\system32') ||
|
|
306
|
+
lower.includes('\\windows\\system') ||
|
|
307
|
+
lower.includes('/usr/sbin') ||
|
|
308
|
+
lower.includes('/sbin') ||
|
|
309
|
+
lower.includes('\\powershell');
|
|
310
|
+
if (!isSystem) {
|
|
311
|
+
const isToolLike = lower.includes('tool') ||
|
|
312
|
+
lower.includes('bin') ||
|
|
313
|
+
lower.includes('.local') ||
|
|
314
|
+
lower.includes('apps') ||
|
|
315
|
+
lower.includes('npm') ||
|
|
316
|
+
lower.includes('cargo') ||
|
|
317
|
+
lower.includes('heimdall');
|
|
318
|
+
if (isToolLike) {
|
|
319
|
+
candidates.push(resolved);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
} catch {}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Fallback candidate if none detected
|
|
327
|
+
const defaultUserTools = path.join(userHome, '.heimdall', 'bin');
|
|
328
|
+
if (candidates.length === 0) {
|
|
329
|
+
candidates.push(defaultUserTools);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return candidates;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Dynamically discovers candidate paths for universal doctrine AGENTS.md.
|
|
337
|
+
*/
|
|
338
|
+
function detectDoctrineCandidates() {
|
|
339
|
+
const candidates = [];
|
|
340
|
+
const seen = new Set();
|
|
341
|
+
|
|
342
|
+
// 1. User home agents (~/.agents/AGENTS.md)
|
|
343
|
+
const userDoctrine = path.join(userHome, '.agents', 'AGENTS.md');
|
|
344
|
+
candidates.push(userDoctrine);
|
|
345
|
+
seen.add(userDoctrine.toLowerCase());
|
|
346
|
+
|
|
347
|
+
// 2. Parent workspace directory if exists
|
|
348
|
+
const parentWorkspace = path.join(path.dirname(__dirname), 'AGENTS.md');
|
|
349
|
+
if (!seen.has(parentWorkspace.toLowerCase())) {
|
|
350
|
+
if (fs.existsSync(parentWorkspace)) {
|
|
351
|
+
candidates.unshift(parentWorkspace); // Prioritize if already active
|
|
352
|
+
} else {
|
|
353
|
+
candidates.push(parentWorkspace);
|
|
354
|
+
}
|
|
355
|
+
seen.add(parentWorkspace.toLowerCase());
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// 3. Current working directory if different
|
|
359
|
+
const cwdDoctrine = path.join(process.cwd(), 'AGENTS.md');
|
|
360
|
+
if (!seen.has(cwdDoctrine.toLowerCase())) {
|
|
361
|
+
candidates.push(cwdDoctrine);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return candidates;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function detectEnvironment() {
|
|
368
|
+
const detected = {
|
|
369
|
+
tools: {},
|
|
370
|
+
endpoints: {},
|
|
371
|
+
pathCandidates: detectPathCandidates(),
|
|
372
|
+
doctrineCandidates: detectDoctrineCandidates()
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// 1. Check CLI binaries on PATH / standard install paths
|
|
376
|
+
detected.tools.claude = checkCommand('claude');
|
|
377
|
+
detected.tools.agy = checkCommand('agy');
|
|
378
|
+
detected.tools.codex = detectCodexBinary();
|
|
379
|
+
detected.tools.hermes = detectHermesBinary();
|
|
380
|
+
detected.tools.openclaw = detectOpenClawBinary();
|
|
381
|
+
detected.tools.cursor = checkCommand('cursor');
|
|
382
|
+
detected.tools.windsurf = checkCommand('windsurf');
|
|
383
|
+
|
|
384
|
+
// 2. Check Claude Desktop directory (Windows, macOS, Linux)
|
|
385
|
+
const claudeDesktopDir = getClaudeDesktopDir();
|
|
386
|
+
detected.tools.claudeDesktop = fs.existsSync(claudeDesktopDir) ? claudeDesktopDir : null;
|
|
387
|
+
|
|
388
|
+
// 3. Check Claude Code endpoint
|
|
389
|
+
const claudeSettingsPath = path.join(userHome, '.claude', 'settings.json');
|
|
390
|
+
if (fs.existsSync(claudeSettingsPath)) {
|
|
391
|
+
try {
|
|
392
|
+
const settings = JSON.parse(fs.readFileSync(claudeSettingsPath, 'utf8'));
|
|
393
|
+
if (settings.env?.ANTHROPIC_BASE_URL || settings.env?.CLAUDE_BASE_URL) {
|
|
394
|
+
detected.endpoints.claude = settings.env.ANTHROPIC_BASE_URL || settings.env.CLAUDE_BASE_URL;
|
|
395
|
+
}
|
|
396
|
+
} catch {}
|
|
397
|
+
}
|
|
398
|
+
if (!detected.endpoints.claude && process.env.ANTHROPIC_BASE_URL) {
|
|
399
|
+
detected.endpoints.claude = process.env.ANTHROPIC_BASE_URL;
|
|
400
|
+
}
|
|
401
|
+
if (!detected.endpoints.claude) {
|
|
402
|
+
detected.endpoints.claude = 'https://api.anthropic.com (Official)';
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// 4. Check Codex endpoint
|
|
406
|
+
const codexConfigPath = path.join(userHome, '.codex', 'config.toml');
|
|
407
|
+
if (fs.existsSync(codexConfigPath)) {
|
|
408
|
+
try {
|
|
409
|
+
const content = fs.readFileSync(codexConfigPath, 'utf8');
|
|
410
|
+
const match = content.match(/base_url\s*=\s*"([^"]+)"/);
|
|
411
|
+
if (match) detected.endpoints.codex = match[1];
|
|
412
|
+
} catch {}
|
|
413
|
+
}
|
|
414
|
+
if (!detected.endpoints.codex && process.env.OPENAI_BASE_URL) {
|
|
415
|
+
detected.endpoints.codex = process.env.OPENAI_BASE_URL;
|
|
416
|
+
}
|
|
417
|
+
if (!detected.endpoints.codex) {
|
|
418
|
+
detected.endpoints.codex = 'https://api.openai.com (Official)';
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// 5. Check Gemini / Google Antigravity
|
|
422
|
+
// Antigravity connects via Google OAuth / Cloud credentials by default unless a custom API key or proxy is set.
|
|
423
|
+
if (process.env.GEMINI_BASE_URL) {
|
|
424
|
+
detected.endpoints.gemini = `Custom Proxy (${process.env.GEMINI_BASE_URL})`;
|
|
425
|
+
} else if (process.env.GEMINI_API_KEY) {
|
|
426
|
+
detected.endpoints.gemini = 'Google GenAI API Key (Custom Direct API)';
|
|
427
|
+
} else if (detected.tools.agy || fs.existsSync(path.join(userHome, '.gemini', 'antigravity-cli'))) {
|
|
428
|
+
detected.endpoints.gemini = 'Google OAuth (Default Native Account)';
|
|
429
|
+
} else {
|
|
430
|
+
detected.endpoints.gemini = 'Not Installed / Unconfigured';
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// 6. Check Hermes Agent
|
|
434
|
+
const hermesDir = getHermesDir();
|
|
435
|
+
const hermesConfigPath = path.join(hermesDir, 'config.yaml');
|
|
436
|
+
if (fs.existsSync(hermesConfigPath)) {
|
|
437
|
+
try {
|
|
438
|
+
const content = fs.readFileSync(hermesConfigPath, 'utf8');
|
|
439
|
+
const defaultMatch = content.match(/^\s*default:\s*["']?([^"'#\r\n]+)["']?/m);
|
|
440
|
+
const modelMatch = content.match(/^\s*model:\s*["']?([^"'#\r\n]+)["']?/m);
|
|
441
|
+
const providerMatch = content.match(/^\s*provider:\s*["']?([^"'#\r\n]+)["']?/m);
|
|
442
|
+
const resolvedModel = (defaultMatch && defaultMatch[1].trim()) || (modelMatch && modelMatch[1].trim());
|
|
443
|
+
if (resolvedModel) {
|
|
444
|
+
const prov = providerMatch ? `${providerMatch[1].trim()}/` : '';
|
|
445
|
+
detected.endpoints.hermes = `${prov}${resolvedModel}`;
|
|
446
|
+
}
|
|
447
|
+
} catch {}
|
|
448
|
+
}
|
|
449
|
+
if (!detected.endpoints.hermes && (detected.tools.hermes || fs.existsSync(hermesDir))) {
|
|
450
|
+
detected.endpoints.hermes = 'Nous Research / Configured Provider';
|
|
451
|
+
} else if (!detected.endpoints.hermes) {
|
|
452
|
+
detected.endpoints.hermes = 'Not Installed / Unconfigured';
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// 7. Check OpenClaw
|
|
456
|
+
const openclawDir = getOpenClawDir();
|
|
457
|
+
const openclawConfigPath = path.join(openclawDir, 'openclaw.json');
|
|
458
|
+
if (fs.existsSync(openclawConfigPath)) {
|
|
459
|
+
try {
|
|
460
|
+
const cfg = JSON.parse(fs.readFileSync(openclawConfigPath, 'utf8'));
|
|
461
|
+
if (cfg.model) detected.endpoints.openclaw = cfg.model;
|
|
462
|
+
} catch {}
|
|
463
|
+
}
|
|
464
|
+
if (!detected.endpoints.openclaw && (detected.tools.openclaw || fs.existsSync(openclawDir))) {
|
|
465
|
+
detected.endpoints.openclaw = 'Local-First Gateway';
|
|
466
|
+
} else if (!detected.endpoints.openclaw) {
|
|
467
|
+
detected.endpoints.openclaw = 'Not Installed / Unconfigured';
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return detected;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function printHelp() {
|
|
474
|
+
console.log(`
|
|
475
|
+
${colors.bold}${colors.cyan}Heimdall Agent CLI${colors.reset} — Intelligent Multi-Agent Sentinel & Quality Bootstrapper
|
|
476
|
+
|
|
477
|
+
${colors.bold}USAGE:${colors.reset}
|
|
478
|
+
heimdall [command] [options]
|
|
479
|
+
node setup.mjs [command] [options]
|
|
480
|
+
|
|
481
|
+
${colors.dim}Note: 'heimdall' and 'node setup.mjs' are identical. 'heimdall' is the global CLI shortcut.${colors.reset}
|
|
482
|
+
|
|
483
|
+
${colors.bold}PRIMARY SUBCOMMANDS:${colors.reset}
|
|
484
|
+
${colors.green}sync${colors.reset} (or ${colors.dim}--sync${colors.reset}) Scan PATH for newly installed AI tools and link skills (1-sec zero-drift)
|
|
485
|
+
${colors.green}audit${colors.reset} (or ${colors.dim}--audit${colors.reset}) Audit installed harnesses, active API endpoints, and skill counts
|
|
486
|
+
${colors.green}uninstall${colors.reset} (or ${colors.dim}--uninstall${colors.reset}) Safely remove Heimdall skills and agent personas from all harnesses
|
|
487
|
+
${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
|
|
488
|
+
${colors.green}skills${colors.reset} (or ${colors.dim}--skills${colors.reset}) List all canonical skills, categories, and upstream provenance
|
|
489
|
+
${colors.green}update-skill <name|all>${colors.reset} Inspect upstream repository, updates, and bounded review protocol
|
|
490
|
+
${colors.green}help${colors.reset} (or ${colors.dim}--help, -h${colors.reset}) Display this parameter and command reference
|
|
491
|
+
|
|
492
|
+
${colors.bold}SETUP & BOOTSTRAP OPTIONS:${colors.reset}
|
|
493
|
+
${colors.yellow}--profile <name>${colors.reset} Skill profile tier: full (50), minimal (16), security (12), design (14) [default: full]
|
|
494
|
+
${colors.yellow}--agents <targets>${colors.reset} Comma-separated harnesses: claude, gemini, codex, hermes, openclaw, desktop, all [default: all]
|
|
495
|
+
${colors.yellow}--link / --no-link${colors.reset} Use live NTFS junctions / symlinks vs static copies [default: false in wizard, true recommended]
|
|
496
|
+
${colors.yellow}--clean${colors.reset} Wipe legacy skills from target directory before deploying
|
|
497
|
+
${colors.yellow}-y, --yes${colors.reset} Non-interactive mode (use defaults or provided CLI arguments)
|
|
498
|
+
${colors.yellow}--dry-run${colors.reset} Simulate execution without modifying the filesystem
|
|
499
|
+
${colors.yellow}--tools-dir <dir>${colors.reset} Custom directory to deploy cross-model bridge tools and 'heimdall' CLI
|
|
500
|
+
${colors.yellow}--doctrine-path <file>${colors.reset} Custom file destination for AGENTS.md universal doctrine
|
|
501
|
+
${colors.yellow}--no-tools${colors.reset} Skip deploying bridge tools and CLI shims
|
|
502
|
+
${colors.yellow}--no-doctrine${colors.reset} Skip deploying AGENTS.md universal doctrine
|
|
503
|
+
|
|
504
|
+
${colors.bold}EXAMPLES:${colors.reset}
|
|
505
|
+
heimdall # Interactive management hub (audit, sync, uninstall)
|
|
506
|
+
heimdall sync # Instant sync after installing a new tool
|
|
507
|
+
heimdall audit # Environment health check
|
|
508
|
+
heimdall uninstall # Safely unbind Heimdall skills and agents
|
|
509
|
+
heimdall skills # Browse canonical skills catalog
|
|
510
|
+
heimdall update-skill ponytail # Inspect upstream provenance & review protocol for single skill
|
|
511
|
+
heimdall update-skill all # Generate full bounded review audit report
|
|
512
|
+
heimdall sync-models # Refresh model catalogs
|
|
513
|
+
node setup.mjs --clean --link --yes # Recommended full automated setup with live junctions
|
|
514
|
+
node setup.mjs --profile minimal --yes # Minimal install for lightweight laptop
|
|
515
|
+
`);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function parseArgs() {
|
|
519
|
+
const args = process.argv.slice(2);
|
|
520
|
+
const options = {
|
|
521
|
+
profile: 'full',
|
|
522
|
+
agents: null,
|
|
523
|
+
link: false,
|
|
524
|
+
clean: false,
|
|
525
|
+
sync: false,
|
|
526
|
+
uninstall: false,
|
|
527
|
+
tools: true,
|
|
528
|
+
doctrine: true,
|
|
529
|
+
toolsDir: null,
|
|
530
|
+
doctrinePath: null,
|
|
531
|
+
dryRun: false,
|
|
532
|
+
audit: false,
|
|
533
|
+
syncModels: false,
|
|
534
|
+
listSkills: false,
|
|
535
|
+
updateSkill: null,
|
|
536
|
+
help: false,
|
|
537
|
+
yes: false,
|
|
538
|
+
hasArgs: args.length > 0
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
for (let i = 0; i < args.length; i++) {
|
|
542
|
+
const rawArg = args[i];
|
|
543
|
+
const arg = rawArg.toLowerCase();
|
|
544
|
+
|
|
545
|
+
if (arg === 'help' || arg === '--help' || arg === '-h') options.help = true;
|
|
546
|
+
else if (arg === 'audit' || arg === '--audit') options.audit = true;
|
|
547
|
+
else if (arg === 'sync' || arg === '--sync') options.sync = true;
|
|
548
|
+
else if (arg === 'uninstall' || arg === '--uninstall') options.uninstall = true;
|
|
549
|
+
else if (arg === 'sync-models' || arg === '--sync-models' || arg === 'syncmodels') options.syncModels = true;
|
|
550
|
+
else if (arg === 'skills' || arg === '--skills') options.listSkills = true;
|
|
551
|
+
else if (arg === 'update-skill' || arg === '--update-skill' || arg === 'updateskill') {
|
|
552
|
+
options.updateSkill = args[i + 1] && !args[i + 1].startsWith('-') ? args[++i] : 'all';
|
|
553
|
+
}
|
|
554
|
+
else if (arg === '--dry-run') options.dryRun = true;
|
|
555
|
+
else if (arg === '--link') options.link = true;
|
|
556
|
+
else if (arg === '--no-link') options.link = false;
|
|
557
|
+
else if (arg === '--clean') options.clean = true;
|
|
558
|
+
else if (arg === '--yes' || arg === '-y') options.yes = true;
|
|
559
|
+
else if (arg === '--no-tools') options.tools = false;
|
|
560
|
+
else if (arg === '--no-doctrine') options.doctrine = false;
|
|
561
|
+
else if (arg === '--profile' && args[i + 1]) {
|
|
562
|
+
options.profile = args[++i].toLowerCase();
|
|
563
|
+
} else if (arg === '--agents' && args[i + 1]) {
|
|
564
|
+
options.agents = args[++i].split(',').map(s => s.trim().toLowerCase());
|
|
565
|
+
} else if (arg === '--tools-dir' && args[i + 1]) {
|
|
566
|
+
options.toolsDir = args[++i];
|
|
567
|
+
} else if (arg === '--doctrine-path' && args[i + 1]) {
|
|
568
|
+
options.doctrinePath = args[++i];
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
return options;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function cleanTargetDirectory(targetDir, dryRun = false, preserveList = ['.system']) {
|
|
576
|
+
if (!fs.existsSync(targetDir)) return 0;
|
|
577
|
+
let cleanedCount = 0;
|
|
578
|
+
const entries = fs.readdirSync(targetDir, { withFileTypes: true });
|
|
579
|
+
|
|
580
|
+
for (const entry of entries) {
|
|
581
|
+
if (preserveList.includes(entry.name)) continue;
|
|
582
|
+
const fullPath = path.join(targetDir, entry.name);
|
|
583
|
+
if (!dryRun) {
|
|
584
|
+
try {
|
|
585
|
+
const stat = fs.lstatSync(fullPath);
|
|
586
|
+
if (stat.isSymbolicLink()) {
|
|
587
|
+
fs.rmSync(fullPath);
|
|
588
|
+
} else {
|
|
589
|
+
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
590
|
+
}
|
|
591
|
+
} catch {
|
|
592
|
+
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
cleanedCount++;
|
|
596
|
+
}
|
|
597
|
+
return cleanedCount;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
function registerClaudeHooks(targetHookDir, dryRun = false) {
|
|
602
|
+
if (dryRun) return;
|
|
603
|
+
const claudeSettingsPath = path.join(userHome, '.claude', 'settings.json');
|
|
604
|
+
const hooksJsonSrc = path.join(hooksDir, 'hooks.json');
|
|
605
|
+
if (!fs.existsSync(hooksJsonSrc)) return;
|
|
606
|
+
|
|
607
|
+
try {
|
|
608
|
+
let rawTemplate = fs.readFileSync(hooksJsonSrc, 'utf8');
|
|
609
|
+
const normalizedHookDir = targetHookDir.replace(/\\/g, '/');
|
|
610
|
+
rawTemplate = rawTemplate.replace(/\{\{HOOKS_DIR\}\}/g, normalizedHookDir);
|
|
611
|
+
const parsedConfig = JSON.parse(rawTemplate);
|
|
612
|
+
|
|
613
|
+
let settings = {};
|
|
614
|
+
if (fs.existsSync(claudeSettingsPath)) {
|
|
615
|
+
try {
|
|
616
|
+
settings = JSON.parse(fs.readFileSync(claudeSettingsPath, 'utf8'));
|
|
617
|
+
} catch {
|
|
618
|
+
settings = {};
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
settings.hooks = parsedConfig.hooks;
|
|
623
|
+
fs.writeFileSync(claudeSettingsPath, JSON.stringify(settings, null, 2), 'utf8');
|
|
624
|
+
console.log(` ${colors.green}✔ Registered Heimdall lifecycle hooks in ${claudeSettingsPath}${colors.reset}`);
|
|
625
|
+
} catch (err) {
|
|
626
|
+
console.log(` ${colors.yellow}⚠ Failed to register hooks in settings.json: ${err.message}${colors.reset}`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function linkDirectory(src, dest, dryRun = false) {
|
|
631
|
+
if (dryRun) return;
|
|
632
|
+
if (fs.existsSync(dest)) {
|
|
633
|
+
try {
|
|
634
|
+
const stat = fs.lstatSync(dest);
|
|
635
|
+
if (stat.isSymbolicLink()) {
|
|
636
|
+
fs.rmSync(dest);
|
|
637
|
+
} else {
|
|
638
|
+
fs.rmSync(dest, { recursive: true, force: true });
|
|
639
|
+
}
|
|
640
|
+
} catch {
|
|
641
|
+
fs.rmSync(dest, { recursive: true, force: true });
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
const symlinkType = os.platform() === 'win32' ? 'junction' : 'dir';
|
|
645
|
+
fs.symlinkSync(src, dest, symlinkType);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function copyDirectory(src, dest, dryRun = false) {
|
|
649
|
+
if (!fs.existsSync(src)) return 0;
|
|
650
|
+
if (!dryRun && !fs.existsSync(dest)) {
|
|
651
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
let count = 0;
|
|
655
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
656
|
+
|
|
657
|
+
for (const entry of entries) {
|
|
658
|
+
const srcPath = path.join(src, entry.name);
|
|
659
|
+
const destPath = path.join(dest, entry.name);
|
|
660
|
+
|
|
661
|
+
if (entry.isDirectory()) {
|
|
662
|
+
count += copyDirectory(srcPath, destPath, dryRun);
|
|
663
|
+
} else {
|
|
664
|
+
if (!dryRun) {
|
|
665
|
+
fs.copyFileSync(srcPath, destPath);
|
|
666
|
+
}
|
|
667
|
+
count++;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
return count;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function deployAgentContracts(targetDir, link = false, clean = false, dryRun = false, agentsList = null) {
|
|
675
|
+
if (!fs.existsSync(agentsDir)) return 0;
|
|
676
|
+
const allFiles = fs.readdirSync(agentsDir).filter(f => f.endsWith('.md'));
|
|
677
|
+
const agentFiles = agentsList ? allFiles.filter(f => agentsList.includes(f)) : allFiles;
|
|
678
|
+
|
|
679
|
+
if (link && agentFiles.length === allFiles.length) {
|
|
680
|
+
linkDirectory(agentsDir, targetDir, dryRun);
|
|
681
|
+
return agentFiles.length;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if (!dryRun && !fs.existsSync(targetDir)) {
|
|
685
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (clean) {
|
|
689
|
+
cleanTargetDirectory(targetDir, dryRun);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
let count = 0;
|
|
693
|
+
for (const file of agentFiles) {
|
|
694
|
+
const src = path.join(agentsDir, file);
|
|
695
|
+
const dest = path.join(targetDir, file);
|
|
696
|
+
if (!dryRun) {
|
|
697
|
+
fs.copyFileSync(src, dest);
|
|
698
|
+
}
|
|
699
|
+
count++;
|
|
700
|
+
}
|
|
701
|
+
return count;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function cleanLegacyLocalAgents(dryRun = false) {
|
|
705
|
+
const parksAppAgents = path.join(path.dirname(__dirname), 'parks-app', '.claude', 'agents');
|
|
706
|
+
if (fs.existsSync(parksAppAgents)) {
|
|
707
|
+
try {
|
|
708
|
+
if (!dryRun) {
|
|
709
|
+
fs.rmSync(parksAppAgents, { recursive: true, force: true });
|
|
710
|
+
linkDirectory(agentsDir, parksAppAgents, false);
|
|
711
|
+
}
|
|
712
|
+
return parksAppAgents;
|
|
713
|
+
} catch {}
|
|
714
|
+
}
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function deployGlobalShims(targetToolsDir, dryRun = false) {
|
|
719
|
+
if (!targetToolsDir) return;
|
|
720
|
+
if (!dryRun && !fs.existsSync(targetToolsDir)) {
|
|
721
|
+
fs.mkdirSync(targetToolsDir, { recursive: true });
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
const isWin = os.platform() === 'win32';
|
|
725
|
+
const entryPath = path.resolve(__filename);
|
|
726
|
+
|
|
727
|
+
if (isWin) {
|
|
728
|
+
const cmdShim = path.join(targetToolsDir, 'heimdall.cmd');
|
|
729
|
+
const psShim = path.join(targetToolsDir, 'heimdall.ps1');
|
|
730
|
+
|
|
731
|
+
const cmdContent = `@echo off\nnode "${entryPath}" %*\n`;
|
|
732
|
+
const psContent = `param([Parameter(ValueFromRemainingArguments=$true)]$args)\n& node "${entryPath}" @args\n`;
|
|
733
|
+
|
|
734
|
+
if (!dryRun) {
|
|
735
|
+
fs.writeFileSync(cmdShim, cmdContent, 'utf8');
|
|
736
|
+
fs.writeFileSync(psShim, psContent, 'utf8');
|
|
737
|
+
}
|
|
738
|
+
} else {
|
|
739
|
+
const shShim = path.join(targetToolsDir, 'heimdall');
|
|
740
|
+
const shContent = `#!/usr/bin/env sh\nexec node "${entryPath}" "$@"\n`;
|
|
741
|
+
if (!dryRun) {
|
|
742
|
+
fs.writeFileSync(shShim, shContent, { mode: 0o755 });
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
async function syncModelsFromEndpoint() {
|
|
748
|
+
console.log(`${colors.cyan}${colors.bold}=== Live Model Synchronization ===${colors.reset}\n`);
|
|
749
|
+
const detected = detectEnvironment();
|
|
750
|
+
let proxyUrl = detected.endpoints.claude || detected.endpoints.codex;
|
|
751
|
+
|
|
752
|
+
let targetUrl = null;
|
|
753
|
+
if (proxyUrl && proxyUrl.startsWith('http')) {
|
|
754
|
+
if (proxyUrl.includes('ghostcli.cloud')) {
|
|
755
|
+
targetUrl = 'https://ghostcli.cloud/v1/models';
|
|
756
|
+
} else if (!proxyUrl.includes('api.anthropic.com') && !proxyUrl.includes('api.openai.com')) {
|
|
757
|
+
const base = proxyUrl.replace(/\/+$/, '');
|
|
758
|
+
targetUrl = base.endsWith('/v1') ? `${base}/models` : (base.endsWith('/models') ? base : `${base}/v1/models`);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
if (targetUrl) {
|
|
763
|
+
console.log(`Probing Proxy / Vendor Models API: ${colors.yellow}${targetUrl}${colors.reset}...`);
|
|
764
|
+
try {
|
|
765
|
+
const res = await fetch(targetUrl);
|
|
766
|
+
if (res.ok) {
|
|
767
|
+
const data = await res.json();
|
|
768
|
+
const modelsList = data.data || data.models || [];
|
|
769
|
+
console.log(`${colors.green}✔ Successfully discovered ${modelsList.length} live models from endpoint!${colors.reset}\n`);
|
|
770
|
+
|
|
771
|
+
let currentModels = {};
|
|
772
|
+
if (fs.existsSync(modelsPath)) {
|
|
773
|
+
currentModels = JSON.parse(fs.readFileSync(modelsPath, 'utf8'));
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const mapped = modelsList.map(m => ({
|
|
777
|
+
id: m.id || m.slug,
|
|
778
|
+
displayName: m.display_name || m.id,
|
|
779
|
+
context: m.context_window ? `${Math.round(m.context_window / 1000)}K` : '1M',
|
|
780
|
+
description: m.description || ''
|
|
781
|
+
}));
|
|
782
|
+
|
|
783
|
+
currentModels.custom_proxies = mapped;
|
|
784
|
+
currentModels.ghostcli = mapped;
|
|
785
|
+
|
|
786
|
+
fs.writeFileSync(modelsPath, JSON.stringify(currentModels, null, 2));
|
|
787
|
+
console.log(`${colors.green}✔ Synchronized models catalog to config/models.json${colors.reset}\n`);
|
|
788
|
+
} else {
|
|
789
|
+
console.log(`${colors.yellow}Notice: Endpoint returned HTTP ${res.status}. Preserving cached models.json.${colors.reset}\n`);
|
|
790
|
+
}
|
|
791
|
+
} catch (err) {
|
|
792
|
+
console.log(`${colors.yellow}Notice: Could not reach remote models API (${err.message}). Using local models.json.${colors.reset}\n`);
|
|
793
|
+
}
|
|
794
|
+
} else {
|
|
795
|
+
console.log(`Using configured models from ${modelsPath}.\n`);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
async function runSync(options, detected) {
|
|
800
|
+
console.log(`${colors.bold}${colors.cyan}=== Heimdall Auto-Sync Engine ===${colors.reset}\n`);
|
|
801
|
+
console.log(`Scanning for newly installed AI tools on PATH...\n`);
|
|
802
|
+
|
|
803
|
+
const allAvailableSkills = fs.readdirSync(skillsDir, { withFileTypes: true })
|
|
804
|
+
.filter(d => d.isDirectory())
|
|
805
|
+
.map(d => d.name);
|
|
806
|
+
|
|
807
|
+
const allAvailableAgents = fs.existsSync(agentsDir)
|
|
808
|
+
? fs.readdirSync(agentsDir).filter(f => f.endsWith('.md'))
|
|
809
|
+
: [];
|
|
810
|
+
|
|
811
|
+
let syncedAny = false;
|
|
812
|
+
|
|
813
|
+
for (const [agent, targetDir] of Object.entries(targetPaths)) {
|
|
814
|
+
let toolInstalled = false;
|
|
815
|
+
if (agent === 'claude' && detected.tools.claude) toolInstalled = true;
|
|
816
|
+
else if (agent === 'gemini' && (detected.tools.agy || fs.existsSync(path.join(userHome, '.gemini', 'antigravity-cli')))) toolInstalled = true;
|
|
817
|
+
else if (agent === 'codex' && detected.tools.codex) toolInstalled = true;
|
|
818
|
+
else if (agent === 'agents') toolInstalled = true;
|
|
819
|
+
else if (agent === 'hermes' && (detected.tools.hermes || fs.existsSync(getHermesDir()))) {
|
|
820
|
+
toolInstalled = true;
|
|
821
|
+
configureHermesExternalDirs(getHermesDir(), false);
|
|
822
|
+
}
|
|
823
|
+
else if (agent === 'openclaw' && (detected.tools.openclaw || fs.existsSync(getOpenClawDir()))) toolInstalled = true;
|
|
824
|
+
|
|
825
|
+
if (toolInstalled) {
|
|
826
|
+
// Synchronize doctrine, playbooks & commands unconditionally for installed harnesses
|
|
827
|
+
const targetDocFile = targetDoctrinePaths[agent];
|
|
828
|
+
const srcDoc = path.join(doctrineDir, 'AGENTS.md');
|
|
829
|
+
if (targetDocFile && fs.existsSync(srcDoc)) {
|
|
830
|
+
const parentDir = path.dirname(targetDocFile);
|
|
831
|
+
if (fs.existsSync(parentDir)) fs.copyFileSync(srcDoc, targetDocFile);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
const targetPlayDir = targetPlaybookPaths[agent];
|
|
835
|
+
if (targetPlayDir && fs.existsSync(playbooksDir)) {
|
|
836
|
+
const parentDir = path.dirname(targetPlayDir);
|
|
837
|
+
if (fs.existsSync(parentDir)) linkDirectory(playbooksDir, targetPlayDir, false);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
const targetCmdDir = targetCommandPaths[agent];
|
|
841
|
+
if (targetCmdDir && fs.existsSync(commandsDir)) {
|
|
842
|
+
const parentDir = path.dirname(targetCmdDir);
|
|
843
|
+
if (fs.existsSync(parentDir)) linkDirectory(commandsDir, targetCmdDir, false);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
const targetHookDir = targetHookPaths[agent];
|
|
847
|
+
if (targetHookDir && fs.existsSync(hooksDir)) {
|
|
848
|
+
const parentDir = path.dirname(targetHookDir);
|
|
849
|
+
if (fs.existsSync(parentDir)) {
|
|
850
|
+
linkDirectory(hooksDir, targetHookDir, false);
|
|
851
|
+
if (agent === 'claude') registerClaudeHooks(targetHookDir, false);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
const exists = fs.existsSync(targetDir);
|
|
856
|
+
const currentSkills = exists
|
|
857
|
+
? fs.readdirSync(targetDir, { withFileTypes: true }).filter(d => d.name !== '.system')
|
|
858
|
+
: [];
|
|
859
|
+
|
|
860
|
+
const targetAgentDir = targetAgentPaths[agent];
|
|
861
|
+
const agentExists = fs.existsSync(targetAgentDir);
|
|
862
|
+
const currentAgents = agentExists
|
|
863
|
+
? fs.readdirSync(targetAgentDir).filter(f => f.endsWith('.md'))
|
|
864
|
+
: [];
|
|
865
|
+
|
|
866
|
+
if (!exists || currentSkills.length < allAvailableSkills.length || !agentExists || currentAgents.length < allAvailableAgents.length) {
|
|
867
|
+
console.log(`-> Newly active harness detected: ${colors.bold}${agent.toUpperCase()}${colors.reset}`);
|
|
868
|
+
if (!fs.existsSync(targetDir)) fs.mkdirSync(targetDir, { recursive: true });
|
|
869
|
+
|
|
870
|
+
let count = 0;
|
|
871
|
+
for (const skill of allAvailableSkills) {
|
|
872
|
+
const srcSkill = path.join(skillsDir, skill);
|
|
873
|
+
const destSkill = path.join(targetDir, skill);
|
|
874
|
+
linkDirectory(srcSkill, destSkill, false);
|
|
875
|
+
count++;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
let agentCount = 0;
|
|
879
|
+
if (targetAgentDir) {
|
|
880
|
+
agentCount = deployAgentContracts(targetAgentDir, true, false, false);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
console.log(` ${colors.green}✔ Linked ${count} skills and ${agentCount} predefined agents via Live Junctions${colors.reset}\n`);
|
|
884
|
+
syncedAny = true;
|
|
885
|
+
} else {
|
|
886
|
+
console.log(` ${colors.green}✔${colors.reset} ${agent.toUpperCase().padEnd(8)}: 100% in sync (${currentSkills.length} skills, ${currentAgents.length} agents active)`);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// Check Claude Desktop
|
|
892
|
+
if (detected.tools.claudeDesktop) {
|
|
893
|
+
const claudeDesktopFile = path.join(detected.tools.claudeDesktop, 'claude_desktop_config.json');
|
|
894
|
+
let deskConfig = { mcpServers: {} };
|
|
895
|
+
if (fs.existsSync(claudeDesktopFile)) {
|
|
896
|
+
try { deskConfig = JSON.parse(fs.readFileSync(claudeDesktopFile, 'utf8')); } catch {}
|
|
897
|
+
}
|
|
898
|
+
if (!deskConfig.mcpServers?.context7) {
|
|
899
|
+
if (!deskConfig.mcpServers) deskConfig.mcpServers = {};
|
|
900
|
+
deskConfig.mcpServers.context7 = {
|
|
901
|
+
command: "npx",
|
|
902
|
+
args: ["-y", "@upstash/context7-mcp"]
|
|
903
|
+
};
|
|
904
|
+
fs.writeFileSync(claudeDesktopFile, JSON.stringify(deskConfig, null, 2));
|
|
905
|
+
console.log(` ${colors.green}✔${colors.reset} Configured Context7 MCP for Claude Desktop`);
|
|
906
|
+
syncedAny = true;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// Refresh bridge tools & shims
|
|
911
|
+
const activeToolsDir = options.toolsDir || detected.pathCandidates[0];
|
|
912
|
+
if (activeToolsDir && fs.existsSync(activeToolsDir)) {
|
|
913
|
+
deployGlobalShims(activeToolsDir, false);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
if (syncedAny) {
|
|
917
|
+
console.log(`\n${colors.bold}${colors.green}✔ Auto-sync complete! All active AI tools are now synchronized.${colors.reset}\n`);
|
|
918
|
+
} else {
|
|
919
|
+
console.log(`\n${colors.bold}${colors.green}✔ All detected AI tools are already up to date.${colors.reset}\n`);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
function runAudit(options) {
|
|
924
|
+
console.log(`${colors.bold}${colors.cyan}=== Heimdall Environment Audit ===${colors.reset}\n`);
|
|
925
|
+
|
|
926
|
+
const detected = detectEnvironment();
|
|
927
|
+
console.log(`${colors.bold}Detected Tools on Machine:${colors.reset}`);
|
|
928
|
+
console.log(` Claude Code CLI: ${detected.tools.claude ? colors.green + detected.tools.claude + colors.reset : colors.dim + 'Not on PATH' + colors.reset}`);
|
|
929
|
+
console.log(` Endpoint: ${colors.cyan}${detected.endpoints.claude}${colors.reset}`);
|
|
930
|
+
console.log(` Google Antigravity: ${detected.tools.agy ? colors.green + detected.tools.agy + colors.reset : colors.dim + 'Not on PATH' + colors.reset}`);
|
|
931
|
+
console.log(` Endpoint: ${colors.cyan}${detected.endpoints.gemini}${colors.reset}`);
|
|
932
|
+
console.log(` OpenAI Codex CLI: ${detected.tools.codex ? colors.green + detected.tools.codex + colors.reset : colors.dim + 'Not on PATH' + colors.reset}`);
|
|
933
|
+
console.log(` Endpoint: ${colors.cyan}${detected.endpoints.codex}${colors.reset}`);
|
|
934
|
+
if (detected.tools.hermes || fs.existsSync(getHermesDir())) {
|
|
935
|
+
console.log(` Hermes Agent: ${detected.tools.hermes ? colors.green + detected.tools.hermes + colors.reset : colors.dim + getHermesDir() + colors.reset}`);
|
|
936
|
+
console.log(` Endpoint: ${colors.cyan}${detected.endpoints.hermes}${colors.reset}`);
|
|
937
|
+
}
|
|
938
|
+
if (detected.tools.openclaw || fs.existsSync(getOpenClawDir())) {
|
|
939
|
+
console.log(` OpenClaw Agent: ${detected.tools.openclaw ? colors.green + detected.tools.openclaw + colors.reset : colors.dim + getOpenClawDir() + colors.reset}`);
|
|
940
|
+
console.log(` Endpoint: ${colors.cyan}${detected.endpoints.openclaw}${colors.reset}`);
|
|
941
|
+
}
|
|
942
|
+
console.log(` Claude Desktop: ${detected.tools.claudeDesktop ? colors.green + detected.tools.claudeDesktop + colors.reset : colors.dim + 'Not found' + colors.reset}`);
|
|
943
|
+
console.log('');
|
|
944
|
+
|
|
945
|
+
const availableSkills = fs.readdirSync(skillsDir, { withFileTypes: true })
|
|
946
|
+
.filter(d => d.isDirectory())
|
|
947
|
+
.map(d => d.name);
|
|
948
|
+
|
|
949
|
+
const availableAgents = fs.existsSync(agentsDir)
|
|
950
|
+
? fs.readdirSync(agentsDir).filter(f => f.endsWith('.md'))
|
|
951
|
+
: [];
|
|
952
|
+
|
|
953
|
+
let suiteCountText = '';
|
|
954
|
+
if (fs.existsSync(skillsConfigPath)) {
|
|
955
|
+
try {
|
|
956
|
+
const catalog = JSON.parse(fs.readFileSync(skillsConfigPath, 'utf8'));
|
|
957
|
+
if (catalog.totalSuites) {
|
|
958
|
+
suiteCountText = `${catalog.totalSuites} Suites (${availableSkills.length} modular capabilities)`;
|
|
959
|
+
}
|
|
960
|
+
} catch {}
|
|
961
|
+
}
|
|
962
|
+
if (!suiteCountText) {
|
|
963
|
+
suiteCountText = `${availableSkills.length} modular capabilities`;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
console.log(`Repository Canonical Skills: ${colors.green}${suiteCountText}${colors.reset}`);
|
|
967
|
+
console.log(`Repository Predefined Agents: ${colors.green}${availableAgents.length} Specialized Personas${colors.reset}\n`);
|
|
968
|
+
|
|
969
|
+
const unlinkedTools = [];
|
|
970
|
+
|
|
971
|
+
for (const [agent, targetDir] of Object.entries(targetPaths)) {
|
|
972
|
+
const targetAgentDir = targetAgentPaths[agent];
|
|
973
|
+
if (fs.existsSync(targetDir)) {
|
|
974
|
+
const entries = fs.readdirSync(targetDir, { withFileTypes: true })
|
|
975
|
+
.filter(d => (d.isDirectory() || d.isSymbolicLink()) && d.name !== '.system');
|
|
976
|
+
|
|
977
|
+
let linkedCount = 0;
|
|
978
|
+
for (const entry of entries) {
|
|
979
|
+
try {
|
|
980
|
+
if (fs.lstatSync(path.join(targetDir, entry.name)).isSymbolicLink()) {
|
|
981
|
+
linkedCount++;
|
|
982
|
+
}
|
|
983
|
+
} catch {}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
const installed = entries.map(d => d.name);
|
|
987
|
+
const missing = availableSkills.filter(s => !installed.includes(s));
|
|
988
|
+
const statusColor = missing.length === 0 ? colors.green : colors.yellow;
|
|
989
|
+
const linkLabel = linkedCount === installed.length && installed.length > 0
|
|
990
|
+
? ` (${colors.cyan}Live Junctions / Single Source of Truth${colors.reset})`
|
|
991
|
+
: linkedCount > 0 ? ` (${linkedCount} linked, ${installed.length - linkedCount} copies)` : ' (Static copies)';
|
|
992
|
+
|
|
993
|
+
const agentCount = fs.existsSync(targetAgentDir)
|
|
994
|
+
? fs.readdirSync(targetAgentDir).filter(f => f.endsWith('.md')).length
|
|
995
|
+
: 0;
|
|
996
|
+
|
|
997
|
+
console.log(` ${colors.bold}${agent.toUpperCase().padEnd(8)}${colors.reset} -> ${statusColor}${installed.length} skills, ${agentCount} agents${colors.reset} in ${path.dirname(targetDir)}${linkLabel}`);
|
|
998
|
+
|
|
999
|
+
if (installed.length === 0) {
|
|
1000
|
+
unlinkedTools.push(agent);
|
|
1001
|
+
}
|
|
1002
|
+
} else {
|
|
1003
|
+
const isHermesOrOpenClaw = agent === 'hermes' || agent === 'openclaw';
|
|
1004
|
+
const isToolDetected = (agent === 'hermes' && (detected.tools.hermes || fs.existsSync(getHermesDir()))) ||
|
|
1005
|
+
(agent === 'openclaw' && (detected.tools.openclaw || fs.existsSync(getOpenClawDir())));
|
|
1006
|
+
if (!isHermesOrOpenClaw || isToolDetected) {
|
|
1007
|
+
console.log(` ${colors.bold}${agent.toUpperCase().padEnd(8)}${colors.reset} -> ${colors.dim}NOT LINKED (${targetDir})${colors.reset}`);
|
|
1008
|
+
}
|
|
1009
|
+
if ((agent === 'claude' && detected.tools.claude) ||
|
|
1010
|
+
(agent === 'gemini' && detected.tools.agy) ||
|
|
1011
|
+
(agent === 'codex' && detected.tools.codex) ||
|
|
1012
|
+
(agent === 'hermes' && (detected.tools.hermes || fs.existsSync(getHermesDir()))) ||
|
|
1013
|
+
(agent === 'openclaw' && (detected.tools.openclaw || fs.existsSync(getOpenClawDir())))) {
|
|
1014
|
+
unlinkedTools.push(agent);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
if (unlinkedTools.length > 0) {
|
|
1020
|
+
console.log(`\n${colors.yellow}${colors.bold}[!] Notice:${colors.reset} Installed tools missing skill/agent links: ${unlinkedTools.join(', ')}`);
|
|
1021
|
+
console.log(` Run ${colors.cyan}heimdall sync${colors.reset} to link automatically in 1 second.`);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
const activeToolsDir = options.toolsDir || detected.pathCandidates[0];
|
|
1025
|
+
console.log(`\n${colors.bold}Cross-Agent Bridge Tools Directory:${colors.reset}`);
|
|
1026
|
+
if (activeToolsDir && fs.existsSync(activeToolsDir)) {
|
|
1027
|
+
const tools = fs.readdirSync(activeToolsDir).filter(f => f.includes('bridge') || f.includes('heimdall'));
|
|
1028
|
+
console.log(` ${colors.green}Found ${tools.length} active scripts in ${activeToolsDir}${colors.reset}`);
|
|
1029
|
+
} else {
|
|
1030
|
+
console.log(` ${colors.yellow}Tools directory unconfigured or empty (${activeToolsDir || 'None'})${colors.reset}`);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
const activeDoctrine = options.doctrinePath || (detected.doctrineCandidates.find(p => fs.existsSync(p)) || detected.doctrineCandidates[0]);
|
|
1034
|
+
console.log(`\n${colors.bold}Universal Doctrine & Playbooks:${colors.reset}`);
|
|
1035
|
+
if (fs.existsSync(activeDoctrine)) {
|
|
1036
|
+
console.log(` ${colors.green}Active at ${activeDoctrine}${colors.reset}`);
|
|
1037
|
+
} else {
|
|
1038
|
+
console.log(` ${colors.dim}Not found at ${activeDoctrine}${colors.reset}`);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
console.log('');
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
function isHeimdallInstalled(detected) {
|
|
1045
|
+
const allAvailableSkills = fs.existsSync(skillsDir)
|
|
1046
|
+
? fs.readdirSync(skillsDir, { withFileTypes: true }).filter(d => d.isDirectory()).map(d => d.name)
|
|
1047
|
+
: [];
|
|
1048
|
+
const skillSet = new Set(allAvailableSkills);
|
|
1049
|
+
const targets = [];
|
|
1050
|
+
let totalSkills = 0;
|
|
1051
|
+
|
|
1052
|
+
for (const [agent, targetDir] of Object.entries(targetPaths)) {
|
|
1053
|
+
if (!fs.existsSync(targetDir)) continue;
|
|
1054
|
+
try {
|
|
1055
|
+
const entries = fs.readdirSync(targetDir);
|
|
1056
|
+
let count = 0;
|
|
1057
|
+
for (const name of entries) {
|
|
1058
|
+
if (name !== '.system' && skillSet.has(name)) {
|
|
1059
|
+
count++;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
if (count > 0) {
|
|
1063
|
+
targets.push(agent);
|
|
1064
|
+
totalSkills += count;
|
|
1065
|
+
}
|
|
1066
|
+
} catch (err) {
|
|
1067
|
+
if (err.code === 'EACCES' || err.code === 'EPERM') {
|
|
1068
|
+
console.warn(`${colors.yellow}Warning: Permission denied inspecting ${targetDir}${colors.reset}`);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
return {
|
|
1074
|
+
installed: totalSkills > 0,
|
|
1075
|
+
targets,
|
|
1076
|
+
totalSkills
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
async function runUninstall(options, detected) {
|
|
1081
|
+
console.log(`${colors.bold}${colors.cyan}=== Heimdall Uninstallation ===${colors.reset}\n`);
|
|
1082
|
+
|
|
1083
|
+
if (!options.yes) {
|
|
1084
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1085
|
+
try {
|
|
1086
|
+
const confirm = await rl.question(`Are you sure you want to remove Heimdall skills and agents from all harnesses? (y/N): `);
|
|
1087
|
+
const answer = confirm.trim().toLowerCase();
|
|
1088
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
1089
|
+
console.log('Uninstallation cancelled.');
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
} finally {
|
|
1093
|
+
rl.close();
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
const allAvailableSkills = fs.existsSync(skillsDir)
|
|
1098
|
+
? fs.readdirSync(skillsDir, { withFileTypes: true }).filter(d => d.isDirectory()).map(d => d.name)
|
|
1099
|
+
: [];
|
|
1100
|
+
const skillSet = new Set(allAvailableSkills);
|
|
1101
|
+
|
|
1102
|
+
const allAvailableAgents = fs.existsSync(agentsDir)
|
|
1103
|
+
? fs.readdirSync(agentsDir).filter(f => f.endsWith('.md'))
|
|
1104
|
+
: [];
|
|
1105
|
+
const agentSet = new Set(allAvailableAgents);
|
|
1106
|
+
|
|
1107
|
+
let totalRemovedSkills = 0;
|
|
1108
|
+
let totalRemovedAgents = 0;
|
|
1109
|
+
|
|
1110
|
+
for (const [agent, targetDir] of Object.entries(targetPaths)) {
|
|
1111
|
+
if (!fs.existsSync(targetDir)) continue;
|
|
1112
|
+
let removed = 0;
|
|
1113
|
+
try {
|
|
1114
|
+
const dirStat = fs.lstatSync(targetDir);
|
|
1115
|
+
if (dirStat.isSymbolicLink()) {
|
|
1116
|
+
try { fs.unlinkSync(targetDir); } catch { fs.rmdirSync(targetDir); }
|
|
1117
|
+
removed = skillSet.size;
|
|
1118
|
+
} else {
|
|
1119
|
+
const entries = fs.readdirSync(targetDir);
|
|
1120
|
+
for (const name of entries) {
|
|
1121
|
+
if (name === '.system') continue;
|
|
1122
|
+
if (skillSet.has(name)) {
|
|
1123
|
+
const itemPath = path.join(targetDir, name);
|
|
1124
|
+
try {
|
|
1125
|
+
const stat = fs.lstatSync(itemPath);
|
|
1126
|
+
if (stat.isSymbolicLink() || stat.isFile()) {
|
|
1127
|
+
try { fs.unlinkSync(itemPath); } catch { fs.rmdirSync(itemPath); }
|
|
1128
|
+
} else if (stat.isDirectory()) {
|
|
1129
|
+
fs.rmSync(itemPath, { recursive: true, force: true });
|
|
1130
|
+
}
|
|
1131
|
+
removed++;
|
|
1132
|
+
} catch {}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
} catch {}
|
|
1137
|
+
if (removed > 0) {
|
|
1138
|
+
console.log(` ${colors.green}✔${colors.reset} Removed ${removed} skills from ${agent.toUpperCase()} (${targetDir})`);
|
|
1139
|
+
totalRemovedSkills += removed;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
for (const [agent, targetAgentDir] of Object.entries(targetAgentPaths)) {
|
|
1144
|
+
if (!fs.existsSync(targetAgentDir)) continue;
|
|
1145
|
+
let removed = 0;
|
|
1146
|
+
try {
|
|
1147
|
+
const dirStat = fs.lstatSync(targetAgentDir);
|
|
1148
|
+
if (dirStat.isSymbolicLink()) {
|
|
1149
|
+
try { fs.unlinkSync(targetAgentDir); } catch { fs.rmdirSync(targetAgentDir); }
|
|
1150
|
+
removed = agentSet.size;
|
|
1151
|
+
} else {
|
|
1152
|
+
const entries = fs.readdirSync(targetAgentDir);
|
|
1153
|
+
for (const file of entries) {
|
|
1154
|
+
if (agentSet.has(file)) {
|
|
1155
|
+
const itemPath = path.join(targetAgentDir, file);
|
|
1156
|
+
try {
|
|
1157
|
+
const stat = fs.lstatSync(itemPath);
|
|
1158
|
+
if (stat.isSymbolicLink() || stat.isFile()) {
|
|
1159
|
+
try { fs.unlinkSync(itemPath); } catch { fs.rmdirSync(itemPath); }
|
|
1160
|
+
} else if (stat.isDirectory()) {
|
|
1161
|
+
fs.rmSync(itemPath, { recursive: true, force: true });
|
|
1162
|
+
} else {
|
|
1163
|
+
fs.unlinkSync(itemPath);
|
|
1164
|
+
}
|
|
1165
|
+
removed++;
|
|
1166
|
+
} catch {}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
} catch {}
|
|
1171
|
+
if (removed > 0) {
|
|
1172
|
+
console.log(` ${colors.green}✔${colors.reset} Removed ${removed} agent personas from ${agent.toUpperCase()} (${targetAgentDir})`);
|
|
1173
|
+
totalRemovedAgents += removed;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
for (const [agent, targetHookDir] of Object.entries(targetHookPaths)) {
|
|
1178
|
+
if (!fs.existsSync(targetHookDir)) continue;
|
|
1179
|
+
try {
|
|
1180
|
+
const dirStat = fs.lstatSync(targetHookDir);
|
|
1181
|
+
if (dirStat.isSymbolicLink()) {
|
|
1182
|
+
try { fs.unlinkSync(targetHookDir); } catch { fs.rmdirSync(targetHookDir); }
|
|
1183
|
+
} else {
|
|
1184
|
+
fs.rmSync(targetHookDir, { recursive: true, force: true });
|
|
1185
|
+
}
|
|
1186
|
+
console.log(` ${colors.green}✔${colors.reset} Removed hooks from ${agent.toUpperCase()} (${targetHookDir})`);
|
|
1187
|
+
} catch {}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
const claudeSettingsPath = path.join(userHome, '.claude', 'settings.json');
|
|
1191
|
+
if (fs.existsSync(claudeSettingsPath)) {
|
|
1192
|
+
try {
|
|
1193
|
+
const settings = JSON.parse(fs.readFileSync(claudeSettingsPath, 'utf8'));
|
|
1194
|
+
if (settings.hooks) {
|
|
1195
|
+
delete settings.hooks;
|
|
1196
|
+
fs.writeFileSync(claudeSettingsPath, JSON.stringify(settings, null, 2), 'utf8');
|
|
1197
|
+
console.log(` ${colors.green}✔${colors.reset} Unregistered hooks from ${claudeSettingsPath}`);
|
|
1198
|
+
}
|
|
1199
|
+
} catch {}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
console.log(`\n${colors.bold}${colors.green}Uninstallation Complete:${colors.reset} Removed ${totalRemovedSkills} skill bindings and ${totalRemovedAgents} agent personas across harnesses.\n`);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
async function runPostInstallMenu(options, detected) {
|
|
1206
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1207
|
+
try {
|
|
1208
|
+
console.log(`${colors.bold}${colors.cyan}=== Heimdall Management Hub ===${colors.reset}`);
|
|
1209
|
+
console.log(`Heimdall is currently installed and active across your environment.\n`);
|
|
1210
|
+
console.log(`What would you like to do?`);
|
|
1211
|
+
console.log(` 1. Audit Environment & Health Check`);
|
|
1212
|
+
console.log(` 2. Fast Sync Skills & Agents (1-sec zero-drift)`);
|
|
1213
|
+
console.log(` 3. Refresh Dynamic Models (sync-models)`);
|
|
1214
|
+
console.log(` 4. Uninstall Heimdall`);
|
|
1215
|
+
console.log(` 5. Reinstall / Reconfigure Profile & Targets`);
|
|
1216
|
+
console.log(` 6. Exit\n`);
|
|
1217
|
+
|
|
1218
|
+
const answer = await rl.question(`Choose an option [1-6, default: 1]: `);
|
|
1219
|
+
const choice = answer.trim().toLowerCase();
|
|
1220
|
+
|
|
1221
|
+
if (choice === '1' || choice === '') {
|
|
1222
|
+
runAudit(options);
|
|
1223
|
+
process.exit(0);
|
|
1224
|
+
} else if (choice === '2') {
|
|
1225
|
+
await runSync(options, detected);
|
|
1226
|
+
process.exit(0);
|
|
1227
|
+
} else if (choice === '3') {
|
|
1228
|
+
await syncModelsFromEndpoint();
|
|
1229
|
+
process.exit(0);
|
|
1230
|
+
} else if (choice === '4') {
|
|
1231
|
+
await runUninstall(options, detected);
|
|
1232
|
+
process.exit(0);
|
|
1233
|
+
} else if (choice === '5') {
|
|
1234
|
+
return 'reinstall';
|
|
1235
|
+
} else if (choice === '6' || choice === 'q' || choice === 'exit') {
|
|
1236
|
+
console.log('Goodbye!');
|
|
1237
|
+
process.exit(0);
|
|
1238
|
+
} else {
|
|
1239
|
+
runAudit(options);
|
|
1240
|
+
process.exit(0);
|
|
1241
|
+
}
|
|
1242
|
+
} finally {
|
|
1243
|
+
rl.close();
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
async function runInteractive(options, detected) {
|
|
1248
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1249
|
+
|
|
1250
|
+
try {
|
|
1251
|
+
console.log(`${colors.bold}${colors.cyan}--- Detected Environment on Your Machine ---${colors.reset}`);
|
|
1252
|
+
console.log(` [${detected.tools.claude ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] Claude Code CLI ${detected.tools.claude ? '(' + detected.tools.claude + ')' : '(Not found)'}`);
|
|
1253
|
+
console.log(` ${colors.dim}Endpoint: ${detected.endpoints.claude}${colors.reset}`);
|
|
1254
|
+
console.log(` [${detected.tools.agy ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] Google Antigravity ${detected.tools.agy ? '(' + detected.tools.agy + ')' : '(Not found)'}`);
|
|
1255
|
+
console.log(` ${colors.dim}Endpoint: ${detected.endpoints.gemini}${colors.reset}`);
|
|
1256
|
+
console.log(` [${detected.tools.codex ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] OpenAI Codex CLI ${detected.tools.codex ? '(' + detected.tools.codex + ')' : '(Not found)'}`);
|
|
1257
|
+
console.log(` ${colors.dim}Endpoint: ${detected.endpoints.codex}${colors.reset}`);
|
|
1258
|
+
console.log(` [${detected.tools.hermes ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] Hermes Agent ${detected.tools.hermes ? '(' + detected.tools.hermes + ')' : '(Not found)'}`);
|
|
1259
|
+
console.log(` ${colors.dim}Endpoint: ${detected.endpoints.hermes}${colors.reset}`);
|
|
1260
|
+
console.log(` [${detected.tools.openclaw ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] OpenClaw ${detected.tools.openclaw ? '(' + detected.tools.openclaw + ')' : '(Not found)'}`);
|
|
1261
|
+
console.log(` ${colors.dim}Endpoint: ${detected.endpoints.openclaw}${colors.reset}`);
|
|
1262
|
+
console.log(` [${detected.tools.claudeDesktop ? colors.green + '✔' : colors.dim + ' '}${colors.reset}] Claude Desktop ${detected.tools.claudeDesktop ? '(' + detected.tools.claudeDesktop + ')' : '(Not found)'}`);
|
|
1263
|
+
console.log('');
|
|
1264
|
+
|
|
1265
|
+
console.log(`${colors.yellow}Where would you like Heimdall installed?${colors.reset}`);
|
|
1266
|
+
console.log(` 1. All Detected Tools (Full Ecosystem) [Recommended]`);
|
|
1267
|
+
console.log(` 2. Claude Code CLI only`);
|
|
1268
|
+
console.log(` 3. Google Antigravity CLI only`);
|
|
1269
|
+
console.log(` 4. OpenAI Codex CLI only`);
|
|
1270
|
+
console.log(` 5. Hermes Agent only`);
|
|
1271
|
+
console.log(` 6. OpenClaw only`);
|
|
1272
|
+
console.log(` 7. Claude Desktop only (MCP & Playbooks)`);
|
|
1273
|
+
console.log(` 8. Custom Multi-Selection (e.g. Claude + Hermes)`);
|
|
1274
|
+
|
|
1275
|
+
const tChoice = await rl.question(`Choose installation targets [1-8, default: 1]: `);
|
|
1276
|
+
if (tChoice === '2') options.agents = ['claude'];
|
|
1277
|
+
else if (tChoice === '3') options.agents = ['gemini'];
|
|
1278
|
+
else if (tChoice === '4') options.agents = ['codex'];
|
|
1279
|
+
else if (tChoice === '5') options.agents = ['hermes'];
|
|
1280
|
+
else if (tChoice === '6') options.agents = ['openclaw'];
|
|
1281
|
+
else if (tChoice === '7') options.agents = ['desktop'];
|
|
1282
|
+
else if (tChoice === '8') {
|
|
1283
|
+
const custom = await rl.question(`Enter comma-separated targets (claude, gemini, codex, hermes, openclaw, desktop): `);
|
|
1284
|
+
options.agents = custom.split(',').map(s => s.trim().toLowerCase());
|
|
1285
|
+
} else {
|
|
1286
|
+
options.agents = ['all'];
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
console.log(`\n${colors.yellow}Select Installation Profile Tier:${colors.reset}`);
|
|
1290
|
+
console.log(` 1. full - All 50 curated skills (Complete Powerhouse)`);
|
|
1291
|
+
console.log(` 2. minimal - 16 core skills (Planning, TDD, Anti-Slop, Taste, Hygiene)`);
|
|
1292
|
+
console.log(` 3. security - 12 security skills (Differential HTTP probing, OWASP, Trail of Bits)`);
|
|
1293
|
+
console.log(` 4. design - 14 frontend skills (Taste, GSAP motion, Brandkit, Tokens)`);
|
|
1294
|
+
|
|
1295
|
+
const pChoice = await rl.question(`Choose profile tier [1-4, default: 1]: `);
|
|
1296
|
+
if (pChoice === '2') options.profile = 'minimal';
|
|
1297
|
+
else if (pChoice === '3') options.profile = 'security';
|
|
1298
|
+
else if (pChoice === '4') options.profile = 'design';
|
|
1299
|
+
else options.profile = 'full';
|
|
1300
|
+
|
|
1301
|
+
console.log(`\n${colors.yellow}Select Deployment Mode:${colors.reset}`);
|
|
1302
|
+
console.log(` 1. Live NTFS Junctions / Symlinks (Single Source of Truth, Instant Sync) [Recommended]`);
|
|
1303
|
+
console.log(` 2. Physical Isolated Copies (Independent folders)`);
|
|
1304
|
+
const mChoice = await rl.question(`Choose mode [1-2, default: 1]: `);
|
|
1305
|
+
options.link = mChoice !== '2';
|
|
1306
|
+
|
|
1307
|
+
const cleanChoice = await rl.question(`Clean existing legacy skills before installing? (y/n, default: y): `);
|
|
1308
|
+
options.clean = cleanChoice.toLowerCase() !== 'n';
|
|
1309
|
+
|
|
1310
|
+
// Dynamic Tools Path Discovery
|
|
1311
|
+
console.log(`\n${colors.yellow}Cross-Agent Bridge Tools & CLI Shortcut Location:${colors.reset}`);
|
|
1312
|
+
detected.pathCandidates.forEach((cand, idx) => {
|
|
1313
|
+
console.log(` ${idx + 1}. ${cand} (Found on PATH)`);
|
|
1314
|
+
});
|
|
1315
|
+
console.log(` ${detected.pathCandidates.length + 1}. Custom Directory Path`);
|
|
1316
|
+
console.log(` ${detected.pathCandidates.length + 2}. Skip Tools Installation`);
|
|
1317
|
+
|
|
1318
|
+
const toolsInput = await rl.question(`Select destination [1-${detected.pathCandidates.length + 2}, default: 1]: `);
|
|
1319
|
+
const chosenIdx = parseInt(toolsInput, 10);
|
|
1320
|
+
if (chosenIdx >= 1 && chosenIdx <= detected.pathCandidates.length) {
|
|
1321
|
+
options.toolsDir = detected.pathCandidates[chosenIdx - 1];
|
|
1322
|
+
options.tools = true;
|
|
1323
|
+
} else if (chosenIdx === detected.pathCandidates.length + 1) {
|
|
1324
|
+
const customPath = await rl.question(`Enter custom directory: `);
|
|
1325
|
+
options.toolsDir = customPath.trim();
|
|
1326
|
+
options.tools = true;
|
|
1327
|
+
} else if (chosenIdx === detected.pathCandidates.length + 2) {
|
|
1328
|
+
options.tools = false;
|
|
1329
|
+
} else {
|
|
1330
|
+
options.toolsDir = detected.pathCandidates[0];
|
|
1331
|
+
options.tools = true;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
// Dynamic Doctrine Path Discovery
|
|
1335
|
+
console.log(`\n${colors.yellow}Universal Doctrine (AGENTS.md) Location:${colors.reset}`);
|
|
1336
|
+
detected.doctrineCandidates.forEach((cand, idx) => {
|
|
1337
|
+
const existsLabel = fs.existsSync(cand) ? ` (${colors.green}Active${colors.reset})` : '';
|
|
1338
|
+
console.log(` ${idx + 1}. ${cand}${existsLabel}`);
|
|
1339
|
+
});
|
|
1340
|
+
console.log(` ${detected.doctrineCandidates.length + 1}. Custom File Path`);
|
|
1341
|
+
console.log(` ${detected.doctrineCandidates.length + 2}. Skip Doctrine Deployment`);
|
|
1342
|
+
|
|
1343
|
+
const docInput = await rl.question(`Select destination [1-${detected.doctrineCandidates.length + 2}, default: 1]: `);
|
|
1344
|
+
const chosenDocIdx = parseInt(docInput, 10);
|
|
1345
|
+
if (chosenDocIdx >= 1 && chosenDocIdx <= detected.doctrineCandidates.length) {
|
|
1346
|
+
options.doctrinePath = detected.doctrineCandidates[chosenDocIdx - 1];
|
|
1347
|
+
options.doctrine = true;
|
|
1348
|
+
} else if (chosenDocIdx === detected.doctrineCandidates.length + 1) {
|
|
1349
|
+
const customDoc = await rl.question(`Enter custom AGENTS.md path: `);
|
|
1350
|
+
options.doctrinePath = customDoc.trim();
|
|
1351
|
+
options.doctrine = true;
|
|
1352
|
+
} else if (chosenDocIdx === detected.doctrineCandidates.length + 2) {
|
|
1353
|
+
options.doctrine = false;
|
|
1354
|
+
} else {
|
|
1355
|
+
options.doctrinePath = detected.doctrineCandidates[0];
|
|
1356
|
+
options.doctrine = true;
|
|
1357
|
+
}
|
|
1358
|
+
} finally {
|
|
1359
|
+
rl.close();
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
function runListSkills() {
|
|
1364
|
+
console.log(`${colors.bold}${colors.cyan}=== Heimdall Canonical Skills & Suites Catalog ===${colors.reset}\n`);
|
|
1365
|
+
|
|
1366
|
+
if (!fs.existsSync(skillsConfigPath)) {
|
|
1367
|
+
console.log(`${colors.red}Registry file not found at ${skillsConfigPath}${colors.reset}`);
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
const catalog = JSON.parse(fs.readFileSync(skillsConfigPath, 'utf8'));
|
|
1372
|
+
const skills = catalog.skills || {};
|
|
1373
|
+
const suites = catalog.suites || {};
|
|
1374
|
+
const totalSuites = catalog.totalSuites || Object.keys(suites).length;
|
|
1375
|
+
const totalModules = catalog.totalModules || Object.keys(skills).length;
|
|
1376
|
+
|
|
1377
|
+
console.log(`Architecture: ${colors.bold}${colors.green}${totalSuites} Primary Toolkits & Suites (${totalModules} modular capabilities)${colors.reset}\n`);
|
|
1378
|
+
|
|
1379
|
+
// 1. Multi-Skill Core Suites
|
|
1380
|
+
console.log(`${colors.bold}${colors.yellow}CORE MULTI-SKILL SUITES:${colors.reset}`);
|
|
1381
|
+
console.log(`${colors.dim}------------------------------------------------------------------------${colors.reset}`);
|
|
1382
|
+
for (const [key, suite] of Object.entries(suites)) {
|
|
1383
|
+
if (suite.type === 'Multi-Skill Suite') {
|
|
1384
|
+
console.log(`\n📦 ${colors.bold}${colors.cyan}${suite.name}${colors.reset} (${suite.modules.length} modules)`);
|
|
1385
|
+
console.log(` ${colors.dim}Upstream: ${suite.upstream}${colors.reset}`);
|
|
1386
|
+
for (const mod of suite.modules) {
|
|
1387
|
+
const modInfo = skills[mod];
|
|
1388
|
+
const descPreview = modInfo && modInfo.description ? `— ${modInfo.description.slice(0, 55)}...` : '';
|
|
1389
|
+
console.log(` • ${colors.bold}${mod.padEnd(32)}${colors.reset} ${colors.dim}${descPreview}${colors.reset}`);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
// 2. Standalone Toolkits
|
|
1395
|
+
console.log(`\n\n${colors.bold}${colors.yellow}STANDALONE POWER TOOLKITS:${colors.reset}`);
|
|
1396
|
+
console.log(`${colors.dim}------------------------------------------------------------------------${colors.reset}`);
|
|
1397
|
+
for (const [key, suite] of Object.entries(suites)) {
|
|
1398
|
+
if (suite.type === 'Standalone Toolkit') {
|
|
1399
|
+
const mod = suite.modules[0];
|
|
1400
|
+
const modInfo = skills[mod];
|
|
1401
|
+
const descPreview = modInfo && modInfo.description ? `— ${modInfo.description.slice(0, 48)}...` : '';
|
|
1402
|
+
console.log(`⚡ ${colors.bold}${mod.padEnd(28)}${colors.reset} ${colors.dim}${descPreview}${colors.reset}`);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
console.log(`\n${colors.dim}Run 'heimdall update-skill <name|all>' to inspect provenance and updates.${colors.reset}\n`);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
function runUpdateSkill(targetSkill = 'all') {
|
|
1410
|
+
console.log(`${colors.bold}${colors.cyan}=== Upstream Skill Provenance & Bounded Review Protocol ===${colors.reset}\n`);
|
|
1411
|
+
|
|
1412
|
+
if (!fs.existsSync(skillsConfigPath)) {
|
|
1413
|
+
console.log(`${colors.red}Registry file not found at ${skillsConfigPath}${colors.reset}`);
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
const catalog = JSON.parse(fs.readFileSync(skillsConfigPath, 'utf8'));
|
|
1418
|
+
const skills = catalog.skills || {};
|
|
1419
|
+
const protocol = catalog.updateProtocol;
|
|
1420
|
+
|
|
1421
|
+
console.log(`${colors.bold}Standard Verification Directive:${colors.reset}`);
|
|
1422
|
+
console.log(`${colors.dim}"${protocol}"${colors.reset}\n`);
|
|
1423
|
+
|
|
1424
|
+
if (targetSkill.toLowerCase() === 'all') {
|
|
1425
|
+
const skillList = Object.entries(skills);
|
|
1426
|
+
console.log(`${colors.bold}Canonical Skills Provenance Table (${skillList.length} skills):${colors.reset}\n`);
|
|
1427
|
+
console.log(`${'Skill Name'.padEnd(32)} ${'Category'.padEnd(28)} Upstream Source`);
|
|
1428
|
+
console.log(`${'-'.repeat(31)} ${'-'.repeat(27)} ${'-'.repeat(45)}`);
|
|
1429
|
+
for (const [name, info] of skillList) {
|
|
1430
|
+
console.log(`${name.padEnd(32)} ${(info.category || '').padEnd(28)} ${colors.cyan}${info.upstream}${colors.reset}`);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
console.log(`\n${colors.bold}${colors.green}Bounded Review Private Report Template:${colors.reset}`);
|
|
1434
|
+
console.log(`------------------------------------------------------------------------`);
|
|
1435
|
+
console.log(`Skill Name: <name>`);
|
|
1436
|
+
console.log(`Upstream Repository: <source URL>`);
|
|
1437
|
+
console.log(`Source Revision: <commit hash / release tag>`);
|
|
1438
|
+
console.log(`Reviewed Range: <diff range: e.g. v1.0.0..v1.1.0>`);
|
|
1439
|
+
console.log(`Actual Tests Run: node setup.mjs audit && <skill-specific-tests>`);
|
|
1440
|
+
console.log(`Remaining Validation: <sign-off status>`);
|
|
1441
|
+
console.log(`------------------------------------------------------------------------\n`);
|
|
1442
|
+
console.log(`To inspect a single skill in detail, run: ${colors.bold}heimdall update-skill <name>${colors.reset}\n`);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
const skillInfo = skills[targetSkill];
|
|
1447
|
+
if (!skillInfo) {
|
|
1448
|
+
console.log(`${colors.red}Skill '${targetSkill}' not found in canonical registry.${colors.reset}`);
|
|
1449
|
+
console.log(`Run ${colors.bold}heimdall skills${colors.reset} to view all available skills.\n`);
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
console.log(`${colors.bold}Skill Target:${colors.reset} ${colors.green}${skillInfo.name}${colors.reset}`);
|
|
1454
|
+
console.log(`${colors.bold}Category:${colors.reset} ${skillInfo.category}`);
|
|
1455
|
+
console.log(`${colors.bold}Description:${colors.reset} ${skillInfo.description || '(none)'}`);
|
|
1456
|
+
console.log(`${colors.bold}Upstream Repository:${colors.reset} ${colors.cyan}${skillInfo.upstream}${colors.reset}`);
|
|
1457
|
+
console.log(`${colors.bold}Frozen Revision:${colors.reset} ${skillInfo.sourceRevision || 'v1.0.0'}\n`);
|
|
1458
|
+
|
|
1459
|
+
console.log(`${colors.bold}Recommended Update Steps:${colors.reset}`);
|
|
1460
|
+
console.log(`1. Inspect upstream changes:`);
|
|
1461
|
+
console.log(` ${colors.dim}git ls-remote ${skillInfo.upstream}${colors.reset}`);
|
|
1462
|
+
console.log(`2. Review changed instructions / references in the updated upstream commit.`);
|
|
1463
|
+
console.log(`3. Apply surgical edits to ${colors.cyan}skills/${skillInfo.name}/SKILL.md${colors.reset}.`);
|
|
1464
|
+
console.log(`4. Run boundary and audit checks:`);
|
|
1465
|
+
console.log(` ${colors.dim}node setup.mjs audit${colors.reset}`);
|
|
1466
|
+
console.log(`5. Record your bounded review report:`);
|
|
1467
|
+
console.log(` ---------------------------------------------------------------------`);
|
|
1468
|
+
console.log(` Skill Name: ${skillInfo.name}`);
|
|
1469
|
+
console.log(` Upstream Repository: ${skillInfo.upstream}`);
|
|
1470
|
+
console.log(` Source Revision: <new-commit-hash>`);
|
|
1471
|
+
console.log(` Reviewed Range: <diff range>`);
|
|
1472
|
+
console.log(` Actual Tests Run: node setup.mjs audit`);
|
|
1473
|
+
console.log(` Remaining Validation: Verified compatible with multi-agent runtimes`);
|
|
1474
|
+
console.log(` ---------------------------------------------------------------------\n`);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
async function main() {
|
|
1478
|
+
printBanner();
|
|
1479
|
+
const options = parseArgs();
|
|
1480
|
+
const detected = detectEnvironment();
|
|
1481
|
+
|
|
1482
|
+
if (options.help) {
|
|
1483
|
+
printHelp();
|
|
1484
|
+
process.exit(0);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
if (options.audit) {
|
|
1488
|
+
runAudit(options);
|
|
1489
|
+
process.exit(0);
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
if (options.listSkills) {
|
|
1493
|
+
runListSkills();
|
|
1494
|
+
process.exit(0);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
if (options.updateSkill) {
|
|
1498
|
+
runUpdateSkill(options.updateSkill);
|
|
1499
|
+
process.exit(0);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
if (options.syncModels) {
|
|
1503
|
+
await syncModelsFromEndpoint();
|
|
1504
|
+
process.exit(0);
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
if (options.sync) {
|
|
1508
|
+
await runSync(options, detected);
|
|
1509
|
+
process.exit(0);
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
if (options.uninstall) {
|
|
1513
|
+
await runUninstall(options, detected);
|
|
1514
|
+
process.exit(0);
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
// Set default dynamic paths if not specified
|
|
1518
|
+
if (!options.toolsDir) {
|
|
1519
|
+
options.toolsDir = detected.pathCandidates[0];
|
|
1520
|
+
}
|
|
1521
|
+
if (!options.doctrinePath) {
|
|
1522
|
+
options.doctrinePath = detected.doctrineCandidates.find(p => fs.existsSync(p)) || detected.doctrineCandidates[0];
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
if (!options.yes && !options.hasArgs) {
|
|
1526
|
+
const installState = isHeimdallInstalled(detected);
|
|
1527
|
+
if (installState.installed) {
|
|
1528
|
+
const action = await runPostInstallMenu(options, detected);
|
|
1529
|
+
if (action !== 'reinstall') {
|
|
1530
|
+
process.exit(0);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
if (!options.yes) {
|
|
1536
|
+
await runInteractive(options, detected);
|
|
1537
|
+
} else if (!options.agents) {
|
|
1538
|
+
options.agents = ['all'];
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
const profilesData = JSON.parse(fs.readFileSync(profilesPath, 'utf8'));
|
|
1542
|
+
const selectedProfile = profilesData.profiles[options.profile] || profilesData.profiles.full;
|
|
1543
|
+
|
|
1544
|
+
console.log(`\n${colors.bold}${colors.cyan}=== Executing Heimdall Installation ===${colors.reset}`);
|
|
1545
|
+
console.log(`Profile: ${colors.bold}${selectedProfile.name}${colors.reset} (${options.profile})`);
|
|
1546
|
+
console.log(`Mode: ${options.link ? colors.cyan + 'Live Junctions (Single Source of Truth)' + colors.reset : 'Physical Copies'}`);
|
|
1547
|
+
console.log(`Cleanup: ${options.clean ? colors.yellow + 'Wiping legacy skills before install' + colors.reset : 'Incremental update'}`);
|
|
1548
|
+
console.log(`Targets: ${options.agents.join(', ')}`);
|
|
1549
|
+
console.log(`Tools Dir: ${options.tools ? colors.green + options.toolsDir + colors.reset : 'Skipped'}`);
|
|
1550
|
+
console.log(`Doctrine: ${options.doctrine ? colors.green + options.doctrinePath + colors.reset : 'Skipped'}`);
|
|
1551
|
+
console.log(`Dry Run: ${options.dryRun ? colors.yellow + 'ENABLED' + colors.reset : 'No'}\n`);
|
|
1552
|
+
|
|
1553
|
+
// 1. Resolve skills to deploy
|
|
1554
|
+
const allAvailableSkills = fs.readdirSync(skillsDir, { withFileTypes: true })
|
|
1555
|
+
.filter(d => d.isDirectory())
|
|
1556
|
+
.map(d => d.name);
|
|
1557
|
+
|
|
1558
|
+
const skillsToInstall = selectedProfile.skills === '*'
|
|
1559
|
+
? allAvailableSkills
|
|
1560
|
+
: selectedProfile.skills.filter(s => allAvailableSkills.includes(s));
|
|
1561
|
+
|
|
1562
|
+
console.log(`Selected Skills to Deploy: ${colors.green}${skillsToInstall.length}${colors.reset}`);
|
|
1563
|
+
|
|
1564
|
+
// 2. Resolve destination agent directories
|
|
1565
|
+
let activeDestinations = [];
|
|
1566
|
+
if (options.agents.includes('all')) {
|
|
1567
|
+
activeDestinations = Object.entries(targetPaths).filter(([agent]) => {
|
|
1568
|
+
if (agent === 'openclaw') return Boolean(detected.tools.openclaw || fs.existsSync(getOpenClawDir()));
|
|
1569
|
+
if (agent === 'hermes') return Boolean(detected.tools.hermes || fs.existsSync(getHermesDir()));
|
|
1570
|
+
return true;
|
|
1571
|
+
});
|
|
1572
|
+
} else {
|
|
1573
|
+
for (const agent of options.agents) {
|
|
1574
|
+
if (targetPaths[agent]) {
|
|
1575
|
+
activeDestinations.push([agent, targetPaths[agent]]);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
// 3. Clean and deploy skills
|
|
1581
|
+
for (const [agent, targetDir] of activeDestinations) {
|
|
1582
|
+
console.log(`\n-> Deploying to ${colors.bold}${agent.toUpperCase()}${colors.reset} (${targetDir})...`);
|
|
1583
|
+
if (!options.dryRun && !fs.existsSync(targetDir)) {
|
|
1584
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
if (options.clean) {
|
|
1588
|
+
const cleaned = cleanTargetDirectory(targetDir, options.dryRun);
|
|
1589
|
+
if (cleaned > 0) {
|
|
1590
|
+
console.log(` ${colors.yellow}Cleaned ${cleaned} legacy entries (preserved vendor files)${colors.reset}`);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
let installedCount = 0;
|
|
1595
|
+
for (const skill of skillsToInstall) {
|
|
1596
|
+
const srcSkill = path.join(skillsDir, skill);
|
|
1597
|
+
const destSkill = path.join(targetDir, skill);
|
|
1598
|
+
|
|
1599
|
+
if (options.link) {
|
|
1600
|
+
linkDirectory(srcSkill, destSkill, options.dryRun);
|
|
1601
|
+
} else {
|
|
1602
|
+
copyDirectory(srcSkill, destSkill, options.dryRun);
|
|
1603
|
+
}
|
|
1604
|
+
installedCount++;
|
|
1605
|
+
}
|
|
1606
|
+
const modeVerb = options.link ? 'Linked (NTFS Junctions)' : 'Synchronized';
|
|
1607
|
+
console.log(` ${colors.green}✔ ${modeVerb} ${installedCount} skills to ${agent}${colors.reset}`);
|
|
1608
|
+
|
|
1609
|
+
if (agent === 'hermes') {
|
|
1610
|
+
const hermesConfigured = configureHermesExternalDirs(getHermesDir(), options.dryRun);
|
|
1611
|
+
if (hermesConfigured) {
|
|
1612
|
+
console.log(` ${colors.green}✔ Registered ~/.agents/skills in Hermes config.yaml external_dirs${colors.reset}`);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
// 3.b Deploy Predefined Agents
|
|
1618
|
+
console.log(`\n${colors.bold}${colors.cyan}--- Deploying Predefined Agents ---${colors.reset}`);
|
|
1619
|
+
const allAvailableAgents = fs.existsSync(agentsDir)
|
|
1620
|
+
? fs.readdirSync(agentsDir).filter(f => f.endsWith('.md'))
|
|
1621
|
+
: [];
|
|
1622
|
+
const agentsToInstall = (selectedProfile.agents === '*' || !selectedProfile.agents)
|
|
1623
|
+
? allAvailableAgents
|
|
1624
|
+
: selectedProfile.agents.map(a => `${a}.md`).filter(f => allAvailableAgents.includes(f));
|
|
1625
|
+
|
|
1626
|
+
for (const [agent, targetDir] of activeDestinations) {
|
|
1627
|
+
const targetAgentDir = targetAgentPaths[agent];
|
|
1628
|
+
if (targetAgentDir) {
|
|
1629
|
+
const count = deployAgentContracts(targetAgentDir, options.link, options.clean, options.dryRun, agentsToInstall);
|
|
1630
|
+
const modeVerb = options.link ? 'Linked (NTFS Junctions)' : 'Synchronized';
|
|
1631
|
+
console.log(` ${colors.green}✔ ${modeVerb} ${count} predefined agents to ${agent} (${targetAgentDir})${colors.reset}`);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
// Cleanup legacy local agents if clean requested
|
|
1636
|
+
if (options.clean) {
|
|
1637
|
+
const cleanedLocal = cleanLegacyLocalAgents(options.dryRun);
|
|
1638
|
+
if (cleanedLocal) {
|
|
1639
|
+
console.log(` ${colors.yellow}✔ Cleaned legacy local agents in ${cleanedLocal} and linked canonical registry${colors.reset}`);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
// 4. Configure Claude Desktop if selected or in 'all'
|
|
1644
|
+
if (options.agents.includes('desktop') || options.agents.includes('all')) {
|
|
1645
|
+
const claudeDesktopDir = getClaudeDesktopDir();
|
|
1646
|
+
const claudeDesktopFile = path.join(claudeDesktopDir, 'claude_desktop_config.json');
|
|
1647
|
+
|
|
1648
|
+
console.log(`\n-> Configuring Claude Desktop (${claudeDesktopFile})...`);
|
|
1649
|
+
if (!options.dryRun) {
|
|
1650
|
+
if (!fs.existsSync(claudeDesktopDir)) fs.mkdirSync(claudeDesktopDir, { recursive: true });
|
|
1651
|
+
let deskConfig = { mcpServers: {} };
|
|
1652
|
+
if (fs.existsSync(claudeDesktopFile)) {
|
|
1653
|
+
try { deskConfig = JSON.parse(fs.readFileSync(claudeDesktopFile, 'utf8')); } catch {}
|
|
1654
|
+
}
|
|
1655
|
+
if (!deskConfig.mcpServers) deskConfig.mcpServers = {};
|
|
1656
|
+
deskConfig.mcpServers.context7 = {
|
|
1657
|
+
command: "npx",
|
|
1658
|
+
args: ["-y", "@upstash/context7-mcp"]
|
|
1659
|
+
};
|
|
1660
|
+
fs.writeFileSync(claudeDesktopFile, JSON.stringify(deskConfig, null, 2));
|
|
1661
|
+
}
|
|
1662
|
+
console.log(` ${colors.green}✔ Configured Context7 MCP for Claude Desktop${colors.reset}`);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// 5. Deploy tools & global heimdall CLI shims if requested
|
|
1666
|
+
if (options.tools && options.toolsDir) {
|
|
1667
|
+
console.log(`\n-> Deploying Bridge Tools & 'heimdall' CLI to ${colors.bold}${options.toolsDir}${colors.reset}...`);
|
|
1668
|
+
if (!options.dryRun && !fs.existsSync(options.toolsDir)) {
|
|
1669
|
+
fs.mkdirSync(options.toolsDir, { recursive: true });
|
|
1670
|
+
}
|
|
1671
|
+
const tools = fs.readdirSync(toolsDir);
|
|
1672
|
+
for (const tool of tools) {
|
|
1673
|
+
const src = path.join(toolsDir, tool);
|
|
1674
|
+
const dest = path.join(options.toolsDir, tool);
|
|
1675
|
+
if (!options.dryRun) {
|
|
1676
|
+
fs.copyFileSync(src, dest);
|
|
1677
|
+
if (os.platform() !== 'win32' && tool.endsWith('.sh')) {
|
|
1678
|
+
try { fs.chmodSync(dest, 0o755); } catch {}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
// Deploy global heimdall shim
|
|
1683
|
+
deployGlobalShims(options.toolsDir, options.dryRun);
|
|
1684
|
+
console.log(` ${colors.green}✔ Deployed ${tools.length} cross-model bridge tools + 'heimdall' global CLI shim${colors.reset}`);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
// 6. Deploy universal doctrine & playbooks if requested
|
|
1688
|
+
if (options.doctrine) {
|
|
1689
|
+
console.log(`\n-> Deploying Universal Doctrine & Playbooks...`);
|
|
1690
|
+
const srcDoc = path.join(doctrineDir, 'AGENTS.md');
|
|
1691
|
+
if (fs.existsSync(srcDoc) && !options.dryRun) {
|
|
1692
|
+
if (options.doctrinePath) {
|
|
1693
|
+
const docParent = path.dirname(options.doctrinePath);
|
|
1694
|
+
if (!fs.existsSync(docParent)) fs.mkdirSync(docParent, { recursive: true });
|
|
1695
|
+
fs.copyFileSync(srcDoc, options.doctrinePath);
|
|
1696
|
+
console.log(` ${colors.green}✔ Universal AGENTS.md doctrine active at ${options.doctrinePath}${colors.reset}`);
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
// Synchronize doctrine across all active harnesses
|
|
1700
|
+
for (const [agent, targetDocFile] of Object.entries(targetDoctrinePaths)) {
|
|
1701
|
+
const parentDir = path.dirname(targetDocFile);
|
|
1702
|
+
if (fs.existsSync(parentDir)) {
|
|
1703
|
+
fs.copyFileSync(srcDoc, targetDocFile);
|
|
1704
|
+
console.log(` ${colors.green}✔ Synchronized doctrine to ${targetDocFile}${colors.reset}`);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
// Synchronize playbooks
|
|
1709
|
+
if (fs.existsSync(playbooksDir)) {
|
|
1710
|
+
for (const [agent, targetPlayDir] of Object.entries(targetPlaybookPaths)) {
|
|
1711
|
+
const parentDir = path.dirname(targetPlayDir);
|
|
1712
|
+
if (fs.existsSync(parentDir)) {
|
|
1713
|
+
if (options.link) {
|
|
1714
|
+
linkDirectory(playbooksDir, targetPlayDir, options.dryRun);
|
|
1715
|
+
} else {
|
|
1716
|
+
copyDirectory(playbooksDir, targetPlayDir, options.dryRun);
|
|
1717
|
+
}
|
|
1718
|
+
console.log(` ${colors.green}✔ Synchronized playbooks to ${targetPlayDir}${colors.reset}`);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
// Synchronize custom commands (Claude Code CLI)
|
|
1724
|
+
if (fs.existsSync(commandsDir)) {
|
|
1725
|
+
for (const [agent, targetCmdDir] of Object.entries(targetCommandPaths)) {
|
|
1726
|
+
const parentDir = path.dirname(targetCmdDir);
|
|
1727
|
+
if (fs.existsSync(parentDir)) {
|
|
1728
|
+
if (options.link) {
|
|
1729
|
+
linkDirectory(commandsDir, targetCmdDir, options.dryRun);
|
|
1730
|
+
} else {
|
|
1731
|
+
copyDirectory(commandsDir, targetCmdDir, options.dryRun);
|
|
1732
|
+
}
|
|
1733
|
+
console.log(` ${colors.green}✔ Synchronized commands to ${targetCmdDir}${colors.reset}`);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// Synchronize lifecycle hooks (Claude Code CLI)
|
|
1739
|
+
if (fs.existsSync(hooksDir)) {
|
|
1740
|
+
for (const [agent, targetHookDir] of Object.entries(targetHookPaths)) {
|
|
1741
|
+
const parentDir = path.dirname(targetHookDir);
|
|
1742
|
+
if (fs.existsSync(parentDir)) {
|
|
1743
|
+
if (options.link) {
|
|
1744
|
+
linkDirectory(hooksDir, targetHookDir, options.dryRun);
|
|
1745
|
+
} else {
|
|
1746
|
+
copyDirectory(hooksDir, targetHookDir, options.dryRun);
|
|
1747
|
+
}
|
|
1748
|
+
console.log(` ${colors.green}✔ Synchronized lifecycle hooks to ${targetHookDir}${colors.reset}`);
|
|
1749
|
+
if (agent === 'claude') {
|
|
1750
|
+
registerClaudeHooks(targetHookDir, options.dryRun);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
console.log(`\n${colors.bold}${colors.green}=== Heimdall Installation Complete! ===${colors.reset}\n`);
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
main().catch(err => {
|
|
1762
|
+
console.error(`\n${colors.red}Error executing Heimdall installer:${colors.reset}`, err);
|
|
1763
|
+
process.exit(1);
|
|
1764
|
+
});
|