Files
gstack/hosts/index.ts
Rocky 834c6db075
Some checks failed
Workflow Lint / actionlint (push) Has been cancelled
Build CI Image / build (push) Has been cancelled
Skill Docs Freshness / check-freshness (push) Has been cancelled
Periodic Evals / build-image (push) Has been cancelled
Periodic Evals / evals (map[file:test/codex-e2e.test.ts name:e2e-codex]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/gemini-e2e.test.ts name:e2e-gemini]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-design.test.ts name:e2e-design]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-plan.test.ts name:e2e-plan]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-qa-bugs.test.ts name:e2e-qa-bugs]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-qa-workflow.test.ts name:e2e-qa-workflow]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-review.test.ts name:e2e-review]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-workflow.test.ts name:e2e-workflow]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-routing-e2e.test.ts name:e2e-routing]) (push) Has been cancelled
Initial import from garrytan/gstack@026751e (main snapshot via local relay)
Source: https://github.com/garrytan/gstack/commit/026751e
2026-05-19 21:18:17 +02:00

69 lines
2.2 KiB
TypeScript

/**
* Host config registry.
*
* Import all host configs and derive the Host union type.
* Adding a new host: create hosts/myhost.ts, import here, add to ALL_HOST_CONFIGS.
*/
import type { HostConfig } from '../scripts/host-config';
import claude from './claude';
import codex from './codex';
import factory from './factory';
import kiro from './kiro';
import opencode from './opencode';
import slate from './slate';
import cursor from './cursor';
import openclaw from './openclaw';
import hermes from './hermes';
import gbrain from './gbrain';
/** All registered host configs. Add new hosts here. */
export const ALL_HOST_CONFIGS: HostConfig[] = [claude, codex, factory, kiro, opencode, slate, cursor, openclaw, hermes, gbrain];
/** Map from host name to config. */
export const HOST_CONFIG_MAP: Record<string, HostConfig> = Object.fromEntries(
ALL_HOST_CONFIGS.map(c => [c.name, c])
);
/** Union type of all host names, derived from configs. */
export type Host = (typeof ALL_HOST_CONFIGS)[number]['name'];
/** All host names as a string array (for CLI arg validation, etc.). */
export const ALL_HOST_NAMES: string[] = ALL_HOST_CONFIGS.map(c => c.name);
/** Get a host config by name. Throws if not found. */
export function getHostConfig(name: string): HostConfig {
const config = HOST_CONFIG_MAP[name];
if (!config) {
throw new Error(`Unknown host '${name}'. Valid hosts: ${ALL_HOST_NAMES.join(', ')}`);
}
return config;
}
/**
* Resolve a host name from a CLI argument, handling aliases.
* e.g., 'agents' → 'codex', 'droid' → 'factory'
*/
export function resolveHostArg(arg: string): string {
// Direct name match
if (HOST_CONFIG_MAP[arg]) return arg;
// Alias match
for (const config of ALL_HOST_CONFIGS) {
if (config.cliAliases?.includes(arg)) return config.name;
}
throw new Error(`Unknown host '${arg}'. Valid hosts: ${ALL_HOST_NAMES.join(', ')}`);
}
/**
* Get hosts that are NOT the primary host (Claude).
* These are the hosts that need generated skill docs.
*/
export function getExternalHosts(): HostConfig[] {
return ALL_HOST_CONFIGS.filter(c => c.name !== 'claude');
}
// Re-export individual configs for direct import
export { claude, codex, factory, kiro, opencode, slate, cursor, openclaw, hermes, gbrain };