@voidh4x0r/slopgate 0.1.8 → 0.1.10

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,28 @@ 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.10] - 2026-11-22
13
+
14
+ ### Fixed
15
+ - Reporter output paths are repository-relative when the scan target is inside a git repository. `slopgate src`, `slopgate src/a.py` and absolute targets now emit `src/a.py` in JSON, pretty, SARIF and GitHub annotations instead of `a.py`. The prefix comes from the nearest `.git` marker (filesystem walk, no subprocess); non-git targets keep target-relative paths. Baseline fingerprints and diff filtering continue to use the raw target-relative paths.
16
+ - Documented and tested that a rule set to `severity: "info"` stays visible but still fails CI; `off` or a baseline is the exemption mechanism.
17
+
18
+ ### Changed
19
+ - 257 tests, including single-file/subdirectory reporter paths, SARIF/GitHub annotations, and the `severity-override` fixture.
20
+ - Benchmark findings 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: []`.
21
+
22
+ ## [0.1.9] - 2026-11-22
23
+
24
+ ### Changed
25
+ - Documented that a config `include` replaces the default Python/TS/JS pattern set, while CLI `--include` appends to it. `--verbose` now prints the effective include count so a reduced file set is visible.
26
+ - `py/noop-test` reuses the `function_definition` list already collected by the rule instead of walking the tree a second time for the helper index.
27
+ - Added `include-semantics` coverage: default 3 files, config `src/**` 2 files, CLI `--include src/**` 3 files, and verbose shows 11 patterns.
28
+
29
+ ### Unchanged
30
+ - No runtime behavior change to include handling; this is documentation and visibility only.
31
+ - Benchmark remains **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: []`.
32
+ - 255 tests.
33
+
12
34
  ## [0.1.8] - 2026-11-22
13
35
 
14
36
  ### 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.8 · 4 files · 39ms
17
+ slopgate 0.1.10 · 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
@@ -144,11 +144,15 @@ slopgate [path] [options]
144
144
  }
145
145
  ```
146
146
 
147
- - `include` / `exclude` — globs relative to the project root; the defaults cover Python and TS/JS sources.
147
+ - `include` / `exclude` — globs relative to the project root. **A config `include` replaces the default pattern set** (the ten Python/TS/JS globs); list every extension you still want. The CLI `--include` **appends** to the effective set, so `--include "src/**"` keeps the defaults.
148
148
  - `ignoreModules` — top-level modules to always treat as declared (dynamic imports, private packages).
149
- - `rules` — `"off"` or an explicit severity (`"error"`, `"warning"`, `"info"`).
149
+ - `rules` — `"off"` or an explicit severity (`"error"`, `"warning"`, `"info"`). Severity changes display and annotation level only; **CI failure is controlled by confidence and `--fail-on`**. A rule set to `"info"` stays visible and still fails when its confidence meets `--fail-on`; use `"off"` or a baseline to exempt it.
150
150
  - `confidence` / `failOn` — same meaning as the CLI flags; CLI flags win.
151
151
 
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
+
154
+ 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
+
152
156
  `slopgate init` writes a minimal config plus a GitHub Actions workflow.
153
157
 
154
158
  ### Adopting it on an existing repository
@@ -204,7 +208,7 @@ jobs:
204
208
  - uses: actions/checkout@v4
205
209
  - uses: actions/setup-node@v4
206
210
  with: { node-version: 22 }
207
- - run: npx --yes @voidh4x0r/slopgate@0.1.8 . --fail-on high
211
+ - run: npx --yes @voidh4x0r/slopgate@0.1.10 . --fail-on high
208
212
  ```
209
213
 
210
214
  For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
@@ -212,7 +216,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
212
216
  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):
213
217
 
214
218
  ```yaml
215
- - run: npx --yes @voidh4x0r/slopgate@0.1.8 . --format github --fail-on high
219
+ - run: npx --yes @voidh4x0r/slopgate@0.1.10 . --format github --fail-on high
216
220
  ```
217
221
 
218
222
  Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
@@ -297,7 +301,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
297
301
  git clone https://github.com/VoidH4x0r/slopgate
298
302
  cd slopgate
299
303
  npm install
300
- npm test # 252 tests; the tests themselves make no network or child-process calls
304
+ npm test # 257 tests; the tests themselves make no network or child-process calls
301
305
  npm run typecheck
302
306
  npm run verify # all release gates in one command
303
307
  ```
package/dist/cli.js CHANGED
@@ -216,6 +216,26 @@ 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
+ }
219
239
  async function runRules(options, io) {
220
240
  const rows = ALL_RULES.map((rule) => ({
221
241
  id: rule.meta.id,
@@ -391,8 +411,23 @@ async function runScan(options, io) {
391
411
  : merged.failOn;
392
412
  const visible = fresh.filter((finding) => meetsConfidence(finding.confidence, displayConfidence));
393
413
  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;
394
429
  const run = {
395
- visible,
430
+ visible: outputVisible,
396
431
  stats: result.stats,
397
432
  suppressed: result.suppressedCount,
398
433
  baselined: known.length,
@@ -402,7 +437,7 @@ async function runScan(options, io) {
402
437
  const version = await readVersion();
403
438
  if (options.format === 'json') {
404
439
  writeOut(io, renderJson({
405
- findings: visible,
440
+ findings: outputVisible,
406
441
  stats: run.stats,
407
442
  version,
408
443
  suppressedByComment: run.suppressed,
@@ -411,14 +446,14 @@ async function runScan(options, io) {
411
446
  }));
412
447
  }
413
448
  else if (options.format === 'sarif') {
414
- writeOut(io, renderSarif(visible, version));
449
+ writeOut(io, renderSarif(outputVisible, version));
415
450
  }
416
451
  else if (options.format === 'github') {
417
- writeOut(io, renderGithub(visible, run.stats));
452
+ writeOut(io, renderGithub(outputVisible, run.stats));
418
453
  }
419
454
  else {
420
455
  writeOut(io, renderPretty({
421
- findings: visible,
456
+ findings: outputVisible,
422
457
  stats: run.stats,
423
458
  suppressedByComment: run.suppressed,
424
459
  baselined: run.baselined,
@@ -428,7 +463,7 @@ async function runScan(options, io) {
428
463
  quiet: options.quiet,
429
464
  }));
430
465
  if (options.verbose) {
431
- writeOut(io, ` config: ${configFile ?? '(none)'} baseline: ${baseline ? path.relative(process.cwd(), baselinePath) : '(none)'}` +
466
+ writeOut(io, ` config: ${configFile ?? '(none)'} include: ${merged.include.length} pattern(s) baseline: ${baseline ? path.relative(process.cwd(), baselinePath) : '(none)'}` +
432
467
  (onlyDiff > 0 ? ` diff-only: ${onlyDiff} finding(s) outside the diff were ignored` : '') +
433
468
  '\n');
434
469
  }
@@ -112,9 +112,9 @@ function bodyCallsSelf(body) {
112
112
  return found;
113
113
  }
114
114
  /** Lightweight name → node index; assertion checks happen on demand. */
