refactor(opencode): improve startup time by 38% (#30453)
Co-authored-by: starptech <starptech@starptechs-MBP.fritz.box>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import type { Argv } from "yargs"
|
||||
import { Effect, Schema } from "effect"
|
||||
import { AppRuntime, type AppServices } from "@/effect/app-runtime"
|
||||
import { InstanceStore } from "@/project/instance-store"
|
||||
import { InstanceRef } from "@/effect/instance-ref"
|
||||
import type { AppServices } from "@/effect/app-runtime"
|
||||
import type { InstanceStore } from "@/project/instance-store"
|
||||
import { cmd, type WithDoubleDash } from "./cmd/cmd"
|
||||
|
||||
/**
|
||||
@@ -74,6 +73,7 @@ export const effectCmd = <Args, A>(opts: EffectCmdOpts<Args, A>) =>
|
||||
describe: opts.describe,
|
||||
builder: opts.builder as never,
|
||||
async handler(rawArgs) {
|
||||
const { AppRuntime } = await import("@/effect/app-runtime")
|
||||
// yargs typing wraps Args in ArgumentsCamelCase<WithDoubleDash<...>>; cast at the boundary.
|
||||
const args = rawArgs as unknown as WithDoubleDash<Args>
|
||||
const useInstance = typeof opts.instance === "function" ? opts.instance(args) : opts.instance !== false
|
||||
@@ -81,6 +81,8 @@ export const effectCmd = <Args, A>(opts: EffectCmdOpts<Args, A>) =>
|
||||
await AppRuntime.runPromise(opts.handler(args))
|
||||
return
|
||||
}
|
||||
const { InstanceStore } = await import("@/project/instance-store")
|
||||
const { InstanceRef } = await import("@/effect/instance-ref")
|
||||
const directory = opts.directory?.(args) ?? process.cwd()
|
||||
const { store, ctx } = await AppRuntime.runPromise(
|
||||
InstanceStore.Service.use((store) => store.load({ directory }).pipe(Effect.map((ctx) => ({ store, ctx })))),
|
||||
|
||||
Reference in New Issue
Block a user