Skip to content

feat(opencode): OC Kit installer, updater, registry client and doctor (Phase 7-8) - #12

Merged
qkhalk merged 6 commits into
mainfrom
feature/oc-kit-installer
Aug 27, 2026
Merged

qkhalk merged 6 commits into
mainfrom
feature/oc-kit-installer

Conversation

@qkhalk

@qkhalk qkhalk commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #8

Type of change

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

What does this PR do?

Implements the OC Kit install/update lifecycle (Phases 7-8) against a GitHub
Releases registry backend, plus a doctor health check.

  • src/ockit/registry-remote.ts — typed remote registry client: resolves the
    latest compatible release (or an exact tag), reads checksums + kit manifest,
    and guards min_opencode compatibility against the running runtime.
  • src/ockit/installer.ts — install/uninstall: resolve → download → sha256
    verify → extract → ownership claim → write → checkpoint rollback snapshot.
  • src/ockit/updater.ts — update pipeline: detects user edits, plans replace/
    preserve/warn per file, applies only owned-unmodified replacements, and
    rolls back to the latest checkpoint when asked.
  • src/ockit/doctor.ts — typed DoctorReport over runtime, config, installed
    kits, registry reachability, ownership conflicts, broken manifests, and
    checkpoint count.
  • scripts/install.sh + scripts/install.ps1 — single-command installers.
  • test/ockit/{registry-remote,installer,updater,doctor}.test.ts — unit tests.

Why this works:

  • All typed errors are Schema.TaggedErrorClass with a kind discriminator,
    and every FSUtil/HTTP/checkpoint error is collapsed to the module's domain
    error so callers see one typed channel.
  • Process.run (spawn-backed) drives tar/unzip/Expand-Archive — no shell
    flag, so it passes the pinned @types/bun typecheck.
  • Ownership + checkpoint modules are consumed but not modified (shared read-only).

How did you verify your code works?

Unit tests added for release resolution/checksum/incompatible handling, the
install pipeline (checksum verify + ownership + dev mode), update planning
(user edits preserved, unmodified files replaced), rollback (restores previous
bytes), and doctor report sections. The full diff is cb8f9df..HEAD and CI
(typecheck + unit linux) is the verification gate.

Screenshots / recordings

Not a 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 20, 2026 04:25

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:

…(Phase 7-8)

CI (typecheck + unit linux) caught schema and overload regressions in the
Phase 7-8 installer workstream. Root causes:

- `Schema.Literal(a, b, c)` resolves to the unary Decorator literal in
  effect@4.0.0-beta.83, narrowing each kind/mode/severity schema to its first
  value (fetch, production, pass). Switched to the array form
  `Schema.Literals([...])` (the repo-wide idiom) in DoctorItem, InstallerError,
  InstallSummary, UpdateError and ReleaseError.
- `Effect.fn(function* (...) : Effect.Effect<...>)` return-type annotations are
  self-referential/unsupported for generators in beta.83. Removed them from
  collectFiles/downloadAndExtract/install/uninstall (installer), doctor (doctor),
  previewUpdate/update/rollback (updater) — bare Generator, matching merged-good
  Effect.fn usage.
- `Effect.orElse` does not exist in beta.83; replaced the tar->unzip extraction
  fallback with `Effect.catch` (the repo's catch-style fallback).
- `fetchJson` was escaping its payload type via `as never`; made it a generic
  factory over the decoded Schema so ReleaseInfo flows as a real typed value.
- Tests: wrap plain-assertion it.effect bodies in Effect.gen, inject the fake
  HttpClient via the `http` option (no fragile Effect.provide layer), squeeze
  typed errors via Exit/Cause.squash. Verifies: checksum failures, dev mode,
  doctor warn items, and rollback/not-found errors now assert on the intended
  union kinds instead of the narrowed single literal.
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

- registry-remote: whenIncompatible returns ReleaseInfo | undefined; map
  HttpClientError to ReleaseError inside fetchJson/fetchText; guard pinned
  release info before returning incompatible error
- installer: widen extract seam to FSUtil.Error; type walk closure; map
  download/extract/fs errors to InstallerError; uninstall uses OwnershipEntry
- updater: map FSUtil and checkpoint errors to UpdateError across preview,
  update and rollback
- registry-remote test: provide HttpClient via Effect.provideService instead
  of the http injection option so the effect has no service requirement
…ipeline

- fetchText maps the response-body read to ReleaseError so resolveLatest
  callers never see HttpClientError in the error channel
- extract error handler reads err.message only (both error types extend Error)
- latestBackupDir reads dir entries via FSUtil (typed error) instead of a
  raw fs/promises readdir that inferred a never error channel
@github-actions

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

The update() calls in updater.test.ts were missing the extract option,
causing the real extractArchive to run tar -xzf on stub data that is
not gzip format. Pass fakeExtract(KIT_V2_FILES) to all update() calls
that trigger archive extraction.

Fixes 4 failing tests in PR #12:
- ockit registry-remote > treats incompatible min_opencode as not-found
- ockit updater > update with --dry-run previews without mutating
- ockit updater > update replaces owned-unmodified files
- ockit updater > rollback restores previous bytes

The registry-remote test failure was a cascade from the updater tests
running in the same turbo test suite.
@qkhalk
qkhalk merged commit 1f72e4b into main Aug 27, 2026
6 of 8 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.

feat(opencode): oc kit CLI (list, validate) on Phase 1 domain model

3 participants