115
- function localFunctionDefinitions(root) {
115
+ function localFunctionDefinitions(functions) {
116
116
  const definitions = new Map();
117
- for (const fn of descendantsOfType(root, ['function_definition'])) {
117
+ for (const fn of functions) {
118
118
  if (fn.parent?.type === 'class_definition')
119
119
  continue;
120
120
  const name = fn.childForFieldName('name')?.text;
@@ -315,15 +315,17 @@ const noopTest = {
315
315
  if (isStubFile(ctx.file))
316
316
  return [];
317
317
  const drafts = [];
318
- // A test-dense file may have thousands of assertion-free tests. Build the
319
- // name index once, and only assert-check the helper actually called.
318
+ // A test-dense file may have thousands of assertion-free tests. Reuse the
319
+ // function list the rule already collected; build the name index once, and
320
+ // only assert-check the helper actually called.
321
+ const functions = descendantsOfType(ctx.root, ['function_definition']);
320
322
  let definitionIndex;
321
323
  const definitions = () => {
322
- definitionIndex ??= localFunctionDefinitions(ctx.root);
324
+ definitionIndex ??= localFunctionDefinitions(functions);
323
325
  return definitionIndex;
324
326
  };
325
327
  const helperAssertions = new Map();
326
- for (const fn of descendantsOfType(ctx.root, ['function_definition'])) {
328
+ for (const fn of functions) {
327
329
  const name = testFunctionName(fn);
328
330
  if (!name)
329
331
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidh4x0r/slopgate",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
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",