@voidh4x0r/slopgate 0.1.13 → 0.1.15

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/CHANGELOG.md CHANGED
@@ -9,6 +9,29 @@ All notable changes to this project are documented here. The format follows [Kee
9
9
  - Go and Rust grammars.
10
10
  - VS Code diagnostics.
11
11
 
12
+ ## [0.1.15] - 2026-11-22
13
+
14
+ ### Fixed
15
+ - MCP `scan_path` now normalizes findings to MCP-root-relative paths inside `defaultMcpDeps.scan` before applying the root baseline, so a baseline written by `slopgate . --write-baseline` suppresses findings for subdirectory and single-file scans too. `scan_diff` is unchanged because it scans the root (empty prefix).
16
+ - Removed the duplicate path prefixing from `scan_path`; normalization has one owner and cannot double-prefix.
17
+
18
+ ### Changed
19
+ - 267 tests, including root-baseline suppression for MCP directory/file/root scans and no-double-prefix coverage.
20
+ - Documented that the MCP server root must be the repository root; select subdirectories with `scan_path`.
21
+ - Benchmark unchanged at **29 high-confidence findings across 991,705 lines of CPython, 96.6% labeled precision (28/29), 14/14 seeded defects, 0 high findings on 601 JavaScript files**; `staleLabels: []`, `unlabeledHigh: []`.
22
+
23
+ ## [0.1.14] - 2026-11-22
24
+
25
+ ### Fixed
26
+ - MCP `scan_path` resolves config for the requested target with the same nearest-config search as the CLI (package config wins, root config falls back). Configs are cached per resolved config root.
27
+ - MCP findings are reported relative to the MCP server root (`packages/app/app.py`), not relative to the scan target (`app.py`).
28
+ - MCP uses the target config’s `confidence` as the default when a call omits `confidence`.
29
+ - `findGitRoot` / `hasConfig` / `findConfigRoot` moved from `cli.ts` to `config.ts`, shared by CLI and MCP.
30
+
31
+ ### Changed
32
+ - 266 tests, including MCP package-vs-root config parity, root-relative paths, and target-confidence behavior.
33
+ - Benchmark unchanged at **29 high-confidence findings across 991,705 lines of CPython, 96.6% labeled precision (28/29), 14/14 seeded defects, 0 high findings on 601 JavaScript files**; `staleLabels: []`, `unlabeledHigh: []`.
34
+
12
35
  ## [0.1.13] - 2026-11-22
13
36
 
14
37
  ### Added
package/README.md CHANGED
@@ -14,7 +14,7 @@ AI writes code that *looks* right. `slopgate` finds the parts that only look rig
14
14
  ```console
15
15
  $ npx @voidh4x0r/slopgate .
16
16
 
17
- slopgate 0.1.13 · 4 files · 39ms
17
+ slopgate 0.1.15 · 4 files · 39ms
18
18
 
19
19
  app.py
20
20
  4:1 error high py/phantom-import `helper` is imported but not declared in any manifest and not present in this repository
@@ -190,7 +190,7 @@ npx @voidh4x0r/slopgate . --diff origin/main --fail-on high
190
190
  | `scan_path` | findings in a file or directory |
191
191
  | `list_rules` | the rule table, so the agent knows what is checked |
192
192
 
193
- Reports are compact text: `file:line:col severity confidence rule-id message`, evidence included, capped at 50 findings per call. The server reads `.slopgate.json` and `.slopgate-baseline.json` like the CLI does, so an agent never re-reports debt you already accepted. It runs locally, makes no network calls, and writes nothing to disk.
193
+ Reports are compact text: `file:line:col severity confidence rule-id message`, evidence included, capped at 50 findings per call. Paths are relative to the MCP server root, and config is resolved per requested path with the same nearest-config rule as the CLI. Point the MCP server at the repository root; use `scan_path` to select subdirectories. The server reads `.slopgate.json` and `.slopgate-baseline.json` like the CLI does, so an agent never re-reports debt you already accepted. It runs locally, makes no network calls, and writes nothing to disk.
194
194
 
195
195
  Full details: [docs/mcp.md](https://github.com/VoidH4x0r/slopgate/blob/main/docs/mcp.md).
196
196
 
@@ -210,7 +210,7 @@ jobs:
210
210
  - uses: actions/checkout@v4
211
211
  - uses: actions/setup-node@v4
212
212
  with: { node-version: 22 }
213
- - run: npx --yes @voidh4x0r/slopgate@0.1.13 . --fail-on high
213
+ - run: npx --yes @voidh4x0r/slopgate@0.1.15 . --fail-on high
214
214
  ```
215
215
 
216
216
  For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
@@ -218,7 +218,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
218
218
  For inline pull-request annotations **without** code scanning, use `--format github`, which emits [workflow commands](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions):
219
219
 
220
220
  ```yaml
221
- - run: npx --yes @voidh4x0r/slopgate@0.1.13 . --format github --fail-on high
221
+ - run: npx --yes @voidh4x0r/slopgate@0.1.15 . --format github --fail-on high
222
222
  ```
223
223
 
224
224
  Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
@@ -303,7 +303,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
303
303
  git clone https://github.com/VoidH4x0r/slopgate
304
304
  cd slopgate
305
305
  npm install
306
- npm test # 263 tests; the tests themselves make no network or child-process calls
306
+ npm test # 267 tests; the tests themselves make no network or child-process calls
307
307
  npm run typecheck
308
308
  npm run verify # all release gates in one command
309
309
  ```
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import * as path from 'node:path';
4
4
  import process from 'node:process';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { loadBaseline, partitionByBaseline, writeBaseline } from "./baseline.js";
7
- import { CONFIG_FILENAMES, confidenceRank, loadConfig, meetsConfidence, } from "./config.js";
7
+ import { confidenceRank, findConfigRoot, findGitRoot, loadConfig, meetsConfidence, } from "./config.js";
8
8
  import { assertSafeRef, diffSince, findRepoRoot, isInDiffWithPrefix } from "./diff.js";
9
9
  import { scanProject } from "./engine.js";
10
10
  import { serveMcp } from "./mcp.js";
@@ -216,56 +216,6 @@ function warn(io, options, message) {
216
216
  if (!options.quiet)
217
217
  io.err(`slopgate: ${message}\n`);
218
218
  }
219
- /**
220
- * Nearest ancestor containing `.git`, without spawning git. A `.git` file
221
- * (worktree/submodule) counts as a repository marker too.
222
- */
223
- async function findGitRoot(start) {
224
- let dir = path.resolve(start);
225
- for (;;) {
226
- try {
227
- await stat(path.join(dir, '.git'));
228
- return dir;
229
- }
230
- catch {
231
- // keep walking towards the filesystem root
232
- }
233
- const parent = path.dirname(dir);
234
- if (parent === dir)
235
- return undefined;
236
- dir = parent;
237
- }
238
- }
239
- async function hasConfig(dir) {
240
- for (const name of CONFIG_FILENAMES) {
241
- try {
242
- await stat(path.join(dir, name));
243
- return true;
244
- }
245
- catch {
246
- // try the next config filename
247
- }
248
- }
249
- return false;
250
- }
251
- /**
252
- * Nearest config wins: target → ancestors → repository root. Outside git,
253
- * only the target directory is considered.
254
- */
255
- async function findConfigRoot(start, repoRoot) {
256
- const target = path.resolve(start);
257
- let dir = target;
258
- for (;;) {
259
- if (await hasConfig(dir))
260
- return dir;
261
- if (repoRoot === undefined || dir === repoRoot)
262
- return repoRoot ?? target;
263
- const parent = path.dirname(dir);
264
- if (parent === dir)
265
- return repoRoot;
266
- dir = parent;
267
- }
268
- }
269
219
  async function runRules(options, io) {
270
220
  const rows = ALL_RULES.map((rule) => ({
271
221
  id: rule.meta.id,
package/dist/config.d.ts CHANGED
@@ -17,6 +17,14 @@ export interface LoadedConfig {
17
17
  file: string | undefined;
18
18
  }
19
19
  export declare const CONFIG_FILENAMES: readonly [".slopgate.json", "slopgate.config.json"];
20
+ /** Nearest ancestor containing `.git`, without spawning git. */
21
+ export declare function findGitRoot(start: string): Promise<string | undefined>;
22
+ export declare function hasConfig(dir: string): Promise<boolean>;
23
+ /**
24
+ * Nearest config wins: target → ancestors → repository root. Outside git,
25
+ * only the target directory is considered.
26
+ */
27
+ export declare function findConfigRoot(start: string, repoRoot: string | undefined): Promise<string>;
20
28
  export declare const DEFAULT_CONFIG: Config;
21
29
  export declare function confidenceRank(c: Confidence): number;
22
30
  export declare function meetsConfidence(value: Confidence, minimum: Confidence): boolean;
package/dist/config.js CHANGED
@@ -1,7 +1,54 @@
1
- import { readFile } from 'node:fs/promises';
1
+ import { readFile, stat } from 'node:fs/promises';
2
2
  import * as path from 'node:path';
3
3
  import { DEFAULT_INCLUDE } from "./files.js";
4
4
  export const CONFIG_FILENAMES = ['.slopgate.json', 'slopgate.config.json'];
5
+ /** Nearest ancestor containing `.git`, without spawning git. */
6
+ export async function findGitRoot(start) {
7
+ let dir = path.resolve(start);
8
+ for (;;) {
9
+ try {
10
+ await stat(path.join(dir, '.git'));
11
+ return dir;
12
+ }
13
+ catch {
14
+ // keep walking towards the filesystem root
15
+ }
16
+ const parent = path.dirname(dir);
17
+ if (parent === dir)
18
+ return undefined;
19
+ dir = parent;
20
+ }
21
+ }
22
+ export async function hasConfig(dir) {
23
+ for (const name of CONFIG_FILENAMES) {
24
+ try {
25
+ await stat(path.join(dir, name));
26
+ return true;
27
+ }
28
+ catch {
29
+ // try the next config filename
30
+ }
31
+ }
32
+ return false;
33
+ }
34
+ /**
35
+ * Nearest config wins: target → ancestors → repository root. Outside git,
36
+ * only the target directory is considered.
37
+ */
38
+ export async function findConfigRoot(start, repoRoot) {
39
+ const target = path.resolve(start);
40
+ let dir = target;
41
+ for (;;) {
42
+ if (await hasConfig(dir))
43
+ return dir;
44
+ if (repoRoot === undefined || dir === repoRoot)
45
+ return repoRoot ?? target;
46
+ const parent = path.dirname(dir);
47
+ if (parent === dir)
48
+ return repoRoot;
49
+ dir = parent;
50
+ }
51
+ }
5
52
  export const DEFAULT_CONFIG = {
6
53
  include: [...DEFAULT_INCLUDE],
7
54
  exclude: [],
package/dist/mcp.d.ts CHANGED
@@ -28,6 +28,8 @@ export interface McpDeps {
28
28
  root: string;
29
29
  version: string;
30
30
  config: Config;
31
+ /** Resolve the nearest config for a scan target; falls back to `config`. */
32
+ configFor?: (root: string) => Promise<Config>;
31
33
  scan: (root: string) => Promise<ScanResult>;
32
34
  diff: (root: string, base: string) => Promise<DiffSet>;
33
35
  }
package/dist/mcp.js CHANGED
@@ -1,9 +1,9 @@
1
- import { realpath } from 'node:fs/promises';
1
+ import { realpath, stat } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import process from 'node:process';
4
4
  import { createInterface } from 'node:readline';
5
5
  import { loadBaseline, partitionByBaseline } from "./baseline.js";
6
- import { loadConfig, meetsConfidence } from "./config.js";
6
+ import { findConfigRoot, findGitRoot, loadConfig, meetsConfidence, } from "./config.js";
7
7
  import { diffSince, isInDiff } from "./diff.js";
8
8
  import { scanProject } from "./engine.js";
9
9
  import { ALL_RULES } from "./rules/index.js";
@@ -97,6 +97,12 @@ function formatFindings(findings, result, version, max, preamble) {
97
97
  }
98
98
  return lines.join('\n');
99
99
  }
100
+ function prefixForRoot(root, base) {
101
+ const relative = path.relative(root, base);
102
+ if (!relative || relative.startsWith('..') || path.isAbsolute(relative))
103
+ return '';
104
+ return relative.replace(/\\/g, '/');
105
+ }
100
106
  export function createMcpServer(deps) {
101
107
  async function callTool(name, params) {
102
108
  if (name === 'list_rules') {
@@ -106,8 +112,8 @@ export function createMcpServer(deps) {
106
112
  }
107
113
  return textResult(lines.join('\n'));
108
114
  }
109
- const confidence = coerceConfidence(params.confidence, deps.config.confidence);
110
115
  const max = coerceNumber(params.maxFindings, MAX_FINDINGS);
116
+ const configFor = deps.configFor ?? (async () => deps.config);
111
117
  if (name === 'scan_path') {
112
118
  const target = path.resolve(deps.root, typeof params.path === 'string' ? params.path : '.');
113
119
  if (!isInsideRoot(deps.root, target)) {
@@ -120,6 +126,8 @@ export function createMcpServer(deps) {
120
126
  if (!isInsideRoot(realRoot, realTarget)) {
121
127
  return textResult(`Refusing to scan outside the repository root: ${target}`, true);
122
128
  }
129
+ const targetConfig = await configFor(target);
130
+ const confidence = coerceConfidence(params.confidence, targetConfig.confidence);
123
131
  const result = await deps.scan(target);
124
132
  if (result.stats.files === 0) {
125
133
  return textResult(`No files matched under ${target} (check include/exclude patterns)`, true);
@@ -129,6 +137,8 @@ export function createMcpServer(deps) {
129
137
  }
130
138
  if (name === 'scan_diff') {
131
139
  const base = typeof params.base === 'string' && params.base.length > 0 ? params.base : 'HEAD';
140
+ const rootConfig = await configFor(deps.root);
141
+ const confidence = coerceConfidence(params.confidence, rootConfig.confidence);
132
142
  const result = await deps.scan(deps.root);
133
143
  if (result.stats.files === 0) {
134
144
  return textResult('No files matched in the repository (check include/exclude patterns)', true);
@@ -195,22 +205,41 @@ export function createMcpServer(deps) {
195
205
  };
196
206
  }
197
207
  export function defaultMcpDeps(root, version) {
198
- let configPromise;
199
- const getConfig = async () => {
200
- configPromise ??= loadConfig(root).then((loaded) => loaded.config);
201
- return configPromise;
208
+ const configCache = new Map();
209
+ const configFor = async (start) => {
210
+ const target = path.resolve(start);
211
+ const repoRoot = (await findGitRoot(target)) ?? root;
212
+ const configRoot = await findConfigRoot(target, repoRoot);
213
+ let pending = configCache.get(configRoot);
214
+ if (!pending) {
215
+ pending = loadConfig(configRoot).then((loaded) => loaded.config);
216
+ configCache.set(configRoot, pending);
217
+ }
218
+ return pending;
202
219
  };
203
220
  return {
204
221
  root,
205
222
  version,
223
+ configFor,
206
224
  async scan(scanRoot) {
207
- const config = await getConfig();
225
+ const config = await configFor(scanRoot);
208
226
  const result = await scanProject({ root: scanRoot, config });
227
+ // Findings and baseline fingerprints are MCP-root-relative. Normalize
228
+ // here, before partitioning, so a root baseline matches subdirectory and
229
+ // single-file scans too.
230
+ const target = path.resolve(scanRoot);
231
+ const info = await stat(target).catch(() => undefined);
232
+ const base = info?.isFile() ? path.dirname(target) : target;
233
+ const prefix = prefixForRoot(root, base);
234
+ const normalized = prefix
235
+ ? result.findings.map((finding) => ({ ...finding, file: `${prefix}/${finding.file}` }))
236
+ : result.findings;
209
237
  // Respect a baseline if one exists, so agents do not re-report known debt.
210
238
  const baseline = await loadBaseline(path.join(root, '.slopgate-baseline.json'));
211
- if (baseline)
212
- return { ...result, findings: partitionByBaseline(result.findings, baseline).fresh };
213
- return result;
239
+ if (baseline) {
240
+ return { ...result, findings: partitionByBaseline(normalized, baseline).fresh };
241
+ }
242
+ return { ...result, findings: normalized };
214
243
  },
215
244
  diff: diffSince,
216
245
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidh4x0r/slopgate",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "The slop gate for AI-written code. Precision-first structural linting for Python and TypeScript.",
5
5
  "type": "module",
6
6
  "license": "MIT",