@mohantn/gate-keeper 2.1.0
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/.github/instructions/dotnet-api-integration.instructions.md +416 -0
- package/.github/instructions/dotnet-development.instructions.md +353 -0
- package/.github/instructions/dotnet-testing.instructions.md +406 -0
- package/.github/instructions/gate-keeper.instructions.md +91 -0
- package/.github/instructions/react-development.instructions.md +315 -0
- package/.github/instructions/react-testing-optimization.instructions.md +373 -0
- package/.github/instructions/uiux.instructions.md +261 -0
- package/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/analyzer/coverage-analyzer.d.ts +126 -0
- package/dist/analyzer/coverage-analyzer.d.ts.map +1 -0
- package/dist/analyzer/coverage-analyzer.js +633 -0
- package/dist/analyzer/coverage-analyzer.js.map +1 -0
- package/dist/analyzer/csharp-analyzer.d.ts +28 -0
- package/dist/analyzer/csharp-analyzer.d.ts.map +1 -0
- package/dist/analyzer/csharp-analyzer.js +437 -0
- package/dist/analyzer/csharp-analyzer.js.map +1 -0
- package/dist/analyzer/pattern-detector.d.ts +5 -0
- package/dist/analyzer/pattern-detector.d.ts.map +1 -0
- package/dist/analyzer/pattern-detector.js +74 -0
- package/dist/analyzer/pattern-detector.js.map +1 -0
- package/dist/analyzer/refactoring-advisor.d.ts +7 -0
- package/dist/analyzer/refactoring-advisor.d.ts.map +1 -0
- package/dist/analyzer/refactoring-advisor.js +280 -0
- package/dist/analyzer/refactoring-advisor.js.map +1 -0
- package/dist/analyzer/sonar-eslint-runner.d.ts +3 -0
- package/dist/analyzer/sonar-eslint-runner.d.ts.map +1 -0
- package/dist/analyzer/sonar-eslint-runner.js +136 -0
- package/dist/analyzer/sonar-eslint-runner.js.map +1 -0
- package/dist/analyzer/sonar-rule-map.d.ts +19 -0
- package/dist/analyzer/sonar-rule-map.d.ts.map +1 -0
- package/dist/analyzer/sonar-rule-map.js +67 -0
- package/dist/analyzer/sonar-rule-map.js.map +1 -0
- package/dist/analyzer/string-analyzer.d.ts +27 -0
- package/dist/analyzer/string-analyzer.d.ts.map +1 -0
- package/dist/analyzer/string-analyzer.js +274 -0
- package/dist/analyzer/string-analyzer.js.map +1 -0
- package/dist/analyzer/typescript-analyzer.d.ts +27 -0
- package/dist/analyzer/typescript-analyzer.d.ts.map +1 -0
- package/dist/analyzer/typescript-analyzer.js +437 -0
- package/dist/analyzer/typescript-analyzer.js.map +1 -0
- package/dist/analyzer/universal-analyzer.d.ts +10 -0
- package/dist/analyzer/universal-analyzer.d.ts.map +1 -0
- package/dist/analyzer/universal-analyzer.js +155 -0
- package/dist/analyzer/universal-analyzer.js.map +1 -0
- package/dist/cache/quality-cache.d.ts +119 -0
- package/dist/cache/quality-cache.d.ts.map +1 -0
- package/dist/cache/quality-cache.js +130 -0
- package/dist/cache/quality-cache.js.map +1 -0
- package/dist/cache/sqlite-cache.d.ts +43 -0
- package/dist/cache/sqlite-cache.d.ts.map +1 -0
- package/dist/cache/sqlite-cache.js +346 -0
- package/dist/cache/sqlite-cache.js.map +1 -0
- package/dist/cli/query-repl.d.ts +37 -0
- package/dist/cli/query-repl.d.ts.map +1 -0
- package/dist/cli/query-repl.js +298 -0
- package/dist/cli/query-repl.js.map +1 -0
- package/dist/cli/repl-algorithms.d.ts +49 -0
- package/dist/cli/repl-algorithms.d.ts.map +1 -0
- package/dist/cli/repl-algorithms.js +147 -0
- package/dist/cli/repl-algorithms.js.map +1 -0
- package/dist/cli/setup-core.d.ts +38 -0
- package/dist/cli/setup-core.d.ts.map +1 -0
- package/dist/cli/setup-core.js +427 -0
- package/dist/cli/setup-core.js.map +1 -0
- package/dist/cli/setup.d.ts +25 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +159 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli-entry.d.ts +19 -0
- package/dist/cli-entry.d.ts.map +1 -0
- package/dist/cli-entry.js +178 -0
- package/dist/cli-entry.js.map +1 -0
- package/dist/daemon/watch-mode.d.ts +41 -0
- package/dist/daemon/watch-mode.d.ts.map +1 -0
- package/dist/daemon/watch-mode.js +163 -0
- package/dist/daemon/watch-mode.js.map +1 -0
- package/dist/daemon.d.ts +24 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +357 -0
- package/dist/daemon.js.map +1 -0
- package/dist/github/app.d.ts +34 -0
- package/dist/github/app.d.ts.map +1 -0
- package/dist/github/app.js +261 -0
- package/dist/github/app.js.map +1 -0
- package/dist/github/commenter.d.ts +67 -0
- package/dist/github/commenter.d.ts.map +1 -0
- package/dist/github/commenter.js +155 -0
- package/dist/github/commenter.js.map +1 -0
- package/dist/graph/dependency-graph.d.ts +28 -0
- package/dist/graph/dependency-graph.d.ts.map +1 -0
- package/dist/graph/dependency-graph.js +198 -0
- package/dist/graph/dependency-graph.js.map +1 -0
- package/dist/graph/global-graph.d.ts +65 -0
- package/dist/graph/global-graph.d.ts.map +1 -0
- package/dist/graph/global-graph.js +153 -0
- package/dist/graph/global-graph.js.map +1 -0
- package/dist/graph/graph-algorithms.d.ts +90 -0
- package/dist/graph/graph-algorithms.d.ts.map +1 -0
- package/dist/graph/graph-algorithms.js +180 -0
- package/dist/graph/graph-algorithms.js.map +1 -0
- package/dist/graph/graph-export.d.ts +68 -0
- package/dist/graph/graph-export.d.ts.map +1 -0
- package/dist/graph/graph-export.js +264 -0
- package/dist/graph/graph-export.js.map +1 -0
- package/dist/graph/graph-report.d.ts +34 -0
- package/dist/graph/graph-report.d.ts.map +1 -0
- package/dist/graph/graph-report.js +136 -0
- package/dist/graph/graph-report.js.map +1 -0
- package/dist/graph/graph-summary.d.ts +68 -0
- package/dist/graph/graph-summary.d.ts.map +1 -0
- package/dist/graph/graph-summary.js +213 -0
- package/dist/graph/graph-summary.js.map +1 -0
- package/dist/graph/graphify-ignore.d.ts +32 -0
- package/dist/graph/graphify-ignore.d.ts.map +1 -0
- package/dist/graph/graphify-ignore.js +124 -0
- package/dist/graph/graphify-ignore.js.map +1 -0
- package/dist/graph/question-suggester.d.ts +30 -0
- package/dist/graph/question-suggester.d.ts.map +1 -0
- package/dist/graph/question-suggester.js +113 -0
- package/dist/graph/question-suggester.js.map +1 -0
- package/dist/graph/relationship-extractor.d.ts +40 -0
- package/dist/graph/relationship-extractor.d.ts.map +1 -0
- package/dist/graph/relationship-extractor.js +254 -0
- package/dist/graph/relationship-extractor.js.map +1 -0
- package/dist/graph/relationship-types.d.ts +24 -0
- package/dist/graph/relationship-types.d.ts.map +1 -0
- package/dist/graph/relationship-types.js +21 -0
- package/dist/graph/relationship-types.js.map +1 -0
- package/dist/graph/surprising-connections.d.ts +39 -0
- package/dist/graph/surprising-connections.d.ts.map +1 -0
- package/dist/graph/surprising-connections.js +127 -0
- package/dist/graph/surprising-connections.js.map +1 -0
- package/dist/hook-pre-tool-use.d.ts +14 -0
- package/dist/hook-pre-tool-use.d.ts.map +1 -0
- package/dist/hook-pre-tool-use.js +167 -0
- package/dist/hook-pre-tool-use.js.map +1 -0
- package/dist/hook-receiver.d.ts +29 -0
- package/dist/hook-receiver.d.ts.map +1 -0
- package/dist/hook-receiver.js +327 -0
- package/dist/hook-receiver.js.map +1 -0
- package/dist/hooks/git-hooks.d.ts +30 -0
- package/dist/hooks/git-hooks.d.ts.map +1 -0
- package/dist/hooks/git-hooks.js +179 -0
- package/dist/hooks/git-hooks.js.map +1 -0
- package/dist/mcp/cache-preload.d.ts +29 -0
- package/dist/mcp/cache-preload.d.ts.map +1 -0
- package/dist/mcp/cache-preload.js +103 -0
- package/dist/mcp/cache-preload.js.map +1 -0
- package/dist/mcp/handlers/analysis.d.ts +4 -0
- package/dist/mcp/handlers/analysis.d.ts.map +1 -0
- package/dist/mcp/handlers/analysis.js +196 -0
- package/dist/mcp/handlers/analysis.js.map +1 -0
- package/dist/mcp/handlers/context.d.ts +25 -0
- package/dist/mcp/handlers/context.d.ts.map +1 -0
- package/dist/mcp/handlers/context.js +382 -0
- package/dist/mcp/handlers/context.js.map +1 -0
- package/dist/mcp/handlers/graph-intelligence.d.ts +26 -0
- package/dist/mcp/handlers/graph-intelligence.d.ts.map +1 -0
- package/dist/mcp/handlers/graph-intelligence.js +371 -0
- package/dist/mcp/handlers/graph-intelligence.js.map +1 -0
- package/dist/mcp/handlers/graph-query.d.ts +25 -0
- package/dist/mcp/handlers/graph-query.d.ts.map +1 -0
- package/dist/mcp/handlers/graph-query.js +410 -0
- package/dist/mcp/handlers/graph-query.js.map +1 -0
- package/dist/mcp/handlers/graph.d.ts +5 -0
- package/dist/mcp/handlers/graph.d.ts.map +1 -0
- package/dist/mcp/handlers/graph.js +283 -0
- package/dist/mcp/handlers/graph.js.map +1 -0
- package/dist/mcp/handlers/impact-format.d.ts +9 -0
- package/dist/mcp/handlers/impact-format.d.ts.map +1 -0
- package/dist/mcp/handlers/impact-format.js +189 -0
- package/dist/mcp/handlers/impact-format.js.map +1 -0
- package/dist/mcp/handlers/impact.d.ts +4 -0
- package/dist/mcp/handlers/impact.d.ts.map +1 -0
- package/dist/mcp/handlers/impact.js +139 -0
- package/dist/mcp/handlers/impact.js.map +1 -0
- package/dist/mcp/handlers/improvement.d.ts +4 -0
- package/dist/mcp/handlers/improvement.d.ts.map +1 -0
- package/dist/mcp/handlers/improvement.js +136 -0
- package/dist/mcp/handlers/improvement.js.map +1 -0
- package/dist/mcp/handlers/index.d.ts +14 -0
- package/dist/mcp/handlers/index.d.ts.map +1 -0
- package/dist/mcp/handlers/index.js +36 -0
- package/dist/mcp/handlers/index.js.map +1 -0
- package/dist/mcp/handlers/platform-installer.d.ts +10 -0
- package/dist/mcp/handlers/platform-installer.d.ts.map +1 -0
- package/dist/mcp/handlers/platform-installer.js +168 -0
- package/dist/mcp/handlers/platform-installer.js.map +1 -0
- package/dist/mcp/handlers/pr-review.d.ts +33 -0
- package/dist/mcp/handlers/pr-review.d.ts.map +1 -0
- package/dist/mcp/handlers/pr-review.js +170 -0
- package/dist/mcp/handlers/pr-review.js.map +1 -0
- package/dist/mcp/handlers/shared.d.ts +20 -0
- package/dist/mcp/handlers/shared.d.ts.map +1 -0
- package/dist/mcp/handlers/shared.js +27 -0
- package/dist/mcp/handlers/shared.js.map +1 -0
- package/dist/mcp/handlers/types.d.ts +46 -0
- package/dist/mcp/handlers/types.d.ts.map +1 -0
- package/dist/mcp/handlers/types.js +3 -0
- package/dist/mcp/handlers/types.js.map +1 -0
- package/dist/mcp/helpers.d.ts +36 -0
- package/dist/mcp/helpers.d.ts.map +1 -0
- package/dist/mcp/helpers.js +199 -0
- package/dist/mcp/helpers.js.map +1 -0
- package/dist/mcp/installer.d.ts +22 -0
- package/dist/mcp/installer.d.ts.map +1 -0
- package/dist/mcp/installer.js +341 -0
- package/dist/mcp/installer.js.map +1 -0
- package/dist/mcp/server.d.ts +111 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +216 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/token-tracker.d.ts +47 -0
- package/dist/mcp/token-tracker.d.ts.map +1 -0
- package/dist/mcp/token-tracker.js +93 -0
- package/dist/mcp/token-tracker.js.map +1 -0
- package/dist/quality-loop/file-lock.d.ts +12 -0
- package/dist/quality-loop/file-lock.d.ts.map +1 -0
- package/dist/quality-loop/file-lock.js +38 -0
- package/dist/quality-loop/file-lock.js.map +1 -0
- package/dist/quality-loop/fix-worker.d.ts +44 -0
- package/dist/quality-loop/fix-worker.d.ts.map +1 -0
- package/dist/quality-loop/fix-worker.js +414 -0
- package/dist/quality-loop/fix-worker.js.map +1 -0
- package/dist/quality-loop/orchestrator.d.ts +137 -0
- package/dist/quality-loop/orchestrator.d.ts.map +1 -0
- package/dist/quality-loop/orchestrator.js +894 -0
- package/dist/quality-loop/orchestrator.js.map +1 -0
- package/dist/quality-loop/queue-manager.d.ts +45 -0
- package/dist/quality-loop/queue-manager.d.ts.map +1 -0
- package/dist/quality-loop/queue-manager.js +173 -0
- package/dist/quality-loop/queue-manager.js.map +1 -0
- package/dist/rating/rating-calculator.d.ts +15 -0
- package/dist/rating/rating-calculator.d.ts.map +1 -0
- package/dist/rating/rating-calculator.js +136 -0
- package/dist/rating/rating-calculator.js.map +1 -0
- package/dist/types/agent.d.ts +49 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +7 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types.d.ts +156 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/util/fix-text.d.ts +7 -0
- package/dist/util/fix-text.d.ts.map +1 -0
- package/dist/util/fix-text.js +13 -0
- package/dist/util/fix-text.js.map +1 -0
- package/dist/viz/graph-viz.d.ts +40 -0
- package/dist/viz/graph-viz.d.ts.map +1 -0
- package/dist/viz/graph-viz.js +332 -0
- package/dist/viz/graph-viz.js.map +1 -0
- package/dist/viz/viz-helpers.d.ts +13 -0
- package/dist/viz/viz-helpers.d.ts.map +1 -0
- package/dist/viz/viz-helpers.js +134 -0
- package/dist/viz/viz-helpers.js.map +1 -0
- package/dist/viz/viz-routes.d.ts +28 -0
- package/dist/viz/viz-routes.d.ts.map +1 -0
- package/dist/viz/viz-routes.js +333 -0
- package/dist/viz/viz-routes.js.map +1 -0
- package/dist/viz/viz-scanner.d.ts +20 -0
- package/dist/viz/viz-scanner.d.ts.map +1 -0
- package/dist/viz/viz-scanner.js +241 -0
- package/dist/viz/viz-scanner.js.map +1 -0
- package/dist/viz/viz-server.d.ts +38 -0
- package/dist/viz/viz-server.d.ts.map +1 -0
- package/dist/viz/viz-server.js +240 -0
- package/dist/viz/viz-server.js.map +1 -0
- package/package.json +89 -0
- package/scripts/postinstall.js +28 -0
- package/scripts/setup.sh +113 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Platform integration installer — generates config files that wire gate-keeper
|
|
4
|
+
* into various AI coding assistants.
|
|
5
|
+
*
|
|
6
|
+
* Each platform generator returns the target file path and content to write.
|
|
7
|
+
* The handler is responsible for actually writing to disk and checking conflicts.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.claudeCodeConfig = claudeCodeConfig;
|
|
44
|
+
exports.copilotConfig = copilotConfig;
|
|
45
|
+
exports.cursorConfig = cursorConfig;
|
|
46
|
+
exports.vscodeConfig = vscodeConfig;
|
|
47
|
+
exports.githubActionConfig = githubActionConfig;
|
|
48
|
+
exports.getPlatformConfig = getPlatformConfig;
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
// ── Platform config generators ─────────────────────────────
|
|
51
|
+
function claudeCodeConfig(repoRoot) {
|
|
52
|
+
const content = `
|
|
53
|
+
## Gate Keeper — Graphify Integration
|
|
54
|
+
|
|
55
|
+
**Session Start Protocol:**
|
|
56
|
+
1. Call \`get_graph_report\` to understand the architecture before writing any code.
|
|
57
|
+
2. Call \`get_centrality_rank\` to identify high-blast-radius files.
|
|
58
|
+
3. Before editing any file, call \`check_pre_edit_safety\` — treat **block** verdicts as hard stops.
|
|
59
|
+
|
|
60
|
+
**MCP Tools available:** get_impact_set, trace_path, summarize_file, find_callers, check_pre_edit_safety, get_graph_report, query_graph, explain_node, get_session_metrics
|
|
61
|
+
|
|
62
|
+
**Token efficiency:** Use these tools instead of reading raw files. One graph query (~100–300 tokens) replaces reading 5+ files (~25 000 tokens).
|
|
63
|
+
`;
|
|
64
|
+
return {
|
|
65
|
+
platform: 'claude-code',
|
|
66
|
+
filePath: path.join(repoRoot, 'CLAUDE.md'),
|
|
67
|
+
content,
|
|
68
|
+
description: 'Appends gate-keeper session protocol to CLAUDE.md',
|
|
69
|
+
append: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function copilotConfig(repoRoot, mcpServerPath) {
|
|
73
|
+
const serverPath = mcpServerPath ?? 'node dist/mcp/server.js';
|
|
74
|
+
const content = `# Gate Keeper — Mandatory Quality Workflow
|
|
75
|
+
|
|
76
|
+
> **Every code action (plan, create, edit) must pass through the gate-keeper MCP tools. No exceptions.**
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## MCP Server Configuration
|
|
81
|
+
|
|
82
|
+
Add this to your VS Code settings (or \`mcp.json\`) to register the gate-keeper MCP server:
|
|
83
|
+
|
|
84
|
+
\`\`\`json
|
|
85
|
+
{
|
|
86
|
+
"mcpServers": {
|
|
87
|
+
"gate-keeper": {
|
|
88
|
+
"command": "node",
|
|
89
|
+
"args": ["${serverPath}"],
|
|
90
|
+
"cwd": "${repoRoot}"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Tool Quick Reference
|
|
99
|
+
|
|
100
|
+
| Category | Tool | What it does |
|
|
101
|
+
|----------|------|-------------|
|
|
102
|
+
| **Quality** | \`analyze_file\` | Rate a file 0–10, get violations |
|
|
103
|
+
| | \`analyze_code\` | Preview quality before writing a new file |
|
|
104
|
+
| | \`get_quality_rules\` | Learn scoring thresholds and deductions |
|
|
105
|
+
| **Context** | \`summarize_file\` | Get file overview without reading raw content |
|
|
106
|
+
| | \`get_file_context\` | Dependencies, reverse deps, cycles, rating |
|
|
107
|
+
| | \`get_dependency_graph\` | Full repo graph: nodes (relative paths), nd (node data), adj (integer-indexed) |
|
|
108
|
+
| | \`get_graph_summary\` | Pre-computed analytics: hotspots, worst files, coupling |
|
|
109
|
+
| | \`get_graph_report\` | Narrative report: god nodes, surprises |
|
|
110
|
+
| **Safety** | \`check_pre_edit_safety\` | Risk verdict before editing (safe/warn/block) |
|
|
111
|
+
| | \`get_impact_set\` | Files that would break if you change this one |
|
|
112
|
+
| | \`predict_impact_with_remediation\` | Blast radius + fix instructions |
|
|
113
|
+
| | \`find_callers\` | All call sites before renaming a function |
|
|
114
|
+
| **Analysis** | \`suggest_refactoring\` | Ranked fixes for a low-rated file |
|
|
115
|
+
| | \`get_codebase_health\` | Overall project quality scan |
|
|
116
|
+
| | \`get_violation_patterns\` | Most common violations across the codebase |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Session Start (once per session)
|
|
121
|
+
|
|
122
|
+
\`\`\`
|
|
123
|
+
get_quality_rules ← learn scoring thresholds
|
|
124
|
+
get_dependency_graph ← full repo graph: nodes, nd, adj (integer-indexed)
|
|
125
|
+
get_graph_summary ← pre-computed analytics: hotspots, worst files, module coupling
|
|
126
|
+
\`\`\`
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Before Any Change
|
|
131
|
+
|
|
132
|
+
\`\`\`
|
|
133
|
+
get_file_context <file>
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
If the file has **many reverse dependencies**:
|
|
137
|
+
\`\`\`
|
|
138
|
+
get_impact_analysis <file> ← direct + transitive dependents
|
|
139
|
+
predict_impact_with_remediation <file> ← remediation for at-risk downstream files
|
|
140
|
+
\`\`\`
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Writing Code
|
|
145
|
+
|
|
146
|
+
### New file
|
|
147
|
+
1. \`analyze_code <code string>\` — preview quality BEFORE writing to disk
|
|
148
|
+
2. Only write if rating ≥ 7.0, or fix the code first
|
|
149
|
+
3. After writing: \`analyze_file <path>\` to verify
|
|
150
|
+
|
|
151
|
+
### Existing file
|
|
152
|
+
1. Edit the file
|
|
153
|
+
2. Immediately: \`analyze_file <absolute path>\` (MANDATORY)
|
|
154
|
+
|
|
155
|
+
| Rating | Action |
|
|
156
|
+
|--------|--------|
|
|
157
|
+
| ≥ 7.0 | ✅ Done — proceed |
|
|
158
|
+
| < 7.0 | \`suggest_refactoring\` → fix → \`analyze_file\` again (max 3 cycles) |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## After Bulk Changes (3+ files)
|
|
163
|
+
|
|
164
|
+
\`\`\`
|
|
165
|
+
get_codebase_health ← verify overall project quality has not degraded
|
|
166
|
+
\`\`\`
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Hard Rules
|
|
171
|
+
|
|
172
|
+
- Never use \`any\` — use specific types or \`unknown\`
|
|
173
|
+
- Never leave empty catch blocks
|
|
174
|
+
- Never skip \`analyze_file\` after editing a code file
|
|
175
|
+
- Never edit a widely-imported file without \`get_impact_analysis\` first
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Quality Thresholds
|
|
180
|
+
|
|
181
|
+
| Metric | Deduction |
|
|
182
|
+
|--------|-----------|
|
|
183
|
+
| Error violation | −1.5 |
|
|
184
|
+
| Warning violation | −0.5 |
|
|
185
|
+
| Info violation | −0.1 |
|
|
186
|
+
| Cyclomatic complexity >20 / >10 | −2.0 / −1.0 |
|
|
187
|
+
| Import count >30 / >15 | −2.0 / −0.5 |
|
|
188
|
+
| Lines >500 / >300 | −1.5 / −0.5 |
|
|
189
|
+
| Circular dependency | −1.0 per cycle |
|
|
190
|
+
| Test coverage <30% / <50% / <80% | −2.5 / −2.0 / −1.0 |
|
|
191
|
+
|
|
192
|
+
**Minimum passing rating: 7.0 / 10**
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Fix Priority
|
|
197
|
+
|
|
198
|
+
1. **Errors −1.5 each** — missing \`key\` props, empty catch blocks
|
|
199
|
+
2. **Warnings −0.5 each** — \`any\` types, god classes, long methods (>50 lines), tight coupling
|
|
200
|
+
3. **Circular deps −1.0 each** — break import cycles via shared types or dependency inversion
|
|
201
|
+
4. **Info −0.1 each** — console.log statements
|
|
202
|
+
`;
|
|
203
|
+
return {
|
|
204
|
+
platform: 'copilot',
|
|
205
|
+
filePath: path.join(repoRoot, '.github', 'copilot-instructions.md'),
|
|
206
|
+
content,
|
|
207
|
+
description: 'Creates .github/copilot-instructions.md with gate-keeper usage guide',
|
|
208
|
+
append: false,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function cursorConfig(repoRoot) {
|
|
212
|
+
const content = `# Gate Keeper — Cursor Rules
|
|
213
|
+
|
|
214
|
+
## Before editing any file
|
|
215
|
+
1. Call MCP tool \`check_pre_edit_safety\` with the file path.
|
|
216
|
+
2. If verdict is "warn": also call \`get_impact_set\` to see affected files.
|
|
217
|
+
3. If verdict is "block": fix fragile dependents first.
|
|
218
|
+
|
|
219
|
+
## Architecture awareness
|
|
220
|
+
- Call \`get_graph_report\` once per session to understand module structure.
|
|
221
|
+
- Use \`summarize_file\` instead of reading raw files for context.
|
|
222
|
+
- Use \`find_callers\` before renaming or deleting any function/export.
|
|
223
|
+
- Use \`trace_path\` to understand why two modules are coupled.
|
|
224
|
+
|
|
225
|
+
## Quality gates
|
|
226
|
+
- After every file edit, call \`analyze_file\`. Target rating ≥ 7.0/10.
|
|
227
|
+
- If rating < 7.0, call \`suggest_refactoring\` and fix violations.
|
|
228
|
+
|
|
229
|
+
## MCP Server: node dist/mcp/server.js (in repo root)
|
|
230
|
+
`;
|
|
231
|
+
return {
|
|
232
|
+
platform: 'cursor',
|
|
233
|
+
filePath: path.join(repoRoot, '.cursorrules'),
|
|
234
|
+
content,
|
|
235
|
+
description: 'Creates .cursorrules with gate-keeper workflow instructions',
|
|
236
|
+
append: false,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function vscodeConfig(repoRoot, gateKeeperPath) {
|
|
240
|
+
const serverPath = gateKeeperPath ?? repoRoot;
|
|
241
|
+
const config = {
|
|
242
|
+
servers: {
|
|
243
|
+
'gate-keeper': {
|
|
244
|
+
command: 'node',
|
|
245
|
+
args: ['dist/mcp/server.js'],
|
|
246
|
+
cwd: serverPath,
|
|
247
|
+
env: {},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
return {
|
|
252
|
+
platform: 'vscode',
|
|
253
|
+
filePath: path.join(repoRoot, '.vscode', 'mcp.json'),
|
|
254
|
+
content: JSON.stringify(config, null, 2),
|
|
255
|
+
description: 'Creates .vscode/mcp.json registering gate-keeper as a VS Code MCP server',
|
|
256
|
+
append: false,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function githubActionConfig() {
|
|
260
|
+
const content = `name: Gate Keeper — Code Quality Analysis
|
|
261
|
+
|
|
262
|
+
on:
|
|
263
|
+
push:
|
|
264
|
+
branches: ["**"]
|
|
265
|
+
pull_request:
|
|
266
|
+
branches: [main, master]
|
|
267
|
+
|
|
268
|
+
jobs:
|
|
269
|
+
quality-analysis:
|
|
270
|
+
name: Analyze code quality
|
|
271
|
+
runs-on: ubuntu-latest
|
|
272
|
+
permissions:
|
|
273
|
+
contents: read
|
|
274
|
+
pull-requests: write
|
|
275
|
+
|
|
276
|
+
steps:
|
|
277
|
+
- uses: actions/checkout@v4
|
|
278
|
+
|
|
279
|
+
- uses: actions/setup-node@v4
|
|
280
|
+
with:
|
|
281
|
+
node-version: '20'
|
|
282
|
+
cache: 'npm'
|
|
283
|
+
cache-dependency-path: |
|
|
284
|
+
package-lock.json
|
|
285
|
+
|
|
286
|
+
- name: Install gate-keeper
|
|
287
|
+
run: npm ci
|
|
288
|
+
|
|
289
|
+
- name: Build gate-keeper
|
|
290
|
+
run: npm run build
|
|
291
|
+
|
|
292
|
+
- name: Run quality analysis
|
|
293
|
+
id: analysis
|
|
294
|
+
run: |
|
|
295
|
+
node -e "
|
|
296
|
+
const { UniversalAnalyzer } = require('./dist/analyzer/universal-analyzer');
|
|
297
|
+
const { findSourceFiles } = require('./dist/mcp/helpers');
|
|
298
|
+
const files = findSourceFiles('.', 100);
|
|
299
|
+
Promise.all(files.map(f => new UniversalAnalyzer().analyze(f)))
|
|
300
|
+
.then(results => {
|
|
301
|
+
const avg = results.reduce((s, r) => s + r.rating, 0) / results.length;
|
|
302
|
+
const failed = results.filter(r => r.rating < 7.0);
|
|
303
|
+
console.log('overall_rating=' + avg.toFixed(1));
|
|
304
|
+
console.log('failed_files=' + failed.length);
|
|
305
|
+
if (failed.length > 0) process.exit(1);
|
|
306
|
+
})
|
|
307
|
+
.catch(e => { console.error(e); process.exit(1); });
|
|
308
|
+
" | tee -a "\$GITHUB_OUTPUT"
|
|
309
|
+
|
|
310
|
+
- name: Post quality summary
|
|
311
|
+
if: github.event_name == 'pull_request'
|
|
312
|
+
uses: actions/github-script@v7
|
|
313
|
+
with:
|
|
314
|
+
script: |
|
|
315
|
+
const overall = '\${{ steps.analysis.outputs.overall_rating }}';
|
|
316
|
+
const failed = '\${{ steps.analysis.outputs.failed_files }}';
|
|
317
|
+
github.rest.issues.createComment({
|
|
318
|
+
issue_number: context.issue.number,
|
|
319
|
+
owner: context.repo.owner,
|
|
320
|
+
repo: context.repo.repo,
|
|
321
|
+
body: \`## Gate Keeper Quality Report\\n\\n**Overall rating:** \${overall}/10\\n**Files below threshold:** \${failed}\\n\\nRun \\\`get_graph_report\\\` in gate-keeper MCP for full analysis.\`
|
|
322
|
+
});
|
|
323
|
+
`;
|
|
324
|
+
return {
|
|
325
|
+
platform: 'github-action',
|
|
326
|
+
filePath: path.join('.github', 'workflows', 'gate-keeper.yml'),
|
|
327
|
+
content,
|
|
328
|
+
description: 'Creates .github/workflows/gate-keeper.yml for CI quality analysis',
|
|
329
|
+
append: false,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function getPlatformConfig(platform, repoRoot, gateKeeperPath) {
|
|
333
|
+
switch (platform) {
|
|
334
|
+
case 'claude-code': return claudeCodeConfig(repoRoot);
|
|
335
|
+
case 'copilot': return copilotConfig(repoRoot, gateKeeperPath);
|
|
336
|
+
case 'cursor': return cursorConfig(repoRoot);
|
|
337
|
+
case 'vscode': return vscodeConfig(repoRoot, gateKeeperPath);
|
|
338
|
+
case 'github-action': return githubActionConfig();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/mcp/installer.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBH,4CAoBC;AAED,sCA0IC;AAED,oCA2BC;AAED,oCAmBC;AAED,gDAwEC;AAED,8CAYC;AAxTD,2CAA6B;AAY7B,8DAA8D;AAE9D,SAAgB,gBAAg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|
|
2
|
+
* Gate Keeper — MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Exposes code-quality analysis as MCP tools that AI agents (GitHub Copilot,
|
|
5
|
+
* Claude, etc.) call after file edits. The agent sees the rating, violations,
|
|
6
|
+
* and codebase health, then self-corrects until quality reaches the threshold.
|
|
7
|
+
*
|
|
8
|
+
* Protocol: JSON-RPC 2.0 over stdio (MCP standard transport).
|
|
9
|
+
*
|
|
10
|
+
* Run: npx tsx src/mcp/server.ts
|
|
11
|
+
* node dist/mcp/server.js
|
|
12
|
+
*/
|
|
13
|
+
export declare const TOOLS: ({
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object";
|
|
18
|
+
properties: {
|
|
19
|
+
file_path?: undefined;
|
|
20
|
+
repo?: undefined;
|
|
21
|
+
directory?: undefined;
|
|
22
|
+
max_files?: undefined;
|
|
23
|
+
};
|
|
24
|
+
required?: undefined;
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: "object";
|
|
31
|
+
properties: {
|
|
32
|
+
file_path: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
repo: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
directory?: undefined;
|
|
41
|
+
max_files?: undefined;
|
|
42
|
+
};
|
|
43
|
+
required: string[];
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: "object";
|
|
50
|
+
properties: {
|
|
51
|
+
repo: {
|
|
52
|
+
type: string;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
file_path?: undefined;
|
|
56
|
+
directory?: undefined;
|
|
57
|
+
max_files?: undefined;
|
|
58
|
+
};
|
|
59
|
+
required?: undefined;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
inputSchema: {
|
|
65
|
+
type: "object";
|
|
66
|
+
properties: {
|
|
67
|
+
directory: {
|
|
68
|
+
type: string;
|
|
69
|
+
description: string;
|
|
70
|
+
};
|
|
71
|
+
max_files: {
|
|
72
|
+
type: string;
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
file_path?: undefined;
|
|
76
|
+
repo?: undefined;
|
|
77
|
+
};
|
|
78
|
+
required?: undefined;
|
|
79
|
+
};
|
|
80
|
+
})[];
|
|
81
|
+
export interface JsonRpcRequest {
|
|
82
|
+
jsonrpc: '2.0';
|
|
83
|
+
id?: number | string;
|
|
84
|
+
method: string;
|
|
85
|
+
params?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
export interface JsonRpcResponse {
|
|
88
|
+
jsonrpc: '2.0';
|
|
89
|
+
id: number | string | null;
|
|
90
|
+
result?: unknown;
|
|
91
|
+
error?: {
|
|
92
|
+
code: number;
|
|
93
|
+
message: string;
|
|
94
|
+
data?: unknown;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Send JSON-RPC response to stdout */
|
|
98
|
+
export declare function send(response: JsonRpcResponse): void;
|
|
99
|
+
/** Send successful result */
|
|
100
|
+
export declare function sendResult(id: number | string | null, result: unknown): void;
|
|
101
|
+
/** Send error response */
|
|
102
|
+
export declare function sendError(id: number | string | null, code: number, message: string): void;
|
|
103
|
+
/** Handle incoming JSON-RPC message */
|
|
104
|
+
export declare function handleMessage(msg: JsonRpcRequest): Promise<void>;
|
|
105
|
+
/** Process a line of input from stdin */
|
|
106
|
+
export declare function processLine(line: string, buffer: {
|
|
107
|
+
current: string;
|
|
108
|
+
}): void;
|
|
109
|
+
/** Start the MCP server (stdio transport) */
|
|
110
|
+
export declare function startServer(): void;
|
|
111
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 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MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmB3E;AAED,6CAA6C;AAC7C,wBAAgB,WAAW,IAAI,IAAI,CAwBlC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gate Keeper — MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes code-quality analysis as MCP tools that AI agents (GitHub Copilot,
|
|
6
|
+
* Claude, etc.) call after file edits. The agent sees the rating, violations,
|
|
7
|
+
* and codebase health, then self-corrects until quality reaches the threshold.
|
|
8
|
+
*
|
|
9
|
+
* Protocol: JSON-RPC 2.0 over stdio (MCP standard transport).
|
|
10
|
+
*
|
|
11
|
+
* Run: npx tsx src/mcp/server.ts
|
|
12
|
+
* node dist/mcp/server.js
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TOOLS = void 0;
|
|
16
|
+
exports.send = send;
|
|
17
|
+
exports.sendResult = sendResult;
|
|
18
|
+
exports.sendError = sendError;
|
|
19
|
+
exports.handleMessage = handleMessage;
|
|
20
|
+
exports.processLine = processLine;
|
|
21
|
+
exports.startServer = startServer;
|
|
22
|
+
const handlers_1 = require("./handlers");
|
|
23
|
+
// ── Tool definitions ───────────────────────────────────────
|
|
24
|
+
exports.TOOLS = [
|
|
25
|
+
{
|
|
26
|
+
name: 'get_quality_rules',
|
|
27
|
+
description: 'Return the quality rules, thresholds, and scoring deductions Gate Keeper enforces. ' +
|
|
28
|
+
'Call this at session start to understand what to avoid when writing code.',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'get_file_context',
|
|
36
|
+
description: 'Get full context for a file: quality rating, dependencies (what it imports), ' +
|
|
37
|
+
'reverse dependencies (files that import it), circular dependency cycles, ' +
|
|
38
|
+
'rating breakdown, rating trend, and git diff. Compact response for LLM consumption.',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
file_path: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'Absolute path to the source file',
|
|
45
|
+
},
|
|
46
|
+
repo: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Repository root path (defaults to git root of file_path)',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
required: ['file_path'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'get_graph_summary',
|
|
56
|
+
description: 'Return a pre-computed dependency graph summary: rating distribution, ' +
|
|
57
|
+
'top fan-in / fan-out hotspots (with fragileHub flags), worst-rated files, ' +
|
|
58
|
+
'circular dependencies, and module-level coupling. Also returns raw ' +
|
|
59
|
+
'nodes/edges/adjacency/reverseAdjacency for power use. Use the `summary` ' +
|
|
60
|
+
'fields directly instead of recomputing them — they answer the common ' +
|
|
61
|
+
'"which files are risky/hottest/worst?" questions without further analysis.',
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
repo: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Repository root path (defaults to git root of cwd)',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'get_dependency_graph',
|
|
74
|
+
description: 'Return the full repository dependency graph in a compact, LLM-optimized format. ' +
|
|
75
|
+
'Includes: adjacency (file → imports), reverseAdjacency (file → dependents), ' +
|
|
76
|
+
'nodeData (rating, violations, LOC per file), edges, and cycles. ' +
|
|
77
|
+
'Use this for full graph traversal and architecture analysis. ' +
|
|
78
|
+
'For pre-computed analytics (hotspots, worst files), use get_graph_summary instead.',
|
|
79
|
+
inputSchema: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
repo: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'Repository root path (defaults to git root of cwd)',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'get_codebase_health',
|
|
91
|
+
description: 'Scan the codebase and return overall quality: average rating, rating distribution, ' +
|
|
92
|
+
'worst-rated files, most common violations, and topological fix order.',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
directory: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
description: 'Absolute path to the directory to scan (defaults to git root or cwd)',
|
|
99
|
+
},
|
|
100
|
+
max_files: {
|
|
101
|
+
type: 'number',
|
|
102
|
+
description: 'Maximum files to analyze (default 200)',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
/** Send JSON-RPC response to stdout */
|
|
109
|
+
function send(response) {
|
|
110
|
+
const json = JSON.stringify(response);
|
|
111
|
+
process.stdout.write(json + '\n');
|
|
112
|
+
}
|
|
113
|
+
/** Send successful result */
|
|
114
|
+
function sendResult(id, result) {
|
|
115
|
+
send({ jsonrpc: '2.0', id, result });
|
|
116
|
+
}
|
|
117
|
+
/** Send error response */
|
|
118
|
+
function sendError(id, code, message) {
|
|
119
|
+
send({ jsonrpc: '2.0', id, error: { code, message } });
|
|
120
|
+
}
|
|
121
|
+
/** Handle incoming JSON-RPC message */
|
|
122
|
+
async function handleMessage(msg) {
|
|
123
|
+
const { id, method, params } = msg;
|
|
124
|
+
switch (method) {
|
|
125
|
+
case 'initialize':
|
|
126
|
+
sendResult(id ?? null, {
|
|
127
|
+
protocolVersion: '2024-11-05',
|
|
128
|
+
capabilities: { tools: {} },
|
|
129
|
+
serverInfo: { name: 'gate-keeper', version: '1.0.0' },
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
case 'notifications/initialized':
|
|
133
|
+
// No response needed for notifications
|
|
134
|
+
break;
|
|
135
|
+
case 'tools/list':
|
|
136
|
+
sendResult(id ?? null, { tools: exports.TOOLS });
|
|
137
|
+
break;
|
|
138
|
+
case 'tools/call': {
|
|
139
|
+
const callParams = params;
|
|
140
|
+
const toolName = String(callParams?.name ?? '');
|
|
141
|
+
const toolArgs = (callParams?.arguments ?? {});
|
|
142
|
+
try {
|
|
143
|
+
const result = await (0, handlers_1.handleToolCall)(toolName, toolArgs);
|
|
144
|
+
sendResult(id ?? null, result);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
148
|
+
sendResult(id ?? null, {
|
|
149
|
+
content: [{ type: 'text', text: `Error: ${message}` }],
|
|
150
|
+
isError: true,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case 'ping':
|
|
156
|
+
sendResult(id ?? null, {});
|
|
157
|
+
break;
|
|
158
|
+
default:
|
|
159
|
+
// Ignore unknown notifications (no id), error on unknown requests (with id)
|
|
160
|
+
if (id !== undefined) {
|
|
161
|
+
sendError(id, -32601, `Method not found: ${method}`);
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** Process a line of input from stdin */
|
|
167
|
+
function processLine(line, buffer) {
|
|
168
|
+
buffer.current += line;
|
|
169
|
+
let nlIndex;
|
|
170
|
+
while ((nlIndex = buffer.current.indexOf('\n')) !== -1) {
|
|
171
|
+
const completeLine = buffer.current.substring(0, nlIndex).trim();
|
|
172
|
+
buffer.current = buffer.current.substring(nlIndex + 1);
|
|
173
|
+
if (!completeLine || completeLine.startsWith('Content-Length:'))
|
|
174
|
+
continue;
|
|
175
|
+
try {
|
|
176
|
+
const msg = JSON.parse(completeLine);
|
|
177
|
+
handleMessage(msg).catch(err => {
|
|
178
|
+
process.stderr.write(`[gate-keeper] Handler error: ${err}\n`);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Not valid JSON — skip
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** Start the MCP server (stdio transport) */
|
|
187
|
+
function startServer() {
|
|
188
|
+
const buffer = { current: '' };
|
|
189
|
+
process.stdin.setEncoding('utf8');
|
|
190
|
+
process.stdin.on('data', (chunk) => {
|
|
191
|
+
buffer.current += chunk;
|
|
192
|
+
let nlIndex;
|
|
193
|
+
while ((nlIndex = buffer.current.indexOf('\n')) !== -1) {
|
|
194
|
+
const line = buffer.current.substring(0, nlIndex).trim();
|
|
195
|
+
buffer.current = buffer.current.substring(nlIndex + 1);
|
|
196
|
+
if (!line || line.startsWith('Content-Length:'))
|
|
197
|
+
continue;
|
|
198
|
+
try {
|
|
199
|
+
const msg = JSON.parse(line);
|
|
200
|
+
handleMessage(msg).catch(err => {
|
|
201
|
+
process.stderr.write(`[gate-keeper] Handler error: ${err}\n`);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// Not valid JSON — skip
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
process.stdin.on('end', () => process.exit(0));
|
|
210
|
+
process.stderr.write('[gate-keeper] MCP server started (stdio)\n');
|
|
211
|
+
}
|
|
212
|
+
// Only start server when run directly, not when imported for testing
|
|
213
|
+
if (require.main === module) {
|
|
214
|
+
startServer();
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAiHH,oBAGC;AAGD,gCAEC;AAGD,8BAEC;AAGD,sCAgDC;AAGD,kCAmBC;AAGD,kCAwBC;AAhOD,yCAA0D;AAE1D,8DAA8D;AAEjD,QAAA,KAAK,GAAG;IACnB;QACE,IAAI,EAAE,mBAA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