focus-hud 0.1.0__tar.gz

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.
Files changed (85) hide show
  1. focus_hud-0.1.0/.cursor/rules/README.md +13 -0
  2. focus_hud-0.1.0/.cursor/rules/focus-engineering.mdc +34 -0
  3. focus_hud-0.1.0/.cursor/rules/focus-project.mdc +66 -0
  4. focus_hud-0.1.0/.focus.toml.example +7 -0
  5. focus_hud-0.1.0/.github/workflows/focus.yml +47 -0
  6. focus_hud-0.1.0/.github/workflows/publish.yml +34 -0
  7. focus_hud-0.1.0/.gitignore +56 -0
  8. focus_hud-0.1.0/LICENSE +21 -0
  9. focus_hud-0.1.0/PKG-INFO +203 -0
  10. focus_hud-0.1.0/README.md +174 -0
  11. focus_hud-0.1.0/docs/ACTION.md +32 -0
  12. focus_hud-0.1.0/docs/DECISIONS.md +28 -0
  13. focus_hud-0.1.0/docs/DEMO.md +77 -0
  14. focus_hud-0.1.0/docs/ETHICS.md +121 -0
  15. focus_hud-0.1.0/docs/HUD.md +158 -0
  16. focus_hud-0.1.0/docs/LAUNCH.md +89 -0
  17. focus_hud-0.1.0/docs/PRIVACY.md +142 -0
  18. focus_hud-0.1.0/docs/PUBLISH.md +37 -0
  19. focus_hud-0.1.0/docs/ROADMAP.md +129 -0
  20. focus_hud-0.1.0/docs/STACK.md +76 -0
  21. focus_hud-0.1.0/docs/TESTING.md +221 -0
  22. focus_hud-0.1.0/docs/TRIGGERS.md +120 -0
  23. focus_hud-0.1.0/docs/assets/focus-demo.gif +0 -0
  24. focus_hud-0.1.0/docs/assets/hero-focus.png +0 -0
  25. focus_hud-0.1.0/docs/assets/how-it-works.png +0 -0
  26. focus_hud-0.1.0/docs/assets/how-it-works.svg +21 -0
  27. focus_hud-0.1.0/docs/assets/hud-classify.png +0 -0
  28. focus_hud-0.1.0/docs/assets/hud-classify.svg +28 -0
  29. focus_hud-0.1.0/docs/assets/hud-glass-box.png +0 -0
  30. focus_hud-0.1.0/docs/assets/hud-glass-box.svg +32 -0
  31. focus_hud-0.1.0/docs/assets/pr-comment.png +0 -0
  32. focus_hud-0.1.0/docs/assets/pr-comment.svg +15 -0
  33. focus_hud-0.1.0/docs/examples/focus-hud-classify.md +75 -0
  34. focus_hud-0.1.0/docs/examples/focus-hud-glass-box-js.md +46 -0
  35. focus_hud-0.1.0/docs/examples/focus-hud-glass-box.md +46 -0
  36. focus_hud-0.1.0/examples/focus-action.yml +47 -0
  37. focus_hud-0.1.0/pyproject.toml +60 -0
  38. focus_hud-0.1.0/src/focus/__init__.py +1 -0
  39. focus_hud-0.1.0/src/focus/audit.py +241 -0
  40. focus_hud-0.1.0/src/focus/ci/__init__.py +15 -0
  41. focus_hud-0.1.0/src/focus/ci/github_comment.py +129 -0
  42. focus_hud-0.1.0/src/focus/cli.py +146 -0
  43. focus_hud-0.1.0/src/focus/config.py +37 -0
  44. focus_hud-0.1.0/src/focus/graph/__init__.py +5 -0
  45. focus_hud-0.1.0/src/focus/graph/builder.py +154 -0
  46. focus_hud-0.1.0/src/focus/hud/__init__.py +11 -0
  47. focus_hud-0.1.0/src/focus/hud/build.py +79 -0
  48. focus_hud-0.1.0/src/focus/hud/classify.py +208 -0
  49. focus_hud-0.1.0/src/focus/hud/mermaid.py +124 -0
  50. focus_hud-0.1.0/src/focus/hud/render.py +68 -0
  51. focus_hud-0.1.0/src/focus/ingest/__init__.py +22 -0
  52. focus_hud-0.1.0/src/focus/ingest/diff.py +104 -0
  53. focus_hud-0.1.0/src/focus/ingest/symbols.py +233 -0
  54. focus_hud-0.1.0/src/focus/models.py +88 -0
  55. focus_hud-0.1.0/src/focus/scan/__init__.py +14 -0
  56. focus_hud-0.1.0/src/focus/scan/cache.py +89 -0
  57. focus_hud-0.1.0/src/focus/scan/js_parser.py +209 -0
  58. focus_hud-0.1.0/src/focus/scan/parser.py +121 -0
  59. focus_hud-0.1.0/src/focus/scan/walker.py +100 -0
  60. focus_hud-0.1.0/src/focus/triggers/__init__.py +5 -0
  61. focus_hud-0.1.0/src/focus/triggers/rules.py +119 -0
  62. focus_hud-0.1.0/tests/conftest.py +20 -0
  63. focus_hud-0.1.0/tests/fixtures/glass_box/api/routes.py +21 -0
  64. focus_hud-0.1.0/tests/fixtures/glass_box/auth_utils.py +13 -0
  65. focus_hud-0.1.0/tests/fixtures/glass_box/billing/service.py +10 -0
  66. focus_hud-0.1.0/tests/fixtures/glass_box/dashboard/views.py +10 -0
  67. focus_hud-0.1.0/tests/fixtures/glass_box/jobs/worker.py +7 -0
  68. focus_hud-0.1.0/tests/fixtures/glass_box_js/api/routes.ts +9 -0
  69. focus_hud-0.1.0/tests/fixtures/glass_box_js/authUtils.ts +9 -0
  70. focus_hud-0.1.0/tests/fixtures/glass_box_js/billing/service.ts +12 -0
  71. focus_hud-0.1.0/tests/fixtures/glass_box_js/dashboard/views.ts +8 -0
  72. focus_hud-0.1.0/tests/fixtures/glass_box_js/jobs/worker.ts +6 -0
  73. focus_hud-0.1.0/tests/test_audit.py +182 -0
  74. focus_hud-0.1.0/tests/test_ci_comment.py +16 -0
  75. focus_hud-0.1.0/tests/test_cli.py +65 -0
  76. focus_hud-0.1.0/tests/test_config_symbols.py +68 -0
  77. focus_hud-0.1.0/tests/test_diff_range.py +41 -0
  78. focus_hud-0.1.0/tests/test_graph.py +95 -0
  79. focus_hud-0.1.0/tests/test_hud_golden.py +74 -0
  80. focus_hud-0.1.0/tests/test_ingest.py +42 -0
  81. focus_hud-0.1.0/tests/test_js_ts.py +85 -0
  82. focus_hud-0.1.0/tests/test_parse_cache.py +90 -0
  83. focus_hud-0.1.0/tests/test_parser.py +105 -0
  84. focus_hud-0.1.0/tests/test_scan.py +61 -0
  85. focus_hud-0.1.0/uv.lock +383 -0
