mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-08 06:26:45 +02:00
refactor: derive Host type and HOST_PATHS from host configs
types.ts no longer hardcodes host names or paths. The Host type is derived from ALL_HOST_CONFIGS in hosts/index.ts, and HOST_PATHS is built dynamically from each config's globalRoot/localSkillRoot/usesEnvVars. Adding a new host to hosts/index.ts automatically extends the type system. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+39
-24
@@ -1,4 +1,11 @@
|
|||||||
export type Host = 'claude' | 'codex' | 'factory';
|
import { ALL_HOST_CONFIGS } from '../../hosts/index';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Host type — derived from host configs in hosts/*.ts.
|
||||||
|
* Adding a new host: create hosts/myhost.ts + add to hosts/index.ts.
|
||||||
|
* Do NOT hardcode host names here.
|
||||||
|
*/
|
||||||
|
export type Host = (typeof ALL_HOST_CONFIGS)[number]['name'];
|
||||||
|
|
||||||
export interface HostPaths {
|
export interface HostPaths {
|
||||||
skillRoot: string;
|
skillRoot: string;
|
||||||
@@ -8,29 +15,37 @@ export interface HostPaths {
|
|||||||
designDir: string;
|
designDir: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HOST_PATHS: Record<Host, HostPaths> = {
|
/**
|
||||||
claude: {
|
* HOST_PATHS — derived from host configs.
|
||||||
skillRoot: '~/.claude/skills/gstack',
|
* Each config's globalRoot/localSkillRoot determines the path structure.
|
||||||
localSkillRoot: '.claude/skills/gstack',
|
* Non-Claude hosts use $GSTACK_ROOT env vars (set by preamble).
|
||||||
binDir: '~/.claude/skills/gstack/bin',
|
*/
|
||||||
browseDir: '~/.claude/skills/gstack/browse/dist',
|
function buildHostPaths(): Record<string, HostPaths> {
|
||||||
designDir: '~/.claude/skills/gstack/design/dist',
|
const paths: Record<string, HostPaths> = {};
|
||||||
},
|
for (const config of ALL_HOST_CONFIGS) {
|
||||||
codex: {
|
if (config.usesEnvVars) {
|
||||||
skillRoot: '$GSTACK_ROOT',
|
paths[config.name] = {
|
||||||
localSkillRoot: '.agents/skills/gstack',
|
skillRoot: '$GSTACK_ROOT',
|
||||||
binDir: '$GSTACK_BIN',
|
localSkillRoot: config.localSkillRoot,
|
||||||
browseDir: '$GSTACK_BROWSE',
|
binDir: '$GSTACK_BIN',
|
||||||
designDir: '$GSTACK_DESIGN',
|
browseDir: '$GSTACK_BROWSE',
|
||||||
},
|
designDir: '$GSTACK_DESIGN',
|
||||||
factory: {
|
};
|
||||||
skillRoot: '$GSTACK_ROOT',
|
} else {
|
||||||
localSkillRoot: '.factory/skills/gstack',
|
const root = `~/${config.globalRoot}`;
|
||||||
binDir: '$GSTACK_BIN',
|
paths[config.name] = {
|
||||||
browseDir: '$GSTACK_BROWSE',
|
skillRoot: root,
|
||||||
designDir: '$GSTACK_DESIGN',
|
localSkillRoot: config.localSkillRoot,
|
||||||
},
|
binDir: `${root}/bin`,
|
||||||
};
|
browseDir: `${root}/browse/dist`,
|
||||||
|
designDir: `${root}/design/dist`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const HOST_PATHS: Record<string, HostPaths> = buildHostPaths();
|
||||||
|
|
||||||
export interface TemplateContext {
|
export interface TemplateContext {
|
||||||
skillName: string;
|
skillName: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user