@voidh4x0r/slopgate 0.1.10 → 0.1.13
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 +37 -0
- package/README.md +9 -7
- package/dist/cli.js +82 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,43 @@ 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.13] - 2026-11-22
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Per-package config discovery: `.slopgate.json` / `slopgate.config.json` is searched from the scan target upward to the git repository root, and the nearest config wins. `packages/app` uses its own package config; `src` without one falls back to the root config. Baselines remain shared at the repository root.
|
|
16
|
+
- `slopgate init <dir>` writes the config in `<dir>` and the workflow at the repository root, with the workflow command targeting `./<dir>`. Root `init` output is unchanged.
|
|
17
|
+
- `--verbose` shows the resolved config path, e.g. `packages/app/.slopgate.json`, not just the filename.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Git-root discovery runs once per scan and is reused for config search, baseline root and output prefix.
|
|
21
|
+
- **Behavior change:** `init <subdir>` now writes the config in that subdirectory (0.1.12 wrote it at the repo root); this makes generated package configs actually apply. The workflow still lives at the root.
|
|
22
|
+
- 263 tests, including a monorepo package-vs-root config test, package config `init`, and the updated subdirectory init expectations.
|
|
23
|
+
- 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: []`.
|
|
24
|
+
|
|
25
|
+
## [0.1.12] - 2026-11-22
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- Baseline fingerprints are normalized to repository-relative paths, so one baseline written with `slopgate .`, `slopgate src` or `slopgate src/a.py` suppresses the same findings from any target.
|
|
29
|
+
- `slopgate init <subdirectory>` writes `.slopgate.json` and `.github/workflows/slopgate.yml` at the repository root, matching scan/config semantics; non-git targets keep the requested directory.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- **Migration:** baselines written by 0.1.11 while scanning a subdirectory contain target-relative keys and are no longer matched; recreate them from the root or with the current version. Baselines written from the repository root remain compatible.
|
|
33
|
+
- 261 tests, including mixed root/directory/file baseline reads and subdirectory `init`.
|
|
34
|
+
- 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: []`.
|
|
35
|
+
|
|
36
|
+
## [0.1.11] - 2026-11-22
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
- `.slopgate.json` and `.slopgate-baseline.json` are now loaded from the nearest git repository root, not from the scan target. `slopgate src` and `slopgate src/a.py` see the same `rules` / `include` / `exclude` / `ignoreModules` / `confidence` / `failOn` settings as `slopgate .`, matching MCP.
|
|
40
|
+
- Default and explicit baseline paths resolve from the repository root. `--write-baseline` started from `src` now writes `<repo>/.slopgate-baseline.json`, and later scans from any subdirectory read it.
|
|
41
|
+
- Manifest and local-module resolution remains target-scoped, so monorepo packages still use their own `package.json` / `pyproject.toml`.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
- **Behavior change:** a baseline written by an older version inside a scanned subdirectory is no longer found automatically; move it to the repository root or pass `--baseline`.
|
|
45
|
+
- 259 tests, including repo-root config applying to directory/file scans and default-baseline read/write at the root.
|
|
46
|
+
- The performance guard now ignores corpora under 500 ms, so 5% comparisons target the CPython/ESLint-scale scans rather than startup noise.
|
|
47
|
+
- 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: []`.
|
|
48
|
+
|
|
12
49
|
## [0.1.10] - 2026-11-22
|
|
13
50
|
|
|
14
51
|
### Fixed
|
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.13 · 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
|
|
@@ -116,7 +116,7 @@ slopgate [path] [options]
|
|
|
116
116
|
--confidence high|medium|low minimum confidence to report (default: high)
|
|
117
117
|
--fail-on high|medium|low|none minimum confidence that fails CI (default: high)
|
|
118
118
|
(a lower value also lowers what is displayed)
|
|
119
|
-
--baseline [path] ignore findings recorded in a file (default: .slopgate-baseline.json)
|
|
119
|
+
--baseline [path] ignore findings recorded in a file (default: .slopgate-baseline.json at the repo root)
|
|
120
120
|
--write-baseline [path] record current findings, then exit 0
|
|
121
121
|
--diff [ref] only report findings on changed lines (default: HEAD)
|
|
122
122
|
--include/--exclude <glob> adjust the file set
|
|
@@ -128,7 +128,7 @@ slopgate [path] [options]
|
|
|
128
128
|
|
|
129
129
|
### Configuration
|
|
130
130
|
|
|
131
|
-
`slopgate` reads `.slopgate.json` (or `slopgate.config.json`) from the
|
|
131
|
+
`slopgate` reads `.slopgate.json` (or `slopgate.config.json`) by walking up from the scan target to the git repository root and using the **nearest** config. A package config such as `packages/app/.slopgate.json` overrides the root config; `src` with no config falls back to the root. Every key is optional:
|
|
132
132
|
|
|
133
133
|
```json
|
|
134
134
|
{
|
|
@@ -151,9 +151,11 @@ slopgate [path] [options]
|
|
|
151
151
|
|
|
152
152
|
For example, `{"include": ["src/**"]}` scans only files under `src/`; it does **not** keep the default Python/TS/JS coverage. Add the patterns you need, or use the CLI flag to append one pattern to the defaults.
|
|
153
153
|
|
|
154
|
+
The default `.slopgate-baseline.json` also lives at the repository root. `--baseline` and `--write-baseline` paths resolve there, so scanning `src` and then the repository root share one baseline. Baseline fingerprints use the same repository-relative paths as reports, so one root baseline works for `slopgate .`, `slopgate src`, and `slopgate path/to/file.py`.
|
|
155
|
+
|
|
154
156
|
Reported paths (including SARIF and GitHub annotations) are relative to the nearest git repository root. If the target is outside a git repository, paths stay relative to the scan target.
|
|
155
157
|
|
|
156
|
-
`slopgate init` writes a minimal config
|
|
158
|
+
`slopgate init` writes a minimal config at the requested directory and a GitHub Actions workflow at the repository root; the workflow targets that directory. Run it at the repository root for a repo-wide config.
|
|
157
159
|
|
|
158
160
|
### Adopting it on an existing repository
|
|
159
161
|
|
|
@@ -208,7 +210,7 @@ jobs:
|
|
|
208
210
|
- uses: actions/checkout@v4
|
|
209
211
|
- uses: actions/setup-node@v4
|
|
210
212
|
with: { node-version: 22 }
|
|
211
|
-
- run: npx --yes @voidh4x0r/slopgate@0.1.
|
|
213
|
+
- run: npx --yes @voidh4x0r/slopgate@0.1.13 . --fail-on high
|
|
212
214
|
```
|
|
213
215
|
|
|
214
216
|
For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
|
|
@@ -216,7 +218,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
|
|
|
216
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):
|
|
217
219
|
|
|
218
220
|
```yaml
|
|
219
|
-
- run: npx --yes @voidh4x0r/slopgate@0.1.
|
|
221
|
+
- run: npx --yes @voidh4x0r/slopgate@0.1.13 . --format github --fail-on high
|
|
220
222
|
```
|
|
221
223
|
|
|
222
224
|
Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
|
|
@@ -301,7 +303,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
|
|
|
301
303
|
git clone https://github.com/VoidH4x0r/slopgate
|
|
302
304
|
cd slopgate
|
|
303
305
|
npm install
|
|
304
|
-
npm test #
|
|
306
|
+
npm test # 263 tests; the tests themselves make no network or child-process calls
|
|
305
307
|
npm run typecheck
|
|
306
308
|
npm run verify # all release gates in one command
|
|
307
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 { confidenceRank, loadConfig, meetsConfidence } from "./config.js";
|
|
7
|
+
import { CONFIG_FILENAMES, confidenceRank, 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";
|
|
@@ -31,7 +31,7 @@ Options:
|
|
|
31
31
|
--format <pretty|json|sarif|github> output format (default: pretty)
|
|
32
32
|
--confidence <high|medium|low> minimum confidence to show (default: high)
|
|
33
33
|
--fail-on <high|medium|low|none> minimum confidence that fails the run (default: high)
|
|
34
|
-
--baseline [path] findings file to ignore (default: ${DEFAULT_BASELINE})
|
|
34
|
+
--baseline [path] findings file to ignore (default: ${DEFAULT_BASELINE} at the repo root)
|
|
35
35
|
--write-baseline [path] record current findings as the baseline, then exit 0
|
|
36
36
|
--diff [ref] only report findings on lines changed since ref (default: HEAD)
|
|
37
37
|
--include <glob> extra include pattern (repeatable)
|
|
@@ -236,6 +236,36 @@ async function findGitRoot(start) {
|
|
|
236
236
|
dir = parent;
|
|
237
237
|
}
|
|
238
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
|
+
}
|
|
239
269
|
async function runRules(options, io) {
|
|
240
270
|
const rows = ALL_RULES.map((rule) => ({
|
|
241
271
|
id: rule.meta.id,
|
|
@@ -285,7 +315,7 @@ const INIT_CONFIG = {
|
|
|
285
315
|
confidence: 'high',
|
|
286
316
|
failOn: 'high',
|
|
287
317
|
};
|
|
288
|
-
const INIT_WORKFLOW = (version) => `name: slopgate
|
|
318
|
+
const INIT_WORKFLOW = (version, target) => `name: slopgate
|
|
289
319
|
|
|
290
320
|
on:
|
|
291
321
|
push:
|
|
@@ -305,13 +335,20 @@ jobs:
|
|
|
305
335
|
with:
|
|
306
336
|
node-version: 22
|
|
307
337
|
- name: Scan for AI slop
|
|
308
|
-
run: npx --yes @voidh4x0r/slopgate@${version}
|
|
338
|
+
run: npx --yes @voidh4x0r/slopgate@${version} ${target} --fail-on high --format pretty
|
|
309
339
|
`;
|
|
310
340
|
async function runInit(options, io, version) {
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const
|
|
341
|
+
const requested = path.resolve(options.paths[0] ?? '.');
|
|
342
|
+
// Find the repo root before creating a directory, so `init newdir` does not
|
|
343
|
+
// leave an empty directory when the config belongs at the root.
|
|
344
|
+
const repoRoot = await findGitRoot(requested);
|
|
345
|
+
await mkdir(requested, { recursive: true });
|
|
346
|
+
const workflowRoot = repoRoot ?? requested;
|
|
347
|
+
const relativeTarget = path.relative(workflowRoot, requested).replace(/\\/g, '/');
|
|
348
|
+
const rawTarget = relativeTarget.length > 0 ? `./${relativeTarget}` : '.';
|
|
349
|
+
const workflowTarget = /\s/.test(rawTarget) ? `"${rawTarget}"` : rawTarget;
|
|
350
|
+
const configPath = path.join(requested, '.slopgate.json');
|
|
351
|
+
const workflowPath = path.join(workflowRoot, '.github', 'workflows', 'slopgate.yml');
|
|
315
352
|
if (!options.force && (await exists(configPath))) {
|
|
316
353
|
warn(io, options, `${path.relative(process.cwd(), configPath)} already exists (use --force to overwrite)`);
|
|
317
354
|
}
|
|
@@ -324,10 +361,10 @@ async function runInit(options, io, version) {
|
|
|
324
361
|
}
|
|
325
362
|
else {
|
|
326
363
|
await mkdir(path.dirname(workflowPath), { recursive: true });
|
|
327
|
-
await writeFile(workflowPath, INIT_WORKFLOW(version), 'utf8');
|
|
364
|
+
await writeFile(workflowPath, INIT_WORKFLOW(version, workflowTarget), 'utf8');
|
|
328
365
|
writeOut(io, `created ${path.relative(process.cwd(), workflowPath)}`);
|
|
329
366
|
}
|
|
330
|
-
writeOut(io,
|
|
367
|
+
writeOut(io, `next: npx @voidh4x0r/slopgate ${workflowTarget} --write-baseline, then commit the baseline`);
|
|
331
368
|
return 0;
|
|
332
369
|
}
|
|
333
370
|
async function runMcp(options) {
|
|
@@ -349,7 +386,9 @@ async function runScan(options, io) {
|
|
|
349
386
|
throw new Error(`path not found: ${target}`);
|
|
350
387
|
}
|
|
351
388
|
const projectRoot = targetInfo.isFile() ? path.dirname(target) : target;
|
|
352
|
-
const
|
|
389
|
+
const repoRoot = await findGitRoot(projectRoot);
|
|
390
|
+
const configRoot = await findConfigRoot(projectRoot, repoRoot);
|
|
391
|
+
const { config, file: configFile } = await loadConfig(configRoot);
|
|
353
392
|
if (options.rules.length > 0) {
|
|
354
393
|
const unknown = options.rules.filter((id) => !RULE_BY_ID.has(id));
|
|
355
394
|
if (unknown.length > 0) {
|
|
@@ -379,13 +418,27 @@ async function runScan(options, io) {
|
|
|
379
418
|
if (result.stats.files === 0) {
|
|
380
419
|
throw new Error(`no files matched under ${path.relative(process.cwd(), target) || '.'} (check include/exclude patterns)`);
|
|
381
420
|
}
|
|
382
|
-
const
|
|
421
|
+
const scanBase = projectRoot;
|
|
422
|
+
let outputPrefix = '';
|
|
423
|
+
if (repoRoot) {
|
|
424
|
+
const relative = path.relative(repoRoot, scanBase);
|
|
425
|
+
if (relative && !relative.startsWith('..') && !path.isAbsolute(relative)) {
|
|
426
|
+
outputPrefix = relative.replace(/\\/g, '/');
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const toRepoRelative = (items) => outputPrefix
|
|
430
|
+
? items.map((finding) => ({ ...finding, file: `${outputPrefix}/${finding.file}` }))
|
|
431
|
+
: [...items];
|
|
432
|
+
const baselineRoot = repoRoot ?? projectRoot;
|
|
433
|
+
const baselinePath = path.resolve(baselineRoot, options.baseline ?? DEFAULT_BASELINE);
|
|
383
434
|
const explicitWrite = options.writeBaseline;
|
|
384
435
|
if (explicitWrite) {
|
|
385
|
-
const writeTarget = path.resolve(
|
|
386
|
-
// Record the current findings, not the diff-filtered subset
|
|
387
|
-
|
|
388
|
-
|
|
436
|
+
const writeTarget = path.resolve(baselineRoot, explicitWrite);
|
|
437
|
+
// Record the current findings, not the diff-filtered subset, with the same
|
|
438
|
+
// repo-relative keys used when reading the baseline.
|
|
439
|
+
const toRecord = toRepoRelative(result.findings);
|
|
440
|
+
await writeBaseline(writeTarget, toRecord);
|
|
441
|
+
writeOut(io, `wrote ${toRecord.length} findings to ${path.relative(process.cwd(), writeTarget)}`);
|
|
389
442
|
return 0;
|
|
390
443
|
}
|
|
391
444
|
let findings = result.findings;
|
|
@@ -403,7 +456,10 @@ async function runScan(options, io) {
|
|
|
403
456
|
if (baseline === undefined && options.baseline !== undefined) {
|
|
404
457
|
throw new Error(`baseline file not found: ${baselinePath}`);
|
|
405
458
|
}
|
|
406
|
-
|
|
459
|
+
// Baseline fingerprints and report paths both use repo-relative paths, so
|
|
460
|
+
// one root baseline works for every scan target.
|
|
461
|
+
const normalizedFindings = toRepoRelative(findings);
|
|
462
|
+
const { fresh, known } = partitionByBaseline(normalizedFindings, baseline);
|
|
407
463
|
// `--fail-on` below `--confidence` must lower the display threshold too,
|
|
408
464
|
// otherwise the setting can never fail CI (the findings are filtered out).
|
|
409
465
|
const displayConfidence = merged.failOn === 'none' || confidenceRank(merged.confidence) <= confidenceRank(merged.failOn)
|
|
@@ -411,23 +467,8 @@ async function runScan(options, io) {
|
|
|
411
467
|
: merged.failOn;
|
|
412
468
|
const visible = fresh.filter((finding) => meetsConfidence(finding.confidence, displayConfidence));
|
|
413
469
|
const hidden = fresh.length - visible.length;
|
|
414
|
-
// Reporters (SARIF, GitHub workflow commands) resolve paths from the repo
|
|
415
|
-
// root, not from the scan target. Prefix output findings only: baseline
|
|
416
|
-
// fingerprints and diff filtering keep using the raw target-relative paths.
|
|
417
|
-
const scanBase = targetInfo.isFile() ? path.dirname(target) : target;
|
|
418
|
-
const outputRoot = await findGitRoot(scanBase);
|
|
419
|
-
let outputPrefix = '';
|
|
420
|
-
if (outputRoot) {
|
|
421
|
-
const relative = path.relative(outputRoot, scanBase);
|
|
422
|
-
if (relative && !relative.startsWith('..') && !path.isAbsolute(relative)) {
|
|
423
|
-
outputPrefix = relative.replace(/\\/g, '/');
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
const outputVisible = outputPrefix
|
|
427
|
-
? visible.map((finding) => ({ ...finding, file: `${outputPrefix}/${finding.file}` }))
|
|
428
|
-
: visible;
|
|
429
470
|
const run = {
|
|
430
|
-
visible
|
|
471
|
+
visible,
|
|
431
472
|
stats: result.stats,
|
|
432
473
|
suppressed: result.suppressedCount,
|
|
433
474
|
baselined: known.length,
|
|
@@ -437,7 +478,7 @@ async function runScan(options, io) {
|
|
|
437
478
|
const version = await readVersion();
|
|
438
479
|
if (options.format === 'json') {
|
|
439
480
|
writeOut(io, renderJson({
|
|
440
|
-
findings:
|
|
481
|
+
findings: visible,
|
|
441
482
|
stats: run.stats,
|
|
442
483
|
version,
|
|
443
484
|
suppressedByComment: run.suppressed,
|
|
@@ -446,14 +487,14 @@ async function runScan(options, io) {
|
|
|
446
487
|
}));
|
|
447
488
|
}
|
|
448
489
|
else if (options.format === 'sarif') {
|
|
449
|
-
writeOut(io, renderSarif(
|
|
490
|
+
writeOut(io, renderSarif(visible, version));
|
|
450
491
|
}
|
|
451
492
|
else if (options.format === 'github') {
|
|
452
|
-
writeOut(io, renderGithub(
|
|
493
|
+
writeOut(io, renderGithub(visible, run.stats));
|
|
453
494
|
}
|
|
454
495
|
else {
|
|
455
496
|
writeOut(io, renderPretty({
|
|
456
|
-
findings:
|
|
497
|
+
findings: visible,
|
|
457
498
|
stats: run.stats,
|
|
458
499
|
suppressedByComment: run.suppressed,
|
|
459
500
|
baselined: run.baselined,
|
|
@@ -463,7 +504,10 @@ async function runScan(options, io) {
|
|
|
463
504
|
quiet: options.quiet,
|
|
464
505
|
}));
|
|
465
506
|
if (options.verbose) {
|
|
466
|
-
|
|
507
|
+
const configLabel = configFile
|
|
508
|
+
? path.relative(process.cwd(), path.join(configRoot, configFile))
|
|
509
|
+
: '(none)';
|
|
510
|
+
writeOut(io, ` config: ${configLabel} include: ${merged.include.length} pattern(s) baseline: ${baseline ? path.relative(process.cwd(), baselinePath) : '(none)'}` +
|
|
467
511
|
(onlyDiff > 0 ? ` diff-only: ${onlyDiff} finding(s) outside the diff were ignored` : '') +
|
|
468
512
|
'\n');
|
|
469
513
|
}
|