RepoFlow Lite

v0.2.0
io.github.LolPanda2004/repoflow Checked 6 hours ago Published 2 days ago

Learn an open-source Python repo before you contribute: map, rules, safe tests, teaching cards.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

analyze_repo

Map a public Python GitHub repo. CALL THIS FIRST for any new repo. Clones the repo if needed (full history, so later blame/bisect work), then returns a RepoMap: lines per language, top-level packages, entry points (console scripts, __main__.py), test framework and the exact suggested test command, the 25 largest non-test modules with their intra-repo imports (parsed with ast), a README excerpt, and notes such as "no tests found" or "uses C extensions". Results are cached per HEAD commit; pass refresh=True to rebuild. Args: repo: "owner/name" or a github.co…

ParameterTypeDescription
repo *string
refreshboolean

find_hotspots

Rank files where bugs most likely hide: change frequency (churn) x code complexity. Use after analyze_repo to decide where to look for bugs or what to read first. Churn = number of commits touching the file in the window (`git log --numstat`); complexity = approximate McCabe cyclomatic complexity per function via ast. Research basis: relative code churn predicts defect density (Nagappan & Ball, ICSE 2005), and churn combined with complexity pinpoints defect-prone "hotspots" (Tornhill, "Your Code as a Crime Scene", 2015). Test files are excluded. Returns per file:…

ParameterTypeDescription
repo *string
sincestring
topinteger

get_architecture

Summarize the repo's internal module dependency structure from static imports. Use to explain how the code fits together, or to judge the blast radius of a change. Returns core modules (most imported by other internal modules), leaf modules (imported but import nothing internal), the most dependent modules (most internal imports), a count of isolated modules, and import cycles (groups of modules that import each other, often a design smell). Test modules are excluded; dynamic imports are not seen. Args: repo: "owner/name" or a github.com URL.

ParameterTypeDescription
repo *string

setup_environment

Create the repo's isolated Python environment and install the repo plus its test deps. Call this once per repo before run_tests, run_static_analysis or detect_flaky_tests. `extras` is a comma-separated list of pip extras (e.g. "test" or "test,dev"); "" installs none. Returns {ok, output (trimmed), next_steps}.

ParameterTypeDescription
repo *string
extrasstring

run_tests

Run the repo's pytest suite (or one `target`: a file, dir or node id) in its environment. Use this to find real, reproducible test failures. Returns counts, the exact command and commit (ready to use as Evidence), and up to `max_failures` failures. Each failure has the message, a trimmed traceback, and `location`: the deepest traceback frame inside the repo that is NOT a test file, i.e. where the bug most likely lives (null if only test code ran). Requires setup_environment first. Check failures with detect_flaky_tests before reporting.

ParameterTypeDescription
repo *string
max_failuresinteger
target
timeout_s

run_static_analysis

Run static analyzers (pyflakes, mypy --ignore-missing-imports) over the repo's code. Use this to find likely bugs without running tests: undefined names, redefinitions, type errors. `tools` is comma-separated ("pyflakes", "mypy" or both). `paths` is comma-separated repo-relative paths (default: top-level source dirs). Noise such as unused imports/variables and mypy notes is dropped unless include_style=True. Missing analyzers are pip-installed into the repo env. Returns {issues: [{file, line, code, message, tool}], counts_by_code, commands, commit, truncated}. Static i…

ParameterTypeDescription
repo *string
include_styleboolean
max_resultsinteger
paths
toolsstring

detect_flaky_tests

Re-run specific tests `runs` times to tell real bugs from flaky tests. ALWAYS use this before reporting any test failure as a bug. Pass node ids from run_tests (e.g. "tests/test_x.py::test_y"); at most 10 ids, runs clamped to 2..20. Each test runs in its own pytest process (so one bad id cannot spoil the others) and is classified as consistently_failing, flaky, passing or not_run, with pass/fail counts per run.

ParameterTypeDescription
repo *string
test_ids *array
runsinteger
timeout_s

record_finding

Save a bug to the local evidence ledger (no GitHub calls). Use after you have reproduced a bug. Never record without a reproducing command: pass evidence_command (the exact command you ran) and evidence_output (its output). If you could not reproduce it, confidence MUST be "low". source: test | static | fuzz | flaky | manual. severity: low | medium | high | critical. file is repo-relative and must be given with line (1-based). The evidence is stamped with the repo HEAD commit and UTC time. Returns the stored finding, including its id (e.g. "F-001").

