Files
msd-core/tests/multi-runtime-select.test.cjs
teknium1 b126c0579a feat(install): add Hermes Agent runtime support (#2841)
Adds Hermes Agent as a supported installation target. Users can run
\`npx get-shit-done-cc --hermes\` to install all 86 GSD commands as
skills under \`~/.hermes/skills/gsd-*/SKILL.md\`, following the same
open skill standard as Claude Code 2.1.88+, Qwen Code, Antigravity,
Trae, Augment, and Codebuddy.

Hermes Agent is an open-source AI agent framework by Nous Research
(NousResearch/hermes-agent, MIT). Its skill loader accepts the Claude
skill format as-is: frontmatter parsed with PyYAML SafeLoader (unknown
keys like \`allowed-tools\` / \`argument-hint\` ignored), body XML tags
(\`<objective>\`, \`<execution_context>\`, \`<process>\`) passed directly
to the model. Compatibility proven end-to-end with all 86 GSD skills
loading cleanly, \`skill_view()\` returning full bodies, and
\`build_skills_system_prompt()\` emitting them into the agent system
prompt — zero Hermes code changes required.

Changes:
- \`bin/install.js\`: --hermes flag, getDirName/getGlobalDir/getConfigDirFromHome
  support, HERMES_HOME env var (native to Hermes — used for profile
  mode / Docker deploys), install/uninstall pipelines, interactive
  picker option 10 (alphabetical: between Gemini and Kilo), .hermes
  path replacements in copyCommandsAsClaudeSkills and
  copyWithPathReplacement, legacy commands/gsd cleanup, CLAUDE.md ->
  HERMES.md and "Claude Code" -> "Hermes Agent" content rewrites in
  skills/agents/hooks, runtime-appropriate finish message.
- \`get-shit-done/bin/lib/core.cjs\`: add hermes to KNOWN_RUNTIMES;
  add RUNTIME_PROFILE_MAP.hermes with OpenRouter-slug defaults
  (Hermes is provider-agnostic; these defaults resolve across
  OpenRouter, native Anthropic, and Copilot via Hermes' aggregator-
  aware resolver, and are overridable per-tier via
  model_profile_overrides.hermes.{opus,sonnet,haiku}).
- \`README.md\`: Hermes Agent in tagline, runtime list, verification
  command, install/uninstall examples, \`--hermes\` flag reference.
- \`tests/hermes-install.test.cjs\`: new, 14 tests covering directory
  mapping, HERMES_HOME env var precedence, install/uninstall
  lifecycle, user-skill preservation, engine cleanup.
- \`tests/hermes-skills-migration.test.cjs\`: new, 11 tests covering
  frontmatter conversion, path replacement (~/.claude/ ->
  \$HERMES_HOME/skills/), CLAUDE.md -> HERMES.md, "Claude Code" ->
  "Hermes Agent", stale skill cleanup, SKILL.md format validation.
- \`tests/multi-runtime-select.test.cjs\`: updated for new option
  numbering (hermes=10, kilo=11, opencode=12, qwen=13, trae=14,
  windsurf=15, all=16).
- \`tests/kilo-install.test.cjs\`: updated assertions for Kilo having
  moved from option 10 to option 11.

Closes #2841

Implementation notes:
- Zero custom code paths: Hermes reuses copyCommandsAsClaudeSkills()
  identical to Qwen Code / Antigravity pattern.
- Path replacement: ~/.claude/, \$HOME/.claude/, ./.claude/ ->
  .hermes equivalents in skill/agent/hook content.
- Config precedence: --config-dir > HERMES_HOME > ~/.hermes (matches
  how Hermes itself resolves its home directory).
- Legacy cleanup: removes commands/gsd/ if present from a prior
  install, preserving dev-preferences.md (same as Qwen).
- No external dependencies added.

Testing: 5841 / 5841 tests pass (0 failures, 0 regressions)
- 14 new tests in hermes-install.test.cjs
- 11 new tests in hermes-skills-migration.test.cjs
- multi-runtime-select.test.cjs renumbered + 1 new test (single choice for hermes)
2026-04-30 17:24:53 -04:00

210 lines
6.8 KiB
JavaScript

/**
* Tests for multi-runtime selection in the interactive installer prompt.
* Verifies that promptRuntime accepts comma-separated, space-separated,
* and single-choice inputs, deduplicates, and falls back to claude.
* See issue #1281.
*/
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
// Read install.js source to extract the runtimeMap and parsing logic
const installSrc = fs.readFileSync(
path.join(__dirname, '..', 'bin', 'install.js'),
'utf8'
);
// Extract runtimeMap from source for validation
const runtimeMap = {
'1': 'claude',
'2': 'antigravity',
'3': 'augment',
'4': 'cline',
'5': 'codebuddy',
'6': 'codex',
'7': 'copilot',
'8': 'cursor',
'9': 'gemini',
'10': 'hermes',
'11': 'kilo',
'12': 'opencode',
'13': 'qwen',
'14': 'trae',
'15': 'windsurf'
};
const allRuntimes = ['claude', 'antigravity', 'augment', 'cline', 'codebuddy', 'codex', 'copilot', 'cursor', 'gemini', 'hermes', 'kilo', 'opencode', 'qwen', 'trae', 'windsurf'];
/**
* Simulate the parsing logic from promptRuntime without requiring readline.
* This mirrors the exact logic in the rl.question callback.
*/
function parseRuntimeInput(input) {
input = input.trim() || '1';
if (input === '16') {
return allRuntimes;
}
const choices = input.split(/[\s,]+/).filter(Boolean);
const selected = [];
for (const c of choices) {
const runtime = runtimeMap[c];
if (runtime && !selected.includes(runtime)) {
selected.push(runtime);
}
}
return selected.length > 0 ? selected : ['claude'];
}
describe('multi-runtime selection parsing', () => {
test('single choice returns single runtime', () => {
assert.deepStrictEqual(parseRuntimeInput('1'), ['claude']);
assert.deepStrictEqual(parseRuntimeInput('2'), ['antigravity']);
assert.deepStrictEqual(parseRuntimeInput('3'), ['augment']);
assert.deepStrictEqual(parseRuntimeInput('4'), ['cline']);
assert.deepStrictEqual(parseRuntimeInput('5'), ['codebuddy']);
assert.deepStrictEqual(parseRuntimeInput('6'), ['codex']);
assert.deepStrictEqual(parseRuntimeInput('7'), ['copilot']);
assert.deepStrictEqual(parseRuntimeInput('8'), ['cursor']);
});
test('comma-separated choices return multiple runtimes', () => {
assert.deepStrictEqual(parseRuntimeInput('1,7,9'), ['claude', 'copilot', 'gemini']);
assert.deepStrictEqual(parseRuntimeInput('2,3'), ['antigravity', 'augment']);
assert.deepStrictEqual(parseRuntimeInput('3,6'), ['augment', 'codex']);
});
test('space-separated choices return multiple runtimes', () => {
assert.deepStrictEqual(parseRuntimeInput('1 7 9'), ['claude', 'copilot', 'gemini']);
assert.deepStrictEqual(parseRuntimeInput('8 11'), ['cursor', 'kilo']);
});
test('mixed comma and space separators work', () => {
assert.deepStrictEqual(parseRuntimeInput('1, 7, 9'), ['claude', 'copilot', 'gemini']);
assert.deepStrictEqual(parseRuntimeInput('2 , 8'), ['antigravity', 'cursor']);
});
test('single choice for hermes', () => {
assert.deepStrictEqual(parseRuntimeInput('10'), ['hermes']);
});
test('single choice for kilo', () => {
assert.deepStrictEqual(parseRuntimeInput('11'), ['kilo']);
});
test('single choice for opencode', () => {
assert.deepStrictEqual(parseRuntimeInput('12'), ['opencode']);
});
test('single choice for qwen', () => {
assert.deepStrictEqual(parseRuntimeInput('13'), ['qwen']);
});
test('single choice for trae', () => {
assert.deepStrictEqual(parseRuntimeInput('14'), ['trae']);
});
test('single choice for windsurf', () => {
assert.deepStrictEqual(parseRuntimeInput('15'), ['windsurf']);
});
test('choice 16 returns all runtimes', () => {
assert.deepStrictEqual(parseRuntimeInput('16'), allRuntimes);
});
test('empty input defaults to claude', () => {
assert.deepStrictEqual(parseRuntimeInput(''), ['claude']);
assert.deepStrictEqual(parseRuntimeInput(' '), ['claude']);
});
test('invalid choices are ignored, falls back to claude if all invalid', () => {
assert.deepStrictEqual(parseRuntimeInput('17'), ['claude']);
assert.deepStrictEqual(parseRuntimeInput('0'), ['claude']);
assert.deepStrictEqual(parseRuntimeInput('abc'), ['claude']);
});
test('invalid choices mixed with valid are filtered out', () => {
assert.deepStrictEqual(parseRuntimeInput('1,17,7'), ['claude', 'copilot']);
assert.deepStrictEqual(parseRuntimeInput('abc 3 xyz'), ['augment']);
});
test('duplicate choices are deduplicated', () => {
assert.deepStrictEqual(parseRuntimeInput('1,1,1'), ['claude']);
assert.deepStrictEqual(parseRuntimeInput('7,7,9,9'), ['copilot', 'gemini']);
});
test('preserves selection order', () => {
assert.deepStrictEqual(parseRuntimeInput('9,1,7'), ['gemini', 'claude', 'copilot']);
assert.deepStrictEqual(parseRuntimeInput('11,2,8'), ['kilo', 'antigravity', 'cursor']);
});
});
describe('install.js source contains multi-select support', () => {
test('runtimeMap is defined with all 15 runtimes', () => {
for (const [key, name] of Object.entries(runtimeMap)) {
assert.ok(
installSrc.includes(`'${key}': '${name}'`),
`runtimeMap has ${key} -> ${name}`
);
}
});
test('allRuntimes array contains all runtimes', () => {
const match = installSrc.match(/const allRuntimes = \[([^\]]+)\]/);
assert.ok(match, 'allRuntimes array found');
for (const rt of allRuntimes) {
assert.ok(match[1].includes(`'${rt}'`), `allRuntimes includes ${rt}`);
}
});
test('all shortcut uses option 16', () => {
assert.ok(
installSrc.includes("if (input === '16')"),
'all shortcut uses option 16'
);
});
test('prompt lists Hermes Agent as option 10, Qwen Code as option 13, and All as option 16', () => {
assert.ok(
installSrc.includes('10${reset}) Hermes Agent'),
'prompt lists Hermes Agent as option 10'
);
assert.ok(
installSrc.includes('13${reset}) Qwen Code'),
'prompt lists Qwen Code as option 13'
);
assert.ok(
installSrc.includes('14${reset}) Trae'),
'prompt lists Trae as option 14'
);
assert.ok(
installSrc.includes('16${reset}) All'),
'prompt lists All as option 16'
);
});
test('prompt text shows multi-select hint', () => {
assert.ok(
installSrc.includes('Select multiple'),
'prompt includes multi-select instructions'
);
});
test('parsing uses split with comma and space regex', () => {
assert.ok(
installSrc.includes("split(/[\\s,]+/)"),
'input is split on commas and whitespace'
);
});
test('deduplication check exists', () => {
assert.ok(
installSrc.includes('!selected.includes(runtime)'),
'deduplication guard exists'
);
});
});