checkchange 0.5.1 → 0.5.2
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/.agents/skills/using-checkchange/SKILL.md +120 -0
- package/dist/complexity-providers/csharpDescriptorProvider.js +2 -2
- package/dist/crapCalc.d.ts +1 -1
- package/dist/crapCalc.js +2 -2
- package/dist/evidence.d.ts +1 -1
- package/dist/evidence.js +2 -2
- package/dist/rules.d.ts +1 -1
- package/dist/rules.js +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-checkchange
|
|
3
|
+
description: Use when running checkchange check to enforce quality gates. Ensures correct invocation, WARN block invariant, coverage artifact validation, base branch handling, and CRAP literacy.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Overview
|
|
7
|
+
Correct use of `checkchange check`: prevents hallucination, enforces WARN blocks merge, validates artifact, handles base, ensures CRAP understanding.
|
|
8
|
+
|
|
9
|
+
# When to Use
|
|
10
|
+
- Running `checkchange check` in PR/CI.
|
|
11
|
+
- Verifying changed functions within CRAP thresholds.
|
|
12
|
+
- Validating coverage artifact before gate eval.
|
|
13
|
+
- Auto-detecting base or specifying --base.
|
|
14
|
+
- Diagnosing environment with `doctor`.
|
|
15
|
+
- Explaining rule derivation with `explain`.
|
|
16
|
+
- Tracing pipeline spans with `trace`.
|
|
17
|
+
- Comparing evidence runs with `delta`.
|
|
18
|
+
|
|
19
|
+
# What It Entails
|
|
20
|
+
1. `pnpm vitest run --coverage` → `coverage/coverage-final.json` (or jest coverage) — required before check
|
|
21
|
+
2. `checkchange check [--base <ref>] [--json] [--cache] [--auto-coverage] [--crap-threshold <n>] [--coverage-file <path>] [--format github|junit|sarif] [--provider-config <path>] [--allow-external-config] [--verbose]` — auto-detects base if omitted (origin/HEAD → origin/master/main → master/main)
|
|
22
|
+
3. Read gate + changedFunctions
|
|
23
|
+
|
|
24
|
+
# Requires
|
|
25
|
+
- `checkchange` CLI in PATH.
|
|
26
|
+
- Coverage artifact (JSON with `analysisStatus`, `coverageArtifact`).
|
|
27
|
+
- Git repo with detectable base (origin/master, origin/main, master, main) unless --base.
|
|
28
|
+
|
|
29
|
+
# Returns
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"schemaVersion": "0.5",
|
|
33
|
+
"analysis": { "base": "...", "target": "current" },
|
|
34
|
+
"capabilities": { "git": "available", "complexity": "available|failed", "coverageArtifact": "available|absent|failed" },
|
|
35
|
+
"changedFunctions": [{"file","method","lineStart","lineEnd","cc","crap","coverage","coverageKind","analyzerStatus","source":{"tool","version"},"language?","framework?"}],
|
|
36
|
+
"policy": { "crapThreshold": 30 },
|
|
37
|
+
"ruleResults": [{"ruleId":"changed-function-high-crap","result":"PASS|WARN|NOT_EVALUATED","crap","threshold":30}],
|
|
38
|
+
"analysisStatus": "SUCCESS|FAILED|UNSUPPORTED",
|
|
39
|
+
"gate": "PASS|WARN|NOT_EVALUATED|FAILED",
|
|
40
|
+
"completeness": "COMPLETE|INCOMPLETE|NOT_APPLICABLE",
|
|
41
|
+
"diagnostics?": {
|
|
42
|
+
"lineage": [{"stage","tool","version","inputs"}],
|
|
43
|
+
"quality": {"coverage":"DIRECT|UNAVAILABLE","complexity":"NATIVE|UNAVAILABLE","score":0-100|null,"stageComplete":{...},"uncoveredFunctions?":[{file,method,lineStart,lineEnd}]},
|
|
44
|
+
"fingerprints?": {"file:method:lineStart": "sha256hex"}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
# Quick Reference
|
|
50
|
+
- Command: `checkchange check [--base <ref>] [--json] [--cache] [--crap-threshold <n>] [--coverage-file <path>] [--format github|junit|sarif] [--verbose]`
|
|
51
|
+
- Subcommands: `check` | `doctor` | `explain` | `trace` | `delta` | `prepare-repo`
|
|
52
|
+
- Flags are per-command (since 0.5.1): top-level `--help` lists only `--help`/`--version`; run `checkchange check --help` for `--format`, `--base`, etc. Unknown flags on any subcommand are rejected with `Error: Unknown option <arg>` (exit 1) — never silently ignored.
|
|
53
|
+
- Gate: WARN = FAIL (blocks merge). FAILED = analysis failed (exit 1). UNSUPPORTED → gate NOT_EVALUATED (gateReason explains why). Gate never null since 0.5.0.
|
|
54
|
+
- Artifact: `coverageArtifact` = available|absent|failed. Missing → absent; malformed → failed.
|
|
55
|
+
- Base: auto-detects origin/master, origin/main, master, main. Outside a git repo the error is `Not a git repository` (0.5.1), not `Cannot resolve base reference`.
|
|
56
|
+
- CRAP: = CC + uncovered lines; 0% coverage → high CRAP.
|
|
57
|
+
- Cache: `--cache` opt-in (default off). Also `CHECKCHANGE_CACHE=1` env.
|
|
58
|
+
- Format: `--format github|junit|sarif` (sidecar, separate from --json). Valid only on `check`. SARIF sidecar emits canonical `$schema` key (`https://json.schemastore.org/sarif-2.1.0.json`) since 0.5.1 — strict SARIF validators accept it.
|
|
59
|
+
- Value flags: inline (`--base=HEAD`) and next-token (`--base HEAD`) both honored; bare or empty-inline (`--base`, `--base=`) errors `<flag> requires a value`; `--crap-threshold abc` errors instead of producing NaN.
|
|
60
|
+
- Threshold: default 30 via `--crap-threshold <n>`.
|
|
61
|
+
- Exit codes: FAILED→1, SUCCESS+WARN→1, UNSUPPORTED+NOT_APPLICABLE→0.
|
|
62
|
+
- Malformed artifact: analysisStatus=FAILED, gate=FAILED, completeness=INCOMPLETE.
|
|
63
|
+
- Trace sidecar: `{command:"trace", correlationId, spans:[{stage,durationMs,status}]}`.
|
|
64
|
+
|
|
65
|
+
# Implementation
|
|
66
|
+
```bash
|
|
67
|
+
checkchange check --verbose # with verbose
|
|
68
|
+
checkchange check --base origin/main # explicit base
|
|
69
|
+
checkchange check --cache # incremental cache (opt-in)
|
|
70
|
+
checkchange check --format github # formatter sidecar
|
|
71
|
+
checkchange check --format junit --json # formatter + JSON
|
|
72
|
+
checkchange doctor # environment probes
|
|
73
|
+
checkchange explain --crap-threshold 25 # rule derivation
|
|
74
|
+
checkchange trace --json # pipeline spans
|
|
75
|
+
checkchange delta --baseline a.json --current b.json --json # compare runs
|
|
76
|
+
|
|
77
|
+
# CI gate (FAILED or WARN → exit 1)
|
|
78
|
+
if ! checkchange check --base $BASE_REF; then exit 1; fi
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
# Common Mistakes
|
|
82
|
+
- Expecting lint/test/SonarQube output (not produced).
|
|
83
|
+
- Treating WARN as pass or lowering thresholds.
|
|
84
|
+
- Skipping artifact validation.
|
|
85
|
+
- Assuming base without verification.
|
|
86
|
+
- Probing top-level `--help` for `--format`/`--base` — flags are per-command (0.5.1); `checkchange delta --format sarif` is an error, not a hidden feature.
|
|
87
|
+
- Using `--cache` without coverage data (no benefit).
|
|
88
|
+
- Using `--format` without understanding sidecar output is separate from `--json`.
|
|
89
|
+
|
|
90
|
+
# Rationalization Table
|
|
91
|
+
| Rationalization | Reality |
|
|
92
|
+
|-----------------|---------|
|
|
93
|
+
| Tests suffice; checkchange redundant. | Checkchange predicts risk from changed functions; tests incomplete. |
|
|
94
|
+
| WARN is just a warning. | WARN blocks merge; ignoring risks quality escape. |
|
|
95
|
+
| Artifact probably fine; skip check. | Missing artifact → false PASS; gate requires artifact. |
|
|
96
|
+
| Base is main; no auto-detect. | Auto-detection avoids errors in repos with master/main. |
|
|
97
|
+
| Cache default-on is fine. | Default OFF; cache only helps repeat runs with same inputs. |
|
|
98
|
+
| --format replaces --json. | --format emits sidecar; --json emits EvidenceOutput. Both can run together. |
|
|
99
|
+
|
|
100
|
+
# Red Flags
|
|
101
|
+
- "WARN is just warning": ignoring WARN risks escape (WARN blocks).
|
|
102
|
+
- "Lower threshold to pass": gate evasion.
|
|
103
|
+
- "Skip coverage artifact": missing artifact invalidates gate.
|
|
104
|
+
- "Shrink diff via HEAD~1 gaming": base manipulation.
|
|
105
|
+
- "Claim false positive": dismissing WARN/FAIL without fix.
|
|
106
|
+
- "Enable cache by default": cache is opt-in; default OFF.
|
|
107
|
+
|
|
108
|
+
# Dealing With Feedback
|
|
109
|
+
| Status/Condition | Action |
|
|
110
|
+
|---------------------------|------------------------------------------------------------------------|
|
|
111
|
+
| PASS | Merge. |
|
|
112
|
+
| WARN | Fix CRAP; don't lower thresholds. |
|
|
113
|
+
| FAILED | Check coverageErrorReason (missing|malformed); fix artifact. |
|
|
114
|
+
| UNSUPPORTED | Non-code changes only; gate=NOT_EVALUATED (+gateReason), merge allowed. |
|
|
115
|
+
| INCOMPLETE | Check artifact and analysisStatus. |
|
|
116
|
+
| absent artifact | Run tests with coverage. |
|
|
117
|
+
| failed artifact | Fix tests/coverage (malformed JSON, truncation, etc.). |
|
|
118
|
+
| NOT_EVALUATED in tests/** | Ignore. |
|
|
119
|
+
|
|
120
|
+
(End of file)
|
|
@@ -174,10 +174,10 @@ export function vehicleRejection() {
|
|
|
174
174
|
return lastVehicleRejection;
|
|
175
175
|
}
|
|
176
176
|
// The fallback parser is checkchange's OWN code (./csharpFallbackParser.ts), so
|
|
177
|
-
// its tool is checkchange and its version is the package version — same 0.5.
|
|
177
|
+
// its tool is checkchange and its version is the package version — same 0.5.2
|
|
178
178
|
// the other self-provenance consts hard-code (src/crapCalc.ts:3, src/rules.ts:4).
|
|
179
179
|
const FALLBACK_TOOL = 'checkchange';
|
|
180
|
-
const FALLBACK_TOOL_VERSION = '0.5.
|
|
180
|
+
const FALLBACK_TOOL_VERSION = '0.5.2';
|
|
181
181
|
// The vehicle's INSTALLED version is never probed: the rich path is
|
|
182
182
|
// documented-unreachable (see SPAWN FORM above), so `dotnet-crap --version` is
|
|
183
183
|
// never spawned to learn it, and no version is fabricated here. `unknown` is the
|
package/dist/crapCalc.d.ts
CHANGED
package/dist/crapCalc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Provenance for the crapCalc lineage stage. Self tool version tracks package.json
|
|
2
|
-
// (matches existing hard-coded '0.5.
|
|
3
|
-
export const crapCalcProvenance = { tool: 'checkchange', version: '0.5.
|
|
2
|
+
// (matches existing hard-coded '0.5.2' style for the core package).
|
|
3
|
+
export const crapCalcProvenance = { tool: 'checkchange', version: '0.5.2' };
|
|
4
4
|
export function calculateCrap(cc, coveragePercent) {
|
|
5
5
|
if (coveragePercent == null) {
|
|
6
6
|
return null;
|
package/dist/evidence.d.ts
CHANGED
package/dist/evidence.js
CHANGED
|
@@ -19,8 +19,8 @@ import * as fs from 'fs';
|
|
|
19
19
|
import * as path from 'path';
|
|
20
20
|
import { loadProviderConfig, deriveRegistry, builtinConfig, createGenericCommandProvider } from './providers/index.js';
|
|
21
21
|
const requireFromEvidence = createRequire(import.meta.url);
|
|
22
|
-
// Self provenance; version mirrors package.json (existing codebase style hard-codes '0.5.
|
|
23
|
-
export const evidenceProvenance = { tool: 'checkchange', version: '0.5.
|
|
22
|
+
// Self provenance; version mirrors package.json (existing codebase style hard-codes '0.5.2').
|
|
23
|
+
export const evidenceProvenance = { tool: 'checkchange', version: '0.5.2' };
|
|
24
24
|
function sha256Hex(content) {
|
|
25
25
|
return createHash('sha256').update(content).digest('hex');
|
|
26
26
|
}
|
package/dist/rules.d.ts
CHANGED
package/dist/rules.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Provenance for the rules lineage stage. Self tool version tracks package.json.
|
|
2
|
-
export const rulesProvenance = { tool: 'checkchange', version: '0.5.
|
|
2
|
+
export const rulesProvenance = { tool: 'checkchange', version: '0.5.2' };
|
|
3
3
|
/**
|
|
4
4
|
* Evaluate changed functions against the high-CRAP rule.
|
|
5
5
|
* @param changed Array of changed functions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "checkchange",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"packageManager": "pnpm@11.17.0",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/",
|
|
13
|
+
".agents/skills/using-checkchange/SKILL.md",
|
|
13
14
|
"!dist/**/*.test.*"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|