xpd enhance discover
Run xpd enhance discover to find the names, strings and modules that one text search does not find, and gate each rename in a recorded run.
| Group | Finding kinds |
|---|---|
| Names that one search does not find | name-collision, generic-verb-name, vague-module-name, module-private-name, import-alias, wildcard-import |
| Strings and dead ends that a search misses | interpolated-key, hasattr-probe, error-message-prefix, deprecated-without-decorator |
| Types that let a caller swap arguments | id-without-newtype |
A name-collision finding means two or more modules define the same public name. The survey counts Python public names, Go exported package declarations, and Rust public items separately. JavaScript and TypeScript exports share a count. It leaves out test files, Python __init__.py and Hamilton modules, main, and names that start with an underscore. The other kinds come from the Python rules of the same name. The header counts how many public names one module alone defines, and a rename that makes a name collide adds a finding that fails the gate.
Each module with a finding gets six checklist items. Run xpd enhance discover --questions to read the questions and the facts that inform them.
xpd enhance discover [OPTIONS] [PATHS]... xpd enhance discover <COMMAND>Subcommands
Section titled “Subcommands”| Subcommand | What it does |
|---|---|
xpd enhance discover start |
Start a run: record the commit it starts from, the paths, line count, checks and optional benchmark of the project |
xpd enhance discover plan |
Record the plan of a round: the fixes in order, and the findings that are right as they are |
xpd enhance discover approve |
Record that the user said yes to a fix that changes what callers or users see |
xpd enhance discover gate |
Gate a fix that is committed: run the checks, time --bench when set, count lines and compare the findings with the commit before it. Exit 1 when the fix is not kept |
xpd enhance discover drop |
Record that a fix was given up, after its files were restored |
xpd enhance discover status |
Print the run and the stage that comes next |
xpd enhance discover finish |
End the run: compare findings, line count and benchmark timing with the start commit. Exit 1 while a fix is open or a new finding has no reason |
Arguments
Section titled “Arguments”| Argument | What it does |
|---|---|
<PATHS>... |
Files or directories (directories respect .gitignore) |
Options
Section titled “Options”| Option | Default | What it does |
|---|---|---|
--kind <KIND> |
List only the findings of these kinds, separated by commas. Repeatable. Values: name-collision (Two or more modules define the same public name), generic-verb-name, vague-module-name, module-private-name, import-alias, wildcard-import, interpolated-key, hasattr-probe, error-message-prefix, deprecated-without-decorator, id-without-newtype. |
|
--limit <LIMIT> |
20 |
The most findings to list of each kind, strongest first. 0 lists every finding. |
--since <COMMIT> |
Count the findings at this commit too, and print each count beside the count of today. | |
--group-by <GROUP_BY> |
none |
Group findings and checklist items by owning module or shared cause. Values: none (Keep the default flat per-kind listing), module (Group findings and checklist items by owning module path), cause (Group related findings by shared kind and anchor files). |
--packet <N> |
Emit one 1-indexed deterministic context-budgeted review packet for the Nth cluster. | |
--budget-lines <LINES> |
300 |
Maximum source lines included across excerpts inside a --packet view. |
--all-modules |
Include checklist review items for every surveyed module, not only modules with findings. | |
--format <FORMAT> |
Output format. Default: text on a terminal, json otherwise. Values: text, json. |
|
--questions |
Recorded run
Section titled “Recorded run”- Start: record the current commit, paths, and project checks from a clean tracked tree with
xpd enhance discover start titles.py notes.py --check "your-project-check". - List: read stable finding IDs and checklist item IDs with
xpd enhance discover . --format json. - Plan: record ordered fixes, accepted findings, and checklist verdicts (
pass,na, oraccepted) with reasons usingxpd enhance discover plan plan.json. Setchanges_interfaceon a rename that other modules import. - Approve: record approval for an interface change with
xpd enhance discover approve fix-id. - Gate: commit one fix and run
xpd enhance discover gate fix-id. - Drop: return to the run's current commit and record a reason with
xpd enhance discover drop fix-id --reason "reason". - Status: show the current run, its recorded answers, and the next stage with
xpd enhance discover status. - Finish: compare against the starting commit with
xpd enhance discover finish. An open fix, a new finding without an accepted reason, or an unanswered checklist item causes exit 1.
Example
Section titled “Example”Two modules define clean, so a search for it finds two definitions, and neither name says what it cleans.
def clean(text): return text.strip()def clean(text): return " ".join(text.split())$ git init -q && git add titles.py notes.py && git -c user.name=xpd -c user.email=xpd@example.com -c commit.gpgsign=false commit -qm start$ xpd enhance discover start titles.py notes.py --check "python3 -m py_compile titles.py notes.py" --format json | jq -c '{findings: .run.was, next: .next.stage}'{"findings":3,"next":"plan"}$ xpd enhance discover titles.py notes.py --format json | jq -c '{names: .read, kinds: [.findings[].kind]}'{"names":{"files":2,"public_names":1,"defined_once":0},"kinds":["name-collision","generic-verb-name","generic-verb-name"]}$ xpd enhance discover titles.py notes.py --format json | jq -c '{fixes: [{id: "rename-clean", title: "Name each clean after what it cleans", findings: [.findings[].id], changes_interface: true}]}' | xpd enhance discover plan - --format json | jq -c .next.stage"ask"$ xpd enhance discover approve rename-clean --format json | jq -c .next.stage"fix"$ sed -i 's/^def clean(/def clean_title(/' titles.py && sed -i 's/^def clean(/def clean_note(/' notes.py && git -c user.name=xpd -c user.email=xpd@example.com -c commit.gpgsign=false commit -qam "Name each clean after what it cleans"$ xpd enhance discover gate rename-clean --format json | jq -c '.run.rounds[0][0] | {outcome, fixed: (.fixed | length)}'{"outcome":"kept","fixed":3}$ xpd enhance discover titles.py notes.py --format json | jq -c .read{"files":2,"public_names":2,"defined_once":2}$ xpd enhance discover finish --format json | jq -c .run.finishedxpd: 3 findings at the start, 0 now: 3 fixed, 0 added, 0 accepted, 0 left without a reason; lines 4 -> 4trueExit status
Section titled “Exit status”A successful list or recorded stage exits 0. A rejected gate or a finish blocked by findings or checklist items exits 1. Invalid input exits 2.