Files

33 lines
1.3 KiB
JavaScript

/**
* @file Installs .claude/skills/ship-feature-lane/ into ~/.claude/skills/, so
* /ship-feature-lane is discoverable from a session running inside any
* lane's own working directory — not just inside this repo, where it lives
* until installed. Shared by bin/ccam.js's `ccam skills install` CLI and the
* POST /api/skills/install route, so there is exactly one copy of this
* logic. Pure filesystem action.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
/**
* @param {{repoRoot: string}} options - `repoRoot` is this checkout's own
* root (bin/ccam.js already computes this as `REPO_ROOT`; the server
* computes its own equivalent — see the route for how).
* @returns {{installed: true, path: string}}
*/
function installShipFeatureLaneSkill({ repoRoot }) {
const src = path.join(repoRoot, ".claude", "skills", "ship-feature-lane");
if (!fs.existsSync(src)) {
throw Object.assign(new Error(`not found: ${src}`), { code: "ENOSKILLSRC" });
}
const dest = path.join(os.homedir(), ".claude", "skills", "ship-feature-lane");
fs.mkdirSync(path.dirname(dest), { recursive: true });
fs.cpSync(src, dest, { recursive: true, force: true });
return { installed: true, path: dest };
}
module.exports = { installShipFeatureLaneSkill };