jamgate 0.4.0 → 0.4.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/dist/index.js +20 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { realpathSync } from "node:fs";
|
|
5
6
|
import { pathToFileURL } from "node:url";
|
|
6
7
|
import { VERSION } from "./version.js";
|
|
7
8
|
import { FileStore } from "./store/fileStore.js";
|
|
@@ -229,8 +230,25 @@ async function main() {
|
|
|
229
230
|
// stdout is the MCP channel; logs must go to stderr.
|
|
230
231
|
console.error("jamgate MCP server running on stdio");
|
|
231
232
|
}
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
/** True when this module is the process entrypoint (run as the CLI), not imported by a test.
|
|
234
|
+
* Must compare against the *realpath* of `process.argv[1]`: npm/npx install the bin as a
|
|
235
|
+
* symlink (`node_modules/.bin/jamgate` → the real `dist/index.js`), so `process.argv[1]` is
|
|
236
|
+
* the symlink path while `import.meta.url` is the resolved target. A naive equality check
|
|
237
|
+
* fails there and `main()` never runs — the wizard exits 0 with no output (the 0.4.0 bug).
|
|
238
|
+
* Resolving the symlink first makes both sides the same real file. */
|
|
239
|
+
function isMainEntrypoint() {
|
|
240
|
+
const entry = process.argv[1];
|
|
241
|
+
if (!entry)
|
|
242
|
+
return false;
|
|
243
|
+
try {
|
|
244
|
+
return import.meta.url === pathToFileURL(realpathSync(entry)).href;
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
// realpathSync throws if the path doesn't exist; fall back to the raw comparison.
|
|
248
|
+
return import.meta.url === pathToFileURL(entry).href;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (isMainEntrypoint()) {
|
|
234
252
|
main().catch((err) => {
|
|
235
253
|
console.error("jamgate fatal:", err);
|
|
236
254
|
process.exit(1);
|
package/dist/version.js
CHANGED
package/package.json
CHANGED