Commit Graph

59 Commits

Author SHA1 Message Date
imfozilbek
f6bb65f2f1 chore: bump version to 0.7.5-beta.1 2025-11-25 15:48:31 +05:00
imfozilbek
8916ce9eab feat(cli): add AI Agent Instructions to --help output
Add dedicated section in help for AI coding assistants with:
- Step-by-step workflow (scan → fix → verify → expand)
- Recommended commands for each step
- Output format description for parsing
- Priority order guidance (CRITICAL → HIGH → MEDIUM → LOW)

This helps AI agents (Claude, Copilot, Cursor) immediately
understand how to use Guardian and take action.
2025-11-25 15:48:03 +05:00
imfozilbek
24f54d4b57 docs: add hardening releases v0.7.5-v0.7.9 to ROADMAP
Plan internal improvements before v0.8.0:
- v0.7.5: Refactor AnalyzeProject use-case (614 -> ~100 lines)
- v0.7.6: Refactor CLI module (470 -> ~100 lines)
- v0.7.7: Improve test coverage for domain files
- v0.7.8: Add E2E tests for pipeline and CLI
- v0.7.9: Refactor large detectors (optional)

Each release scoped to fit single session (~128K tokens).
2025-11-25 15:42:12 +05:00
imfozilbek
d038f90bd2 docs: add SecretDetector feature to ROADMAP v0.8.0
- Add comprehensive SecretDetector feature specification for v0.8.0
- Shift all future roadmap versions by +1 (0.8.0→0.9.0, 0.9.0→0.10.0, etc.)
- Document Secretlint integration approach
- Specify 350+ secret patterns detection (AWS, GitHub, NPM, SSH, GCP, Slack)
- Define architecture with ISecretDetector interface and SecretViolation value object
- Highlight separation from HardcodeDetector (two focused detectors)
- Target: Q1 2025, Priority: CRITICAL
2025-11-25 15:18:27 +05:00
imfozilbek
e79874e420 chore: bump version to 0.7.4 2025-11-25 13:27:38 +05:00
imfozilbek
1663d191ee docs: update CHANGELOG for v0.7.4 v0.7.4 2025-11-25 12:16:17 +05:00
imfozilbek
7b4cb60f13 feat: reduce false positives in hardcode detector by 35%
Add TypeScript-aware filtering to HardcodeDetector to ignore legitimate
language constructs that are not actually hardcoded values.

Changes:
- Add detection and filtering of TypeScript type contexts:
  * Union types (type Status = 'active' | 'inactive')
  * Interface property types (interface { mode: 'development' })
  * Type assertions (as 'read' | 'write')
  * typeof checks (typeof x === 'string')
- Add Symbol() call detection for DI container tokens
- Add import() dynamic import detection
- Extend constants file patterns to include tokens.ts/tokens.js
- Add 13 new tests covering TypeScript type context filtering

Impact:
- Tested on real project (puaro/core): 985 → 633 issues (35.7% reduction)
- All 345 tests pass
- Zero new linting errors
2025-11-25 12:12:36 +05:00
imfozilbek
33d763c41b fix: allow internal bounded context imports in aggregate detection (v0.7.3) v0.7.3 2025-11-25 00:54:03 +05:00
imfozilbek
3cd97c6197 fix: add errors/exceptions folders to DDD non-aggregate list (v0.7.2) v0.7.2 2025-11-25 00:43:41 +05:00
imfozilbek
8dd445995d fix: eliminate magic strings and fix aggregate boundary detection
- Extract DDD folder names and repository method suggestions to constants
- Fix regex pattern to support relative paths (domain/... without leading /)
- Add non-aggregate folder exclusions (constants, shared, factories, etc.)
- Remove findAll, exists, count from ORM_QUERY_METHODS (valid domain methods)
- Add exists, count, countBy patterns to domainMethodPatterns
- Add aggregate boundary test examples
v0.7.1
2025-11-25 00:29:02 +05:00
imfozilbek
c75738ba51 feat: add aggregate boundary validation (v0.7.0)
Implement DDD aggregate boundary validation to detect and prevent direct
entity references across aggregate boundaries.

