crapkit
v0.8.1Twelve tools to inspect CRAP scores, find work, and check edited functions against their ceiling.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
get_next_item Next function to fix
Returns the next function to fix as a work packet, the newest trusted run's worst row by crap. Use it to start a fix, list_worklist to survey the same run by risk, and get_function_brief once a function is chosen. It runs no tests, and empty true means the queue is spent, not the work, so read reasons. Filters cut before top counts: top 3 with exclude ["tests/"] returns the three worst rows outside tests, and an unknown scope name is a config error.
| Parameter | Type | Description |
|---|---|---|
exclude | array | skip rows whose path or long function name contains any of these fragments (one --exclude each) |
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
scope | array | restrict the ranking to these declared scopes (exact [[scope]] names from crapkit.toml, one --scope each) |
top | integer | return the next N packets as items instead of one item (N >= 1, default 1) |
list_worklist Risk ranking of every function
Lists the newest trusted run's whole risk ranking, every admitted function ordered by ccn times recency-weighted churn. Use it to survey a repo or split work, and get_next_item for the one packet to fix now. It runs no tests and keeps finished rows, so it never empties. Churn is cached per HEAD: after a commit, or on first use, the next read walks git log. git ls-files and git status count changed scored files (scored_changes). scope narrows before top caps, and an unknown scope is a config error. repo may be any directory under the measured checkout.
| Parameter | Type | Description |
|---|---|---|
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
scope | array | restrict the ranking to these declared scopes (exact [[scope]] names from crapkit.toml, one --scope each) |
top | integer | cap the active list (default: the config's worklist_top, 50) |
list_runs Scored run history
Lists every run in the store, oldest first by id. Use it to see which commit the other tools answer from, get_trend for totals and get_function_history for one function. Marking the baseline run costs one git ancestry check per trusted run's commit, newest first, down to it: one when it is the newest, on any branch, none with no trusted run. repo may be any directory under the checkout, and a relative path resolves from the server's start directory. With no crapkit.toml above it, or no snapshot store yet, it answers isError true with the command to run.
| Parameter | Type | Description |
|---|---|---|
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
get_trend Debt trend per run
Returns per-run totals for every trusted run, oldest first, with a grade per scope. Use it for the whole repo's trajectory. Use get_function_history for one function and get_ratchet_report for marked debt. It runs no lane and spawns no git. The first call on a large store sums every run into a rollup cache and takes seconds. Later calls read the cache back. repo may be any directory under a checkout where crapkit init and crapkit coverage have run. One with no snapshot store yet answers isError true with the setup pointer.
| Parameter | Type | Description |
|---|---|---|
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
get_function_brief Start-editing packet for one function
Returns one function's start-editing packet from the newest trusted run: scored row, uncovered lines and the refresh, test, gate and verify command lines, none of them run. Use it once a function is chosen. Skip it for picking what to fix, that is get_next_item, and for a score across runs, get_function_history. Twins come from the run's stored index, whose first build takes seconds. name must live in path. A miss is a tool error (isError true, the exit-1 error object) whose message lists the file's functions.
| Parameter | Type | Description |
|---|---|---|
name * | string | the long_name get_next_item printed (classify( score , late )), the bare identifier (classify, or route for a Rust `route cmd : & Cmd`), a fragment of either, the line the function starts on, or a han… |
path * | string | source file, repo-relative or absolute inside the repo; a backslash separates folders on Windows only |
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
get_function_history One function's score across runs
Returns one function's ccn, coverage, crap and flag per run, oldest first, plus its ratchet mark. Use it to tell improving from decaying or regrown, and get_function_brief to start an edit. history true spawns git log -L capped at 10 commits, and tests true is null unless the lane recorded contexts. name matches the long names any run scored in path, so a fragment returns one entry per match, and a bare twin name picks the worst twin. A same-line twin's history skips runs stored before same-line positions. repo may be any directory under the checkout.
| Parameter | Type | Description |
|---|---|---|
name * | string | the long_name get_next_item printed (classify( score , late )), the bare identifier (classify, or route for a Rust `route cmd : & Cmd`), a fragment of either, the line the function starts on, or a han… |
path * | string | source file, repo-relative or absolute inside the repo; a backslash separates folders on Windows only |
history | boolean | also list the commits that touched this function (git log -L), as commits |
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
tests | boolean | also list the tests covering this function (coverage.py contexts), as tests |
check_config Config and repo health check
Checks that crapkit.toml agrees with the repo: typo keys, empty scopes, missing lane cwds, runners that fail to start. Run it first when any tool answers strangely or the ranking misses a file, and list_runs when only the history is in question. It needs no run, probes each runner once per lane directory and environment, runs no lane, and any problem arrives with isError true. repo can be any directory under the checkout, and one with no crapkit.toml above it answers a pointer, never a parent's config.
| Parameter | Type | Description |
|---|---|---|
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
list_coupled_files Files that change together
Lists file pairs that keep landing in the same commits over the churn window, strongest first, at most 50. Use it before editing a file to learn what an edit drags along, and list_duplicate_functions for copied code. It reads a cached ranking, not the scored run, and walks git log again only when HEAD, the churn window or the clone depth moved. An empty list means no pair cleared both thresholds, not a missing run: min_support 5 needs five shared commits, and min_confidence 0.5 means the rarer file moved with its partner half the time.
| Parameter | Type | Description |
|---|---|---|
min_confidence | number | minimum P(pair changes together), 0 to 1 (default 0.5) |
min_support | integer | minimum shared commits before a pair counts (default 5) |
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
list_duplicate_functions Near-duplicate function pairs
Lists near-duplicate function pairs in the newest run, at most 50. Use it before a refactor so twins are folded together, and get_function_brief for one function's twins. It reads the run's stored index, whose first build takes seconds on a large repo, skips functions with under 8 lines of their own and nested pairs, and an empty list means no pair reached similarity. similarity is shared shingles over the smaller function: 1.0 admits only a function found whole inside another, 0.8 four lines in five, and repo may be any directory under the checkout.
| Parameter | Type | Description |
|---|---|---|
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
similarity | number | containment threshold, shared over smaller, 0 to 1 (default 0.8) |
get_ratchet_report Ratchet debt burn-down
Reports the ratchet debt burn-down: open marks with their age, repayments and policy findings. Use it to judge whether marked debt is repaid or piling up, and get_function_history for one function's mark. It reads the marks file and its git history only, and ages count from the newest commit touching that file, never the clock. Open marks are the file's rows, committed or not. A deleted or emptied file reports the marks its history last held as open, none repaid, and no file with no history reports zeros. repo may be any directory under the checkout.
| Parameter | Type | Description |
|---|---|---|
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
check_gate rescore --gate verdict for an edited file
Checks an edited file by rescore --gate's rule: each changed function's ccn against its scope's ceiling, pardoned only while its crap is at or under its ratchet mark. The hook's commit gate pardons any marked function, so this is stricter and a breach predicts a verify refusal. Call it after an edit once get_function_brief states the rule. It runs no tests, and a breach reads gate.ok false, not an error. Marks are read only on a breach, so a clean gate skips a broken marks file. A tracked file is judged on its diff from HEAD, an untracked one in full.
| Parameter | Type | Description |
|---|---|---|
path * | string | repo-relative, or absolute inside repo, source file to judge as edited. Outside the repo, missing or a directory answers a config error, and an unchanged or unscoped file judges 0. A file a scope take… |
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |
list_claims Open queue claims
Lists open claims on queue items, oldest first. Use it when get_next_item answers empty or skipped_claimed above 0, and use get_function_brief to see one function's own attempts. No tool here writes a claim: the CLI releases a stale one with crapkit claims release PATH NAME, and verify closes one at the ceiling. repo may be any directory under the checkout, since the server walks up to the nearest crapkit.toml. No crapkit.toml above it answers an init pointer, and one with no snapshot store yet a coverage pointer, both as isError true.
| Parameter | Type | Description |
|---|---|---|
repo | string | path to the scored repo's root (default: the repo the server was started in); a leading ~ is the home directory |