@voidh4x0r/slopgate 0.1.13 → 0.1.14
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 +12 -0
- package/README.md +5 -5
- package/dist/cli.js +1 -51
- package/dist/config.d.ts +8 -0
- package/dist/config.js +48 -1
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +33 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,18 @@ 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.14] - 2026-11-22
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- 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.
|
|
16
|
+
- MCP findings are reported relative to the MCP server root (`packages/app/app.py`), not relative to the scan target (`app.py`).
|
|
17
|
+
- MCP uses the target config’s `confidence` as the default when a call omits `confidence`.
|
|
18
|
+
- `findGitRoot` / `hasConfig` / `findConfigRoot` moved from `cli.ts` to `config.ts`, shared by CLI and MCP.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- 266 tests, including MCP package-vs-root config parity, root-relative paths, and target-confidence behavior.
|
|
22
|
+
- 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: []`.
|
|
23
|
+
|
|
12
24
|
## [0.1.13] - 2026-11-22
|
|
13
25
|
|
|
14
26
|
### 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.
|
|
17
|
+
slopgate 0.1.14 · 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. 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.
|
|
213
|
+
- run: npx --yes @voidh4x0r/slopgate@0.1.14 . --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.
|
|
221
|
+
- run: npx --yes @voidh4x0r/slopgate@0.1.14 . --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 #
|
|
306
|
+
npm test # 266 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 {
|
|
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,15 +126,25 @@ 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);
|
|
126
134
|
}
|
|
127
135
|
const visible = result.findings.filter((finding) => meetsConfidence(finding.confidence, confidence));
|
|
128
|
-
|
|
136
|
+
const targetInfo = await stat(target).catch(() => undefined);
|
|
137
|
+
const base = targetInfo?.isFile() ? path.dirname(target) : target;
|
|
138
|
+
const prefix = prefixForRoot(deps.root, base);
|
|
139
|
+
const output = prefix
|
|
140
|
+
? visible.map((finding) => ({ ...finding, file: `${prefix}/${finding.file}` }))
|
|
141
|
+
: visible;
|
|
142
|
+
return textResult(formatFindings(output, result, deps.version, max));
|
|
129
143
|
}
|
|
130
144
|
if (name === 'scan_diff') {
|
|
131
145
|
const base = typeof params.base === 'string' && params.base.length > 0 ? params.base : 'HEAD';
|
|
146
|
+
const rootConfig = await configFor(deps.root);
|
|
147
|
+
const confidence = coerceConfidence(params.confidence, rootConfig.confidence);
|
|
132
148
|
const result = await deps.scan(deps.root);
|
|
133
149
|
if (result.stats.files === 0) {
|
|
134
150
|
return textResult('No files matched in the repository (check include/exclude patterns)', true);
|
|
@@ -195,16 +211,24 @@ export function createMcpServer(deps) {
|
|
|
195
211
|
};
|
|
196
212
|
}
|
|
197
213
|
export function defaultMcpDeps(root, version) {
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
214
|
+
const configCache = new Map();
|
|
215
|
+
const configFor = async (start) => {
|
|
216
|
+
const target = path.resolve(start);
|
|
217
|
+
const repoRoot = (await findGitRoot(target)) ?? root;
|
|
218
|
+
const configRoot = await findConfigRoot(target, repoRoot);
|
|
219
|
+
let pending = configCache.get(configRoot);
|
|
220
|
+
if (!pending) {
|
|
221
|
+
pending = loadConfig(configRoot).then((loaded) => loaded.config);
|
|
222
|
+
configCache.set(configRoot, pending);
|
|
223
|
+
}
|
|
224
|
+
return pending;
|
|
202
225
|
};
|
|
203
226
|
return {
|
|
204
227
|
root,
|
|
205
228
|
version,
|
|
229
|
+
configFor,
|
|
206
230
|
async scan(scanRoot) {
|
|
207
|
-
const config = await
|
|
231
|
+
const config = await configFor(scanRoot);
|
|
208
232
|
const result = await scanProject({ root: scanRoot, config });
|
|
209
233
|
// Respect a baseline if one exists, so agents do not re-report known debt.
|
|
210
234
|
const baseline = await loadBaseline(path.join(root, '.slopgate-baseline.json'));
|