vibe-cokit 1.0.1 → 1.2.0

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/cli.js +167 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -606,14 +606,19 @@ var dist_default = cac;
606
606
  var version = "0.1.0";
607
607
 
608
608
  // src/commands/init.ts
609
+ import { join as join2 } from "path";
610
+
611
+ // src/utils/config.ts
609
612
  import { homedir } from "os";
610
613
  import { join } from "path";
611
- import { mkdir, cp, rm, stat } from "fs/promises";
614
+ import { mkdir, cp, rm, stat, readdir } from "fs/promises";
612
615
  import { execFile } from "child_process";
613
616
  import { promisify } from "util";
614
617
  var exec = promisify(execFile);
615
618
  var REPO = "vibe-cokit/claude-code";
619
+ var SKILLS_REPO = "vibe-cokit/skills";
616
620
  var CLAUDE_DIR = join(homedir(), ".claude");
621
+ var SKILLS_DIR = join(CLAUDE_DIR, "skills");
617
622
  var CONFIG_FOLDERS = ["agents", "commands", "hooks", "prompts", "workflows"];
618
623
  var TEMP_DIR = join(homedir(), ".vibe-cokit-tmp");
619
624
  function log(step) {
@@ -626,9 +631,9 @@ async function verifyPrerequisites() {
626
631
  throw new Error("gh CLI not found. Install: https://cli.github.com");
627
632
  }
628
633
  }
