@skillport/cli 0.1.1 → 0.1.2
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 +30 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2496,6 +2496,16 @@ import { createServer } from "node:http";
|
|
|
2496
2496
|
import { randomBytes } from "node:crypto";
|
|
2497
2497
|
import chalk9 from "chalk";
|
|
2498
2498
|
import inquirer4 from "inquirer";
|
|
2499
|
+
function listenOnPort(server, port) {
|
|
2500
|
+
return new Promise((resolve, reject) => {
|
|
2501
|
+
server.once("error", reject);
|
|
2502
|
+
server.listen(port, () => {
|
|
2503
|
+
server.removeListener("error", reject);
|
|
2504
|
+
const addr = server.address();
|
|
2505
|
+
resolve(addr.port);
|
|
2506
|
+
});
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2499
2509
|
async function loginCommand(options) {
|
|
2500
2510
|
const config = loadConfig();
|
|
2501
2511
|
console.log(chalk9.bold("SkillPort Market Login"));
|
|
@@ -2533,8 +2543,22 @@ async function loginCommand(options) {
|
|
|
2533
2543
|
return;
|
|
2534
2544
|
}
|
|
2535
2545
|
const state = randomBytes(16).toString("hex");
|
|
2536
|
-
const
|
|
2537
|
-
const
|
|
2546
|
+
const requestedPort = options.port !== void 0 ? parseInt(options.port, 10) : 9876;
|
|
2547
|
+
const userExplicitPort = options.port !== void 0;
|
|
2548
|
+
const server = createServer();
|
|
2549
|
+
let actualPort;
|
|
2550
|
+
try {
|
|
2551
|
+
actualPort = await listenOnPort(server, requestedPort);
|
|
2552
|
+
} catch (err) {
|
|
2553
|
+
const code = err.code;
|
|
2554
|
+
if (code === "EADDRINUSE" && !userExplicitPort) {
|
|
2555
|
+
console.log(chalk9.yellow(`Port ${requestedPort} in use, selecting a free port...`));
|
|
2556
|
+
actualPort = await listenOnPort(server, 0);
|
|
2557
|
+
} else {
|
|
2558
|
+
throw err;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
const authUrl = `${config.marketplace_url}/auth/cli?state=${state}&port=${actualPort}`;
|
|
2538
2562
|
if (options.browser === false) {
|
|
2539
2563
|
console.log(chalk9.bold("Open this URL in your browser to authenticate:"));
|
|
2540
2564
|
console.log();
|
|
@@ -2553,8 +2577,8 @@ async function loginCommand(options) {
|
|
|
2553
2577
|
server.close();
|
|
2554
2578
|
reject(new Error("Authentication timed out (60s). Try again or use: skillport login --method token --token <your-token>"));
|
|
2555
2579
|
}, 6e4);
|
|
2556
|
-
|
|
2557
|
-
const url = new URL(req.url || "", `http://localhost:${
|
|
2580
|
+
server.on("request", (req, res) => {
|
|
2581
|
+
const url = new URL(req.url || "", `http://localhost:${actualPort}`);
|
|
2558
2582
|
if (url.pathname === "/callback") {
|
|
2559
2583
|
const callbackState = url.searchParams.get("state");
|
|
2560
2584
|
const accessToken = url.searchParams.get("token");
|
|
@@ -2575,7 +2599,6 @@ async function loginCommand(options) {
|
|
|
2575
2599
|
resolve(accessToken);
|
|
2576
2600
|
}
|
|
2577
2601
|
});
|
|
2578
|
-
server.listen(port);
|
|
2579
2602
|
});
|
|
2580
2603
|
try {
|
|
2581
2604
|
const response = await fetch(`${config.marketplace_url}/v1/auth/cli-token`, {
|
|
@@ -2697,7 +2720,7 @@ async function publishCommand(sspPath) {
|
|
|
2697
2720
|
|
|
2698
2721
|
// src/index.ts
|
|
2699
2722
|
var program = new Command();
|
|
2700
|
-
program.name("skillport").description("SkillPort \u2014 secure skill distribution for OpenClaw").version("0.1.
|
|
2723
|
+
program.name("skillport").description("SkillPort \u2014 secure skill distribution for OpenClaw").version("0.1.2");
|
|
2701
2724
|
program.command("init").description("Generate Ed25519 key pair for signing").action(initCommand);
|
|
2702
2725
|
program.command("scan <path>").description("Run security scan on a skill directory or .ssp file").action(scanCommand);
|
|
2703
2726
|
program.command("export <path>").description("Export a skill directory as a SkillPort package (.ssp)").option("-o, --output <file>", "Output file path").option("-y, --yes", "Non-interactive mode (include all, skip prompts)").option("--id <id>", "Skill ID (author-slug/skill-slug)").option("--name <name>", "Skill name").option("--description <desc>", "Skill description").option("--skill-version <ver>", "Skill version (semver)").option("--author <name>", "Author name").option("--openclaw-compat <range>", "OpenClaw compatibility range").option("--os <os...>", "Compatible OS (macos, linux, windows)").action(exportCommand);
|
|
@@ -2706,6 +2729,6 @@ program.command("verify <ssp>").description("Verify SkillPort package signatures
|
|
|
2706
2729
|
program.command("install <target>").description("Install a SkillPort package").option("--accept-risk", "Accept high-risk permissions (shell, critical flags)").option("-y, --yes", "Non-interactive mode (auto-approve, use defaults)").action(installCommand);
|
|
2707
2730
|
program.command("dry-run <ssp>").description("Run installation diagnostics without installing").action(dryRunCommand);
|
|
2708
2731
|
program.command("uninstall <id>").description("Uninstall an installed skill").action(uninstallCommand);
|
|
2709
|
-
program.command("login").description("Authenticate with SkillPort Market").option("--method <method>", "Login method: browser or token", "browser").option("--token <token>", "API token (for --method token)").option("-y, --yes", "Non-interactive mode (skip prompts)").option("--no-browser", "Print auth URL instead of opening browser").action(loginCommand);
|
|
2732
|
+
program.command("login").description("Authenticate with SkillPort Market").option("--method <method>", "Login method: browser or token", "browser").option("--token <token>", "API token (for --method token)").option("-y, --yes", "Non-interactive mode (skip prompts)").option("--no-browser", "Print auth URL instead of opening browser").option("--port <port>", "Callback port (default: 9876, use 0 for auto)").action(loginCommand);
|
|
2710
2733
|
program.command("publish <ssp>").description("Publish a SkillPort package to the marketplace").action(publishCommand);
|
|
2711
2734
|
program.parse();
|
package/package.json
CHANGED