中文 | English
IntentLens 是一款 VS Code 扩展,用更易懂的方式解释开发代码与 diff,适合读遗留代码、做代码评审与新成员上手。
- 解释选中代码:用自然语言快速说明这段代码的意图。
- 解释 Diff 影响:告诉你改动带来的行为变化与风险点。
- 新手模式:教学式解释,适合新人、导师与评审场景。
- 配置设置:
intentlens.apiKey:OpenAI 兼容 API Key。DeepSeek 的 Key 一般以sk-开头。intentlens.baseUrl:API 地址(默认:https://api.openai.com/v1,也可配置 https://api.deepseek.com/v1)。intentlens.model:模型名(默认:gpt-4o-mini)。intentlens.beginnerMode:开启教学式解释。
可选模型建议(DeepSeek):
日常写代码 / 快速解释 / 意图识别
推荐模型:✅deepseek-chat
深度推理 / 复杂问题 / 架构分析
推荐模型:✅deepseek-reasoner
- 使用命令:
- 命令面板:
- "IntentLens: Explain Selected Code(解释选中代码)"
- "IntentLens: Explain Diff Impact(解释 Diff 影响)"
- 右键菜单:已支持选中代码后直接右键调用。
- 命令面板:
Explain Selected Code
结论:将组件名从
loadingState改为loadingState1
行为变化:旧引用可能失效,导致组件无法渲染或使用
风险区域:所有引用处需同步更新,动态组件或路由更需关注
建议检查:更新引用、验证渲染与样式、更新相关测试
Explain Diff Impact
结论:组件名变更会影响引用一致性
影响:未更新的引用会产生渲染失败
测试:引用点检查、样式验证、回归测试覆盖
- 新人上手 React Hook:选中组件运行 Explain Selected Code。
- 表单校验改动评审:运行 Explain Diff Impact 检查行为变化与测试点。
- 排查副作用与依赖:用新手模式理解异步流程与 effect 触发。
- 评审效率提升:10 秒内理解意图与影响。
- 无需改变流程:只需两条命令即可使用。
- 适合上手与辅导:像资深同事讲解代码。
- 降低反复沟通:提前提示风险与缺失测试。
- 兼容遗留代码:不必逐行阅读即可掌握意图。
- 灵活安全:支持自建或企业网关。
- 仅发送选中代码或当前文件的 diff 到配置的 LLM 端点。
- 企业环境可接内部网关或 Azure OpenAI。
- 不会上传整个仓库。
- 没有输出?
- 可能未选中代码、文件无 diff,或未设置
intentlens.apiKey。
- 可能未选中代码、文件无 diff,或未设置
- 无法获取 git diff?
- 文件不在 Git 仓库中,或系统找不到
git。
- 文件不在 Git 仓库中,或系统找不到
- 支持更多语言/框架吗?
- 支持。提示词与语言无关,可按你的技术栈调整。
- 能用本地模型吗?
- 可以,只要提供 OpenAI 兼容的
chat/completions端点。
- 可以,只要提供 OpenAI 兼容的
- 会上传整个仓库吗?
- 不会,仅发送选中代码或当前文件 diff。
- 和 Copilot 有什么区别?
- IntentLens 专注解释意图与影响,不做代码生成。
IntentLens is a VS Code extension that explains frontend code and diffs in human terms, ideal for reading legacy code, reviewing changes, and onboarding new team members.
- Explain Selected Code: Understand what a block of code intends to do in seconds.
- Explain Diff Impact: See how a change affects behavior and risk areas.
- Beginner Mode: Teaching-style explanations for new developers, mentors, and reviewers.
- Configure settings:
intentlens.apiKey: Your OpenAI-compatible API key. DeepSeek keys usually start withsk-.intentlens.baseUrl: API base URL (default: https://api.openai.com/v1, or https://api.deepseek.com/v1).intentlens.model: Model name (default: gpt-4o-mini).intentlens.beginnerMode: Teaching-style explanations for selected code.
Model suggestions (DeepSeek):
Daily coding / quick explanation / intent recognition
Recommended model: ✅deepseek-chat
Deep reasoning / complex problems / architecture analysis
Recommended model: ✅deepseek-reasoner
- Use the commands:
- Command Palette:
- "IntentLens: Explain Selected Code (解释选中代码)"
- "IntentLens: Explain Diff Impact (解释 Diff 影响)"
- Right-click menu: available after selecting code.
- Command Palette:
Explain Selected Code
Result: Component renamed from
loadingStatetoloadingState1
Behavior: Old references may break rendering
Risk: All references must be updated, especially dynamic usage
Checks: Update references, verify render/styles, refresh tests
Explain Diff Impact
Result: Rename affects reference consistency
Impact: Stale references cause render failures
Tests: Reference audit, style verification, regression coverage
- Onboarding a new dev into a React Hook: select a hook-heavy component and run Explain Selected Code.
- Reviewing a form validation diff: run Explain Diff Impact to spot behavior changes and test ideas.
- Investigating side effects and dependencies: use Beginner Mode to surface async flow and effect triggers.
- Instant clarity in reviews: understand intent and impact in ~10 seconds.
- No workflow changes: works inside VS Code with two simple commands.
- Great for onboarding: explains code like a senior pairing session.
- Reduces review churn: highlights risks and missing tests early.
- Handles legacy code: summarize intent without reading line-by-line.
- Safe and flexible: use your own endpoint or company gateway.
- The extension sends selected code or file diffs to the configured LLM endpoint.
- For enterprise usage, route through an internal gateway or Azure OpenAI.
- IntentLens does not upload entire repositories.
- Why is there no output?
- You might not have selected code, the file has no diff, or
intentlens.apiKeyis not set.
- You might not have selected code, the file has no diff, or
- Why can't git diff be fetched?
- The file may not be in a Git repo, or
gitis not available in PATH.
- The file may not be in a Git repo, or
- Can it support more languages or frameworks?
- Yes. The prompts are language-agnostic; tweak them for your stack.
- Can I use a local model?
- Yes, if it exposes an OpenAI-compatible
chat/completionsendpoint.
- Yes, if it exposes an OpenAI-compatible
- Does it upload my whole repo?
- No. Only the selected code or the unified diff for the active file.
- How is this different from Copilot?
- IntentLens focuses on explaining intent and impact, not code generation.
