Skip to content

Commit 4e24940

Browse files
committed
review: address PR #11 follow-ups (drop debug logs, centralize MCP_VERSION)
Addresses apappascs review on #11. - Remove debug `console.log` calls from `incrementOps()` and `window.onmessage` in `ui-entry.ts`. The instrumentation served its purpose; shipping verbose runtime logging in a polish PR was wrong. - Centralize the `pluginos@<version>` pin via build-time injection. The webpack config now reads `mcp-server/package.json#version` and passes it into the UI bundle (DefinePlugin → `__MCP_VERSION__`) and into `bootloader.html` (`templateParameters` → `<%= MCP_VERSION %>`). Drift becomes impossible because `package.json` is the single source. - Drop the regex sweep in `scripts/bump-lockstep.cjs` over `ui-entry.ts` and `bootloader.html` — no longer needed, those files are templated. - Drop the 2-line `constants.ts` shim. With `resolveJsonModule: true`, `ui-entry.ts` imports `DXT_URL` directly from `constants.json`. - README: add a one-line nudge above the `<details>` install block so Cursor / Claude Code CLI users do not skim past the collapsed section. - ESLint: ignore `.claude/` and `.worktrees/` (parallels `.prettierignore`) so nested Claude Code session worktrees do not poison `npm run lint`. Items 4 and 6 from the review (TIER_1_RULES / INSTALL_COMMAND dedup and bootloader theme-token drift) are deferred to a follow-up issue since both span this PR's scope. Verification: `npm run check` ✅ (lint + format + build:shared + typecheck + build + test). Built `dist/bootloader.html` and `dist/ui.html` both contain the literal `pluginos@0.4.2` from `mcp-server/package.json`.
1 parent 97ab1ae commit 4e24940

7 files changed

Lines changed: 21 additions & 32 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ PluginOS takes a fundamentally different approach:
3030

3131
No JSON editing, no terminal. Note: Claude.ai web is **not** supported — it cannot reach local MCP servers.
3232

33+
Using Cursor or Claude Code CLI? Open the section below for the right config.
34+
3335
<details>
3436
<summary><strong>Other AI tools</strong> (Cursor, Claude Code CLI, manual config)</summary>
3537

eslint.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export default tseslint.config(
1414
"**/*.cjs",
1515
"**/*.mjs",
1616
"!eslint.config.js",
17+
".claude/",
18+
".worktrees/",
1719
],
1820
},
1921
{

packages/bridge-plugin/src/bootloader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
}, 1000);
144144
}
145145

146-
var MCP_CONFIG_JSON = JSON.stringify({ mcpServers: { pluginos: { command: "npx", args: ["-y", "pluginos@0.4.2"] } } }, null, 2);
146+
var MCP_CONFIG_JSON = JSON.stringify({ mcpServers: { pluginos: { command: "npx", args: ["-y", "pluginos@<%= MCP_VERSION %>"] } } }, null, 2);
147147
var TIER_1_RULES = "When working with Figma, always use PluginOS tools exclusively:\n- Use `list_operations` (pluginos) first to discover available Figma operations.\n- Use `run_operation` (pluginos) to execute them.\n- Use `execute_figma` (pluginos) only for one-off custom logic not covered by built-in ops.\n- Do NOT use `mcp__Figma__*` tools — they bypass the plugin and return raw, token-heavy data. PluginOS returns pre-summarized, structured results at ~230 tokens/call.\n- If PluginOS returns \"No plugin connected\", open the PluginOS Bridge plugin in Figma before retrying.\n\nAudit/lint/check operations default to `scope: \"selection\"`. Pass `scope: \"page\"` explicitly (and `confirm: true` for pages over 500 nodes) to scan the whole page. Responses carry `_hint` and `_next_hints` fields — respect them when deciding what to do next.";
148148
var INSTALL_COMMAND = "/plugin marketplace add github:LSDimi/pluginos\n/plugin install pluginos";
149149
var DXT_URL = "<%= DXT_URL %>";

packages/bridge-plugin/src/constants.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/bridge-plugin/src/ui-entry.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { DXT_URL } from "./constants";
1+
import { DXT_URL } from "./constants.json";
2+
3+
declare const __MCP_VERSION__: string;
24

