diff --git a/README.md b/README.md
index d292bf3..19b927a 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@ Local-first Python CLI and reusable GitHub Action for verifying Python repositor
- CI-friendly exit codes
- GitHub composite Action
- Local-first scanning
+- Modern local GUI dashboard (`codeproof gui`) for scans, findings, policy, and history
## Install
```bash
@@ -26,8 +27,9 @@ codeproof init
codeproof inventory .
codeproof generate-tests . --output tests/generated
codeproof scan . --format all --fail-under 70
+codeproof gui . --host 127.0.0.1 --port 8787
```
-Reports are stored under `.codeproof/reports/`.
+Reports are stored under `.codeproof/reports/`. The GUI runs locally and uses the same core engine/policy as the CLI. See `ROADMAP.md` for planned enhancements.
## Confidence model
The score is the weighted percentage of included checks that pass. Missing required tools fail policy. Missing optional tools are marked unavailable and excluded from the denominator. A passing report is evidence that configured checks passed, not proof of correctness.
diff --git a/ROADMAP.md b/ROADMAP.md
new file mode 100644
index 0000000..d11e23e
--- /dev/null
+++ b/ROADMAP.md
@@ -0,0 +1,42 @@
+# CodeProof-AI Roadmap
+
+## Vision
+Make CodeProof-AI the most trusted, local-first evidence platform for Python repository health—transparent scoring, actionable diagnostics, and seamless workflows from CLI to CI to interactive GUI.
+
+## Current State (v0.1.0)
+- Deterministic checks: Ruff, mypy, pytest, Bandit, Semgrep, import-smoke
+- Weighted policy engine with required-tool gates and configurable thresholds
+- AST-based symbol inventory and reviewable smoke-test generation
+- Reports: JSON, Markdown, HTML
+- Typer CLI + reusable GitHub Action
+- Local-first execution model
+
+## Near-term (v0.2.x) — Usability & Visibility
+- **Modern GUI dashboard (in progress)**: local web interface to run scans, view results, inspect findings, browse report history, and edit policy.
+- **Scan history & trends**: persist run metadata/summaries; show score trends over time per project.
+- **Richer finding details**: normalize adapter outputs (file/line/rule/severity) into structured findings across all tools.
+- **Config UX**: validate `.codeproof.yml`, expose presets (strict/balanced/fast), and document all options.
+- **Improved HTML reports**: interactive filtering, sortable tables, and deep links to evidence/raw output.
+- **Doctor enhancements**: version checks, install hints, and environment diagnostics.
+
+## Mid-term (v0.3.x–v0.4.x) — Depth & Integrations
+- **Async/background scans in GUI** with live progress and cancellation.
+- **Baseline & diff mode**: compare current scan against a baseline to highlight regressions/new findings (PR-focused).
+- **Plugin/adapter system**: stable interface for custom checks (coverage, pip-audit, vulture, complexity, license checks).
+- **Coverage integration**: parse `coverage.xml`/pytest-cov output as a first-class evidence source.
+- **Multi-language groundwork**: abstract runner/report model to support additional ecosystems (starting with JS/TS) while keeping Python best-in-class.
+- **SARIF export** and better GitHub Code Scanning/PR annotation workflows.
+- **Caching & incremental checks**: speed up repeated local scans.
+
+## Long-term (v1.0+) — Team & Trust
+- **Policy packs & provenance**: signed/shareable policy profiles; clear evidence provenance in reports.
+- **Workspace/monorepo support**: per-package policies, aggregated scoring, and targeted scans.
+- **Optional hosted/CI insights**: opt-in aggregation for teams (never default; preserve local-first core).
+- **AI-assisted, evidence-grounded explanations**: summarize findings and suggest fixes *with citations to check output* (no correctness claims).
+- **Stability guarantees**: versioned report schema, backward-compatible config migrations, and documented extension API.
+
+## Guiding Principles
+- **Evidence over claims**: reports show what ran, what passed/failed, and what was excluded.
+- **Local-first & transparent**: predictable execution, explicit limitations, user-controlled network use.
+- **Composable**: CLI, GUI, and CI share the same core engine and config.
+- **Safe by default**: clear warnings when scanning executes untrusted code; encourage isolated environments.
diff --git a/pyproject.toml b/pyproject.toml
index 51aa695..ced11d2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,5 +16,10 @@ dev=["codeproof-ai[checkers]"]
codeproof="codeproof.cli:app"
[tool.hatch.build.targets.wheel]
packages=["src/codeproof"]
+
+[tool.hatch.build.targets.wheel.force-include]
+"src/codeproof/gui" = "codeproof/gui"
+
[tool.pytest.ini_options]
testpaths=["tests"]
+
diff --git a/src/codeproof/cli.py b/src/codeproof/cli.py
index 48c7683..34f8fc4 100644
--- a/src/codeproof/cli.py
+++ b/src/codeproof/cli.py
@@ -34,4 +34,12 @@ def scan(path:Path=Path("."),format:str="all",fail_under:float|None=None,output:
console.print(t);console.print(f"Score {report.score}/100 ({report.grade}); policy {'PASS' if report.policy_passed else 'FAIL'}")
for p in write(report,root/output,format):console.print(f"Report: {p}")
raise typer.Exit(0 if report.policy_passed else 1)
+
+@app.command()
+def gui(path:Path=Path("."),host:str="127.0.0.1",port:int=8787,no_open:bool=False):
+ """Launch the local CodeProof GUI dashboard."""
+ from .web import serve
+ serve(host=host,port=port,target=path.resolve(),open_browser=not no_open)
+
if __name__=="__main__":app()
+
diff --git a/src/codeproof/gui/__init__.py b/src/codeproof/gui/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/codeproof/gui/__init__.py
@@ -0,0 +1 @@
+
diff --git a/src/codeproof/gui/app.js b/src/codeproof/gui/app.js
new file mode 100644
index 0000000..5632f6b
--- /dev/null
+++ b/src/codeproof/gui/app.js
@@ -0,0 +1,149 @@
+const state = { report: null, findings: [] };
+const $ = (s) => document.querySelector(s);
+const $$ = (s) => Array.from(document.querySelectorAll(s));
+
+function fmt(n, d = 2) { return typeof n === 'number' ? n.toFixed(d).replace(/\.00$/, '') : n; }
+function esc(s) { return String(s ?? '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); }
+
+async function api(path, opts = {}) {
+ const res = await fetch(path, { headers: { 'Content-Type': 'application/json' }, ...opts });
+ const data = await res.json().catch(() => ({}));
+ if (!res.ok) throw new Error(data.error || res.statusText);
+ return data;
+}
+
+function setView(name) {
+ $$('.view').forEach(v => v.classList.toggle('active', v.id === `view-${name}`));
+ $$('.nav-btn').forEach(b => b.classList.toggle('active', b.dataset.view === name));
+ const titles = { dashboard: 'Repository overview', findings: 'Findings', inventory: 'Inventory', policy: 'Policy & tools', history: 'Report history' };
+ $('#view-title').textContent = titles[name];
+ $('#breadcrumb').textContent = name === 'dashboard' ? 'OVERVIEW' : name.toUpperCase();
+ if (name === 'policy') { loadPolicy(); loadDoctor(); }
+ if (name === 'history') loadHistory();
+}
+
+function scoreColor(score) {
+ if (score >= 80) return 'var(--good)';
+ if (score >= 60) return 'var(--warn)';
+ return 'var(--bad)';
+}
+
+function renderReport(report) {
+ state.report = report;
+ state.findings = [];
+ (report.results || []).forEach(r => (r.findings || []).forEach(f => state.findings.push({ check: r.name, ...f })));
+ $('#project-meta').textContent = `${report.project} • ${report.target} • ${new Date(report.generated_at).toLocaleString()}`;
+ $('#score-value').textContent = fmt(report.score, 0);
+ $('#grade').textContent = `Grade ${report.grade}`;
+ const deg = Math.max(0, Math.min(100, report.score)) * 3.6;
+ $('#score-ring').style.background = `conic-gradient(${scoreColor(report.score)} ${deg}deg, rgba(255,255,255,0.06) ${deg}deg)`;
+ const badge = $('#policy-badge');
+ badge.textContent = report.policy_passed ? 'Policy PASS' : 'Policy FAIL';
+ badge.className = 'badge ' + (report.policy_passed ? 'pass' : 'fail');
+ $('#kpi-checks').textContent = (report.results || []).length;
+ const passed = (report.results || []).filter(r => r.status === 'passed').length;
+ $('#kpi-checks-sub').textContent = `${passed} passed`;
+ $('#kpi-findings').textContent = state.findings.length;
+ $('#kpi-threshold').textContent = `≥ ${fmt(report.fail_under)}`;
+ $('#kpi-generated').textContent = `CodeProof ${report.codeproof_version}`;
+ renderResults();
+ renderFindings();
+ $('#limitations').innerHTML = (report.limitations || []).map(l => `
${esc(l)} `).join('') || 'None. ';
+}
+
+function renderResults() {
+ const filter = $('#status-filter').value;
+ const rows = (state.report?.results || []).filter(r => filter === 'all' || r.status === filter);
+ $('#results-table tbody').innerHTML = rows.map(r => `
+ ${esc(r.name)}
+ ${esc(r.status)}
+ ${fmt(r.weight)}
+ ${r.required ? 'Yes' : 'No'}
+ ${fmt(r.duration_seconds, 3)}s
+ ${esc(r.summary)}
+ `).join('') || `No results to show ${state.report ? 'Try another status filter.' : 'Run a scan to see your check results here.'} `;
+}
+
+function renderFindings() {
+ const q = ($('#finding-search')?.value || '').toLowerCase();
+ const rows = state.findings.filter(f => !q || JSON.stringify(f).toLowerCase().includes(q));
+ $('#findings-table tbody').innerHTML = rows.map(f => `
+ ${esc(f.check)} ${esc(f.level)} ${esc(f.rule || '')}
+ ${esc(f.path || '')} ${f.line ?? ''} ${esc(f.message)}
+ `).join('') || `No findings to show ${q ? 'Try a different search.' : state.report ? 'No structured findings were reported in this scan.' : 'Run a scan to see reported findings.'} `;
+}
+
+async function runScan() {
+ const btn = $('#run-scan');
+ btn.disabled = true; $('#scan-status').textContent = 'Running scan… this may take a while (tools execute in the target repo).';
+ try {
+ const target = $('#target').value.trim();
+ const report = await api('/api/scan', { method: 'POST', body: JSON.stringify({ path: target }) });
+ renderReport(report);
+ $('#scan-status').textContent = `Scan complete. Policy ${report.policy_passed ? 'PASS' : 'FAIL'}.`;
+ loadHistory();
+ } catch (e) {
+ $('#scan-status').textContent = `Error: ${e.message}`;
+ } finally { btn.disabled = false; }
+}
+
+async function loadDoctor() {
+ try {
+ const data = await api('/api/doctor');
+ $('#doctor').innerHTML = (data.tools || []).map(t => `${esc(t.name)}
${t.available ? 'Available' : 'Missing'}
${t.path ? `
${esc(t.path)}
` : ''}
`).join('');
+ } catch (e) { $('#doctor').innerHTML = `Error: ${esc(e.message)}
`; }
+}
+
+async function loadInventory() {
+ try {
+ const target = $('#target').value.trim();
+ const data = await api(`/api/inventory?path=${encodeURIComponent(target)}`);
+ $('#inventory-table tbody').innerHTML = (data.symbols || []).map(s => `${esc(s.name)} ${esc(s.file)} ${s.line} `).join('') || 'No public symbols found. ';
+ } catch (e) { $('#inventory-table tbody').innerHTML = `Error: ${esc(e.message)} `; }
+}
+
+async function loadPolicy() {
+ try {
+ const target = $('#target').value.trim();
+ const data = await api(`/api/policy?path=${encodeURIComponent(target)}`);
+ $('#policy-json').textContent = JSON.stringify(data, null, 2);
+ } catch (e) { $('#policy-json').textContent = `Error: ${e.message}`; }
+}
+
+async function loadHistory() {
+ try {
+ const target = $('#target').value.trim();
+ const data = await api(`/api/history?path=${encodeURIComponent(target)}`);
+ $('#history-table tbody').innerHTML = (data.reports || []).map(r => `
+ ${esc(new Date(r.generated_at).toLocaleString())} ${esc(r.project)} ${fmt(r.score)} ${esc(r.grade)}
+ ${r.policy_passed ? 'PASS' : 'FAIL'}
+ Load
+ `).join('') || 'No saved JSON reports found in .codeproof/reports. ';
+ $$('#history-table [data-load-report]').forEach(btn => btn.addEventListener('click', async () => {
+ try {
+ const report = await api(`/api/report?path=${encodeURIComponent(target)}&file=${encodeURIComponent(btn.dataset.loadReport)}`);
+ renderReport(report); setView('dashboard');
+ } catch (e) {
+ $('#history-table tbody').innerHTML = `Error: ${esc(e.message)} `;
+ }
+ }));
+ } catch (e) { $('#history-table tbody').innerHTML = `Error: ${esc(e.message)} `; }
+}
+
+$$('.nav-btn').forEach(b => b.addEventListener('click', () => setView(b.dataset.view)));
+$('#run-scan').addEventListener('click', runScan);
+$('#status-filter').addEventListener('change', renderResults);
+$('#finding-search').addEventListener('input', renderFindings);
+$('#refresh-doctor').addEventListener('click', () => setView('policy'));
+$('#load-inventory').addEventListener('click', loadInventory);
+$('#load-policy').addEventListener('click', () => { loadPolicy(); loadDoctor(); });
+$('#load-history').addEventListener('click', loadHistory);
+$('#open-reports').addEventListener('click', async () => {
+ try { await api('/api/open-reports', { method: 'POST', body: JSON.stringify({ path: $('#target').value.trim() }) }); }
+ catch (e) { alert(e.message); }
+});
+
+(async function init() {
+ try { const info = await api('/api/info'); $('#target').value = info.default_target || ''; } catch {}
+ loadDoctor(); loadHistory();
+})();
diff --git a/src/codeproof/gui/index.html b/src/codeproof/gui/index.html
new file mode 100644
index 0000000..b676379
--- /dev/null
+++ b/src/codeproof/gui/index.html
@@ -0,0 +1,78 @@
+
+
+
+
+
+ CodeProof AI — Dashboard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WORKSPACE / OVERVIEW
Local environment
+
+
+
+
+
EVIDENCE, NOT GUESSWORK
Know where yourcode stands. Run your checks in one place and turn the results into a clearer picture of your repository’s health.
+
+
Checks run locally in your target repository.
+
+
REPORT CONFIDENCE ↗
No scan yet
Awaiting results
+
+ A snapshot of your loaded report
+
+
+
FINDINGS
—
Structured findings reported
+
PASS THRESHOLD
—
Defined by your policy
+
+
+
THE DETAILS
Check results See how each check performed.
Filter by status All statuses Passed Failed Unavailable Error
Check Status Weight Required Duration Summary
Ready when you are Run a scan to see your check results here.
+
GOOD TO KNOW
About your results Confidence is built from the checks in your policy. Each report shows what passed, what didn’t, and what needs a closer look.
KEEP IN MIND
A passing report is evidence, not proof that code is correct. Scans may execute repository code. Use an isolated environment for untrusted projects.
+
+
+ Check Level Rule Path Line Message No findings to show Run a scan to see reported findings.
+ EXPLORE
Public symbols Browse the public symbols in your repository.
Load inventory Symbol File Line Inventory is ready to load Load your public symbols to explore them here.
+ CONFIGURATION
Effective policy The settings used to evaluate your repository.
Reload Select Reload to view your effective policy. ENVIRONMENT
Tool availability Check which tools are available locally.
+ PREVIOUS RUNS
Report history Return to a saved report from this repository.
Reload Generated Project Score Grade Policy Action
+
+
+
+
+
diff --git a/src/codeproof/gui/styles.css b/src/codeproof/gui/styles.css
new file mode 100644
index 0000000..e675d9e
--- /dev/null
+++ b/src/codeproof/gui/styles.css
@@ -0,0 +1,48 @@
+:root { --ink:#1c2a29; --muted:#60716b; --border:#e5ebe8; --good:#19876b; --warn:#b97b27; --bad:#bd5d58; --neutral:#899c97; font-synthesis:none; }
+* { box-sizing:border-box; }
+html, body { margin:0; min-height:100%; background:#f6f8f6; color:var(--ink); font:14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
+button, input, select { font:inherit; color:inherit; }
+button { cursor:pointer; }
+button:focus-visible, input:focus-visible, select:focus-visible { outline:3px solid #8bd3bc; outline-offset:2px; }
+svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; flex:none; }
+.icon-defs, .sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
+.app { display:grid; grid-template-columns:246px minmax(0,1fr); min-height:100vh; }
+.sidebar { background:#172b28; color:#fff; padding:32px 18px 20px; display:flex; flex-direction:column; position:sticky; top:0; height:100vh; }
+.brand { display:flex; align-items:center; gap:11px; padding:0 8px 42px; }
+.logo { width:39px; height:39px; display:grid; place-items:center; background:#b9e4cf; color:#183a30; border-radius:12px; }
+.logo svg { width:23px; height:23px; stroke-width:2; }
+.brand h1 { margin:0; font-size:17px; letter-spacing:-.5px; line-height:1.2; }
+.brand h1 span { color:#a6d9bf; }
+.brand p { margin:4px 0 0; font-size:8px; font-weight:700; letter-spacing:1.35px; color:#91aaa0; }
+.nav-label { color:#77918a; font-size:10px; font-weight:700; letter-spacing:1.2px; padding:0 14px; margin-bottom:12px; }
+nav { display:flex; flex-direction:column; gap:5px; }
+.nav-btn { display:flex; align-items:center; gap:13px; width:100%; text-align:left; padding:12px 14px; color:#a6bab3; background:transparent; border:0; border-radius:8px; font-weight:500; }
+.nav-btn:hover { background:#233c36; color:white; }
+.nav-btn.active { color:#e4f7ec; background:#31544a; font-weight:650; }
+.nav-btn.active svg { color:#b2e1c8; }
+.sidebar-footer { margin-top:auto; background:#223a34; border:1px solid #37534a; border-radius:12px; padding:16px; }
+.local-icon { color:#bce5ce; margin-bottom:11px; }
+.sidebar-footer strong { font-size:13px; }
+.sidebar-footer p { font-size:12px; line-height:1.6; color:#a4b9b0; margin:7px 0 15px; }
+.sidebar-footer span { color:#b6d7c4; font-size:9px; font-weight:700; letter-spacing:.9px; }
+i { display:inline-block; width:6px; height:6px; border-radius:50%; background:#81caa4; margin-right:6px; vertical-align:middle; }
+.sidebar-bottom { color:#789088; padding:21px 3px 0; font-size:10px; letter-spacing:1px; font-weight:700; }.sidebar-bottom span { margin:0 6px; }
+.content { padding:0 42px 45px; min-width:0; max-width:1700px; width:100%; margin:0 auto; }
+.utility-bar { height:58px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); color:#596f65; font-size:10px; font-weight:700; letter-spacing:1px; }.utility-bar span { margin:0 10px; color:#cbd5d1; }.utility-bar strong { color:#5d7369; }
+.local-pill { color:#526f60; background:#edf3ef; border:1px solid #e1ebe4; border-radius:20px; padding:6px 10px; font-size:10px; letter-spacing:0; font-weight:600; }
+.topbar { display:flex; justify-content:space-between; align-items:end; gap:20px; padding:31px 0 25px; }.eyebrow { font-size:10px; letter-spacing:1.35px; font-weight:750; color:#557666; }.topbar h2 { margin:4px 0 3px; font-size:30px; line-height:1.2; letter-spacing:-1.15px; }.muted { color:var(--muted); margin:0; }.topbar .muted { font-size:13px; }.topbar-actions { display:flex; gap:8px; flex-wrap:wrap; }
+.ghost { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:10px 13px; border:1px solid #dfe7e2; background:#fff; border-radius:8px; font-size:12px; font-weight:650; color:#52665e; }.ghost svg { width:15px; height:15px; }.ghost:hover { background:#edf4ef; }
+.view { display:none; }.view.active { display:block; }
+.hero { position:relative; overflow:hidden; min-height:305px; display:grid; grid-template-columns:minmax(0,1fr) 270px; color:#fff; background:#1e3b34; border-radius:16px; }
+.hero::before, .hero::after { content:""; position:absolute; pointer-events:none; border:1px solid rgba(189,224,199,.1); border-radius:50%; width:470px; height:470px; right:180px; top:-210px; }.hero::after { width:600px; height:600px; right:115px; top:-275px; }
+.hero-copy { position:relative; z-index:1; padding:31px 36px 27px; }.hero-kicker { color:#b6dac4; font-size:10px; font-weight:750; letter-spacing:1.45px; }.hero-kicker span { display:inline-block; width:18px; height:2px; vertical-align:middle; margin-right:7px; background:#a7d5b8; }.hero h3 { margin:14px 0 10px; font-size:32px; line-height:1.14; font-weight:650; letter-spacing:-1px; }.hero h3 em { font-family:Georgia, serif; font-weight:400; color:#b8e2c8; }.hero-copy > p:not(.scan-status) { max-width:475px; margin:0; color:#b1c7ba; font-size:13px; line-height:1.65; }
+.scan-controls { display:flex; gap:9px; max-width:590px; align-items:end; margin-top:21px; }.field { flex:1; min-width:0; }.field label { display:block; margin-bottom:6px; font-size:9px; font-weight:700; letter-spacing:1px; color:#b2c9bd; }.input-wrap { display:flex; align-items:center; gap:9px; background:#fff; color:#90a49a; border-radius:8px; padding:0 12px; }.input-wrap svg { width:16px; }.input-wrap input { min-width:0; width:100%; border:0; outline:0; padding:12px 0; color:#43574e; background:transparent; font-size:12px; }.input-wrap:focus-within { outline:3px solid #8bd3bc; }.primary { display:inline-flex; align-items:center; justify-content:center; gap:18px; min-height:42px; padding:0 17px; border:0; border-radius:8px; color:#183a2d; background:#bce5ca; font-size:12px; font-weight:750; white-space:nowrap; }.primary:hover { background:#d1f1dc; }.primary:disabled { opacity:.6; cursor:progress; }.primary svg { width:16px; }
+.scan-status { color:#a7c2b2; font-size:11px; margin:9px 0 0; }
+.hero-score { position:relative; z-index:1; display:flex; flex-direction:column; align-items:center; justify-content:center; border-left:1px solid rgba(213,239,222,.12); background:rgba(11,36,29,.15); padding:22px; }.score-heading { width:100%; display:flex; justify-content:space-between; color:#a7c3b3; letter-spacing:1px; font-weight:700; font-size:9px; }.score-heading span { font-size:16px; }.score-ring { width:140px; height:140px; display:grid; place-items:center; border-radius:50%; margin:17px 0 12px; background:conic-gradient(var(--neutral) 0deg, rgba(220,246,230,.14) 0deg); }.score-inner { width:122px; height:122px; border-radius:50%; background:#203e35; display:flex; flex-direction:column; align-items:center; justify-content:center; }.score-inner span { font-size:38px; font-weight:650; line-height:1; letter-spacing:-2px; }.score-inner small { margin-top:8px; font-size:8px; font-weight:700; letter-spacing:1px; color:#9ab9a8; }.grade { font-size:13px; font-weight:650; margin-bottom:7px; }.badge { display:inline-flex; align-items:center; padding:4px 9px; border-radius:20px; font-size:10px; font-weight:700; color:#c1d7ca; background:#38584b; }.badge.pass { background:#ddf3e7; color:#26785a; }.badge.fail { background:#f9e7e4; color:#a34943; }
+.section-heading { display:flex; align-items:end; justify-content:space-between; margin:32px 0 14px; }.section-heading h3, .panel h3 { font-size:18px; letter-spacing:-.4px; margin:3px 0 0; }.section-note { color:#687c72; font-size:12px; }.cards { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-bottom:24px; }.card,.panel { background:#fff; border:1px solid var(--border); border-radius:12px; box-shadow:0 3px 12px rgba(23,48,37,.025); }.card { padding:17px 19px 16px; }.card-top { display:flex; align-items:center; justify-content:space-between; }.kpi-label { font-size:10px; color:#62766b; letter-spacing:1px; font-weight:750; }.metric-icon { display:grid; place-items:center; width:33px; height:33px; border-radius:9px; }.metric-icon svg { width:16px; }.blue { color:#6685a7; background:#edf3f8; }.peach { color:#c28768; background:#fbf1e9; }.green { color:#6e9a7b; background:#edf6ee; }.kpi { font-size:28px; line-height:1.2; font-weight:700; letter-spacing:-1px; margin:3px 0; }.small { font-size:12px; }
+.dashboard-grid { display:grid; grid-template-columns:minmax(0,1.8fr) minmax(260px,1fr); gap:14px; align-items:start; }.panel { overflow:hidden; margin-bottom:14px; }.panel-head { padding:20px 21px; display:flex; justify-content:space-between; align-items:center; gap:14px; border-bottom:1px solid #edf1ee; }.panel-head p { color:#667b70; font-size:12px; margin:4px 0 0; }.table-wrap { overflow:auto; }table { width:100%; border-collapse:collapse; }th, td { padding:12px 15px; border-bottom:1px solid #f0f3f1; text-align:left; vertical-align:top; font-size:12px; }th { color:#5e7167; font-size:9px; text-transform:uppercase; letter-spacing:.8px; white-space:nowrap; background:#fafcfb; }tbody tr:last-child td { border-bottom:0; }tbody tr:hover { background:#fbfdfb; }.empty-cell { text-align:center; padding:32px 15px 37px; color:#53695f; }.empty-cell strong,.empty-cell span { display:block; }.empty-cell span { margin-top:5px; color:#5f7368; font-size:12px; }.empty-icon { margin:0 auto 10px; display:grid; place-items:center; width:38px; height:38px; background:#eef5f0; border-radius:50%; color:#8bb19a; }
+select, .search { background:#fff; border:1px solid #e2eae5; border-radius:8px; padding:9px 12px; color:#60756b; font-size:12px; }.search { width:220px; }.status { display:inline-flex; padding:3px 8px; border-radius:20px; font-size:10px; font-weight:700; text-transform:capitalize; }.status.passed { background:#e5f5ea; color:#27855f; }.status.failed { background:#fae9e7; color:#b8504c; }.status.unavailable,.status.skipped { background:#f0f3f1; color:#75857d; }.status.error { background:#fbf1dd; color:#a77321; }
+.insight-icon { color:#7ba38b; background:#eef6f0; width:36px; height:36px; display:grid; place-items:center; border-radius:10px; }.insight-body { padding:18px 21px 22px; color:#5e7568; font-size:12px; line-height:1.7; }.insight-body p { margin:0; }.insight-divider { border-top:1px solid #edf1ee; margin:17px 0; }.insight-title { font-size:9px; font-weight:750; letter-spacing:1px; color:#5d7367; }.limitations { margin:8px 0 0; padding-left:17px; }.limitations li { margin:7px 0; padding-left:3px; }.codeblock { margin:0; padding:20px; overflow:auto; color:#526d5e; font:12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }.doctor-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:10px; padding:20px; }.doctor-item { padding:14px; border:1px solid var(--border); border-radius:9px; overflow-wrap:anywhere; }.doctor-item .name { font-weight:700; margin-bottom:8px; }.doctor-item .small { margin-top:8px; }
+@media (max-width:1100px) { .content { padding-left:28px; padding-right:28px; }.dashboard-grid { grid-template-columns:1fr; }.hero { grid-template-columns:minmax(0,1fr) 220px; } }
+@media (max-width:760px) { .app { display:block; }.sidebar { position:static; height:auto; padding:16px; }.brand { padding:0 0 15px; }.nav-label,.sidebar-footer,.sidebar-bottom { display:none; }nav { flex-direction:row; flex-wrap:wrap; }.nav-btn { width:auto; white-space:nowrap; padding:9px 11px; }.nav-btn svg { width:15px; }.content { padding:0 18px 30px; }.utility-bar { height:45px; }.topbar { align-items:flex-start; flex-direction:column; padding:24px 0; }.topbar h2 { font-size:26px; }.hero { grid-template-columns:1fr; }.hero-copy { padding:27px 24px; }.hero-score { border-left:0; border-top:1px solid rgba(213,239,222,.12); padding:20px; }.score-ring { width:110px; height:110px; margin:10px 0; }.score-inner { width:94px; height:94px; }.score-inner span { font-size:30px; }.cards { gap:8px; }.card { padding:13px; }.kpi { font-size:24px; }.section-note { display:none; } }
+@media (max-width:480px) { .scan-controls { flex-direction:column; align-items:stretch; }.cards { grid-template-columns:1fr; }.card { display:grid; grid-template-columns:1fr auto; align-items:center; }.card-top { grid-column:1 / -1; }.panel-head { align-items:flex-start; flex-direction:column; }.filters, .filters select, .search { width:100%; }.topbar-actions { width:100%; }.topbar-actions .ghost { flex:1; }.hero h3 { font-size:29px; } }
diff --git a/src/codeproof/web.py b/src/codeproof/web.py
new file mode 100644
index 0000000..33e5644
--- /dev/null
+++ b/src/codeproof/web.py
@@ -0,0 +1,151 @@
+from __future__ import annotations
+import json, mimetypes, os, shutil, subprocess, sys, webbrowser
+from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
+from pathlib import Path
+from urllib.parse import parse_qs, urlparse
+from . import __version__
+
+GUI_DIR = Path(__file__).resolve().parent / "gui"
+
+
+def _json(handler: BaseHTTPRequestHandler, status: int, payload):
+ body = json.dumps(payload, default=str).encode("utf-8")
+ handler.send_response(status)
+ handler.send_header("Content-Type", "application/json; charset=utf-8")
+ handler.send_header("Content-Length", str(len(body)))
+ handler.send_header("Cache-Control", "no-store")
+ handler.end_headers()
+ handler.wfile.write(body)
+
+def _read_json(handler: BaseHTTPRequestHandler):
+ n = int(handler.headers.get("Content-Length") or 0)
+ raw = handler.rfile.read(n) if n else b"{}"
+ return json.loads(raw.decode("utf-8") or "{}")
+
+def _target(path: str | None, default: Path) -> Path:
+ p = Path(path).expanduser() if path else default
+ return p.resolve()
+
+class Handler(BaseHTTPRequestHandler):
+ server_version = f"CodeProofGUI/{__version__}"
+ default_target = Path.cwd()
+
+ def log_message(self, fmt, *args):
+ sys.stderr.write(f"[gui] {self.address_string()} - {fmt % args}\n")
+
+ def do_GET(self):
+ parsed = urlparse(self.path)
+ try:
+ if parsed.path in ("/", "/index.html"):
+ return self._serve_file(GUI_DIR / "index.html")
+ if parsed.path.startswith("/static/"):
+ rel = parsed.path.removeprefix("/static/").replace("/", os.sep)
+ return self._serve_file((GUI_DIR / rel).resolve())
+ if parsed.path == "/api/info":
+ return _json(self, 200, {"version": __version__, "default_target": str(self.default_target)})
+ if parsed.path == "/api/doctor":
+ tools = []
+ for n in ["ruff", "mypy", "pytest", "bandit", "semgrep"]:
+ p = shutil.which(n)
+ tools.append({"name": n, "available": bool(p), "path": p})
+ return _json(self, 200, {"tools": tools})
+ if parsed.path == "/api/policy":
+ from .config import load
+ qs = parse_qs(parsed.query)
+ root = _target((qs.get("path") or [None])[0], self.default_target)
+ cfg = load(root)
+ return _json(self, 200, cfg.model_dump(mode="json"))
+ if parsed.path == "/api/inventory":
+ from .config import load
+ from .discovery import symbols
+ qs = parse_qs(parsed.query)
+ root = _target((qs.get("path") or [None])[0], self.default_target)
+ cfg = load(root)
+ data = [{"name": n, "file": str(p), "line": l} for n, p, l in symbols(root, cfg.source_paths)]
+ return _json(self, 200, {"root": str(root), "count": len(data), "symbols": data})
+ if parsed.path == "/api/history":
+ qs = parse_qs(parsed.query)
+ root = _target((qs.get("path") or [None])[0], self.default_target)
+ reports_dir = root / ".codeproof" / "reports"
+ items = []
+ if reports_dir.exists():
+ for p in sorted(reports_dir.glob("*.json"), key=lambda x: x.stat().st_mtime, reverse=True):
+ try:
+ d = json.loads(p.read_text(encoding="utf-8"))
+ items.append({"file": p.name, "generated_at": d.get("generated_at"), "project": d.get("project"),
+ "score": d.get("score"), "grade": d.get("grade"), "policy_passed": d.get("policy_passed")})
+ except Exception:
+ continue
+ return _json(self, 200, {"root": str(root), "reports": items})
+ if parsed.path == "/api/report":
+ qs = parse_qs(parsed.query)
+ root = _target((qs.get("path") or [None])[0], self.default_target)
+ name = (qs.get("file") or [""])[0]
+ p = (root / ".codeproof" / "reports" / name).resolve()
+ if not name or p.parent != (root / ".codeproof" / "reports").resolve() or not p.exists():
+ return _json(self, 404, {"error": "report not found"})
+ return _json(self, 200, json.loads(p.read_text(encoding="utf-8")))
+ return _json(self, 404, {"error": "not found"})
+ except Exception as e:
+ return _json(self, 500, {"error": str(e)})
+
+ def do_POST(self):
+ parsed = urlparse(self.path)
+ try:
+ if parsed.path == "/api/scan":
+ from .config import load
+ from .core import scan as run_scan
+ from .reporting import write as write_reports
+ data = _read_json(self)
+ root = _target(data.get("path"), self.default_target)
+ if not root.exists():
+ return _json(self, 400, {"error": f"target does not exist: {root}"})
+ cfg = load(root)
+ report = run_scan(root, cfg, data.get("fail_under"))
+ write_reports(report, root / ".codeproof" / "reports", "all")
+ return _json(self, 200, report.model_dump(mode="json"))
+ if parsed.path == "/api/open-reports":
+ data = _read_json(self)
+ root = _target(data.get("path"), self.default_target)
+ out = root / ".codeproof" / "reports"
+ out.mkdir(parents=True, exist_ok=True)
+ if sys.platform.startswith("win"):
+ os.startfile(out) # type: ignore[attr-defined]
+ elif sys.platform == "darwin":
+ subprocess.Popen(["open", str(out)])
+ else:
+ subprocess.Popen(["xdg-open", str(out)])
+ return _json(self, 200, {"ok": True, "path": str(out)})
+ return _json(self, 404, {"error": "not found"})
+ except Exception as e:
+ return _json(self, 500, {"error": str(e)})
+
+ def _serve_file(self, path: Path):
+ if GUI_DIR not in path.parents and path != GUI_DIR / "index.html":
+ return _json(self, 403, {"error": "forbidden"})
+ if not path.exists() or not path.is_file():
+ return _json(self, 404, {"error": "not found"})
+ body = path.read_bytes()
+ ctype = mimetypes.guess_type(path.name)[0] or "application/octet-stream"
+ self.send_response(200)
+ self.send_header("Content-Type", ctype)
+ self.send_header("Content-Length", str(len(body)))
+ self.send_header("Cache-Control", "no-store")
+ self.end_headers()
+ self.wfile.write(body)
+
+def serve(host: str = "127.0.0.1", port: int = 8787, target: Path | None = None, open_browser: bool = True):
+ Handler.default_target = (target or Path.cwd()).resolve()
+ httpd = ThreadingHTTPServer((host, port), Handler)
+ url = f"http://{host}:{port}/"
+ print(f"CodeProof GUI running at {url}")
+ print(f"Default target: {Handler.default_target}")
+ if open_browser:
+ try: webbrowser.open(url)
+ except Exception: pass
+ try:
+ httpd.serve_forever()
+ except KeyboardInterrupt:
+ pass
+ finally:
+ httpd.server_close()