Commit Graph

258 Commits

Author SHA1 Message Date
Alex Newman bcfd036dfe Merge pull request #38 from thedotmack/copilot/update-documentation-stop-claude-code
Clarify Stop hook is automatic, not user action
2025-11-03 13:40:00 -05:00
Alex Newman ebf53e9fb0 Merge pull request #39 from thedotmack/thedotmack-patch-1-1
Update repository link in README.md
2025-11-02 21:56:59 -05:00
Alex Newman 7133108f15 Document usage tracking feature in CLAUDE.md 2025-11-02 21:53:58 -05:00
Alex Newman f20bb5bced Add SDK usage tracking to JSONL logs
Features:
- New UsageLogger utility that writes usage metrics to daily JSONL files
- Captures token counts, costs, timing, and cache metrics from SDK result messages
- Usage logs stored in ~/.claude-mem/usage-logs/ (one file per day)
- Added analyze-usage.js script for analyzing usage patterns

Usage data captured:
- Token counts (input, output, cache creation, cache read)
- Total cost in USD per API call
- Duration metrics (total and API time)
- Number of turns per session
- Session and project attribution

Analysis script features:
- Aggregates totals by project and model
- Shows cache hit rates and savings
- Displays cost breakdowns and averages
- npm scripts: usage:analyze and usage:today

Files:
- src/utils/usage-logger.ts (new)
- src/services/worker-service.ts (modified - captures SDK result messages)
- scripts/analyze-usage.js (new)
- package.json (added usage:* npm scripts)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 21:53:42 -05:00
Alex Newman e238a81b34 Update repository link in README.md 2025-11-02 20:57:24 -05:00
Alex Newman 9215c7e1f5 Release v4.3.4: Fix SessionStart hooks on resume
Fixes:
- Fixed SessionStart hooks running on session resume
- Added matcher configuration to only run hooks on startup, clear, or compact events
- Prevents unnecessary hook execution and improves performance

Technical changes:
- Modified plugin/hooks/hooks.json (added matcher)
- Updated version to 4.3.4 in all metadata files

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

Co-Authored-By: Claude <noreply@anthropic.com>
v4.3.4
2025-11-01 21:47:00 -04:00
Alex Newman b694f233db Remove unwanted index.html file 2025-11-01 21:45:29 -04:00
Alex Newman c9e0301e3e Create index.html for landing page design 2025-11-01 20:36:58 -04:00
copilot-swe-agent[bot] 192adf5cbc Fix: /clear DOES inject context via SessionStart hook
Corrected incorrect documentation that claimed /clear doesn't inject context.
The SessionStart hook fires with source: "clear" when /clear is used, which
re-injects context from recent sessions. Updated docs to accurately reflect
that /clear both clears conversation AND re-injects fresh context.

Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
2025-10-31 21:28:54 +00:00
copilot-swe-agent[bot] 140a5f3469 Clarify Stop hook behavior and /clear vs exit in docs
- Changed "Stop Claude" to "Claude finishes responding" to clarify that the Stop hook fires automatically
- Explained Stop hook triggers summary generation automatically, not as a user action
- Added detailed section explaining /clear behavior vs completely exiting Claude Code
- Clarified when new context is injected (new session start, not after /clear)
- Fixed session count: changed "last 3 sessions" to "last 10 sessions" (matches implementation)

Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
2025-10-31 21:06:59 +00:00
copilot-swe-agent[bot] 5c4b44d4c7 Initial plan 2025-10-31 21:02:02 +00:00
Alex Newman 3bbacb8fa4 Release v4.3.3: Configurable session display and first-time setup UX
Improvements:
- Made session display count configurable (DISPLAY_SESSION_COUNT = 8)
- Added first-time setup detection with helpful user messaging
- Improved UX: First install message clarifies Plugin Hook Error display
- Cleaned up code comments

Technical changes:
- Updated src/hooks/context-hook.ts (configurable session count)
- Updated src/hooks/user-message-hook.ts (first-time setup detection)
- Rebuilt plugin/scripts/context-hook.js
- Rebuilt plugin/scripts/user-message-hook.js
- Bumped version to 4.3.3 in all metadata files

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

Co-Authored-By: Claude <noreply@anthropic.com>
v4.3.3
2025-10-27 01:22:47 -04:00
Alex Newman d69a95bd29 Refactor PM2 ecosystem configuration: set restart delay to 0 and reduce timeout values 2025-10-27 00:52:40 -04:00
Alex Newman 90b209081c Add GitHub release step to version-bump skill workflow 2025-10-27 00:25:44 -04:00
Alex Newman 6d145c035c Update version-bump skill to include plugin.json and git tagging workflow v4.3.2 2025-10-27 00:17:09 -04:00
Alex Newman bd5ad6e5c2 Update version-bump skill documentation and bump plugin version to 4.3.2 2025-10-27 00:14:18 -04:00
Alex Newman 28005b75af Release v4.3.2: User-facing context display via stderr hook
Improvements:
- Added user-message-hook for displaying context to users (src/hooks/user-message-hook.ts)
- Hook fires simultaneously with context injection, sending duplicate message via stderr
- Error messages don't get added to context, enabling user visibility
- Added 4 comprehensive documentation files (2500+ lines total)
- Improved cross-platform path handling in context-hook

