Skip to content

feat(hooks): ocgs-hooks extension for Pi and oh-my-pi - #113

Merged
striderZA merged 4 commits into
masterfrom
feat/ocgs-hooks-pi-omp
Nov 4, 2026
Merged

striderZA merged 4 commits into
masterfrom
feat/ocgs-hooks-pi-omp

Conversation

@striderZA

Copy link
Copy Markdown
Owner

Summary

Ports the 12 CCGS hooks listed under "Hooks Mapping" in README.md to Pi and oh-my-pi as one extension, .pi/extensions/ocgs-hooks/. The harness-neutral logic lives in core.ts. index.ts maps it to each harness's events. omp loads the extension through .omp/config.yml.

Related Issues

None. No tracking issue exists for this work. Design and mapping are in docs/pi-extensions.md#ocgs-hooks and the root README.md "Hooks Mapping".

Type of Change

  • New feature
  • Documentation

Commits (review in order)

  1. 3b904cb core.ts: harness-neutral hook logic, no Pi or omp imports
  2. 222299f index.ts and tests: event wiring, subagent stop guard, regression test
  3. 53975d5 .omp/config.yml and the omp config test (seven extensions)
  4. 67ab290 docs: Pi extension reference, omp wiring table, root pointer, Pi workflow row

Differences from the bash originals

  • Compaction context: Pi has no hook that runs before the summary is written. On Pi the context is sent as a hidden message after compaction. omp puts it in the summary via session.compacting.
  • Subagent guard is omp-only: ctx.agent.kind === "sub" skips the session-start, session-stop, and compaction handlers. Pi's ExtensionContext has no agent field, so on Pi these guards never match.
  • Session log: agent_settled fires after every run, so session-log.md gets one entry per run.
  • Not ported: upstream hooks outside the 12 (validate-read, validate-write, validate-registry, validate-agent-artifact, update-check, log-instructions).

Testing

  • npm run test:extensions: 61 pass, 36 of them in tests/extensions/test-ocgs-hooks.test.mjs
  • npm run test:omp: 3 pass
  • npm run test:framework: passes
  • Regression: the two subagent-stop tests failed before the guard (2 fail, 34 pass) and pass after it
  • Headless load: pi --mode rpc -a and omp --mode rpc, no prompt. Both exit 0 with empty stderr, and the session_start summary is emitted. omp's log shows no ocgs-hooks load errors.

The PR template's test command points at .opencode/plugins/tests/, which does not cover this change. The suites above are the ones that do.

Not verified

  • Model-driven behavior: compaction context reaching the model, the notification UI, and ui_prompt_start / tool_approval_requested firing in a live session.
  • Type checking: tsc is not installed, so the TypeScript is exercised at runtime only.

Checklist

  • Conventional Commits style used in branch commits
  • README updated for the new public interface (root "Hooks Mapping" pointer, Pi extension table and reference)
  • No secrets or credentials committed

Ports the hook logic from .opencode/plugins/ccgs-hooks.ts into a pure
Node module with no Pi or omp imports. The wiring is in a separate
extension (next commit), so this logic runs under node --test directly.

Git calls use argv instead of a shell. Notifications spawn detached, so
a missing notifier binary cannot block the agent.
Maps the 12 hooks listed under "Hooks Mapping" in README.md to Pi and
omp events. Pi auto-discovers .pi/extensions/ocgs-hooks. omp loads it
through .omp/config.yml (next commit).

Each harness emits only some of the events. A handler for an event the
running harness never emits never fires.

The shared session-stop handler skips subagent sessions
(ctx.agent.kind === "sub"), so a child session cannot archive the
parent's active.md. Pi's ExtensionContext has no agent field, so this
guard is inert on Pi.

Tests cover the commit and push guards, asset and skill checks, agent
audit, compaction context, and the subagent stop regression.
Adds the extension to the project config and to the expected extension
list in tests/omp/test-config.test.mjs, which is now seven entries.
Adds the extension to the Pi extension table and reference, the omp
wiring table, the root hooks section, and the Pi workflow comparison.

The reference lists where Pi and omp differ from the bash originals: no
pre-summary compaction hook on Pi, one session-log entry per run, and
subagent detection only on omp.
@striderZA
striderZA merged commit 213d719 into master Nov 4, 2026
5 checks passed
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.

1 participant