pattern-mcp 0.14.0 → 0.14.1
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.
- package/README.md +11 -6
- package/dist/index.js +54 -35
- package/dist/telemetry.js +16 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,12 +15,17 @@ design reference.
|
|
|
15
15
|
|
|
16
16
|
[Website](https://usepattern.sh) · [npm](https://www.npmjs.com/package/pattern-mcp) · [Report an issue](https://github.com/donaldrichard19-LVD/pattern-mcp/issues/new/choose)
|
|
17
17
|
|
|
18
|
-
**Current release: v0.14.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
**Current release: v0.14.1** — the crash/exit telemetry added in
|
|
19
|
+
v0.14.0 (`pattern_cli_exited`) is now registered before any of this
|
|
20
|
+
file's own module-level code runs, instead of near `main()`, so it
|
|
21
|
+
catches more of what can go wrong on startup; both `pattern_cli_started`
|
|
22
|
+
and `pattern_cli_exited` now also carry the running package version, so
|
|
23
|
+
a crash right around a release can be tied to the old or new binary
|
|
24
|
+
instead of staying ambiguous. Previously: v0.14.0 made a crash on
|
|
25
|
+
startup diagnosable instead of silent, warned at startup if
|
|
26
|
+
`ANTHROPIC_API_KEY` is missing or clearly malformed instead of only
|
|
27
|
+
surfacing a raw 401 mid-call, and added one respectful retry on a 429
|
|
28
|
+
(honoring `Retry-After`). Before that: v0.13.0 added `npx pattern-mcp init`,
|
|
24
29
|
which sets up the connection to your MCP client for you (Claude Code,
|
|
25
30
|
Claude Desktop, Cursor detected and configured automatically; Codex CLI
|
|
26
31
|
gets manual instructions). Running `npx pattern-mcp` bare in your own
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,53 @@ import { fileURLToPath } from "node:url";
|
|
|
40
40
|
import { captureApiError, captureCliExited, captureCliStarted, captureRecommendation, getClient as getPostHogClient, installId, printTelemetryNoticeOnce, shutdownTelemetry, TELEMETRY_ENABLED, } from "./telemetry.js";
|
|
41
41
|
import { offerEnforcementSetupOnce } from "./init-enforcement.js";
|
|
42
42
|
import { connectInstructionsText, offerClientConnectSetupOnce, runConnect } from "./client-connect.js";
|
|
43
|
+
// Read as early as possible in this file's own module-level code, wrapped
|
|
44
|
+
// so a missing/corrupt package.json can't itself become a new, unguarded
|
|
45
|
+
// crash source -- this is read before the crash handlers below exist to
|
|
46
|
+
// catch anything. Moved up from where it used to live (just above the
|
|
47
|
+
// `server` construction, far later in this file) after a 2026-09-14
|
|
48
|
+
// incident where a caller crashed on every single launch, ~29 times in 4
|
|
49
|
+
// minutes, immediately after a version bump published -- telemetry had no
|
|
50
|
+
// way to say whether the crashing process was the old or new version (see
|
|
51
|
+
// project_pattern_activation_funnel memory). Every pattern_cli_started/
|
|
52
|
+
// pattern_cli_exited event now carries this, closing that gap for next
|
|
53
|
+
// time.
|
|
54
|
+
const PACKAGE_VERSION = (() => {
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8")).version;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return "unknown";
|
|
60
|
+
}
|
|
61
|
+
})();
|
|
62
|
+
// Registered before anything else in this file runs (all the way up here,
|
|
63
|
+
// not down by main() where it used to be) so a throw anywhere in this
|
|
64
|
+
// file's own module-level code -- not just inside main() -- is captured
|
|
65
|
+
// instead of dying silently before these handlers would otherwise have
|
|
66
|
+
// existed. Can't cover a throw during the import statements above this
|
|
67
|
+
// line (nothing can run before those resolve), but this closes the much
|
|
68
|
+
// larger window between "imports finished" and "main() starts," which is
|
|
69
|
+
// most of this file's ~4700 lines of function/constant definitions and
|
|
70
|
+
// tool registrations.
|
|
71
|
+
let exitTelemetryCaptured = false;
|
|
72
|
+
function captureExitOnce(reason, err) {
|
|
73
|
+
if (exitTelemetryCaptured)
|
|
74
|
+
return;
|
|
75
|
+
exitTelemetryCaptured = true;
|
|
76
|
+
captureCliExited(reason, err, PACKAGE_VERSION);
|
|
77
|
+
}
|
|
78
|
+
process.on("uncaughtException", async (err) => {
|
|
79
|
+
console.error("Pattern: uncaught exception, exiting.", err);
|
|
80
|
+
captureExitOnce("uncaught_exception", err);
|
|
81
|
+
await shutdownTelemetry();
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
process.on("unhandledRejection", async (reason) => {
|
|
85
|
+
console.error("Pattern: unhandled rejection, exiting.", reason);
|
|
86
|
+
captureExitOnce("unhandled_rejection", reason);
|
|
87
|
+
await shutdownTelemetry();
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|
|
43
90
|
export const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
|
|
44
91
|
// Only required for org-scoped keys (not tied to one workspace); unset for
|
|
45
92
|
// legacy workspace-scoped keys, which don't need it.
|
|
@@ -3414,11 +3461,8 @@ export function extractJson(text) {
|
|
|
3414
3461
|
return text;
|
|
3415
3462
|
return text.slice(start, end + 1);
|
|
3416
3463
|
}
|
|
3417
|
-
//
|
|
3418
|
-
//
|
|
3419
|
-
// initialize response) reflects the version actually installed instead of
|
|
3420
|
-
// staying frozen at whatever it was when this line was first written.
|
|
3421
|
-
const PACKAGE_VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8")).version;
|
|
3464
|
+
// PACKAGE_VERSION is defined near the top of this file now (read as early
|
|
3465
|
+
// as possible, before the crash handlers -- see the comment there).
|
|
3422
3466
|
const server = new Server({ name: "pattern-mcp", version: PACKAGE_VERSION }, { capabilities: { tools: {} } });
|
|
3423
3467
|
// Standard MCP tool-call analytics (tool name, duration, success/failure,
|
|
3424
3468
|
// unique installs/sessions) via PostHog's own MCP SDK -- separate from
|
|
@@ -3938,41 +3982,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3938
3982
|
// they're still looking at the terminal, not five minutes after they
|
|
3939
3983
|
// alt-tabbed away.
|
|
3940
3984
|
const IDLE_CONNECT_NUDGE_MS = 20_000;
|
|
3941
|
-
//
|
|
3942
|
-
//
|
|
3943
|
-
//
|
|
3944
|
-
// all: captureCliStarted fires, the process dies, and nothing explains why
|
|
3945
|
-
// (see project_pattern_activation_funnel memory -- the incident this
|
|
3946
|
-
// exists to make diagnosable next time). Both handlers exit(1) after
|
|
3947
|
-
// capturing: Node considers the process's state undefined past an uncaught
|
|
3948
|
-
// exception, so continuing to run is the wrong default regardless of
|
|
3949
|
-
// telemetry.
|
|
3950
|
-
let exitTelemetryCaptured = false;
|
|
3951
|
-
function captureExitOnce(reason, err) {
|
|
3952
|
-
if (exitTelemetryCaptured)
|
|
3953
|
-
return;
|
|
3954
|
-
exitTelemetryCaptured = true;
|
|
3955
|
-
captureCliExited(reason, err);
|
|
3956
|
-
}
|
|
3957
|
-
process.on("uncaughtException", async (err) => {
|
|
3958
|
-
console.error("Pattern: uncaught exception, exiting.", err);
|
|
3959
|
-
captureExitOnce("uncaught_exception", err);
|
|
3960
|
-
await shutdownTelemetry();
|
|
3961
|
-
process.exit(1);
|
|
3962
|
-
});
|
|
3963
|
-
process.on("unhandledRejection", async (reason) => {
|
|
3964
|
-
console.error("Pattern: unhandled rejection, exiting.", reason);
|
|
3965
|
-
captureExitOnce("unhandled_rejection", reason);
|
|
3966
|
-
await shutdownTelemetry();
|
|
3967
|
-
process.exit(1);
|
|
3968
|
-
});
|
|
3985
|
+
// captureExitOnce and the uncaughtException/unhandledRejection handlers
|
|
3986
|
+
// are registered near the top of this file now, before PACKAGE_VERSION's
|
|
3987
|
+
// definition -- see the comment there for why.
|
|
3969
3988
|
async function main() {
|
|
3970
3989
|
// `npx pattern-mcp init` -- the connect wizard -- exits without ever
|
|
3971
3990
|
// starting the server. Checked before anything else so it can't be
|
|
3972
3991
|
// shadowed by a tool name collision later.
|
|
3973
3992
|
const argv = process.argv.slice(2);
|
|
3974
3993
|
if (argv[0] === "init") {
|
|
3975
|
-
captureCliStarted("init");
|
|
3994
|
+
captureCliStarted("init", PACKAGE_VERSION);
|
|
3976
3995
|
await runConnect(PROJECT_ROOT, { yes: argv.includes("--yes") });
|
|
3977
3996
|
await shutdownTelemetry();
|
|
3978
3997
|
// Explicit exit, not a bare return -- shutdownTelemetry races a
|
|
@@ -3982,7 +4001,7 @@ async function main() {
|
|
|
3982
4001
|
// event loop to drain on its own if some other handle is lingering.
|
|
3983
4002
|
process.exit(0);
|
|
3984
4003
|
}
|
|
3985
|
-
captureCliStarted("server");
|
|
4004
|
+
captureCliStarted("server", PACKAGE_VERSION);
|
|
3986
4005
|
warnIfAnthropicKeyLooksWrong();
|
|
3987
4006
|
printTelemetryNoticeOnce();
|
|
3988
4007
|
// Piggybacks on this same first-run moment (Option B, see
|
package/dist/telemetry.js
CHANGED
|
@@ -241,21 +241,30 @@ export function captureRecommendation(args) {
|
|
|
241
241
|
// project_pattern_reddit_launch_spike memory for why that gap mattered:
|
|
242
242
|
// a 2026-09-11 download spike showed almost no matching $mcp_initialize
|
|
243
243
|
// growth, and there was no signal at all for the step in between.
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
// `version` is the running package.json version (see index.ts's
|
|
245
|
+
// PACKAGE_VERSION) -- added 2026-09-14 after an incident where a caller
|
|
246
|
+
// crashed on every launch attempt (~29 times in 4 minutes) in the few
|
|
247
|
+
// minutes right after a version bump published, and telemetry had no way
|
|
248
|
+
// to say whether the crashing process was the old or new version. Without
|
|
249
|
+
// it, "did the fix actually ship before this happened" is unanswerable
|
|
250
|
+
// from telemetry alone.
|
|
251
|
+
export function captureCliStarted(mode, version) {
|
|
252
|
+
capture("pattern_cli_started", { mode, version });
|
|
246
253
|
}
|
|
247
254
|
// Paired with captureCliStarted so a start with no matching handshake is
|
|
248
255
|
// diagnosable instead of silent -- added after a 2026-09-13 incident where
|
|
249
256
|
// 33 starts in one hour produced exactly 1 successful handshake, and
|
|
250
257
|
// telemetry had no way to say why the other 32 processes ended (see
|
|
251
|
-
// project_pattern_activation_funnel memory). Only a coarse reason
|
|
252
|
-
// thrown value's constructor name
|
|
253
|
-
// stack, which could contain a file path, a
|
|
254
|
-
// local detail never sent by design (see
|
|
255
|
-
|
|
258
|
+
// project_pattern_activation_funnel memory). Only a coarse reason, the
|
|
259
|
+
// thrown value's constructor name, and the running version travel --
|
|
260
|
+
// never the error message or stack, which could contain a file path, a
|
|
261
|
+
// stray argument value, or other local detail never sent by design (see
|
|
262
|
+
// this file's header).
|
|
263
|
+
export function captureCliExited(reason, err, version) {
|
|
256
264
|
capture("pattern_cli_exited", {
|
|
257
265
|
exit_reason: reason,
|
|
258
266
|
error_name: err instanceof Error ? err.name : null,
|
|
267
|
+
version,
|
|
259
268
|
});
|
|
260
269
|
}
|
|
261
270
|
export function captureApiError(args) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pattern-mcp",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "MCP server that turns your design guidance into a checkable process -- evaluates UI components from external libraries (shadcn/ui, 21st.dev, ReUI) or your own registered design system against a requirements checklist, then tells the agent whether to reuse an existing component or build one from a concrete design reference.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|