Skip to content

feat(opencode): OC Kit hooks bus and artifact manager (Phase 5) - #11

Merged
qkhalk merged 3 commits into
mainfrom
feature/oc-kit-runtime
Aug 19, 2026
Merged

qkhalk merged 3 commits into
mainfrom
feature/oc-kit-runtime

Conversation

@qkhalk

@qkhalk qkhalk commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Issue for this PR

Phase 5 of the OC Kit MVP (see plans/260820-0317-ockit-mvp-phases-3-8/).

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds the OC Kit runtime subsystems that Phase 5 of the OC Kit MVP scope needs: the lifecycle hooks bus (event definitions, event matcher, command dispatcher) and the typed artifact manager (persistent manifest index, create/read/list/verify, integrity checksums).

Hooks:

  • src/ockit/hook/events.ts — Effect Schema discriminated union of every OC Kit lifecycle event (kit:*, session:*, workflow:*, skill:*, tool:*, permission:request, artifact:created, checkpoint:created, verification:*). Events carry only observational data — never handles that could elevate permission.
  • src/ockit/hook/matcher.ts — pure matches/matchHooks/knownEventOrThrow with trailing-wildcard support; no I/O; trivially testable; typed HookError.
  • src/ockit/hook/dispatcher.ts — runs each matching hook's command as an ordinary subprocess (Bun.spawn through the shell) and observes proc.exited. It never reads, grants, skips, or fabricates a permission decision, and it does not inject secrets via env vars — the only extra vars are the event name and the command itself. A failing command surfaces a typed HookError.

Artifacts:

  • src/ockit/artifact/manifest.ts — ArtifactManifest schema (local to the module, honoring the ownership contract that the shared domain schema in types.ts is not extended), load/save under .oc/artifacts/manifest.json.
  • src/ockit/artifact/manager.ts — create/list/read/verify/markVerified/markFailed. Each record stores the sha256 of the content file so verify can detect tampering. Honors the oc_kit.checkpoint config flag: when enabled, creating an artifact also writes a checkpoint marker through the shared checkpoint module.

Constraints honored: only my owned files (hook + artifact modules and their tests); no change to types.ts, src/ockit/index.ts, the CLI, or the workflow module; relative imports; import type used where only the type is needed; kebab-case files; the export * as X from "./index" self-export convention.

How did you verify your code works?

Unit tests under test/ockit/hook/* and test/ockit/artifact/* exercise real behavior against real effects (FSUtil node layer, real child processes via it.live, real config layer). Typecheck and unit(linux) are the CI gates for this PR.

Screenshots / recordings

N/A — no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copilot AI lite review requested due to automatic review settings August 19, 2026 22:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

The following comment was made by an LLM, it may be inaccurate:

The pinned @types/bun SpawnOptions has no shell option, so Bun.spawn with
shell:true fails typecheck. Use the committed @/util/process wrapper
(Process.spawn) which drives cross-spawn with shell support. Child env
inherits process.env per Process.spawn contract; only OC_KIT_EVENT and
OC_KIT_HOOK_COMMAND metadata are added.
@qkhalk
qkhalk merged commit cb8f9df into main Aug 19, 2026
7 of 8 checks passed
@qkhalk
qkhalk deleted the feature/oc-kit-runtime branch August 19, 2026 23:01
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