Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,55 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.0] - 2026-01-28

### Added - Smart Enforcement System
- **New `verify` tool** - Quality gate that must pass before presenting code to user
- Validates tests are provided (TDD compliance)
- Checks for interfaces (DI compliance)
- Detects critical code issues
- Returns PASS/FAIL with specific feedback

- **Real code analysis in `validate` tool**
- Regex-based anti-pattern detection (15+ patterns)
- Method/class length analysis
- Quality score calculation (0-100)
- Actionable suggestions for each issue

- **New `code-analyzer` module** (`src/analysis/code-analyzer.ts`)
- Detects: empty catch, hardcoded secrets, eval, innerHTML, generic exceptions
- Detects: console statements, field injection, any type, loose equality
- Measures: method lines, class lines, interface count, test count

- **Mandatory Checkpoint JSON** in `get_context` output
- Forces LLM to commit to architecture decisions before coding
- Includes: interfaces_to_create, tests_to_write, quality_commitments

- **Contractual Response Format** in `get_context` output
- Enforces order: CHECKPOINT → INTERFACES → TESTS → IMPLEMENTATION → SELF-REVIEW
- Prevents skipping TDD steps

- **Mandatory Self-Review JSON** in `get_context` output
- LLM must audit own code: methods_over_20_lines, tests_written, etc.
- Must achieve quality_score >= 7 before presenting code

### Changed
- `get_context` output now includes Smart Enforcement sections (~400 tokens extra)
- `validate` returns real analysis instead of just checklist
- Added `verify` to tool list and dispatcher

### Technical
- 52 new tests (37 for analyzer, 15 for verify)
- Coverage maintained at 82.62%
- No new external dependencies

### Breaking Changes
- `validate` output format changed from checklist to analysis results

---

## [1.1.0] - 2026-01-15

### Added
- `search_standards` tool for querying documentation by topic (kafka, docker, testing, etc.)
- Enhanced Zod schemas for CQRS, Event-Driven, ArchUnit, HttpClients, Observability
Expand Down
147 changes: 142 additions & 5 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,26 @@ Complete reference for Corbat MCP tools, resources, and prompts.

### validate

Validate code against coding standards.
**Real code analysis** - Analyzes code and returns specific issues with suggestions.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `code` | string | Yes | The code to validate |
| `task_type` | enum | No | One of: `feature`, `bugfix`, `refactor`, `test` |
| `task_type` | enum | No | One of: `feature`, `bugfix`, `refactor`, `test`, `security`, `performance` |

**Detects:**
- Anti-patterns: empty catch, hardcoded secrets, eval, innerHTML, generic exceptions
- Code quality: console statements, field injection, any type, loose equality
- Structure: method length > 20 lines, class length > 200 lines
- Missing: tests, interfaces

**Returns:**
- Code quality thresholds
- Guardrails for task type
- Review checklist template
- Quality score (0-100)
- CRITICAL issues (must fix)
- WARNINGS (should fix)
- INFO (optional)
- Metrics (lines, methods, classes, interfaces, tests)
- PASSED/NEEDS WORK verdict

**Example:**
```json
Expand All @@ -54,6 +63,134 @@ Validate code against coding standards.
}
```

**Example Output:**
```markdown
# ✅ Code Analysis Results

**GOOD: Code follows most best practices**

**Score: 78/100**

---

## Metrics

| Metric | Value |
|--------|-------|
| Total Lines | 45 |
| Methods | 3 |
| Interfaces | 1 |
| Tests | 5 |

---

## Warnings (should fix)

- **Line 12:** Console statement found
- Suggestion: Use a proper logging framework in production code

---

## Verdict

**PASSED** - Code meets quality standards.
```

---

### verify (NEW in v2.0)

**Quality gate** - REQUIRED before presenting code to user.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `code` | string | Yes | All implementation code |
| `tests` | string | Yes* | All test code (*required for TDD compliance) |
| `interfaces` | string | No | All interfaces and type definitions |
| `task_type` | enum | No | One of: `feature`, `bugfix`, `refactor`, `test`, `security`, `performance` |

**Checks:**
1. Tests are provided (TDD compliance)
2. Interfaces exist (DI compliance)
3. No critical code issues
4. Quality score >= 50

**Returns:**
- `PASS`: Code meets standards - present to user
- `FAIL`: Issues listed - fix and verify again

**Workflow:**
```
1. Call get_context() → get guidelines
2. Complete checkpoint JSON
3. Write code: INTERFACES → TESTS → IMPLEMENTATION
4. Complete self-review JSON
5. Call verify() → must PASS
6. If FAIL: fix issues, call verify again
7. If PASS: present to user
```

**Example:**
```json
{
"code": "class UserServiceImpl implements UserService { ... }",
"tests": "describe('UserService', () => { ... })",
"interfaces": "interface UserService { getUser(id: string): User; }",
"task_type": "feature"
}
```

**Example PASS Output:**
```markdown
# ✅ VERIFICATION PASSED

**Score: 85/100**

The code meets quality standards and is ready to present to the user.

---

## Verification Summary

- Tests provided: Yes
- Interfaces provided: Yes
- Critical issues: 0
- Warnings: 2
- Test count: 5
- Interface count: 2

---

**You may now present this code to the user.**
```

**Example FAIL Output:**
```markdown
# ❌ VERIFICATION FAILED

**Score: 45/100**

The code does not meet quality standards. Fix the issues below and verify again.

---

## Issues to Fix (Blocking)

- No tests provided - TDD requires tests before/with implementation
- 2 critical code issue(s) detected - see details below

---

## Critical Code Issues

- **Line 5:** Potential hardcoded secret detected
- Fix: Use environment variables or a secrets manager

---

**Fix these issues and call `verify` again before presenting code to user.**
```

---

### search
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@corbat-tech/coding-standards-mcp",
"version": "1.1.0",
"version": "2.0.0",
"description": "AI coding standards that apply themselves - MCP server that enforces production-grade code",
"mcpName": "io.github.corbat-tech/coding-standards",
"type": "module",
Expand Down
Loading