granttap-mcp 0.8.162 → 0.8.164
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.
|
@@ -3,17 +3,43 @@ import { analyzeProjectGraphNow } from "../mesh/runtime";
|
|
|
3
3
|
|
|
4
4
|
const inFlight = new Map<string, Set<string>>();
|
|
5
5
|
|
|
6
|
+
const short = (id: string) => (id.length > 12 ? `${id.slice(0, 12)}…` : id);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The phone's Graph spinner waits for exactly one answer. Without these lines a
|
|
10
|
+
* build that never started, sent nothing or failed looked the same in the log:
|
|
11
|
+
* absent. Ids are opaque Project and request ids, never paths or code.
|
|
12
|
+
*/
|
|
13
|
+
function defaultLog(line: string): void { process.stderr.write(`[monitor] ${line}\n`); }
|
|
14
|
+
|
|
6
15
|
/** One user request starts one analysis per Project, even during reconnect. */
|
|
7
16
|
export function requestProjectGraphRefresh(
|
|
8
17
|
client: RelayClient, projectId: string,
|
|
9
18
|
analyze: typeof analyzeProjectGraphNow = analyzeProjectGraphNow,
|
|
10
19
|
requestId?: string,
|
|
20
|
+
log: (line: string) => void = defaultLog,
|
|
21
|
+
now: () => number = Date.now,
|
|
11
22
|
): boolean {
|
|
23
|
+
const request = requestId ? ` request=${short(requestId)}` : "";
|
|
12
24
|
const pending = inFlight.get(projectId);
|
|
13
|
-
if (pending) {
|
|
25
|
+
if (pending) {
|
|
26
|
+
if (requestId) pending.add(requestId);
|
|
27
|
+
log(`Graph build requested project=${short(projectId)}${request}; joined the build already running.`);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
14
30
|
const receipts = new Set(requestId ? [requestId] : []);
|
|
15
31
|
inFlight.set(projectId, receipts);
|
|
16
|
-
|
|
32
|
+
const started = now();
|
|
33
|
+
log(`Graph build requested project=${short(projectId)}${request}; started.`);
|
|
34
|
+
const seconds = () => ((now() - started) / 1000).toFixed(1);
|
|
35
|
+
void analyze(client, projectId, undefined, receipts).then((answered) => {
|
|
36
|
+
log(answered
|
|
37
|
+
? `Graph build project=${short(projectId)} finished in ${seconds()} s; answer sent for ${Math.max(receipts.size, 1)} request(s).`
|
|
38
|
+
: `Graph build project=${short(projectId)} sent no answer after ${seconds()} s: this computer has no Mesh snapshot or bound repository for it.`);
|
|
39
|
+
}, (error: unknown) => {
|
|
40
|
+
const cause = error instanceof Error ? `${error.name}: ${error.message}`.slice(0, 200) : "unknown error";
|
|
41
|
+
log(`Graph build project=${short(projectId)} failed after ${seconds()} s (${cause}); the phone gets no answer.`);
|
|
42
|
+
}).finally(() => {
|
|
17
43
|
inFlight.delete(projectId);
|
|
18
44
|
});
|
|
19
45
|
return true;
|
|
@@ -6,25 +6,38 @@ import { grantTaskAutomation } from ".";
|
|
|
6
6
|
|
|
7
7
|
export type GrantRejection = "ambiguous_session" | "approval_unavailable" | "policy_changed";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A request waits in the phone's list for as long as the person takes to open
|
|
11
|
+
* it. Five minutes, the hook's own pending window, refused nearly every grant
|
|
12
|
+
* made from the request's details; a still-pending request stays grantable.
|
|
13
|
+
*/
|
|
14
|
+
export const GRANT_PENDING_AGE_MS = 6 * 60 * 60_000;
|
|
15
|
+
|
|
9
16
|
/** Bind a controller's choice to the exact request and policy it displayed. */
|
|
10
17
|
export function applyControllerGrant(session: NonNullable<ConfigSet["autoAcceptSession"]>,
|
|
11
18
|
now: number): GrantRejection | undefined {
|
|
12
19
|
const mappedProject = projectIdForSession(session.sessionId);
|
|
13
20
|
if (mappedProject === null) return "ambiguous_session";
|
|
14
21
|
let projectId = mappedProject;
|
|
22
|
+
// A hook that could not read the Project's revision leaves the request
|
|
23
|
+
// unstamped, and the phone then shows and returns none. Refusing that as a
|
|
24
|
+
// policy change made every grant from such a request fail; it binds to the
|
|
25
|
+
// revision in force now, which still applies every Project rule.
|
|
26
|
+
let unstamped = false;
|
|
15
27
|
if (session.approvalRequestId) {
|
|
16
28
|
const record = readRawRecord(session.approvalRequestId);
|
|
17
29
|
if (!record || record.state !== "pending" || record.request.sessionId !== session.sessionId
|
|
18
|
-
|| now - record.updatedAt > MAX_PENDING_AGE_MS) return "approval_unavailable";
|
|
30
|
+
|| now - record.updatedAt > Math.max(MAX_PENDING_AGE_MS, GRANT_PENDING_AGE_MS)) return "approval_unavailable";
|
|
19
31
|
const request = record.request;
|
|
20
32
|
if (projectId && request.projectId && projectId !== request.projectId) return "ambiguous_session";
|
|
21
33
|
projectId ??= request.projectId;
|
|
22
34
|
if (request.policyRevision !== session.expectedPolicyRevision) return "policy_changed";
|
|
35
|
+
unstamped = request.policyRevision == null;
|
|
23
36
|
}
|
|
24
37
|
if (projectId) {
|
|
25
38
|
const revision = governedRevision(projectId) ?? 0;
|
|
26
|
-
if ((revision > 0 && session.expectedPolicyRevision == null)
|
|
27
|
-
|| (session.expectedPolicyRevision != null && session.expectedPolicyRevision !== revision)) {
|
|
39
|
+
if (!unstamped && ((revision > 0 && session.expectedPolicyRevision == null)
|
|
40
|
+
|| (session.expectedPolicyRevision != null && session.expectedPolicyRevision !== revision))) {
|
|
28
41
|
return "policy_changed";
|
|
29
42
|
}
|
|
30
43
|
grantTaskAutomation(session.sessionId, projectId, revision, session.level);
|
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.164
|
|
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.164\";\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.164";
|
|
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;
|