mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-06 13:45:35 +02:00
8b5256342b
Three new hosts added to the declarative config system. Each is a typed HostConfig object with paths, frontmatter rules, and path rewrites. All generate valid SKILL.md output with zero .claude/skills path leakage. - hosts/opencode.ts: OpenCode (opencode.ai), skills at ~/.config/opencode/ - hosts/slate.ts: Slate (Random Labs), skills at ~/.slate/ - hosts/cursor.ts: Cursor, skills at ~/.cursor/ - .gitignore: add .kiro/, .opencode/, .slate/, .cursor/, .openclaw/ Zero code changes needed — just config files + re-export in index.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
66 lines
2.1 KiB
TypeScript
66 lines
2.1 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';
|
|
|
|
/** All registered host configs. Add new hosts here. */
|
|
export const ALL_HOST_CONFIGS: HostConfig[] = [claude, codex, factory, kiro, opencode, slate, cursor];
|
|
|
|
/** 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 };
|