Files
kilocode/packages/opencode/test/server/httpapi-exercise/runtime.ts
T
Aarav 12c392ce44 test(cli): optimize httpapi exerciser by removing redundant git fixtures and isolating scenario passes (#13091)
* test(cli): optimize httpapi exerciser by removing redundant git fixtures and isolating scenario passes

- Default scenario project fixture is now in-memory; only VCS/worktree/diff
  routes opt into git init via .inProject({ git: true }).
- mode coverage becomes a standalone fast static check that skips the full
  runtime/LLM/DB allocation.
- --shard <index>/<total> flag lets CI runners fan the exerciser out across
  processes; each shard already owns an isolated PID-keyed DB.

Refs #12999

* test(cli): keep coverage mode off the runtime and run llm scenario guard statically

- Move the runtime() finalizer below the coverage early-return so the
  static OpenAPI comparison path never imports session/worktree/project.
- Hoist the llmScenarios consistency check above the coverage branch so a
  scenario missing .withLlm() is still caught in static mode.
- Coverage branch now runs cleanupExercisePaths directly before returning.
- Fix typo HEAD-baseed -> HEAD-based in dsl.ts comment.

* test(cli): opt three scenarios into git init that depend on a git-backed project

CI surfaced three regressions after switching the default scenario
fixture to in-memory. Each scenario asserts behavior that requires
the project directory to be a git worktree:

- path.get: `body.worktree === ctx.directory`
- project.current: `body.worktree === ctx.directory`
- v2.session.permission.create: `body.data.effect === "ask"`
  for an untracked resource (the permission resolver consults VCS
  state before deciding to ask).

Adding `.inProject({ git: true })` to each restores the prior
behavior without re-introducing the global git init default.
2026-08-13 19:17:36 +02:00

58 lines
2.7 KiB
TypeScript

export type Runtime = {
PublicApi: (typeof import("../../../src/server/routes/instance/httpapi/public"))["PublicApi"]
HttpApiApp: (typeof import("../../../src/server/routes/instance/httpapi/server"))["HttpApiApp"]
AppLayer: (typeof import("../../../src/effect/app-runtime"))["AppLayer"]
memoMap: import("effect").Layer.MemoMap
InstanceRef: (typeof import("../../../src/effect/instance-ref"))["InstanceRef"]
InstanceStore: (typeof import("../../../src/project/instance-store"))["InstanceStore"]
Session: (typeof import("../../../src/session/session"))["Session"]
Todo: (typeof import("../../../src/session/todo"))["Todo"]
Worktree: (typeof import("../../../src/worktree"))["Worktree"]
Project: (typeof import("../../../src/project/project"))["Project"]
Tui: typeof import("../../../src/server/shared/tui-control")
disposeAllInstances: (typeof import("../../fixture/fixture"))["disposeAllInstances"]
tmpdir: (typeof import("../../fixture/fixture"))["tmpdir"]
}
// kilocode_change start - coverage only needs the OpenAPI group; bypass the full runtime import to keep
// static route-coverage checks sub-second on CI
export async function publicApi() {
const publicApiModule = await import("../../../src/server/routes/instance/httpapi/public")
return publicApiModule.PublicApi
}
// kilocode_change end
let runtimePromise: Promise<Runtime> | undefined
export function runtime() {
return (runtimePromise ??= (async () => {
const publicApi = await import("../../../src/server/routes/instance/httpapi/public")
const httpApiServer = await import("../../../src/server/routes/instance/httpapi/server")
const appRuntime = await import("../../../src/effect/app-runtime")
const { Layer } = await import("effect")
const instanceRef = await import("../../../src/effect/instance-ref")
const instanceStore = await import("../../../src/project/instance-store")
const session = await import("../../../src/session/session")
const todo = await import("../../../src/session/todo")
const worktree = await import("../../../src/worktree")
const project = await import("../../../src/project/project")
const tui = await import("../../../src/server/shared/tui-control")
const fixture = await import("../../fixture/fixture")
return {
PublicApi: publicApi.PublicApi,
HttpApiApp: httpApiServer.HttpApiApp,
AppLayer: appRuntime.AppLayer,
memoMap: Layer.makeMemoMapUnsafe(),
InstanceRef: instanceRef.InstanceRef,
InstanceStore: instanceStore.InstanceStore,
Session: session.Session,
Todo: todo.Todo,
Worktree: worktree.Worktree,
Project: project.Project,
Tui: tui,
disposeAllInstances: fixture.disposeAllInstances,
tmpdir: fixture.tmpdir,
}
})())
}