Add comprehensive tests for keyword detection, session state management, and user abort detection

- Implement tests for KeywordDetector including keyword detection, sanitization, and priority handling.
- Add tests for SessionStateService covering session validation, loading, saving, and state updates.
- Create tests for UserAbortDetector to validate user abort detection logic and pattern matching.
This commit is contained in:
catlog22
2026-02-18 21:48:56 +08:00
parent 65762af254
commit 46d4b4edfd
23 changed files with 6992 additions and 329 deletions

View File

@@ -0,0 +1,60 @@
/**
* Core Hooks Module
*
* Provides detector functions and utilities for Claude Code hooks integration.
*/
// Context Limit Detector
export {
isContextLimitStop,
getMatchingContextPattern,
getAllMatchingContextPatterns,
CONTEXT_LIMIT_PATTERNS,
type StopContext
} from './context-limit-detector.js';
// User Abort Detector
export {
isUserAbort,
getMatchingAbortPattern,
getAllMatchingAbortPatterns,
shouldAllowContinuation,
USER_ABORT_EXACT_PATTERNS,
USER_ABORT_SUBSTRING_PATTERNS,
USER_ABORT_PATTERNS
} from './user-abort-detector.js';
// Keyword Detector
export {
detectKeywords,
hasKeyword,
getAllKeywords,
getPrimaryKeyword,
getKeywordType,
hasKeywordType,
sanitizeText,
removeCodeBlocks,
KEYWORD_PATTERNS,
KEYWORD_PRIORITY,
type KeywordType,
type DetectedKeyword
} from './keyword-detector.js';
// Stop Handler
export {
StopHandler,
createStopHandler,
defaultStopHandler,
type ExtendedStopContext,
type StopResult,
type StopHandlerOptions
} from './stop-handler.js';
// Recovery Handler
export {
RecoveryHandler,
createRecoveryHandler,
type PreCompactInput,
type HookOutput,
type RecoveryHandlerOptions
} from './recovery-handler.js';