Technical changes:
- New: src/hooks/user-message-hook.ts (stderr-based display mechanism)
- New: plugin/scripts/user-message-hook.js (built executable)
- New: docs/architecture-evolution.mdx (801 lines)
- New: docs/context-engineering.mdx (222 lines)
- New: docs/hooks-architecture.mdx (784 lines)
- New: docs/progressive-disclosure.mdx (655 lines)
- Modified: plugin/hooks/hooks.json (hook configuration)
- Modified: src/hooks/context-hook.ts (path handling)
- Modified: scripts/build-hooks.js (build support)
- Bumped version to 4.3.2 in all metadata files

Design rationale: Temporary workaround until Claude Code potentially adds ability to share messages with both user and context simultaneously.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 00:11:13 -04:00
Alex Newman 322f81e515 Merge pull request #31 from thedotmack/test/stderr-hook-experiment
Add User-Facing Context Display via stderr Hook
2025-10-27 00:05:34 -04:00
Alex Newman ea54a03fae Refactor: Update stderr-test-hook to user-message-hook and improve path handling 2025-10-27 00:04:26 -04:00
Alex Newman 15c55a57a3 Rename stderr-test-hook to user-message-hook for production
Changes:
- Renamed src/hooks/stderr-test-hook.ts to user-message-hook.ts
- Updated user-message-hook with production-ready messaging
- Updated scripts/build-hooks.js to build user-message-hook
- Updated plugin/hooks/hooks.json to reference user-message-hook.js
- Cleaned up old stderr-test-hook.js files
- Built and deployed user-message-hook.js to plugin directory

This hook displays context information to users via stderr, which is
currently the only way to show messages in Claude Code UI. It runs in
parallel with context-hook during SessionStart.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 23:14:19 -04:00
Alex Newman 056cd12558 Fix: Remove duplicate shebang from stderr-test-hook source 2025-10-26 22:33:01 -04:00
Alex Newman b0fae0cfd4 Add stderr test hook for UI experiment 2025-10-26 22:29:43 -04:00
Alex Newman 44b69b737b Remove memory toggle feature documentation as it is no longer relevant 2025-10-26 00:44:31 -04:00
Alex Newman 56213ef84a Fix: Update npm loglevel to silent in SessionStart hook to prevent context injection issues; consolidate hooks architecture and update documentation for v4.3.1 2025-10-26 00:44:04 -04:00
Alex Newman 64dfc0467d Docs: Update CHANGELOG.md and README.md for v4.3.1
- Added v4.3.1 entry to CHANGELOG.md with detailed fixes
- Updated README.md version badge to v4.3.1
- Updated "What's New" section highlighting SessionStart hook fix
- Documented hooks architecture consolidation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 00:14:53 -04:00
Alex Newman c75563a89b Release v4.3.1: Version bump and documentation updates
- Updated package.json version to 4.3.1
- Updated marketplace.json version to 4.3.1
- Added v4.3.1 entry to CLAUDE.md version history
- Documented SessionStart hook context injection fix
- Documented hooks architecture consolidation
- Rebuilt all executables with updated version

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

Co-Authored-By: Claude <noreply@anthropic.com>
v4.3.1
2025-10-26 00:11:36 -04:00
Alex Newman fb00b517c0 Fix: Silence npm output in SessionStart hook to fix context injection
Problem: npm install outputs "up to date in Xms" to stdout, which prepends
non-JSON text to the hook output. Claude Code expects pure JSON and cannot
parse the output, causing context injection to fail silently.

Solution: Changed npm install flag from --loglevel=error to --loglevel=silent
to completely suppress stdout output, ensuring clean JSON output for hook.

Impact: SessionStart hook will now properly inject recent context into sessions.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 00:06:53 -04:00
Alex Newman df44bd8fd3 Fix double shebang: remove shebang from TS source files (esbuild adds it) 2025-10-26 00:01:04 -04:00
Alex Newman e9c0ec45db Consolidate hooks: merge bin/hooks and hooks into single hooks/ directory
- Removed bin/hooks/ wrapper layer
- Moved all hook logic into consolidated hooks/*-hook.ts files
- Each hook now handles its own stdin/stdout/JSON wrapping
- Removed ALL try-catch blocks from context-hook (let errors surface)
- Updated build script to reference new src/hooks/ paths
- Reduced from 12+ files to 6 hook files

This simplifies the architecture and makes debugging actually possible.
2025-10-25 23:59:43 -04:00
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>
v4.3.0
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 19ecc7845f docs: Consolidate version history in CHANGELOG.md
Changes:
- CHANGELOG.md now contains detailed version history (already has v4.2.11)
- CLAUDE.md Version History section now:
  - References CHANGELOG.md for detailed history
  - Shows current version (4.2.11)
  - Includes brief highlights for recent versions only
  - Removed ~250 lines of detailed version documentation

This makes documentation more maintainable - single source of truth for
version history in CHANGELOG.md following Keep a Changelog format.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 15:13:14 -04:00
Alex Newman 142d6ae56f chore: Update changelog for v4.2.11 with cross-platform path detection fixes 2025-10-25 15:12:05 -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 b87654d452 Release v4.2.11: Cross-platform Claude path detection
Critical Bugfix:
- Fixed SDK auto-detection failure by implementing explicit which/where commands
- 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)

Impact:
- Before: Worker failed with "path must be string, received undefined"
- After: Worker correctly finds Claude executable on all platforms

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
- Bumped version to 4.2.11 in all metadata files
- Updated CLAUDE.md with v4.2.11 release notes

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

Co-Authored-By: Claude <noreply@anthropic.com>
v4.2.11
2025-10-25 14:56:30 -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 ab0938633a worker 2025-10-25 14:39:13 -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 6131f9694a Update @anthropic-ai/claude-agent-sdk to version 0.1.27 in package.json and package-lock.json 2025-10-25 14:32:37 -04:00