@voidh4x0r/slopgate 0.1.2 → 0.1.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/CHANGELOG.md CHANGED
@@ -9,6 +9,21 @@ 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.3] - 2026-11-22
13
+
14
+ ### Fixed
15
+ - MCP `scan_path` and `scan_diff` now return a tool error (`isError: true`) when zero files match, matching the CLI's exit 2 instead of reporting a clean run.
16
+ - `py/swallowed-exception` counts an explanatory comment immediately above `try` (keyword-filtered so a generic "parse the payload" comment does not hide a silent handler), and no longer includes a trailing comment on the last try-body line (off-by-one in the window start).
17
+ - `py/stub-body` skips `dummy_threading.py`-style modules again: exact no-op directories plus file stems starting `dummy_`/`noop_`/`_dummy_`; `dummy_data/` and `shims/` real stubs remain reported.
18
+ - `ts/noop-test` recognises renamed `node:assert` imports (namespace, default, named aliases and `require` bindings) as assertions.
19
+ - The extension language/dialect tables are merged into one map, so an extension cannot be present in one table and silently dropped from discovery.
20
+ - Added a docs test that fails when README or the demo artwork version disagrees with `package.json`; RELEASE now lists the docs update.
21
+
22
+ ### Changed
23
+ - 193 tests, including third-round regression fixtures for `window`, `renamed-assert` and `dummy-variants`.
24
+ - Benchmark re-run: **29 high-confidence findings across 991,705 lines of CPython, 96.6% labeled precision (28/29), 14/14 seeded defects detected, 0 high findings on 601 JavaScript files.** One 0.1.2 label became stale after the comment-window change and was pruned; the file now has 18 labels covering 29 occurrences, with `staleLabels: []` and `unlabeledHigh: []`.
25
+ - Docs: MCP zero-file behaviour, the four comment placements, dummy naming variants, and renamed assert imports are documented.
26
+
12
27
  ## [0.1.2] - 2026-11-22
13
28
 
14
29
  ### 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.2 · 4 files · 39ms
17
+ slopgate 0.1.3 · 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
@@ -204,7 +204,7 @@ jobs:
204
204
  - uses: actions/checkout@v4
205
205
  - uses: actions/setup-node@v4
206
206
  with: { node-version: 22 }
207
- - run: npx --yes @voidh4x0r/slopgate@0.1.2 . --fail-on high
207
+ - run: npx --yes @voidh4x0r/slopgate@0.1.3 . --fail-on high
208
208
  ```
209
209
 
210
210
  For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
@@ -212,7 +212,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
212
212
  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
213
 
214
214
  ```yaml
215
- - run: npx --yes @voidh4x0r/slopgate@0.1.2 . --format github --fail-on high
215
+ - run: npx --yes @voidh4x0r/slopgate@0.1.3 . --format github --fail-on high
216
216
  ```
217
217
 
218
218
  Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
@@ -296,7 +296,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
296
296
  git clone https://github.com/VoidH4x0r/slopgate
297
297
  cd slopgate
298
298
  npm install
299
- npm test # 179 tests; the tests themselves make no network or child-process calls
299
+ npm test # 193 tests; the tests themselves make no network or child-process calls
300
300
  npm run typecheck
301
301
  npm run verify # all release gates in one command
302
302
  ```
package/dist/files.js CHANGED
@@ -17,30 +17,18 @@ export const DEFAULT_INCLUDE = [
17
17
  '**/*.ts', '**/*.mts', '**/*.cts', '**/*.tsx',
18
18
  '**/*.js', '**/*.mjs', '**/*.cjs', '**/*.jsx',
19
19
  ];
