granttap-mcp 0.8.135 → 0.8.136
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/apps/bridge/src/bin/runtime/monitor.ts +1 -1
- package/apps/bridge/src/monitor/index.ts +2 -2
- package/apps/bridge/src/monitor/support/leadership.ts +8 -1
- package/apps/bridge/src/monitor/support/runtime.ts +2 -2
- package/apps/bridge/src/reply/process/index.ts +3 -1
- package/apps/bridge/src/sessions/README.md +13 -3
- package/apps/bridge/src/sessions/scan/claude/activity.ts +2 -2
- package/apps/bridge/src/sessions/scan/claude/parse.ts +17 -7
- package/apps/bridge/src/sessions/scan/claude/repository-observation/index.ts +49 -6
- package/apps/bridge/src/sessions/scan/claude/shared.ts +2 -1
- package/apps/bridge/src/sessions/support/activity-helpers.ts +14 -0
- package/apps/bridge/src/sessions/support/repository-checkout/index.ts +23 -2
- package/cursor-plugin/README.md +1 -1
- package/cursor-plugin/mcp.json +1 -1
- package/cursor-plugin/stdio-bootstrap.cjs +1 -1
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ try {
|
|
|
43
43
|
replayPath: join(configDir(), `replay-${cfg.room}.json`),
|
|
44
44
|
peerAllowed: controllerPeerGate(cfg),
|
|
45
45
|
});
|
|
46
|
-
monitor = startSessionMonitor(client);
|
|
46
|
+
monitor = startSessionMonitor(client, { primary: process.env.GRANTTAP_MONITOR_PRIMARY === "1" });
|
|
47
47
|
stopTaskDispatch = startTaskDispatchMonitor({ config: cfg, client,
|
|
48
48
|
isLeader: monitor.isLeader, peerAllowed: controllerPeerGate(cfg), publish: monitor.publish });
|
|
49
49
|
stopTaskNetwork = startTaskNetworkMonitor({ config: cfg, client,
|
|
@@ -16,6 +16,6 @@ export { sweepAttachments, resolveMessageAttachments } from "./handlers/receipts
|
|
|
16
16
|
export { handleUserMessage } from "./handlers/user-message";
|
|
17
17
|
export type { SessionMonitor } from "./support/runtime";
|
|
18
18
|
|
|
19
|
-
export function startSessionMonitor(client: RelayClient) {
|
|
20
|
-
return start(client);
|
|
19
|
+
export function startSessionMonitor(client: RelayClient, options: { primary?: boolean } = {}) {
|
|
20
|
+
return start(client, options);
|
|
21
21
|
}
|
|
@@ -87,13 +87,20 @@ function tryAcquireLock(input: {
|
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Only the installed monitor process may claim to be primary. The flag lives in
|
|
92
|
+
* its environment, and every chat it starts inherits that environment; an MCP
|
|
93
|
+
* server inside such a chat that trusted the variable would take the lease
|
|
94
|
+
* from the real monitor, publish only from its own corner, and leave the phone
|
|
95
|
+
* without the other chats' progress.
|
|
96
|
+
*/
|
|
90
97
|
export function monitorLeadership(
|
|
91
98
|
now: () => number = Date.now,
|
|
92
99
|
report: (message: string) => void = (message) => process.stderr.write(message),
|
|
93
100
|
connected: () => boolean = () => true,
|
|
101
|
+
primary = false,
|
|
94
102
|
): MonitorLeadership {
|
|
95
103
|
const path = join(configDir(), "monitor.lock");
|
|
96
|
-
const primary = process.env.GRANTTAP_MONITOR_PRIMARY === "1";
|
|
97
104
|
const token = `${process.pid}:${randomUUID()}:${primary ? "primary" : "peer"}`;
|
|
98
105
|
let leader = false;
|
|
99
106
|
let reportedAt = 0;
|
|
@@ -173,9 +173,9 @@ async function publishMonitorTick(input: {
|
|
|
173
173
|
* used by MCP tools. This keeps STDIO stdout clean and removes the old need for
|
|
174
174
|
* a separate `granttap-mcp monitor` terminal process.
|
|
175
175
|
*/
|
|
176
|
-
export function startSessionMonitor(client: RelayClient): SessionMonitor {
|
|
176
|
+
export function startSessionMonitor(client: RelayClient, options: { primary?: boolean } = {}): SessionMonitor {
|
|
177
177
|
const subscriptions = new Set<string>();
|
|
178
|
-
const leadership = monitorLeadership(Date.now, undefined, () => client.isConnected);
|
|
178
|
+
const leadership = monitorLeadership(Date.now, undefined, () => client.isConnected, options.primary === true);
|
|
179
179
|
restoreMonitorState(client);
|
|
180
180
|
let historyCache: { generatedAt: number; sessions: SessionsStatus["sessions"] } | undefined;
|
|
181
181
|
let historyRead: Promise<SessionsStatus["sessions"]> | undefined;
|
|
@@ -21,8 +21,10 @@ function projectEnvForCwd(cwd?: string): NodeJS.ProcessEnv {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** A chat started from the phone is not the monitor, whatever the monitor's environment says. */
|
|
24
25
|
export function providerProcessEnvironment(cwd?: string): NodeJS.ProcessEnv {
|
|
25
|
-
const
|
|
26
|
+
const { GRANTTAP_MONITOR_PRIMARY: _monitorOnly, ...inherited } = process.env;
|
|
27
|
+
const env: NodeJS.ProcessEnv = { ...inherited, GRANTTAP_DELIVERY: "1", ...projectEnvForCwd(cwd) };
|
|
26
28
|
const nodeDirectory = dirname(process.execPath);
|
|
27
29
|
env.PATH = [nodeDirectory, ...(env.PATH ?? '').split(delimiter)
|
|
28
30
|
.filter(part => part && part !== nodeDirectory)].join(delimiter);
|
|
@@ -11,9 +11,19 @@ replaces them; checkout verification caches belong to one scan across its yields
|
|
|
11
11
|
|
|
12
12
|
Claude root records update the current working folder and branch as the native
|
|
13
13
|
conversation moves. Its launch directory is not a permanent repository binding.
|
|
14
|
-
Sidechain folders
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Sidechain folders cannot replace the root conversation's checkout. When the
|
|
15
|
+
launch folder is inside a repository, the current folder decides, unless
|
|
16
|
+
sustained recent tool work shows another checkout. When it is a parent folder
|
|
17
|
+
such as `~/dev`, the chat belongs to the repository it most recently changed
|
|
18
|
+
(Write, Edit, MultiEdit, NotebookEdit, or `git -C <path> commit`), found by
|
|
19
|
+
walking up for `.git` without running Git; the current folder decides only
|
|
20
|
+
until such a change is known. Catalog linking verifies the chosen Git root while
|
|
21
|
+
preserving the existing Task and Project identities.
|
|
22
|
+
|
|
23
|
+
A pasted Claude image appears as an attachment. The label Claude Code writes
|
|
24
|
+
beside it (`[Image: source: …]`, `[Image #1]`) is dropped from the chat, title
|
|
25
|
+
and child title when that block holds only labels and the message carries the
|
|
26
|
+
image; any words the person typed with it stay.
|
|
17
27
|
|
|
18
28
|
Claude child reads use only the requested owned log and its bounded recent
|
|
19
29
|
window. Native `agentId` remains authoritative when it differs from the filename;
|
|
@@ -3,7 +3,7 @@ import { createClaudeUsageRecorder } from './recorded-usage';
|
|
|
3
3
|
import { readFileSync, statSync } from "node:fs";
|
|
4
4
|
import type { ActivityEntry, ChildThreadInfo, SessionInfo } from "../../../../../../packages/protocol/schema";
|
|
5
5
|
import { safeParse, ts } from "../../support/common";
|
|
6
|
-
import { classifyTool, estimateTokens, pushEntry as appendEntry, type PushEntryInput, toolDescription, toolSummary } from "../../support/activity-helpers";
|
|
6
|
+
import { classifyTool, estimateTokens, pastedImageLabel, pushEntry as appendEntry, type PushEntryInput, toolDescription, toolSummary } from "../../support/activity-helpers";
|
|
7
7
|
import { childEntryFields } from "../../support/child-threads";
|
|
8
8
|
import { diffPreviewFromInput, patchStatsByToolUse, sensitivePath, statsFromInput } from "../../support/edit-stats";
|
|
9
9
|
import { redactSecrets } from "../../telemetry/command-preview";
|
|
@@ -262,7 +262,7 @@ export function appendClaudeActivity(input: {
|
|
|
262
262
|
pushEntry({ out, seen, sessionId: session.sessionId, kind: "user", text: attachment,
|
|
263
263
|
createdAt, ordinal: index * 100 + blockIndex, extras: { ...childFields, attachments: [attachment] },
|
|
264
264
|
idOverride: claudeMessageIdentity(sourceThreadId, d, line, blockIndex) });
|
|
265
|
-
} else if (block?.type === "text") {
|
|
265
|
+
} else if (block?.type === "text" && !pastedImageLabel(block, content)) {
|
|
266
266
|
pushEntry({ out: out, seen: seen, sessionId: session.sessionId, kind: "user", text: block.text, createdAt: createdAt, ordinal: index * 100 + blockIndex, extras: childFields,
|
|
267
267
|
idOverride: claudeMessageIdentity(sourceThreadId, d, line, blockIndex) });
|
|
268
268
|
}
|
|
@@ -8,8 +8,8 @@ import { observeClaudeTurn } from "./turn-state";
|
|
|
8
8
|
import { LIVE_MS, safeParse, stateFor, ts } from "../../support/common";
|
|
9
9
|
import { finishScan } from "../../cooperative-scan";
|
|
10
10
|
import { claudeCapabilityUsage, createClaudeCapabilityCollector } from "./activity";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { pastedImageLabel } from "../../support/activity-helpers";
|
|
12
|
+
import { claudeChangedPaths, claudeCheckout, claudeRepositoryPaths } from "./repository-observation";
|
|
13
13
|
import {
|
|
14
14
|
childLogsFingerprint,
|
|
15
15
|
claudeChildLogPaths,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type ClaudeParseState = {
|
|
24
24
|
sessionId: string;
|
|
25
25
|
cwd?: string;
|
|
26
|
+
launchCwd?: string;
|
|
26
27
|
branch?: string;
|
|
27
28
|
model?: string;
|
|
28
29
|
title?: string;
|
|
@@ -34,16 +35,24 @@ type ClaudeParseState = {
|
|
|
34
35
|
tokensLastTurn: number;
|
|
35
36
|
contextTokensUsed?: number;
|
|
36
37
|
repositoryPaths: string[];
|
|
38
|
+
changedPaths: string[];
|
|
37
39
|
turnEnded: boolean;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
function applyClaudeLine(d: any, state: ClaudeParseState): void {
|
|
41
43
|
observeClaudeTurn(d, state);
|
|
42
|
-
if (d.isSidechain !== true)
|
|
44
|
+
if (d.isSidechain !== true) {
|
|
45
|
+
state.repositoryPaths.push(...claudeRepositoryPaths(d));
|
|
46
|
+
state.changedPaths.push(...claudeChangedPaths(d));
|
|
47
|
+
}
|
|
43
48
|
state.repositoryPaths = state.repositoryPaths.slice(-64);
|
|
49
|
+
state.changedPaths = state.changedPaths.slice(-64);
|
|
44
50
|
if (d.sessionId && !state.sessionId) state.sessionId = String(d.sessionId);
|
|
45
51
|
if (d.isSidechain !== true) {
|
|
46
|
-
if (typeof d.cwd === "string" && d.cwd.trim())
|
|
52
|
+
if (typeof d.cwd === "string" && d.cwd.trim()) {
|
|
53
|
+
state.cwd = d.cwd;
|
|
54
|
+
state.launchCwd ??= d.cwd;
|
|
55
|
+
}
|
|
47
56
|
if (typeof d.gitBranch === "string" && d.gitBranch.trim()) state.branch = d.gitBranch;
|
|
48
57
|
}
|
|
49
58
|
if (d.type === "ai-title" && typeof d.content === "string" && !state.title) state.title = d.content;
|
|
@@ -53,7 +62,8 @@ function applyClaudeLine(d: any, state: ClaudeParseState): void {
|
|
|
53
62
|
? d.message.content
|
|
54
63
|
: Array.isArray(d.message?.content)
|
|
55
64
|
? d.message.content
|
|
56
|
-
.filter((b: any) => b?.type === "text" && typeof b.text === "string"
|
|
65
|
+
.filter((b: any) => b?.type === "text" && typeof b.text === "string"
|
|
66
|
+
&& !pastedImageLabel(b, d.message.content))
|
|
57
67
|
.map((b: any) => b.text)
|
|
58
68
|
.join("\n")
|
|
59
69
|
: typeof d.content === "string"
|
|
@@ -120,7 +130,7 @@ const TAIL_BYTES = 256;
|
|
|
120
130
|
function newProgress(device: number, inode: number, fallbackSessionId: string): ClaudeParseProgress {
|
|
121
131
|
const state: ClaudeParseState = {
|
|
122
132
|
sessionId: "", startedAt: 0, lastActivityAt: 0, lastMessageAt: 0,
|
|
123
|
-
tokensSession: 0, tokensLastTurn: 0, repositoryPaths: [], turnEnded: false,
|
|
133
|
+
tokensSession: 0, tokensLastTurn: 0, repositoryPaths: [], changedPaths: [], turnEnded: false,
|
|
124
134
|
};
|
|
125
135
|
return { device, inode, offset: 0, tail: Buffer.alloc(0), state, children: new Map(),
|
|
126
136
|
capabilities: createClaudeCapabilityCollector(() => ({ sessionId: state.sessionId || fallbackSessionId,
|
|
@@ -251,7 +261,7 @@ export function* parseClaudeFileSteps(file: string): Generator<void, ClaudeParse
|
|
|
251
261
|
agent: "claude",
|
|
252
262
|
title: state.title,
|
|
253
263
|
cwd: state.cwd,
|
|
254
|
-
worktree: state.cwd ?
|
|
264
|
+
worktree: state.cwd ? claudeCheckout({ ...state, cwd: state.cwd }) : undefined,
|
|
255
265
|
branch: state.branch,
|
|
256
266
|
model: state.model,
|
|
257
267
|
summary: state.summary,
|
|
@@ -1,16 +1,59 @@
|
|
|
1
1
|
import { dirname, isAbsolute } from "node:path";
|
|
2
|
-
import { shellCheckout } from "../../../support/repository-checkout";
|
|
2
|
+
import { observedCheckoutRoot, repositoryRootOf, shellCheckout } from "../../../support/repository-checkout";
|
|
3
|
+
|
|
4
|
+
const FILE_EDITS = ["Write", "Edit", "MultiEdit", "NotebookEdit"];
|
|
5
|
+
|
|
6
|
+
function assistantTools(line: any): any[] {
|
|
7
|
+
if (line.message?.role !== "assistant" || !Array.isArray(line.message.content)) return [];
|
|
8
|
+
return line.message.content.filter((block: any) => block?.type === "tool_use");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function editedFile(input: any): unknown {
|
|
12
|
+
return input.file_path ?? input.notebook_path;
|
|
13
|
+
}
|
|
3
14
|
|
|
4
15
|
/** Writes and explicit shell working directories are stronger evidence than session labels. */
|
|
5
16
|
export function claudeRepositoryPaths(line: any): string[] {
|
|
6
|
-
|
|
7
|
-
return line.message.content.flatMap((block: any) => {
|
|
8
|
-
if (block?.type !== "tool_use") return [];
|
|
17
|
+
return assistantTools(line).flatMap((block: any) => {
|
|
9
18
|
const input = block.input ?? {};
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
const file = editedFile(input);
|
|
20
|
+
if (FILE_EDITS.includes(block.name) && typeof file === "string" && isAbsolute(file)) return [dirname(file)];
|
|
12
21
|
if (block.name !== "Bash") return [];
|
|
13
22
|
const path = shellCheckout(input.command) ?? input.cwd ?? input.workdir;
|
|
14
23
|
return typeof path === "string" && isAbsolute(path) ? [path] : [];
|
|
15
24
|
});
|
|
16
25
|
}
|
|
26
|
+
|
|
27
|
+
/** Paths the agent changed: edited files and folders it committed from. */
|
|
28
|
+
export function claudeChangedPaths(line: any): string[] {
|
|
29
|
+
return assistantTools(line).flatMap((block: any) => {
|
|
30
|
+
const input = block.input ?? {};
|
|
31
|
+
const file = editedFile(input);
|
|
32
|
+
if (FILE_EDITS.includes(block.name)) {
|
|
33
|
+
return typeof file === "string" && isAbsolute(file) ? [dirname(file)] : [];
|
|
34
|
+
}
|
|
35
|
+
if (block.name !== "Bash" || !/\bgit\b[^;&|]*\bcommit\b/.test(String(input.command))) return [];
|
|
36
|
+
const path = shellCheckout(input.command);
|
|
37
|
+
return path ? [path] : [];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A chat launched inside a repository keeps the current-folder rule. One
|
|
43
|
+
* launched from a parent folder such as `~/dev` belongs to the repository it
|
|
44
|
+
* most recently changed, wherever its shell has wandered since.
|
|
45
|
+
*/
|
|
46
|
+
export function claudeCheckout(input: {
|
|
47
|
+
launchCwd?: string;
|
|
48
|
+
cwd: string;
|
|
49
|
+
repositoryPaths: string[];
|
|
50
|
+
changedPaths: string[];
|
|
51
|
+
}): string | undefined {
|
|
52
|
+
if (input.launchCwd && !repositoryRootOf(input.launchCwd)) {
|
|
53
|
+
for (const path of [...input.changedPaths].reverse()) {
|
|
54
|
+
const root = repositoryRootOf(path);
|
|
55
|
+
if (root) return root;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return observedCheckoutRoot(input.cwd, input.repositoryPaths);
|
|
59
|
+
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
classifyTool,
|
|
27
27
|
estimateTokens,
|
|
28
|
+
pastedImageLabel,
|
|
28
29
|
pushEntry,
|
|
29
30
|
toolDescription,
|
|
30
31
|
toolSummary,
|
|
@@ -117,7 +118,7 @@ export function claudeChildSummary(
|
|
|
117
118
|
else if (Array.isArray(content)) {
|
|
118
119
|
title = childTitle(
|
|
119
120
|
content
|
|
120
|
-
.filter((block: any) => block?.type === "text")
|
|
121
|
+
.filter((block: any) => block?.type === "text" && !pastedImageLabel(block, content))
|
|
121
122
|
.map((block: any) => block.text)
|
|
122
123
|
.join("\n"),
|
|
123
124
|
);
|
|
@@ -48,6 +48,20 @@ export function stripTranscriptMarkup(value: unknown): string {
|
|
|
48
48
|
return text.replace(/^\s+|\s+$/g, "");
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
const IMAGE_LABEL = /^\[Image(?: #\d+|: source: .+|: original .+)\]$/;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Claude Code names a pasted image in a text block beside it
|
|
55
|
+
* (`[Image: source: /private/tmp/…]`, `[Image #1]`). With the image itself in
|
|
56
|
+
* the same message, a block of only such labels is not something anyone typed.
|
|
57
|
+
*/
|
|
58
|
+
export function pastedImageLabel(block: any, content: readonly any[]): boolean {
|
|
59
|
+
if (block?.type !== "text" || typeof block.text !== "string") return false;
|
|
60
|
+
const lines = block.text.split("\n").map((line: string) => line.trim()).filter(Boolean);
|
|
61
|
+
return lines.length > 0 && lines.every((line: string) => IMAGE_LABEL.test(line))
|
|
62
|
+
&& content.some((item) => item?.type === "image");
|
|
63
|
+
}
|
|
64
|
+
|
|
51
65
|
/** Remove host-injected transport context that is not a message the person typed. */
|
|
52
66
|
/**
|
|
53
67
|
* The note GrantTap itself appends when a phone message carries attachments,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { realpathSync } from "node:fs";
|
|
4
|
-
import { isAbsolute } from "node:path";
|
|
3
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
4
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
5
5
|
|
|
6
6
|
const checkoutScans = new AsyncLocalStorage<Map<string, string | undefined>>();
|
|
7
7
|
|
|
@@ -51,3 +51,24 @@ export function observedCheckoutRoot(cwd: string, paths: string[]): string | und
|
|
|
51
51
|
const root = choices[0]![0];
|
|
52
52
|
return root === gitRoot(cwd) ? undefined : root;
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
const walkedRoots = new Map<string, { root: string | undefined; at: number }>();
|
|
56
|
+
|
|
57
|
+
/** The repository holding a path, by walking up for `.git`; cheap enough for every journal line. */
|
|
58
|
+
export function repositoryRootOf(path: string): string | undefined {
|
|
59
|
+
if (!isAbsolute(path)) return undefined;
|
|
60
|
+
const now = Date.now();
|
|
61
|
+
const cached = walkedRoots.get(path);
|
|
62
|
+
if (cached && now - cached.at < 60_000) return cached.root;
|
|
63
|
+
let root: string | undefined;
|
|
64
|
+
for (let dir = path; ; dir = dirname(dir)) {
|
|
65
|
+
if (existsSync(join(dir, ".git"))) {
|
|
66
|
+
try { root = realpathSync(dir); } catch { root = dir; }
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
if (dirname(dir) === dir) break;
|
|
70
|
+
}
|
|
71
|
+
if (walkedRoots.size >= 256) walkedRoots.clear();
|
|
72
|
+
walkedRoots.set(path, { root, at: now });
|
|
73
|
+
return root;
|
|
74
|
+
}
|
package/cursor-plugin/README.md
CHANGED
|
@@ -10,7 +10,7 @@ keeps each phone response tied to the exact originating chat and prompt.
|
|
|
10
10
|
Install the supported CLI on this computer, then run:
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm install -g granttap-mcp@0.8.
|
|
13
|
+
npm install -g granttap-mcp@0.8.136
|
|
14
14
|
granttap setup
|
|
15
15
|
granttap status
|
|
16
16
|
```
|
package/cursor-plugin/mcp.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"command": "node",
|
|
5
5
|
"args": [
|
|
6
6
|
"-e",
|
|
7
|
-
"\"use strict\";\n\n// Cursor may start this MCP from any cwd. Execute JavaScript entry points with\n// Node itself: Windows batch shims require shell quoting that differs by host.\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { delimiter, dirname, join } = require(\"node:path\");\n\nconst PACKAGE = \"granttap-mcp@0.8.
|
|
7
|
+
"\"use strict\";\n\n// Cursor may start this MCP from any cwd. Execute JavaScript entry points with\n// Node itself: Windows batch shims require shell quoting that differs by host.\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { delimiter, dirname, join } = require(\"node:path\");\n\nconst PACKAGE = \"granttap-mcp@0.8.136\";\nconst dryRun = process.env.GRANTTAP_BOOTSTRAP_DRY_RUN === \"1\";\nconst platform = dryRun && process.env.GRANTTAP_BOOTSTRAP_PLATFORM\n ? process.env.GRANTTAP_BOOTSTRAP_PLATFORM : process.platform;\nconst nodeRoot = dryRun && process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT\n ? process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT : dirname(process.execPath);\nconst pathRoots = (process.env.PATH || \"\").split(delimiter).filter(Boolean);\nconst appData = process.env.APPDATA;\nconst roots = [nodeRoot, ...pathRoots, ...(appData ? [join(appData, \"npm\")] : [])];\nconst first = (paths) => paths.find((path) => existsSync(path));\n\nfunction launch() {\n if (platform !== \"win32\") {\n const installed = first(roots.map((root) => join(root, \"granttap-mcp\")));\n if (installed) return { command: installed, args: [] };\n const npx = first(roots.map((root) => join(root, \"npx\"))) || \"npx\";\n return { command: npx, args: [\"-y\", PACKAGE] };\n }\n const installed = first(roots.map((root) =>\n join(root, \"node_modules\", \"granttap-mcp\", \"bin\", \"granttap-mcp.mjs\")));\n if (installed) return { command: process.execPath, args: [installed] };\n const npx = first(roots.map((root) =>\n join(root, \"node_modules\", \"npm\", \"bin\", \"npx-cli.js\")));\n if (npx) return { command: process.execPath, args: [npx, \"-y\", PACKAGE] };\n throw new Error(\"Node.js/npm 22.13.0+ is required on this Windows device. Install npm and retry GrantTap.\");\n}\n\nlet target;\ntry { target = launch(); }\ncatch (error) {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n}\n\nif (dryRun) {\n process.stdout.write(JSON.stringify(target));\n process.exit(0);\n}\n\nconst child = spawn(target.command, target.args, { stdio: \"inherit\", windowsHide: true });\nchild.on(\"error\", (error) => {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n});\nchild.on(\"exit\", (code, signal) => {\n if (signal && platform !== \"win32\") {\n try { process.kill(process.pid, signal); } catch { process.exit(code ?? 1); }\n return;\n }\n process.exit(code ?? 1);\n});\n"
|
|
8
8
|
]
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -7,7 +7,7 @@ const { spawn } = require("node:child_process");
|
|
|
7
7
|
const { existsSync } = require("node:fs");
|
|
8
8
|
const { delimiter, dirname, join } = require("node:path");
|
|
9
9
|
|
|
10
|
-
const PACKAGE = "granttap-mcp@0.8.
|
|
10
|
+
const PACKAGE = "granttap-mcp@0.8.136";
|
|
11
11
|
const dryRun = process.env.GRANTTAP_BOOTSTRAP_DRY_RUN === "1";
|
|
12
12
|
const platform = dryRun && process.env.GRANTTAP_BOOTSTRAP_PLATFORM
|
|
13
13
|
? process.env.GRANTTAP_BOOTSTRAP_PLATFORM : process.platform;
|