@unsloplabs/cli 0.0.0-stage → 0.1.1
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/LICENSE.md +63 -0
- package/README.md +28 -2
- package/dist/analyze.d.ts +21 -0
- package/dist/analyze.js +36 -0
- package/dist/analyze.js.map +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +10 -0
- package/dist/bin.js.map +1 -0
- package/dist/check.d.ts +17 -0
- package/dist/check.js +34 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +133 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.js +76 -0
- package/dist/config.js.map +1 -0
- package/dist/format.d.ts +18 -0
- package/dist/format.js +140 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/packs.d.ts +13 -0
- package/dist/packs.js +55 -0
- package/dist/packs.js.map +1 -0
- package/dist/report.d.ts +110 -0
- package/dist/report.js +170 -0
- package/dist/report.js.map +1 -0
- package/package.json +45 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# PolyForm Internal Use License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/internal-use/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license), and you may not distribute the software.
|
|
12
|
+
|
|
13
|
+
## Changes and New Works License
|
|
14
|
+
|
|
15
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
16
|
+
|
|
17
|
+
## Patent License
|
|
18
|
+
|
|
19
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
20
|
+
|
|
21
|
+
## Fair Use
|
|
22
|
+
|
|
23
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
24
|
+
|
|
25
|
+
## Internal Business Use
|
|
26
|
+
|
|
27
|
+
Use of the software for the internal business operations of you and your company is use for a permitted purpose.
|
|
28
|
+
|
|
29
|
+
## No Other Rights
|
|
30
|
+
|
|
31
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
32
|
+
|
|
33
|
+
## Patent Defense
|
|
34
|
+
|
|
35
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
36
|
+
|
|
37
|
+
## Violations
|
|
38
|
+
|
|
39
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
40
|
+
|
|
41
|
+
## No Liability
|
|
42
|
+
|
|
43
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
44
|
+
|
|
45
|
+
## Definitions
|
|
46
|
+
|
|
47
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
48
|
+
|
|
49
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
50
|
+
|
|
51
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
52
|
+
|
|
53
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
54
|
+
|
|
55
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
Licensor: Unslop Labs. Copyright (c) 2026 Unslop Labs.
|
|
60
|
+
|
|
61
|
+
In plain words, which do not replace the terms above: you may install this software and run it
|
|
62
|
+
on your own code, in your own work and your company's. You may not distribute it, repackage it,
|
|
63
|
+
sell it, or offer it to others as a product or a service.
|
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
<p><a href="https://unslop.software"><img src="https://unslop.software/favicon.svg" width="64" height="64" alt="Unslop"></a></p>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @unsloplabs/cli
|
|
4
|
+
|
|
5
|
+
Find out what is wrong with an app made with an AI app builder, in plain English, and keep it fixed.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npx @unsloplabs/cli scan .
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
| Command | What it does |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `unslop scan [dir]` | The Slop Report: one score, the top five issues, and the map behind them |
|
|
14
|
+
| `unslop check [dir]` | A gate for CI: exits 1 when a rule fires or cannot run |
|
|
15
|
+
| `unslop guidance [dir]` | The rules written for a coding agent, ready for `CLAUDE.md` (`--write` puts them there) |
|
|
16
|
+
|
|
17
|
+
`--json` gives output a machine can read (scan, check), `--md` gives Markdown (scan), `--all` shows every issue
|
|
18
|
+
rather than the top five (scan), and `--fail-on low|medium|high|critical` sets how bad an issue has to be to fail
|
|
19
|
+
the check. `unslop --help` lists them all.
|
|
20
|
+
|
|
21
|
+
The checker reads your code and never runs it. Rules for every repo, React, Supabase, Stripe and Lovable apps
|
|
22
|
+
come with it.
|
|
23
|
+
|
|
24
|
+
Want the free report without installing anything, or the app rebuilt so it stops breaking?
|
|
25
|
+
[unslop.software](https://unslop.software)
|
|
26
|
+
|
|
27
|
+
## Licence
|
|
28
|
+
|
|
29
|
+
[PolyForm Internal Use 1.0.0](LICENSE.md): run the checker on your own code; do not distribute or sell it.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type RepoFingerprint, type RepoSnapshot, type ResolvedRuleSet, type RulePack, type RunResult, type RunSession } from '@unsloplabs/engine';
|
|
2
|
+
import { type PlatformDetection } from '@unsloplabs/platforms';
|
|
3
|
+
import { type UnslopConfig } from './config.js';
|
|
4
|
+
export interface AnalyzeInput {
|
|
5
|
+
snapshot: RepoSnapshot;
|
|
6
|
+
config?: UnslopConfig;
|
|
7
|
+
packs?: readonly RulePack[];
|
|
8
|
+
}
|
|
9
|
+
export interface Analysis {
|
|
10
|
+
/** The snapshot after the config's excludes. */
|
|
11
|
+
snapshot: RepoSnapshot;
|
|
12
|
+
fingerprint: RepoFingerprint;
|
|
13
|
+
detection: PlatformDetection;
|
|
14
|
+
/** The platform the rule set was resolved for, if any. */
|
|
15
|
+
platformId: string | undefined;
|
|
16
|
+
ruleSet: ResolvedRuleSet;
|
|
17
|
+
result: RunResult;
|
|
18
|
+
session: RunSession;
|
|
19
|
+
}
|
|
20
|
+
/** The one pipeline behind `scan`, `check` and the hosted Slop Report: fingerprint, detect, layer, run. */
|
|
21
|
+
export declare function analyzeRepo(input: AnalyzeInput): Analysis;
|
package/dist/analyze.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createMatcher, createSession, filterSnapshot, fingerprintRepo, resolveRuleSet, runRules, } from '@unsloplabs/engine';
|
|
2
|
+
import { detectPlatform, sourcePlatforms } from '@unsloplabs/platforms';
|
|
3
|
+
import { DEFAULT_CONFIG } from './config.js';
|
|
4
|
+
import { builtinPacks } from './packs.js';
|
|
5
|
+
function resolvePlatform(config, detected) {
|
|
6
|
+
if (config.platform !== undefined) {
|
|
7
|
+
const forced = sourcePlatforms.find((platform) => platform.id === config.platform);
|
|
8
|
+
if (!forced)
|
|
9
|
+
throw new Error(`Unknown platform "${config.platform}" in config. Known: ${sourcePlatforms.map((p) => p.id).join(', ')}`);
|
|
10
|
+
const match = { confidence: 1, markers: ['set in unslop.config.json'] };
|
|
11
|
+
const stack = forced.stacks[forced.stacks.length - 1];
|
|
12
|
+
if (!stack)
|
|
13
|
+
throw new Error(`Platform "${forced.id}" declares no stack`);
|
|
14
|
+
return { detection: { status: 'supported', platform: forced, stack, match }, platformId: forced.id };
|
|
15
|
+
}
|
|
16
|
+
// Platform overlay rules assume the adapter's stack, so they only apply when that stack is present.
|
|
17
|
+
return { detection: detected, platformId: detected.status === 'supported' ? detected.platform.id : undefined };
|
|
18
|
+
}
|
|
19
|
+
/** The one pipeline behind `scan`, `check` and the hosted Slop Report: fingerprint, detect, layer, run. */
|
|
20
|
+
export function analyzeRepo(input) {
|
|
21
|
+
const config = input.config ?? DEFAULT_CONFIG;
|
|
22
|
+
const snapshot = config.exclude.length > 0 ? filterSnapshot(input.snapshot, createMatcher(config.exclude)) : input.snapshot;
|
|
23
|
+
const fingerprint = fingerprintRepo(snapshot);
|
|
24
|
+
const { detection, platformId } = resolvePlatform(config, detectPlatform({ snapshot, fingerprint }));
|
|
25
|
+
const ruleSet = resolveRuleSet({
|
|
26
|
+
packs: input.packs ?? builtinPacks,
|
|
27
|
+
snapshot,
|
|
28
|
+
fingerprint,
|
|
29
|
+
platform: platformId,
|
|
30
|
+
overrides: config.overrides,
|
|
31
|
+
});
|
|
32
|
+
const session = createSession({ snapshot, fingerprint, platform: platformId });
|
|
33
|
+
const result = runRules({ snapshot, ruleSet, session });
|
|
34
|
+
return { snapshot, fingerprint, detection, platformId, ruleSet, result, session };
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=analyze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,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';
|
|
3
|
+
const code = await run(process.argv.slice(2), {
|
|
4
|
+
out: (text) => process.stdout.write(text),
|
|
5
|
+
err: (text) => process.stderr.write(text),
|
|
6
|
+
cwd: process.cwd(),
|
|
7
|
+
color: process.stdout.isTTY && process.env['NO_COLOR'] === undefined,
|
|
8
|
+
});
|
|
9
|
+
process.exitCode = code;
|
|
10
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC5C,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IACzC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IACzC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS;CACrE,CAAC,CAAC;AACH,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC"}
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Finding, type RunError, type Severity } from '@unsloplabs/engine';
|
|
2
|
+
import type { Analysis } from './analyze.js';
|
|
3
|
+
import { type Palette } from './format.js';
|
|
4
|
+
export interface CheckResult {
|
|
5
|
+
passed: boolean;
|
|
6
|
+
/** Findings at or above the threshold: these fail the gate. */
|
|
7
|
+
failures: Finding[];
|
|
8
|
+
/** Findings below the threshold: reported, not failing. */
|
|
9
|
+
warnings: Finding[];
|
|
10
|
+
/** Rules that could not run. Any error fails the gate: an unchecked rule is not a passed rule. */
|
|
11
|
+
errors: RunError[];
|
|
12
|
+
failOn: Severity;
|
|
13
|
+
rulesRun: number;
|
|
14
|
+
}
|
|
15
|
+
/** The gate: every active rule must run, and none may fire at or above `failOn`. */
|
|
16
|
+
export declare function checkAnalysis(analysis: Analysis, failOn: Severity): CheckResult;
|
|
17
|
+
export declare function renderCheck(result: CheckResult, palette?: Palette): string;
|
package/dist/check.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { severityIndex } from '@unsloplabs/engine';
|
|
2
|
+
import { renderFinding, plainPalette } from './format.js';
|
|
3
|
+
/** The gate: every active rule must run, and none may fire at or above `failOn`. */
|
|
4
|
+
export function checkAnalysis(analysis, failOn) {
|
|
5
|
+
const threshold = severityIndex(failOn);
|
|
6
|
+
const failures = analysis.result.findings.filter((finding) => severityIndex(finding.severity) >= threshold);
|
|
7
|
+
const warnings = analysis.result.findings.filter((finding) => severityIndex(finding.severity) < threshold);
|
|
8
|
+
const errors = analysis.result.errors;
|
|
9
|
+
return { passed: failures.length === 0 && errors.length === 0, failures, warnings, errors, failOn, rulesRun: analysis.ruleSet.rules.length };
|
|
10
|
+
}
|
|
11
|
+
export function renderCheck(result, palette = plainPalette) {
|
|
12
|
+
const lines = [];
|
|
13
|
+
for (const finding of result.failures)
|
|
14
|
+
lines.push(renderFinding(finding, palette));
|
|
15
|
+
for (const finding of result.warnings)
|
|
16
|
+
lines.push(renderFinding(finding, palette));
|
|
17
|
+
for (const error of result.errors)
|
|
18
|
+
lines.push(palette.red(`error ${error.ruleId} ${error.message}`));
|
|
19
|
+
if (lines.length > 0)
|
|
20
|
+
lines.push('');
|
|
21
|
+
if (result.passed) {
|
|
22
|
+
const note = result.warnings.length > 0 ? ` (${result.warnings.length} below the "${result.failOn}" threshold)` : '';
|
|
23
|
+
lines.push(palette.green(`unslop check passed: ${result.rulesRun} rules, 0 failures${note}`));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const failingRules = new Set(result.failures.map((finding) => finding.ruleId)).size;
|
|
27
|
+
const parts = [`${result.failures.length} ${result.failures.length === 1 ? 'finding' : 'findings'} in ${failingRules} of ${result.rulesRun} rules`];
|
|
28
|
+
if (result.errors.length > 0)
|
|
29
|
+
parts.push(`${result.errors.length} rule error(s)`);
|
|
30
|
+
lines.push(palette.red(`unslop check failed: ${parts.join(', ')}`));
|
|
31
|
+
}
|
|
32
|
+
return lines.join('\n') + '\n';
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8C,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAAE,aAAa,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAC;AAcxE,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,QAAkB,EAAE,MAAgB;IAChE,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,CAAC;IAC5G,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC;IAC3G,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,E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CAAC;QACpF,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,OAAO,YAAY,OAAO,MAAM,CAAC,QAAQ,QAAQ,CAAC,CAAC;QACpJ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,gBAAgB,CAAC,CAAC;QAClF,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface CliIo {
|
|
2
|
+
out(text: string): void;
|
|
3
|
+
err(text: string): void;
|
|
4
|
+
cwd: string;
|
|
5
|
+
color: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Runs the CLI. Returns the process exit code: 0 ok, 1 gate failed, 2 usage or config error. */
|
|
8
|
+
export declare function run(argv: readonly string[], io: CliIo): Promise<number>;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { basename, join, resolve } from 'node:path';
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { compileGuidance, createFsSnapshot, isSeverity, mergeGuidance, RuleSetError } from '@unsloplabs/engine';
|
|
6
|
+
import { analyzeRepo } from './analyze.js';
|
|
7
|
+
import { checkAnalysis, renderCheck } from './check.js';
|
|
8
|
+
import { ConfigError, loadConfig } from './config.js';
|
|
9
|
+
import { colorPalette, plainPalette, renderReportMarkdown, renderReportText } from './format.js';
|
|
10
|
+
import { builtinPacks, loadPacks } from './packs.js';
|
|
11
|
+
import { buildReport } from './report.js';
|
|
12
|
+
const USAGE = `unslop: find out what is wrong with a vibe-coded app, and keep it fixed.
|
|
13
|
+
|
|
14
|
+
Usage
|
|
15
|
+
unslop scan [dir] Slop Report: one score, the top five issues, the map behind them
|
|
16
|
+
unslop check [dir] CI gate: exits 1 when an active rule fires or cannot run
|
|
17
|
+
unslop guidance [dir] Print the agent rules for CLAUDE.md, compiled from the active rule packs
|
|
18
|
+
|
|
19
|
+
Options
|
|
20
|
+
--json Machine-readable output (scan, check)
|
|
21
|
+
--md Markdown output (scan)
|
|
22
|
+
--all Show every issue, not just the top five (scan)
|
|
23
|
+
--fail-on <severity> low | medium | high | critical. Overrides the config (check)
|
|
24
|
+
--write Write the rules block into CLAUDE.md (guidance)
|
|
25
|
+
-h, --help Show this help
|
|
26
|
+
`;
|
|
27
|
+
class UsageError extends Error {
|
|
28
|
+
}
|
|
29
|
+
function targetDir(io, positional) {
|
|
30
|
+
const dir = resolve(io.cwd, positional ?? '.');
|
|
31
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory())
|
|
32
|
+
throw new UsageError(`Not a directory: ${dir}`);
|
|
33
|
+
return dir;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* When `dir` is the top of a git work tree: the files git would commit, tracked or new, without
|
|
37
|
+
* what .gitignore leaves out. A local `.env` the repo ignores is not the repo's, and reporting it as
|
|
38
|
+
* committed is wrong. Anywhere else (no git, a folder inside a repo, git not installed): undefined,
|
|
39
|
+
* and every file is read.
|
|
40
|
+
*/
|
|
41
|
+
function gitFiles(dir) {
|
|
42
|
+
const git = (...args) => execFileSync('git', ['-C', dir, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 64 * 1024 * 1024 });
|
|
43
|
+
try {
|
|
44
|
+
if (realpathSync(git('rev-parse', '--show-toplevel').trim()) !== realpathSync(dir))
|
|
45
|
+
return undefined;
|
|
46
|
+
return git('ls-files', '-z', '--cached', '--others', '--exclude-standard').split('\0').filter(Boolean);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Not a git work tree, or no git here: read the folder as it is, as before.
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function prepare(dir) {
|
|
54
|
+
const only = gitFiles(dir);
|
|
55
|
+
const snapshot = createFsSnapshot(dir, only === undefined ? {} : { only });
|
|
56
|
+
const config = loadConfig(snapshot);
|
|
57
|
+
let packs = builtinPacks;
|
|
58
|
+
if (config.packs !== undefined)
|
|
59
|
+
packs = (await loadPacks(config.packs, dir)).map((loaded) => loaded.pack);
|
|
60
|
+
return { ...analyzeRepo({ snapshot, config, packs }), failOn: config.failOn };
|
|
61
|
+
}
|
|
62
|
+
/** Runs the CLI. Returns the process exit code: 0 ok, 1 gate failed, 2 usage or config error. */
|
|
63
|
+
export async function run(argv, io) {
|
|
64
|
+
const palette = io.color ? colorPalette : plainPalette;
|
|
65
|
+
try {
|
|
66
|
+
const { values, positionals } = parseArgs({
|
|
67
|
+
args: [...argv],
|
|
68
|
+
allowPositionals: true,
|
|
69
|
+
options: {
|
|
70
|
+
json: { type: 'boolean', default: false },
|
|
71
|
+
md: { type: 'boolean', default: false },
|
|
72
|
+
all: { type: 'boolean', default: false },
|
|
73
|
+
write: { type: 'boolean', default: false },
|
|
74
|
+
'fail-on': { type: 'string' },
|
|
75
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const [command, dirArgument, ...extra] = positionals;
|
|
79
|
+
if (values.help || command === undefined) {
|
|
80
|
+
io.out(USAGE);
|
|
81
|
+
return command === undefined && !values.help ? 2 : 0;
|
|
82
|
+
}
|
|
83
|
+
if (extra.length > 0)
|
|
84
|
+
throw new UsageError(`Unexpected argument: ${extra[0] ?? ''}`);
|
|
85
|
+
const dir = targetDir(io, dirArgument);
|
|
86
|
+
if (command === 'scan') {
|
|
87
|
+
const analysis = await prepare(dir);
|
|
88
|
+
const report = buildReport(analysis, { repoName: basename(dir) });
|
|
89
|
+
if (values.json)
|
|
90
|
+
io.out(JSON.stringify(report, null, 2) + '\n');
|
|
91
|
+
else if (values.md)
|
|
92
|
+
io.out(renderReportMarkdown(report));
|
|
93
|
+
else
|
|
94
|
+
io.out(renderReportText(report, palette, values.all));
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
if (command === 'check') {
|
|
98
|
+
const analysis = await prepare(dir);
|
|
99
|
+
const failOn = values['fail-on'] ?? analysis.failOn;
|
|
100
|
+
if (!isSeverity(failOn))
|
|
101
|
+
throw new UsageError(`--fail-on must be low, medium, high or critical; got "${failOn}"`);
|
|
102
|
+
const result = checkAnalysis(analysis, failOn);
|
|
103
|
+
io.out(values.json ? JSON.stringify(result, null, 2) + '\n' : renderCheck(result, palette));
|
|
104
|
+
return result.passed ? 0 : 1;
|
|
105
|
+
}
|
|
106
|
+
if (command === 'guidance') {
|
|
107
|
+
const analysis = await prepare(dir);
|
|
108
|
+
const block = compileGuidance(analysis.ruleSet, analysis.session.architecture);
|
|
109
|
+
if (!values.write) {
|
|
110
|
+
io.out(block + '\n');
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
const file = join(dir, 'CLAUDE.md');
|
|
114
|
+
const existing = existsSync(file) ? readFileSync(file, 'utf8') : undefined;
|
|
115
|
+
writeFileSync(file, mergeGuidance(existing, block));
|
|
116
|
+
io.out(`Wrote ${analysis.ruleSet.rules.length} rules to ${file}\n`);
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
throw new UsageError(`Unknown command: ${command}`);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (error instanceof UsageError || error instanceof ConfigError || error instanceof RuleSetError) {
|
|
123
|
+
io.err(`unslop: ${error.message}\n`);
|
|
124
|
+
return 2;
|
|
125
|
+
}
|
|
126
|
+
if (error instanceof Error && 'code' in error && typeof error.code === 'string' && error.code.startsWith('ERR_PARSE_ARGS')) {
|
|
127
|
+
io.err(`unslop: ${error.message}\n\n${USAGE}`);
|
|
128
|
+
return 2;
|
|
129
|
+
}
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAS1C,MAAM,KAAK,GAAG;;;;;;;;;;;;;;CAcb,CAAC;AAEF,MAAM,UAAW,SAAQ,KAAK;C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AAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YACpD,EAAE,CAAC,GAAG,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,aAAa,IAAI,IAAI,CAAC,CAAC;YACpE,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,IAAI,UAAU,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,YAAY,WAAW,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;YACjG,EAAE,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;YACrC,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC3H,EAAE,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC;YAC/C,OAAO,CAAC,CAAC;QACX,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type RepoSnapshot, type RuleOverride, type Severity } from '@unsloplabs/engine';
|
|
2
|
+
export declare const CONFIG_FILE = "unslop.config.json";
|
|
3
|
+
/** A repo's `unslop.config.json`: the repo layer of the rule set, plus how the gate behaves. */
|
|
4
|
+
export interface UnslopConfig {
|
|
5
|
+
/** Source platform id. Leave out to detect it from the repo. */
|
|
6
|
+
platform?: string;
|
|
7
|
+
/** Path globs left out of every rule: fixtures, vendored code, sample apps. */
|
|
8
|
+
exclude: readonly string[];
|
|
9
|
+
/** The owner's recorded decisions to tune or disable rules. Each needs a reason. */
|
|
10
|
+
overrides: readonly RuleOverride[];
|
|
11
|
+
/** `unslop check` fails on findings at or above this severity. Default `low`: any finding fails. */
|
|
12
|
+
failOn: Severity;
|
|
13
|
+
/** Rule packs to load, by npm name, resolved from the repo's own node_modules first. */
|
|
14
|
+
packs?: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export declare class ConfigError extends Error {
|
|
17
|
+
readonly name = "ConfigError";
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_CONFIG: UnslopConfig;
|
|
20
|
+
export declare function parseConfig(raw: unknown): UnslopConfig;
|
|
21
|
+
export declare function loadConfig(snapshot: RepoSnapshot): UnslopConfig;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isRecord, isSeverity, readJson } from '@unsloplabs/engine';
|
|
2
|
+
export const CONFIG_FILE = 'unslop.config.json';
|
|
3
|
+
export class ConfigError extends Error {
|
|
4
|
+
name = 'ConfigError';
|
|
5
|
+
}
|
|
6
|
+
export const DEFAULT_CONFIG = { exclude: [], overrides: [], failOn: 'low' };
|
|
7
|
+
function strings(value, field) {
|
|
8
|
+
if (value === undefined)
|
|
9
|
+
return [];
|
|
10
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
|
|
11
|
+
throw new ConfigError(`${CONFIG_FILE}: "${field}" must be a list of strings`);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function parseOverride(raw, index) {
|
|
16
|
+
const where = `${CONFIG_FILE}: overrides[${index}]`;
|
|
17
|
+
if (!isRecord(raw))
|
|
18
|
+
throw new ConfigError(`${where} must be an object`);
|
|
19
|
+
if (typeof raw['rule'] !== 'string')
|
|
20
|
+
throw new ConfigError(`${where} needs a "rule" id`);
|
|
21
|
+
if (raw['action'] !== 'disable' && raw['action'] !== 'tune') {
|
|
22
|
+
throw new ConfigError(`${where}: "action" must be "disable" or "tune"`);
|
|
23
|
+
}
|
|
24
|
+
if (typeof raw['reason'] !== 'string' || raw['reason'].trim() === '') {
|
|
25
|
+
throw new ConfigError(`${where}: a "reason" is required. Rules are never changed silently.`);
|
|
26
|
+
}
|
|
27
|
+
if (raw['severity'] !== undefined && !isSeverity(raw['severity'])) {
|
|
28
|
+
throw new ConfigError(`${where}: unknown severity ${JSON.stringify(raw['severity'])}`);
|
|
29
|
+
}
|
|
30
|
+
if (raw['options'] !== undefined && !isRecord(raw['options']))
|
|
31
|
+
throw new ConfigError(`${where}: "options" must be an object`);
|
|
32
|
+
const exclude = strings(raw['exclude'], `overrides[${index}].exclude`);
|
|
33
|
+
return {
|
|
34
|
+
rule: raw['rule'],
|
|
35
|
+
action: raw['action'],
|
|
36
|
+
reason: raw['reason'],
|
|
37
|
+
...(raw['severity'] === undefined ? {} : { severity: raw['severity'] }),
|
|
38
|
+
...(exclude.length > 0 ? { exclude } : {}),
|
|
39
|
+
...(raw['options'] === undefined ? {} : { options: raw['options'] }),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function parseConfig(raw) {
|
|
43
|
+
if (!isRecord(raw))
|
|
44
|
+
throw new ConfigError(`${CONFIG_FILE} must be an object`);
|
|
45
|
+
const known = new Set(['$schema', 'platform', 'exclude', 'overrides', 'failOn', 'packs']);
|
|
46
|
+
for (const key of Object.keys(raw)) {
|
|
47
|
+
if (!known.has(key))
|
|
48
|
+
throw new ConfigError(`${CONFIG_FILE}: unknown field "${key}"`);
|
|
49
|
+
}
|
|
50
|
+
if (raw['platform'] !== undefined && typeof raw['platform'] !== 'string') {
|
|
51
|
+
throw new ConfigError(`${CONFIG_FILE}: "platform" must be a string`);
|
|
52
|
+
}
|
|
53
|
+
if (raw['failOn'] !== undefined && !isSeverity(raw['failOn'])) {
|
|
54
|
+
throw new ConfigError(`${CONFIG_FILE}: "failOn" must be one of low, medium, high, critical`);
|
|
55
|
+
}
|
|
56
|
+
if (raw['overrides'] !== undefined && !Array.isArray(raw['overrides'])) {
|
|
57
|
+
throw new ConfigError(`${CONFIG_FILE}: "overrides" must be a list`);
|
|
58
|
+
}
|
|
59
|
+
const packs = raw['packs'] === undefined ? undefined : strings(raw['packs'], 'packs');
|
|
60
|
+
return {
|
|
61
|
+
...(raw['platform'] === undefined ? {} : { platform: raw['platform'] }),
|
|
62
|
+
exclude: strings(raw['exclude'], 'exclude'),
|
|
63
|
+
overrides: (raw['overrides'] ?? []).map(parseOverride),
|
|
64
|
+
failOn: raw['failOn'] ?? 'low',
|
|
65
|
+
...(packs === undefined ? {} : { packs }),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function loadConfig(snapshot) {
|
|
69
|
+
if (!snapshot.has(CONFIG_FILE))
|
|
70
|
+
return DEFAULT_CONFIG;
|
|
71
|
+
const raw = readJson(snapshot, CONFIG_FILE);
|
|
72
|
+
if (raw === undefined)
|
|
73
|
+
throw new ConfigError(`${CONFIG_FILE} is not valid JSON`);
|
|
74
|
+
return parseConfig(raw);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAuD,MAAM,oBAAoB,CAAC;AAEzH,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAgBhD,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClB,IAAI,GAAG,aAAa,CAAC;CACxC;AAED,MAAM,CAAC,MAAM,cAAc,GAAiB,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAE1F,SAAS,OAAO,CAAC,KAAc,EAAE,KAAa;IAC5C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,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AAC,CAAC,EAAE,KAAK,EAAE,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAsB;IAC/C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;QAAE,OAAO,cAAc,CAAC;IACtD,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5C,IAAI,GAAG,KAAK,SAAS;QAAE,MAAM,IAAI,WAAW,CAAC,GAAG,WAAW,oBAAoB,CAAC,CAAC;IACjF,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Finding } from '@unsloplabs/engine';
|
|
2
|
+
import type { SlopReport } from './report.js';
|
|
3
|
+
export interface Palette {
|
|
4
|
+
bold(text: string): string;
|
|
5
|
+
dim(text: string): string;
|
|
6
|
+
red(text: string): string;
|
|
7
|
+
yellow(text: string): string;
|
|
8
|
+
green(text: string): string;
|
|
9
|
+
}
|
|
10
|
+
export declare const colorPalette: Palette;
|
|
11
|
+
export declare const plainPalette: Palette;
|
|
12
|
+
export declare function location(finding: Finding): string;
|
|
13
|
+
/** The Slop Report for a terminal. Talks outcomes first; rule names are the small print. */
|
|
14
|
+
export declare function renderReportText(report: SlopReport, palette?: Palette, showAll?: boolean): string;
|
|
15
|
+
/** The same report as Markdown, for a PR comment or an email. */
|
|
16
|
+
export declare function renderReportMarkdown(report: SlopReport): string;
|
|
17
|
+
/** One line per finding, in the `file:line severity rule message` shape editors and CI logs link. */
|
|
18
|
+
export declare function renderFinding(finding: Finding, palette?: Palette): string;
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const wrap = (code) => (text) => `\u001b[${code}m${text}\u001b[0m`;
|
|
2
|
+
const identity = (text) => text;
|
|
3
|
+
export const colorPalette = { bold: wrap(1), dim: wrap(2), red: wrap(31), yellow: wrap(33), green: wrap(32) };
|
|
4
|
+
export const plainPalette = { bold: identity, dim: identity, red: identity, yellow: identity, green: identity };
|
|
5
|
+
const GRADE_LABEL = {
|
|
6
|
+
clean: 'Clean',
|
|
7
|
+
'needs-attention': 'Needs attention',
|
|
8
|
+
fragile: 'Fragile',
|
|
9
|
+
critical: 'Critical',
|
|
10
|
+
};
|
|
11
|
+
function paint(palette, severity, text) {
|
|
12
|
+
if (severity === 'critical' || severity === 'high')
|
|
13
|
+
return palette.red(text);
|
|
14
|
+
if (severity === 'medium')
|
|
15
|
+
return palette.yellow(text);
|
|
16
|
+
return palette.dim(text);
|
|
17
|
+
}
|
|
18
|
+
function gradeColor(palette, grade, text) {
|
|
19
|
+
if (grade === 'clean')
|
|
20
|
+
return palette.green(text);
|
|
21
|
+
if (grade === 'needs-attention')
|
|
22
|
+
return palette.yellow(text);
|
|
23
|
+
return palette.red(text);
|
|
24
|
+
}
|
|
25
|
+
export function location(finding) {
|
|
26
|
+
if (finding.file === undefined)
|
|
27
|
+
return '(whole repo)';
|
|
28
|
+
return finding.line === undefined ? finding.file : `${finding.file}:${finding.line}`;
|
|
29
|
+
}
|
|
30
|
+
const plural = (count, one, many = `${one}s`) => `${count} ${count === 1 ? one : many}`;
|
|
31
|
+
const usd = (amount) => `$${amount.toLocaleString('en-US')}`;
|
|
32
|
+
function issueLines(issue, index, palette) {
|
|
33
|
+
const where = issue.examples.map(location).filter((place) => place !== '(whole repo)').slice(0, 2).join(', ');
|
|
34
|
+
const tag = paint(palette, issue.severity, issue.severity.toUpperCase().padEnd(8));
|
|
35
|
+
const lines = [`${String(index + 1).padStart(3)}. ${tag} ${palette.bold(issue.ownerSummary)}`];
|
|
36
|
+
const evidence = [issue.title, plural(issue.count, 'place'), where].filter((part) => part !== '').join(' · ');
|
|
37
|
+
lines.push(` ${palette.dim(evidence)}`);
|
|
38
|
+
return lines;
|
|
39
|
+
}
|
|
40
|
+
function platformLine(report) {
|
|
41
|
+
const { platform } = report;
|
|
42
|
+
if (platform.id === null)
|
|
43
|
+
return 'Origin not recognised: no supported builder left its marks on this repo.';
|
|
44
|
+
if (platform.supported)
|
|
45
|
+
return `${platform.displayName} project${platform.stack === null ? '' : ` (${platform.stack})`}`;
|
|
46
|
+
if (platform.stack !== null)
|
|
47
|
+
return `${platform.displayName} project on a stack Unslop does not support yet (supported: ${platform.stack}).`;
|
|
48
|
+
return `${platform.displayName} project. Unslop does not support ${platform.displayName} yet; this report still applies.`;
|
|
49
|
+
}
|
|
50
|
+
/** The Slop Report for a terminal. Talks outcomes first; rule names are the small print. */
|
|
51
|
+
export function renderReportText(report, palette = plainPalette, showAll = false) {
|
|
52
|
+
const lines = [];
|
|
53
|
+
lines.push(palette.bold('Slop Report') + (report.repo.name === null ? '' : ` ${report.repo.name}`));
|
|
54
|
+
lines.push(palette.dim(`${platformLine(report)} · ${plural(report.repo.sourceFiles, 'source file')} · ${report.repo.linesOfCode.toLocaleString('en-US')} lines`));
|
|
55
|
+
lines.push('');
|
|
56
|
+
lines.push(`Health score ${gradeColor(palette, report.grade, palette.bold(`${report.score} / 100`))} ${gradeColor(palette, report.grade, GRADE_LABEL[report.grade])}`);
|
|
57
|
+
lines.push(` Security ${String(report.scores.security).padStart(3)} / 100`);
|
|
58
|
+
lines.push(` Maintenance ${String(report.scores.maintenance).padStart(3)} / 100 ${palette.dim(report.scores.areas.map((area) => `${area.label.toLowerCase()} ${area.score}`).join(' · '))}`);
|
|
59
|
+
lines.push('');
|
|
60
|
+
if (report.issues.length === 0) {
|
|
61
|
+
lines.push(palette.green('No issues found by the active rules.'));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const shown = showAll ? report.issues : report.topIssues;
|
|
65
|
+
lines.push(palette.bold(showAll ? 'Issues' : `Top ${shown.length} ${shown.length === 1 ? 'issue' : 'issues'}`));
|
|
66
|
+
shown.forEach((issue, index) => lines.push(...issueLines(issue, index, palette)));
|
|
67
|
+
const hidden = report.issues.length - shown.length;
|
|
68
|
+
if (hidden > 0)
|
|
69
|
+
lines.push(palette.dim(` …and ${plural(hidden, 'more issue')}. Run with --all to see them.`));
|
|
70
|
+
}
|
|
71
|
+
lines.push('');
|
|
72
|
+
lines.push(palette.bold('How the code is organised') + palette.dim(report.architecture.source === 'declared' ? ' (from architecture.json)' : ' (inferred from folders; nothing is enforced)'));
|
|
73
|
+
for (const module of report.architecture.modules.slice(0, 8)) {
|
|
74
|
+
const uses = report.architecture.edges.filter((edge) => edge.from === module.name).map((edge) => edge.to);
|
|
75
|
+
lines.push(` ${module.name.padEnd(16)} ${plural(module.files, 'file').padEnd(10)}${uses.length > 0 ? palette.dim(` → ${uses.join(', ')}`) : ''}`);
|
|
76
|
+
}
|
|
77
|
+
if (report.architecture.tangles.length > 0) {
|
|
78
|
+
lines.push(` ${palette.yellow('Tangled:')} ${report.architecture.tangles.map(([a, b]) => `${a} ↔ ${b}`).join(', ')}`);
|
|
79
|
+
}
|
|
80
|
+
lines.push('');
|
|
81
|
+
const { tests } = report;
|
|
82
|
+
lines.push(`${palette.bold('Tests')} ${plural(tests.unitTestFiles, 'unit test file')}, ${plural(tests.endToEndSpecs, 'end-to-end spec')} for ${plural(tests.sourceFiles, 'source file')}`);
|
|
83
|
+
if (report.managedServices.length > 0) {
|
|
84
|
+
lines.push(`${palette.bold('Stays on ' + report.platform.displayName)} ${report.managedServices.map((service) => service.name).join(', ')}`);
|
|
85
|
+
}
|
|
86
|
+
if (report.rules.exceptions.length > 0) {
|
|
87
|
+
lines.push(palette.dim(`${plural(report.rules.exceptions.length, 'rule')} adjusted for this repo, each with a recorded reason (see --json).`));
|
|
88
|
+
}
|
|
89
|
+
for (const error of report.errors)
|
|
90
|
+
lines.push(palette.red(`Could not run ${error.ruleId}: ${error.message}`));
|
|
91
|
+
lines.push('');
|
|
92
|
+
if (!report.rebuildable) {
|
|
93
|
+
lines.push(`${palette.bold('No estimate.')} The repo is missing parts of the app, so it cannot be unslopped as it stands.`);
|
|
94
|
+
}
|
|
95
|
+
else if (report.platform.supported) {
|
|
96
|
+
const price = `${report.quote.startingAt ? 'from ' : ''}${usd(report.quote.priceUsd)} one-time`;
|
|
97
|
+
lines.push(`${palette.bold('Estimate')} ${report.quote.label}, ${price}`);
|
|
98
|
+
}
|
|
99
|
+
else if (report.platform.waitlist !== null) {
|
|
100
|
+
lines.push(`${palette.bold('Not supported yet.')} Join the ${report.platform.displayName} waitlist to be told when it is.`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
lines.push(palette.dim('Unslop currently fixes Lovable projects. This report is still yours to use.'));
|
|
104
|
+
}
|
|
105
|
+
return lines.join('\n') + '\n';
|
|
106
|
+
}
|
|
107
|
+
/** The same report as Markdown, for a PR comment or an email. */
|
|
108
|
+
export function renderReportMarkdown(report) {
|
|
109
|
+
const lines = [`# Slop Report${report.repo.name === null ? '' : `: ${report.repo.name}`}`, ''];
|
|
110
|
+
lines.push(`**Health score: ${report.score} / 100 (${GRADE_LABEL[report.grade]})**`, '');
|
|
111
|
+
lines.push(`Security ${report.scores.security} / 100 · Maintenance ${report.scores.maintenance} / 100 (${report.scores.areas.map((area) => `${area.label.toLowerCase()} ${area.score}`).join(', ')})`, '');
|
|
112
|
+
lines.push(`${platformLine(report)} · ${plural(report.repo.sourceFiles, 'source file')} · ${report.repo.linesOfCode.toLocaleString('en-US')} lines`, '');
|
|
113
|
+
if (report.topIssues.length > 0) {
|
|
114
|
+
lines.push('## Top issues', '');
|
|
115
|
+
report.topIssues.forEach((issue, index) => {
|
|
116
|
+
lines.push(`${index + 1}. **${issue.ownerSummary}** `);
|
|
117
|
+
lines.push(` ${issue.severity} · ${issue.title} · ${plural(issue.count, 'place')}`);
|
|
118
|
+
});
|
|
119
|
+
lines.push('');
|
|
120
|
+
}
|
|
121
|
+
if (report.issues.length > report.topIssues.length) {
|
|
122
|
+
lines.push('## Everything else', '', '| Issue | Severity | Places |', '| --- | --- | --- |');
|
|
123
|
+
for (const issue of report.issues.slice(report.topIssues.length))
|
|
124
|
+
lines.push(`| ${issue.title} | ${issue.severity} | ${issue.count} |`);
|
|
125
|
+
lines.push('');
|
|
126
|
+
}
|
|
127
|
+
lines.push('## Tests', '', `${plural(report.tests.unitTestFiles, 'unit test file')} and ${plural(report.tests.endToEndSpecs, 'end-to-end spec')} for ${plural(report.tests.sourceFiles, 'source file')}.`, '');
|
|
128
|
+
if (report.managedServices.length > 0) {
|
|
129
|
+
lines.push(`## Stays on ${report.platform.displayName}`, '');
|
|
130
|
+
for (const service of report.managedServices)
|
|
131
|
+
lines.push(`- **${service.name}**: ${service.description}`);
|
|
132
|
+
lines.push('');
|
|
133
|
+
}
|
|
134
|
+
return lines.join('\n');
|
|
135
|
+
}
|
|
136
|
+
/** One line per finding, in the `file:line severity rule message` shape editors and CI logs link. */
|
|
137
|
+
export function renderFinding(finding, palette = plainPalette) {
|
|
138
|
+
return `${location(finding)} ${paint(palette, finding.severity, finding.severity)} ${palette.dim(finding.ruleId)} ${finding.message}`;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAWA,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,IAAI,IAAI,IAAI,WAAW,CAAC;AACnF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACvH,MAAM,CAAC,MAAM,YAAY,GAAY,EAAE,IAAI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E,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7D,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,eAAe;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAC1G,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,UAAmB,YAAY;IAC7E,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3I,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { analyzeRepo, type Analysis, type AnalyzeInput } from './analyze.js';
|
|
2
|
+
export { buildReport, createSlopReport, screenFromRouteFile, REPORT_SCHEMA_VERSION, TOP_ISSUE_COUNT, type MaintenanceArea, type ReportManagedService, type ReportOptions, type ReportPlatform, type SlopReport, } from './report.js';
|
|
3
|
+
export { isReportStage, REPORT_STAGES, UNSLOP_STAGES, type ReportStage, type UnslopStage } from '@unsloplabs/pricing';
|
|
4
|
+
export { checkAnalysis, renderCheck, type CheckResult } from './check.js';
|
|
5
|
+
export { CONFIG_FILE, ConfigError, DEFAULT_CONFIG, loadConfig, parseConfig, type UnslopConfig } from './config.js';
|
|
6
|
+
export { builtinPacks, loadPacks, type LoadedPack } from './packs.js';
|
|
7
|
+
export { formatUsd, KEEP_CLEAN_MONTHLY_USD, quoteFor, TIERS, type Quote, type TierId } from '@unsloplabs/pricing';
|
|
8
|
+
export { colorPalette, plainPalette, renderFinding, renderReportMarkdown, renderReportText, type Palette } from './format.js';
|
|
9
|
+
export { run, type CliIo } from './cli.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { analyzeRepo } from './analyze.js';
|
|
2
|
+
export { buildReport, createSlopReport, screenFromRouteFile, REPORT_SCHEMA_VERSION, TOP_ISSUE_COUNT, } from './report.js';
|
|
3
|
+
export { isReportStage, REPORT_STAGES, UNSLOP_STAGES } from '@unsloplabs/pricing';
|
|
4
|
+
export { checkAnalysis, renderCheck } from './check.js';
|
|
5
|
+
export { CONFIG_FILE, ConfigError, DEFAULT_CONFIG, loadConfig, parseConfig } from './config.js';
|
|
6
|
+
export { builtinPacks, loadPacks } from './packs.js';
|
|
7
|
+
export { formatUsd, KEEP_CLEAN_MONTHLY_USD, quoteFor, TIERS } from '@unsloplabs/pricing';
|
|
8
|
+
export { colorPalette, plainPalette, renderFinding, renderReportMarkdown, renderReportText } from './format.js';
|
|
9
|
+
export { run } from './cli.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoC,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,GAMhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAsC,MAAM,qBAAqB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAmB,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,KAAK,EAA2B,MAAM,qBAAqB,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,gBAAgB,EAAgB,MAAM,aAAa,CAAC;AAC9H,OAAO,EAAE,GAAG,EAAc,MAAM,UAAU,CAAC"}
|
package/dist/packs.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RulePack } from '@unsloplabs/engine';
|
|
2
|
+
/** The packs this version of the CLI ships with. */
|
|
3
|
+
export declare const builtinPacks: readonly RulePack[];
|
|
4
|
+
export interface LoadedPack {
|
|
5
|
+
pack: RulePack;
|
|
6
|
+
/** `repo` when it came from the repo's own node_modules (a pinned version), else `builtin`. */
|
|
7
|
+
source: 'repo' | 'builtin';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Loads rule packs by npm name. A delivered repo pins its packs as dependencies, so its own
|
|
11
|
+
* node_modules wins: the gate then runs exactly the version the repo was delivered with.
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadPacks(names: readonly string[], repoDir: string | undefined): Promise<LoadedPack[]>;
|
package/dist/packs.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { join, relative, isAbsolute } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { isRecord } from '@unsloplabs/engine';
|
|
6
|
+
import rulesBase from '@unsloplabs/rules-base';
|
|
7
|
+
import rulesLovable from '@unsloplabs/rules-lovable';
|
|
8
|
+
import rulesReact from '@unsloplabs/rules-react';
|
|
9
|
+
import rulesStripe from '@unsloplabs/rules-stripe';
|
|
10
|
+
import rulesSupabase from '@unsloplabs/rules-supabase';
|
|
11
|
+
/** The packs this version of the CLI ships with. */
|
|
12
|
+
export const builtinPacks = [rulesBase, rulesReact, rulesSupabase, rulesStripe, rulesLovable];
|
|
13
|
+
function isRulePack(value) {
|
|
14
|
+
return isRecord(value) && typeof value['name'] === 'string' && typeof value['version'] === 'string' && Array.isArray(value['rules']);
|
|
15
|
+
}
|
|
16
|
+
function isInside(dir, file) {
|
|
17
|
+
const path = relative(dir, file);
|
|
18
|
+
return path !== '' && !path.startsWith('..') && !isAbsolute(path);
|
|
19
|
+
}
|
|
20
|
+
/** The pack as the repo itself has it installed, if it has. */
|
|
21
|
+
async function packInRepo(name, repoDir) {
|
|
22
|
+
try {
|
|
23
|
+
const resolved = createRequire(join(repoDir, 'package.json')).resolve(name);
|
|
24
|
+
// NODE_PATH and global folders can satisfy the lookup too; only the repo's own install is a pin.
|
|
25
|
+
if (!isInside(realpathSync(repoDir), realpathSync(resolved)))
|
|
26
|
+
return undefined;
|
|
27
|
+
const module = await import(pathToFileURL(resolved).href);
|
|
28
|
+
const candidate = isRecord(module) ? module['default'] : undefined;
|
|
29
|
+
return isRulePack(candidate) ? candidate : undefined;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Not installed in the repo: the built-in copy is used.
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Loads rule packs by npm name. A delivered repo pins its packs as dependencies, so its own
|
|
38
|
+
* node_modules wins: the gate then runs exactly the version the repo was delivered with.
|
|
39
|
+
*/
|
|
40
|
+
export async function loadPacks(names, repoDir) {
|
|
41
|
+
const loaded = [];
|
|
42
|
+
for (const name of names) {
|
|
43
|
+
const fromRepo = repoDir === undefined ? undefined : await packInRepo(name, repoDir);
|
|
44
|
+
if (fromRepo) {
|
|
45
|
+
loaded.push({ pack: fromRepo, source: 'repo' });
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const builtin = builtinPacks.find((pack) => pack.name === name);
|
|
49
|
+
if (!builtin)
|
|
50
|
+
throw new Error(`Rule pack "${name}" is not installed in the repo and is not built in.`);
|
|
51
|
+
loaded.push({ pack: builtin, source: 'builtin' });
|
|
52
|
+
}
|
|
53
|
+
return loaded;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=packs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packs.js","sourceRoot":"","sources":["../src/packs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAiB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,YAAY,MAAM,2BAA2B,CAAC;AACrD,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAEvD,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAwB,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AAQnH,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACvI,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW,EAAE,IAAY;IACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACjC,OAAO,IAAI,KA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AAM,EAAE,CAAC,CAAC;YAChD,SAAS;QACX,CAAC;QACD,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,qDAAqD,CAAC,CAAC;QACvG,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type ArchitectureMap, type Category, type Grade, type Issue, type ResolutionEntry, type RunError } from '@unsloplabs/engine';
|
|
2
|
+
import { type Analysis, type AnalyzeInput } from './analyze.js';
|
|
3
|
+
import { type Quote } from '@unsloplabs/pricing';
|
|
4
|
+
export declare const REPORT_SCHEMA_VERSION = 1;
|
|
5
|
+
export declare const TOP_ISSUE_COUNT = 5;
|
|
6
|
+
export interface ReportPlatform {
|
|
7
|
+
/** Adapter or waitlist platform id; null when the repo's origin is not recognised. */
|
|
8
|
+
id: string | null;
|
|
9
|
+
displayName: string;
|
|
10
|
+
/** False when there is no adapter for this repo yet: the report still runs, the unslop does not. */
|
|
11
|
+
supported: boolean;
|
|
12
|
+
/** Platform whose waitlist the owner should join, when unsupported. */
|
|
13
|
+
waitlist: string | null;
|
|
14
|
+
confidence: number;
|
|
15
|
+
markers: string[];
|
|
16
|
+
/** The supported stack the repo is on, or (when unsupported) the stacks that are, for the message. */
|
|
17
|
+
stack: string | null;
|
|
18
|
+
/** Id of the matched stack; null when the repo is not on a supported one. */
|
|
19
|
+
stackId: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface MaintenanceArea {
|
|
22
|
+
id: 'modular' | 'repetition' | 'safety-net' | 'scales';
|
|
23
|
+
label: string;
|
|
24
|
+
/** What the area asks of the code, in a few words. */
|
|
25
|
+
asks: string;
|
|
26
|
+
score: number;
|
|
27
|
+
/** Rules that fired in this area. */
|
|
28
|
+
issues: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ReportManagedService {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
/** Files where the dependency shows up. */
|
|
34
|
+
evidence: string[];
|
|
35
|
+
}
|
|
36
|
+
/** The free Slop Report: one score, the top five issues, and the map behind them. */
|
|
37
|
+
export interface SlopReport {
|
|
38
|
+
schemaVersion: typeof REPORT_SCHEMA_VERSION;
|
|
39
|
+
generatedAt: string;
|
|
40
|
+
repo: {
|
|
41
|
+
name: string | null;
|
|
42
|
+
files: number;
|
|
43
|
+
sourceFiles: number;
|
|
44
|
+
linesOfCode: number;
|
|
45
|
+
};
|
|
46
|
+
platform: ReportPlatform;
|
|
47
|
+
/** 0–100, higher is healthier. Every finding counts toward it. */
|
|
48
|
+
score: number;
|
|
49
|
+
grade: Grade;
|
|
50
|
+
/**
|
|
51
|
+
* The two questions an owner asks. Security: is anything exposed; the health score's formula
|
|
52
|
+
* over security findings alone, so one critical finding sinks it. Maintenance: can this code
|
|
53
|
+
* keep being changed; the share of the maintenance checks the code passes, weighted by
|
|
54
|
+
* severity, overall and for each of the four areas it is made of.
|
|
55
|
+
*/
|
|
56
|
+
scores: {
|
|
57
|
+
security: number;
|
|
58
|
+
maintenance: number;
|
|
59
|
+
areas: MaintenanceArea[];
|
|
60
|
+
};
|
|
61
|
+
topIssues: Issue[];
|
|
62
|
+
/** Every issue, worst first; `topIssues` is its head. */
|
|
63
|
+
issues: Issue[];
|
|
64
|
+
findingCounts: Record<Category, number>;
|
|
65
|
+
architecture: ArchitectureMap;
|
|
66
|
+
tests: {
|
|
67
|
+
unitTestFiles: number;
|
|
68
|
+
endToEndSpecs: number;
|
|
69
|
+
sourceFiles: number;
|
|
70
|
+
};
|
|
71
|
+
/** Screens the app declares in its router, by path: what behaviour-locking will cover first. */
|
|
72
|
+
screens: string[];
|
|
73
|
+
/** Platform-hosted services this repo depends on that do not export as standalone code. */
|
|
74
|
+
managedServices: ReportManagedService[];
|
|
75
|
+
quote: Quote;
|
|
76
|
+
/**
|
|
77
|
+
* False when the repo is missing parts of the app (`base/app-is-whole`): it cannot be built as
|
|
78
|
+
* it stands, so there is nothing to rebuild and nothing to sell until the whole project is in it.
|
|
79
|
+
*/
|
|
80
|
+
rebuildable: boolean;
|
|
81
|
+
fixPlan: {
|
|
82
|
+
byCodemod: number;
|
|
83
|
+
byAgent: number;
|
|
84
|
+
};
|
|
85
|
+
rules: {
|
|
86
|
+
packs: {
|
|
87
|
+
name: string;
|
|
88
|
+
version: string;
|
|
89
|
+
layer: string;
|
|
90
|
+
}[];
|
|
91
|
+
active: number;
|
|
92
|
+
/** Rules tuned or disabled by a later layer, with the recorded reason. */
|
|
93
|
+
exceptions: ResolutionEntry[];
|
|
94
|
+
};
|
|
95
|
+
/** Rules that could not run. Empty in a healthy scan. */
|
|
96
|
+
errors: RunError[];
|
|
97
|
+
}
|
|
98
|
+
export interface ReportOptions {
|
|
99
|
+
repoName?: string;
|
|
100
|
+
/** Injected clock, so reports are reproducible in tests. */
|
|
101
|
+
now?: Date;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The URL a TanStack file route serves, or undefined for files that are not a screen: the root
|
|
105
|
+
* layout, server routes, router-ignored files and platform internals with escaped names.
|
|
106
|
+
*/
|
|
107
|
+
export declare function screenFromRouteFile(file: string): string | undefined;
|
|
108
|
+
export declare function buildReport(analysis: Analysis, options?: ReportOptions): SlopReport;
|
|
109
|
+
/** Scans a repo snapshot and returns its Slop Report. Pure apart from the clock. */
|
|
110
|
+
export declare function createSlopReport(input: AnalyzeInput, options?: ReportOptions): SlopReport;
|
package/dist/report.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { buildArchitectureMap, CATEGORIES, computeScore, createMatcher, evaluateCondition, gradeFor, isSourceFile, isTestFile, planFixes, scoreFor, shareFor, summarizeIssues, } from '@unsloplabs/engine';
|
|
2
|
+
import { analyzeRepo } from './analyze.js';
|
|
3
|
+
import { quoteFor } from '@unsloplabs/pricing';
|
|
4
|
+
export const REPORT_SCHEMA_VERSION = 1;
|
|
5
|
+
export const TOP_ISSUE_COUNT = 5;
|
|
6
|
+
/** What makes code hard to keep changing, and which finding categories speak to each. */
|
|
7
|
+
const MAINTENANCE_AREAS = [
|
|
8
|
+
{ id: 'modular', label: 'Modular', asks: 'Clear parts with enforced edges', categories: ['architecture'] },
|
|
9
|
+
{ id: 'repetition', label: 'No repetition', asks: 'One home for each piece of logic', categories: ['duplication', 'dead-code'] },
|
|
10
|
+
{ id: 'safety-net', label: 'Safety net', asks: 'Types and tests that catch a break', categories: ['types', 'tests', 'reliability'] },
|
|
11
|
+
{ id: 'scales', label: 'Scales', asks: 'Work that does not grow with every row and page', categories: ['performance'] },
|
|
12
|
+
];
|
|
13
|
+
const E2E_SPEC = createMatcher(['**/e2e/**/*.{ts,tsx,js,jsx}', '**/*.e2e.{ts,tsx,js,jsx}', '**/cypress/e2e/**', '**/*.feature']);
|
|
14
|
+
const UNIT_TEST = createMatcher(['**/*.test.{ts,tsx,js,jsx,mts}', '**/__tests__/**/*.{ts,tsx,js,jsx}']);
|
|
15
|
+
function describePlatform(analysis) {
|
|
16
|
+
const { detection } = analysis;
|
|
17
|
+
if (detection.status === 'unknown') {
|
|
18
|
+
return { id: null, displayName: 'Unrecognised', supported: false, waitlist: null, confidence: 0, markers: [], stack: null, stackId: null };
|
|
19
|
+
}
|
|
20
|
+
const supported = detection.status === 'supported';
|
|
21
|
+
return {
|
|
22
|
+
id: detection.platform.id,
|
|
23
|
+
displayName: detection.platform.displayName,
|
|
24
|
+
supported,
|
|
25
|
+
waitlist: supported ? null : detection.platform.id,
|
|
26
|
+
confidence: detection.match.confidence,
|
|
27
|
+
markers: detection.match.markers,
|
|
28
|
+
stack: detection.status === 'supported'
|
|
29
|
+
? detection.stack.description
|
|
30
|
+
: detection.status === 'unsupported-stack'
|
|
31
|
+
? detection.platform.stacks.map((stack) => stack.description).join('; or ')
|
|
32
|
+
: null,
|
|
33
|
+
stackId: detection.status === 'supported' ? detection.stack.id : null,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The platform's hosted services this repo shows signs of using, with the files that rule findings point at. */
|
|
37
|
+
function managedServices(analysis) {
|
|
38
|
+
const { detection } = analysis;
|
|
39
|
+
if (detection.status !== 'supported')
|
|
40
|
+
return [];
|
|
41
|
+
const files = new Map();
|
|
42
|
+
for (const finding of analysis.result.findings) {
|
|
43
|
+
const service = finding.data?.['service'];
|
|
44
|
+
if (typeof service !== 'string' || finding.file === undefined)
|
|
45
|
+
continue;
|
|
46
|
+
files.set(service, (files.get(service) ?? new Set()).add(finding.file));
|
|
47
|
+
}
|
|
48
|
+
const context = { snapshot: analysis.snapshot, fingerprint: analysis.fingerprint, platform: detection.platform.id };
|
|
49
|
+
return detection.platform.managedServices
|
|
50
|
+
.filter((service) => files.has(service.name) || (service.evidence !== undefined && evaluateCondition(service.evidence, context)))
|
|
51
|
+
.map((service) => ({ name: service.name, description: service.description, evidence: [...(files.get(service.name) ?? [])].sort() }));
|
|
52
|
+
}
|
|
53
|
+
const ROUTE_PATH = /<Route\b[^>]*?\bpath=(?:"([^"]+)"|'([^']+)'|\{\s*["']([^"']+)["']\s*\})/g;
|
|
54
|
+
const MAX_SCREENS = 40;
|
|
55
|
+
const ROUTE_FILE = /(?:^|\/)src\/routes\/(.+)\.[jt]sx$/;
|
|
56
|
+
/**
|
|
57
|
+
* The URL a TanStack file route serves, or undefined for files that are not a screen: the root
|
|
58
|
+
* layout, server routes, router-ignored files and platform internals with escaped names.
|
|
59
|
+
*/
|
|
60
|
+
export function screenFromRouteFile(file) {
|
|
61
|
+
const relative = ROUTE_FILE.exec(file)?.[1];
|
|
62
|
+
if (relative === undefined || relative.includes('['))
|
|
63
|
+
return undefined;
|
|
64
|
+
const parts = [];
|
|
65
|
+
for (const raw of relative.split(/[/.]/)) {
|
|
66
|
+
if (raw === '__root' || raw === 'api' || raw.startsWith('-'))
|
|
67
|
+
return undefined;
|
|
68
|
+
// Index and layout files add nothing to the path; nor do pathless (_name) and grouping ((name)) segments.
|
|
69
|
+
if (raw === '' || raw === 'index' || raw === 'route' || raw.startsWith('_') || raw.startsWith('('))
|
|
70
|
+
continue;
|
|
71
|
+
const name = raw.replace(/_$/, '');
|
|
72
|
+
parts.push(name === '$' ? '*' : name.startsWith('$') ? `:${name.slice(1)}` : name);
|
|
73
|
+
}
|
|
74
|
+
return `/${parts.join('/')}`;
|
|
75
|
+
}
|
|
76
|
+
/** Paths of the app's screens: react-router routes in the order declared, then file-based routes. */
|
|
77
|
+
function findScreens(analysis) {
|
|
78
|
+
const screens = new Set();
|
|
79
|
+
for (const file of analysis.snapshot.files) {
|
|
80
|
+
if (!/\.(tsx|jsx)$/.test(file) || isTestFile(file))
|
|
81
|
+
continue;
|
|
82
|
+
const source = analysis.snapshot.read(file);
|
|
83
|
+
if (source === undefined || !source.includes('<Route'))
|
|
84
|
+
continue;
|
|
85
|
+
for (const match of source.matchAll(ROUTE_PATH)) {
|
|
86
|
+
const path = match[1] ?? match[2] ?? match[3] ?? '';
|
|
87
|
+
if (path === '*' || path === '')
|
|
88
|
+
continue;
|
|
89
|
+
screens.add(path.startsWith('/') ? path : `/${path}`);
|
|
90
|
+
if (screens.size >= MAX_SCREENS)
|
|
91
|
+
return [...screens];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const fileRoutes = analysis.snapshot.files.map(screenFromRouteFile).filter((screen) => screen !== undefined);
|
|
95
|
+
for (const screen of [...new Set(fileRoutes)].sort()) {
|
|
96
|
+
if (screens.size >= MAX_SCREENS)
|
|
97
|
+
break;
|
|
98
|
+
screens.add(screen);
|
|
99
|
+
}
|
|
100
|
+
return [...screens];
|
|
101
|
+
}
|
|
102
|
+
function countLines(analysis, files) {
|
|
103
|
+
let lines = 0;
|
|
104
|
+
for (const file of files) {
|
|
105
|
+
for (const line of (analysis.snapshot.read(file) ?? '').split('\n'))
|
|
106
|
+
if (line.trim() !== '')
|
|
107
|
+
lines++;
|
|
108
|
+
}
|
|
109
|
+
return lines;
|
|
110
|
+
}
|
|
111
|
+
export function buildReport(analysis, options = {}) {
|
|
112
|
+
const { snapshot, ruleSet, result, session } = analysis;
|
|
113
|
+
const issues = summarizeIssues(result.findings, ruleSet);
|
|
114
|
+
const score = computeScore(issues);
|
|
115
|
+
const sourceFiles = snapshot.files.filter((file) => isSourceFile(file) && !isTestFile(file));
|
|
116
|
+
const findingCounts = Object.fromEntries(CATEGORIES.map((category) => [category, 0]));
|
|
117
|
+
for (const finding of result.findings)
|
|
118
|
+
findingCounts[finding.category]++;
|
|
119
|
+
const plan = planFixes(ruleSet, result.findings);
|
|
120
|
+
return {
|
|
121
|
+
schemaVersion: REPORT_SCHEMA_VERSION,
|
|
122
|
+
generatedAt: (options.now ?? new Date()).toISOString(),
|
|
123
|
+
repo: {
|
|
124
|
+
name: options.repoName ?? null,
|
|
125
|
+
files: snapshot.files.length,
|
|
126
|
+
sourceFiles: sourceFiles.length,
|
|
127
|
+
linesOfCode: countLines(analysis, sourceFiles),
|
|
128
|
+
},
|
|
129
|
+
platform: describePlatform(analysis),
|
|
130
|
+
score,
|
|
131
|
+
grade: gradeFor(score, issues),
|
|
132
|
+
scores: {
|
|
133
|
+
security: scoreFor(issues, ['security']),
|
|
134
|
+
maintenance: shareFor(issues, ruleSet, MAINTENANCE_AREAS.flatMap((area) => area.categories)),
|
|
135
|
+
areas: MAINTENANCE_AREAS.map(({ categories, ...area }) => ({
|
|
136
|
+
...area,
|
|
137
|
+
score: shareFor(issues, ruleSet, categories),
|
|
138
|
+
issues: issues.filter((issue) => categories.includes(issue.category)).length,
|
|
139
|
+
})),
|
|
140
|
+
},
|
|
141
|
+
topIssues: issues.slice(0, TOP_ISSUE_COUNT),
|
|
142
|
+
issues,
|
|
143
|
+
findingCounts,
|
|
144
|
+
architecture: buildArchitectureMap(session.imports(), session.architecture),
|
|
145
|
+
tests: {
|
|
146
|
+
unitTestFiles: snapshot.files.filter(UNIT_TEST).length,
|
|
147
|
+
endToEndSpecs: snapshot.files.filter(E2E_SPEC).length,
|
|
148
|
+
sourceFiles: sourceFiles.length,
|
|
149
|
+
},
|
|
150
|
+
screens: findScreens(analysis),
|
|
151
|
+
managedServices: managedServices(analysis),
|
|
152
|
+
quote: quoteFor(sourceFiles.length),
|
|
153
|
+
rebuildable: !issues.some((issue) => issue.ruleId === 'base/app-is-whole'),
|
|
154
|
+
fixPlan: {
|
|
155
|
+
byCodemod: plan.codemods.reduce((sum, codemod) => sum + codemod.findings, 0),
|
|
156
|
+
byAgent: plan.agentTasks.reduce((sum, task) => sum + task.findings.length, 0),
|
|
157
|
+
},
|
|
158
|
+
rules: {
|
|
159
|
+
packs: ruleSet.packs.map((pack) => ({ ...pack })),
|
|
160
|
+
active: ruleSet.rules.length,
|
|
161
|
+
exceptions: ruleSet.log.filter((entry) => entry.outcome === 'tuned' || entry.outcome === 'disabled'),
|
|
162
|
+
},
|
|
163
|
+
errors: result.errors,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Scans a repo snapshot and returns its Slop Report. Pure apart from the clock. */
|
|
167
|
+
export function createSlopReport(input, options = {}) {
|
|
168
|
+
return buildReport(analyzeRepo(input), options);
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,eAAe,GAOhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAoC,MAAM,cAAc,CA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
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unsloplabs/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "`unslop scan`, `unslop check`, `unslop guidance`, and the Slop Report builder the hosted service reuses",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
|
+
"homepage": "https://unslop.software",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"@unslop/source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"LICENSE.md"
|
|
18
|
+
],
|
|
19
|
+
"nx": {
|
|
20
|
+
"tags": [
|
|
21
|
+
"scope:public",
|
|
22
|
+
"type:app"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"unslop": "./dist/bin.js"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@unsloplabs/engine": "0.1.0",
|
|
30
|
+
"@unsloplabs/rules-react": "0.1.0",
|
|
31
|
+
"@unsloplabs/platforms": "0.1.0",
|
|
32
|
+
"@unsloplabs/rules-lovable": "0.1.0",
|
|
33
|
+
"@unsloplabs/pricing": "0.1.0",
|
|
34
|
+
"@unsloplabs/rules-base": "0.1.0",
|
|
35
|
+
"@unsloplabs/rules-stripe": "0.1.0",
|
|
36
|
+
"@unsloplabs/rules-supabase": "0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"author": "Unslop Labs",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.build.json",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"lint": "eslint .",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
}
|
|
6
48
|
}
|