skild 0.2.4 → 0.2.6

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.
Files changed (2) hide show
  1. package/dist/index.js +66 -16
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -399,20 +399,48 @@ async function promptLine(question, defaultValue) {
399
399
  }
400
400
  }
401
401
  async function promptPassword(question) {
402
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true });
403
- rl.stdoutMuted = true;
404
- rl._writeToOutput = function _writeToOutput(stringToWrite) {
405
- if (this.stdoutMuted) return;
406
- this.output.write(stringToWrite);
407
- };
408
- try {
409
- const answer = await new Promise((resolve) => rl.question(`${question}: `, resolve));
410
- return String(answer || "");
411
- } finally {
412
- rl.stdoutMuted = false;
413
- rl.close();
414
- process.stdout.write("\n");
415
- }
402
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
403
+ return promptLine(question);
404
+ }
405
+ const stdin = process.stdin;
406
+ const stdout = process.stdout;
407
+ stdout.write(`${question}: `);
408
+ const wasRaw = Boolean(stdin.isRaw);
409
+ stdin.setRawMode(true);
410
+ stdin.resume();
411
+ readline.emitKeypressEvents(stdin);
412
+ const buf = [];
413
+ return await new Promise((resolve, reject) => {
414
+ function cleanup() {
415
+ stdin.off("keypress", onKeypress);
416
+ stdin.setRawMode(wasRaw);
417
+ stdin.pause();
418
+ }
419
+ function onKeypress(str, key) {
420
+ if (key?.ctrl && key?.name === "c") {
421
+ stdout.write("\n");
422
+ cleanup();
423
+ const err = new Error("Prompt cancelled");
424
+ err.code = "PROMPT_CANCELLED";
425
+ reject(err);
426
+ return;
427
+ }
428
+ if (key?.name === "return" || key?.name === "enter") {
429
+ stdout.write("\n");
430
+ cleanup();
431
+ resolve(buf.join(""));
432
+ return;
433
+ }
434
+ if (key?.name === "backspace" || key?.name === "delete") {
435
+ if (buf.length) buf.pop();
436
+ return;
437
+ }
438
+ if (!str) return;
439
+ if (key?.ctrl || key?.meta) return;
440
+ buf.push(str);
441
+ }
442
+ stdin.on("keypress", onKeypress);
443
+ });
416
444
  }
417
445
 
418
446
  // src/commands/signup.ts
@@ -429,7 +457,18 @@ async function signup(options) {
429
457
  }
430
458
  const finalEmail = email || await promptLine("Email");
431
459
  const finalHandle = handle || (await promptLine("Handle (publisher scope)", void 0)).toLowerCase();
432
- const finalPassword = password || await promptPassword("Password");
460
+ let finalPassword = password;
461
+ if (!finalPassword) {
462
+ try {
463
+ finalPassword = await promptPassword("Password");
464
+ } catch (e) {
465
+ if (e?.code === "PROMPT_CANCELLED") {
466
+ process.exitCode = 130;
467
+ return;
468
+ }
469
+ throw e;
470
+ }
471
+ }
433
472
  let text = "";
434
473
  try {
435
474
  const res = await fetchWithTimeout2(
@@ -496,7 +535,18 @@ async function login(options) {
496
535
  return;
497
536
  }
498
537
  const finalHandleOrEmail = handleOrEmail || await promptLine("Handle or email");
499
- const finalPassword = password || await promptPassword("Password");
538
+ let finalPassword = password;
539
+ if (!finalPassword) {
540
+ try {
541
+ finalPassword = await promptPassword("Password");
542
+ } catch (e) {
543
+ if (e?.code === "PROMPT_CANCELLED") {
544
+ process.exitCode = 130;
545
+ return;
546
+ }
547
+ throw e;
548
+ }
549
+ }
500
550
  const finalTokenName = options.tokenName?.trim() || void 0;
501
551
  let text = "";
502
552
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skild",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "The npm for Agent Skills — Discover, install, manage, and publish AI Agent Skills with ease.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "commander": "^12.1.0",
38
38
  "ora": "^8.0.1",
39
39
  "tar": "^7.4.3",
40
- "@skild/core": "^0.2.4"
40
+ "@skild/core": "^0.2.6"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^20.10.0",