skissue 0.1.18 → 0.1.19

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/entry.js +120 -65
  2. package/package.json +1 -1
package/dist/entry.js CHANGED
@@ -9,7 +9,7 @@ import { resolve as resolve4 } from "node:path";
9
9
  // src/commands/init.ts
10
10
  import * as p2 from "@clack/prompts";
11
11
  import chalk2 from "chalk";
12
- import { existsSync as existsSync4 } from "node:fs";
12
+ import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
13
13
  import { mkdir as mkdir4 } from "node:fs/promises";
14
14
  import { relative, resolve as resolve3 } from "node:path";
15
15
 
@@ -367,6 +367,15 @@ function validateSkillId(raw) {
367
367
  function validateSkillIdPrompt(v) {
368
368
  return validateSkillId(String(v ?? ""));
369
369
  }
370
+ function registryDirectoryExists(root) {
371
+ const regDir = join3(root, "registry");
372
+ if (!existsSync3(regDir)) return false;
373
+ try {
374
+ return statSync2(regDir).isDirectory();
375
+ } catch {
376
+ return false;
377
+ }
378
+ }
370
379
  function registryLayoutExists(root) {
371
380
  const jsonPath = join3(root, "registry.json");
372
381
  const regDir = join3(root, "registry");
@@ -574,6 +583,59 @@ Transport: ${mode}
574
583
  Branch: ${r.branch}
575
584
  skillsRoot: ${cfg.skillsRoot}`;
576
585
  }
586
+ async function runLocalBootstrapFlow(cwd, resolvedRoot) {
587
+ const atConsumerRoot = resolvedRoot === resolve3(cwd);
588
+ if (atConsumerRoot && !registryLayoutExists(resolvedRoot)) {
589
+ const okRoot = await p2.confirm({
590
+ message: "This adds registry.json and registry/ at your project root. Continue?",
591
+ initialValue: false
592
+ });
593
+ if (p2.isCancel(okRoot) || !okRoot) {
594
+ p2.cancel("Aborted.");
595
+ return { ok: false, exitCode: 0 };
596
+ }
597
+ }
598
+ const prompted = await promptMinimalRegistryScaffold(resolvedRoot);
599
+ if (!prompted) {
600
+ p2.cancel("Aborted. No files were changed.");
601
+ return { ok: false, exitCode: 0 };
602
+ }
603
+ let result;
604
+ try {
605
+ result = await scaffoldMinimalRegistry({
606
+ root: resolvedRoot,
607
+ skillId: prompted.skillId,
608
+ runGitInit: prompted.runGitInit
609
+ });
610
+ } catch (e) {
611
+ p2.cancel(e instanceof Error ? e.message : String(e));
612
+ return { ok: false, exitCode: 1 };
613
+ }
614
+ if (!prompted.hadGit && !result.gitInitRan) {
615
+ p2.note(
616
+ "This folder is not a git repository. Run `git init` before using it as a local skissue registry.",
617
+ chalk2.yellow("Heads up")
618
+ );
619
+ }
620
+ const branchDefault = await gitBranchShowCurrent(resolvedRoot) ?? "main";
621
+ const branch = await p2.text({
622
+ message: "Branch label (stored in config; installs use git HEAD from that directory)",
623
+ initialValue: branchDefault,
624
+ validate: requiredTrimmed
625
+ });
626
+ if (p2.isCancel(branch)) {
627
+ p2.cancel("Aborted.");
628
+ return { ok: false, exitCode: 0 };
629
+ }
630
+ const cfg = ConfigSchema.parse({
631
+ registry: {
632
+ path: localRegistryPathForConfig(cwd, resolvedRoot),
633
+ branch: String(branch).trim()
634
+ },
635
+ skillsRoot: ".agents/skills"
636
+ });
637
+ return { ok: true, cfg, bootstrappedSkillId: result.skillId };
638
+ }
577
639
  async function runInit(cwd) {
578
640
  p2.intro(chalk2.bold("skissue init"));
579
641
  const existingPath = configPath(cwd);
@@ -646,23 +708,57 @@ async function runInit(cwd) {
646
708
  process.exit(0);
647
709
  }
648
710
  const resolvedExisting = resolve3(cwd, String(regPath).trim());
649
- const branchDefault = await gitBranchShowCurrent(resolvedExisting) ?? "main";
650
- const branch = await p2.text({
651
- message: "Branch label (stored in config; installs use git HEAD from that directory)",
652
- initialValue: branchDefault,
653
- validate: requiredTrimmed
654
- });
655
- if (p2.isCancel(branch)) {
656
- p2.cancel("Aborted.");
657
- process.exit(0);
711
+ if (!existsSync4(resolvedExisting) || !statSync3(resolvedExisting).isDirectory()) {
712
+ p2.cancel(`Path does not exist or is not a directory: ${resolvedExisting}`);
713
+ process.exitCode = 1;
714
+ return;
715
+ }
716
+ if (!registryDirectoryExists(resolvedExisting)) {
717
+ const pathLabel = String(regPath).trim() || ".";
718
+ const bootstrapHere = await p2.confirm({
719
+ message: `${chalk2.yellow("No registry/ directory")} at ${chalk2.cyan(pathLabel)}. Bootstrap a minimal sample registry (registry.json + registry/<skill>) here?`,
720
+ initialValue: true
721
+ });
722
+ if (p2.isCancel(bootstrapHere)) {
723
+ p2.cancel("Aborted.");
724
+ process.exit(0);
725
+ }
726
+ if (!bootstrapHere) {
727
+ p2.cancel(
728
+ "Aborted. Create a registry/ folder in that directory, or run skissue init and choose Bootstrap a minimal sample registry."
729
+ );
730
+ process.exit(0);
731
+ }
732
+ const outcome = await runLocalBootstrapFlow(cwd, resolvedExisting);
733
+ if (!outcome.ok) {
734
+ if (outcome.exitCode === 1) {
735
+ process.exitCode = 1;
736
+ } else {
737
+ process.exit(0);
738
+ }
739
+ return;
740
+ }
741
+ cfg = outcome.cfg;
742
+ bootstrappedSkillId = outcome.bootstrappedSkillId;
743
+ } else {
744
+ const branchDefault = await gitBranchShowCurrent(resolvedExisting) ?? "main";
745
+ const branch = await p2.text({
746
+ message: "Branch label (stored in config; installs use git HEAD from that directory)",
747
+ initialValue: branchDefault,
748
+ validate: requiredTrimmed
749
+ });
750
+ if (p2.isCancel(branch)) {
751
+ p2.cancel("Aborted.");
752
+ process.exit(0);
753
+ }
754
+ cfg = ConfigSchema.parse({
755
+ registry: {
756
+ path: String(regPath).trim(),
757
+ branch: String(branch).trim()
758
+ },
759
+ skillsRoot: ".agents/skills"
760
+ });
658
761
  }
659
- cfg = ConfigSchema.parse({
660
- registry: {
661
- path: String(regPath).trim(),
662
- branch: String(branch).trim()
663
- },
664
- skillsRoot: ".agents/skills"
665
- });
666
762
  } else {
667
763
  const pathRaw = await p2.text({
668
764
  message: "Path for the new registry root (relative to this project or absolute)",
@@ -675,58 +771,17 @@ async function runInit(cwd) {
675
771
  process.exit(0);
676
772
  }
677
773
  const resolvedRoot = resolve3(cwd, String(pathRaw).trim());
678
- const atConsumerRoot = resolvedRoot === resolve3(cwd);
679
- if (atConsumerRoot && !registryLayoutExists(resolvedRoot)) {
680
- const okRoot = await p2.confirm({
681
- message: "This adds registry.json and registry/ at your project root. Continue?",
682
- initialValue: false
683
- });
684
- if (p2.isCancel(okRoot) || !okRoot) {
685
- p2.cancel("Aborted.");
774
+ const outcome = await runLocalBootstrapFlow(cwd, resolvedRoot);
775
+ if (!outcome.ok) {
776
+ if (outcome.exitCode === 1) {
777
+ process.exitCode = 1;
778
+ } else {
686
779
  process.exit(0);
687
780
  }
688
- }
689
- const prompted = await promptMinimalRegistryScaffold(resolvedRoot);
690
- if (!prompted) {
691
- p2.cancel("Aborted. No files were changed.");
692
- process.exit(0);
693
- }
694
- let result;
695
- try {
696
- result = await scaffoldMinimalRegistry({
697
- root: resolvedRoot,
698
- skillId: prompted.skillId,
699
- runGitInit: prompted.runGitInit
700
- });
701
- } catch (e) {
702
- p2.cancel(e instanceof Error ? e.message : String(e));
703
- process.exitCode = 1;
704
781
  return;
705
782
  }
706
- bootstrappedSkillId = result.skillId;
707
- if (!prompted.hadGit && !result.gitInitRan) {
708
- p2.note(
709
- "This folder is not a git repository. Run `git init` before using it as a local skissue registry.",
710
- chalk2.yellow("Heads up")
711
- );
712
- }
713
- const branchDefault = await gitBranchShowCurrent(resolvedRoot) ?? "main";
714
- const branch = await p2.text({
715
- message: "Branch label (stored in config; installs use git HEAD from that directory)",
716
- initialValue: branchDefault,
717
- validate: requiredTrimmed
718
- });
719
- if (p2.isCancel(branch)) {
720
- p2.cancel("Aborted.");
721
- process.exit(0);
722
- }
723
- cfg = ConfigSchema.parse({
724
- registry: {
725
- path: localRegistryPathForConfig(cwd, resolvedRoot),
726
- branch: String(branch).trim()
727
- },
728
- skillsRoot: ".agents/skills"
729
- });
783
+ cfg = outcome.cfg;
784
+ bootstrappedSkillId = outcome.bootstrappedSkillId;
730
785
  }
731
786
  } else {
732
787
  const owner = await p2.text({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skissue",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",