granttap-mcp 0.8.81 → 0.8.83
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 -1
- package/THIRD_PARTY_LICENSES.txt +2 -2
- package/apps/bridge/src/engine/distribution/artifacts.ts +6 -6
- package/apps/bridge/src/engine/protocol/transport/code-checks/README.md +11 -0
- package/apps/bridge/src/engine/protocol/transport/code-checks/index.ts +14 -0
- package/apps/bridge/src/engine/protocol/transport/protocol-types.ts +3 -1
- package/apps/bridge/src/engine/protocol/transport/result-parser.ts +2 -0
- package/apps/bridge/src/engine/runtime/engine-projects.ts +2 -14
- package/apps/bridge/src/engine/runtime/repository-graph/README.md +20 -0
- package/apps/bridge/src/engine/runtime/repository-graph/fit.ts +32 -9
- package/apps/bridge/src/engine/runtime/repository-graph/source-map.ts +21 -0
- package/apps/bridge/src/engine/runtime/repository-graph/source-sampling.ts +39 -0
- package/apps/bridge/src/mesh/runtime/graph/README.md +4 -2
- package/apps/bridge/src/mesh/runtime/graph/analysis.ts +13 -3
- package/apps/bridge/src/mesh/runtime/graph/binding-sync.ts +1 -1
- package/apps/bridge/src/mesh/runtime/graph/checkout-identity.ts +26 -3
- package/apps/bridge/src/mesh/runtime/snapshot/enriched.ts +1 -1
- 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
- package/packages/protocol/messages/mesh/graph/code-map.ts +6 -0
package/README.md
CHANGED
|
@@ -239,7 +239,17 @@ manual rebuilds join pending work and return their own delivery receipts.
|
|
|
239
239
|
Usable reports persist privately on the computer across MCP restarts, while
|
|
240
240
|
the phone keeps its last received map visible during a rebuild. Source Git
|
|
241
241
|
revision and analysis content fingerprint are separate freshness facts.
|
|
242
|
-
Partial and unavailable reports retain their scope and status.
|
|
242
|
+
Partial and unavailable reports retain their scope and status. Health separates
|
|
243
|
+
report freshness from completeness and offers local filtering, sorting and
|
|
244
|
+
diagnostics options. The code city has an independent legend, symbol-kind and
|
|
245
|
+
size colours, label and relation controls, and optional measured code checks.
|
|
246
|
+
|
|
247
|
+
Engine source checks carry measured function extent, a token-based cyclomatic
|
|
248
|
+
estimate, loop nesting and resolved call fan-in. The clients compare those
|
|
249
|
+
measurements with the selected thresholds. Green means within those checks; red
|
|
250
|
+
means review a threshold; unmeasured code remains unknown. Correctness, test
|
|
251
|
+
coverage and runtime performance are not inferred. Analysis uses this computer's
|
|
252
|
+
verified Git checkout roots, observed revision and local Git exclusions.
|
|
243
253
|
|
|
244
254
|
<p align="center">
|
|
245
255
|
<img src="docs/images/iphone-chat-work-summary.png" width="200" alt="Files and Agents above the composer with deterministic sample work">
|
package/THIRD_PARTY_LICENSES.txt
CHANGED
|
@@ -324,8 +324,8 @@ hasown 2.0.4 — MIT
|
|
|
324
324
|
Source: https://www.npmjs.com/package/hasown/v/2.0.4
|
|
325
325
|
Notices: bf9b0d665be2a689851eea667ca9f42066ea1d903b38349c51e6a44b2577680a
|
|
326
326
|
|
|
327
|
-
hono 4.13.
|
|
328
|
-
Source: https://www.npmjs.com/package/hono/v/4.13.
|
|
327
|
+
hono 4.13.13 — MIT
|
|
328
|
+
Source: https://www.npmjs.com/package/hono/v/4.13.13
|
|
329
329
|
Notices: a6ab98e5c77b9070c443eaff2ff81034a6f8cc05a7524d5098eb0f24defa0115
|
|
330
330
|
|
|
331
331
|
http-errors 2.0.1 — MIT
|
|
@@ -8,12 +8,12 @@ export type EngineArtifact = {
|
|
|
8
8
|
|
|
9
9
|
/** Release hashes are part of the reviewed MCP, never supplied by a remote manifest. */
|
|
10
10
|
export const ENGINE_ARTIFACTS: readonly EngineArtifact[] = [
|
|
11
|
-
{ version: "0.1.
|
|
12
|
-
sha256: "
|
|
13
|
-
{ version: "0.1.
|
|
14
|
-
sha256: "
|
|
15
|
-
{ version: "0.1.
|
|
16
|
-
sha256: "
|
|
11
|
+
{ version: "0.1.2", platform: "darwin", arch: "arm64",
|
|
12
|
+
sha256: "fa23668f2f2cbb716a0ba66c5a6e027a25ed4e7e2dedf0c870edb32199045b97", bytes: 12101408 },
|
|
13
|
+
{ version: "0.1.2", platform: "darwin", arch: "x64",
|
|
14
|
+
sha256: "b3235a15936a77ec323d5ecbc54a0bc19994fe6e5a36044da964b68524b4c1dd", bytes: 13944984 },
|
|
15
|
+
{ version: "0.1.2", platform: "linux", arch: "x64",
|
|
16
|
+
sha256: "1a6b227289b69459a64cd13078044960cf83bb858e6be1b70b1b38c950b00cc0", bytes: 14753312 },
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
export function selectEngineArtifact(platform: string = process.platform, arch: string = process.arch): EngineArtifact | undefined {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Measured source checks
|
|
2
|
+
|
|
3
|
+
Public entry: `index.ts`. The Engine response parser admits optional, measured
|
|
4
|
+
function size, token-based complexity, nesting and resolved call fan-in. Absent
|
|
5
|
+
measurements stay absent. Malformed, negative and out-of-range values fail the
|
|
6
|
+
response instead of becoming healthy zeroes.
|
|
7
|
+
|
|
8
|
+
Integration tests: `runtime/repository-graph/tests/code-checks.test.ts`, relative
|
|
9
|
+
to the Engine module. The additive fields remain compatible with older Engines.
|
|
10
|
+
|
|
11
|
+
License: GrantTap Commercial Source License; see the repository LICENSE.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EngineProtocolError } from "../protocol-base";
|
|
2
|
+
|
|
3
|
+
/** Missing checks stay unknown; present checks must be bounded measurements. */
|
|
4
|
+
export function parseCodeChecks(value: unknown): void {
|
|
5
|
+
if (value == null) return;
|
|
6
|
+
const checks = value as Record<string, unknown>;
|
|
7
|
+
if (typeof checks !== "object" || Array.isArray(checks) || checks.measured !== true
|
|
8
|
+
|| !["source_lines", "cyclomatic", "max_loop_depth", "callers"].every(key =>
|
|
9
|
+
Number.isSafeInteger(checks[key]) && Number(checks[key]) >=
|
|
10
|
+
(["source_lines", "cyclomatic"].includes(key) ? 1 : 0)
|
|
11
|
+
&& Number(checks[key]) <= 0xffff_ffff)) {
|
|
12
|
+
throw new EngineProtocolError("invalid measured code checks");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -49,7 +49,9 @@ export type EngineRepositoryGraph = {
|
|
|
49
49
|
code_map?: {
|
|
50
50
|
files: Array<{ path: string; language: string | null; line_count: number | null;
|
|
51
51
|
symbols: Array<{ id: string; label: string; kind: string;
|
|
52
|
-
start_line: number; line_count: number
|
|
52
|
+
start_line: number; line_count: number;
|
|
53
|
+
metrics?: { measured: boolean; source_lines: number; cyclomatic: number;
|
|
54
|
+
max_loop_depth: number; callers: number } }> }>;
|
|
53
55
|
externals?: Array<{ id: string; label: string; kind: string }>;
|
|
54
56
|
roads: Array<{ source: string; target: string; relation: string }>;
|
|
55
57
|
total_files: number;
|
|
@@ -4,6 +4,7 @@ import { parsePolicyResult } from "../engine-policy-protocol";
|
|
|
4
4
|
import { parseImpactResult } from "../impact/engine-impact-protocol";
|
|
5
5
|
import { parseEngineIdentityResult } from "./identity-result-parser";
|
|
6
6
|
import { parseProjectCatalog } from "./project-catalog-parser";
|
|
7
|
+
import { parseCodeChecks } from "./code-checks";
|
|
7
8
|
import {
|
|
8
9
|
ENGINE_PROTOCOL_VERSION,
|
|
9
10
|
EngineProtocolError,
|
|
@@ -186,6 +187,7 @@ function parseCodeMap(value: unknown): void {
|
|
|
186
187
|
requireBoundedString(symbol.id, "code symbol id", 512);
|
|
187
188
|
requireBoundedString(symbol.label, "code symbol label", 160);
|
|
188
189
|
requireBoundedString(symbol.kind, "code symbol kind", 64);
|
|
190
|
+
parseCodeChecks(symbol.metrics);
|
|
189
191
|
if (!Number.isSafeInteger(symbol.start_line) || Number(symbol.start_line) < 1
|
|
190
192
|
|| !Number.isSafeInteger(symbol.line_count) || Number(symbol.line_count) < 1) invalidResult();
|
|
191
193
|
}
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
import { RepositoryGraphJobs } from "./repository-graph-jobs";
|
|
18
18
|
import { fitRepositoryGraph } from "./repository-graph/fit";
|
|
19
19
|
import { RepositoryGraphCache } from "./repository-graph/cache";
|
|
20
|
+
import { repositorySourceMap } from "./repository-graph/source-map";
|
|
20
21
|
|
|
21
22
|
export type LocalProjectBinding = {
|
|
22
23
|
summary: ProjectBindingSummary;
|
|
@@ -229,20 +230,7 @@ async function analyzeRepositoryGraph(
|
|
|
229
230
|
analysisId: graph.analysis_id ?? undefined,
|
|
230
231
|
analysisStatus: graph.analysis_status,
|
|
231
232
|
architectureHypotheses: graph.architecture_hypotheses,
|
|
232
|
-
codeMap: graph
|
|
233
|
-
files: graph.code_map.files.map((file) => ({
|
|
234
|
-
path: file.path, language: file.language, lineCount: file.line_count,
|
|
235
|
-
symbols: file.symbols.map((symbol) => ({
|
|
236
|
-
id: symbol.id, label: symbol.label, kind: symbol.kind,
|
|
237
|
-
startLine: symbol.start_line, lineCount: symbol.line_count,
|
|
238
|
-
})),
|
|
239
|
-
})),
|
|
240
|
-
externals: graph.code_map.externals ?? [],
|
|
241
|
-
roads: graph.code_map.roads,
|
|
242
|
-
totalFiles: graph.code_map.total_files,
|
|
243
|
-
totalExternals: graph.code_map.total_externals ?? 0,
|
|
244
|
-
truncated: graph.code_map.truncated,
|
|
245
|
-
} : undefined,
|
|
233
|
+
codeMap: repositorySourceMap(graph),
|
|
246
234
|
nodes: graph.nodes,
|
|
247
235
|
relations: graph.relations.map((edge) => ({
|
|
248
236
|
source: edge.source, target: edge.target, relation: edge.relation,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Repository graph delivery
|
|
2
|
+
|
|
3
|
+
[Runtime entry point](../engine-projects.ts) · [Wire fitting](fit.ts)
|
|
4
|
+
|
|
5
|
+
The encrypted Mesh snapshot carries bounded, observed repository metadata.
|
|
6
|
+
`fitRepositoryGraph` preserves file identities, measured LOC and source sections.
|
|
7
|
+
When directed file links dominate the wire budget, it reduces those links before
|
|
8
|
+
discarding source sections. The bounded sample keeps links reaching previously
|
|
9
|
+
unrepresented files and external services, then fills in original report order.
|
|
10
|
+
It never invents links, reverses their direction, or edits the engine report.
|
|
11
|
+
|
|
12
|
+
Remaining reductions retain the existing wire limit and mark partial evidence.
|
|
13
|
+
The persistent cache keeps a last successful bounded report through an MCP
|
|
14
|
+
restart while the normal observation refresh obtains current engine evidence.
|
|
15
|
+
|
|
16
|
+
Behavior tests live in `tests/`; runtime and cache integration scenarios remain
|
|
17
|
+
under the repository's `tests/engine` harness.
|
|
18
|
+
|
|
19
|
+
License: this module is distributed under the GrantTap Commercial Source License
|
|
20
|
+
in the repository-root `LICENSE` file.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProjectRepositoryGraph } from "../../../../../../packages/protocol/schema";
|
|
2
|
+
import { representativeSourcePaths, canReduceSymbols, sampleSymbols } from "./source-sampling";
|
|
2
3
|
|
|
3
4
|
type CodeMap = NonNullable<ProjectRepositoryGraph["codeMap"]>;
|
|
4
5
|
type Relation = ProjectRepositoryGraph["relations"][number];
|
|
@@ -16,7 +17,12 @@ export function fitRepositoryGraph(
|
|
|
16
17
|
}
|
|
17
18
|
while (bytes() > maxBytes) {
|
|
18
19
|
const map = bounded.codeMap;
|
|
19
|
-
|
|
20
|
+
// Dense import graphs must not consume the source-section budget. Keep
|
|
21
|
+
// observed directed links across the inventory before reducing symbols.
|
|
22
|
+
if (map && map.roads.length > 16
|
|
23
|
+
&& Buffer.byteLength(JSON.stringify(map.roads), "utf8") > maxBytes / 3) {
|
|
24
|
+
bounded = { ...bounded, codeMap: trimRoads(map) };
|
|
25
|
+
} else if (map && canReduceSymbols(map)) {
|
|
20
26
|
bounded = { ...bounded, codeMap: trimSymbols(map) };
|
|
21
27
|
} else if (bounded.relations.length > 8) {
|
|
22
28
|
bounded = { ...bounded, relations: strongestRelations(bounded.relations,
|
|
@@ -27,8 +33,7 @@ export function fitRepositoryGraph(
|
|
|
27
33
|
bounded = { ...bounded, nodes, relations: bounded.relations.filter((edge) =>
|
|
28
34
|
ids.has(edge.source) && ids.has(edge.target)), truncated: true };
|
|
29
35
|
} else if (map && map.roads.length > 16) {
|
|
30
|
-
bounded = { ...bounded, codeMap:
|
|
31
|
-
roads: map.roads.slice(0, Math.ceil(map.roads.length / 2)) } };
|
|
36
|
+
bounded = { ...bounded, codeMap: trimRoads(map) };
|
|
32
37
|
} else if (map && map.files.length > 8) {
|
|
33
38
|
bounded = { ...bounded, codeMap: trimFiles(map) };
|
|
34
39
|
} else if (map) {
|
|
@@ -40,6 +45,20 @@ export function fitRepositoryGraph(
|
|
|
40
45
|
return bounded;
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
function trimRoads(map: CodeMap): CodeMap {
|
|
49
|
+
const limit = Math.max(16, Math.ceil(map.roads.length / 2));
|
|
50
|
+
const kept = new Set<number>(), endpoints = new Set<string>();
|
|
51
|
+
for (const [index, road] of map.roads.entries()) {
|
|
52
|
+
if (kept.size === limit) break;
|
|
53
|
+
if (endpoints.has(road.source) && endpoints.has(road.target)) continue;
|
|
54
|
+
kept.add(index);
|
|
55
|
+
endpoints.add(road.source);
|
|
56
|
+
endpoints.add(road.target);
|
|
57
|
+
}
|
|
58
|
+
for (let index = 0; kept.size < limit; index++) kept.add(index);
|
|
59
|
+
return { ...map, truncated: true, roads: map.roads.filter((_, index) => kept.has(index)) };
|
|
60
|
+
}
|
|
61
|
+
|
|
43
62
|
function strongestRelations(relations: Relation[], limit: number): Relation[] {
|
|
44
63
|
return relations.map((edge, index) => ({ edge, index }))
|
|
45
64
|
.sort((left, right) => (right.edge.evidenceCount ?? 0) - (left.edge.evidenceCount ?? 0)
|
|
@@ -57,27 +76,31 @@ function roadDegree(map: CodeMap): Map<string, number> {
|
|
|
57
76
|
return degree;
|
|
58
77
|
}
|
|
59
78
|
|
|
60
|
-
function rankedFiles(map: CodeMap): CodeMap["files"] {
|
|
79
|
+
function rankedFiles(map: CodeMap, preserveSource = false): CodeMap["files"] {
|
|
61
80
|
const degree = roadDegree(map);
|
|
81
|
+
const representatives = preserveSource ? representativeSourcePaths(map) : new Set<string>();
|
|
62
82
|
return [...map.files].sort((left, right) =>
|
|
63
|
-
(
|
|
83
|
+
Number(representatives.has(right.path)) - Number(representatives.has(left.path))
|
|
84
|
+
|| (preserveSource ? Number(right.symbols.length > 0) - Number(left.symbols.length > 0) : 0)
|
|
85
|
+
|| (degree.get(right.path) ?? 0) - (degree.get(left.path) ?? 0)
|
|
64
86
|
|| (right.lineCount ?? 0) - (left.lineCount ?? 0)
|
|
65
87
|
|| left.path.localeCompare(right.path));
|
|
66
88
|
}
|
|
67
89
|
|
|
68
90
|
function trimSymbols(map: CodeMap): CodeMap {
|
|
69
91
|
const ranked = rankedFiles(map).filter((file) => file.symbols.length > 0);
|
|
70
|
-
|
|
92
|
+
if (ranked.length <= 16) return { ...map, truncated: true,
|
|
93
|
+
files: map.files.map(file => ({ ...file, symbols: sampleSymbols(file.symbols) })) };
|
|
94
|
+
const candidates = [...representativeSourcePaths(map), ...ranked.map(file => file.path)];
|
|
95
|
+
const keep = new Set([...new Set(candidates)].slice(0, Math.max(16, Math.floor(ranked.length / 2))));
|
|
71
96
|
return { ...map, truncated: true, files: map.files.map((file) => {
|
|
72
97
|
if (!keep.has(file.path)) return { ...file, symbols: [] };
|
|
73
|
-
if (ranked.length === 1) return { ...file, symbols: file.symbols.slice(0,
|
|
74
|
-
Math.floor(file.symbols.length / 2)) };
|
|
75
98
|
return file;
|
|
76
99
|
}) };
|
|
77
100
|
}
|
|
78
101
|
|
|
79
102
|
function trimFiles(map: CodeMap): CodeMap {
|
|
80
|
-
const files = rankedFiles(map).slice(0, Math.ceil(map.files.length / 2))
|
|
103
|
+
const files = rankedFiles(map, true).slice(0, Math.ceil(map.files.length / 2))
|
|
81
104
|
.sort((left, right) => left.path.localeCompare(right.path));
|
|
82
105
|
const paths = new Set(files.map((file) => file.path));
|
|
83
106
|
for (const external of map.externals ?? []) paths.add(external.id);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EngineRepositoryGraph } from "../../protocol/engine-protocol";
|
|
2
|
+
import type { ProjectCodeMap } from "../../../../../../packages/protocol/messages/mesh/graph/code-map";
|
|
3
|
+
|
|
4
|
+
/** Preserve optional source checks without turning absent measurements into zero. */
|
|
5
|
+
export function repositorySourceMap(graph: EngineRepositoryGraph): ProjectCodeMap | undefined {
|
|
6
|
+
const map = graph.code_map;
|
|
7
|
+
if (!map) return undefined;
|
|
8
|
+
return {
|
|
9
|
+
files: map.files.map(file => ({ path: file.path, language: file.language, lineCount: file.line_count,
|
|
10
|
+
symbols: file.symbols.map(symbol => ({
|
|
11
|
+
id: symbol.id, label: symbol.label, kind: symbol.kind, startLine: symbol.start_line, lineCount: symbol.line_count,
|
|
12
|
+
...(symbol.metrics?.measured === true ? { metrics: {
|
|
13
|
+
measured: true as const, sourceLines: symbol.metrics.source_lines, cyclomatic: symbol.metrics.cyclomatic,
|
|
14
|
+
maxLoopDepth: symbol.metrics.max_loop_depth, callers: symbol.metrics.callers,
|
|
15
|
+
} } : {}),
|
|
16
|
+
})),
|
|
17
|
+
})),
|
|
18
|
+
externals: map.externals ?? [], roads: map.roads, totalFiles: map.total_files,
|
|
19
|
+
totalExternals: map.total_externals ?? 0, truncated: map.truncated,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ProjectRepositoryGraph } from "../../../../../../packages/protocol/schema";
|
|
2
|
+
|
|
3
|
+
type CodeMap = NonNullable<ProjectRepositoryGraph["codeMap"]>;
|
|
4
|
+
type Symbol = CodeMap["files"][number]["symbols"][number];
|
|
5
|
+
|
|
6
|
+
/** Reserve actual measured checks and a small sample of distinct source kinds. */
|
|
7
|
+
export function representativeSourcePaths(map: CodeMap): Set<string> {
|
|
8
|
+
const paths = new Set<string>();
|
|
9
|
+
const measured = map.files.find(file => file.symbols.some(symbol => symbol.metrics?.measured));
|
|
10
|
+
if (measured) paths.add(measured.path);
|
|
11
|
+
const kinds = new Set<string>();
|
|
12
|
+
for (const file of map.files) for (const symbol of file.symbols) {
|
|
13
|
+
if (kinds.has(symbol.kind) || paths.size >= 8) continue;
|
|
14
|
+
kinds.add(symbol.kind); paths.add(file.path);
|
|
15
|
+
}
|
|
16
|
+
return paths;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function canReduceSymbols(map: CodeMap): boolean {
|
|
20
|
+
return map.files.filter(file => file.symbols.length > 0).length > 16
|
|
21
|
+
|| map.files.some(file => file.symbols.length > 1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function sampleSymbols(symbols: Symbol[]): Symbol[] {
|
|
25
|
+
if (symbols.length <= 1) return symbols;
|
|
26
|
+
const keep = new Set<Symbol>(), kinds = new Set<string>();
|
|
27
|
+
const limit = Math.max(1, Math.floor(symbols.length / 2));
|
|
28
|
+
const measured = symbols.find(symbol => symbol.metrics?.measured);
|
|
29
|
+
if (measured) { keep.add(measured); kinds.add(measured.kind); }
|
|
30
|
+
for (const symbol of symbols) {
|
|
31
|
+
if (keep.size >= limit) break;
|
|
32
|
+
if (!kinds.has(symbol.kind)) { keep.add(symbol); kinds.add(symbol.kind); }
|
|
33
|
+
}
|
|
34
|
+
for (const symbol of symbols) {
|
|
35
|
+
if (keep.size >= limit) break;
|
|
36
|
+
keep.add(symbol);
|
|
37
|
+
}
|
|
38
|
+
return symbols.filter(symbol => keep.has(symbol));
|
|
39
|
+
}
|
|
@@ -11,8 +11,10 @@ remote claim. Changed remote identities and local paths to different checkouts
|
|
|
11
11
|
remain rejected. Neither Task identity nor Project membership is rewritten.
|
|
12
12
|
|
|
13
13
|
After admission, `graphAnalysisBindings` selects one graph per endpoint and real
|
|
14
|
-
checkout path, preferring
|
|
15
|
-
|
|
14
|
+
checkout path, preferring the currently verified canonical binding over retired aliases.
|
|
15
|
+
Observed Git revisions replace old catalog observations in admission and report
|
|
16
|
+
provenance. A subfolder with a remembered parent commit is not a checkout. Each
|
|
17
|
+
computer analyzes only its own endpoint bindings. Failed bindings remain visible with their original error. Both the Mac
|
|
16
18
|
projection and phone refresh use this rule. The graph contains actual Engine
|
|
17
19
|
analysis; unavailable analysis is never synthesized as a successful graph.
|
|
18
20
|
|
|
@@ -6,6 +6,8 @@ import { publishedCatalog } from "../../../session-catalog";
|
|
|
6
6
|
import { meshSnapshot, meshSnapshots } from "..";
|
|
7
7
|
import { refreshLocalGraphBindings } from "./binding-sync";
|
|
8
8
|
import { graphAnalysisBindings } from "./checkout-identity";
|
|
9
|
+
import { computerId } from "../../identity/computer";
|
|
10
|
+
import { repositoryDetails } from "../../repository-details";
|
|
9
11
|
|
|
10
12
|
/** A person's explicit Graph refresh bypasses background job backoff. */
|
|
11
13
|
type GraphAnalysisDependencies = {
|
|
@@ -16,6 +18,8 @@ type GraphAnalysisDependencies = {
|
|
|
16
18
|
backbone: typeof projectBackbone;
|
|
17
19
|
graphs: typeof projectRepositoryGraphs;
|
|
18
20
|
send: (client: RelayClient, snapshot: MeshSnapshot) => Promise<void>;
|
|
21
|
+
endpoint?: () => string;
|
|
22
|
+
details?: (snapshot: MeshSnapshot) => ReturnType<typeof repositoryDetails>;
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
const graphAnalysisDependencies: GraphAnalysisDependencies = {
|
|
@@ -24,6 +28,8 @@ const graphAnalysisDependencies: GraphAnalysisDependencies = {
|
|
|
24
28
|
sync: refreshLocalGraphBindings,
|
|
25
29
|
backbone: projectBackbone,
|
|
26
30
|
graphs: projectRepositoryGraphs,
|
|
31
|
+
endpoint: computerId,
|
|
32
|
+
details: snapshot => repositoryDetails(snapshot, computerId()),
|
|
27
33
|
send: (client, snapshot) => sendMeshPayload(client, snapshot, "phone", {
|
|
28
34
|
ttlMs: 60_000, reliable: true,
|
|
29
35
|
}),
|
|
@@ -47,10 +53,13 @@ export async function analyzeProjectGraphNow(
|
|
|
47
53
|
if (!current) return false;
|
|
48
54
|
const failures = dependencies.sync ? await dependencies.sync(current) : [];
|
|
49
55
|
const rejected = new Set(failures.map(report => report.repositoryId));
|
|
50
|
-
const
|
|
56
|
+
const bindings = graphAnalysisBindings((current.bindings ?? [])
|
|
57
|
+
.filter(binding => !rejected.has(binding.repositoryId)), dependencies.endpoint?.());
|
|
58
|
+
if (dependencies.endpoint && !bindings.length && !failures.length && current.bindings?.length) return false;
|
|
59
|
+
const [backbone, repositoryGraphs, details] = await Promise.all([
|
|
51
60
|
dependencies.backbone(projectId),
|
|
52
|
-
dependencies.graphs(projectId,
|
|
53
|
-
|
|
61
|
+
dependencies.graphs(projectId, bindings, { background: false }),
|
|
62
|
+
dependencies.details?.(current),
|
|
54
63
|
]);
|
|
55
64
|
const observed = [...repositoryGraphs, ...failures];
|
|
56
65
|
const reports = observed.length > 0 ? observed : [{
|
|
@@ -63,6 +72,7 @@ export async function analyzeProjectGraphNow(
|
|
|
63
72
|
for (const id of receipts) {
|
|
64
73
|
await dependencies.send(client, {
|
|
65
74
|
...current, backbone, repositoryGraphs: reports, generatedAt: Date.now(),
|
|
75
|
+
...(details ? { repositoryDetails: details } : {}),
|
|
66
76
|
...(id ? { graphAnalysisRequestId: id } : {}),
|
|
67
77
|
});
|
|
68
78
|
}
|
|
@@ -44,7 +44,7 @@ export async function refreshLocalGraphBindings(
|
|
|
44
44
|
}
|
|
45
45
|
try {
|
|
46
46
|
const admitted = await dependencies.sync(snapshot.project, {
|
|
47
|
-
summary: binding,
|
|
47
|
+
summary: { ...binding, revision: facts.revision ?? binding.revision },
|
|
48
48
|
localRoot: facts.root,
|
|
49
49
|
// A local binding is scoped by its verified path. Do not relabel it as
|
|
50
50
|
// a remote repository or move it into that repository's Project scope.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { isAbsolute } from "node:path";
|
|
3
3
|
import type { ProjectBindingSummary } from "../../../../../../packages/protocol/schema";
|
|
4
|
+
import { inspectRepository, type RepositoryFacts } from "../../catalog";
|
|
4
5
|
|
|
5
6
|
/** Local identities name an exact directory, even after that directory gains an origin. */
|
|
6
7
|
export function matchesLocalCheckout(repositoryId: string, root: string): boolean {
|
|
@@ -12,17 +13,39 @@ export function matchesLocalCheckout(repositoryId: string, root: string): boolea
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/** Once admitted, one checkout contributes one graph to this Mesh. */
|
|
15
|
-
export function graphAnalysisBindings(bindings: ProjectBindingSummary[]): ProjectBindingSummary[] {
|
|
16
|
+
export function graphAnalysisBindings(bindings: ProjectBindingSummary[], endpointId?: string): ProjectBindingSummary[] {
|
|
16
17
|
const selected = new Map<string, ProjectBindingSummary>();
|
|
18
|
+
const observations = new Map<string, RepositoryFacts | undefined>();
|
|
19
|
+
const nonRepositories = new Set<string>();
|
|
20
|
+
const ranks = new Map<string, number>();
|
|
17
21
|
for (const binding of bindings) {
|
|
22
|
+
if (endpointId && binding.endpointId !== endpointId) continue;
|
|
18
23
|
let path: string | undefined;
|
|
19
24
|
if (binding.available && binding.localPathHint) {
|
|
20
25
|
try { path = realpathSync(binding.localPathHint); } catch { /* Keep an unavailable checkout distinct. */ }
|
|
21
26
|
}
|
|
27
|
+
if (path && !observations.has(path)) {
|
|
28
|
+
let facts: RepositoryFacts | undefined;
|
|
29
|
+
try {
|
|
30
|
+
const observed = inspectRepository(path);
|
|
31
|
+
if (observed.worktree && realpathSync(observed.root) === path) facts = observed;
|
|
32
|
+
else nonRepositories.add(path);
|
|
33
|
+
} catch { /* Unavailable roots retain their own identity. */ }
|
|
34
|
+
observations.set(path, facts);
|
|
35
|
+
}
|
|
36
|
+
// A remembered commit from the parent does not make a subfolder a checkout.
|
|
37
|
+
if (path && nonRepositories.has(path)) continue;
|
|
38
|
+
const facts = path ? observations.get(path) : undefined;
|
|
39
|
+
const canonical = facts?.canonicalRepositoryId === binding.repositoryId;
|
|
40
|
+
const scoped = facts && matchesLocalCheckout(binding.repositoryId, facts.root);
|
|
41
|
+
const rank = canonical ? 3 : scoped ? 2 : binding.repositoryId.startsWith("local:") ? 0 : 1;
|
|
42
|
+
const candidate = (canonical || scoped) && facts?.revision
|
|
43
|
+
? { ...binding, revision: facts.revision } : binding;
|
|
22
44
|
const key = JSON.stringify([binding.endpointId, path ?? binding.repositoryId]);
|
|
23
45
|
const previous = selected.get(key);
|
|
24
|
-
if (!previous || (
|
|
25
|
-
selected.set(key,
|
|
46
|
+
if (!previous || rank > (ranks.get(key) ?? 0)) {
|
|
47
|
+
selected.set(key, candidate);
|
|
48
|
+
ranks.set(key, rank);
|
|
26
49
|
}
|
|
27
50
|
}
|
|
28
51
|
return [...selected.values()];
|
|
@@ -18,7 +18,7 @@ export async function enrichMeshSnapshot(
|
|
|
18
18
|
const identityFailures = await refreshLocalGraphBindings(snapshot);
|
|
19
19
|
const excludedRepositories = new Set(identityFailures.map((report) => report.repositoryId));
|
|
20
20
|
const bindings = graphAnalysisBindings((snapshot.bindings ?? [])
|
|
21
|
-
.filter((binding) => !excludedRepositories.has(binding.repositoryId)));
|
|
21
|
+
.filter((binding) => !excludedRepositories.has(binding.repositoryId)), computerId());
|
|
22
22
|
await waitForProjectBindingSync(snapshot.projectId);
|
|
23
23
|
queueProjectKnowledgeSync({
|
|
24
24
|
projectId: snapshot.projectId,
|
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.83
|
|
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.83\";\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 20+ 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.83";
|
|
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;
|
package/package.json
CHANGED
|
@@ -14,6 +14,12 @@ export const ProjectCodeMap = z.object({
|
|
|
14
14
|
kind: z.string().trim().min(1).max(64),
|
|
15
15
|
startLine: z.number().int().positive(),
|
|
16
16
|
lineCount: z.number().int().positive(),
|
|
17
|
+
metrics: z.object({
|
|
18
|
+
measured: z.literal(true), sourceLines: z.number().int().positive().max(0xffff_ffff),
|
|
19
|
+
cyclomatic: z.number().int().positive().max(0xffff_ffff),
|
|
20
|
+
maxLoopDepth: z.number().int().nonnegative().max(0xffff_ffff),
|
|
21
|
+
callers: z.number().int().nonnegative().max(0xffff_ffff),
|
|
22
|
+
}).strict().optional(),
|
|
17
23
|
}).strict()).max(72),
|
|
18
24
|
}).strict()).max(650),
|
|
19
25
|
externals: z.array(z.object({
|