plugins 1.2.7 → 1.2.10-canary.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/index.js +39 -10
  2. package/package.json +4 -2
package/dist/index.js CHANGED
@@ -380,10 +380,11 @@ function detectBinary(name) {
380
380
 
381
381
  // lib/install.ts
382
382
  import { join as join3, relative } from "path";
383
- import { mkdir, cp, readFile as readFile2, writeFile } from "fs/promises";
383
+ import { mkdir, cp, readFile as readFile2, writeFile, rm } from "fs/promises";
384
384
  import { existsSync as existsSync2 } from "fs";
385
385
  import { execSync as execSync2 } from "child_process";
386
386
  import { homedir as homedir2 } from "os";
387
+ import { createHash } from "crypto";
387
388
 
388
389
  // lib/ui.ts
389
390
  var isColorSupported = process.env.FORCE_COLOR !== "0" && !process.env.NO_COLOR && (process.env.FORCE_COLOR !== void 0 || process.stdout.isTTY);
@@ -684,19 +685,45 @@ function banner() {
684
685
  var cachePopulated = false;
685
686
  async function installPlugins(plugins, target, scope, repoPath, source) {
686
687
  switch (target.id) {
687
- case "claude-code":
688
- await installToClaudeCode(plugins, scope, repoPath, source);
688
+ case "claude-code": {
689
+ const workspace = await stageInstallWorkspace(plugins, repoPath, target.id);
690
+ await installToClaudeCode(workspace.plugins, scope, workspace.repoPath, source);
689
691
  break;
690
- case "cursor":
691
- await installToCursor(plugins, scope, repoPath, source);
692
+ }
693
+ case "cursor": {
694
+ if (cachePopulated) return;
695
+ const workspace = await stageInstallWorkspace(plugins, repoPath, target.id);
696
+ await installToCursor(workspace.plugins, scope, workspace.repoPath, source);
692
697
  break;
693
- case "codex":
694
- await installToCodex(plugins, scope, repoPath, source);
698
+ }
699
+ case "codex": {
700
+ const workspace = await stageInstallWorkspace(plugins, repoPath, target.id);
701
+ await installToCodex(workspace.plugins, scope, workspace.repoPath, source);
695
702
  break;
703
+ }
696
704
  default:
697
705
  throw new Error(`Unsupported target: ${target.id}`);
698
706
  }
699
707
  }
708
+ async function stageInstallWorkspace(plugins, repoPath, targetId, stagingBaseDir = join3(homedir2(), ".cache", "plugins", ".install-staging")) {
709
+ const stageKey = createHash("sha1").update(repoPath).digest("hex");
710
+ const stageRoot = join3(stagingBaseDir, stageKey, targetId);
711
+ const stagedRepoPath = join3(stageRoot, "repo");
712
+ await mkdir(stageRoot, { recursive: true });
713
+ await rm(stagedRepoPath, { recursive: true, force: true });
714
+ await cp(repoPath, stagedRepoPath, { recursive: true });
715
+ const stagedPlugins = plugins.map((plugin) => {
716
+ const relPath = relative(repoPath, plugin.path);
717
+ return {
718
+ ...plugin,
719
+ path: relPath === "" ? stagedRepoPath : join3(stagedRepoPath, relPath)
720
+ };
721
+ });
722
+ return {
723
+ repoPath: stagedRepoPath,
724
+ plugins: stagedPlugins
725
+ };
726
+ }
700
727
  async function installToClaudeCode(plugins, scope, repoPath, source) {
701
728
  const marketplaceName = plugins[0]?.marketplace ?? deriveMarketplaceName(source);
702
729
  step("Preparing plugins for Claude Code...");
@@ -814,8 +841,9 @@ async function installToPluginCache(plugins, scope, repoPath, source) {
814
841
  for (const plugin of plugins) {
815
842
  const pluginRef = `${plugin.name}@${marketplaceName}`;
816
843
  const version = plugin.version ?? "0.0.0";
844
+ const versionKey = gitSha ? gitSha.slice(0, 12) : version;
817
845
  step(`Installing ${c.bold(pluginRef)}...`);
818
- const cacheDest = join3(cacheDir, marketplaceName, plugin.name, version);
846
+ const cacheDest = join3(cacheDir, marketplaceName, plugin.name, versionKey);
819
847
  await mkdir(cacheDest, { recursive: true });
820
848
  await cp(plugin.path, cacheDest, { recursive: true });
821
849
  barDebug(c.dim(`Cached to ${cacheDest}`));
@@ -865,7 +893,8 @@ async function installToCursorExtensions(plugins, scope, repoPath, source) {
865
893
  for (const plugin of plugins) {
866
894
  const pluginRef = `${plugin.name}@${marketplaceName}`;
867
895
  const version = plugin.version ?? "0.0.0";
868
- const folderName = `${marketplaceName}.${plugin.name}-${version}`;
896
+ const versionKey = gitSha ? gitSha.slice(0, 12) : version;
897
+ const folderName = `${marketplaceName}.${plugin.name}-${versionKey}`;
869
898
  const destDir = join3(extensionsDir, folderName);
870
899
  step(`Installing ${c.bold(pluginRef)}...`);
871
900
  await mkdir(destDir, { recursive: true });
@@ -1220,7 +1249,7 @@ function track(data) {
1220
1249
  }
1221
1250
 
1222
1251
  // index.ts
1223
- setVersion("1.0.1");
1252
+ setVersion("1.2.8");
1224
1253
  var { values, positionals } = parseArgs({
1225
1254
  args: process.argv.slice(2),
1226
1255
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugins",
3
- "version": "1.2.7",
3
+ "version": "1.2.10-canary.0",
4
4
  "description": "Install open-plugin format plugins into agent tools",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,9 +11,11 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "build": "tsup",
14
- "start": "node dist/index.js"
14
+ "start": "node dist/index.js",
15
+ "test": "tsx --test test/*.test.ts"
15
16
  },
16
17
  "devDependencies": {
18
+ "tsx": "^4.20.6",
17
19
  "tsup": "^8",
18
20
  "typescript": "^5"
19
21
  }