api2cli 0.3.15 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2803,11 +2803,40 @@ async function buildCli(app, compile) {
|
|
|
2803
2803
|
|
|
2804
2804
|
// src/commands/link.ts
|
|
2805
2805
|
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
2806
|
-
import { existsSync as existsSync9, readdirSync as readdirSync5 } from "fs";
|
|
2807
|
-
|
|
2806
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readdirSync as readdirSync5, symlinkSync as symlinkSync3, unlinkSync as unlinkSync3 } from "fs";
|
|
2807
|
+
import { homedir as homedir4 } from "os";
|
|
2808
|
+
import { join as join8 } from "path";
|
|
2809
|
+
var AGENT_SKILL_DIRS = {
|
|
2810
|
+
claude: join8(homedir4(), ".claude", "skills"),
|
|
2811
|
+
cursor: join8(homedir4(), ".cursor", "skills"),
|
|
2812
|
+
openclaw: join8(homedir4(), ".openclaw", "workspace", "skills")
|
|
2813
|
+
};
|
|
2814
|
+
function linkSkill(app, skillsPath) {
|
|
2815
|
+
const cliDir = getCliDir(app);
|
|
2816
|
+
const skillSource = join8(cliDir, "skills", `${app}-cli`, "SKILL.md");
|
|
2817
|
+
if (!existsSync9(skillSource)) {
|
|
2818
|
+
console.log(` ${import_picocolors7.default.dim("No SKILL.md found for")} ${app}-cli${import_picocolors7.default.dim(", skipping skill link")}`);
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
const targetDir = join8(skillsPath, `${app}-cli`);
|
|
2822
|
+
mkdirSync5(targetDir, { recursive: true });
|
|
2823
|
+
const targetLink = join8(targetDir, "SKILL.md");
|
|
2824
|
+
if (existsSync9(targetLink))
|
|
2825
|
+
unlinkSync3(targetLink);
|
|
2826
|
+
symlinkSync3(skillSource, targetLink);
|
|
2827
|
+
console.log(`${import_picocolors7.default.green("+")} Skill linked ${import_picocolors7.default.bold(`${app}-cli`)} -> ${import_picocolors7.default.dim(targetLink)}`);
|
|
2828
|
+
}
|
|
2829
|
+
var linkCommand = new Command("link").description("Add a CLI to your PATH (and optionally link skills to agent directories)").argument("[app]", "CLI to link (omit with --all)").option("--all", "Link all installed CLIs").option("--openclaw", "Also symlink skill to ~/.openclaw/workspace/skills/").option("--skills-path <path>", "Custom path to symlink the skill into").addHelpText("after", `
|
|
2808
2830
|
Examples:
|
|
2809
2831
|
api2cli link typefully
|
|
2810
|
-
api2cli link --
|
|
2832
|
+
api2cli link typefully --openclaw
|
|
2833
|
+
api2cli link typefully --skills-path ~/.openclaw/workspace/skills
|
|
2834
|
+
api2cli link --all --openclaw`).action((app, opts) => {
|
|
2835
|
+
const skillsPaths = [];
|
|
2836
|
+
if (opts.openclaw)
|
|
2837
|
+
skillsPaths.push(AGENT_SKILL_DIRS.openclaw);
|
|
2838
|
+
if (opts.skillsPath)
|
|
2839
|
+
skillsPaths.push(opts.skillsPath.replace(/^~/, homedir4()));
|
|
2811
2840
|
if (opts.all || !app) {
|
|
2812
2841
|
if (!existsSync9(CLI_ROOT)) {
|
|
2813
2842
|
console.log("No CLIs installed.");
|
|
@@ -2817,6 +2846,8 @@ Examples:
|
|
|
2817
2846
|
for (const d of dirs) {
|
|
2818
2847
|
const name = d.replace(/-cli$/, "");
|
|
2819
2848
|
addToPath(name, getDistDir(name));
|
|
2849
|
+
for (const sp of skillsPaths)
|
|
2850
|
+
linkSkill(name, sp);
|
|
2820
2851
|
}
|
|
2821
2852
|
return;
|
|
2822
2853
|
}
|
|
@@ -2825,6 +2856,8 @@ Examples:
|
|
|
2825
2856
|
process.exit(1);
|
|
2826
2857
|
}
|
|
2827
2858
|
addToPath(app, getDistDir(app));
|
|
2859
|
+
for (const sp of skillsPaths)
|
|
2860
|
+
linkSkill(app, sp);
|
|
2828
2861
|
});
|
|
2829
2862
|
|
|
2830
2863
|
// src/commands/unlink.ts
|
|
@@ -2837,7 +2870,7 @@ Example:
|
|
|
2837
2870
|
// src/commands/tokens.ts
|
|
2838
2871
|
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
2839
2872
|
import { existsSync as existsSync10, readdirSync as readdirSync6, readFileSync as readFileSync4 } from "fs";
|
|
2840
|
-
import { join as
|
|
2873
|
+
import { join as join9 } from "path";
|
|
2841
2874
|
var tokensCommand = new Command("tokens").description("List all configured API tokens").option("--show", "Show full unmasked tokens").addHelpText("after", `
|
|
2842
2875
|
Examples:
|
|
2843
2876
|
api2cli tokens
|
|
@@ -2856,7 +2889,7 @@ ${import_picocolors8.default.bold("Configured tokens:")}
|
|
|
2856
2889
|
`);
|
|
2857
2890
|
for (const f of files) {
|
|
2858
2891
|
const name = f.replace(".txt", "");
|
|
2859
|
-
const token = readFileSync4(
|
|
2892
|
+
const token = readFileSync4(join9(TOKENS_DIR, f), "utf-8").trim();
|
|
2860
2893
|
const display = opts.show ? token : token.length > 8 ? `${token.slice(0, 4)}${import_picocolors8.default.dim("...")}${token.slice(-4)}` : import_picocolors8.default.dim("****");
|
|
2861
2894
|
console.log(` ${import_picocolors8.default.bold(name.padEnd(25))} ${display}`);
|
|
2862
2895
|
}
|