Add multi-host skill bridge for WorkBuddy, Claude, and Qoder
Decouple agent host skill bridging into dedicated module src/core/agent-hosts/: - antigravity.ts: manage ~/.gemini/config/skills.json - symlink-hosts.ts: detect and bridge ~/.workbuddy, ~/.claude, and ~/.qoder - types.ts: explicit types for host results and statuses - agent-hosts.test.ts: isolated unit tests for host discovery and symlinks Respect existing parent symlinks, replace legacy real directories safely, prevent dotfile pollution by only acting when host roots exist, and expose unified hosts array in seal-use skill install & status.
This commit is contained in:
1 parent
ee4cb332d9
commit
fb673f754e
8 files changed
+785
-254
No files matched your search
+2
-138
@@ -105,141 +105,5 @@ export function syncGlobalSkillIfPresent(): { synced: boolean; targetDir?: strin
|
||||
return { synced: false };
|
||||
}
|
||||
|
||||
export type AntigravitySkillsSyncResult = {
|
||||
detected: boolean;
|
||||
configured: boolean;
|
||||
configPath: string;
|
||||
targetDir: string;
|
||||
action: "created" | "prepended" | "already_present" | "updated_tilde";
|
||||
};
|
||||
|
||||
export type AntigravitySkillsStatus = {
|
||||
detected: boolean;
|
||||
configured: boolean;
|
||||
configPath: string;
|
||||
targetDir: string;
|
||||
};
|
||||
|
||||
export function getGlobalAgentsSkillsDir(): string {
|
||||
return join(homedir(), ".agents", "skills");
|
||||
}
|
||||
|
||||
export function getAntigravitySkillsConfigFile(): string {
|
||||
return join(homedir(), ".gemini", "config", "skills.json");
|
||||
}
|
||||
|
||||
export function isAntigravityDetected(): boolean {
|
||||
const home = homedir();
|
||||
return (
|
||||
existsSync(join(home, ".gemini", "antigravity")) ||
|
||||
existsSync(join(home, ".gemini", "antigravity-cli")) ||
|
||||
existsSync(join(home, ".local", "bin", "agy"))
|
||||
);
|
||||
}
|
||||
|
||||
export function syncAntigravitySkillsConfig(options?: {
|
||||
configFile?: string;
|
||||
targetSkillsDir?: string;
|
||||
}): AntigravitySkillsSyncResult {
|
||||
const targetDir = options?.targetSkillsDir ?? getGlobalAgentsSkillsDir();
|
||||
const configPath = options?.configFile ?? getAntigravitySkillsConfigFile();
|
||||
const detected = isAntigravityDetected();
|
||||
|
||||
if (!existsSync(configPath)) {
|
||||
mkdirSync(dirname(configPath), { recursive: true });
|
||||
const initialConfig = {
|
||||
entries: [{ path: targetDir }]
|
||||
};
|
||||
writeFileSync(configPath, JSON.stringify(initialConfig, null, 2) + "\n", "utf8");
|
||||
return {
|
||||
detected,
|
||||
configured: true,
|
||||
configPath,
|
||||
targetDir,
|
||||
action: "created"
|
||||
};
|
||||
}
|
||||
|
||||
let parsed: { entries?: Array<{ path?: string; [key: string]: unknown }>; [key: string]: unknown } = {};
|
||||
try {
|
||||
parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
||||
} catch {
|
||||
parsed = { entries: [] };
|
||||
}
|
||||
|
||||
if (!Array.isArray(parsed.entries)) {
|
||||
parsed.entries = [];
|
||||
}
|
||||
|
||||
const exactIndex = parsed.entries.findIndex(
|
||||
(entry) => entry && typeof entry.path === "string" && entry.path === targetDir
|
||||
);
|
||||
if (exactIndex !== -1) {
|
||||
return {
|
||||
detected,
|
||||
configured: true,
|
||||
configPath,
|
||||
targetDir,
|
||||
action: "already_present"
|
||||
};
|
||||
}
|
||||
|
||||
const tildeIndex = parsed.entries.findIndex(
|
||||
(entry) =>
|
||||
entry &&
|
||||
typeof entry.path === "string" &&
|
||||
(entry.path === "~/.agents/skills" || entry.path === "~/.agents/skills/")
|
||||
);
|
||||
if (tildeIndex !== -1) {
|
||||
parsed.entries[tildeIndex] = { ...parsed.entries[tildeIndex], path: targetDir };
|
||||
writeFileSync(configPath, JSON.stringify(parsed, null, 2) + "\n", "utf8");
|
||||
return {
|
||||
detected,
|
||||
configured: true,
|
||||
configPath,
|
||||
targetDir,
|
||||
action: "updated_tilde"
|
||||
};
|
||||
}
|
||||
|
||||
parsed.entries.unshift({ path: targetDir });
|
||||
writeFileSync(configPath, JSON.stringify(parsed, null, 2) + "\n", "utf8");
|
||||
return {
|
||||
detected,
|
||||
configured: true,
|
||||
configPath,
|
||||
targetDir,
|
||||
action: "prepended"
|
||||
};
|
||||
}
|
||||
|
||||
export function getAntigravitySkillsStatus(options?: {
|
||||
configFile?: string;
|
||||
targetSkillsDir?: string;
|
||||
}): AntigravitySkillsStatus {
|
||||
const targetDir = options?.targetSkillsDir ?? getGlobalAgentsSkillsDir();
|
||||
const configPath = options?.configFile ?? getAntigravitySkillsConfigFile();
|
||||
const detected = isAntigravityDetected();
|
||||
let configured = false;
|
||||
|
||||
if (existsSync(configPath)) {
|
||||
try {
|
||||
const parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
||||
if (Array.isArray(parsed?.entries)) {
|
||||
configured = parsed.entries.some(
|
||||
(e: { path?: string }) => e?.path === targetDir
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
detected,
|
||||
configured,
|
||||
configPath,
|
||||
targetDir
|
||||
};
|
||||
}
|
||||
|
||||
// Re-export agent host skill bridging capabilities
|
||||
export * from "./agent-hosts/index.js";
|
||||
Reference in new issue
Block a user