Skip to content

Implement SRP Complexity Classifier with Multi-language Support#275

Merged
JeremyDev87 merged 1 commit intomasterfrom
feat/274
Jan 22, 2026
Merged

Implement SRP Complexity Classifier with Multi-language Support#275
JeremyDev87 merged 1 commit intomasterfrom
feat/274

Conversation

@JeremyDev87
Copy link
Owner

Implement SRP Complexity Classifier with Multi-language Support

Summary

This PR introduces an intelligent complexity classification system for the PLAN mode workflow. The classifier analyzes user prompts to determine whether they require structured reasoning (SRP) or can be handled directly, supporting 5 languages with negation pattern detection.

Implementation Details

1. Complexity Classification Algorithm

Score = Σ(matched_indicator.weight) / Σ(all_indicator.weight)

If COMPLEX_score > 0.08 AND COMPLEX_score > SIMPLE_score → COMPLEX
If SIMPLE_score > 0.10 AND SIMPLE_score > COMPLEX_score → SIMPLE
Otherwise → Borderline handling with safety margin

2. Negation Pattern Detection

Implemented language-aware negation detection:

  • Prefix negations (EN, ZH, ES): "don't", "不要", "no"
  • Suffix negations (KO, JA): "하지 말고", "しないで"

The isNegatedMatch() function checks 30 characters before and 15 characters after each match to detect negation context.

3. Function Decomposition

Refactored classifyComplexity() into focused helpers:

classifyComplexity(prompt, options)
  ├── extractSrpOverride(prompt)      // Handle --srp/--no-srp flags
  ├── calculateScores(prompt)          // Score both indicator types
       ├── calculateScore(COMPLEX_INDICATORS, checkNegation=true)
       └── calculateScore(SIMPLE_INDICATORS, checkNegation=false)
  ├── determineComplexity(scores)      // Apply thresholds
  └── applyOverride(result, override)  // Handle user overrides

4. Multi-language Support

Language COMPLEX Keywords SIMPLE Keywords Negation Patterns
English design, architect, refactor, optimize fix, format, typo, comment don't, do not, skip, avoid
Korean 설계, 아키텍처, 리팩토링, 최적화 수정, 포맷, 오타, 주석 하지 말, 안 해도, 필요 없
Japanese 設計, アーキテクチャ, リファクタリング 修正, フォーマット, タイポ しないで, 必要ない
Chinese 设计, 架构, 重构, 优化 修复, 格式化, 错字 不要, 不需要, 别
Spanish diseño, arquitectura, refactorizar corregir, formatear, error no, sin, evitar

Test Coverage

  • 94 tests covering all scenarios
  • 13ms total test execution time
  • Test categories:
    • Basic classification (COMPLEX/SIMPLE)
    • Override handling (--srp, --no-srp)
    • i18n patterns (EN, KO, JA, ZH, ES)
    • Negation detection (21 tests)
    • Mixed-language prompts (6 tests)
    • Telemetry callback
    • Configurable thresholds
    • Edge cases and borderline scenarios

Quality Assurance

Code Quality Review: LOW RISK

  • Excellent SOLID compliance
  • Clean function decomposition
  • Strong type safety (no any)
  • Backwards compatibility maintained

Performance Review: LOW RISK

  • Bundle size: ~27KB (acceptable for MCP server)
  • Test execution: 13ms
  • No critical performance issues

Breaking Changes

None. The API is additive and backwards compatible.

How to Test

# Run complexity classifier tests
yarn workspace codingbuddy test src/keyword/complexity-classifier.spec.ts

# Run all keyword module tests
yarn workspace codingbuddy test src/keyword/

Related

close #274

@JeremyDev87 JeremyDev87 self-assigned this Jan 22, 2026
@JeremyDev87 JeremyDev87 marked this pull request as ready for review January 22, 2026 13:15
Implement intelligent task complexity classification for PLAN mode that
determines whether Structured Reasoning Process (SRP) should be applied.

close #274
@JeremyDev87 JeremyDev87 merged commit 3d4e789 into master Jan 22, 2026
16 checks passed
@JeremyDev87 JeremyDev87 deleted the feat/274 branch January 22, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Structured Reasoning Process (SRP) for PLAN Mode

1 participant