fix: Claude Code 2.1.1 compatibility + log-level audit + path validation fixes (#614)

* Refactor CLAUDE.md and related files for December 2025 updates

- Updated CLAUDE.md in src/services/worker with new entries for December 2025, including changes to Search.ts, GeminiAgent.ts, SDKAgent.ts, and SessionManager.ts.
- Revised CLAUDE.md in src/shared to reflect updates and new entries for December 2025, including paths.ts and worker-utils.ts.
- Modified hook-constants.ts to clarify exit codes and their behaviors.
- Added comprehensive hooks reference documentation for Claude Code, detailing usage, events, and examples.
- Created initial CLAUDE.md files in various directories to track recent activity.

* fix: Merge user-message-hook output into context-hook hookSpecificOutput

- Add footer message to additionalContext in context-hook.ts
- Remove user-message-hook from SessionStart hooks array
- Fixes issue where stderr+exit(1) approach was silently discarded

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update logs and documentation for recent plugin and worker service changes

- Added detailed logs for worker service activities from Dec 10, 2025 to Jan 7, 2026, including initialization patterns, cleanup confirmations, and diagnostic logging.
- Updated plugin documentation with recent activities, including plugin synchronization and configuration changes from Dec 3, 2025 to Jan 7, 2026.
- Enhanced the context hook and worker service logs to reflect improvements and fixes in the plugin architecture.
- Documented the migration and verification processes for the Claude memory system and its integration with the marketplace.

* Refactor hooks architecture and remove deprecated user-message-hook

- Updated hook configurations in CLAUDE.md and hooks.json to reflect changes in session start behavior.
- Removed user-message-hook functionality as it is no longer utilized in Claude Code 2.1.0; context is now injected silently.
- Enhanced context-hook to handle session context injection without user-visible messages.
- Cleaned up documentation across multiple files to align with the new hook structure and removed references to obsolete hooks.
- Adjusted timing and command execution for hooks to improve performance and reliability.

* fix: Address PR #610 review issues

- Replace USER_MESSAGE_ONLY test with BLOCKING_ERROR test in hook-constants.test.ts
- Standardize Claude Code 2.1.0 note wording across all three documentation files
- Exclude deprecated user-message-hook.ts from logger-usage-standards test

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Remove hardcoded fake token counts from context injection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Address PR #610 review issues by fixing test files, standardizing documentation notes, and verifying code quality improvements.

* fix: Add path validation to CLAUDE.md distribution to prevent invalid directory creation

- Add isValidPathForClaudeMd() function to reject invalid paths:
  - Tilde paths (~) that Node.js doesn't expand
  - URLs (http://, https://)
  - Paths with spaces (likely command text or PR references)
  - Paths with # (GitHub issue/PR references)
  - Relative paths that escape project boundary

- Integrate validation in updateFolderClaudeMdFiles loop
- Add 6 unit tests for path validation
- Update .gitignore to prevent accidental commit of malformed directories
- Clean up existing invalid directories (~/, PR #610..., git diff..., https:)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: Implement path validation in CLAUDE.md generation to prevent invalid directory creation

- Added `isValidPathForClaudeMd()` function to validate file paths in `src/utils/claude-md-utils.ts`.
- Integrated path validation in `updateFolderClaudeMdFiles` to skip invalid paths.
- Added 6 new unit tests in `tests/utils/claude-md-utils.test.ts` to cover various rejection cases.
- Updated `.gitignore` to prevent tracking of invalid directories.
- Cleaned up existing invalid directories in the repository.

* feat: Promote critical WARN logs to ERROR level across codebase

Comprehensive log-level audit promoting 38+ WARN messages to ERROR for
improved debugging and incident response:

- Parser: observation type errors, data contamination
- SDK/Agents: empty init responses (Gemini, OpenRouter)
- Worker/Queue: session recovery, auto-recovery failures
- Chroma: sync failures, search failures (now treated as critical)
- SQLite: search failures (primary data store)
- Session/Generator: failures, missing context
- Infrastructure: shutdown, process management failures
- File Operations: CLAUDE.md updates, config reads
- Branch Management: recovery checkout failures

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: Address PR #614 review issues

- Remove incorrectly tracked tilde-prefixed files from git
- Fix absolute path validation to check projectRoot boundaries
- Add test coverage for absolute path validation edge cases

Closes review issues:
- Issue 1: ~/ prefixed files removed from tracking
- Issue 3: Absolute paths now validated against projectRoot
- Issue 4: Added 3 new test cases for absolute path scenarios

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* build assets and context

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-01-07 23:34:20 -05:00
committed by GitHub
parent 687146ce53
commit 2659ec3231
98 changed files with 8927 additions and 3554 deletions
+71 -75
View File
@@ -3,117 +3,113 @@
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 2, 2026
### Nov 10, 2025
**SettingsDefaultsManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35965 | 4:45 PM | | Removed Session Alignment Debug Mode Setting | ~249 |
| #6295 | 1:18 PM | 🔵 | Path Configuration Structure for claude-mem | ~305 |
### Dec 5, 2025
**worker-utils.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35900 | 2:49 PM | 🔵 | Worker Health Checks Use Fetch Without Timeout Configuration | ~397 |
| #20730 | 9:06 PM | 🔵 | Path Configuration Module with ESM/CJS Compatibility | ~578 |
| #20718 | 9:00 PM | 🔵 | Worker Service Auto-Start and Health Check System | ~448 |
| #20410 | 7:21 PM | 🔵 | Path utilities provide cross-runtime directory management with Claude integration support | ~478 |
| #20409 | 7:20 PM | 🔵 | Worker utilities provide automatic PM2 startup with health checking and port configuration | ~479 |
### Dec 9, 2025
**paths.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35901 | 2:49 PM | 🔵 | PR #525 File Changes Summary | ~376 |
| #23141 | 6:42 PM | 🔵 | Located getSettingsPath Function in paths.ts | ~261 |
| #23134 | 6:41 PM | ✅ | Set CLAUDE_MEM_SKIP_TOOLS Default Value in SettingsDefaultsManager | ~261 |
| #23133 | " | ✅ | Added CLAUDE_MEM_SKIP_TOOLS to SettingsDefaults Interface | ~231 |
| #23131 | 6:40 PM | 🔵 | SettingsDefaultsManager Structure and Configuration Schema | ~363 |
| #22858 | 2:28 PM | 🔄 | Removed Brittle save.md Validation from paths.ts | ~305 |
| #22852 | 2:26 PM | 🔵 | Located save.md Validation Logic in paths.ts | ~255 |
| #22805 | 2:01 PM | 🔵 | Early Settings Silent Failure Point Identified | ~363 |
| #22803 | " | 🔵 | Worker Utilities Current Implementation Review | ~390 |
| #22518 | 12:59 AM | 🔵 | Worker Utils StartWorker Implementation Uses Plugin Root for PM2 | ~311 |
### Dec 10, 2025
**hook-constants.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35890 | 2:47 PM | 🔵 | Hook Exit Codes Define Three States But Not All Hooks Use Them | ~362 |
| #35865 | 2:35 PM | 🔵 | Hook Constants Define Timeouts and Exit Codes | ~445 |
| #23831 | 11:15 PM | 🔵 | Current hook-error-handler.ts References PM2 | ~277 |
| #23830 | " | 🔵 | Current worker-utils.ts Implementation Uses PM2 | ~431 |
| #23812 | 10:49 PM | 🔵 | Current Worker Startup Uses PM2 and PowerShell; Phase 2 Will Replace | ~428 |
| #23811 | " | 🔵 | Existing Paths Configuration for Phase 2 Reference | ~297 |
### Dec 12, 2025
**transcript-parser.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35746 | 1:17 PM | 🔵 | Transcript Parser extractLastMessage Implementation Examined | ~423 |
| #24405 | 8:12 PM | 🔵 | PM2 Legacy Cleanup Migration in Worker Startup | ~303 |
| #24400 | 8:10 PM | 🔵 | Retrieved PM2 Cleanup Implementation Details from Memory | ~355 |
| #24362 | 7:00 PM | 🟣 | Implemented PM2 Cleanup One-Time Marker in worker-utils.ts | ~376 |
| #24361 | " | ✅ | Added File System Imports to worker-utils.ts for PM2 Marker | ~263 |
| #24360 | " | 🔵 | worker-utils.ts Contains PM2 Cleanup Logic Without One-Time Marker | ~390 |
### Jan 4, 2026
### Dec 13, 2025
**SettingsDefaultsManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36781 | 12:45 AM | 🔵 | Complete GeminiAgent Model Configuration Gap Analysis | ~552 |
| #36757 | 12:33 AM | 🔵 | Issue #511 Root Cause Identified - Gemini-3-Flash Configuration Mismatch | ~416 |
| #36754 | " | 🔵 | Gemini-3-Flash Model Already Supported | ~301 |
| #25088 | 7:18 PM | 🟣 | Added CLAUDE_MEM_EMBEDDING_FUNCTION to Settings Interface | ~269 |
### Jan 5, 2026
### Dec 14, 2025
**CLAUDE.md**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38082 | 10:13 PM | | Merge Conflict Resolution - Kept Feature Branch Versions | ~431 |
| #38078 | 9:54 PM | | CLAUDE.md Documentation Cleanup - 1,233 Lines Removed Across 18 Files | ~590 |
| #26790 | 11:38 PM | 🔴 | Fixed Undefined Port Variable in Error Logger | ~340 |
| #26789 | " | 🔴 | Fixed Undefined Port Variable in Error Logging | ~316 |
| #26788 | " | 🔵 | Worker Utils Already Imports Required Dependencies for Implementation | ~283 |
| #26787 | " | 🟣 | Phase 2 Complete: Pre-Restart Delay Added to Version Mismatch Handler | ~436 |
| #26786 | " | 🟣 | Phase 2 Complete: Pre-Restart Delay Added to ensureWorkerVersionMatches Function | ~420 |
| #26785 | 11:37 PM | 🟣 | Phase 1 Complete: PRE_RESTART_SETTLE_DELAY Constant Added to Hook Timeouts | ~351 |
| #26784 | " | 🟣 | Phase 1 Complete: PRE_RESTART_SETTLE_DELAY Constant Added to HOOK_TIMEOUTS | ~370 |
| #26783 | " | 🔵 | Hook Constants File Defines Timeout Values and Platform Multiplier | ~452 |
| #26782 | " | 🔵 | hook-constants.ts Defines Timeout Constants With Windows Platform Multiplier | ~418 |
| #26766 | 11:30 PM | ⚖️ | Root Cause Identified: Missing Post-Install Worker Restart Trigger in Plugin Update Flow | ~604 |
| #26765 | " | 🔵 | Explore Agent Confirms Root Cause: No Proactive Worker Restart After Plugin Updates | ~613 |
| #26732 | 11:25 PM | 🔵 | Worker Utils Implements Version Mismatch Detection and Auto-Restart | ~516 |
| #26731 | 11:24 PM | 🔵 | ensureWorkerRunning Implementation Shows 2.5 Second Startup Wait With Version Check | ~522 |
| #25695 | 4:27 PM | 🟣 | Added comprehensive error logging to transcript parser for debugging message extraction failures | ~473 |
| #25693 | 4:24 PM | 🔵 | Transcript parser extracts messages from JSONL file by scanning backwards for role-specific entries | ~491 |
### Dec 17, 2025
**SettingsDefaultsManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38064 | 9:50 PM | ⚖️ | 9.0 Release Documentation Audit Complete - Major Gaps Identified | ~997 |
| #38055 | 9:47 PM | 🔵 | SettingsDefaultsManager Missing CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED Setting | ~549 |
| #38048 | 9:45 PM | 🔴 | PR #558 - Comprehensive Bug Fix and Test Quality Improvement | ~585 |
| #38005 | 9:03 PM | 🔵 | Comprehensive exploration of PR review items completed | ~438 |
| #37996 | 9:01 PM | 🔵 | SettingsDefaultsManager provides centralized settings management | ~310 |
| #37995 | " | 🔵 | CLAUDE_MEM_WORKER_HOST setting implementation pattern | ~304 |
| #37990 | 9:00 PM | 🔵 | CLAUDE_MEM_WORKER_HOST setting used across 19 files | ~289 |
| #37887 | 7:32 PM | ✅ | Added Cross-Reference Comment for DEFAULT_DATA_DIR Constant | ~361 |
| #37881 | 7:31 PM | 🔵 | SettingsDefaultsManager Implementation Details Examined | ~384 |
| #37785 | 6:37 PM | 🔴 | Completed Removal of All Logger References from SettingsDefaultsManager | ~315 |
| #37784 | " | 🔄 | Replaced Logger Calls with Console Logging in SettingsDefaultsManager | ~331 |
| #37783 | " | 🔄 | Removed Logger Import from SettingsDefaultsManager | ~323 |
| #37779 | 6:36 PM | 🔵 | SettingsDefaultsManager Uses Logger Methods | ~375 |
| #37774 | 6:35 PM | 🔵 | Circular Dependency Between Logger and SettingsDefaultsManager | ~326 |
| #37773 | " | 🔵 | SettingsDefaultsManager Uses Logger Import | ~267 |
| #37665 | 5:52 PM | 🔵 | Codebase uses dependency injection and lazy initialization patterns to avoid circular dependencies | ~548 |
| #37632 | 5:37 PM | 🔵 | SettingsDefaultsManager Circular Dependency with Logger Confirmed | ~556 |
| #37628 | 5:36 PM | 🔴 | Test Execution Shows Logger Circular Dependency Error | ~596 |
| #37617 | 5:32 PM | ⚖️ | PR #558 Review Requirements Categorized by Priority | ~637 |
| #37613 | 5:31 PM | 🔵 | PR #558 Review Feedback Analysis | ~544 |
| #37593 | 4:56 PM | 🟣 | Phase 3 Committed - Settings Auto-Creation Implemented | ~386 |
| #37592 | " | ✅ | Phase 3 Anti-Pattern Check Complete - Clean Implementation | ~434 |
| #37590 | 4:55 PM | 🟣 | Phase 3 Complete - Settings Auto-Creation Implemented | ~400 |
| #37589 | " | 🟣 | Implemented Settings File Auto-Creation in loadFromFile | ~385 |
| #37588 | " | ✅ | Added Required Imports for Settings File Creation | ~291 |
| #37587 | 4:54 PM | 🔵 | SettingsDefaultsManager Missing File Auto-Creation | ~374 |
| #37548 | 4:48 PM | ✅ | Issue #543 Analysis Report Created for Slash Command Availability | ~540 |
| #37547 | 4:47 PM | ✅ | Issue #557 Analysis Report Created for Plugin Startup Failure | ~491 |
| #37535 | 4:44 PM | 🔵 | Settings Defaults Manager Implementation Analysis | ~447 |
| #28464 | 4:25 PM | 🔵 | Platform-Adjusted Hook Timeout Configuration | ~468 |
| #28461 | " | 🔵 | Dual ESM/CJS Path Resolution System | ~479 |
| #28452 | 4:23 PM | 🔵 | Worker Version Matching and Auto-Restart System | ~510 |
### Dec 18, 2025
**worker-utils.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38012 | 9:12 PM | | Completed Phase 1: Added getWorkerHost() import and replaced hard-coded localhost | ~319 |
| #38000 | 9:02 PM | 🔵 | Mixed usage of hard-coded 127.0.0.1 vs getWorkerHost() | ~347 |
| #37999 | " | 🔵 | getWorkerHost and getWorkerPort used in 18 files across codebase | ~282 |
| #37998 | " | 🔵 | worker-utils.ts provides cached host and port accessors | ~360 |
| #29797 | 7:09 PM | 🔵 | Settings System Uses CLAUDE_MEM_MODE for Mode Selection | ~353 |
| #29234 | 12:10 AM | 🔵 | Centralized Settings Management with Environment Defaults | ~394 |
### Dec 20, 2025
**timeline-formatting.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37967 | 8:21 PM | 🔵 | Timeline Formatting Utilities Provide Correct Date Functions | ~384 |
| #31086 | 7:59 PM | 🔵 | Transcript Parser Extracts Messages from JSONL Hook Files | ~327 |
| #30939 | 6:57 PM | 🔵 | Worker Utils File Examined for Error Handling Inconsistency | ~393 |
| #30855 | 6:22 PM | 🔵 | Transcript Parser Content Format Handling Examined | ~406 |
### Dec 25, 2025
**hook-constants.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37558 | 4:49 PM | 🔵 | Issue #555 Windows Hook Execution Patterns and Fix Strategy Documented | ~510 |
| #37552 | 4:48 PM | 🔵 | Hook Timeout Configuration and Windows Multiplier | ~352 |
| #32616 | 8:43 PM | 🔵 | Comprehensive analysis of "enable billing" setting and its impact on rate limiting | ~533 |
| #32538 | 7:28 PM | | Set default Gemini billing to disabled | ~164 |
### Jan 7, 2026
**paths.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37536 | 4:44 PM | 🔵 | Path Configuration and Directory Initialization Logic | ~430 |
### Jan 6, 2026
**worker-utils.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38108 | 12:15 AM | 🔵 | Complete Windows Zombie Port Bug Technical Deep Dive | ~935 |
**hook-constants.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38104 | 12:14 AM | 🔵 | Windows Compatibility Issues Documented Across 56 Memory Entries | ~509 |
| #38175 | 7:26 PM | 🔵 | Complete Claude-Mem Hook Output Architecture Documented | ~530 |
</claude-mem-context>
+7 -2
View File
@@ -9,12 +9,17 @@ export const HOOK_TIMEOUTS = {
/**
* Hook exit codes for Claude Code
*
* Exit code behavior per Claude Code docs:
* - 0: Success. For SessionStart/UserPromptSubmit, stdout added to context.
* - 2: Blocking error. For SessionStart, stderr shown to user only.
* - Other non-zero: stderr shown in verbose mode only.
*/
export const HOOK_EXIT_CODES = {
SUCCESS: 0,
FAILURE: 1,
/** Show user message that Claude does NOT receive as context */
USER_MESSAGE_ONLY: 3,
/** Blocking error - for SessionStart, shows stderr to user only */
BLOCKING_ERROR: 2,
} as const;
export function getTimeout(baseTimeout: number): number {