@mohantn/gate-keeper 2.2.2 → 2.2.3

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 CHANGED
@@ -13,11 +13,9 @@
13
13
 
14
14
  ## What it is
15
15
 
16
- Gate Keeper analyzes every file your AI agent writes TypeScript Compiler API for TS/JS/JSX, Roslyn (or text fallback) for C# rates it 0–10, and publishes the result to a live dependency graph. Agents see the graph through a 5-tool MCP server; humans see it at `http://localhost:5378/viz`.
16
+ Gate Keeper sits between you and your AI coding agent — Claude Code, GitHub Copilot, or any MCP-compatible editor. Every file the agent writes is analyzed (TypeScript Compiler API for TS/JS/JSX, Roslyn for C#), rated 0–10, and published to a live dependency graph. The agent sees the graph through a 5-tool MCP server; you see it at a live dashboard.
17
17
 
18
- Two integration points:
19
- - **Claude Code** — Pre/PostToolUse hooks that block low-quality or high-risk edits
20
- - **GitHub Copilot / VS Code** — `.github/instructions/gate-keeper.instructions.md` + `.vscode/mcp.json` + `.vscode/tasks.json`
18
+ **Quality feedback loop:** Claude Code hooks tell the agent to use the MCP tools at the right moments — `get_dependency_graph` at session start, `get_file_context` before edits, `get_codebase_health` after bulk changes. The agent self-corrects based on the data these tools return.
21
19
 
22
20
  ---
23
21
 
@@ -27,95 +25,134 @@ Two integration points:
27
25
  npm install -g @mohantn/gate-keeper
28
26
  ```
29
27
 
30
- This installs the `gate-keeper` and `gk` CLI commands.
28
+ Installs two CLI commands: `gate-keeper` and `gk`.
31
29
 
32
30
  ---
33
31
 
34
32
  ## Quick Start
35
33
 
36
34
  ```bash
37
- gate-keeper setup
35
+ gate-keeper setup # Configure for both Claude Code and Copilot
36
+ gate-keeper setup claude # Claude Code only (writes ~/.claude/settings.json)
37
+ gate-keeper setup copilot # Copilot / VS Code only (prints .vscode/ setup)
38
38
  ```
39
39
 
40
- This installs dependencies, builds, starts the daemon, and configures Claude Code hooks. Open **http://localhost:5378/viz** for the live dashboard.
41
-
42
- To run individual components:
40
+ This starts the daemon and configures the tools you're using. Open **http://localhost:5378/viz** for the live dashboard.
43
41
 
44
42
  | Command | Description |
45
43
  |---------|-------------|
46
44
  | `gate-keeper daemon` | Start the daemon (ports 5378 / 5379) |
47
45
  | `gate-keeper mcp` | Start the MCP server (stdio) |
46
+ | `gate-keeper register` | Register current directory as a repo with the daemon |
47
+ | `gate-keeper guide session-start` | Register repo + print MCP tool guidance |
48
+ | `gate-keeper guide pre-edit` | Print pre-edit guidance (`get_file_context`) |
49
+ | `gate-keeper guide post-edit` | Print post-edit guidance (`get_file_context` + `get_codebase_health`) |
48
50
  | `gate-keeper dashboard` | Open the dashboard in browser |
49
51
  | `gate-keeper status` | Check daemon health |
52
+ | `gk <command>` | Short alias for any command |
53
+
54
+ > The npm package ships pre-built. `gate-keeper setup` detects whether you're running from a git clone (builds from source) or a global install (skips build, starts directly).
50
55
 
51
56
  ---
52
57
 
53
58
  ## Claude Code Integration
54
59
 
55
- Gate Keeper uses two hooks in `~/.claude/settings.json`:
60
+ `gate-keeper setup` writes three hooks to `~/.claude/settings.json`:
56
61
 
57
62
  ```json
58
63
  {
59
64
  "hooks": {
65
+ "SessionStart": [
66
+ {
67
+ "hooks": [
68
+ {
69
+ "type": "command",
70
+ "command": "gate-keeper guide session-start"
71
+ }
72
+ ]
73
+ }
74
+ ],
60
75
  "PreToolUse": [
61
76
  {
62
77
  "matcher": "Write|Edit|MultiEdit",
63
- "hooks": [{ "type": "command", "command": "node /path/to/gate-keeper/dist/hook-pre-tool-use.js" }]
78
+ "hooks": [
79
+ {
80
+ "type": "command",
81
+ "command": "gate-keeper guide pre-edit"
82
+ }
83
+ ]
64
84
  }
65
85
  ],
66
86
  "PostToolUse": [
67
87
  {
68
88
  "matcher": "Write|Edit|MultiEdit",
69
- "hooks": [{ "type": "command", "command": "node /path/to/gate-keeper/dist/hook-receiver.js" }]
89
+ "hooks": [
90
+ {
91
+ "type": "command",
92
+ "command": "gate-keeper guide post-edit"
93
+ }
94
+ ]
70
95
  }
71
96
  ]
72
97
  }
73
98
  }
74
99
  ```
75
100
 
76
- **PreToolUse** — before every Write/Edit, the daemon checks the impact set (BFS over reverse dependencies). If editing the file would break 3+ fragile dependents, a warning is printed and the agent is advised to proceed with care.
101
+ **SessionStart** — fires once when a new Claude Code session begins. Registers the repo with the daemon, fetches the dependency graph from the daemon's API, and outputs a compact summary: file count, module directories, most-depended-on files, and average quality rating. Claude sees this architecture context immediately without needing to call a separate MCP tool.
77
102
 
78
- **PostToolUse** — after every Write/Edit, the hook-receiver analyzes the written file using the TypeScript Compiler API (AST-level, not regex). If the quality rating falls below the configured minimum (default 7.0/10), the hook exits with code 2, blocking the edit and surfacing violations inline. The agent self-corrects and retries, creating a tight quality feedback loop.
103
+ **PreToolUse** — fires before every Write/Edit. Prints a reminder to call `get_file_context` with the file path to check its quality rating and dependencies before making changes.
79
104
 
80
- **Session start** — on `SessionStart` and `UserPromptSubmit`, the hook-receiver automatically registers the repository with the daemon. Claude agents should call `get_quality_rules` and `get_file_context` before editing files to understand the dependency landscape.
105
+ **PostToolUse** — fires after every Write/Edit. Prints a reminder to call `get_file_context` again to see the latest quality rating, and to call `get_codebase_health` if 3+ files were changed.
81
106
 
82
- ### Agent workflow inside Claude
107
+ The hooks don't block or analyze anything — they output lightweight guidance text that Claude sees and acts on. The actual quality analysis happens when the agent calls the MCP tools.
83
108
 
84
- At session start:
85
- ```
86
- get_quality_rules ← Learn scoring thresholds and minimum rating
87
- ```
88
-
89
- Before editing any file:
90
- ```
91
- get_file_context <file_path> ← Get rating, imports, importers, cycles, trend
92
- ```
93
-
94
- After bulk changes (3+ files):
95
- ```
96
- get_codebase_health ← Verify overall project quality hasn't degraded
97
- ```
109
+ > No `.github/instructions/` file needed — the hooks themselves guide the agent at the right moments.
98
110
 
99
111
  ---
100
112
 
101
113
  ## GitHub Copilot / VS Code Integration
102
114
 
103
- ### 1. Repository registration (`tasks.json`)
115
+ ### 1. Repository registration task (auto-runs on folder open)
104
116
 
105
- `.vscode/tasks.json` ships in the repo with a task that runs on folder open. It calls `hook-receiver.js` with a `session_create` event to register the repo with the daemon. Copilot instructions handle all subsequent interaction.
117
+ Add `.vscode/tasks.json` in the repo:
118
+
119
+ ```json
120
+ {
121
+ "version": "2.0.0",
122
+ "tasks": [
123
+ {
124
+ "label": "gate-keeper: register repo",
125
+ "type": "shell",
126
+ "command": "gate-keeper",
127
+ "args": [
128
+ "register"
129
+ ],
130
+ "runOptions": {
131
+ "runOn": "folderOpen"
132
+ },
133
+ "presentation": {
134
+ "reveal": "never",
135
+ "echo": false,
136
+ "close": true
137
+ },
138
+ "problemMatcher": []
139
+ }
140
+ ]
141
+ }
142
+ ```
106
143
 
107
- No manual action needed the task fires automatically when the workspace opens.
144
+ This fires automatically when VS Code opens the workspace. It calls `gate-keeper register`, which tells the daemon to watch this repo. The task runs silently — no terminal popup. Works whether gate-keeper is globally installed or locally cloned.
108
145
 
109
- ### 2. Agent instructions
146
+ ### 2. Agent instructions (auto-loaded)
110
147
 
111
- `.github/instructions/gate-keeper.instructions.md` ships in the repo with `applyTo: "**/*.{ts,tsx,jsx,js,cs}"`. Copilot auto-loads it on every matching edit. The instructions tell the agent to:
148
+ Create `.github/instructions/gate-keeper.instructions.md` in the repo with `applyTo: "**/*.{ts,tsx,jsx,js,cs}"`. Copilot auto-loads it on every matching edit. The instructions tell the agent to:
112
149
 
113
150
  - Call `get_quality_rules` at session start
114
151
  - Call `get_file_context` before editing any file
115
152
  - Call `get_codebase_health` after bulk changes
116
153
  - Follow the quality thresholds
117
154
 
118
- ### 3. MCP server
155
+ ### 3. MCP server for VS Code
119
156
 
120
157
  To let VS Code discover the MCP server, add `.vscode/mcp.json`:
121
158
 
@@ -123,92 +160,26 @@ To let VS Code discover the MCP server, add `.vscode/mcp.json`:
123
160
  {
124
161
  "servers": {
125
162
  "gate-keeper": {
126
- "command": "node",
127
- "args": ["${workspaceFolder}/dist/mcp/server.js"]
163
+ "command": "gate-keeper",
164
+ "args": ["mcp"]
128
165
  }
129
166
  }
130
167
  }
131
168
  ```
132
169
 
133
- This ships with the repo no manual setup needed for existing clones.
134
-
135
- ---
136
-
137
- ## MCP Tools (5)
138
-
139
- | Tool | Purpose |
140
- |------|---------|
141
- | `get_quality_rules` | Scoring thresholds, deductions, minimum rating. Call once per session. |
142
- | `get_file_context` | Single-file dossier: rating, imports, importers, cycles, trend, git diff. |
143
- | `get_dependency_graph` | Full repo graph in compact LLM-optimized format. |
144
- | `get_graph_summary` | Pre-computed analytics: rating distribution, hotspots, worst files, module coupling. |
145
- | `get_codebase_health` | Avg rating, distribution, worst files, common violations, fix order. |
146
-
147
- ---
148
-
149
- ## Quality System
150
-
151
- Each file rated 0–10 (10 minus deductions):
152
-
153
- | Deduction | Trigger |
154
- |-----------|---------|
155
- | −1.5 / error | Missing `key`, empty catch |
156
- | −0.5 / warning | `any`, god class, long method, tight coupling |
157
- | −0.1 / info | `console.log`, magic number |
158
- | −2.0 / −1.0 | Cyclomatic complexity > 20 / > 10 |
159
- | −2.0 / −0.5 | Import count > 30 / > 15 |
160
- | −1.5 / −0.5 | LOC > 500 / > 300 |
161
- | −1.0 / cycle | Circular dependency |
162
- | −2.5 / −2.0 / −1.0 | Test coverage < 30% / < 50% / < 80% |
163
-
164
- **Minimum passing rating: 7.0/10** (configurable in `~/.gate-keeper/config.json`).
165
-
166
- ---
167
-
168
- ## Architecture
169
-
170
- ```
171
- Claude Code VS Code / Copilot
172
- │ │
173
- │ Hooks (PreToolUse / PostToolUse) │ MCP + instructions
174
- ▼ ▼
175
- ┌──────────────────────────────────────────────────┐
176
- │ daemon (ports 5378 / 5379) │
177
- │ UniversalAnalyzer → RatingCalc → SqliteCache │
178
- │ DependencyGraph (in-memory, cycle detection) │
179
- └──────────┬───────────────────┬───────────────────┘
180
- │ WebSocket+HTTP │ stdio
181
- ▼ ▼
182
- ┌────────────────┐ ┌────────────────┐
183
- │ Dashboard │ │ MCP Server │
184
- │ :5378/viz │ │ (5 tools) │
185
- └────────────────┘ └────────────────┘
186
- ```
187
-
188
- ### Key files
189
-
190
- | Path | Purpose |
191
- |------|---------|
192
- | `src/hook-pre-tool-use.ts` | PreToolUse hook — blocks risky edits, exit 2 |
193
- | `src/hook-receiver.ts` | PostToolUse / SessionStart / session_create handler — < 100 ms |
194
- | `src/daemon.ts` | Long-lived daemon, ports 5378 / 5379 |
195
- | `src/analyzer/` | TS Compiler API + C# analyzers |
196
- | `src/rating/rating-calculator.ts` | 0–10 scoring engine |
197
- | `src/graph/` | Dependency graph, BFS impact sets, centrality, cycle detection |
198
- | `src/mcp/server.ts` | 5-tool MCP server (stdio) |
199
- | `src/viz/` | Dashboard server + HTML visualizer |
170
+ Works with both global install and local clone `gate-keeper` is always on PATH.
200
171
 
201
172
  ---
202
173
 
203
- ## Ports & Files
174
+ ## Troubleshooting
204
175
 
205
- | Resource | Purpose |
206
- |----------|---------|
207
- | `:5378` | Dashboard HTTP + WebSocket |
208
- | `:5379` | Daemon IPC (localhost only) |
209
- | `~/.gate-keeper/cache.db` | SQLite analyses, rating history, repos |
210
- | `~/.gate-keeper/config.json` | `minRating` threshold (default 7.0) |
211
- | `~/.gate-keeper/daemon.pid` | PID file |
176
+ | Symptom | Cause | Fix |
177
+ |---------|-------|-----|
178
+ | Daemon won't start | Missing runtime dependency (eslint) or port conflict | Run `npm install -g @mohantn/gate-keeper` again, or kill the process on ports 5378/5379. |
179
+ | Hooks not firing | `~/.claude/settings.json` missing or wrong path | Run `gate-keeper setup` again. |
180
+ | `gate-keeper register` fails | Daemon isn't running | Start it first: `gate-keeper daemon` |
181
+ | Copilot doesn't see MCP tools | `.vscode/mcp.json` missing or incorrect | Use `"command": "gate-keeper"` and `"args": ["mcp"]` (not a file path) |
182
+ | Agent isn't calling MCP tools | Hooks output not being followed | The hooks print guidance — Claude should act on it. If not, check `~/.claude/settings.json` is correct. |
212
183
 
213
184
  ---
214
185
 
@@ -6,6 +6,8 @@
6
6
  * gate-keeper setup # Install deps, build, start daemon, write hooks
7
7
  * gate-keeper daemon # Start the daemon
8
8
  * gate-keeper mcp # Start the MCP server (stdio)
9
+ * gate-keeper register # Register current directory as a repo
10
+ * gate-keeper guide # Print context-aware guidance for the AI agent
9
11
  * gate-keeper dashboard # Open the dashboard in browser
10
12
  * gate-keeper status # Check daemon status
11
13
  * gate-keeper help # Show this help
@@ -1 +1 @@
1
- {"version":3,"file":"cli-entry.d.ts","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;GAeG"}
1
+ {"version":3,"file":"cli-entry.d.ts","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;GAiBG"}
package/dist/cli-entry.js CHANGED
@@ -7,6 +7,8 @@
7
7
  * gate-keeper setup # Install deps, build, start daemon, write hooks
8
8
  * gate-keeper daemon # Start the daemon
9
9
  * gate-keeper mcp # Start the MCP server (stdio)
10
+ * gate-keeper register # Register current directory as a repo
11
+ * gate-keeper guide # Print context-aware guidance for the AI agent
10
12
  * gate-keeper dashboard # Open the dashboard in browser
11
13
  * gate-keeper status # Check daemon status
12
14
  * gate-keeper help # Show this help
@@ -53,19 +55,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
55
  const child_process = __importStar(require("child_process"));
54
56
  const path = __importStar(require("path"));
55
57
  const http = __importStar(require("http"));
58
+ const fs = __importStar(require("fs"));
56
59
  const GK_DIR = path.join(process.env.HOME ?? '/tmp', '.gate-keeper');
57
60
  const PID_FILE = path.join(GK_DIR, 'daemon.pid');
58
61
  const DAEMON_PORT = 5378;
62
+ const IPC_PORT = 5379;
59
63
  const HELP = `
60
- Gate Keeper Real-time quality gates for AI-assisted development
64
+ \xe2\xac\xa1 Gate Keeper \xe2\x80\x94 Real-time quality gates for AI-assisted development
61
65
 
62
66
  Usage:
63
67
  gate-keeper <command>
64
68
 
65
69
  Commands:
66
- setup Install deps, build, start daemon, write Claude hooks
70
+ setup Set up daemon + (claude|copilot|both). Default: both
67
71
  daemon Start the daemon (ports 5378/5379)
68
- mcp Start the MCP server (stdio) pipe to your MCP client
72
+ mcp Start the MCP server (stdio) \xe2\x80\x94 pipe to your MCP client
73
+ register Register the current directory as a repo with the daemon
74
+ guide Print context-aware guidance for the AI agent
69
75
  dashboard Open http://localhost:5378/viz in your browser
70
76
  status Check if the daemon is running
71
77
  help Show this message
@@ -73,11 +79,11 @@ Commands:
73
79
  Examples:
74
80
  gate-keeper setup
75
81
  gate-keeper daemon --no-scan
82
+ gate-keeper register
76
83
  echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | gate-keeper mcp
77
84
  `;
78
85
  function isDaemonAlive() {
79
86
  try {
80
- const fs = require('fs');
81
87
  const pid = parseInt(fs.readFileSync(PID_FILE, 'utf8').trim(), 10);
82
88
  if (isNaN(pid))
83
89
  return false;
@@ -88,12 +94,36 @@ function isDaemonAlive() {
88
94
  return false;
89
95
  }
90
96
  }
97
+ function findGitRoot(dir) {
98
+ try {
99
+ const result = child_process.spawnSync('git', ['rev-parse', '--show-toplevel'], {
100
+ cwd: dir, encoding: 'utf8', timeout: 3000
101
+ });
102
+ return (result.status === 0 && result.stdout.trim()) ? result.stdout.trim() : dir;
103
+ }
104
+ catch {
105
+ return dir;
106
+ }
107
+ }
108
+ function getDaemonStatus() {
109
+ if (!isDaemonAlive()) {
110
+ return 'daemon-not-running';
111
+ }
112
+ try {
113
+ const pid = fs.readFileSync(PID_FILE, 'utf8').trim();
114
+ return `daemon-running (PID: ${pid})`;
115
+ }
116
+ catch {
117
+ return 'daemon-not-running';
118
+ }
119
+ }
91
120
  async function main() {
92
121
  const cmd = process.argv[2]?.toLowerCase() ?? 'help';
93
122
  switch (cmd) {
94
123
  case 'setup': {
95
124
  const setupScript = path.join(__dirname, '..', 'scripts', 'setup.sh');
96
- const result = child_process.spawnSync('bash', [setupScript], {
125
+ const args = process.argv.slice(3);
126
+ const result = child_process.spawnSync('bash', [setupScript, ...args], {
97
127
  stdio: 'inherit',
98
128
  cwd: path.join(__dirname, '..'),
99
129
  });
@@ -119,6 +149,123 @@ async function main() {
119
149
  mcp.on('exit', (code) => process.exit(code ?? 0));
120
150
  break;
121
151
  }
152
+ case 'guide': {
153
+ const event = process.argv[3]?.toLowerCase() ?? '';
154
+ const daemonStatus = getDaemonStatus();
155
+ switch (event) {
156
+ case 'session-start': {
157
+ console.log(`[Gate Keeper] Guide: session-start`);
158
+ const repoRoot = findGitRoot(process.cwd());
159
+ const repoName = path.basename(repoRoot);
160
+ const sessionId = `claude-${Date.now()}`;
161
+ if (daemonStatus.startsWith('daemon-running')) {
162
+ // Register the repo
163
+ try {
164
+ const body = JSON.stringify({
165
+ action: 'register_repo',
166
+ repo: { path: repoRoot, name: repoName, sessionId, sessionType: 'claude', createdAt: Date.now() }
167
+ });
168
+ await new Promise((resolve, reject) => {
169
+ const req = http.request({
170
+ hostname: '127.0.0.1', port: IPC_PORT, path: '/repo-register',
171
+ method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }
172
+ }, () => resolve());
173
+ req.on('error', reject);
174
+ req.setTimeout(3000, () => { req.destroy(); reject(new Error('timeout')); });
175
+ req.write(body);
176
+ req.end();
177
+ });
178
+ }
179
+ catch { /* non-blocking */ }
180
+ // Fetch dependency graph
181
+ try {
182
+ const encodedRepo = encodeURIComponent(repoRoot);
183
+ const graphData = await new Promise((resolve, reject) => {
184
+ const req = http.get(`http://127.0.0.1:${DAEMON_PORT}/api/graph?repo=${encodedRepo}`, (res) => {
185
+ let d = '';
186
+ res.on('data', (c) => d += c);
187
+ res.on('end', () => { try {
188
+ resolve(JSON.parse(d));
189
+ }
190
+ catch {
191
+ resolve(null);
192
+ } });
193
+ });
194
+ req.on('error', reject);
195
+ req.setTimeout(5000, () => { req.destroy(); reject(new Error('timeout')); });
196
+ });
197
+ if (graphData && graphData.nodes && graphData.nodes.length > 0) {
198
+ const nodes = graphData.nodes;
199
+ const edges = graphData.edges || [];
200
+ const topDirs = new Set();
201
+ for (const n of nodes) {
202
+ const nodeId = n.id || n.path || '';
203
+ // Strip repo prefix to get relative path, then extract module dir
204
+ const relPath = repoRoot ? nodeId.replace(repoRoot + '/', '') : nodeId;
205
+ const firstDir = relPath.split('/')[0];
206
+ if (firstDir)
207
+ topDirs.add(firstDir);
208
+ }
209
+ const importCount = new Map();
210
+ for (const e of edges) {
211
+ importCount.set(e.target, (importCount.get(e.target) || 0) + 1);
212
+ }
213
+ const topImported = [...importCount.entries()]
214
+ .sort((a, b) => b[1] - a[1])
215
+ .slice(0, 5)
216
+ .map(e => `${repoRoot ? e[0].replace(repoRoot + '/', '') : e[0]} (${e[1]} dependents)`);
217
+ const avgRating = nodes.reduce((s, n) => s + (n.rating || 0), 0) / nodes.length;
218
+ console.log(` Registered ${repoName}. Codebase: ${nodes.length} files, ${edges.length} deps`);
219
+ console.log(` Modules: ${[...topDirs].sort().join(', ')}`);
220
+ if (topImported.length > 0)
221
+ console.log(` Hot files: ${topImported.join('; ')}`);
222
+ console.log(` Avg quality: ${avgRating.toFixed(1)}/10 (minimum 7.0/10)`);
223
+ }
224
+ else {
225
+ console.log(` Registered ${repoName}. Call get_dependency_graph for codebase context.`);
226
+ }
227
+ }
228
+ catch {
229
+ console.log(` Registered ${repoName}. Minimum quality: 7.0/10.`);
230
+ }
231
+ }
232
+ else {
233
+ console.log(` Repository: ${repoName}. Daemon not running — quality gates inactive.`);
234
+ }
235
+ break;
236
+ }
237
+ case 'pre-edit': {
238
+ const filePath = process.argv[4] ?? '';
239
+ console.log('[Gate Keeper] Guide: pre-edit');
240
+ if (filePath) {
241
+ console.log(` Before editing ${filePath}, call get_file_context with this file path.`);
242
+ console.log(' This returns the quality rating, dependencies, and violation details.');
243
+ }
244
+ else {
245
+ console.log(' Before editing files, call get_file_context to check quality and dependencies.');
246
+ }
247
+ console.log(' Aim for the minimum quality rating (default 7.0/10).');
248
+ break;
249
+ }
250
+ case 'post-edit': {
251
+ console.log(`[Gate Keeper] Guide: post-edit`);
252
+ console.log(` Call get_file_context again to see the latest rating after your edit.`);
253
+ console.log(` If you changed 3+ files, also call get_codebase_health to verify overall quality.`);
254
+ break;
255
+ }
256
+ default:
257
+ console.log('[Gate Keeper] Guide');
258
+ console.log('');
259
+ console.log(' Usage: gate-keeper guide <event> [file-path]');
260
+ console.log('');
261
+ console.log(' Events:');
262
+ console.log(' session-start Register repo and print guidance');
263
+ console.log(' pre-edit Print pre-edit guidance');
264
+ console.log(' post-edit Print post-edit guidance');
265
+ break;
266
+ }
267
+ break;
268
+ }
122
269
  case 'dashboard': {
123
270
  const url = `http://localhost:${DAEMON_PORT}/viz`;
124
271
  if (isDaemonAlive()) {
@@ -132,12 +279,59 @@ async function main() {
132
279
  }
133
280
  break;
134
281
  }
282
+ case 'register': {
283
+ const repoRoot = findGitRoot(process.cwd());
284
+ const repoName = path.basename(repoRoot);
285
+ const sessionId = `cli-${Date.now()}`;
286
+ if (!isDaemonAlive()) {
287
+ console.log('[gate-keeper] Daemon is not running. Start it first:');
288
+ console.log(' gate-keeper daemon');
289
+ process.exit(1);
290
+ }
291
+ const body = JSON.stringify({
292
+ action: 'register_repo',
293
+ repo: {
294
+ path: repoRoot,
295
+ name: repoName,
296
+ sessionId,
297
+ sessionType: 'cli',
298
+ createdAt: Date.now()
299
+ }
300
+ });
301
+ try {
302
+ await new Promise((resolve, reject) => {
303
+ const req = http.request({
304
+ hostname: '127.0.0.1',
305
+ port: IPC_PORT,
306
+ path: '/repo-register',
307
+ method: 'POST',
308
+ headers: {
309
+ 'Content-Type': 'application/json',
310
+ 'Content-Length': Buffer.byteLength(body)
311
+ }
312
+ }, (res) => {
313
+ let d = '';
314
+ res.on('data', (c) => d += c);
315
+ res.on('end', () => resolve(d));
316
+ });
317
+ req.on('error', reject);
318
+ req.setTimeout(5000, () => { req.destroy(); reject(new Error('timeout')); });
319
+ req.write(body);
320
+ req.end();
321
+ });
322
+ console.log(`[gate-keeper] Registered repo: ${repoName} (${repoRoot})`);
323
+ }
324
+ catch {
325
+ console.log(`[gate-keeper] Failed to register repo — daemon not responding on port ${IPC_PORT}`);
326
+ process.exit(1);
327
+ }
328
+ break;
329
+ }
135
330
  case 'status': {
136
331
  if (isDaemonAlive()) {
137
- const pid = require('fs').readFileSync(PID_FILE, 'utf8').trim();
332
+ const pid = fs.readFileSync(PID_FILE, 'utf8').trim();
138
333
  console.log(`[gate-keeper] Daemon is running (PID: ${pid})`);
139
334
  console.log(` Dashboard: http://localhost:${DAEMON_PORT}/viz`);
140
- // Quick health check
141
335
  try {
142
336
  const data = await new Promise((resolve, reject) => {
143
337
  const req = http.get(`http://127.0.0.1:${DAEMON_PORT}/api/status`, (res) => {
@@ -1 +1 @@
1
- {"version":3,"file":"cli-entry.js","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6DAA+C;AAC/C,2CAA6B;AAC7B,2CAA6B;AAE7B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,EAAE,cAAc,CAAC,CAAC;AACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACjD,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;CAkBZ,CAAC;AAEF,SAAS,aAAa;IACpB,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACnE,IAAI,KAAK,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC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C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohantn/gate-keeper",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Real-time code quality gates & dependency graph for AI-assisted development. MCP server for Claude Code, GitHub Copilot, and any MCP-compatible agent.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -66,7 +66,10 @@
66
66
  "express": "^4.18.2",
67
67
  "open": "^9.1.0",
68
68
  "typescript": "^5.3.3",
69
- "ws": "^8.16.0"
69
+ "ws": "^8.16.0",
70
+ "eslint": "^9.39.4",
71
+ "eslint-plugin-sonarjs": "^4.0.3",
72
+ "@typescript-eslint/parser": "^8.59.4"
70
73
  },
71
74
  "devDependencies": {
72
75
  "@testing-library/jest-dom": "^6.1.5",
@@ -76,9 +79,6 @@
76
79
  "@types/jest": "^29.5.11",
77
80
  "@types/node": "^20.11.5",
78
81
  "@types/ws": "^8.5.10",
79
- "@typescript-eslint/parser": "^8.59.4",
80
- "eslint": "^9.39.4",
81
- "eslint-plugin-sonarjs": "^4.0.3",
82
82
  "jest": "^29.7.0",
83
83
  "jest-environment-jsdom": "^29.7.0",
84
84
  "react": "^18.2.0",
package/scripts/setup.sh CHANGED
@@ -1,9 +1,37 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
+ MODE="${1:-both}"
5
+
4
6
  GATE_KEEPER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
7
  DAEMON_PID_FILE="$HOME/.gate-keeper/daemon.pid"
6
8
 
9
+ # Validate mode
10
+ if [[ "$MODE" != "claude" && "$MODE" != "copilot" && "$MODE" != "both" ]]; then
11
+ echo "[gate-keeper] Unknown option: $MODE"
12
+ echo " Usage: gate-keeper setup [claude|copilot]"
13
+ echo " claude - Configure for Claude Code (writes hooks to ~/.claude/settings.json)"
14
+ echo " copilot - Configure for GitHub Copilot / VS Code (prints .vscode/ setup)"
15
+ echo " (none) - Configure for both Claude Code and Copilot"
16
+ exit 1
17
+ fi
18
+
19
+ if [[ "$MODE" == "both" ]]; then
20
+ echo "[gate-keeper] Setting up for Claude Code and Copilot"
21
+ elif [[ "$MODE" == "claude" ]]; then
22
+ echo "[gate-keeper] Setting up for Claude Code only"
23
+ else
24
+ echo "[gate-keeper] Setting up for Copilot / VS Code only"
25
+ fi
26
+
27
+ # Detect installation context: git clone (has source) vs global npm install (pre-built)
28
+ HAS_SOURCE=false
29
+ [[ -f "$GATE_KEEPER_DIR/tsconfig.json" ]] && HAS_SOURCE=true
30
+ HAS_DASHBOARD=false
31
+ [[ -d "$GATE_KEEPER_DIR/dashboard" ]] && HAS_DASHBOARD=true
32
+
33
+ echo "[gate-keeper] Detected: $([[ $HAS_SOURCE == true ]] && echo 'source build (git clone)' || echo 'pre-built package (npm global)')"
34
+
7
35
  # Kill old daemon process if it exists
8
36
  if [[ -f "$DAEMON_PID_FILE" ]]; then
9
37
  OLD_PID=$(cat "$DAEMON_PID_FILE")
@@ -26,54 +54,75 @@ done
26
54
 
27
55
  sleep 1
28
56
 
29
- echo "[gate-keeper] Installing dependencies..."
30
- cd "$GATE_KEEPER_DIR"
31
- npm install --silent
57
+ # ── Build from source (only for git clones) ──
58
+ if [[ $HAS_SOURCE == true ]]; then
59
+ echo "[gate-keeper] Installing dependencies..."
60
+ cd "$GATE_KEEPER_DIR"
61
+ npm install --silent
32
62
 
33
- echo "[gate-keeper] Building TypeScript..."
34
- npx tsc
63
+ echo "[gate-keeper] Building TypeScript..."
64
+ npx tsc
35
65
 
36
- echo "[gate-keeper] Building dashboard..."
37
- cd "$GATE_KEEPER_DIR/dashboard"
38
- npm install --silent
39
- npm run build
66
+ if [[ $HAS_DASHBOARD == true ]]; then
67
+ echo "[gate-keeper] Building dashboard..."
68
+ cd "$GATE_KEEPER_DIR/dashboard"
69
+ npm install --silent
70
+ npm run build
71
+ cd "$GATE_KEEPER_DIR"
72
+ fi
40
73
 
41
- echo ""
42
- echo "[gate-keeper] Build complete!"
43
- echo ""
74
+ echo ""
75
+ echo "[gate-keeper] Build complete!"
76
+ echo ""
77
+ else
78
+ echo "[gate-keeper] Pre-built package detected — skipping build steps"
79
+ fi
44
80
 
45
- # Start daemon in background (no auto-scan)
81
+ # ── Start daemon ──
46
82
  echo "[gate-keeper] Starting daemon..."
47
83
  cd "$GATE_KEEPER_DIR"
48
84
  nohup node dist/daemon.js --no-scan > /tmp/gk-daemon.log 2>&1 &
49
85
  NEW_PID=$!
50
86
  sleep 2
51
87
 
88
+ DAEMON_STARTED=false
52
89
  if kill -0 "$NEW_PID" 2>/dev/null; then
90
+ DAEMON_STARTED=true
53
91
  echo "[gate-keeper] Daemon started (PID: $NEW_PID)"
54
- echo "[gate-keeper] Dashboard: http://localhost:5378/viz"
55
92
  else
56
93
  echo "[gate-keeper] WARNING: Daemon failed to start. Check /tmp/gk-daemon.log"
57
94
  fi
58
95
 
59
- echo ""
60
- echo "[gate-keeper] Configuring Claude Code hooks..."
61
- CLAUDE_SETTINGS="$HOME/.claude/settings.json"
62
- if [[ ! -d "$HOME/.claude" ]]; then
63
- mkdir -p "$HOME/.claude"
64
- fi
96
+ # ── Write Claude Code hooks (only for claude or both) ──
97
+ if [[ "$MODE" == "claude" || "$MODE" == "both" ]]; then
98
+ echo ""
99
+ echo "[gate-keeper] Configuring Claude Code hooks..."
100
+ CLAUDE_SETTINGS="$HOME/.claude/settings.json"
101
+ if [[ ! -d "$HOME/.claude" ]]; then
102
+ mkdir -p "$HOME/.claude"
103
+ fi
65
104
 
66
- if [[ ! -f "$CLAUDE_SETTINGS" ]]; then
67
- cat > "$CLAUDE_SETTINGS" << EOF
105
+ if [[ ! -f "$CLAUDE_SETTINGS" ]]; then
106
+ cat > "$CLAUDE_SETTINGS" << SETUP_EOF
68
107
  {
69
108
  "hooks": {
109
+ "SessionStart": [
110
+ {
111
+ "hooks": [
112
+ {
113
+ "type": "command",
114
+ "command": "gate-keeper guide session-start"
115
+ }
116
+ ]
117
+ }
118
+ ],
70
119
  "PreToolUse": [
71
120
  {
72
121
  "matcher": "Write|Edit|MultiEdit",
73
122
  "hooks": [
74
123
  {
75
124
  "type": "command",
76
- "command": "node ${GATE_KEEPER_DIR}/dist/hook-pre-tool-use.js"
125
+ "command": "gate-keeper guide pre-edit"
77
126
  }
78
127
  ]
79
128
  }
@@ -84,30 +133,59 @@ if [[ ! -f "$CLAUDE_SETTINGS" ]]; then
84
133
  "hooks": [
85
134
  {
86
135
  "type": "command",
87
- "command": "node ${GATE_KEEPER_DIR}/dist/hook-receiver.js"
136
+ "command": "gate-keeper guide post-edit"
88
137
  }
89
138
  ]
90
139
  }
91
140
  ]
92
141
  }
93
142
  }
94
- EOF
95
- echo "[gate-keeper] ✓ Created ~/.claude/settings.json with Pre/PostToolUse hooks"
96
- else
97
- if ! grep -q "gate-keeper" "$CLAUDE_SETTINGS"; then
143
+ SETUP_EOF
144
+ echo "[gate-keeper] ✓ Created ~/.claude/settings.json with SessionStart/PreToolUse/PostToolUse hooks"
145
+ elif ! grep -q "gate-keeper" "$CLAUDE_SETTINGS"; then
98
146
  echo "[gate-keeper] ⚠ ~/.claude/settings.json exists but does not reference gate-keeper."
99
- echo "[gate-keeper] See README.md for the hook snippet to add manually."
147
+ echo "[gate-keeper] Manually add these hooks to enable guidance:"
148
+ echo "[gate-keeper] SessionStart: gate-keeper guide session-start"
149
+ echo "[gate-keeper] PreToolUse: gate-keeper guide pre-edit"
100
150
  else
101
151
  echo "[gate-keeper] ✓ Hooks already configured in ~/.claude/settings.json"
102
152
  fi
103
153
  fi
104
154
 
155
+ # ── Print Copilot / VS Code instructions (only for copilot or both) ──
156
+ if [[ "$MODE" == "copilot" || "$MODE" == "both" ]]; then
157
+ echo ""
158
+ echo "[gate-keeper] Copilot / VS Code setup:"
159
+ echo " Add these files to your repo:"
160
+ echo ""
161
+ echo " .vscode/tasks.json — auto-registers repo on folder open:"
162
+ echo ' { "version": "2.0.0", "tasks": [{ "label": "gate-keeper: register repo",'
163
+ echo ' "type": "shell", "command": "gate-keeper", "args": ["register"],'
164
+ echo ' "runOptions": { "runOn": "folderOpen" },'
165
+ echo ' "presentation": { "reveal": "never", "echo": false, "close": true },'
166
+ echo ' "problemMatcher": [] }] }'
167
+ echo ""
168
+ echo " .vscode/mcp.json — exposes 5 MCP tools to Copilot:"
169
+ echo ' { "servers": { "gate-keeper": { "command": "gate-keeper", "args": ["mcp"] } } }'
170
+ echo ""
171
+ echo " See README.md for the full instructions."
172
+ fi
173
+
174
+ # ── Summary ──
105
175
  echo ""
106
176
  echo "[gate-keeper] Setup Summary:"
107
177
  echo ""
108
- echo " ✓ Dependencies installed and built"
109
- echo " ✓ Daemon running on ports 5378 (WebSocket) and 5379 (IPC)"
110
- echo " ✓ Dashboard available at http://localhost:5378/viz"
178
+ if [[ $DAEMON_STARTED == true ]]; then
179
+ echo " ✓ Daemon running on ports 5378 (WebSocket) and 5379 (IPC)"
180
+ echo " ✓ Dashboard available at http://localhost:5378/viz"
181
+ else
182
+ echo " ✗ Daemon failed to start — check /tmp/gk-daemon.log"
183
+ fi
184
+ if [[ "$MODE" == "claude" || "$MODE" == "both" ]]; then
185
+ echo " ✓ Claude Code hooks configured in ~/.claude/settings.json"
186
+ fi
187
+ if [[ "$MODE" == "copilot" || "$MODE" == "both" ]]; then
188
+ echo " ✓ Copilot / VS Code: add .vscode/tasks.json and .vscode/mcp.json to your repo"
189
+ fi
111
190
  echo ""
112
- echo " Copilot / VS Code: instructions auto-load from .github/instructions/"
113
- echo " MCP server entry : node dist/mcp/server.js (or: npm run mcp)"
191
+ echo " MCP server : gate-keeper mcp"