35
const TIER_1_RULES = `When working with Figma, always use PluginOS tools exclusively:
46
- Use \`list_operations\` (pluginos) first to discover available Figma operations.
@@ -13,7 +15,7 @@ const MCP_CONFIG_JSON = `{
1315
"mcpServers": {
1416
"pluginos": {
1517
"command": "npx",
16-
"args": ["-y", "pluginos@0.4.2"]
18+
"args": ["-y", "pluginos@${__MCP_VERSION__}"]
1719
}
1820
}
1921
}`;
@@ -189,8 +191,6 @@ function updateFilename(name: string) {
189191

190192
function incrementOps() {
191193
opsRunCount++;
192-
// eslint-disable-next-line no-console
193-
console.log("[pluginos:debug] incrementOps called, count=" + opsRunCount);
194194
const el = $("ops-run-count");
195195
if (el) el.textContent = opsRunCount + " ops run";
196196
}
@@ -307,10 +307,6 @@ document
307307
window.onmessage = (event: MessageEvent) => {
308308
const msg = event.data.pluginMessage;
309309
if (!msg) return;
310-
// eslint-disable-next-line no-console
311-
console.log(
312-
"[pluginos:debug] window.onmessage type=" + msg.type + " payload.type=" + msg?.payload?.type
313-
);
314310

315311
if (msg.type === "__ui_list_operations_result") {
316312
renderOpsPanel(msg.operations);

packages/bridge-plugin/webpack.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const path = require("path");
2+
const webpack = require("webpack");
23
const HtmlWebpackPlugin = require("html-webpack-plugin");
34
const HtmlInlineScriptPlugin = require("html-inline-script-webpack-plugin");
45

56
const { DXT_URL } = require("./src/constants.json");
7+
const { version: MCP_VERSION } = require("../mcp-server/package.json");
68

79
const noModernSyntax = {
810
arrowFunction: true,
@@ -43,6 +45,9 @@ module.exports = (env, argv) => [
4345
resolve: { extensions: [".ts", ".js"] },
4446
devtool: false,
4547
plugins: [
48+
new webpack.DefinePlugin({
49+
__MCP_VERSION__: JSON.stringify(MCP_VERSION),
50+
}),
4651
new HtmlWebpackPlugin({
4752
template: "./src/ui.html",
4853
filename: "ui.html",
@@ -62,7 +67,7 @@ module.exports = (env, argv) => [
6267
template: "./src/bootloader.html",
6368
filename: "bootloader.html",
6469
inject: false,
65-
templateParameters: { DXT_URL },
70+
templateParameters: { DXT_URL, MCP_VERSION },
6671
}),
6772
],
6873
mode: argv.mode || "production",

scripts/bump-lockstep.cjs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
/**
33
* Postversion hook for packages/mcp-server. When `npm version` bumps the
44
* MCP server, propagate the same version string to every file that pins the
5-
* pluginos version: peer package.json manifests, the DXT manifest (both the
6-
* top-level `version` and its `server.mcp_config.args` pin), and the
7-
* hardcoded npx args inside the Figma plugin's UI sources.
5+
* pluginos version: peer package.json manifests and the DXT manifest (both
6+
* the top-level `version` and its `server.mcp_config.args` pin).
7+
*
8+
* Note: the Figma plugin UI (`bridge-plugin/src/ui-entry.ts` and
9+
* `bootloader.html`) reads `mcp-server/package.json#version` at webpack
10+
* build time, so no source-file rewrite is needed there.
811
*/
912
const fs = require("node:fs");
1013
const path = require("node:path");
@@ -40,20 +43,3 @@ if (Array.isArray(dxt?.server?.mcp_config?.args)) {
4043
}
4144
fs.writeFileSync(dxtAbs, JSON.stringify(dxt, null, 2) + "\n");
4245
console.log(`Bumped ${dxtManifestRel}${newVersion}`);
43-
44-
// Sources that hardcode `pluginos@<version>` in copy-paste MCP config snippets.
45-
// These use a regex swap so formatting is preserved.
46-
const sourceTargets = [
47-
"packages/bridge-plugin/src/ui-entry.ts",
48-
"packages/bridge-plugin/src/bootloader.html",
49-
];
50-
51-
for (const rel of sourceTargets) {
52-
const abs = path.join(repoRoot, rel);
53-
const before = fs.readFileSync(abs, "utf8");
54-
const after = before.replace(/pluginos@\d+\.\d+\.\d+/g, `pluginos@${newVersion}`);
55-
if (after !== before) {
56-
fs.writeFileSync(abs, after);
57-
console.log(`Bumped ${rel} → pluginos@${newVersion}`);
58-
}
59-
}

0 commit comments

Comments
 (0)