Skip to content

Rules for an AI coding agent to filter out generic AI-generated UI designs, text, and code.

fix(plugin): pick the Python name at runtime instead of hardcoding one (#22)

Fajar Hidayata6f3cc8bc879
diff --git a/.claude-plugin/contrast-mcp-launcher.mjs b/.claude-plugin/contrast-mcp-launcher.mjs
new file mode 100755
index 0000000..de5cfc3
--- /dev/null
+++ b/.claude-plugin/contrast-mcp-launcher.mjs
@@ -0,0 +1,37 @@
+#!/usr/bin/env node
+/**
+ * Starts contrast-mcp.py with whichever Python name this machine actually has.
+ *
+ * The manifest's `command` is one string with no shell, so it cannot pick per
+ * platform on its own, and every single-name answer breaks somewhere: macOS has
+ * had no `python` since 12.3 removed Python 2, and Windows has no `python3` on
+ * some installs. v3.0.2 made allowed-tools and the skill prose accept both; this
+ * is the same fix for the one place that only takes a single value.
+ */
+import { spawn, spawnSync } from "node:child_process";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const here = path.dirname(fileURLToPath(import.meta.url));
+const server = path.join(here, "..", "skills", "antislop-human", "contrast-mcp.py");
+
+const candidates = process.platform === "win32" ? ["python", "python3"] : ["python3", "python"];
+
+// Run each candidate rather than just looking it up: Windows ships a `python`
+// stub that exists on PATH and only opens the Store page, and pyenv leaves
+// shims that exit non-zero when no version is selected.
+const python = candidates.find(
+ (bin) => spawnSync(bin, ["-c", ""], { stdio: "ignore" }).status === 0
+);
+
+if (!python) {
+ // stderr, never stdout: stdout is the JSON-RPC channel.
+ console.error(
+ `antislop-contrast: no working Python found (tried ${candidates.join(", ")}). ` +
+ "Install Python 3 to use the contrast tool."
+ );
+ process.exit(1);
+}
+
+const child = spawn(python, [server], { stdio: "inherit" });
+child.on("exit", (code, signal) => process.exit(signal ? 1 : (code ?? 0)));
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index aecd985..c1805f0 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -12,8 +12,8 @@
"skills": ["./skills/"],
"mcpServers": {
"antislop-contrast": {
- "command": "python",
- "args": ["${CLAUDE_PLUGIN_ROOT}/skills/antislop-human/contrast-mcp.py"],
+ "command": "node",
+ "args": ["${CLAUDE_PLUGIN_ROOT}/.claude-plugin/contrast-mcp-launcher.mjs"],
"env": {}
}
}