From 5dc4a4ca839f3f71f76b53cdbb532c874a855cdd Mon Sep 17 00:00:00 2001 From: Sungman Cho Date: Fri, 20 Mar 2026 00:49:13 -0700 Subject: [PATCH 1/6] fix(plugin): fallback CLAUDE_PLUGIN_DATA to ~/.betterprompt When CLAUDE_PLUGIN_DATA env var is unset (e.g., mid-session MCP registration), use homedir-based default so native dep installation still works. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/plugin/dist/chunk-IEEHTH2R.js.map | 1 - .../plugin/dist/{chunk-IEEHTH2R.js => chunk-M3JIHQUB.js} | 5 +++-- packages/plugin/dist/chunk-M3JIHQUB.js.map | 1 + packages/plugin/dist/hooks/session-start-handler.js | 2 +- packages/plugin/dist/mcp/server-entry.js | 2 +- packages/plugin/lib/native-deps.ts | 3 ++- 6 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 packages/plugin/dist/chunk-IEEHTH2R.js.map rename packages/plugin/dist/{chunk-IEEHTH2R.js => chunk-M3JIHQUB.js} (82%) create mode 100644 packages/plugin/dist/chunk-M3JIHQUB.js.map diff --git a/packages/plugin/dist/chunk-IEEHTH2R.js.map b/packages/plugin/dist/chunk-IEEHTH2R.js.map deleted file mode 100644 index 585588de..00000000 --- a/packages/plugin/dist/chunk-IEEHTH2R.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../lib/native-deps.ts"],"sourcesContent":["/**\n * Shared native dependency installer.\n *\n * Ensures `better-sqlite3` is compiled and available in the persistent\n * plugin data directory. Safe to call from multiple entry points\n * (SessionStart hook, MCP server startup) — a marker file prevents\n * redundant installs.\n */\n\nimport { existsSync } from 'node:fs';\nimport { execFileSync } from 'node:child_process';\nimport { join } from 'node:path';\n\nexport function ensureNativeDeps(opts?: { fatal?: boolean }): void {\n const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA;\n if (!pluginDataDir) return;\n\n const marker = join(pluginDataDir, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node');\n if (existsSync(marker)) return;\n\n try {\n execFileSync('npm', ['install', '--prefix', pluginDataDir, 'better-sqlite3@12.8.0'], {\n stdio: 'ignore',\n timeout: 60_000,\n });\n } catch (err) {\n const msg = `[betterprompt] Failed to install better-sqlite3: ${err instanceof Error ? err.message : err}`;\n if (opts?.fatal) {\n throw new Error(msg);\n }\n process.stderr.write(msg + '\\n');\n }\n}\n"],"mappings":";AASA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AAEd,SAAS,iBAAiB,MAAkC;AACjE,QAAM,gBAAgB,QAAQ,IAAI;AAClC,MAAI,CAAC,cAAe;AAEpB,QAAM,SAAS,KAAK,eAAe,gBAAgB,kBAAkB,SAAS,WAAW,qBAAqB;AAC9G,MAAI,WAAW,MAAM,EAAG;AAExB,MAAI;AACF,iBAAa,OAAO,CAAC,WAAW,YAAY,eAAe,uBAAuB,GAAG;AAAA,MACnF,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,UAAM,MAAM,oDAAoD,eAAe,QAAQ,IAAI,UAAU,GAAG;AACxG,QAAI,MAAM,OAAO;AACf,YAAM,IAAI,MAAM,GAAG;AAAA,IACrB;AACA,YAAQ,OAAO,MAAM,MAAM,IAAI;AAAA,EACjC;AACF;","names":[]} \ No newline at end of file diff --git a/packages/plugin/dist/chunk-IEEHTH2R.js b/packages/plugin/dist/chunk-M3JIHQUB.js similarity index 82% rename from packages/plugin/dist/chunk-IEEHTH2R.js rename to packages/plugin/dist/chunk-M3JIHQUB.js index e2c73472..6de9f1ee 100644 --- a/packages/plugin/dist/chunk-IEEHTH2R.js +++ b/packages/plugin/dist/chunk-M3JIHQUB.js @@ -2,8 +2,9 @@ import { existsSync } from "fs"; import { execFileSync } from "child_process"; import { join } from "path"; +import { homedir } from "os"; function ensureNativeDeps(opts) { - const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA; + const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), ".betterprompt"); if (!pluginDataDir) return; const marker = join(pluginDataDir, "node_modules", "better-sqlite3", "build", "Release", "better_sqlite3.node"); if (existsSync(marker)) return; @@ -24,4 +25,4 @@ function ensureNativeDeps(opts) { export { ensureNativeDeps }; -//# sourceMappingURL=chunk-IEEHTH2R.js.map \ No newline at end of file +//# sourceMappingURL=chunk-M3JIHQUB.js.map \ No newline at end of file diff --git a/packages/plugin/dist/chunk-M3JIHQUB.js.map b/packages/plugin/dist/chunk-M3JIHQUB.js.map new file mode 100644 index 00000000..f45fa046 --- /dev/null +++ b/packages/plugin/dist/chunk-M3JIHQUB.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../lib/native-deps.ts"],"sourcesContent":["/**\n * Shared native dependency installer.\n *\n * Ensures `better-sqlite3` is compiled and available in the persistent\n * plugin data directory. Safe to call from multiple entry points\n * (SessionStart hook, MCP server startup) — a marker file prevents\n * redundant installs.\n */\n\nimport { existsSync } from 'node:fs';\nimport { execFileSync } from 'node:child_process';\nimport { join } from 'node:path';\nimport { homedir } from 'node:os';\n\nexport function ensureNativeDeps(opts?: { fatal?: boolean }): void {\n const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), '.betterprompt');\n if (!pluginDataDir) return;\n\n const marker = join(pluginDataDir, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node');\n if (existsSync(marker)) return;\n\n try {\n execFileSync('npm', ['install', '--prefix', pluginDataDir, 'better-sqlite3@12.8.0'], {\n stdio: 'ignore',\n timeout: 60_000,\n });\n } catch (err) {\n const msg = `[betterprompt] Failed to install better-sqlite3: ${err instanceof Error ? err.message : err}`;\n if (opts?.fatal) {\n throw new Error(msg);\n }\n process.stderr.write(msg + '\\n');\n }\n}\n"],"mappings":";AASA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,eAAe;AAEjB,SAAS,iBAAiB,MAAkC;AACjE,QAAM,gBAAgB,QAAQ,IAAI,sBAAsB,KAAK,QAAQ,GAAG,eAAe;AACvF,MAAI,CAAC,cAAe;AAEpB,QAAM,SAAS,KAAK,eAAe,gBAAgB,kBAAkB,SAAS,WAAW,qBAAqB;AAC9G,MAAI,WAAW,MAAM,EAAG;AAExB,MAAI;AACF,iBAAa,OAAO,CAAC,WAAW,YAAY,eAAe,uBAAuB,GAAG;AAAA,MACnF,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,UAAM,MAAM,oDAAoD,eAAe,QAAQ,IAAI,UAAU,GAAG;AACxG,QAAI,MAAM,OAAO;AACf,YAAM,IAAI,MAAM,GAAG;AAAA,IACrB;AACA,YAAQ,OAAO,MAAM,MAAM,IAAI;AAAA,EACjC;AACF;","names":[]} \ No newline at end of file diff --git a/packages/plugin/dist/hooks/session-start-handler.js b/packages/plugin/dist/hooks/session-start-handler.js index a43e229d..841b0b0e 100755 --- a/packages/plugin/dist/hooks/session-start-handler.js +++ b/packages/plugin/dist/hooks/session-start-handler.js @@ -1,7 +1,7 @@ #!/usr/bin/env node import { ensureNativeDeps -} from "../chunk-IEEHTH2R.js"; +} from "../chunk-M3JIHQUB.js"; import { buildFirstRunAdditionalContext, buildPendingAnalysisAdditionalContext diff --git a/packages/plugin/dist/mcp/server-entry.js b/packages/plugin/dist/mcp/server-entry.js index 8b03d64e..f9a22c5d 100755 --- a/packages/plugin/dist/mcp/server-entry.js +++ b/packages/plugin/dist/mcp/server-entry.js @@ -1,7 +1,7 @@ #!/usr/bin/env node import { ensureNativeDeps -} from "../chunk-IEEHTH2R.js"; +} from "../chunk-M3JIHQUB.js"; import "../chunk-PR4QN5HX.js"; // mcp/server-entry.ts diff --git a/packages/plugin/lib/native-deps.ts b/packages/plugin/lib/native-deps.ts index d4cb7fee..49b43629 100644 --- a/packages/plugin/lib/native-deps.ts +++ b/packages/plugin/lib/native-deps.ts @@ -10,9 +10,10 @@ import { existsSync } from 'node:fs'; import { execFileSync } from 'node:child_process'; import { join } from 'node:path'; +import { homedir } from 'node:os'; export function ensureNativeDeps(opts?: { fatal?: boolean }): void { - const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA; + const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), '.betterprompt'); if (!pluginDataDir) return; const marker = join(pluginDataDir, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node'); From ac1b2b3bc646f058afd2c0d1b1646dd6579bc68e Mon Sep 17 00:00:00 2001 From: Sungman Cho Date: Fri, 20 Mar 2026 00:49:15 -0700 Subject: [PATCH 2/6] feat(plugin): add mid-session MCP registration to setup wizard New Step 0.5 in /bp-setup: detects if the MCP server is running and registers it via `claude mcp add` if missing, enabling install-then- setup in a single Claude Code session. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/plugin/skills/bp-setup/SKILL.md | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/plugin/skills/bp-setup/SKILL.md b/packages/plugin/skills/bp-setup/SKILL.md index d296f145..f11d5998 100644 --- a/packages/plugin/skills/bp-setup/SKILL.md +++ b/packages/plugin/skills/bp-setup/SKILL.md @@ -37,6 +37,29 @@ your machine. This setup takes about 1 minute. ``` +### Step 0.5: Ensure MCP Server + +After a fresh plugin installation, the MCP server is not running yet in the current session. This step registers it so all BetterPrompt tools become available immediately. + +1. Run `claude mcp list` via Bash and check whether `betterprompt` appears in the output. +2. If `betterprompt` is already listed, skip to Step 1. +3. If NOT listed: + a. Find the plugin's server entry point — search for the file matching this glob pattern: + ``` + ~/.claude/plugins/cache/betterprompt/betterprompt/*/dist/mcp/server-entry.js + ``` + b. Create the data directory if it doesn't exist: `mkdir -p ~/.betterprompt` + c. Register the MCP server: + ```bash + claude mcp add -s user \ + -e NODE_PATH="$HOME/.betterprompt/node_modules" \ + -e CLAUDE_PLUGIN_DATA="$HOME/.betterprompt" \ + betterprompt -- \ + node "" + ``` + d. Tell the user: "MCP server registered. BetterPrompt tools are now available." +4. If the server entry point cannot be found, inform the user and suggest reinstalling the plugin. + ### Step 1: Verify Installation Call the `scan_sessions` MCP tool to confirm the plugin is working. @@ -147,7 +170,8 @@ Use `AskUserQuestion` with these options: ## Important Notes -- Never skip Step 1 (verification) -- this confirms the plugin works. +- Never skip Step 0.5 (MCP server) or Step 1 (verification) -- these confirm the plugin works. +- Step 0.5 makes install-then-setup possible in a single Claude Code session. - Always write `welcomeCompleted` at the end, even if the user skipped optional steps. - If any step fails, log the error but continue to the next step. Do not abort the entire wizard for a non-critical failure (Steps 2, 3 are non-critical). - The CLAUDE.md block uses HTML comment markers (`` / ``) so it can be cleanly replaced or removed later. From 03262341028ac9c7b2b7533dc507eb70daa0657a Mon Sep 17 00:00:00 2001 From: Sungman Cho Date: Fri, 20 Mar 2026 00:49:17 -0700 Subject: [PATCH 3/6] chore(plugin): add skills and mcpServers fields to plugin manifest Declare skills directory and MCP server config paths in plugin.json for proper plugin discovery. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/plugin/.claude-plugin/plugin.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/plugin/.claude-plugin/plugin.json b/packages/plugin/.claude-plugin/plugin.json index c55cb237..781e804c 100644 --- a/packages/plugin/.claude-plugin/plugin.json +++ b/packages/plugin/.claude-plugin/plugin.json @@ -7,6 +7,8 @@ "name": "BetterPrompt" }, "repository": "https://github.com/onlycastle/BetterPrompt", + "skills": "./skills/", + "mcpServers": "./.mcp.json", "configuration": { "serverUrl": { "type": "string", From cd2c0114ed760c61ceb6997ffb1e43d17a48664e Mon Sep 17 00:00:00 2001 From: Sungman Cho Date: Fri, 20 Mar 2026 00:49:18 -0700 Subject: [PATCH 4/6] docs(plugin): document single-session install flow Add section explaining how Step 0.5 bridges the gap between plugin install and MCP server availability within the same session. Co-Authored-By: Claude Opus 4.6 (1M context) --- docs/agent/PLUGIN.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/agent/PLUGIN.md b/docs/agent/PLUGIN.md index 85ed0ca5..a474cd0b 100644 --- a/docs/agent/PLUGIN.md +++ b/docs/agent/PLUGIN.md @@ -51,7 +51,7 @@ Claude Code plugin at `packages/plugin/`. MCP server + queued auto-analysis hook | `lib/native-deps.ts` | Shared `ensureNativeDeps()` — idempotent better-sqlite3 installer used by both server-entry and SessionStart hook | | `hooks/session-start-handler.ts` | `SessionStart` hook, first-run detection + queued `/bp-analyze` context | | `hooks/hooks.json` | Hook registration (`SessionStart` + `SessionEnd`) | -| `skills/bp-setup/SKILL.md` | Guided onboarding wizard skill | +| `skills/bp-setup/SKILL.md` | Guided onboarding wizard skill (includes mid-session MCP registration via `claude mcp add`) | | `skills/bp-analyze/SKILL.md` | Full analysis pipeline orchestrator skill | | `.claude-plugin/plugin.json` | Plugin metadata + config schema | | `.mcp.json` | MCP server config (stdio transport) | @@ -146,6 +146,16 @@ Evaluated in order by `shouldTriggerAnalysis(sessionDurationMs)`: Session count: scans `~/.claude/projects/*/` for `.jsonl` files (filesystem only, no content reading). +## Single-Session Install Flow + +After `claude plugin install`, the MCP server isn't running yet (plugin lifecycle starts next session). The `/bp-setup` skill handles this with Step 0.5: + +``` +install plugin → /bp-setup → Step 0.5: `claude mcp add -s user betterprompt` → MCP tools available → continue setup +``` + +The `claude mcp add` command registers the server at user scope with `NODE_PATH` and `CLAUDE_PLUGIN_DATA` env vars pointing to `~/.betterprompt/`. On subsequent sessions, the plugin's `.mcp.json` handles server startup normally. + ## Queued Auto-Analysis Flow ``` From 496e117ad993afcb69a0c0c78f255b3ce586e4a6 Mon Sep 17 00:00:00 2001 From: Sungman Cho Date: Fri, 20 Mar 2026 07:05:53 -0700 Subject: [PATCH 5/6] fix(plugin): remove unreachable pluginDataDir guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `if (!pluginDataDir) return` guard became dead code after adding the `homedir()` fallback — the expression always produces a truthy string. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/plugin/dist/{chunk-M3JIHQUB.js => chunk-KH675EAB.js} | 3 +-- packages/plugin/dist/chunk-KH675EAB.js.map | 1 + packages/plugin/dist/chunk-M3JIHQUB.js.map | 1 - packages/plugin/dist/hooks/session-start-handler.js | 2 +- packages/plugin/dist/mcp/server-entry.js | 2 +- packages/plugin/lib/native-deps.ts | 1 - 6 files changed, 4 insertions(+), 6 deletions(-) rename packages/plugin/dist/{chunk-M3JIHQUB.js => chunk-KH675EAB.js} (92%) create mode 100644 packages/plugin/dist/chunk-KH675EAB.js.map delete mode 100644 packages/plugin/dist/chunk-M3JIHQUB.js.map diff --git a/packages/plugin/dist/chunk-M3JIHQUB.js b/packages/plugin/dist/chunk-KH675EAB.js similarity index 92% rename from packages/plugin/dist/chunk-M3JIHQUB.js rename to packages/plugin/dist/chunk-KH675EAB.js index 6de9f1ee..55a0d484 100644 --- a/packages/plugin/dist/chunk-M3JIHQUB.js +++ b/packages/plugin/dist/chunk-KH675EAB.js @@ -5,7 +5,6 @@ import { join } from "path"; import { homedir } from "os"; function ensureNativeDeps(opts) { const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), ".betterprompt"); - if (!pluginDataDir) return; const marker = join(pluginDataDir, "node_modules", "better-sqlite3", "build", "Release", "better_sqlite3.node"); if (existsSync(marker)) return; try { @@ -25,4 +24,4 @@ function ensureNativeDeps(opts) { export { ensureNativeDeps }; -//# sourceMappingURL=chunk-M3JIHQUB.js.map \ No newline at end of file +//# sourceMappingURL=chunk-KH675EAB.js.map \ No newline at end of file diff --git a/packages/plugin/dist/chunk-KH675EAB.js.map b/packages/plugin/dist/chunk-KH675EAB.js.map new file mode 100644 index 00000000..1e09d46d --- /dev/null +++ b/packages/plugin/dist/chunk-KH675EAB.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../lib/native-deps.ts"],"sourcesContent":["/**\n * Shared native dependency installer.\n *\n * Ensures `better-sqlite3` is compiled and available in the persistent\n * plugin data directory. Safe to call from multiple entry points\n * (SessionStart hook, MCP server startup) — a marker file prevents\n * redundant installs.\n */\n\nimport { existsSync } from 'node:fs';\nimport { execFileSync } from 'node:child_process';\nimport { join } from 'node:path';\nimport { homedir } from 'node:os';\n\nexport function ensureNativeDeps(opts?: { fatal?: boolean }): void {\n const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), '.betterprompt');\n\n const marker = join(pluginDataDir, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node');\n if (existsSync(marker)) return;\n\n try {\n execFileSync('npm', ['install', '--prefix', pluginDataDir, 'better-sqlite3@12.8.0'], {\n stdio: 'ignore',\n timeout: 60_000,\n });\n } catch (err) {\n const msg = `[betterprompt] Failed to install better-sqlite3: ${err instanceof Error ? err.message : err}`;\n if (opts?.fatal) {\n throw new Error(msg);\n }\n process.stderr.write(msg + '\\n');\n }\n}\n"],"mappings":";AASA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,eAAe;AAEjB,SAAS,iBAAiB,MAAkC;AACjE,QAAM,gBAAgB,QAAQ,IAAI,sBAAsB,KAAK,QAAQ,GAAG,eAAe;AAEvF,QAAM,SAAS,KAAK,eAAe,gBAAgB,kBAAkB,SAAS,WAAW,qBAAqB;AAC9G,MAAI,WAAW,MAAM,EAAG;AAExB,MAAI;AACF,iBAAa,OAAO,CAAC,WAAW,YAAY,eAAe,uBAAuB,GAAG;AAAA,MACnF,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,UAAM,MAAM,oDAAoD,eAAe,QAAQ,IAAI,UAAU,GAAG;AACxG,QAAI,MAAM,OAAO;AACf,YAAM,IAAI,MAAM,GAAG;AAAA,IACrB;AACA,YAAQ,OAAO,MAAM,MAAM,IAAI;AAAA,EACjC;AACF;","names":[]} \ No newline at end of file diff --git a/packages/plugin/dist/chunk-M3JIHQUB.js.map b/packages/plugin/dist/chunk-M3JIHQUB.js.map deleted file mode 100644 index f45fa046..00000000 --- a/packages/plugin/dist/chunk-M3JIHQUB.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../lib/native-deps.ts"],"sourcesContent":["/**\n * Shared native dependency installer.\n *\n * Ensures `better-sqlite3` is compiled and available in the persistent\n * plugin data directory. Safe to call from multiple entry points\n * (SessionStart hook, MCP server startup) — a marker file prevents\n * redundant installs.\n */\n\nimport { existsSync } from 'node:fs';\nimport { execFileSync } from 'node:child_process';\nimport { join } from 'node:path';\nimport { homedir } from 'node:os';\n\nexport function ensureNativeDeps(opts?: { fatal?: boolean }): void {\n const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), '.betterprompt');\n if (!pluginDataDir) return;\n\n const marker = join(pluginDataDir, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node');\n if (existsSync(marker)) return;\n\n try {\n execFileSync('npm', ['install', '--prefix', pluginDataDir, 'better-sqlite3@12.8.0'], {\n stdio: 'ignore',\n timeout: 60_000,\n });\n } catch (err) {\n const msg = `[betterprompt] Failed to install better-sqlite3: ${err instanceof Error ? err.message : err}`;\n if (opts?.fatal) {\n throw new Error(msg);\n }\n process.stderr.write(msg + '\\n');\n }\n}\n"],"mappings":";AASA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,eAAe;AAEjB,SAAS,iBAAiB,MAAkC;AACjE,QAAM,gBAAgB,QAAQ,IAAI,sBAAsB,KAAK,QAAQ,GAAG,eAAe;AACvF,MAAI,CAAC,cAAe;AAEpB,QAAM,SAAS,KAAK,eAAe,gBAAgB,kBAAkB,SAAS,WAAW,qBAAqB;AAC9G,MAAI,WAAW,MAAM,EAAG;AAExB,MAAI;AACF,iBAAa,OAAO,CAAC,WAAW,YAAY,eAAe,uBAAuB,GAAG;AAAA,MACnF,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,UAAM,MAAM,oDAAoD,eAAe,QAAQ,IAAI,UAAU,GAAG;AACxG,QAAI,MAAM,OAAO;AACf,YAAM,IAAI,MAAM,GAAG;AAAA,IACrB;AACA,YAAQ,OAAO,MAAM,MAAM,IAAI;AAAA,EACjC;AACF;","names":[]} \ No newline at end of file diff --git a/packages/plugin/dist/hooks/session-start-handler.js b/packages/plugin/dist/hooks/session-start-handler.js index 841b0b0e..ce205561 100755 --- a/packages/plugin/dist/hooks/session-start-handler.js +++ b/packages/plugin/dist/hooks/session-start-handler.js @@ -1,7 +1,7 @@ #!/usr/bin/env node import { ensureNativeDeps -} from "../chunk-M3JIHQUB.js"; +} from "../chunk-KH675EAB.js"; import { buildFirstRunAdditionalContext, buildPendingAnalysisAdditionalContext diff --git a/packages/plugin/dist/mcp/server-entry.js b/packages/plugin/dist/mcp/server-entry.js index f9a22c5d..1198d9c8 100755 --- a/packages/plugin/dist/mcp/server-entry.js +++ b/packages/plugin/dist/mcp/server-entry.js @@ -1,7 +1,7 @@ #!/usr/bin/env node import { ensureNativeDeps -} from "../chunk-M3JIHQUB.js"; +} from "../chunk-KH675EAB.js"; import "../chunk-PR4QN5HX.js"; // mcp/server-entry.ts diff --git a/packages/plugin/lib/native-deps.ts b/packages/plugin/lib/native-deps.ts index 49b43629..889a915d 100644 --- a/packages/plugin/lib/native-deps.ts +++ b/packages/plugin/lib/native-deps.ts @@ -14,7 +14,6 @@ import { homedir } from 'node:os'; export function ensureNativeDeps(opts?: { fatal?: boolean }): void { const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), '.betterprompt'); - if (!pluginDataDir) return; const marker = join(pluginDataDir, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node'); if (existsSync(marker)) return; From 1bf8a68b5868e5addb4a48a158a9126203f20c69 Mon Sep 17 00:00:00 2001 From: Sungman Cho Date: Fri, 20 Mar 2026 07:05:56 -0700 Subject: [PATCH 6/6] docs(plugin): fix incomplete mcp add command and clarify dedup Show the full `claude mcp add` invocation with -e flags in the diagram, and note that Claude Code deduplicates by server name so the user-scoped and plugin-managed entries don't conflict. Co-Authored-By: Claude Opus 4.6 (1M context) --- docs/agent/PLUGIN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/agent/PLUGIN.md b/docs/agent/PLUGIN.md index a474cd0b..0f912622 100644 --- a/docs/agent/PLUGIN.md +++ b/docs/agent/PLUGIN.md @@ -151,10 +151,10 @@ Session count: scans `~/.claude/projects/*/` for `.jsonl` files (filesystem only After `claude plugin install`, the MCP server isn't running yet (plugin lifecycle starts next session). The `/bp-setup` skill handles this with Step 0.5: ``` -install plugin → /bp-setup → Step 0.5: `claude mcp add -s user betterprompt` → MCP tools available → continue setup +install plugin → /bp-setup → Step 0.5: `claude mcp add -s user -e NODE_PATH=... -e CLAUDE_PLUGIN_DATA=... betterprompt -- node ` → MCP tools available → continue setup ``` -The `claude mcp add` command registers the server at user scope with `NODE_PATH` and `CLAUDE_PLUGIN_DATA` env vars pointing to `~/.betterprompt/`. On subsequent sessions, the plugin's `.mcp.json` handles server startup normally. +The `claude mcp add` command registers the server at user scope with `NODE_PATH` and `CLAUDE_PLUGIN_DATA` env vars pointing to `~/.betterprompt/`. On subsequent sessions, the plugin's `.mcp.json` handles server startup normally — Claude Code deduplicates by server name, so the user-scoped entry and the plugin-managed `.mcp.json` entry do not conflict. ## Queued Auto-Analysis Flow