CodeMentorFlow
CodeMentorFlow is a Visual Studio Code extension that performs privacy-first, real-time code review for teams. It surfaces local best-practice suggestions as you edit, keeps all analysis on your machine, and offers fast ways to accept or dismiss feedback inline.
✨ Features
- Workspace-aware scanning – Recursively scans nested folders using configurable include/exclude globs.
- Real-time suggestions – Debounced analysis runs on save and as you type to keep feedback fresh without blocking.
- Inline guidance – Diagnostics and CodeLens entries highlight issues and provide one-click accept/dismiss controls.
- Custom rules – Ships with complexity and documentation rules; extendable with additional local heuristics.
- Team-ready privacy – Never sends code or metrics off-device. All processing stays within the local VS Code process.
🛠 Project setup
Initialize from the VS Code extension generator (one-time):
npm install -g yo generator-code
yo code
Choose the TypeScript option, provide the extension name CodeMentorFlow, and accept the default scaffolding. This repository already mirrors the output, so you only need to repeat these commands if you want to regenerate the base template elsewhere.
Install dependencies:
npm install
Compile the extension:
npm run compile
Launch inside VS Code: Press F5 or run the Run CodeMentorFlow launch configuration to open a new Extension Development Host.
⚙️ Configuration
Adjust behaviour through Settings ▸ Extensions ▸ CodeMentorFlow:
| Setting |
Description |
Default |
codementorflow.scan.include |
Glob patterns to include during recursive scans. |
**/*.{ts,tsx,js,jsx,py,java,cs} |
codementorflow.scan.exclude |
Glob patterns to ignore (e.g., build output and dependencies). |
node_modules, .git, dist, out, build |
codementorflow.performance.maxFiles |
Max files evaluated per explicit scan. |
200 |
codementorflow.performance.maxFileSizeKB |
Skip files larger than this size. |
512 |
codementorflow.rules.complexity.* |
Set thresholds for function length and branching heuristics. |
enabled=true, maxLines=60, maxBranching=10 |
codementorflow.rules.missingDocumentation.* |
Enable/disable doc checks and target languages. |
Enabled for JS/TS |
🔍 Rule set overview
| Rule |
Trigger |
Suggestion |
complexity/function-length |
Functions exceeding configured line or branching thresholds. |
Prompts a refactor; highlights the function definition line. |
documentation/missing |
Functions without a leading doc block in supported languages. |
Offers to insert a documentation stub aligned with indentation. |
Extend the rule set by adding new entries to RULES in src/analyzer/rules.ts. Each rule receives the document and live configuration, returning Suggestion objects with optional fixes.
🧠 Architecture highlights
src/extension.ts wires activation, workspace listeners, diagnostics, and CodeLens.
src/analyzer/* handles rule orchestration and language-agnostic pattern matching.
src/services/* includes configuration access, debounced scheduling, file scanning, and suggestion state.
test/ hosts mocha-based integration tests executed via the VS Code test runner.
✅ Testing & quality gates
npm run lint
npm test
The test suite spins up a VS Code Extension Development Host instance, writes temporary files, and asserts the expected suggestions. Linting uses ESLint with TypeScript-aware rules to keep the codebase clean.
📦 Packaging & distribution
Bump the version in package.json and update CHANGELOG.md.
Run the prepublish step (compilation happens automatically):
npm run vscode:prepublish
Package a VSIX bundle:
npm run package
Share the generated .vsix internally or publish to the VS Code Marketplace with vsce publish (requires a publisher ID and Personal Access Token).
🧪 Suggested manual test flow
- Open a project with at least one TypeScript or JavaScript file.
- Introduce a long function without documentation.
- Save the file and observe diagnostics & CodeLens suggestions.
- Use CodeMentorFlow: Scan Workspace from the Command Palette to trigger a recursive analysis.
- Accept the documentation suggestion to auto-generate a stub, or dismiss suggestions you want to ignore.
- All computations stay local; no HTTP requests or telemetry are emitted.
- Large files and dependency directories are skipped by default.
- Debounced analysis prevents redundant work while typing; adjust the delay in
DebouncedScheduler if your team prefers faster or slower feedback.
📚 Documentation checklist
- Inline comments throughout the code explain rule heuristics and controller responsibilities.
- Update
CHANGELOG.md with noteworthy releases.
- Provide teammate onboarding in this README so teams can adopt the extension quickly.
Happy mentoring! 🎯
| |