effectify Worktree service with Effect layer and facades

Migrate Worktree from direct Instance ALS reads to the Effect service
pattern: define Interface, Service, layer (yielding InstanceContext),
and promise facades using runPromiseInstance. Wire into instances.ts.
This commit is contained in:
Kit Langton
2026-03-19 21:23:30 -04:00
parent 52a7a04ad8
commit b3023f0fa0
3 changed files with 416 additions and 330 deletions
@@ -10,6 +10,7 @@ import { ProviderAuth } from "@/provider/auth"
import { Question } from "@/question"
import { Skill } from "@/skill/skill"
import { Snapshot } from "@/snapshot"
import { Worktree } from "@/worktree"
import { InstanceContext } from "./instance-context"
import { registerDisposer } from "./instance-registry"
@@ -26,6 +27,7 @@ export type InstanceServices =
| File.Service
| Skill.Service
| Snapshot.Service
| Worktree.Service
// NOTE: LayerMap only passes the key (directory string) to lookup, but we need
// the full instance context (directory, worktree, project). We read from the
@@ -46,6 +48,7 @@ function lookup(_key: string) {
Layer.fresh(File.layer),
Layer.fresh(Skill.defaultLayer),
Layer.fresh(Snapshot.defaultLayer),
Layer.fresh(Worktree.layer),
).pipe(Layer.provide(ctx))
}