@@ -0,0 +1,13 @@
1
+ # Focus Cursor Rules
2
+
3
+ Project-specific rules loaded by Cursor when you work in this repo.
4
+
5
+ | File | Purpose |
6
+ |---|---|
7
+ | `focus-project.mdc` | Product context, architecture, tech stack *(public, committed)* |
8
+ | `focus-engineering.mdc` | Non-negotiable engineering constraints *(public, committed)* |
9
+ | `focus.mdc` | Diagnostic engine identity, HUD contract, directives *(symlink → `cursor-rules/focus/`)* |
10
+ | `focus-learning.mdc` | Learn-while-building technology map *(symlink → `cursor-rules/focus/`)* |
11
+ | `focus-mentorship.mdc` | Mentorship protocol *(symlink → `cursor-rules/focus/`)* |
12
+
13
+ Global rules (SWE standards, communication, owner profile) live in the private **`cursor-rules`** repo, symlinked to `~/.cursor/plugins/local/swe-standards`.
@@ -0,0 +1,34 @@
1
+ ---
2
+ description: Focus immutable engineering rules — non-negotiable constraints
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Focus — Immutable Engineering Rules
7
+
8
+ These are non-negotiable. If a task appears to require breaking one of these rules, **stop and ask the project owner** rather than improvising a workaround.
9
+
10
+ 1. **Full-repo graph, never diff-only.** Tree-sitter must index the entire repository (respecting `.gitignore`). Blast radius is computed via reverse traversal on the dependency graph. Reading only the git patch to infer impact is forbidden — it causes the blindspots Focus exists to eliminate.
11
+
12
+ 2. **LLM labels topology; LLM does not invent topology.** The dependency graph and blast radius subgraph are computed deterministically. The LLM may generate Mermaid labels, executive summary prose, and layout hints from structured JSON — it must not add nodes or edges not present in the graph payload. Validate Mermaid output against the graph before posting.
13
+
14
+ 3. **Smart triggers are mandatory.** Do not generate diagrams for every change. Pass-through (summary only) for markdown, cosmetic UI, comments, and isolated private utils with zero downstream surface hits. Diagram for schema, API route, global state, dependency manifest, or blast radius above threshold.
15
+
16
+ 4. **Credential isolation via `.env`.** LLM API keys and GitHub tokens live in `.env`, loaded via `pydantic-settings`. Never hardcode, commit, or log secrets. `.env.example` stays in sync with placeholders only.
17
+
18
+ 5. **Passive UX only.** Focus comments and CLI output inform; they never block merges, gate CI, or quiz developers. No required interactive steps.
19
+
20
+ 6. **Mermaid first, SVG fallback later.** Primary output is Mermaid in CLI stdout and GitHub PR comments (native render). Pre-rendered SVG/Graphviz is a Phase 3+ fallback when validation fails — not the default.
21
+
22
+ 7. **Type everything.** Python: full type hints, Pydantic models for graph payloads, HUD schema, and CLI I/O.
23
+
24
+ 8. **Framework agnostic.** Heuristics for routes/schemas/state use patterns (decorators, path conventions) — not hard dependency on one web framework. Phase 1 proves the pipeline on plain Python imports/calls first.
25
+
26
+ 9. **No silent refactors.** Do not restructure or rename beyond explicit task scope. Propose and ask first.
27
+
28
+ 10. **Parse cache is optional, correctness is not.** File-hash AST caches may speed repeat runs but must invalidate on content change. Never serve stale graph data silently.
29
+
30
+ 11. **Privacy-by-design.** Respect `.gitignore` and `.focusignore`. Never parse, log, or transmit `.env`, keys, or credential files. LLM calls (when enabled) receive structured graph JSON only — not full source files. See `docs/PRIVACY.md`.
31
+
32
+ 12. **No surveillance features.** Do not build developer identity tracking, blame metrics, merge gates, or management dashboards. Focus analyzes code structure for review aid only. See `docs/ETHICS.md`.
33
+
34
+ 13. **Stay current — no stale deps or Actions.** Prefer current stable majors for Python packages (`uv lock` / `uv sync`) and GitHub Actions. When adding or touching a workflow, verify `uses:` pins against **tags that actually exist** on the action's releases page (e.g. `actions/checkout@v7`, `astral-sh/setup-uv@v8.3.2`) — do not invent floating majors like `@v8` if the repo only publishes `@v8.x.y`. On dependency or CI work: check for newer stable versions and upgrade unless there is a documented break. Deprecation warnings and "unable to resolve action" failures in CI are defects to fix, not noise to ignore.
@@ -0,0 +1,66 @@
1
+ ---
2
+ description: Focus project context, architecture, and tech stack
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Focus — Project Context
7
+
8
+ Focus is an **architectural diagnostic engine** — an "AR HUD for codebases." It transforms opaque "Black Box" legacy repositories into transparent "Glass Box" environments, giving developers structural clarity before they change code.
9
+
10
+ ## The Problem
11
+
12
+ AI-generated pull requests are large and fast to produce but slow and scary to review. A line-level diff hides *blast radius*: downstream importers, API routes, schema coupling, and regression vectors. Text summaries cause cognitive overload without evidence.
13
+
14
+ ## The Solution
15
+
16
+ Focus intercepts analysis at the CLI or GitHub Action layer and emits a **Focus HUD**:
17
+
18
+ 1. **Executive Summary** — 1–2 sentence architectural health assessment.
19
+ 2. **Visual Dependency Map** — Mermaid flowchart of impact paths (topology from computed graph, not LLM invention).
20
+ 3. **Blast Radius Report** — bulleted Danger Zones and downstream dependencies.
21
+
22
+ ## Core Capabilities
23
+
24
+ | Capability | Description |
25
+ |---|---|
26
+ | **Focus Scan** | Tree-sitter full-repo AST index; map imports, calls, routes, schemas |
27
+ | **Blast Radius Engine** | Reverse BFS from changed symbols; pre-flight regression simulation |
28
+ | **Smart Triggers** | Diagram only for high-impact changes; one-liner for pass-through edits |
29
+
30
+ ## Design Principles
31
+
32
+ - **Codebase-wide context** — never diff-only blindspots
33
+ - **Evidence-based** — graph edges are computed; LLM labels only
34
+ - **Concise & visual** — charts and bullets over prose walls
35
+ - **Passive enablement** — no blocking commits, no developer quizzes (design principle; owner has asked that this line NOT appear in the README — it lives in `docs/ETHICS.md`)
36
+ - Production-grade Python with full type hints
37
+
38
+ ## Documentation
39
+
40
+ | Doc | Purpose |
41
+ |---|---|
42
+ | [`docs/HUD.md`](../../docs/HUD.md) | Frozen HUD schema (canonical) |
43
+ | [`docs/STACK.md`](../../docs/STACK.md) | Locked stack decisions |
44
+ | [`docs/DECISIONS.md`](../../docs/DECISIONS.md) | Phase 0 resolved questions |
45
+ | [`docs/ETHICS.md`](../../docs/ETHICS.md) | Responsible use, LLM ethics, won't-build list |
46
+ | [`docs/PRIVACY.md`](../../docs/PRIVACY.md) | Data boundaries, secrets, Action permissions |
47
+ | [`docs/TRIGGERS.md`](../../docs/TRIGGERS.md) | Diagram vs pass-through rules |
48
+ | [`docs/TESTING.md`](../../docs/TESTING.md) | Golden fixtures, CI constraints |
49
+
50
+ ## Tech Stack
51
+
52
+ | Layer | Technology | Notes |
53
+ |---|---|---|
54
+ | CLI | Python 3.12+ / Typer | `focus scan`, `focus trace`, `focus audit` |
55
+ | AST | Tree-sitter | Multi-language grammars; Phase 1 = Python |
56
+ | Graph | NetworkX | Dependency graph + reverse BFS blast radius |
57
+ | Diagrams | Mermaid.js | Native GitHub PR rendering |
58
+ | LLM | Off by default (`FOCUS_LLM_ENABLED=false`); Phase 3+ opt-in | Node labels + layout hints from structured graph JSON only |
59
+ | GitHub | Actions + REST API | PR comment on open/sync |
60
+
61
+ ## Commands
62
+
63
+ - `focus scan [path]` — full-repo index + graph build
64
+ - `focus trace [file]` — dependency map for a file/symbol
65
+ - `focus audit [pr|branch]` — pre-merge blast radius
66
+ - `focus audit --local` — working tree vs base branch
@@ -0,0 +1,7 @@
1
+ # Optional Focus config — copy to `.focus.toml` at your repo root.
2
+ # Missing file = defaults (fan_out_threshold = 3).
3
+
4
+ [focus]
5
+ # A file becomes a Danger Zone when this many other files import it directly
6
+ # (package __init__.py files are never Danger Zones via fan-out alone).
7
+ fan_out_threshold = 3
@@ -0,0 +1,47 @@
1
+ # Opt-in Focus HUD on pull requests.
2
+ # Permissions: contents:read (checkout) + pull-requests:write (comment only).
3
+ # See docs/PRIVACY.md.
4
+
5
+ name: Focus
6
+
7
+ on:
8
+ pull_request:
9
+ types: [opened, synchronize, reopened]
10
+
11
+ permissions:
12
+ contents: read
13
+ pull-requests: write
14
+
15
+ jobs:
16
+ hud:
17
+ name: Focus HUD
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - name: Checkout
21
+ uses: actions/checkout@v7
22
+ with:
23
+ fetch-depth: 0
24
+
25
+ - name: Install uv
26
+ uses: astral-sh/setup-uv@v8.3.2
27
+ with:
28
+ enable-cache: true
29
+
30
+ - name: Set up Python
31
+ run: uv python install 3.12
32
+
33
+ - name: Install Focus
34
+ run: uv sync --frozen
35
+
36
+ - name: Run Focus audit
37
+ env:
38
+ FOCUS_BASE: ${{ github.event.pull_request.base.sha }}
39
+ run: |
40
+ uv run focus audit --base "$FOCUS_BASE" --out focus-hud.md
41
+
42
+ - name: Post or update PR comment
43
+ env:
44
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45
+ FOCUS_PR_NUMBER: ${{ github.event.pull_request.number }}
46
+ run: |
47
+ uv run python -c "from pathlib import Path; from focus.ci import post_from_env; print(post_from_env(Path('focus-hud.md')))"
@@ -0,0 +1,34 @@
1
+ # Publish focus-hud to PyPI on version tags (v0.1.0, …) via Trusted Publishing.
2
+ # One-time setup: https://docs.pypi.org/trusted-publishers/
3
+ # PyPI project: focus-hud
4
+ # Workflow: publish.yml on j0viane/focus, environment: pypi
5
+
6
+ name: Publish
7
+
8
+ on:
9
+ push:
10
+ tags:
11
+ - "v*"
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: read
16
+ id-token: write
17
+
18
+ jobs:
19
+ publish:
20
+ name: Publish to PyPI
21
+ runs-on: ubuntu-latest
22
+ environment: pypi
23
+ steps:
24
+ - name: Checkout
25
+ uses: actions/checkout@v7
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v8.3.2
29
+
30
+ - name: Build
31
+ run: uv build
32
+
33
+ - name: Publish
34
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,56 @@
1
+ # --- Secrets & environment ---
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+ *.pem
6
+ *.key
7
+ secrets/
8
+
9
+ # --- Python ---
10
+ __pycache__/
11
+ *.py[cod]
12
+ *$py.class
13
+ *.so
14
+ .Python
15
+ build/
16
+ dist/
17
+ *.egg-info/
18
+ .eggs/
19
+ .venv/
20
+ venv/
21
+ env/
22
+ ENV/
23
+ .pytest_cache/
24
+ .mypy_cache/
25
+ .ruff_cache/
26
+ .coverage
27
+ htmlcov/
28
+ *.log
29
+
30
+ # Tree-sitter build artifacts
31
+ *.so.dSYM/
32
+ tree-sitter-*/
33
+
34
+ # Generated Focus HUD previews
35
+ focus-hud.md
36
+
37
+ # Focus parse cache (derived AST facts — safe to delete)
38
+ .focus-cache/
39
+
40
+
41
+ # Focus path exclusions (optional)
42
+ # .focusignore is respected at runtime; not gitignored itself
43
+
44
+ # --- Editor / OS ---
45
+ .vscode/
46
+ .idea/
47
+ .DS_Store
48
+ Thumbs.db
49
+
50
+ # --- Claude Code local settings ---
51
+ .claude/settings.local.json
52
+
53
+ # --- Private Cursor rules (canonical copy in ~/Cursor/cursor-rules/focus/) ---
54
+ .cursor/rules/focus.mdc
55
+ .cursor/rules/focus-mentorship.mdc
56
+ .cursor/rules/focus-learning.mdc
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joviane Bellegarde
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: focus-hud
3
+ Version: 0.1.0
4
+ Summary: Blast radius you can defend — evidence-only, before you merge.
5
+ Project-URL: Homepage, https://github.com/j0viane/focus
6
+ Project-URL: Repository, https://github.com/j0viane/focus
7
+ Project-URL: Issues, https://github.com/j0viane/focus/issues
8
+ Project-URL: Documentation, https://github.com/j0viane/focus/blob/main/docs/DEMO.md
9
+ Author: Joviane Bellegarde
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: architecture,blast-radius,code-review,mermaid,static-analysis
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Quality Assurance
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: networkx>=3.6.1
23
+ Requires-Dist: pydantic>=2.13.4
24
+ Requires-Dist: tree-sitter-javascript>=0.25.0
25
+ Requires-Dist: tree-sitter-typescript>=0.23.2
26
+ Requires-Dist: tree-sitter>=0.26.0
27
+ Requires-Dist: typer>=0.26
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Focus
31
+
32
+ **Blast radius you can defend — evidence-only, before you merge.**
33
+
34
+ Focus answers one question: **what else in this codebase could break because of this change?**
35
+
36
+ It's an **AR HUD for codebases**: a computed import graph (Python + JS/TS) → Mermaid map + Danger Zones. Same HUD in the CLI and on the PR. No LLM inventing edges.
37
+
38
+ > **Not** another AI PR summary. **Not** a hop inventory that cries wolf on every file. Focus stays quiet when the change is boring, and loud when you touch a shared hub.
39
+
40
+ ---
41
+
42
+ ## Try in 60 seconds
43
+
44
+ ```bash
45
+ pip install "focus-hud @ git+https://github.com/j0viane/focus.git"
46
+ # after PyPI publish: pip install focus-hud
47
+
48
+ focus trace path/to/shared_module.py --out focus-hud.md
49
+ # open focus-hud.md → Markdown preview for Mermaid
50
+
51
+ focus audit --local --out focus-hud.md # working tree vs main — before you push
52
+ ```
53
+
54
+ **Demo fixture (no app required):**
55
+
56
+ ```bash
57
+ git clone https://github.com/j0viane/focus.git && cd focus
58
+ uv sync
59
+ uv run focus trace tests/fixtures/glass_box/auth_utils.py \
60
+ --root tests/fixtures/glass_box --out focus-hud.md
61
+ ```
62
+
63
+ Gallery + walkthrough: [`docs/DEMO.md`](docs/DEMO.md) · [`docs/assets/`](docs/assets/)
64
+
65
+ ---
66
+
67
+ ## Why this exists
68
+
69
+ There's a new kind of pressure on developers — and it lands hardest on juniors: walk into a codebase you've never seen, point an AI at it, and ship. The code arrives in seconds. The understanding doesn't.
70
+
71
+ Focus is for the moment right before you push into a codebase that was there long before you. **What the system looks like, and what your change will actually touch** — with evidence you can defend in review.
72
+
73
+ | Moment | Command | You get |
74
+ |---|---|---|
75
+ | AI rewrote a shared function | `focus audit --local` | Blast radius of your working tree vs `main` |
76
+ | Big PR in your queue | Focus Action comment | Skim-or-dig: diagram + Danger Zones, or “low impact” |
77
+ | Inherited a module | `focus trace path/to/file.py` | Everything that depends on it |
78
+
79
+ ---
80
+
81
+ ## GitHub Action (any repo)
82
+
83
+ Copy [`examples/focus-action.yml`](examples/focus-action.yml) → `.github/workflows/focus.yml`.
84
+ Details: [`docs/ACTION.md`](docs/ACTION.md). Permissions: `contents: read` + `pull-requests: write` only ([`docs/PRIVACY.md`](docs/PRIVACY.md)).
85
+
86
+ ---
87
+
88
+ ## Already exists? (CodeLayers, Valerian, …)
89
+
90
+ Editor tools show hop lists while you type. Focus is **pre-merge decision support**: evidence-only topology, Danger Zones + smart triggers, **one HUD** from `audit --local` to the PR comment. Open source, local, no architecture backend required.
91
+
92
+ ---
93
+
94
+ ## Getting started (from this repo)
95
+
96
+ ```bash
97
+ git clone https://github.com/j0viane/focus.git
98
+ cd focus
99
+ uv sync
100
+ uv run focus scan .
101
+ uv run focus trace src/focus/models.py --out focus-hud.md
102
+ uv run focus audit --local
103
+ ```
104
+
105
+ Unchanged files reuse **`.focus-cache/`** (gitignored). Pass `--no-cache` to force a full re-parse.
106
+
107
+ Optional: copy [`.focus.toml.example`](.focus.toml.example) → `.focus.toml` to tune `fan_out_threshold` (default **3**).
108
+
109
+ Requirements: Python 3.12+. Package name on PyPI: **`focus-hud`** (CLI: `focus`). Publish notes: [`docs/PUBLISH.md`](docs/PUBLISH.md).
110
+
111
+ ```bash
112
+ uv run pytest
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Why "Focus"?
118
+
119
+ The name comes from *Horizon Zero Dawn*. Aloy navigates an inherited world with her **Focus** — an AR device that reveals weak points and danger ahead. A legacy codebase is the same kind of world. This Focus scans it so you change it with intel, not blind faith.
120
+
121
+ *Horizon Zero Dawn and Aloy belong to Guerrilla Games — no affiliation, just admiration.*
122
+
123
+ ---
124
+
125
+ ## Architecture
126
+
127
+ ```mermaid
128
+ flowchart TB
129
+ subgraph scan [Focus Scan]
130
+ TS[AST Index] --> G[Dependency Graph]
131
+ G --> SURF[Surface Detector]
132
+ end
133
+
134
+ subgraph preflight [Blast Radius Engine]
135
+ DIFF[Git Diff / Symbol Target] --> SEED[Changed Symbols]
136
+ SEED --> BFS[Reverse BFS]
137
+ BFS --> DZ[Danger Zone Scorer]
138
+ end
139
+
140
+ subgraph hud [Focus HUD]
141
+ ES[Executive Summary]
142
+ MAP[Mermaid Map]
143
+ BR[Blast Radius Report]
144
+ end
145
+
146
+ scan --> preflight
147
+ preflight --> hud
148
+ hud --> OUT[CLI stdout / GitHub PR comment]
149
+ ```
150
+
151
+ | Layer | Technology |
152
+ |---|---|
153
+ | CLI | Python 3.12+ / Typer |
154
+ | AST | Python `ast` + Tree-sitter (JS/TS) |
155
+ | Graph | NetworkX |
156
+ | Diagrams | Mermaid (native on GitHub) |
157
+ | CI | Opt-in GitHub Action |
158
+
159
+ ---
160
+
161
+ ## Commands
162
+
163
+ | Command | Purpose |
164
+ |---|---|
165
+ | `focus scan [path]` | Index the repo (Python + JS/TS) |
166
+ | `focus trace [file]` | HUD for one file |
167
+ | `focus audit --local` | Working tree vs `main` |
168
+ | `focus audit --base <sha>` | PR / branch range |
169
+ | `focus version` | Installed version |
170
+
171
+ ---
172
+
173
+ ## Roadmap
174
+
175
+ Phase 3 **complete** (CLI + Action + JS/TS + cache). IDE extension and LLM labels are parked — see [`docs/ROADMAP.md`](docs/ROADMAP.md).
176
+
177
+ ---
178
+
179
+ ## Ethics & privacy
180
+
181
+ - **Evidence-based** — no LLM inventing edges
182
+ - **Privacy-by-design** — respects `.gitignore`; no source to model APIs
183
+ - **No surveillance** — structure, not developer identity
184
+ - **Opt-in Action** — minimum token scope
185
+
186
+ | Doc | Contents |
187
+ |---|---|
188
+ | [`docs/DEMO.md`](docs/DEMO.md) | Walkthrough + gallery |
189
+ | [`docs/LAUNCH.md`](docs/LAUNCH.md) | Product Hunt / Show HN drafts |
190
+ | [`docs/ACTION.md`](docs/ACTION.md) | Action install |
191
+ | [`docs/HUD.md`](docs/HUD.md) | HUD schema |
192
+ | [`docs/ETHICS.md`](docs/ETHICS.md) | Responsible use |
193
+ | [`docs/PRIVACY.md`](docs/PRIVACY.md) | Data boundaries |
194
+
195
+ ---
196
+
197
+ ## License
198
+
199
+ [MIT](LICENSE) © 2026 Joviane Bellegarde.
200
+
201
+ ## Author
202
+
203
+ [Joviane Bellegarde](https://github.com/j0viane). Feedback welcome via Issues.
@@ -0,0 +1,174 @@
1
+ # Focus
2
+
3
+ **Blast radius you can defend — evidence-only, before you merge.**
4
+
5
+ Focus answers one question: **what else in this codebase could break because of this change?**
6
+
7
+ It's an **AR HUD for codebases**: a computed import graph (Python + JS/TS) → Mermaid map + Danger Zones. Same HUD in the CLI and on the PR. No LLM inventing edges.
8
+
9
+ > **Not** another AI PR summary. **Not** a hop inventory that cries wolf on every file. Focus stays quiet when the change is boring, and loud when you touch a shared hub.
10
+
11
+ ---
12
+
13
+ ## Try in 60 seconds
14
+
15
+ ```bash
16
+ pip install "focus-hud @ git+https://github.com/j0viane/focus.git"
17
+ # after PyPI publish: pip install focus-hud
18
+
19
+ focus trace path/to/shared_module.py --out focus-hud.md
20
+ # open focus-hud.md → Markdown preview for Mermaid
21
+
22
+ focus audit --local --out focus-hud.md # working tree vs main — before you push
23
+ ```
24
+
25
+ **Demo fixture (no app required):**
26
+
27
+ ```bash
28
+ git clone https://github.com/j0viane/focus.git && cd focus
29
+ uv sync
30
+ uv run focus trace tests/fixtures/glass_box/auth_utils.py \
31
+ --root tests/fixtures/glass_box --out focus-hud.md
32
+ ```
33
+
34
+ Gallery + walkthrough: [`docs/DEMO.md`](docs/DEMO.md) · [`docs/assets/`](docs/assets/)
35
+
36
+ ---
37
+
38
+ ## Why this exists
39
+
40
+ There's a new kind of pressure on developers — and it lands hardest on juniors: walk into a codebase you've never seen, point an AI at it, and ship. The code arrives in seconds. The understanding doesn't.
41
+
42
+ Focus is for the moment right before you push into a codebase that was there long before you. **What the system looks like, and what your change will actually touch** — with evidence you can defend in review.
43
+
44
+ | Moment | Command | You get |
45
+ |---|---|---|
46
+ | AI rewrote a shared function | `focus audit --local` | Blast radius of your working tree vs `main` |
47
+ | Big PR in your queue | Focus Action comment | Skim-or-dig: diagram + Danger Zones, or “low impact” |
48
+ | Inherited a module | `focus trace path/to/file.py` | Everything that depends on it |
49
+
50
+ ---
51
+
52
+ ## GitHub Action (any repo)
53
+
54
+ Copy [`examples/focus-action.yml`](examples/focus-action.yml) → `.github/workflows/focus.yml`.
55
+ Details: [`docs/ACTION.md`](docs/ACTION.md). Permissions: `contents: read` + `pull-requests: write` only ([`docs/PRIVACY.md`](docs/PRIVACY.md)).
56
+
57
+ ---
58
+
59
+ ## Already exists? (CodeLayers, Valerian, …)
60
+
61
+ Editor tools show hop lists while you type. Focus is **pre-merge decision support**: evidence-only topology, Danger Zones + smart triggers, **one HUD** from `audit --local` to the PR comment. Open source, local, no architecture backend required.
62
+
63
+ ---
64
+
65
+ ## Getting started (from this repo)
66
+
67
+ ```bash
68
+ git clone https://github.com/j0viane/focus.git
69
+ cd focus
70
+ uv sync
71
+ uv run focus scan .
72
+ uv run focus trace src/focus/models.py --out focus-hud.md
73
+ uv run focus audit --local
74
+ ```
75
+
76
+ Unchanged files reuse **`.focus-cache/`** (gitignored). Pass `--no-cache` to force a full re-parse.
77
+
78
+ Optional: copy [`.focus.toml.example`](.focus.toml.example) → `.focus.toml` to tune `fan_out_threshold` (default **3**).
79
+
80
+ Requirements: Python 3.12+. Package name on PyPI: **`focus-hud`** (CLI: `focus`). Publish notes: [`docs/PUBLISH.md`](docs/PUBLISH.md).
81
+
82
+ ```bash
83
+ uv run pytest
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Why "Focus"?
89
+
90
+ The name comes from *Horizon Zero Dawn*. Aloy navigates an inherited world with her **Focus** — an AR device that reveals weak points and danger ahead. A legacy codebase is the same kind of world. This Focus scans it so you change it with intel, not blind faith.
91
+
92
+ *Horizon Zero Dawn and Aloy belong to Guerrilla Games — no affiliation, just admiration.*
93
+
94
+ ---
95
+
96
+ ## Architecture
97
+
98
+ ```mermaid
99
+ flowchart TB
100
+ subgraph scan [Focus Scan]
101
+ TS[AST Index] --> G[Dependency Graph]
102
+ G --> SURF[Surface Detector]
103
+ end
104
+
105
+ subgraph preflight [Blast Radius Engine]
106
+ DIFF[Git Diff / Symbol Target] --> SEED[Changed Symbols]
107
+ SEED --> BFS[Reverse BFS]
108
+ BFS --> DZ[Danger Zone Scorer]
109
+ end
110
+
111
+ subgraph hud [Focus HUD]
112
+ ES[Executive Summary]
113
+ MAP[Mermaid Map]
114
+ BR[Blast Radius Report]
115
+ end
116
+
117
+ scan --> preflight
118
+ preflight --> hud
119
+ hud --> OUT[CLI stdout / GitHub PR comment]
120
+ ```
121
+
122
+ | Layer | Technology |
123
+ |---|---|
124
+ | CLI | Python 3.12+ / Typer |
125
+ | AST | Python `ast` + Tree-sitter (JS/TS) |
126
+ | Graph | NetworkX |
127
+ | Diagrams | Mermaid (native on GitHub) |
128
+ | CI | Opt-in GitHub Action |
129
+
130
+ ---
131
+
132
+ ## Commands
133
+
134
+ | Command | Purpose |
135
+ |---|---|
136
+ | `focus scan [path]` | Index the repo (Python + JS/TS) |
137
+ | `focus trace [file]` | HUD for one file |
138
+ | `focus audit --local` | Working tree vs `main` |
139
+ | `focus audit --base <sha>` | PR / branch range |
140
+ | `focus version` | Installed version |
141
+
142
+ ---
143
+
144
+ ## Roadmap
145
+
146
+ Phase 3 **complete** (CLI + Action + JS/TS + cache). IDE extension and LLM labels are parked — see [`docs/ROADMAP.md`](docs/ROADMAP.md).
147
+
148
+ ---
149
+
150
+ ## Ethics & privacy
151
+
152
+ - **Evidence-based** — no LLM inventing edges
153
+ - **Privacy-by-design** — respects `.gitignore`; no source to model APIs
154
+ - **No surveillance** — structure, not developer identity
155
+ - **Opt-in Action** — minimum token scope
156
+
157
+ | Doc | Contents |
158
+ |---|---|
159
+ | [`docs/DEMO.md`](docs/DEMO.md) | Walkthrough + gallery |
160
+ | [`docs/LAUNCH.md`](docs/LAUNCH.md) | Product Hunt / Show HN drafts |
161
+ | [`docs/ACTION.md`](docs/ACTION.md) | Action install |
162
+ | [`docs/HUD.md`](docs/HUD.md) | HUD schema |
163
+ | [`docs/ETHICS.md`](docs/ETHICS.md) | Responsible use |
164
+ | [`docs/PRIVACY.md`](docs/PRIVACY.md) | Data boundaries |
165
+
166
+ ---
167
+
168
+ ## License
169
+
170
+ [MIT](LICENSE) © 2026 Joviane Bellegarde.
171
+
172
+ ## Author
173
+
174
+ [Joviane Bellegarde](https://github.com/j0viane). Feedback welcome via Issues.