specguard-mcp 0.1.24 → 0.1.25

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.
@@ -2,7 +2,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
2
  import { type Config } from "./config.js";
3
3
  import type { ToolContext, ToolDefinition } from "./tools/types.js";
4
4
  export declare const SERVER_NAME = "specguard-mcp";
5
- export declare const SERVER_VERSION = "0.1.0";
5
+ export declare const SERVER_VERSION: string;
6
6
  export interface CreateServerOptions {
7
7
  /** Overrides the tools served. Defaults to the registry. Tests pass their own. */
8
8
  readonly tools?: readonly ToolDefinition[];
@@ -26,3 +26,42 @@ export interface CreateServerOptions {
26
26
  * to the server.
27
27
  */
28
28
  export declare function createServer(options?: CreateServerOptions): Server;
29
+ /**
30
+ * This package's version, read from the package manifest rather than kept as a
31
+ * literal beside it.
32
+ *
33
+ * The literal this replaced was written at bootstrap and never revisited: the
34
+ * release bot bumps `package.json` alone, so every initialize handshake after
35
+ * the first release told every client the bridge was still the bootstrap
36
+ * version. Nothing caught the drift because the constant has exactly two
37
+ * reader cells — this file's `serverInfo` and the `src/index.ts` re-export —
38
+ * and no test named it. `SERVER_VERSION` stays a const export with the same
39
+ * readers; the ONLY change is that its value now tracks the release instead of
40
+ * the bootstrap.
41
+ *
42
+ * `SERVER_VERSION`'s module-scope initialization is the single read: the walk
43
+ * runs once at import, and every later reader cell sees the cached result.
44
+ *
45
+ * The read is a walk UP from this module to the package root, bounded and
46
+ * name-checked — the shape specguard-ts landed for the same disease (its
47
+ * fixed `../package.json` read resolved against the module's OWN directory and
48
+ * answered `"0.0.0"` in every built layout). The layouts this bridge ships
49
+ * put the compiled module at `dist/src/server.js`, `.test-build/src/server.js`
50
+ * (the test build), or `src/server.ts` (the dev loader), and an install at
51
+ * `node_modules/specguard-mcp/dist/src/` — in each, walking up finds the
52
+ * manifest that names this package, where a fixed relative read would name
53
+ * `dist/package.json` / `.test-build/package.json` (both absent; `files`
54
+ * ships dist only, so src/ is not even present in an installed tree). The
55
+ * name check keeps an ancestor manifest — a monorepo or a vendoring
56
+ * application's package.json — from being mistaken for this package's, and a
57
+ * tree with no matching manifest answers the `"0.0.0"` sentinel without
58
+ * throwing: `createServer` must never gain a failure mode, and a version
59
+ * that says "unknown" is honest where a crashed boot is not.
60
+ *
61
+ * `start` is the injection seam the tests drive the fallback and name-check
62
+ * arms through: a filesystem path whose directory the walk begins from,
63
+ * defaulting to this module's own file. Production always takes the default;
64
+ * tests pass temp-tree paths so the walk can be exercised in layouts the
65
+ * repo does not ship.
66
+ */
67
+ export declare function readPackageVersion(start?: string): string;
@@ -1,3 +1,6 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
1
4
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
5
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
3
6
  import { loadConfig } from "./config.js";
@@ -5,7 +8,7 @@ import { SpecGuardMcpError } from "./errors.js";
5
8
  import { runCommand as defaultRunCommand } from "./support/run-command.js";
6
9
  import { TOOLS } from "./tools/index.js";
7
10
  export const SERVER_NAME = "specguard-mcp";
8
- export const SERVER_VERSION = "0.1.0";
11
+ export const SERVER_VERSION = readPackageVersion();
9
12
  /**
10
13
  * Builds the MCP server: two request handlers over the tool registry, and no
11
14
  * knowledge of any tool in particular.
@@ -110,4 +113,62 @@ function indexByName(tools) {
110
113
  }
111
114
  return byName;
112
115
  }
116
+ /**
117
+ * This package's version, read from the package manifest rather than kept as a
118
+ * literal beside it.
119
+ *
120
+ * The literal this replaced was written at bootstrap and never revisited: the
121
+ * release bot bumps `package.json` alone, so every initialize handshake after
122
+ * the first release told every client the bridge was still the bootstrap
123
+ * version. Nothing caught the drift because the constant has exactly two
124
+ * reader cells — this file's `serverInfo` and the `src/index.ts` re-export —
125
+ * and no test named it. `SERVER_VERSION` stays a const export with the same
126
+ * readers; the ONLY change is that its value now tracks the release instead of
127
+ * the bootstrap.
128
+ *
129
+ * `SERVER_VERSION`'s module-scope initialization is the single read: the walk
130
+ * runs once at import, and every later reader cell sees the cached result.
131
+ *
132
+ * The read is a walk UP from this module to the package root, bounded and
133
+ * name-checked — the shape specguard-ts landed for the same disease (its
134
+ * fixed `../package.json` read resolved against the module's OWN directory and
135
+ * answered `"0.0.0"` in every built layout). The layouts this bridge ships
136
+ * put the compiled module at `dist/src/server.js`, `.test-build/src/server.js`
137
+ * (the test build), or `src/server.ts` (the dev loader), and an install at
138
+ * `node_modules/specguard-mcp/dist/src/` — in each, walking up finds the
139
+ * manifest that names this package, where a fixed relative read would name
140
+ * `dist/package.json` / `.test-build/package.json` (both absent; `files`
141
+ * ships dist only, so src/ is not even present in an installed tree). The
142
+ * name check keeps an ancestor manifest — a monorepo or a vendoring
143
+ * application's package.json — from being mistaken for this package's, and a
144
+ * tree with no matching manifest answers the `"0.0.0"` sentinel without
145
+ * throwing: `createServer` must never gain a failure mode, and a version
146
+ * that says "unknown" is honest where a crashed boot is not.
147
+ *
148
+ * `start` is the injection seam the tests drive the fallback and name-check
149
+ * arms through: a filesystem path whose directory the walk begins from,
150
+ * defaulting to this module's own file. Production always takes the default;
151
+ * tests pass temp-tree paths so the walk can be exercised in layouts the
152
+ * repo does not ship.
153
+ */
154
+ export function readPackageVersion(start = fileURLToPath(import.meta.url)) {
155
+ const require = createRequire(start);
156
+ let dir = dirname(start);
157
+ for (let depth = 0; depth < 6; depth += 1) {
158
+ try {
159
+ const pkg = require(join(dir, "package.json"));
160
+ if (pkg !== undefined && pkg.name === "specguard-mcp" && typeof pkg.version === "string") {
161
+ return pkg.version;
162
+ }
163
+ }
164
+ catch {
165
+ // No manifest at this level — keep walking toward the root.
166
+ }
167
+ const parent = dirname(dir);
168
+ if (parent === dir)
169
+ break; // the filesystem root
170
+ dir = parent;
171
+ }
172
+ return "0.0.0";
173
+ }
113
174
  //# sourceMappingURL=server.js.map
@@ -1 +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;;;GAqCG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAC/E,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACzB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC1C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAEhC,CAAC;YACd,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACzF,OAAO,GAAG,CAAC,OAAO,CAAC;YACrB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,4DAA4D;QAC9D,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM,CAAC,sBAAsB;QACjD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specguard-mcp",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "MCP server exposing SpecGuard suite intelligence to AI coding agents",
5
5
  "license": "ISC",
6
6
  "type": "module",