ParameterTypeDescription
repo *string
source *string
title *string
confidencestring
evidence_command
evidence_exit_code
evidence_outputstring
file
function
introduced_in
line
reprostring
severitystring
test_id
whatstring
whystring

update_finding

Change a recorded finding; only the fields you pass are changed. Use it to fill the teaching fields (why, fix_options, lesson), set status (candidate | confirmed | rejected | reported | fixed), add issue_url / pr_url, or append new evidence (evidence_command + evidence_output). fix_options replaces the list; each item is {"title", "description", "tradeoff", "recommended": bool} and at most one is recommended. Returns the updated finding.

ParameterTypeDescription
finding_id *string
repo *string
confidence
evidence_command
evidence_exit_code
evidence_outputstring
file
fix_options
function
introduced_in
issue_url
lesson
line
pr_url
repro
severity
status
test_id
title
what
why

list_findings

List recorded findings for a repo as compact rows (id, title, severity, confidence, status, location, evidence_count, needs_teaching). Filter with status. Use get_finding for full detail.

ParameterTypeDescription
repo *string
status

get_finding

Return one finding in full, including every evidence entry.

ParameterTypeDescription
finding_id *string
repo *string

explain_finding

Render the teaching card for a finding as markdown: where (file:line, function, introducing commit), the code with the bad line marked >>, what, why, repro, fix options with trade-offs, lesson and evidence. level: "junior" (adds key concepts) or "senior" (terse). If why / fix_options / lesson are missing, the card ends with a "TODO for Claude" section: fill those via update_finding, then call this again. Show the card to the user as-is.

ParameterTypeDescription
finding_id *string
repo *string
levelstring

export_report

Write a markdown audit report (summary table + every teaching card) for all findings. Default location is the repo's RepoFlow artifact dir; a custom path must be inside the workspace and end in .md. Returns the file path and finding count.

ParameterTypeDescription
repo *string
path

sandbox_status

Report how RepoFlow runs code from target repos: the sandbox mode (docker / local / off), whether Docker is available, the Docker image, and safety warnings. Call this before running tests on an unfamiliar repo, or when a run fails with a sandbox error.

get_contribution_playbook

START HERE before contributing to a repo (Layer 0). Returns the repo's contribution rules, read from the local clone at the default branch: CONTRIBUTING, code of conduct, SECURITY policy (security bugs are always reported privately, never as public issues/PRs), PR and issue templates (with required fields), governance/CODEOWNERS, CLA, DCO sign-off, commit message convention, changelog/news-fragment rules, dev setup and test commands, pre-commit hooks, CI workflows, whether an issue must come before a PR, the AI policy, and (with a GitHub token) maintainer activity stats…

ParameterTypeDescription
repo *string
refreshboolean

check_ai_policy

Classify the repo's stance on AI-assisted contributions: banned | disclosure_required | allowed | unknown, with quotes and their source files (CONTRIBUTING, AI_POLICY*, .github/*, README, CODE_OF_CONDUCT). Conservative: ambiguous banning language counts as banned. If banned, do NOT prepare a PR: tell the user and stop. finding_id is optional and checks that the finding exists; Lite does not record the result.

ParameterTypeDescription
repo *string
finding_id

get_contribution_steps

Ordered, repo-specific checklist for a contribution, derived from the playbook. kind: bugfix | docs | feature. Covers: private security reporting, AI policy, reading CONTRIBUTING, duplicate search, issue-first, CLA, branch, dev setup, failing test first, full test run, pre-commit, commit style, DCO sign-off, changelog fragment, PR template, check_pr_readiness, explaining the fix in your own words, then a draft PR you open yourself. Each step names its source and, where one fits, the RepoFlow tool to use (tool is null for manual steps). Walk the user through it in order.

ParameterTypeDescription
repo *string
kindstring

check_pr_readiness

Run the pre-PR checklist on the current branch of the local clone: not on the default branch, commits exist, tests added/changed, DCO sign-off on every branch commit (if required), changelog fragment (if required), PR template sections present in pr_body (required when the repo has a template), issue-first satisfied (finding.issue_url) when required, finding not a security bug (those go private), AI policy not banned. Re-run after any code change. Returns passed, checks[{name, ok, detail}] and next. Lite does not record the result.

ParameterTypeDescription
finding_id *string
repo *string
pr_body