plugins 1.2.7 → 1.2.9

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 +35 -8
  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...");
@@ -1220,7 +1247,7 @@ function track(data) {
1220
1247
  }
1221
1248
 
1222
1249
  // index.ts
1223
- setVersion("1.0.1");
1250
+ setVersion("1.2.8");
1224
1251
  var { values, positionals } = parseArgs({
1225
1252
  args: process.argv.slice(2),
1226
1253
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugins",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
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
  }