Commit Graph

105 Commits

Author SHA1 Message Date
Alex Newman d363dfd668 Fix: Restore hookSpecificOutput JSON format for SessionStart hook
The previous 'fix' to output plain text broke context injection.
SessionStart hooks require hookSpecificOutput JSON format.

Changes:
- Restore JSON output with hookSpecificOutput wrapper
- Keep improved error handling with JSON error output
- Tested with real SessionStart hook input format
2025-10-25 23:53:14 -04:00
Alex Newman c06abbc6f2 Fix: Add proper error handling to context hook stdin processing
- Wrap stdin event handler in try/catch to catch async errors
- Output errors to stdout so Claude can see them
- Show input preview and stack trace for debugging
- Remove outer try/catch that wasn't catching async errors
2025-10-25 23:51:53 -04:00
Alex Newman f499810c7a Fix: Remove startup matcher from SessionStart hook to inject context on all session starts (resume, clear, compact) 2025-10-25 23:48:07 -04:00
Alex Newman 609d8f5c88 Fix SessionStart hook to output plain text instead of JSON 2025-10-25 23:37:06 -04:00
Alex Newman 5ebf6c8aec fix: Increase timeout for SessionStart command in hooks.json 2025-10-25 23:34:52 -04:00
Alex Newman d94a11e2e1 Fix: Add matcher to SessionStart hook in hooks.json 2025-10-25 23:34:20 -04:00
Alex Newman d4d6185bb4 Release v4.3.0: Progressive Disclosure Context
Major Feature:
- Progressive Disclosure Context: 3-layer memory retrieval system
  - Layer 1 (Index): Observation titles, token costs, type indicators
  - Layer 2 (Details): Full narratives via MCP search on-demand
  - Layer 3 (Perfect Recall): Source code and original transcripts
- Context hook displays observations in table format
- Type indicators: 🔴 critical, 🟤 decision, 🔵 informational
- Token counts help Claude decide: fetch details vs read code

Added:
- Agent Skills documentation and version bump management skill
- Memory toggle feature planning document

Changed:
- Enhanced session summary handling and timeline rendering
- Context token cost increased from ~800 to ~2,500 tokens

Fixed:
- Removed hardcoded macOS-specific paths (fixes #23)
- Cross-platform path detection improvements

Files Updated:
- package.json, marketplace.json, plugin.json: version 4.3.0
- CLAUDE.md: version history and current version updated
- README.md: removed experimental section, integrated feature
- CHANGELOG.md: comprehensive v4.3.0 release entry
- Built all hooks and worker service

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 15:42:06 -04:00
Alex Newman 2df50bcaa0 Merge pull request #25 from thedotmack/feature/context-with-observations
feat: Enhanced context hook with session observations and cross-platform improvements
2025-10-25 15:33:29 -04:00
Alex Newman 7db39bb482 Fix: Add cross-platform Claude path detection to feature branch
Applied v4.2.11 fix from main branch:
- Implemented explicit which/where command execution
- Unix/macOS: Uses 'which claude' command
- Windows: Uses 'where claude' command (CMD and PowerShell compatible)
- Fallback to CLAUDE_CODE_PATH environment variable
- Handles Windows multiple results (takes first match)

Technical changes:
- Added findClaudePath() helper using child_process.execSync
- Platform detection via process.platform === 'win32'
- Updated src/sdk/worker.ts with explicit path detection
- Updated src/services/worker-service.ts with explicit path detection
- Built worker-service.cjs reflects changes

This fixes SDK auto-detection failure that returned undefined path.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 14:59:53 -04:00
Alex Newman e600a0f702 chore: Bump version to 4.2.11 in plugin.json 2025-10-25 14:56:48 -04:00
Alex Newman a3b0b70a98 feat: Add functionality to locate Claude Code executable
- Implemented `findClaudePath` function to determine the path of the Claude executable using environment variables or system commands (`which` for Unix/Mac and `where` for Windows).
- Integrated the `findClaudePath` function into the SDK worker and worker service to ensure the correct executable path is used when running the SDK agent.
- Enhanced error handling and logging for better debugging and user feedback regarding the executable path.
2025-10-25 14:53:59 -04:00
Alex Newman 81f8aa7eef worker 2025-10-25 14:45:31 -04:00
Alex Newman 8f8649c2a8 worker 2025-10-25 14:41:16 -04:00
Alex Newman d8d4d2464f worker 2025-10-25 14:38:06 -04:00
Alex Newman 9d32629f9d worker 2025-10-25 14:35:56 -04:00
Alex Newman 6a007a26fe Remove hardcoded path to Claude executable in WorkerService.runSDKAgent method 2025-10-25 14:33:16 -04:00
Alex Newman 22777bdcfe Update default path for Claude Code executable in SDKWorker and WorkerService 2025-10-25 14:28:02 -04:00
Alex Newman d7946522e9 Add configurable path for Claude Code executable in SDKWorker and WorkerService 2025-10-25 14:24:17 -04:00
Alex Newman 9f3bf55c76 refactor: Remove hardcoded paths for project and Claude Code executable in various scripts, fixes issue #23 2025-10-25 13:28:20 -04:00
Alex Newman ae2c789781 Bump version to 4.2.10 and fix Windows compatibility by removing hardcoded macOS path 2025-10-25 13:24:18 -04:00
copilot-swe-agent[bot] b88ce840fa Remove hardcoded Claude executable path and defensive checks
Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
2025-10-25 06:19:30 +00:00
Alex Newman 05ddf3540c Release v4.2.9: Progressive disclosure experimental feature announcement
Documentation Updates:
- Added experimental progressive disclosure context system section to README
- Created EXPERIMENTAL_RELEASE_NOTES.md with comprehensive testing guide
- Created GITHUB_RELEASE_TEMPLATE.md for release announcements
- Updated all version references to 4.2.9 (package.json, marketplace.json, CLAUDE.md, README.md)

Progressive Disclosure Concept:
- Layer 1: Index showing what observations exist with token costs
- Layer 2: On-demand details via MCP search
- Layer 3: Perfect recall via source code access

Purpose:
- Invite users to test feature/context-with-observations branch
- Gather feedback on observation-level context vs summary-only approach
- Validate whether token cost metadata improves Claude's retrieval decisions

Testing Instructions:
- Clear documentation on how to clone, build, and test experimental branch
- Feedback template provided for structured user responses
- GitHub issues encouraged with label 'feedback: progressive-disclosure'

Files Changed:
- README.md (experimental feature section)
- EXPERIMENTAL_RELEASE_NOTES.md (new)
- GITHUB_RELEASE_TEMPLATE.md (new)
- package.json (version bump)
- .claude-plugin/marketplace.json (version bump)
- CLAUDE.md (version history + version number)
- plugin/scripts/*.js (rebuilt)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 01:59:08 -04:00
Alex Newman 77885db345 feat: Add progressive disclosure usage instructions to context hook output 2025-10-25 01:36:39 -04:00
Alex Newman 50d504715d Refactor contextHook to improve session summary handling and timeline rendering
- Updated logic to retrieve recent summaries and observations, focusing on the last 4 summaries for better context.
- Simplified the extraction of unique session IDs from the recent summaries.
- Enhanced the timeline rendering to include both observations and summaries, grouped by day and file.
- Removed redundant queries for recent summaries and observations, streamlining the data retrieval process.
- Improved output formatting for better readability, including color-coded sections and clearer headers.
- Added detailed display of the most recent session's completed status and next steps.
2025-10-25 01:23:47 -04:00
Alex Newman 28d9c43f85 feat: Enhance context hook with detailed session observations and timeline
- Introduced new helper functions for parsing JSON, formatting dates, and estimating token counts.
- Implemented retrieval of recent session IDs and observations from the database.
- Added filtering of observations based on key concepts for a more relevant timeline.
- Enhanced output formatting to include a chronological timeline of recent activities grouped by day and file.
- Included a legend for better understanding of the timeline icons.
- Displayed recent session summaries with improved formatting and details.
- Added footer instructions for accessing records via MCP search.
2025-10-24 23:37:03 -04:00
Alex Newman adc5853c73 Release v4.2.8: Critical bugfix for session ID handling
Critical bugfix release.

Problem:
- NOT NULL constraint violations prevented all observations/summaries from being stored
- Worker service could not store any data in database
- System was completely non-functional for new sessions

Root Cause:
- SessionStore.getSessionById() missing claude_session_id in SELECT query
- Worker received undefined for claude_session_id
- Caused database INSERT failures

Fix:
- Added claude_session_id to getSessionById SQL query
- Updated return type to include claude_session_id field
- Session ID now flows correctly: hook → database → worker → SDK

Impact:
- All observation and summary storage now works correctly
- System maintains session consistency throughout lifecycle
- Critical for proper functioning of memory compression

Version Changes:
- package.json: 4.2.7 → 4.2.8
- marketplace.json: 4.2.6 → 4.2.8
- CLAUDE.md: Updated version and added v4.2.8 changelog

Files Changed:
- package.json (version bump)
- .claude-plugin/marketplace.json (version bump)
- CLAUDE.md (version and changelog)
- src/services/sqlite/SessionStore.ts (bugfix)
- plugin/scripts/* (rebuilt with fix)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 22:20:07 -04:00
Alex Newman 81fdf28347 Fix critical bug: getSessionById missing claude_session_id
Critical bugfix for NOT NULL constraint violation.

Problem:
- Worker service calls getSessionById(sessionDbId) to fetch session data
- Worker then uses dbSession.claude_session_id to create ActiveSession
- But getSessionById was NOT selecting claude_session_id from database
- Result: claudeSessionId = undefined in worker
- Caused: "NOT NULL constraint failed: sdk_sessions.claude_session_id" errors
- Impact: Observations and summaries couldn't be stored

Root cause:
- SessionStore.getSessionById() SQL query missing claude_session_id column
- Line 710-713: "SELECT id, sdk_session_id, project, user_prompt"
- Should be: "SELECT id, claude_session_id, sdk_session_id, project, user_prompt"

Fix:
- Added claude_session_id to SELECT query in getSessionById
- Updated return type to include claude_session_id: string
- Now worker correctly receives claude_session_id from database
- Session ID from hook flows properly through entire system

Files changed:
- src/services/sqlite/SessionStore.ts (getSessionById method)

Testing:
- Build succeeded
- Ready for PM2 restart and live testing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 22:18:03 -04:00
Alex Newman b3a565c448 Refactor buildSummaryPrompt to clarify summary instructions and improve user guidance 2025-10-24 22:05:23 -04:00
Alex Newman 5b28c23b20 Refactor WorkerService to use claude_session_id directly from the database
- Updated session initialization to retrieve claude_session_id instead of sdk_session_id.
- Removed redundant comments and code related to sdk_session_id handling.
- Simplified session creation logic by directly using values from the database.
- Cleaned up message handling logic to focus on assistant messages and removed unnecessary checks for system init messages.
2025-10-24 21:54:07 -04:00
Alex Newman f4217cb2b9 Enhance logging in WorkerService for better debugging and summary tracking
- Added logging of received content length and a preview for debugging purposes.
- Introduced detailed logging for summary parsing, including flags for summary components.
- Improved warning logging when no summary tags are found, including a content sample.
- Updated success message for stored summaries to be more descriptive.
2025-10-24 21:48:11 -04:00
Alex Newman e7252c8999 Refactor WorkerService to always store observations and summaries using claudeSessionId 2025-10-24 21:45:52 -04:00
Alex Newman 74637705d7 Release v4.2.7: Enhanced data quality and comprehensive testing
Improvements:
- Enhanced null handling for empty/whitespace fields
- Ensures clean null values in database instead of empty strings
- Improves query efficiency and data consistency

Testing:
- Added comprehensive regression test suite (49 tests)
- Tests v4.2.5 summary fixes and v4.2.6 observation fixes
- Tests edge cases: missing fields, empty fields, whitespace
- New test script: npm run test:parser
- All tests passing with 100% coverage

Code Quality:
- Removed unused extractFileArray() function
- Improved function documentation
- TypeScript diagnostics clean

Technical Details:
- Updated src/sdk/parser.ts extractField function
- Created src/sdk/parser.test.ts regression test suite
- Updated package.json to v4.2.7
- Updated CLAUDE.md with version history
- All changes backward compatible

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 21:38:05 -04:00
Alex Newman 322cb94c43 Release v4.2.6: Critical bugfix for observation validation
Critical Bugfix:
- Fixed overly defensive observation validation blocking observations from being saved
- Parser now NEVER skips observations - always saves them
- Invalid or missing type defaults to "change" (generic catch-all type)
- Removed validation requiring title, subtitle, and narrative fields
- Prevents critical data loss - partial observations better than no observations

Impact:
- Before: Missing title, subtitle, OR narrative caused entire observation to be discarded
- After: ALL observations preserved regardless of field completeness
- Even partial observations contain valuable data: concepts, files_read, files_modified, facts
- LLMs make mistakes - system must be resilient and save everything
- Consistent with v4.2.5 summary fix

Technical changes:
- Updated src/sdk/parser.ts:52-67 to never skip observations
- Uses "change" as fallback type for invalid/missing types (no schema change)
- Updated ParsedObservation interface to allow null for title, subtitle, narrative
- Updated SessionStore.storeObservation signature to accept nullable fields
- Updated built worker-service.cjs
- Bumped version to 4.2.6 in all metadata files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 21:25:44 -04:00
Alex Newman 21c7ab2929 Release v4.2.5: Critical bugfix for summary validation
Critical Bugfix:
- Fixed overly defensive summary validation blocking summaries from being saved
- Removed validation that returned null when any required fields were missing
- Summaries now always saved when <summary> tags present, even if incomplete
- Prevents critical data loss - partial summaries better than no summaries

Impact:
- Before: Missing single field caused entire summary to be discarded
- After: All summaries preserved, maintaining session context when incomplete
- Ensures continuity of memory compression system

Technical changes:
- Updated src/sdk/parser.ts:137-147 to remove blocking validation
- Parser returns ParsedSummary with whatever fields are available
- Updated built worker-service.cjs
- Bumped version to 4.2.5 in all metadata files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 21:16:38 -04:00
Alex Newman 3846d66ccc Refactor parseSummary to always save summary regardless of missing fields
- Removed validation for required fields in parseSummary function.
- Added a note emphasizing the importance of saving the summary even if some fields are missing.
2025-10-24 21:13:43 -04:00
Alex Newman d7b9f68d80 Release v4.2.4: Enhanced summary prompt clarity
Improvements:
- Removed optional skip_summary functionality (summaries now always generated)
- Clarified that summaries are mid-session checkpoints, not session endings
- Improved request field instructions to better form descriptive titles
- Changed wording from "discovered" to "learned" for consistency

Technical changes:
- Updated src/sdk/prompts.ts summary prompt
- Removed "WHEN NOT TO SUMMARIZE" section
- Added clarifying footer text about ongoing sessions
- Updated built worker-service.cjs
- Bumped version to 4.2.4 in all metadata files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 20:50:31 -04:00
Alex Newman 0adbf38c39 fix: update getDirname function to support both ESM and CJS contexts 2025-10-23 23:03:48 -04:00
Alex Newman 15362d1aed Refactor getDirname function to only return __dirname for CJS context 2025-10-23 23:00:34 -04:00
Alex Newman c04e5c571c Merge pull request #16 from thedotmack/copilot/fix-plugin-hook-error
Fix Windows PowerShell compatibility for plugin hook installation
2025-10-23 20:12:25 -04:00
Alex Newman 66a69f3044 Merge pull request #11 from thedotmack/copilot/fix-fts5-injection-vulnerability
Security: Fix FTS5 injection vulnerability in search functions
2025-10-23 19:21:43 -04:00
copilot-swe-agent[bot] e50c6142bb Simplify Windows fix: use idempotent npm install instead of custom installer
Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
2025-10-23 21:50:35 +00:00
copilot-swe-agent[bot] babb375955 Add cross-platform dependency installer for Windows compatibility
Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
2025-10-23 21:25:49 +00:00
Alex Newman 37cd8b8328 fix: Improve summary prompt clarity and consistency in language 2025-10-23 14:21:31 -04:00
Alex Newman 33d2422faa Refactor summary prompt for clarity and emphasis on deliverables
- Changed the title of the summary prompt to "THIS REQUEST'S SUMMARY" for better context.
- Revised instructions to focus on summarizing what was built/fixed/deployed/configured, rather than the observation process.
- Clarified when not to summarize, emphasizing conversational requests and trivial inquiries.
- Updated examples to better illustrate good summary practices.
2025-10-23 14:08:42 -04:00
copilot-swe-agent[bot] dad3a104b4 Fix FTS5 injection vulnerability with proper escaping and comprehensive tests
Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
2025-10-23 09:22:31 +00:00
Alex Newman f556546994 feat: Optimize context hook file listings to save tokens
Improvements to SessionStart context hook file display:

1. **Remove redundant files**: Files in "Modified" list are now excluded from "Read" list
   - Prevents duplication when a file was both read and modified
   - Reduces token usage by eliminating redundant information

2. **Use relative paths**: Convert absolute paths to project-relative paths
   - Example: /Users/alexnewman/Scripts/claude-mem/src/hooks/context.ts → src/hooks/context.ts
   - Significantly reduces token consumption in context injection
   - Makes file references more readable and portable

Implementation:
- Added toRelativePath() helper function to convert paths
- Added filesModifiedSet.forEach(file => filesReadSet.delete(file)) to remove duplicates
- Applied to both files_read and files_modified when building Sets

Impact: Reduces token usage in Tier 1 summaries (most recent session) where file lists are displayed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 17:23:44 -04:00
Alex Newman 2952b7fb8d feat: Add summary skip logic to prevent duplicate and trivial summaries
Added "WHEN NOT TO SUMMARIZE" section to buildSummaryPrompt that instructs the SDK to skip creating summaries for:
- Work already covered in previous prompts (prevents duplicates)
- Conversational banter with no deliverables
- Trivial requests (questions, status checks)
- Meta-discussions about memory system without shipped changes

Implementation:
- src/sdk/prompts.ts: Added WHEN NOT TO SUMMARIZE section with <skip_summary> output format
- src/sdk/parser.ts: Added skip_summary detection before parsing full summary XML
- src/sdk/parser.ts: Fixed observation type validation to include all 6 types (bugfix, feature, refactor, change, discovery, decision)

This should eliminate the duplicate summaries like the three "restore 6 types" summaries we saw for session d9137878.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 00:07:30 -04:00
Alex Newman 3cb003f4e4 fix(prompts): restore all 6 observation types for better search granularity
Restored full type system: bugfix, feature, refactor, change, discovery, decision.
This enables more precise search queries like "show all bugfixes in auth" vs generic "show all changes".

Also updated README to reflect current behavior (10 summaries with three-tier verbosity).

Changes:
- prompts.ts: Expanded type field from 3 to 6 types with clear definitions
- CLAUDE.md: Fixed context hook description (3 → 10 summaries)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 23:47:01 -04:00
Alex Newman 8b5e5efeb5 fix(prompts): prevent meta-referential descriptions in observations and summaries
Updated SDK prompts to distinguish between deliverables (what was built/shipped) vs meta-operations (what the memory system is doing). This prevents self-referential pollution like "Process tool executions" instead of actual coding tasks like "Fix authentication bug".

Changes:
- buildInitPrompt: Added deliverable-focused framing with contrastive examples
- buildSummaryPrompt: Injected user's original prompt + explicit examples
- Added verb guidance (implemented/fixed/deployed vs analyzed/tracked/stored)
- Added "NOW DOES" present-tense capability framing

Works across all project types: dev, DevOps, docs, infrastructure, research, config.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 23:42:12 -04:00
Alex Newman a57aba82a4 fix(context-hook): remove Learned from Tier 2
Tier 2 should only show Request + Completed + Date, not Learned.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 23:08:54 -04:00