refactor: implement in-process worker architecture for hooks (#722)

* fix: stop generating empty CLAUDE.md files

- Return empty string instead of "No recent activity" when no observations exist
- Skip writing CLAUDE.md files when formatted content is empty
- Remove redundant "auto-generated by claude-mem" HTML comment
- Clean up 98 existing empty CLAUDE.md files across the codebase
- Update tests to expect empty string for empty input

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

* build assets

* refactor: implement in-process worker architecture for hooks

Replaces spawn-based worker startup with in-process architecture:
- Hook processes now become the worker when port 37777 is free
- Eliminates Windows spawn issues (NO SPAWN rule)
- SessionStart chains: smart-install && stop && context

Key changes:
- worker-service.ts: hook case starts WorkerService in-process
- hook-command.ts: skipExit option prevents process.exit() when hosting worker
- hooks.json: single chained command replaces separate start/hook commands
- worker-utils.ts: ensureWorkerRunning() returns boolean, doesn't block
- handlers: graceful fallback when worker unavailable

All 761 tests pass. Manual verification confirms hook stays alive as worker.

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

* context

* a

* MAESTRO: Mark PR #722 test verification task complete

All 797 tests passed (3 skipped, 0 failed) after merge conflict resolution.

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

* MAESTRO: Mark PR #722 build verification task complete

* MAESTRO: Mark PR #722 code review task complete

Code review verified:
- worker-service.ts hook case starts WorkerService in-process
- hook-command.ts has skipExit option
- hooks.json uses single chained command
- worker-utils.ts ensureWorkerRunning() returns boolean

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

* MAESTRO: Mark PR #722 conflict resolution push task complete

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-02-04 19:49:15 -05:00
committed by GitHub
parent 14ca7cf7d6
commit 4df9f61347
107 changed files with 804 additions and 4493 deletions
-120
View File
@@ -1,120 +0,0 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 10, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23818 | 10:52 PM | ✅ | Build Script Updated to Bundle Worker CLI with Bun Shebang | ~225 |
| #23817 | " | 🔵 | Build Script Handles Hook Bundling; Worker Shebang Currently Uses Node | ~323 |
| #23793 | 10:14 PM | 🔄 | Smart Install Script Simplified for Clarity | ~479 |
| #23667 | 8:35 PM | 🔵 | Export-Memories Script Structure and Database Query Pattern | ~287 |
| #23649 | 8:13 PM | 🔴 | Fixed Sessions Array Type in Export Script | ~189 |
| #23648 | " | 🔴 | Applied Type Annotations to Export Script Variables | ~305 |
| #23647 | 8:12 PM | 🔴 | Improved Type Safety in Export Script | ~352 |
| #23646 | " | 🔴 | Fixed Variable Shadowing in Export Script | ~234 |
| #23645 | " | 🔵 | Export Script Has Variable Shadowing Issue | ~234 |
| #23644 | 8:11 PM | 🔴 | Added Database Existence Check to Export Script | ~245 |
| #23643 | " | 🔵 | Export Script Opens Database Without Existence Check | ~238 |
| #23642 | " | 🔴 | Fixed Export Script Hardcoded Port - Now Reads from User Settings | ~244 |
| #23641 | " | ✅ | Added Settings Import to Export Script | ~189 |
| #23640 | " | 🔵 | Export Script Has Hardcoded Port Parameter | ~213 |
| #23639 | " | 🔴 | Fixed Import Script insertSession.run() Call Parameters | ~218 |
### Dec 11, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #24051 | 2:54 PM | 🟣 | Auto-Restart Worker After Marketplace Sync | ~384 |
| #24050 | " | ✅ | Build Worker Binary Script Made Executable | ~225 |
| #24049 | 2:53 PM | 🟣 | Windows Binary Build Script Created | ~362 |
| #24048 | " | ✅ | MCP Server Shebang Updated to Bun Runtime | ~342 |
| #24047 | " | ✅ | Hook Scripts Shebang Updated to Bun Runtime | ~305 |
| #24046 | " | ✅ | Worker Service Shebang Updated to Bun Runtime | ~306 |
| #24045 | 2:52 PM | 🔵 | Sync Marketplace Script Analysis for Auto-Restart Integration | ~366 |
| #24043 | " | 🔵 | Build Script Analysis for Phase 4 Updates | ~380 |
| #23922 | 1:34 PM | 🔵 | Three Node Shebangs Found in Build Configuration | ~349 |
| #23917 | 1:33 PM | 🔵 | Worker Service Build Configuration Current State | ~365 |
### Dec 12, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #24639 | 10:46 PM | 🔴 | Enhanced UV Detection to Support Fresh Installs Before PATH Reload | ~326 |
| #24638 | " | 🔴 | Enhanced Bun Detection to Support Fresh Installs Before PATH Reload | ~338 |
| #24637 | " | 🔵 | Bun Installation Detection Using spawnSync | ~288 |
| #24636 | " | 🔵 | Duplicate Smart Install Scripts in Project Structure | ~288 |
### Dec 14, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #26768 | 11:31 PM | 🔵 | Build Script Generates Empty plugin/package.json Without Postinstall Hook | ~492 |
| #26767 | " | 🔵 | Build Script Generates Empty Plugin Package.json Without Postinstall Hook | ~523 |
| #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 |
| #25815 | 5:31 PM | 🔵 | Comprehensive MCP Server and SKILL.md Structure Analysis | ~575 |
| #25809 | 5:30 PM | 🔵 | Build System Architecture Using esbuild for Component Bundling | ~484 |
### Dec 16, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #27725 | 5:45 PM | 🔵 | Export script uses hybrid search API to export observations, sessions, summaries, and prompts | ~335 |
| #27705 | 5:38 PM | ✅ | Switched import-memories.ts from better-sqlite3 to bun:sqlite | ~212 |
### Dec 17, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #29052 | 10:02 PM | 🔵 | Sync Script Manages Multiple Plugin Installation Locations | ~394 |
### Dec 18, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #29565 | 5:28 PM | ✅ | Output File Changed from code.yaml to code.json | ~234 |
| #29564 | " | 🔄 | Script Refactored to Generate JSON Instead of YAML | ~332 |
### Dec 19, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30109 | 8:11 PM | 🔵 | RAGTIME Script Uses Agent SDK Without Plugin Loading | ~490 |
| #30076 | 8:05 PM | 🔵 | RAGTIME Script Uses Agent SDK Query Function for Email Processing | ~389 |
### Dec 20, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30340 | 3:42 PM | 🔄 | Relocated simple ragtime.ts to ragtime folder | ~219 |
| #30337 | 3:40 PM | 🔵 | Simplified Ragtime Runner in Scripts Directory | ~456 |
| #30256 | 3:18 PM | 🔵 | Plugin Path Resolution Strategy | ~386 |
| #30250 | 3:17 PM | 🟣 | RAGTIME Email Investigation Runner Implemented | ~503 |
### Dec 26, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32983 | 11:04 PM | 🟣 | Complete build and deployment pipeline executed | ~260 |
### Dec 28, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33261 | 2:58 PM | 🔄 | Build script cleanup removes obsolete worker-wrapper and worker-cli build steps | ~335 |
### Dec 30, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34460 | 2:23 PM | 🔵 | Build System Architecture Using ESBuild | ~492 |
### Jan 4, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36765 | 12:41 AM | 🔵 | Smart Install Script Path Detection Logic | ~405 |
</claude-mem-context>