20
- const EXTENSION_LANGUAGE = {
21
- '.py': 'python',
22
- '.pyi': 'python',
23
- '.ts': 'typescript',
24
- '.mts': 'typescript',
25
- '.cts': 'typescript',
26
- '.tsx': 'tsx',
27
- '.jsx': 'tsx',
20
+ const EXTENSIONS = {
21
+ '.py': { language: 'python', dialect: 'python' },
22
+ '.pyi': { language: 'python', dialect: 'python' },
23
+ '.ts': { language: 'typescript', dialect: 'typescript' },
24
+ '.mts': { language: 'typescript', dialect: 'typescript' },
25
+ '.cts': { language: 'typescript', dialect: 'typescript' },
26
+ '.tsx': { language: 'tsx', dialect: 'tsx' },
28
27
  // JSX is legal in .js, and the tsx grammar is a superset of plain JS.
29
- '.js': 'tsx',
30
- '.mjs': 'tsx',
31
- '.cjs': 'tsx',
32
- };
33
- const EXTENSION_DIALECT = {
34
- '.py': 'python',
35
- '.pyi': 'python',
36
- '.ts': 'typescript',
37
- '.mts': 'typescript',
38
- '.cts': 'typescript',
39
- '.tsx': 'tsx',
40
- '.js': 'javascript',
41
- '.jsx': 'javascript',
42
- '.mjs': 'javascript',
43
- '.cjs': 'javascript',
28
+ '.js': { language: 'tsx', dialect: 'javascript' },
29
+ '.jsx': { language: 'tsx', dialect: 'javascript' },
30
+ '.mjs': { language: 'tsx', dialect: 'javascript' },
31
+ '.cjs': { language: 'tsx', dialect: 'javascript' },
44
32
  };
45
33
  const MAX_FILE_BYTES = 1024 * 1024;
46
34
  export function toPosix(p) {
@@ -137,14 +125,13 @@ export function languageFor(fileName) {
137
125
  if (fileName.endsWith('.d.ts') || fileName.endsWith('.d.mts') || fileName.endsWith('.d.cts')) {
138
126
  return undefined;
139
127
  }
140
- const ext = path.extname(fileName).toLowerCase();
141
- return EXTENSION_LANGUAGE[ext];
128
+ return EXTENSIONS[path.extname(fileName).toLowerCase()]?.language;
142
129
  }
143
130
  export function dialectFor(fileName) {
144
131
  if (fileName.endsWith('.d.ts') || fileName.endsWith('.d.mts') || fileName.endsWith('.d.cts')) {
145
132
  return undefined;
146
133
  }
147
- return EXTENSION_DIALECT[path.extname(fileName).toLowerCase()];
134
+ return EXTENSIONS[path.extname(fileName).toLowerCase()]?.dialect;
148
135
  }
149
136
  export async function discoverFiles(options) {
150
137
  const root = path.resolve(options.root);
package/dist/mcp.js CHANGED
@@ -121,12 +121,18 @@ export function createMcpServer(deps) {
121
121
  return textResult(`Refusing to scan outside the repository root: ${target}`, true);
122
122
  }
123
123
  const result = await deps.scan(target);
124
+ if (result.stats.files === 0) {
125
+ return textResult(`No files matched under ${target} (check include/exclude patterns)`, true);
126
+ }
124
127
  const visible = result.findings.filter((finding) => meetsConfidence(finding.confidence, confidence));
125
128
  return textResult(formatFindings(visible, result, deps.version, max));
126
129
  }
127
130
  if (name === 'scan_diff') {
128
131
  const base = typeof params.base === 'string' && params.base.length > 0 ? params.base : 'HEAD';
129
132
  const result = await deps.scan(deps.root);
133
+ if (result.stats.files === 0) {
134
+ return textResult('No files matched in the repository (check include/exclude patterns)', true);
135
+ }
130
136
  const set = await deps.diff(deps.root, base);
131
137
  const inDiff = result.findings.filter((finding) => isInDiff(finding, set) && meetsConfidence(finding.confidence, confidence));
132
138
  const preamble = `Diff since ${base}: ${inDiff.length} finding(s) on changed lines.`;
@@ -111,15 +111,17 @@ export function isStubFile(file) {
111
111
  }
112
112
  /**
113
113
  * Modules whose whole purpose is to provide no-op stand-ins (CPython's
114
- * `multiprocessing/dummy`). Only exact path segments count: `dummy_data/` is a
115
- * normal package, and a `shims/` directory can contain unfinished code.
114
+ * `multiprocessing/dummy`, `dummy_threading.py`). Directory names must match
115
+ * exactly; file names may use the `dummy_`/`noop_` convention. `dummy_data/`
116
+ * is a normal package and `shims/` can contain unfinished code.
116
117
  */
117
- const NOOP_SEGMENTS = new Set(['dummy', '_dummy', 'noop', 'no_op', 'no-op']);
118
+ const NOOP_DIRS = new Set(['dummy', '_dummy', 'noop', 'no_op', 'no-op']);
118
119
  export function isNoopModulePath(file) {
119
- return file
120
- .toLowerCase()
121
- .split('/')
122
- .some((part) => NOOP_SEGMENTS.has(part));
120
+ const parts = file.toLowerCase().split('/');
121
+ if (parts.slice(0, -1).some((part) => NOOP_DIRS.has(part)))
122
+ return true;
123
+ const stem = (parts[parts.length - 1] ?? '').replace(/\.pyi?$/, '');
124
+ return /^_?(dummy|noop|no_op|no-op)(_|$)/.test(stem);
123
125
  }
124
126
  /** True when the file name follows a test-module convention. */
125
127
  export function looksLikeTestModule(file) {
@@ -452,6 +452,16 @@ const stubBody = {
452
452
  return drafts;
453
453
  },
454
454
  };
455
+ /** A comment that actually explains why an error is safe to ignore. */
456
+ const EXPLANATION_WORDS = /error|fail|ignore|abort|expected|safe|best effort|intentional|throw|except|swallow|\bok\b/i;
457
+ function explanatoryCommentBetween(ctx, fromLine, toLine) {
458
+ return ctx.comments.some((comment) => {
459
+ if (comment.startLine > toLine || comment.endLine < fromLine)
460
+ return false;
461
+ const text = ctx.lines.slice(comment.startLine - 1, comment.endLine).join(' ');
462
+ return EXPLANATION_WORDS.test(text);
463
+ });
464
+ }
455
465
  const swallowedException = {
456
466
  meta: {
457
467
  id: 'py/swallowed-exception',
@@ -473,6 +483,9 @@ const swallowedException = {
473
483
  if (tryNode.namedChildren.some((child) => child.type === 'else_clause'))
474
484
  continue;
475
485
  const tryBody = tryNode.namedChildren.find((child) => child.type === 'block');
486
+ // A comment immediately above `try` often explains the failure policy.
487
+ const aboveStart = Math.max(1, tryNode.startPosition.row);
488
+ const above = explanatoryCommentBetween(ctx, aboveStart, tryNode.startPosition.row + 1);
476
489
  /** 0-based end row of the previous region, or -1 when there is no try body. */
477
490
  let previousEndRow = tryBody ? tryBody.endPosition.row : -1;
478
491
  for (const clause of tryNode.namedChildren) {
@@ -485,7 +498,7 @@ const swallowedException = {
485
498
  // handler can explain this handler; comments inside the try body
486
499
  // cannot. Advance the cursor for every handler, silent or not.
487
500
  const handlerEndRow = body.endPosition.row;
488
- const windowStart = previousEndRow >= 0 ? previousEndRow + 1 : clause.startPosition.row + 1;
501
+ const betweenStart = previousEndRow >= 0 ? previousEndRow + 2 : clause.startPosition.row + 1;
489
502
  previousEndRow = handlerEndRow;
490
503
  const statements = statementsOf(body);
491
504
  const silent = statements.length === 0 ||
@@ -503,7 +516,7 @@ const swallowedException = {
503
516
  // Optional-dependency idiom: swallowing a missing import is the point.
504
517
  if (/ImportError|ModuleNotFoundError/.test(typeText))
505
518
  continue;
506
- const commented = hasCommentBetween(ctx, windowStart, handlerEndRow + 1);
519
+ const commented = above || hasCommentBetween(ctx, betweenStart, handlerEndRow + 1);
507
520
  const bare = typeText.length === 0;
508
521
  const broad = bare || /^(\(?\s*)?(Exception|BaseException)(\s*\))?$/.test(typeText);
509
522
  const cleanup = insideCleanupFunction(clause);
@@ -65,7 +65,57 @@ function matchesAlias(specifier, aliases) {
65
65
  return specifier === clean || specifier.startsWith(`${clean}/`);
66
66
  });
67
67
  }
68
- const ASSERTION_ROOTS = new Set(['assert', 'expect', 'expectTypeOf', 'should', 'chai']);
68
+ const NODE_ASSERT_SPECIFIERS = new Set(['node:assert', 'node:assert/strict']);
69
+ function addAssertBinding(aliases, part) {
70
+ const match = /^\s*(?:type\s+)?([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?\s*$/.exec(part);
71
+ if (match?.[1])
72
+ aliases.add(match[2] ?? match[1]);
73
+ }
74
+ /** Local names bound to `node:assert` / `node:assert/strict`. */
75
+ function assertAliases(root) {
76
+ const aliases = new Set();
77
+ for (const node of descendantsOfType(root, ['import_statement'])) {
78
+ const specifier = sourceString(node);
79
+ if (!specifier || !NODE_ASSERT_SPECIFIERS.has(specifier))
80
+ continue;
81
+ const text = node.text;
82
+ const namespace = /import\s+\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(text);
83
+ if (namespace?.[1])
84
+ aliases.add(namespace[1]);
85
+ const defaultImport = /import\s+([A-Za-z_$][\w$]*)\s*(?:,|from)/.exec(text);
86
+ if (defaultImport?.[1])
87
+ aliases.add(defaultImport[1]);
88
+ const named = /\{([^}]*)\}/.exec(text);
89
+ if (named?.[1]) {
90
+ for (const part of named[1].split(','))
91
+ addAssertBinding(aliases, part);
92
+ }
93
+ }
94
+ for (const call of descendantsOfType(root, ['call_expression'])) {
95
+ const fn = call.childForFieldName('function');
96
+ if (!fn || collapseWhitespace(fn.text) !== 'require')
97
+ continue;
98
+ const args = call.childForFieldName('arguments');
99
+ const specifier = stringLiteralValue(args?.namedChildren[0]);
100
+ if (!specifier || !NODE_ASSERT_SPECIFIERS.has(specifier))
101
+ continue;
102
+ const declarator = ancestorOfType(call, ['variable_declarator']);
103
+ const name = declarator?.childForFieldName('name')?.text;
104
+ if (!name)
105
+ continue;
106
+ if (/^[A-Za-z_$][\w$]*$/.test(name)) {
107
+ aliases.add(name);
108
+ }
109
+ else {
110
+ const pattern = /\{([^}]*)\}/.exec(name);
111
+ if (pattern?.[1]) {
112
+ for (const part of pattern[1].split(','))
113
+ addAssertBinding(aliases, part);
114
+ }
115
+ }
116
+ }
117
+ return aliases;
118
+ }
69
119
  const T_ASSERTION_MEMBERS = new Set([
70
120
  'ok',
71
121
  'is',
@@ -84,9 +134,13 @@ const T_ASSERTION_MEMBERS = new Set([
84
134
  * `assert.strictEqual` ends in `strictEqual`, which the old last-segment
85
135
  * regex missed, so node:assert-based tests were reported as assertion-free.
86
136
  */
87
- function isAssertionCallee(text) {
137
+ function isAssertionCallee(text, aliases) {
88
138
  if (text.length === 0)
89
139
  return false;
140
+ // Renamed imports: nodeAssert.strictEqual, strictAssert.equal, eq(...).
141
+ const root = text.split(/[.(]/)[0] ?? '';
142
+ if (aliases.has(root))
143
+ return true;
90
144
  // node:assert and node:assert/strict: assert(...) plus every method.
91
145
  if (text === 'assert' || text.startsWith('assert.'))
92
146
  return true;
@@ -112,7 +166,7 @@ function isAssertionCallee(text) {
112
166
  }
113
167
  return false;
114
168
  }
115
- function hasAssertion(body) {
169
+ function hasAssertion(body, aliases) {
116
170
  let found = false;
117
171
  walk(body, (node) => {
118
172
  if (found)
@@ -120,7 +174,7 @@ function hasAssertion(body) {
120
174
  if (node.type === 'call_expression') {
121
175
  const fn = node.childForFieldName('function') ?? node.namedChildren[0];
122
176
  const text = collapseWhitespace(fn?.text ?? '');
123
- if (isAssertionCallee(text)) {
177
+ if (isAssertionCallee(text, aliases)) {
124
178
  found = true;
125
179
  return false;
126
180
  }
@@ -237,6 +291,7 @@ const noopTest = {
237
291
  if (ctx.language === 'python')
238
292
  return [];
239
293
  const drafts = [];
294
+ const aliases = assertAliases(ctx.root);
240
295
  for (const call of descendantsOfType(ctx.root, ['call_expression'])) {
241
296
  const fn = call.childForFieldName('function');
242
297
  if (!fn || !isTestCall(fn))
@@ -254,7 +309,7 @@ const noopTest = {
254
309
  continue;
255
310
  const label = args.namedChildren[0]?.type === 'string' ? truncate(args.namedChildren[0].text, 60) : undefined;
256
311
  if (body.type !== 'statement_block') {
257
- if (!hasAssertion(body)) {
312
+ if (!hasAssertion(body, aliases)) {
258
313
  drafts.push({
259
314
  message: 'test makes no assertions',
260
315
  start: startOf(call),
@@ -278,7 +333,7 @@ const noopTest = {
278
333
  });
279
334
  continue;
280
335
  }
281
- if (!hasAssertion(body)) {
336
+ if (!hasAssertion(body, aliases)) {
282
337
  drafts.push({
283
338
  message: 'test makes no assertions',
284
339
  start: startOf(call),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidh4x0r/slopgate",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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",