Skip to content

Conversation

@code-yeongyu
Copy link
Owner

@code-yeongyu code-yeongyu commented Dec 20, 2025

Summary

🎤 Live demo from instruct.kr event

  • Add PreCompact hook support for OpenCode's experimental.session.compacting event
  • Allows Claude Code hooks to inject additional context into compaction prompts before session compaction occurs

Changes

  • types.ts: Added PreCompact hook event type, PreCompactInput, PreCompactOutput interfaces
  • pre-compact.ts: New PreCompact hook executor implementation
  • index.ts: Added experimental.session.compacting event handler
  • config.ts & config-loader.ts: Added PreCompact to hook config loading

Usage Example

{
  "hooks": {
    "PreCompact": [
      {
        "matcher": "*",
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/pre-compact/inject-context.sh" }
        ]
      }
    ]
  }
}

Hook scripts can output { "context": ["additional context string"] } to inject context into the compaction prompt.


🤖 Generated with assistance of OhMyOpenCode

@code-yeongyu code-yeongyu changed the base branch from master to dev December 21, 2025 09:02
….session.compacting event

Implement PreCompact hook executor to inject additional context into session compaction prompts. Includes:
- PreCompactInput/PreCompactOutput type definitions
- Pre-compact executor implementation with context injection
- Event handler registration for experimental.session.compacting
- Config loading and disabled hooks support

🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants