| 1234567891011121314151617181920 |
- import type { WorkspaceV2 } from "@kirincode-ai/core/workspace"
- import { Flag } from "@kirincode-ai/core/flag/flag"
- import { Effect, Scope } from "effect"
- /**
- * Scoped override for `Flag.KIRINCODE_WORKSPACE_ID`. Saves the previous value
- * on entry and restores it via finalizer when the surrounding scope closes —
- * preserves the original try/finally semantics regardless of test outcome.
- */
- export function withFixedWorkspaceID(id: WorkspaceV2.ID): Effect.Effect<void, never, Scope.Scope> {
- return Effect.gen(function* () {
- const previous = Flag.KIRINCODE_WORKSPACE_ID
- Flag.KIRINCODE_WORKSPACE_ID = id
- yield* Effect.addFinalizer(() =>
- Effect.sync(() => {
- Flag.KIRINCODE_WORKSPACE_ID = previous
- }),
- )
- })
- }
|