Features:
- Detect direct entity imports between aggregates
- Allow only ID or Value Object references
- Support multiple folder structures (domain/aggregates/*, domain/*, domain/entities/*)
- Filter allowed imports (value-objects, events, repositories, services)
- Critical severity level for violations
- 41 comprehensive tests with 92.55% coverage
- CLI output with detailed suggestions
- Examples of good and bad patterns

Breaking changes: None
Backwards compatible: Yes
v0.7.0
2025-11-24 23:54:16 +05:00
imfozilbek
83b5dccee4 fix: improve repository method name suggestions and patterns
- Add smart context-aware suggestions for repository method names
  - queryUsers() → search, findBy[Property]
  - selectById() → findBy[Property], get[Entity]
  - insertUser() → create, add[Entity], store[Entity]
  - And more intelligent pattern matching

- Expand domain method patterns support
  - find*() methods (findNodes, findNodeById, findSimilar)
  - saveAll() batch operations
  - deleteBy*() methods (deleteByPath, deleteById)
  - deleteAll() clear operations
  - add*() methods (addRelationship, addItem)
  - initializeCollection() initialization

- Remove findAll from ORM blacklist (valid domain method)

- Reduce complexity in suggestDomainMethodName (22 → 9)

Version 0.6.4
v0.6.4
2025-11-24 23:49:49 +05:00
imfozilbek
5a648e2c29 fix: reduce false positives in Repository Pattern detection
- Added 11 new valid DDD repository method patterns
- Support for has*(), is*(), exists*(), clear*(), store*() methods
- Support for lifecycle methods: initialize(), close(), connect(), disconnect()
- Fixes issue where valid DDD patterns were flagged as violations
- Better alignment with real-world Domain-Driven Design practices

This reduces false positives in projects using cache repositories,
connection management, and domain-specific query methods.

Version: 0.6.3
v0.6.3
2025-11-24 23:04:57 +05:00
imfozilbek
d50cbe1a97 docs: add research-backed documentation for v0.6.2
- Added docs/WHY.md with user-friendly rule explanations and authoritative sources
- Added docs/RESEARCH_CITATIONS.md with 551 lines of academic and industry references
- Updated README.md with micro-citations under each feature
- Enhanced CLI help with 'BACKED BY RESEARCH' section
- Updated AI tools mentions across all docs (GitHub Copilot, Cursor, Windsurf, Claude, ChatGPT, Cline)
- Organized documentation structure: moved RESEARCH_CITATIONS.md to docs/
- Version bump: 0.6.1 -> 0.6.2

Research backing includes:
- Academia: MIT Course 6.031, ScienceDirect studies
- Books: Clean Architecture (Martin 2017), DDD (Evans 2003)
- Industry: Google, Microsoft, Airbnb style guides, SonarQube
- Experts: Martin Fowler, Robert C. Martin, Eric Evans, Alistair Cockburn
v0.6.2
2025-11-24 22:51:35 +05:00
imfozilbek
3ddcff1be3 docs: enhance CLI help system for AI agents and users
Improved guardian --help with comprehensive, actionable information:
- Add DETECTS section with quick fix instructions for all 8 violation types
- Add SEVERITY LEVELS explanation (CRITICAL → LOW)
- Add step-by-step WORKFLOW guide
- Add 7 practical EXAMPLES covering common use cases
- Add HOW TO FIX COMMON ISSUES reference section

Technical improvements:
- Extract all help text strings to CLI_HELP_TEXT constants
- Fix 17 hardcoded string violations
- Maintain Single Source of Truth principle
- Zero violations in Guardian's own codebase

The help system now provides complete context for autonomous AI agents
and clear guidance for human developers.
v0.6.1
2025-11-24 21:53:41 +05:00
imfozilbek
452d9aafd0 docs: update ROADMAP to v0.6.0
- Mark v0.6.0 as released
- Add comprehensive v0.6.0 section with all features
- Shift future versions (0.7.0 → 0.8.0, etc.)
- Update last modified date
2025-11-24 21:37:11 +05:00
imfozilbek
a72b4ce167 chore: bump version to 0.6.0
- Update version to 0.6.0 (minor release)
- Add comprehensive CHANGELOG entry for v0.6.0
- Document all features, changes, fixes, and removals
v0.6.0
2025-11-24 21:31:50 +05:00
imfozilbek
7df48c0bd2 docs: add development workflow to CLAUDE.md
- Add complete feature development & release workflow
- Document 6 phases: Planning, Quality Checks, Documentation, Verification, Commit & Version, Publication
- Add quick checklist for new features
- Add common workflows (CLI option, detector, technical debt)
- Add debugging tips for build, test, and coverage issues
- Update Important Notes with best practices
2025-11-24 21:29:26 +05:00
imfozilbek
4c0fc7185a docs: update TODO with technical debt and recent changes
- Add low-coverage files to technical debt (SourceFile, ProjectPath, RepositoryViolation, ValueObject)
- Update test statistics (10 test files, 292 tests, 90.63% coverage)
- Add v0.5.2 section with limit feature and ESLint cleanup
- Document all completed tasks from this release
2025-11-24 21:29:02 +05:00
imfozilbek
b73d736d34 docs: update README with new features
- Add Entity Exposure Detection to features
- Add Dependency Direction Enforcement to features
- Add Repository Pattern Validation to features
- Update API documentation with all 8 violation types
- Add severity levels to all interfaces
- Document --limit option with examples
- Update ProjectMetrics interface
- Update test statistics (292 tests, 90.63% coverage)
2025-11-24 21:28:43 +05:00
imfozilbek
3169936c75 refactor: remove dead code
- Remove unused IBaseRepository interface
- Remove IBaseRepository export from domain/index.ts
- Fix repository pattern violations detected by Guardian
2025-11-24 21:28:21 +05:00
imfozilbek
8654beb43d fix: remove unused imports and variables
- Remove unused SEVERITY_LEVELS import from AnalyzeProject.ts
- Prefix unused fileName variable with underscore in HardcodeDetector.ts
- Replace || with ?? for nullish coalescing
2025-11-24 21:28:05 +05:00
imfozilbek
5e70ee1a38 refactor: optimize ESLint configuration
- Add CLI-specific overrides (disable no-console, complexity, max-lines-per-function)
- Disable no-unsafe-* rules for CLI (Commander.js is untyped)
- Increase max-params to 8 for DDD patterns
- Exclude examples/, tests/, *.config.ts from linting
- Disable style rules (prefer-nullish-coalescing, no-unnecessary-condition, no-nested-ternary)
- Reduce warnings from 129 to 0
2025-11-24 21:27:46 +05:00
imfozilbek
7e4de182ff feat: add --limit CLI option for output control
- Add --limit/-l option to limit detailed violation output
- Implement limit logic in displayGroupedViolations function
- Show warning when violations exceed limit
- Works with severity filters (--only-critical, --min-severity)
- Extract severity labels and headers to constants
- Improve CLI maintainability with SEVERITY_DISPLAY_LABELS and SEVERITY_SECTION_HEADERS
2025-11-24 21:27:27 +05:00
imfozilbek
88876a258b feat: add severity-based sorting and filtering for violations (v0.5.2)
- Add CRITICAL/HIGH/MEDIUM/LOW severity levels to all violations
- Sort violations by severity automatically (most critical first)
- Add CLI flags: --min-severity and --only-critical
- Group violations by severity in CLI output with color-coded headers
- Update all violation interfaces to include severity field
- Maintain 90%+ test coverage with all tests passing
- Update CHANGELOG.md, ROADMAP.md, and package version to 0.5.2
v0.5.2
2025-11-24 20:41:52 +05:00
imfozilbek
a34ca85241 chore: refactor hardcoded values to constants (v0.5.1)
Major internal refactoring to eliminate hardcoded values and improve
maintainability. Guardian now fully passes its own quality checks!

Changes:
- Extract all RepositoryViolation messages to domain constants
- Extract all framework leak template strings to centralized constants
- Extract all layer paths to infrastructure constants
- Extract all regex patterns to IMPORT_PATTERNS constant
- Add 30+ new constants for better maintainability

New files:
- src/infrastructure/constants/paths.ts (layer paths, patterns)
- src/domain/constants/Messages.ts (25+ repository messages)
- src/domain/constants/FrameworkCategories.ts (framework categories)
- src/shared/constants/layers.ts (layer names)

Impact:
- Reduced hardcoded values from 37 to 1 (97% improvement)
- Guardian passes its own src/ directory checks with 0 violations
- All 292 tests still passing (100% pass rate)
- No breaking changes - fully backwards compatible

Test results:
- 292 tests passing (100% pass rate)
- 96.77% statement coverage
- 83.82% branch coverage
v0.5.1
2025-11-24 20:12:08 +05:00
imfozilbek
0534fdf1bd feat: add repository pattern validation (v0.5.0)
Add comprehensive Repository Pattern validation to detect violations
and ensure proper domain-infrastructure separation.

Features:
- ORM type detection in repository interfaces (25+ patterns)
- Concrete repository usage detection in use cases
- Repository instantiation detection (new Repository())
- Domain language validation for repository methods
- Smart violation reporting with fix suggestions

Tests:
- 31 new tests for repository pattern detection
- 292 total tests passing (100% pass rate)
- 96.77% statement coverage, 83.82% branch coverage

Examples:
- 8 example files (4 bad patterns, 4 good patterns)
- Demonstrates Clean Architecture and SOLID principles
v0.5.0
2025-11-24 20:11:43 +05:00
imfozilbek
3fecc98676 feat: add dependency direction enforcement (v0.4.0)
Implement dependency direction detection to enforce Clean Architecture rules:
- Domain layer can only import from Domain and Shared
- Application layer can only import from Domain, Application, and Shared
- Infrastructure layer can import from all layers
- Shared layer can be imported by all layers

Added:
- IDependencyDirectionDetector interface in domain layer
- DependencyViolation value object with detailed suggestions and examples
- DependencyDirectionDetector implementation in infrastructure
- Integration with AnalyzeProject use case
- New DEPENDENCY_DIRECTION rule in constants
- 43 comprehensive tests covering all scenarios (100% passing)
- Good and bad examples in examples directory

Improvements:
- Optimized extractLayerFromImport method to reduce complexity
- Fixed indentation in DependencyGraph.ts
- Updated getExampleFix to avoid false positives in old detector

Test Results:
- All 261 tests passing
- Build successful
- Self-check: 0 architecture violations in src code
2025-11-24 18:31:41 +05:00
imfozilbek
f46048172f feat: add entity exposure detection (v0.3.0)
Implement entity exposure detection to prevent domain entities
from leaking to API responses. Detects when controllers/routes
return domain entities instead of DTOs.

Features:
- EntityExposure value object with detailed suggestions
- IEntityExposureDetector interface in domain layer
- EntityExposureDetector implementation in infrastructure
- Integration into AnalyzeProject use case
- CLI display with helpful suggestions
- 24 comprehensive unit tests (98% coverage)
- Examples for bad and good patterns

Detection scope:
- Infrastructure layer only (controllers, routes, handlers, resolvers, gateways)
- Identifies PascalCase entities without Dto/Request/Response suffixes
- Parses async methods with Promise<T> return types
- Provides step-by-step remediation suggestions

Test coverage:
- EntityExposureDetector: 98.07%
- Overall project: 90.6% statements, 83.97% branches
- 218 tests passing

BREAKING CHANGE: Version bump to 0.3.0
v0.3.0
2025-11-24 13:51:12 +05:00
imfozilbek
a3cd71070e feat: add 25 architectural features to roadmap (v0.3-0.27)
Add comprehensive architectural validation features covering:

Architecture Patterns (v0.3-0.12):
- Dependency Direction Enforcement
- Repository Pattern Validation
- Aggregate Boundary Validation
- Anemic Domain Model Detection
- Domain Event Usage Validation
- Value Object Immutability Check
- Use Case Single Responsibility
- Interface Segregation Validation
- Port-Adapter Pattern Validation
- Configuration File Support

DDD Patterns (v0.13-0.21):
- Command Query Separation (CQS/CQRS)
- Factory Pattern Validation
- Specification Pattern Detection
- Layered Service Anti-pattern Detection
- Bounded Context Leak Detection
- Transaction Script vs Domain Model
- Persistence Ignorance Validation
- Null Object Pattern Detection
- Primitive Obsession in Methods

Advanced Patterns (v0.22-0.27):
- Service Locator Anti-pattern
- Double Dispatch Pattern Validation
- Entity Identity Validation
- Saga Pattern Detection
- Anti-Corruption Layer Detection
- Ubiquitous Language Validation

Each feature includes detailed examples, violation detection,
and planned implementation for Q1-Q4 2026.
2025-11-24 13:30:08 +05:00
imfozilbek
ae361a4d60 chore: bump version to 0.2.0 for framework leak detection release v0.2.0 2025-11-24 12:57:41 +05:00
imfozilbek
32f5d8dbc5 docs: finalize v0.1.0 documentation with framework leak detection
Updates across all documentation files:

CHANGELOG.md:
- Add Framework Leak Detection as implemented feature in v0.1.0
- Update test count: 159 → 194 tests across 7 files
- Update examples count: 36 → 38 files (29 good + 9 bad)
- Remove framework leak from future releases

README.md:
- Add Framework Leak Detection section in Features
- Document supported frameworks: HTTP, ORM/DB, External services
- Include examples of Express, Prisma, TypeORM, etc.
- Emphasize domain boundary protection

ROADMAP.md:
- Move Framework Leak Detection from v0.2.0 to v0.1.0
- Update v0.1.0 metrics: 194 tests, 38 examples
- Renumber future versions (Entity Exposure now v0.2.0)
- Maintain proper version sequence through v1.0.0

CLAUDE.md:
- Update project description with framework leak detection
- Add to Key features list (5 features total)
- Update Guardian capabilities overview

TODO.md:
- Update current tasks and priorities

All documentation now accurately reflects v0.1.0 release with 5 core features:
1. Hardcode Detection
2. Circular Dependency Detection
3. Naming Convention Enforcement
4. Architecture Violations
5. Framework Leak Detection
v0.1.0
2025-11-24 12:54:48 +05:00
imfozilbek
0b7c8796ad fix: resolve linting issues
- Fix indentation in DependencyGraph.ts getMetrics return type
- Add ESLint disable comment for Guards class (utility class pattern)
- Clean up formatting across analyzer files
2025-11-24 12:54:24 +05:00
imfozilbek
3f2a9f2051 docs: add framework leak examples
- Add UserWithFrameworks.ts example showing framework leaks in domain
- Add examples/bad/ directory with anti-pattern demonstrations
- Demonstrate common mistakes: Prisma in domain, Express types, etc.
2025-11-24 12:54:12 +05:00
imfozilbek
ed66b6ba10 feat: add framework leak reporting to CLI
- Add framework leak violations output in CLI check command
- Display framework type, package name, and detailed suggestions
- Include framework leak count in summary statistics
- Format output with proper severity indicators
2025-11-24 12:54:00 +05:00
imfozilbek
19abff30f0 feat: integrate framework leak detection into analysis pipeline
- Add framework leak detector to AnalyzeProject use case
- Export FrameworkLeakDetector in public API
- Add FRAMEWORK_LEAK rule constant
- Include framework leak violations in analysis response
2025-11-24 12:53:50 +05:00
imfozilbek
0e23938e20 feat: add framework leak detection for domain layer
- Add IFrameworkLeakDetector interface in domain/services
- Add FrameworkLeak value object with framework type categorization
- Implement FrameworkLeakDetector with 250+ framework patterns across 12 categories
- Add comprehensive test suite (35 tests) for framework leak detection
- Support HTTP frameworks, ORMs, loggers, caches, message queues, etc.
- Detect framework imports in domain layer and suggest proper abstractions
2025-11-24 12:53:37 +05:00
imfozilbek
32bcf7d465 chore(guardian): rename package to @samiyev/guardian
Rename package from @puaros/guardian to @samiyev/guardian for npm publication.
Update all references in documentation.
2025-11-24 03:14:54 +05:00
imfozilbek
a4a4b36a8a docs: update project documentation for guardian
Update README, CLAUDE.md, and CHANGELOG for guardian package.
Add guardian package documentation and remove core references.
Update repository URLs to samiyev/puaros and add official website link (puaros.ailabs.uz).
2025-11-24 02:55:20 +05:00
imfozilbek
1d22a7d070 chore: update ESLint and Prettier configuration
Update code formatting and linting rules for guardian package.
Ensure consistent code style across monorepo.
2025-11-24 02:55:10 +05:00
imfozilbek
959d84918f chore: update TypeScript configuration
Update TypeScript configuration for guardian package.
Adjust paths and settings for monorepo structure.
2025-11-24 02:55:00 +05:00
imfozilbek
4b1af2089a chore: update workspace configuration
Update pnpm workspace to include guardian package and remove core package.
Update dependencies and lockfile.
2025-11-24 02:54:52 +05:00
imfozilbek
03705b5264 feat(guardian): add guardian package - code quality analyzer
Add @puaros/guardian package v0.1.0 - code quality guardian for vibe coders and enterprise teams.

Features:
- Hardcode detection (magic numbers, magic strings)
- Circular dependency detection
- Naming convention enforcement (Clean Architecture)
- Architecture violation detection
- CLI tool with comprehensive reporting
- 159 tests with 80%+ coverage
- Smart suggestions for fixes
- Built for AI-assisted development

Built with Clean Architecture and DDD principles.
Works with Claude, GPT, Copilot, Cursor, and any AI coding assistant.
2025-11-24 02:54:39 +05:00
imfozilbek
9f97509b06 chore: remove core package
Remove the @puaros/core package as it has been superseded by guardian package.
2025-11-24 02:54:13 +05:00
imfozilbek
d401fb9d3a chore(core): install dependencies
Install required dependencies:
- simple-git for git operations
- tree-sitter and parsers for code parsing
- uuid for ID generation
- vitest for testing
- Remove deprecated @types/ioredis
2025-11-23 21:44:00 +05:00
imfozilbek
6f4d77449a feat(core): configure package exports and npm ignore
- Add public API exports from all layers
- Add .npmignore for clean package publishing
2025-11-23 21:43:58 +05:00
imfozilbek
8b81e6030d test(core): add unit tests and test infrastructure
Add test structure:
- Unit tests for BaseEntity
- Unit tests for Guards utility
- Test fixtures with code samples
- Integration and unit test directories
2025-11-23 21:43:55 +05:00
imfozilbek
3dc531886e feat(core): add shared utilities and types
Add shared layer:
- Result<T,E> type for error handling
- BaseError and error subclasses
- Guards for runtime type checking
- Application constants
2025-11-23 21:43:43 +05:00
imfozilbek
6e24fe6ba8 feat(core): add infrastructure layer services
Add infrastructure implementations:
- BaseRepository with in-memory storage
- GitService for git operations using simple-git
- CodeParser for JS/TS parsing using tree-sitter
2025-11-23 21:43:40 +05:00
imfozilbek
2d54538d81 feat(core): add application layer components
Add application layer:
- UseCase base class for use cases
- ResponseDto for standardized responses
- Mapper for domain-DTO conversion
2025-11-23 21:43:38 +05:00