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.
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { existsSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import {
|
|
getAllLinkableHostsStatus,
|
|
getAntigravitySkillsStatus,
|
|
syncAllLinkableHosts,
|
|
syncAntigravitySkillsConfig
|
|
} from "../../core/agent-hosts/index.js";
|
|
import {
|
|
getDefaultGlobalSkillDir,
|
|
getSkillContent,
|
|
installSkillFiles
|
|
} from "../../core/embedded-skill.js";
|
|
import { booleanOption, stringOption } from "../parser.js";
|
|
import { printJson } from "../printer.js";
|
|
import type { ParsedArgs } from "../types.js";
|
|
|
|
export function handleSkillCommand(action: string | undefined, maybeName: string | undefined, args: ParsedArgs) {
|
|
if (action === "dump" || action === "cat" || action === "show") {
|
|
process.stdout.write(`${getSkillContent()}\n`);
|
|
return;
|
|
}
|
|
|
|
if (action === "install" || action === "init" || action === "sync") {
|
|
const isLocal = booleanOption(args.options.local) || booleanOption(args.options.workspace);
|
|
const customDir = stringOption(args.options.dir) ?? stringOption(args.options.target) ?? maybeName;
|
|
const targetDir = customDir
|
|
? customDir
|
|
: isLocal
|
|
? join(process.cwd(), ".agents", "skills", "seal-use")
|
|
: getDefaultGlobalSkillDir();
|
|
|
|
const result = installSkillFiles(targetDir);
|
|
const isGlobal = !isLocal && !customDir;
|
|
const antigravity = isGlobal ? syncAntigravitySkillsConfig() : undefined;
|
|
const hosts = isGlobal ? syncAllLinkableHosts() : undefined;
|
|
|
|
printJson({
|
|
installed: true,
|
|
targetDir: result.targetDir,
|
|
fileCount: result.files.length,
|
|
files: result.files,
|
|
...(antigravity ? { antigravity } : {}),
|
|
...(hosts ? { hosts } : {})
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (action === "status" || action === "get" || !action) {
|
|
const globalDir = getDefaultGlobalSkillDir();
|
|
const localDir = join(process.cwd(), ".agents", "skills", "seal-use");
|
|
const antigravity = getAntigravitySkillsStatus();
|
|
const hosts = getAllLinkableHostsStatus();
|
|
printJson({
|
|
global: {
|
|
dir: globalDir,
|
|
installed: existsSync(join(globalDir, "SKILL.md"))
|
|
},
|
|
local: {
|
|
dir: localDir,
|
|
installed: existsSync(join(localDir, "SKILL.md"))
|
|
},
|
|
antigravity,
|
|
hosts
|
|
});
|
|
return;
|
|
}
|
|
|
|
throw new Error(`Unknown skill command: ${action}. Run 'seal-use help' for available commands.`);
|
|
}
|