629
- async function cloneRepo(tmpDir) {
634
+ async function cloneRepo(tmpDir, repo = REPO) {
630
635
  try {
631
- await exec("gh", ["repo", "clone", REPO, tmpDir]);
636
+ await exec("gh", ["repo", "clone", repo, tmpDir]);
632
637
  } catch (err) {
633
638
  const msg = err instanceof Error ? err.message : String(err);
634
639
  throw new Error(`Failed to clone repo: ${msg}`);
@@ -696,8 +701,58 @@ async function cleanup(tmpDir) {
696
701
  await rm(tmpDir, { recursive: true, force: true });
697
702
  } catch {}
698
703
  }
704
+ async function getCurrentVersion() {
705
+ const settingsPath = join(CLAUDE_DIR, "settings.json");
706
+ const file = Bun.file(settingsPath);
707
+ if (await file.exists()) {
708
+ const settings = await file.json();
709
+ return settings.version ?? null;
710
+ }
711
+ return null;
712
+ }
713
+ async function getRemoteSha(ref, repo = REPO) {
714
+ const target = ref ?? "HEAD";
715
+ const { stdout } = await exec("git", ["ls-remote", `https://github.com/${repo}.git`, target]);
716
+ const sha = stdout.trim().split("\t")[0];
717
+ if (!sha)
718
+ throw new Error(`Could not resolve ref: ${target}`);
719
+ return sha;
720
+ }
721
+ async function copySkillFolders(srcDir) {
722
+ await mkdir(SKILLS_DIR, { recursive: true });
723
+ const entries = await readdir(srcDir, { withFileTypes: true });
724
+ for (const entry of entries) {
725
+ if (entry.isDirectory() && !entry.name.startsWith(".")) {
726
+ const src = join(srcDir, entry.name);
727
+ const dest = join(SKILLS_DIR, entry.name);
728
+ await cp(src, dest, { recursive: true, force: true });
729
+ log(`Copied skill: ${entry.name}/`);
730
+ }
731
+ }
732
+ }
733
+ async function updateSkillsVersion(commitSha) {
734
+ const settingsPath = join(CLAUDE_DIR, "settings.json");
735
+ let settings = {};
736
+ const file = Bun.file(settingsPath);
737
+ if (await file.exists()) {
738
+ settings = await file.json();
739
+ }
740
+ settings.skillsVersion = commitSha;
741
+ await Bun.write(settingsPath, JSON.stringify(settings, null, 2));
742
+ }
743
+ async function getSkillsVersion() {
744
+ const settingsPath = join(CLAUDE_DIR, "settings.json");
745
+ const file = Bun.file(settingsPath);
746
+ if (await file.exists()) {
747
+ const settings = await file.json();
748
+ return settings.skillsVersion ?? null;
749
+ }
750
+ return null;
751
+ }
752
+
753
+ // src/commands/init.ts
699
754
  async function initCommand() {
700
- const tmpDir = join(TEMP_DIR, crypto.randomUUID());
755
+ const tmpDir = join2(TEMP_DIR, crypto.randomUUID());
701
756
  try {
702
757
  console.log(`
703
758
  vibe-cokit init
@@ -733,12 +788,120 @@ vibe-cokit init
733
788
  }
734
789
  }
735
790
 
791
+ // src/commands/update.ts
792
+ import { join as join3 } from "path";
793
+ import { execFile as execFile2 } from "child_process";
794
+ import { promisify as promisify2 } from "util";
795
+ var exec2 = promisify2(execFile2);
796
+ async function updateCommand(ref) {
797
+ const tmpDir = join3(TEMP_DIR, crypto.randomUUID());
798
+ try {
799
+ console.log(`
800
+ vibe-cokit update
801
+ `);
802
+ log("Verifying prerequisites...");
803
+ await verifyPrerequisites();
804
+ log("Checking current version...");
805
+ const currentSha = await getCurrentVersion();
806
+ log("Fetching latest version info...");
807
+ const targetSha = await getRemoteSha(ref);
808
+ if (currentSha && currentSha === targetSha) {
809
+ console.log(`
810
+ \u2713 Already up-to-date (${currentSha.slice(0, 8)})
811
+ `);
812
+ return;
813
+ }
814
+ log("Cloning vibe-cokit configuration...");
815
+ await cloneRepo(tmpDir);
816
+ if (ref) {
817
+ log(`Checking out ${ref}...`);
818
+ await exec2("git", ["-C", tmpDir, "checkout", ref]);
819
+ }
820
+ log("Updating config folders in ~/.claude/");
821
+ await copyConfigFolders(tmpDir);
822
+ log("Updating version tracking...");
823
+ const sha = await getCommitSha(tmpDir);
824
+ await updateSettings(sha);
825
+ log("Cleaning up...");
826
+ await cleanup(tmpDir);
827
+ const from = currentSha ? currentSha.slice(0, 8) : "none";
828
+ console.log(`
829
+ \u2713 vibe-cokit updated successfully!`);
830
+ console.log(` From: ${from}`);
831
+ console.log(` To: ${sha.slice(0, 8)}`);
832
+ console.log(` Config: ~/.claude/
833
+ `);
834
+ } catch (err) {
835
+ await cleanup(tmpDir);
836
+ const msg = err instanceof Error ? err.message : String(err);
837
+ console.error(`
838
+ \u2717 Update failed: ${msg}
839
+ `);
840
+ process.exit(1);
841
+ }
842
+ }
843
+
844
+ // src/commands/skills.ts
845
+ import { join as join4 } from "path";
846
+ import { execFile as execFile3 } from "child_process";
847
+ import { promisify as promisify3 } from "util";
848
+ var exec3 = promisify3(execFile3);
849
+ async function skillsCommand(ref) {
850
+ const tmpDir = join4(TEMP_DIR, crypto.randomUUID());
851
+ try {
852
+ console.log(`
853
+ vibe-cokit skills
854
+ `);
855
+ log("Verifying prerequisites...");
856
+ await verifyPrerequisites();
857
+ log("Checking current skills version...");
858
+ const currentSha = await getSkillsVersion();
859
+ log("Fetching latest skills version...");
860
+ const targetSha = await getRemoteSha(ref, SKILLS_REPO);
861
+ if (currentSha && currentSha === targetSha) {
862
+ console.log(`
863
+ \u2713 Skills already up-to-date (${currentSha.slice(0, 8)})
864
+ `);
865
+ return;
866
+ }
867
+ log("Cloning skills repository...");
868
+ await cloneRepo(tmpDir, SKILLS_REPO);
869
+ if (ref) {
870
+ log(`Checking out ${ref}...`);
871
+ await exec3("git", ["-C", tmpDir, "checkout", ref]);
872
+ }
873
+ log("Copying skills to ~/.claude/skills/");
874
+ await copySkillFolders(tmpDir);
875
+ log("Updating skills version...");
876
+ const sha = await getCommitSha(tmpDir);
877
+ await updateSkillsVersion(sha);
878
+ log("Cleaning up...");
879
+ await cleanup(tmpDir);
880
+ const from = currentSha ? currentSha.slice(0, 8) : "none";
881
+ console.log(`
882
+ \u2713 Skills installed successfully!`);
883
+ console.log(` From: ${from}`);
884
+ console.log(` To: ${sha.slice(0, 8)}`);
885
+ console.log(` Skills: ~/.claude/skills/
886
+ `);
887
+ } catch (err) {
888
+ await cleanup(tmpDir);
889
+ const msg = err instanceof Error ? err.message : String(err);
890
+ console.error(`
891
+ \u2717 Skills setup failed: ${msg}
892
+ `);
893
+ process.exit(1);
894
+ }
895
+ }
896
+
736
897
  // src/cli.ts
737
898
  var cli = dist_default("vibe-cokit");
738
899
  cli.command("", "A toolkit for interacting with Claude Code").action(() => {
739
900
  cli.outputHelp();
740
901
  });
741
902
  cli.command("init", "Initialize vibe-cokit for current project").action(initCommand);
903
+ cli.command("update [ref]", "Update vibe-cokit to latest or specific version").alias("upgrade").action(updateCommand);
904
+ cli.command("skills [ref]", "Install or update skills from vibe-cokit").action(skillsCommand);
742
905
  cli.help();
743
906
  cli.version(version);
744
907
  cli.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-cokit",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "A toolkit for interacting with Claude Code",
5
5
  "module": "index.ts",
6
6
  "type": "module",