Lenspr

io.github.kyrylopr由 GitHub 帳號 kyrylopr 發布v0.1.1更新於 Oct 24, 2026

Stop vibecoding blind. Code graph so your AI stops breaking things across your codebase.

概覽

AI 產生的概覽

為程式碼庫建立本機相依圖,讓 AI 助理在改程式前看到呼叫端、被呼叫端、測試與影響範圍。

可以做什麼
LensPR 把本機程式碼庫解析成相依圖,並提供 12 組、60 多個 lens_* 工具。導覽與搜尋工具一次呼叫即可回傳原始碼、呼叫端、被呼叫端與相關測試;分析工具在改動前給出影響範圍與嚴重等級;品質工具評估健康度、覆蓋率、死程式碼與架構規則。它也支援以函式為單位的 git blame 與歷史、SQL、Docker、環境變數與 CI/CD 的基礎設施對應,以及工作階段記憶與標註。
適用情境
當 AI 程式助理要修改 Python 或 TypeScript/JavaScript 專案、需要結構資訊以避免破壞遠處相依時適用。適合重構前的影響檢查、死程式碼與覆蓋率審查、架構規則約束,以及前後端跨語言呼叫鏈追蹤。
執行需求
以本機程序方式從 PyPI 安裝(pip install 'lenspr[all]')。需要 Python 3.11+,僅支援 macOS 或 Linux,不支援 Windows;TypeScript/JavaScript 專案還需 Node.js 18+。安裝後執行 lenspr init 與 lenspr setup,並重新啟動 IDE。未宣告帳號、API 金鑰或環境變數。
安裝前請注意
修改類工具會寫入、重新命名、修補與刪除程式碼節點(lens_update_node、lens_patch_node、lens_add_node、lens_delete_node、lens_rename、lens_batch),lens_run_tests 會執行測試,因此可能改動工作區檔案。圖資料保存在本機並由原始碼重建,建議把 .lens/ 加入 .gitignore。目前為 alpha 版本,可能有粗糙之處。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Lenspr,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[LensPR]

Code intelligence for AI coding agents. Your AI sees dependencies before making changes.

Alpha (0.1.x) — works on real projects, used daily by the author. Expect rough edges.

AI assistants edit your code one file at a time. They don't see dependencies. They grep, read, guess — and break things three files away.

LensPR builds a dependency graph of your codebase and gives your AI structural understanding before it changes anything.

Quick Start

Requires Python 3.11+, macOS or Linux. For TypeScript/JS projects, also Node.js 18+.

bash
pip install 'lenspr[all]'lenspr init .lenspr setup .

Restart your IDE. Done. Your AI now has lens_* tools.

Add .lens/ to your .gitignore — the graph is local and rebuilt from source.


What It Does

"What depends on this function?"

One call returns source code, who calls it, what it calls, and related tests:

> lens_context("auth.login_handler")
source: 42 linescallers: auth_routes.create_routes, test_auth.test_login_successcallees: db.get_user, crypto.verify_password, jwt.create_tokentests: test_login_success, test_login_wrong_password

Without LensPR your AI makes 5-7 grep/read calls and still misses things. With LensPR — one call, full picture.

"What breaks if I change this?"

Before any modification, the AI sees the blast radius:

> lens_check_impact("models.User")
severity: CRITICALdirect_dependents: 15indirect_dependents: 23affected_modules: auth, payments, notificationstests_covering: 3

The AI warns you, changes its approach, or asks for confirmation. No more blind edits.

"How healthy is this codebase?"

> lens_vibecheck()
score: 86/100 (B)  test_coverage:    17/25 — 67% functions tested  dead_code:        20/20 — 0% dead code  circular_imports: 15/15 — 0 cycles  architecture:     12/15 — 1 violation  documentation:     8/10 — 81% documented  graph_confidence: 14/15 — 94% edges resolved

Track whether the codebase is improving or degrading over time.

Cross-language visibility

LensPR connects frontend and backend into a single graph:

LoginModal.tsx → fetch("/api/auth/login")                        ↓ CALLS_APIBackend:  @router.post("/login") → login_handler()            → db.query(User)        [reads: users]            → verify_password()            → create_jwt_token()

Also tracks: database tables, Docker services, env vars, CI/CD workflows, SQL migrations.


Works With

IDESetup
Claude Codelenspr setup . — automatic
CursorCopy .mcp.json to .cursor/mcp.json
Any MCP clientlenspr serve <path>

Languages: Python (95%+ resolution via Jedi/Pyright) and TypeScript/JavaScript (85-95% via tree-sitter + TS Compiler API).

Infrastructure: .sql files, Dockerfiles, docker-compose.yml, GitHub Actions workflows, .env files — all parsed into the same graph.

Everything runs locally. Your code never leaves your machine.


Key Features

Impact AnalysisSeverity (LOW → CRITICAL) before any change
One-Call ContextSource + callers + callees + tests in one request
Cross-LanguageFrontend HTTP → backend routes, DB tables, Docker, env vars, CI/CD
Surgical EditsTargeted find/replace within a function — no full file rewrites
Dead CodeFind unreachable functions (Django, FastAPI, Celery entry points)
Architecture RulesEnforce layer boundaries — violations warn before changes apply
Git per FunctionBlame, history, commit scope at function level
Session MemoryAI picks up where it left off across context resets
Auto-SyncFile watcher updates graph on every save
Health Score0-100 score across 6 dimensions — track quality over time

60+ tools organized in 12 groups — enable only what you need with lenspr tools.

All tools by category

Navigation & Search (8): lens_context, lens_get_node, lens_search, lens_grep, lens_find_usages, lens_get_structure, lens_list_nodes, lens_get_connections

Modification (6): lens_update_node, lens_patch_node, lens_add_node, lens_delete_node, lens_rename, lens_batch

Analysis (6): lens_check_impact, lens_validate_change, lens_health, lens_dead_code, lens_dependencies, lens_diff

Quality (7): lens_vibecheck, lens_nfr_check, lens_test_coverage, lens_security_scan, lens_dep_audit, lens_fix_plan, lens_generate_test_skeleton

Architecture (9): lens_arch_rule_add, lens_arch_rule_list, lens_arch_rule_delete, lens_arch_check, lens_class_metrics, lens_project_metrics, lens_largest_classes, lens_compare_classes, lens_components

Git (4): lens_blame, lens_node_history, lens_commit_scope, lens_recent_changes

Infrastructure (5): lens_api_map, lens_db_map, lens_env_map, lens_ffi_map, lens_infra_map

Testing & Tracing (3): lens_run_tests, lens_trace, lens_trace_stats

Annotations (5): lens_annotate, lens_save_annotation, lens_batch_save_annotations, lens_annotate_batch, lens_annotation_stats

Session (4): lens_session_write, lens_session_read, lens_session_handoff, lens_resume

Temporal (2): lens_hotspots, lens_node_timeline

Explanation (1): lens_explain


Known Limitations

  • Windows — not supported. macOS and Linux only.
  • self.method() calls — static parser can't fully resolve instance method dispatch. Workaround: lens_trace (Python 3.12+) resolves these at runtime.
  • Go, Rust, Java — not yet supported. Parser interface is ready for contributors.
  • Dynamic code — getattr, eval, dynamic imports can't be tracked statically.

Contributing

Try it. If it breaks, tell me.

  • Bug reports — even "this doesn't work" is helpful
  • Language parsers — Go, Rust, Java (BaseParser interface is ready)
  • Ideas — open an issue

License

MIT


Built because AI kept breaking my code.

來源:README.md,提交 87bd1c9

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分