plugins 1.2.10-canary.1 → 1.2.10-canary.3
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 +20 -104
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -725,75 +725,15 @@ async function stageInstallWorkspace(plugins, repoPath, targetId, stagingBaseDir
|
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
727
|
async function installToClaudeCode(plugins, scope, repoPath, source) {
|
|
728
|
-
|
|
729
|
-
step("Preparing plugins for Claude Code...");
|
|
730
|
-
barEmpty();
|
|
731
|
-
await prepareForClaudeCode(plugins, repoPath, marketplaceName);
|
|
732
|
-
const marketplaceSource = isAnthropicSource(source) ? normalizeGitUrl(source) : repoPath;
|
|
733
|
-
const claudePath = findClaude();
|
|
734
|
-
step("Adding marketplace");
|
|
735
|
-
barDebug(c.dim(`Binary: ${claudePath}`));
|
|
736
|
-
try {
|
|
737
|
-
const version = execSync2(`${claudePath} --version`, { encoding: "utf-8", stdio: "pipe" }).trim();
|
|
738
|
-
barDebug(c.dim(`Version: ${version}`));
|
|
739
|
-
} catch {
|
|
740
|
-
barDebug(c.dim(`Warning: could not get claude version`));
|
|
741
|
-
}
|
|
742
|
-
try {
|
|
743
|
-
const result = execSync2(`${claudePath} plugin marketplace add ${marketplaceSource}`, {
|
|
744
|
-
encoding: "utf-8",
|
|
745
|
-
stdio: "pipe"
|
|
746
|
-
});
|
|
747
|
-
if (result.trim()) barDebug(c.dim(result.trim()));
|
|
748
|
-
stepDone("Marketplace added");
|
|
749
|
-
} catch (err) {
|
|
750
|
-
const stderr = err.stderr?.toString().trim() ?? "";
|
|
751
|
-
const stdout = err.stdout?.toString().trim() ?? "";
|
|
752
|
-
if (stderr.includes("already") || stdout.includes("already")) {
|
|
753
|
-
stepDone(`Marketplace ${c.dim("'" + marketplaceName + "'")} already on disk`);
|
|
754
|
-
} else {
|
|
755
|
-
stepError("Failed to add marketplace.");
|
|
756
|
-
barLine(c.dim(`Command: ${claudePath} plugin marketplace add ${marketplaceSource}`));
|
|
757
|
-
if (stdout) barLine(c.dim(`stdout: ${stdout}`));
|
|
758
|
-
if (stderr) barLine(c.dim(`stderr: ${stderr}`));
|
|
759
|
-
barLine(c.dim(`exit code: ${err.status}`));
|
|
760
|
-
process.exit(1);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
barEmpty();
|
|
764
|
-
for (const plugin of plugins) {
|
|
765
|
-
const pluginRef = `${plugin.name}@${marketplaceName}`;
|
|
766
|
-
step(`Installing ${c.bold(pluginRef)}...`);
|
|
767
|
-
try {
|
|
768
|
-
execSync2(`${claudePath} plugin install ${pluginRef} --scope ${scope}`, {
|
|
769
|
-
encoding: "utf-8",
|
|
770
|
-
stdio: "pipe"
|
|
771
|
-
});
|
|
772
|
-
stepDone(`Installed ${c.cyan(pluginRef)}`);
|
|
773
|
-
} catch (err) {
|
|
774
|
-
const stderr = err.stderr?.toString().trim() ?? "";
|
|
775
|
-
const stdout = err.stdout?.toString().trim() ?? "";
|
|
776
|
-
if (stderr.includes("already") || stdout.includes("already")) {
|
|
777
|
-
stepDone(`${c.cyan(pluginRef)} ${c.dim("already installed")}`);
|
|
778
|
-
} else {
|
|
779
|
-
stepError(`Failed to install ${pluginRef}`);
|
|
780
|
-
barLine(c.dim(`Command: ${claudePath} plugin install ${pluginRef} --scope ${scope}`));
|
|
781
|
-
if (stdout) barLine(c.dim(`stdout: ${stdout}`));
|
|
782
|
-
if (stderr) barLine(c.dim(`stderr: ${stderr}`));
|
|
783
|
-
barLine(c.dim(`exit code: ${err.status}`));
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
cachePopulated = true;
|
|
728
|
+
await installToPluginCache(plugins, scope, repoPath, source);
|
|
788
729
|
}
|
|
789
730
|
async function installToCursor(plugins, scope, repoPath, source) {
|
|
790
731
|
if (cachePopulated) return;
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
await installToClaudeCode(plugins, scope, repoPath, source);
|
|
732
|
+
if (process.platform === "win32") {
|
|
733
|
+
await installToCursorExtensions(plugins, scope, repoPath, source);
|
|
794
734
|
return;
|
|
795
735
|
}
|
|
796
|
-
await
|
|
736
|
+
await installToPluginCache(plugins, scope, repoPath, source);
|
|
797
737
|
}
|
|
798
738
|
async function installToPluginCache(plugins, scope, repoPath, source) {
|
|
799
739
|
const marketplaceName = plugins[0]?.marketplace ?? deriveMarketplaceName(source);
|
|
@@ -862,13 +802,25 @@ async function installToPluginCache(plugins, scope, repoPath, source) {
|
|
|
862
802
|
}
|
|
863
803
|
await writeFile(installedPath, JSON.stringify(installedData, null, 2));
|
|
864
804
|
barDebug(c.dim("Updated installed_plugins.json"));
|
|
805
|
+
const settingsPath = join3(home, ".claude", "settings.json");
|
|
806
|
+
let settings = {};
|
|
807
|
+
if (existsSync2(settingsPath)) {
|
|
808
|
+
try {
|
|
809
|
+
settings = JSON.parse(await readFile2(settingsPath, "utf-8"));
|
|
810
|
+
} catch {
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
const enabled = settings.enabledPlugins ?? {};
|
|
814
|
+
for (const plugin of plugins) {
|
|
815
|
+
const pluginKey = `${plugin.name}@${marketplaceName}`;
|
|
816
|
+
enabled[pluginKey] = true;
|
|
817
|
+
}
|
|
818
|
+
settings.enabledPlugins = enabled;
|
|
819
|
+
await writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
820
|
+
barDebug(c.dim("Updated settings.json enabledPlugins"));
|
|
865
821
|
cachePopulated = true;
|
|
866
822
|
}
|
|
867
823
|
async function installToCursorExtensions(plugins, scope, repoPath, source) {
|
|
868
|
-
if (process.platform !== "win32") {
|
|
869
|
-
await installToPluginCache(plugins, scope, repoPath, source);
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
824
|
const marketplaceName = plugins[0]?.marketplace ?? deriveMarketplaceName(source);
|
|
873
825
|
const home = homedir2();
|
|
874
826
|
const extensionsDir = join3(home, ".cursor", "extensions");
|
|
@@ -1096,26 +1048,6 @@ async function prepareForClaudeCode(plugins, repoPath, marketplaceName) {
|
|
|
1096
1048
|
await preparePluginDirForVendor(plugin, ".claude-plugin", "CLAUDE_PLUGIN_ROOT");
|
|
1097
1049
|
}
|
|
1098
1050
|
}
|
|
1099
|
-
function findClaudeOrNull() {
|
|
1100
|
-
try {
|
|
1101
|
-
const path = execSync2("which claude", { encoding: "utf-8", stdio: "pipe" }).trim();
|
|
1102
|
-
if (path) return path;
|
|
1103
|
-
} catch {
|
|
1104
|
-
}
|
|
1105
|
-
const home = homedir2();
|
|
1106
|
-
const candidates = [
|
|
1107
|
-
join3(home, ".local", "bin", "claude"),
|
|
1108
|
-
join3(home, ".bun", "bin", "claude"),
|
|
1109
|
-
"/usr/local/bin/claude"
|
|
1110
|
-
];
|
|
1111
|
-
for (const candidate of candidates) {
|
|
1112
|
-
if (existsSync2(candidate)) return candidate;
|
|
1113
|
-
}
|
|
1114
|
-
return null;
|
|
1115
|
-
}
|
|
1116
|
-
function findClaude() {
|
|
1117
|
-
return findClaudeOrNull() ?? "claude";
|
|
1118
|
-
}
|
|
1119
1051
|
async function preparePluginDirForVendor(plugin, vendorDir, envVar) {
|
|
1120
1052
|
const pluginPath = plugin.path;
|
|
1121
1053
|
const openPluginDir = join3(pluginPath, ".plugin");
|
|
@@ -1198,22 +1130,6 @@ function deriveMarketplaceName(source) {
|
|
|
1198
1130
|
const parts = source.replace(/\/$/, "").split("/");
|
|
1199
1131
|
return parts[parts.length - 1] ?? "plugins";
|
|
1200
1132
|
}
|
|
1201
|
-
function isAnthropicSource(source) {
|
|
1202
|
-
if (source.match(/^anthropics\/[\w.-]+$/)) return true;
|
|
1203
|
-
if (source.startsWith("https://github.com/anthropics/")) return true;
|
|
1204
|
-
if (source.startsWith("git@github.com:anthropics/")) return true;
|
|
1205
|
-
return false;
|
|
1206
|
-
}
|
|
1207
|
-
function normalizeGitUrl(source) {
|
|
1208
|
-
if (source.match(/^[\w-]+\/[\w.-]+$/)) {
|
|
1209
|
-
return `https://github.com/${source}`;
|
|
1210
|
-
}
|
|
1211
|
-
const sshMatch = source.match(/^git@([^:]+):(.+?)(?:\.git)?$/);
|
|
1212
|
-
if (sshMatch) {
|
|
1213
|
-
return `https://${sshMatch[1]}/${sshMatch[2]}`;
|
|
1214
|
-
}
|
|
1215
|
-
return source;
|
|
1216
|
-
}
|
|
1217
1133
|
|
|
1218
1134
|
// lib/telemetry.ts
|
|
1219
1135
|
var TELEMETRY_URL = "https://plugins-telemetry.labs.vercel.dev/t";
|