Repository navigation
feat(opencode): OC Kit hooks bus and artifact manager (Phase 5) - #11
Merged
Merged
Conversation
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Phase 5 of the OC Kit MVP (see plans/260820-0317-ockit-mvp-phases-3-8/).
Type of change
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— purematches/matchHooks/knownEventOrThrowwith trailing-wildcard support; no I/O; trivially testable; typedHookError.src/ockit/hook/dispatcher.ts— runs each matching hook'scommandas an ordinary subprocess (Bun.spawn through the shell) and observesproc.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 typedHookError.Artifacts:
src/ockit/artifact/manifest.ts—ArtifactManifestschema (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 soverifycan detect tampering. Honors theoc_kit.checkpointconfig 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 typeused where only the type is needed; kebab-case files; theexport * as X from "./index"self-export convention.How did you verify your code works?
Unit tests under
test/ockit/hook/*andtest/ockit/artifact/*exercise real behavior against real effects (FSUtil node layer, real child processes viait.live, real config layer). Typecheck and unit(linux) are the CI gates for this PR.Screenshots / recordings
N/A — no UI change.
Checklist