@mohantn/gate-keeper 2.2.0 → 2.2.2
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 +82 -46
- package/package.json +2 -2
- package/dist/cli/query-repl.d.ts +0 -37
- package/dist/cli/query-repl.d.ts.map +0 -1
- package/dist/cli/query-repl.js +0 -298
- package/dist/cli/query-repl.js.map +0 -1
- package/dist/cli/repl-algorithms.d.ts +0 -49
- package/dist/cli/repl-algorithms.d.ts.map +0 -1
- package/dist/cli/repl-algorithms.js +0 -147
- package/dist/cli/repl-algorithms.js.map +0 -1
- package/dist/cli/setup-core.d.ts +0 -38
- package/dist/cli/setup-core.d.ts.map +0 -1
- package/dist/cli/setup-core.js +0 -427
- package/dist/cli/setup-core.js.map +0 -1
- package/dist/cli/setup.d.ts +0 -25
- package/dist/cli/setup.d.ts.map +0 -1
- package/dist/cli/setup.js +0 -159
- package/dist/cli/setup.js.map +0 -1
- package/dist/github/app.d.ts +0 -34
- package/dist/github/app.d.ts.map +0 -1
- package/dist/github/app.js +0 -261
- package/dist/github/app.js.map +0 -1
- package/dist/github/commenter.d.ts +0 -67
- package/dist/github/commenter.d.ts.map +0 -1
- package/dist/github/commenter.js +0 -155
- package/dist/github/commenter.js.map +0 -1
- package/dist/hooks/git-hooks.d.ts +0 -30
- package/dist/hooks/git-hooks.d.ts.map +0 -1
- package/dist/hooks/git-hooks.js +0 -179
- package/dist/hooks/git-hooks.js.map +0 -1
- package/dist/mcp/cache-preload.d.ts +0 -29
- package/dist/mcp/cache-preload.d.ts.map +0 -1
- package/dist/mcp/cache-preload.js +0 -103
- package/dist/mcp/cache-preload.js.map +0 -1
- package/dist/mcp/handlers/context.d.ts +0 -25
- package/dist/mcp/handlers/context.d.ts.map +0 -1
- package/dist/mcp/handlers/context.js +0 -382
- package/dist/mcp/handlers/context.js.map +0 -1
- package/dist/mcp/handlers/graph-intelligence.d.ts +0 -26
- package/dist/mcp/handlers/graph-intelligence.d.ts.map +0 -1
- package/dist/mcp/handlers/graph-intelligence.js +0 -371
- package/dist/mcp/handlers/graph-intelligence.js.map +0 -1
- package/dist/mcp/handlers/graph-query.d.ts +0 -25
- package/dist/mcp/handlers/graph-query.d.ts.map +0 -1
- package/dist/mcp/handlers/graph-query.js +0 -410
- package/dist/mcp/handlers/graph-query.js.map +0 -1
- package/dist/mcp/handlers/impact.d.ts +0 -4
- package/dist/mcp/handlers/impact.d.ts.map +0 -1
- package/dist/mcp/handlers/impact.js +0 -139
- package/dist/mcp/handlers/impact.js.map +0 -1
- package/dist/mcp/handlers/improvement.d.ts +0 -4
- package/dist/mcp/handlers/improvement.d.ts.map +0 -1
- package/dist/mcp/handlers/improvement.js +0 -136
- package/dist/mcp/handlers/improvement.js.map +0 -1
- package/dist/mcp/handlers/platform-installer.d.ts +0 -10
- package/dist/mcp/handlers/platform-installer.d.ts.map +0 -1
- package/dist/mcp/handlers/platform-installer.js +0 -168
- package/dist/mcp/handlers/platform-installer.js.map +0 -1
- package/dist/mcp/handlers/pr-review.d.ts +0 -33
- package/dist/mcp/handlers/pr-review.d.ts.map +0 -1
- package/dist/mcp/handlers/pr-review.js +0 -170
- package/dist/mcp/handlers/pr-review.js.map +0 -1
- package/dist/mcp/token-tracker.d.ts +0 -47
- package/dist/mcp/token-tracker.d.ts.map +0 -1
- package/dist/mcp/token-tracker.js +0 -93
- package/dist/mcp/token-tracker.js.map +0 -1
- package/dist/quality-loop/file-lock.d.ts +0 -12
- package/dist/quality-loop/file-lock.d.ts.map +0 -1
- package/dist/quality-loop/file-lock.js +0 -38
- package/dist/quality-loop/file-lock.js.map +0 -1
- package/dist/quality-loop/fix-worker.d.ts +0 -44
- package/dist/quality-loop/fix-worker.d.ts.map +0 -1
- package/dist/quality-loop/fix-worker.js +0 -414
- package/dist/quality-loop/fix-worker.js.map +0 -1
- package/dist/quality-loop/orchestrator.d.ts +0 -137
- package/dist/quality-loop/orchestrator.d.ts.map +0 -1
- package/dist/quality-loop/orchestrator.js +0 -894
- package/dist/quality-loop/orchestrator.js.map +0 -1
- package/dist/quality-loop/queue-manager.d.ts +0 -45
- package/dist/quality-loop/queue-manager.d.ts.map +0 -1
- package/dist/quality-loop/queue-manager.js +0 -173
- package/dist/quality-loop/queue-manager.js.map +0 -1
package/dist/github/commenter.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* GitHub PR comment formatter — generates structured comments from graph analysis.
|
|
4
|
-
*
|
|
5
|
-
* Pure function: takes PR metadata + graph data, returns a markdown comment body.
|
|
6
|
-
* No HTTP calls, no GitHub API — just formatting. The caller (webhook, CLI, etc.)
|
|
7
|
-
* posts the comment via their own transport.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.formatPRComment = formatPRComment;
|
|
11
|
-
exports.formatDependencyDiff = formatDependencyDiff;
|
|
12
|
-
exports.formatSuggestedReviewers = formatSuggestedReviewers;
|
|
13
|
-
/**
|
|
14
|
-
* Generate a PR comment from graph analysis data.
|
|
15
|
-
*
|
|
16
|
-
* @param pr PR metadata (number, title, author, branches)
|
|
17
|
-
* @param files Changed files with graph context
|
|
18
|
-
* @param repoName Short repo name (e.g. "gate-keeper")
|
|
19
|
-
* @param allFilesCount Total files in the graph (for context)
|
|
20
|
-
*/
|
|
21
|
-
function formatPRComment(pr, files, repoName, allFilesCount) {
|
|
22
|
-
const sections = [];
|
|
23
|
-
// Risk assessment header
|
|
24
|
-
const redFiles = files.filter(f => f.rating < 5 || f.fragileDependents >= 3);
|
|
25
|
-
const yellowFiles = files.filter(f => (f.rating >= 5 && f.rating < 7) || f.fragileDependents >= 1);
|
|
26
|
-
const greenFiles = files.filter(f => f.rating >= 7 && f.fragileDependents === 0);
|
|
27
|
-
const verdict = redFiles.length > 0
|
|
28
|
-
? 'request-changes'
|
|
29
|
-
: yellowFiles.length > 0
|
|
30
|
-
? 'neutral'
|
|
31
|
-
: 'approve';
|
|
32
|
-
// Risk table
|
|
33
|
-
const riskLines = [
|
|
34
|
-
'| File | Rating | Dependents | Fragile | Risk |',
|
|
35
|
-
'|------|--------|------------|---------|------|',
|
|
36
|
-
];
|
|
37
|
-
for (const f of files) {
|
|
38
|
-
const isRed = f.rating < 5 || f.fragileDependents >= 3;
|
|
39
|
-
const isYellow = !isRed && ((f.rating >= 5 && f.rating < 7) || f.fragileDependents >= 1);
|
|
40
|
-
const risk = isRed ? '🔴 **HIGH**' : isYellow ? '🟡 MEDIUM' : '🟢 LOW';
|
|
41
|
-
riskLines.push(`| ${f.path} | ${f.rating}/10 | ${f.directDependents} | ${f.fragileDependents} | ${risk} |`);
|
|
42
|
-
}
|
|
43
|
-
sections.push({
|
|
44
|
-
icon: '📊',
|
|
45
|
-
title: 'Impact Analysis',
|
|
46
|
-
body: [
|
|
47
|
-
`**${redFiles.length} high-risk** · ${yellowFiles.length} medium · ${greenFiles.length} low`,
|
|
48
|
-
'',
|
|
49
|
-
...riskLines,
|
|
50
|
-
].join('\n'),
|
|
51
|
-
});
|
|
52
|
-
// Warnings for high-risk files
|
|
53
|
-
if (redFiles.length > 0) {
|
|
54
|
-
sections.push({
|
|
55
|
-
icon: '🚨',
|
|
56
|
-
title: 'High Risk Changes',
|
|
57
|
-
body: redFiles.map(f => {
|
|
58
|
-
const reasons = [];
|
|
59
|
-
if (f.rating < 5)
|
|
60
|
-
reasons.push(`low quality (${f.rating}/10)`);
|
|
61
|
-
if (f.fragileDependents >= 3)
|
|
62
|
-
reasons.push(`${f.fragileDependents} fragile dependents`);
|
|
63
|
-
if (f.directDependents >= 10)
|
|
64
|
-
reasons.push(`${f.directDependents} dependents (god node)`);
|
|
65
|
-
return `- **${f.path}**: ${reasons.join(', ')}`;
|
|
66
|
-
}).join('\n'),
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
// Verification suggestions
|
|
70
|
-
if (files.some(f => f.directDependents > 0)) {
|
|
71
|
-
const testHints = files
|
|
72
|
-
.filter(f => f.directDependents > 0)
|
|
73
|
-
.slice(0, 5)
|
|
74
|
-
.map(f => `- Run \`get_impact_set("${f.path}", depth=1)\` to verify downstream files still pass`);
|
|
75
|
-
sections.push({
|
|
76
|
-
icon: '✅',
|
|
77
|
-
title: 'Suggested Verification',
|
|
78
|
-
body: testHints.join('\n'),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
// Build the full comment body
|
|
82
|
-
const body = [
|
|
83
|
-
`## Gate Keeper — PR #${pr.number}: ${pr.title}`,
|
|
84
|
-
`_Author: ${pr.author} · Branch: \`${pr.headBranch}\` → \`${pr.baseBranch}\`_`,
|
|
85
|
-
`**Codebase context:** ${allFilesCount} analyzed files in \`${repoName}\``,
|
|
86
|
-
'',
|
|
87
|
-
...sections.flatMap(s => [`### ${s.icon} ${s.title}`, '', s.body, '']),
|
|
88
|
-
'---',
|
|
89
|
-
`_Generated by Gate Keeper using the dependency graph._`,
|
|
90
|
-
'',
|
|
91
|
-
].join('\n');
|
|
92
|
-
return { verdict, body };
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Generate a dependency diff between two points in time.
|
|
96
|
-
* Useful for "this PR adds K new dependencies" analysis.
|
|
97
|
-
*/
|
|
98
|
-
function formatDependencyDiff(addedDeps, removedDeps) {
|
|
99
|
-
const lines = ['### 🔗 Dependency Diff', ''];
|
|
100
|
-
if (addedDeps.length > 0) {
|
|
101
|
-
lines.push(`**Added (${addedDeps.length}):**`);
|
|
102
|
-
for (const d of addedDeps.slice(0, 10)) {
|
|
103
|
-
lines.push(`- \`${d.source}\` → \`${d.target}\` [${d.type}]`);
|
|
104
|
-
}
|
|
105
|
-
if (addedDeps.length > 10)
|
|
106
|
-
lines.push(`_... and ${addedDeps.length - 10} more_`);
|
|
107
|
-
lines.push('');
|
|
108
|
-
}
|
|
109
|
-
if (removedDeps.length > 0) {
|
|
110
|
-
lines.push(`**Removed (${removedDeps.length}):**`);
|
|
111
|
-
for (const d of removedDeps.slice(0, 10)) {
|
|
112
|
-
lines.push(`- \`${d.source}\` → \`${d.target}\` [${d.type}]`);
|
|
113
|
-
}
|
|
114
|
-
if (removedDeps.length > 10)
|
|
115
|
-
lines.push(`_... and ${removedDeps.length - 10} more_`);
|
|
116
|
-
lines.push('');
|
|
117
|
-
}
|
|
118
|
-
if (addedDeps.length === 0 && removedDeps.length === 0) {
|
|
119
|
-
lines.push('No dependency changes detected.');
|
|
120
|
-
}
|
|
121
|
-
return lines.join('\n');
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Generate a suggested reviewers list based on module ownership.
|
|
125
|
-
* Files in the PR are grouped by module; the most-committing author
|
|
126
|
-
* of each module is suggested.
|
|
127
|
-
*/
|
|
128
|
-
function formatSuggestedReviewers(prFiles, owners, repoRoot) {
|
|
129
|
-
const lines = ['### 👥 Suggested Reviewers', ''];
|
|
130
|
-
const seen = new Set();
|
|
131
|
-
for (const file of prFiles) {
|
|
132
|
-
const rel = file.filename;
|
|
133
|
-
const reviewers = owners.get(rel) ?? owners.get(pathDir(rel, repoRoot)) ?? [];
|
|
134
|
-
for (const r of reviewers) {
|
|
135
|
-
if (!seen.has(r)) {
|
|
136
|
-
seen.add(r);
|
|
137
|
-
lines.push(`- **@${r}** — owns/modified ${rel}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (seen.size === 0) {
|
|
142
|
-
lines.push('No ownership data available for changed files.');
|
|
143
|
-
}
|
|
144
|
-
return lines.join('\n');
|
|
145
|
-
}
|
|
146
|
-
function pathDir(filePath, _repoRoot) {
|
|
147
|
-
// Returns the top-level directory of a relative path, or '(root)'
|
|
148
|
-
const parts = filePath.split('/').filter(Boolean);
|
|
149
|
-
if (parts.length <= 1)
|
|
150
|
-
return '(root)';
|
|
151
|
-
if (['src', 'lib', 'app'].includes(parts[0]) && parts.length > 2)
|
|
152
|
-
return parts[1];
|
|
153
|
-
return parts[0];
|
|
154
|
-
}
|
|
155
|
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AAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,QAAgB,EAAE,SAAiB;IAClD,kEAAkE;IAClE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,CAAE,CAAC;IACpF,OAAO,KAAK,CAAC,CAAC,CAAE,CAAC;AACnB,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Git hook script generator.
|
|
3
|
-
*
|
|
4
|
-
* Produces shell scripts for post-commit, post-checkout, and the graphify
|
|
5
|
-
* merge driver. Scripts are designed to be written into .git/hooks/ and
|
|
6
|
-
* made executable. They trigger gate-keeper analysis after commits/checkouts
|
|
7
|
-
* without blocking the git operation.
|
|
8
|
-
*/
|
|
9
|
-
export interface HookInstallResult {
|
|
10
|
-
hook: string;
|
|
11
|
-
path: string;
|
|
12
|
-
action: 'created' | 'updated' | 'skipped';
|
|
13
|
-
content: string;
|
|
14
|
-
}
|
|
15
|
-
/** Shell script that re-analyzes changed files via the daemon (if running) */
|
|
16
|
-
export declare function postCommitScript(gateKeeperDir: string): string;
|
|
17
|
-
/** Shell script that triggers a full re-scan after branch checkout */
|
|
18
|
-
export declare function postCheckoutScript(gateKeeperDir: string): string;
|
|
19
|
-
/** Git merge driver that union-merges graph JSON files */
|
|
20
|
-
export declare function mergeDriverScript(): string;
|
|
21
|
-
/**
|
|
22
|
-
* Install git hooks into a repository's .git/hooks/ directory.
|
|
23
|
-
* Returns one result entry per hook.
|
|
24
|
-
*/
|
|
25
|
-
export declare function installGitHooks(repoRoot: string, gateKeeperDir: string, force?: boolean): HookInstallResult[];
|
|
26
|
-
/** Generate the .gitattributes line for the graph merge driver */
|
|
27
|
-
export declare function gitAttributesEntry(): string;
|
|
28
|
-
/** Generate the .git/config snippet for the merge driver */
|
|
29
|
-
export declare function gitConfigEntry(gateKeeperDir: string): string;
|
|
30
|
-
//# sourceMappingURL=git-hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../../src/hooks/git-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAmB9D;AAED,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CA2BhE;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,IAAI,MAAM,CAwC1C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,KAAK,UAAQ,GACZ,iBAAiB,EAAE,CA2BrB;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAG5D"}
|
package/dist/hooks/git-hooks.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Git hook script generator.
|
|
4
|
-
*
|
|
5
|
-
* Produces shell scripts for post-commit, post-checkout, and the graphify
|
|
6
|
-
* merge driver. Scripts are designed to be written into .git/hooks/ and
|
|
7
|
-
* made executable. They trigger gate-keeper analysis after commits/checkouts
|
|
8
|
-
* without blocking the git operation.
|
|
9
|
-
*/
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
-
var ownKeys = function(o) {
|
|
28
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
-
var ar = [];
|
|
30
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
return ownKeys(o);
|
|
34
|
-
};
|
|
35
|
-
return function (mod) {
|
|
36
|
-
if (mod && mod.__esModule) return mod;
|
|
37
|
-
var result = {};
|
|
38
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
-
__setModuleDefault(result, mod);
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.postCommitScript = postCommitScript;
|
|
45
|
-
exports.postCheckoutScript = postCheckoutScript;
|
|
46
|
-
exports.mergeDriverScript = mergeDriverScript;
|
|
47
|
-
exports.installGitHooks = installGitHooks;
|
|
48
|
-
exports.gitAttributesEntry = gitAttributesEntry;
|
|
49
|
-
exports.gitConfigEntry = gitConfigEntry;
|
|
50
|
-
const fs = __importStar(require("fs"));
|
|
51
|
-
const path = __importStar(require("path"));
|
|
52
|
-
/** Shell script that re-analyzes changed files via the daemon (if running) */
|
|
53
|
-
function postCommitScript(gateKeeperDir) {
|
|
54
|
-
const hook = path.join(gateKeeperDir, 'dist', 'hook-receiver.js');
|
|
55
|
-
return `#!/bin/sh
|
|
56
|
-
# Gate Keeper — post-commit hook
|
|
57
|
-
# Re-analyzes files changed in this commit via the daemon (non-blocking).
|
|
58
|
-
set -e
|
|
59
|
-
|
|
60
|
-
HOOK="${hook}"
|
|
61
|
-
if [ ! -f "$HOOK" ]; then exit 0; fi
|
|
62
|
-
|
|
63
|
-
git diff-tree --no-commit-id -r --name-only HEAD | grep -E '\\.(ts|tsx|js|jsx|cs)$' | while read -r file; do
|
|
64
|
-
FULL_PATH="$(git rev-parse --show-toplevel)/$file"
|
|
65
|
-
if [ -f "$FULL_PATH" ]; then
|
|
66
|
-
echo '{"tool_name":"Write","tool_input":{"file_path":"'"$FULL_PATH"'"}}' | node "$HOOK" 2>/dev/null &
|
|
67
|
-
fi
|
|
68
|
-
done
|
|
69
|
-
|
|
70
|
-
exit 0
|
|
71
|
-
`;
|
|
72
|
-
}
|
|
73
|
-
/** Shell script that triggers a full re-scan after branch checkout */
|
|
74
|
-
function postCheckoutScript(gateKeeperDir) {
|
|
75
|
-
const hook = path.join(gateKeeperDir, 'dist', 'hook-receiver.js');
|
|
76
|
-
return `#!/bin/sh
|
|
77
|
-
# Gate Keeper — post-checkout hook
|
|
78
|
-
# Triggers a re-scan when switching branches (non-blocking).
|
|
79
|
-
set -e
|
|
80
|
-
|
|
81
|
-
PREV_HEAD="$1"
|
|
82
|
-
NEW_HEAD="$2"
|
|
83
|
-
BRANCH_CHECKOUT="$3"
|
|
84
|
-
|
|
85
|
-
# Only act on branch checkouts, not file checkouts
|
|
86
|
-
if [ "$BRANCH_CHECKOUT" != "1" ]; then exit 0; fi
|
|
87
|
-
|
|
88
|
-
HOOK="${hook}"
|
|
89
|
-
if [ ! -f "$HOOK" ]; then exit 0; fi
|
|
90
|
-
|
|
91
|
-
# Re-analyze files that differ between branches (non-blocking)
|
|
92
|
-
git diff --name-only "$PREV_HEAD" "$NEW_HEAD" | grep -E '\\.(ts|tsx|js|jsx|cs)$' | head -20 | while read -r file; do
|
|
93
|
-
FULL_PATH="$(git rev-parse --show-toplevel)/$file"
|
|
94
|
-
if [ -f "$FULL_PATH" ]; then
|
|
95
|
-
echo '{"tool_name":"Write","tool_input":{"file_path":"'"$FULL_PATH"'"}}' | node "$HOOK" 2>/dev/null &
|
|
96
|
-
fi
|
|
97
|
-
done
|
|
98
|
-
|
|
99
|
-
exit 0
|
|
100
|
-
`;
|
|
101
|
-
}
|
|
102
|
-
/** Git merge driver that union-merges graph JSON files */
|
|
103
|
-
function mergeDriverScript() {
|
|
104
|
-
return `#!/bin/sh
|
|
105
|
-
# Gate Keeper — graph.json merge driver
|
|
106
|
-
# Registers as: [merge "gate-keeper-graph"] driver = gate-keeper-merge %O %A %B
|
|
107
|
-
# In .gitattributes: graph.json merge=gate-keeper-graph
|
|
108
|
-
|
|
109
|
-
BASE="$1"
|
|
110
|
-
OURS="$2"
|
|
111
|
-
THEIRS="$3"
|
|
112
|
-
|
|
113
|
-
node -e "
|
|
114
|
-
const fs = require('fs');
|
|
115
|
-
const a = JSON.parse(fs.readFileSync('$OURS', 'utf8'));
|
|
116
|
-
const b = JSON.parse(fs.readFileSync('$THEIRS', 'utf8'));
|
|
117
|
-
|
|
118
|
-
// Union-merge nodes (take min rating on conflict)
|
|
119
|
-
const nodeMap = new Map(a.nodes.map(n => [n.id, n]));
|
|
120
|
-
for (const n of b.nodes) {
|
|
121
|
-
const existing = nodeMap.get(n.id);
|
|
122
|
-
if (existing && existing.rating !== n.rating) {
|
|
123
|
-
nodeMap.set(n.id, { ...n, rating: Math.min(existing.rating, n.rating) });
|
|
124
|
-
} else {
|
|
125
|
-
nodeMap.set(n.id, n);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Union edges
|
|
130
|
-
const edgeSet = new Set((a.edges || []).map(e => e.source + '->' + e.target));
|
|
131
|
-
const edges = [...(a.edges || [])];
|
|
132
|
-
for (const e of (b.edges || [])) {
|
|
133
|
-
const key = e.source + '->' + e.target;
|
|
134
|
-
if (!edgeSet.has(key)) { edgeSet.add(key); edges.push(e); }
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const merged = { ...a, nodes: [...nodeMap.values()], edges, generatedAt: Date.now() };
|
|
138
|
-
fs.writeFileSync('$OURS', JSON.stringify(merged, null, 2));
|
|
139
|
-
" 2>/dev/null
|
|
140
|
-
|
|
141
|
-
exit 0
|
|
142
|
-
`;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Install git hooks into a repository's .git/hooks/ directory.
|
|
146
|
-
* Returns one result entry per hook.
|
|
147
|
-
*/
|
|
148
|
-
function installGitHooks(repoRoot, gateKeeperDir, force = false) {
|
|
149
|
-
const hooksDir = path.join(repoRoot, '.git', 'hooks');
|
|
150
|
-
const results = [];
|
|
151
|
-
if (!fs.existsSync(hooksDir)) {
|
|
152
|
-
throw new Error(`No .git/hooks directory at ${hooksDir}. Is this a git repository?`);
|
|
153
|
-
}
|
|
154
|
-
const hooksToInstall = [
|
|
155
|
-
{ name: 'post-commit', content: postCommitScript(gateKeeperDir) },
|
|
156
|
-
{ name: 'post-checkout', content: postCheckoutScript(gateKeeperDir) },
|
|
157
|
-
];
|
|
158
|
-
for (const { name, content } of hooksToInstall) {
|
|
159
|
-
const hookPath = path.join(hooksDir, name);
|
|
160
|
-
const exists = fs.existsSync(hookPath);
|
|
161
|
-
if (exists && !force) {
|
|
162
|
-
results.push({ hook: name, path: hookPath, action: 'skipped', content });
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
fs.writeFileSync(hookPath, content, { encoding: 'utf8', mode: 0o755 });
|
|
166
|
-
results.push({ hook: name, path: hookPath, action: exists ? 'updated' : 'created', content });
|
|
167
|
-
}
|
|
168
|
-
return results;
|
|
169
|
-
}
|
|
170
|
-
/** Generate the .gitattributes line for the graph merge driver */
|
|
171
|
-
function gitAttributesEntry() {
|
|
172
|
-
return 'graph.json merge=gate-keeper-graph\n';
|
|
173
|
-
}
|
|
174
|
-
/** Generate the .git/config snippet for the merge driver */
|
|
175
|
-
function gitConfigEntry(gateKeeperDir) {
|
|
176
|
-
const driverPath = path.join(gateKeeperDir, 'dist', 'hooks', 'merge-driver.sh');
|
|
177
|
-
return `[merge "gate-keeper-graph"]\n\tname = Gate Keeper graph merge driver\n\tdriver = ${driverPath} %O %A %B\n`;
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=git-hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git-hooks.js","sourceRoot":"","sources":["../../src/hooks/git-hooks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaH,4CAmBC;AAGD,gDA2BC;AAGD,8CAwCC;AAMD,0CA+BC;AAGD,gDAEC;AAGD,wCAGC;AAvJD,uCAAyB;AACzB,2CAA6B;AAS7B,8EAA8E;AAC9E,SAAgB,gBAAgB,CAAC,aAAqB;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAClE,OAAO;;;;;QAKD,IAAI;;;;;;;;;;;CAWX,CAAC;AACF,CAAC;AAED,sEAAsE;AACtE,SAAgB,kBAAkB,CAAC,aAAqB;IACtD,MAAM,I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C;YACzE,SAAS;QACX,CAAC;QAED,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,kEAAkE;AAClE,SAAgB,kBAAkB;IAChC,OAAO,sCAAsC,CAAC;AAChD,CAAC;AAED,4DAA4D;AAC5D,SAAgB,cAAc,CAAC,aAAqB;IAClD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAChF,OAAO,oFAAoF,UAAU,aAAa,CAAC;AACrH,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Smart cache preload — reads graph data from the daemon at MCP session start
|
|
3
|
-
* so the first 3-5 queries have zero latency.
|
|
4
|
-
*
|
|
5
|
-
* The preloader fetches the full dependency graph and key metrics, then caches
|
|
6
|
-
* them in memory. Subsequent queries read from this cache instead of hitting
|
|
7
|
-
* the daemon (HTTP round-trip).
|
|
8
|
-
*/
|
|
9
|
-
export interface PreloadedData {
|
|
10
|
-
graph: unknown | null;
|
|
11
|
-
status: {
|
|
12
|
-
overallRating?: number;
|
|
13
|
-
} | null;
|
|
14
|
-
cycles: unknown[] | null;
|
|
15
|
-
loadedAt: number;
|
|
16
|
-
repo: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Preload graph data for `repo`. Returns the cached data.
|
|
20
|
-
* Subsequent calls return the cached data without re-fetching.
|
|
21
|
-
*/
|
|
22
|
-
export declare function preloadForRepo(repo: string): Promise<PreloadedData>;
|
|
23
|
-
/**
|
|
24
|
-
* Invalidate the cached preload so the next call re-fetches.
|
|
25
|
-
*/
|
|
26
|
-
export declare function invalidatePreload(): void;
|
|
27
|
-
/** Check if preloaded data exists and is fresh (< 5 minutes old). */
|
|
28
|
-
export declare function isPreloaded(repo: string): boolean;
|
|
29
|
-
//# sourceMappingURL=cache-preload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache-preload.d.ts","sourceRoot":"","sources":["../../src/mcp/cache-preload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAkBD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAkBzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGjD"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Smart cache preload — reads graph data from the daemon at MCP session start
|
|
4
|
-
* so the first 3-5 queries have zero latency.
|
|
5
|
-
*
|
|
6
|
-
* The preloader fetches the full dependency graph and key metrics, then caches
|
|
7
|
-
* them in memory. Subsequent queries read from this cache instead of hitting
|
|
8
|
-
* the daemon (HTTP round-trip).
|
|
9
|
-
*/
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
-
var ownKeys = function(o) {
|
|
28
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
-
var ar = [];
|
|
30
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
return ownKeys(o);
|
|
34
|
-
};
|
|
35
|
-
return function (mod) {
|
|
36
|
-
if (mod && mod.__esModule) return mod;
|
|
37
|
-
var result = {};
|
|
38
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
-
__setModuleDefault(result, mod);
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.preloadForRepo = preloadForRepo;
|
|
45
|
-
exports.invalidatePreload = invalidatePreload;
|
|
46
|
-
exports.isPreloaded = isPreloaded;
|
|
47
|
-
const http = __importStar(require("http"));
|
|
48
|
-
const DAEMON_PORT = 5378;
|
|
49
|
-
const DEFAULT_REPO = process.cwd();
|
|
50
|
-
let cached = null;
|
|
51
|
-
function fetchApi(urlPath) {
|
|
52
|
-
return new Promise((resolve) => {
|
|
53
|
-
const req = http.get(`http://127.0.0.1:${DAEMON_PORT}${urlPath}`, { timeout: 3000 }, (res) => {
|
|
54
|
-
let body = '';
|
|
55
|
-
res.on('data', (chunk) => { body += chunk; });
|
|
56
|
-
res.on('end', () => {
|
|
57
|
-
try {
|
|
58
|
-
resolve(JSON.parse(body));
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
resolve(null);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
req.on('error', () => resolve(null));
|
|
66
|
-
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Preload graph data for `repo`. Returns the cached data.
|
|
71
|
-
* Subsequent calls return the cached data without re-fetching.
|
|
72
|
-
*/
|
|
73
|
-
async function preloadForRepo(repo) {
|
|
74
|
-
if (cached && cached.repo === repo)
|
|
75
|
-
return cached;
|
|
76
|
-
const repoEncoded = encodeURIComponent(repo);
|
|
77
|
-
const [graph, status, cycles] = await Promise.all([
|
|
78
|
-
fetchApi(`/api/graph?repo=${repoEncoded}`),
|
|
79
|
-
fetchApi(`/api/status?repo=${repoEncoded}`),
|
|
80
|
-
fetchApi(`/api/cycles?repo=${repoEncoded}`),
|
|
81
|
-
]);
|
|
82
|
-
cached = {
|
|
83
|
-
graph,
|
|
84
|
-
status: status,
|
|
85
|
-
cycles: cycles,
|
|
86
|
-
loadedAt: Date.now(),
|
|
87
|
-
repo,
|
|
88
|
-
};
|
|
89
|
-
return cached;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Invalidate the cached preload so the next call re-fetches.
|
|
93
|
-
*/
|
|
94
|
-
function invalidatePreload() {
|
|
95
|
-
cached = null;
|
|
96
|
-
}
|
|
97
|
-
/** Check if preloaded data exists and is fresh (< 5 minutes old). */
|
|
98
|
-
function isPreloaded(repo) {
|
|
99
|
-
if (!cached || cached.repo !== repo)
|
|
100
|
-
return false;
|
|
101
|
-
return (Date.now() - cached.loadedAt) < 5 * 60 * 1000;
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=cache-preload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache-preload.js","sourceRoot":"","sources":["../../src/mcp/cache-preload.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCH,wCAkBC;AAKD,8CAEC;AAGD,kCAGC;AAhED,2CAA6B;AAE7B,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAUnC,IAAI,MAAM,GAAyB,IAAI,CAAC;AAExC,SAAS,QAAQ,CAAC,OAAe;IAC/B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,oBAAoB,WAAW,GAAG,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;YAC3F,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACjB,IAAI,CAAC;oBAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC;oBAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,EAAE,CAAC,OAAO,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-
export declare function handleFileContext(args: Record<string, unknown>): Promise<{
|
|
2
|
-
content: Array<{
|
|
3
|
-
type: string;
|
|
4
|
-
text: string;
|
|
5
|
-
}>;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function handleDependencyGraph(args: Record<string, unknown>): Promise<{
|
|
8
|
-
content: Array<{
|
|
9
|
-
type: string;
|
|
10
|
-
text: string;
|
|
11
|
-
}>;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function handleImpactAnalysis(args: Record<string, unknown>): Promise<{
|
|
14
|
-
content: Array<{
|
|
15
|
-
type: string;
|
|
16
|
-
text: string;
|
|
17
|
-
}>;
|
|
18
|
-
}>;
|
|
19
|
-
export declare function handlePredictImpactWithRemediation(args: Record<string, unknown>): Promise<{
|
|
20
|
-
content: Array<{
|
|
21
|
-
type: string;
|
|
22
|
-
text: string;
|
|
23
|
-
}>;
|
|
24
|
-
}>;
|
|
25
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/mcp/handlers/context.ts"],"names":[],"mappings":"AAiBA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAiGlI;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAqFtI;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA6ErI;AAED,wBAAsB,kCAAkC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA4GnJ"}
|