@smicolon/ai-kit 0.4.0 → 0.4.1
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 +52 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -744,7 +744,58 @@ var initCommand = new Command("init").description("Interactive first-time setup"
|
|
|
744
744
|
return;
|
|
745
745
|
}
|
|
746
746
|
if (action === "add") {
|
|
747
|
-
p.
|
|
747
|
+
const s2 = p.spinner();
|
|
748
|
+
let packs2;
|
|
749
|
+
try {
|
|
750
|
+
s2.start("Fetching available packs...");
|
|
751
|
+
packs2 = await discoverPacks(getRegistryOptions());
|
|
752
|
+
s2.stop("Packs loaded.");
|
|
753
|
+
} catch {
|
|
754
|
+
s2.stop("Failed.");
|
|
755
|
+
p.log.error("Could not fetch packs.");
|
|
756
|
+
p.outro("Failed.");
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
const installedNames = Object.keys(existing.packs);
|
|
760
|
+
const available = packs2.filter((pk) => !installedNames.includes(pk.name));
|
|
761
|
+
if (available.length === 0) {
|
|
762
|
+
p.outro("All packs are already installed!");
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
const packSelection2 = await p.autocompleteMultiselect({
|
|
766
|
+
message: "Which packs do you want to add? (type to filter)",
|
|
767
|
+
options: available.map((pk) => ({
|
|
768
|
+
value: pk.name,
|
|
769
|
+
label: pk.name,
|
|
770
|
+
hint: pk.description
|
|
771
|
+
})),
|
|
772
|
+
required: true
|
|
773
|
+
});
|
|
774
|
+
if (p.isCancel(packSelection2)) {
|
|
775
|
+
p.outro("Cancelled.");
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const selectedNames = packSelection2;
|
|
779
|
+
const installSpinner2 = p.spinner();
|
|
780
|
+
installSpinner2.start("Installing packs...");
|
|
781
|
+
let config2 = existing;
|
|
782
|
+
const selectedPacks2 = packs2.filter((pk) => selectedNames.includes(pk.name));
|
|
783
|
+
for (const pack of selectedPacks2) {
|
|
784
|
+
const result = installPack({
|
|
785
|
+
pack,
|
|
786
|
+
tools: existing.tools,
|
|
787
|
+
projectDir
|
|
788
|
+
});
|
|
789
|
+
config2 = mergeInstall(config2, result);
|
|
790
|
+
config2.packs[pack.name].version = pack.version;
|
|
791
|
+
}
|
|
792
|
+
writeConfig(projectDir, config2);
|
|
793
|
+
updateGitignore(projectDir);
|
|
794
|
+
installSpinner2.stop("Done!");
|
|
795
|
+
for (const pack of selectedPacks2) {
|
|
796
|
+
p.log.message(` ${pc.green("+")} ${pack.name} ${pc.dim(`v${pack.version}`)}`);
|
|
797
|
+
}
|
|
798
|
+
p.outro(`Added ${selectedPacks2.length} pack(s).`);
|
|
748
799
|
return;
|
|
749
800
|
}
|
|
750
801
|
}
|