aislop 0.9.4 → 0.9.5
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/README.md +50 -3
- package/dist/cli.js +1034 -62
- package/dist/{version-C45P3Q1N.js → engine-info-DCvIfZ0f.js} +1 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.js +758 -51
- package/dist/{json-CXiEvR_M.js → json-CZU3lEfE.js} +2 -1
- package/dist/mcp.js +653 -39
- package/dist/sarif-CZVuavf_.js +61 -0
- package/dist/sarif-Cneulb6L.js +60 -0
- package/dist/version-ls3wZmOU.js +5 -0
- package/package.json +3 -2
- package/scripts/gen-config-schema.mjs +35 -0
- /package/dist/{expo-doctor-Bz0LZhQ6.js → expo-doctor-BcIkOte5.js} +0 -0
- /package/dist/{generic-BrcWMW7E.js → generic-D_T4cUaC.js} +0 -0
- /package/dist/{typecheck-XJMuCczG.js → typecheck-DQSzG8fX.js} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { r as APP_VERSION } from "./cli.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/output/sarif.ts
|
|
6
|
+
const SARIF_VERSION = "2.1.0";
|
|
7
|
+
const SARIF_SCHEMA = "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json";
|
|
8
|
+
const levelFromSeverity = (severity) => {
|
|
9
|
+
if (severity === "error") return "error";
|
|
10
|
+
if (severity === "warning") return "warning";
|
|
11
|
+
return "note";
|
|
12
|
+
};
|
|
13
|
+
const oneBased = (value) => value >= 1 ? value : 1;
|
|
14
|
+
const toUri = (filePath) => filePath.split(path.sep).join("/");
|
|
15
|
+
const buildRules = (diagnostics) => {
|
|
16
|
+
const byId = /* @__PURE__ */ new Map();
|
|
17
|
+
for (const d of diagnostics) {
|
|
18
|
+
if (byId.has(d.rule)) continue;
|
|
19
|
+
byId.set(d.rule, {
|
|
20
|
+
id: d.rule,
|
|
21
|
+
name: d.rule,
|
|
22
|
+
shortDescription: { text: d.message },
|
|
23
|
+
help: { text: d.help || d.message }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return [...byId.values()];
|
|
27
|
+
};
|
|
28
|
+
const buildSarifLog = (results) => {
|
|
29
|
+
const diagnostics = results.flatMap((r) => r.diagnostics);
|
|
30
|
+
const rules = buildRules(diagnostics);
|
|
31
|
+
const ruleIndex = new Map(rules.map((rule, index) => [rule.id, index]));
|
|
32
|
+
const sarifResults = diagnostics.map((d) => ({
|
|
33
|
+
ruleId: d.rule,
|
|
34
|
+
ruleIndex: ruleIndex.get(d.rule) ?? 0,
|
|
35
|
+
level: levelFromSeverity(d.severity),
|
|
36
|
+
message: { text: d.message },
|
|
37
|
+
locations: [{ physicalLocation: {
|
|
38
|
+
artifactLocation: { uri: toUri(d.filePath) },
|
|
39
|
+
region: {
|
|
40
|
+
startLine: oneBased(d.line),
|
|
41
|
+
startColumn: oneBased(d.column)
|
|
42
|
+
}
|
|
43
|
+
} }]
|
|
44
|
+
}));
|
|
45
|
+
return {
|
|
46
|
+
$schema: SARIF_SCHEMA,
|
|
47
|
+
version: SARIF_VERSION,
|
|
48
|
+
runs: [{
|
|
49
|
+
tool: { driver: {
|
|
50
|
+
name: "aislop",
|
|
51
|
+
version: APP_VERSION,
|
|
52
|
+
informationUri: "https://github.com/scanaislop/aislop",
|
|
53
|
+
rules
|
|
54
|
+
} },
|
|
55
|
+
results: sarifResults
|
|
56
|
+
}]
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { buildSarifLog };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { t as APP_VERSION } from "./version-ls3wZmOU.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/output/sarif.ts
|
|
5
|
+
const SARIF_VERSION = "2.1.0";
|
|
6
|
+
const SARIF_SCHEMA = "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json";
|
|
7
|
+
const levelFromSeverity = (severity) => {
|
|
8
|
+
if (severity === "error") return "error";
|
|
9
|
+
if (severity === "warning") return "warning";
|
|
10
|
+
return "note";
|
|
11
|
+
};
|
|
12
|
+
const oneBased = (value) => value >= 1 ? value : 1;
|
|
13
|
+
const toUri = (filePath) => filePath.split(path.sep).join("/");
|
|
14
|
+
const buildRules = (diagnostics) => {
|
|
15
|
+
const byId = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const d of diagnostics) {
|
|
17
|
+
if (byId.has(d.rule)) continue;
|
|
18
|
+
byId.set(d.rule, {
|
|
19
|
+
id: d.rule,
|
|
20
|
+
name: d.rule,
|
|
21
|
+
shortDescription: { text: d.message },
|
|
22
|
+
help: { text: d.help || d.message }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return [...byId.values()];
|
|
26
|
+
};
|
|
27
|
+
const buildSarifLog = (results) => {
|
|
28
|
+
const diagnostics = results.flatMap((r) => r.diagnostics);
|
|
29
|
+
const rules = buildRules(diagnostics);
|
|
30
|
+
const ruleIndex = new Map(rules.map((rule, index) => [rule.id, index]));
|
|
31
|
+
const sarifResults = diagnostics.map((d) => ({
|
|
32
|
+
ruleId: d.rule,
|
|
33
|
+
ruleIndex: ruleIndex.get(d.rule) ?? 0,
|
|
34
|
+
level: levelFromSeverity(d.severity),
|
|
35
|
+
message: { text: d.message },
|
|
36
|
+
locations: [{ physicalLocation: {
|
|
37
|
+
artifactLocation: { uri: toUri(d.filePath) },
|
|
38
|
+
region: {
|
|
39
|
+
startLine: oneBased(d.line),
|
|
40
|
+
startColumn: oneBased(d.column)
|
|
41
|
+
}
|
|
42
|
+
} }]
|
|
43
|
+
}));
|
|
44
|
+
return {
|
|
45
|
+
$schema: SARIF_SCHEMA,
|
|
46
|
+
version: SARIF_VERSION,
|
|
47
|
+
runs: [{
|
|
48
|
+
tool: { driver: {
|
|
49
|
+
name: "aislop",
|
|
50
|
+
version: APP_VERSION,
|
|
51
|
+
informationUri: "https://github.com/scanaislop/aislop",
|
|
52
|
+
rules
|
|
53
|
+
} },
|
|
54
|
+
results: sarifResults
|
|
55
|
+
}]
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { buildSarifLog };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aislop",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.5",
|
|
4
|
+
"description": "Catch the slop AI coding agents leave in your code: narrative comments, swallowed exceptions, as-any casts, dead code, oversized functions. 40+ rules across 7 languages (TS/JS, Python, Go, Rust, Ruby, PHP, Java). Sub-second, deterministic, no LLM at runtime. MIT-licensed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"aislop": "./dist/cli.js",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"build": "rm -rf dist && NODE_ENV=production tsdown",
|
|
23
23
|
"postinstall": "node scripts/postinstall-tools.mjs",
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
|
+
"gen:schema": "node --experimental-strip-types scripts/gen-config-schema.mjs",
|
|
25
26
|
"test": "pnpm build && vitest run",
|
|
26
27
|
"scan": "pnpm build && node dist/cli.js scan .",
|
|
27
28
|
"scan:exclude": "pnpm build && node dist/cli.js scan . --exclude .idea --exclude .gitnore --exclude node_modules",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { z } from "zod/v4";
|
|
6
|
+
import { AislopConfigSchema } from "../src/config/schema.ts";
|
|
7
|
+
|
|
8
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const outPath = resolve(here, "..", "schema", "aislop.config.schema.json");
|
|
10
|
+
|
|
11
|
+
// Strip `required`/`additionalProperties:false` so partial user configs (every
|
|
12
|
+
// key has a default) validate, and allow the loader-handled `extends` key.
|
|
13
|
+
const relax = (node) => {
|
|
14
|
+
if (!node || typeof node !== "object") return;
|
|
15
|
+
if (Array.isArray(node)) {
|
|
16
|
+
for (const item of node) relax(item);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
delete node.required;
|
|
20
|
+
if (node.additionalProperties === false) delete node.additionalProperties;
|
|
21
|
+
for (const value of Object.values(node)) relax(value);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const jsonSchema = z.toJSONSchema(AislopConfigSchema, { target: "draft-2020-12" });
|
|
25
|
+
relax(jsonSchema);
|
|
26
|
+
jsonSchema.$id = "https://scanaislop.com/schema/aislop.config.schema.json";
|
|
27
|
+
jsonSchema.title = "aislop configuration (.aislop/config.yml)";
|
|
28
|
+
jsonSchema.description = "Configuration schema for the aislop code-quality CLI.";
|
|
29
|
+
jsonSchema.properties.extends = {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Path to a parent .aislop config to extend.",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
writeFileSync(outPath, `${JSON.stringify(jsonSchema, null, "\t")}\n`);
|
|
35
|
+
process.stdout.write(`Wrote ${outPath}\n`);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|