skild 0.2.5 → 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 +65 -20
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -399,25 +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 = false;
404
- const prompt = `${question}: `;
405
- rl._writeToOutput = function _writeToOutput(stringToWrite) {
406
- if (this.stdoutMuted) {
407
- if (stringToWrite === "\n" || stringToWrite === "\r\n") this.output.write(stringToWrite);
408
- return;
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();
409
418
  }
410
- this.output.write(stringToWrite);
411
- };
412
- try {
413
- const answerPromise = new Promise((resolve) => rl.question(prompt, resolve));
414
- rl.stdoutMuted = true;
415
- const answer = await answerPromise;
416
- return String(answer || "");
417
- } finally {
418
- rl.stdoutMuted = false;
419
- rl.close();
420
- }
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
+ });
421
444
  }
422
445
 
423
446
  // src/commands/signup.ts
@@ -434,7 +457,18 @@ async function signup(options) {
434
457
  }
435
458
  const finalEmail = email || await promptLine("Email");
436
459
  const finalHandle = handle || (await promptLine("Handle (publisher scope)", void 0)).toLowerCase();
437
- 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
+ }
438
472
  let text = "";
439
473
  try {
440
474
  const res = await fetchWithTimeout2(
@@ -501,7 +535,18 @@ async function login(options) {
501
535
  return;
502
536
  }
503
537
  const finalHandleOrEmail = handleOrEmail || await promptLine("Handle or email");
504
- 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
+ }
505
550
  const finalTokenName = options.tokenName?.trim() || void 0;
506
551
  let text = "";
507
552
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skild",
3
- "version": "0.2.5",
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.5"
40
+ "@skild/core": "^0.2.6"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^20.10.0",