Files
orca/src/cli/runtime/environments.ts
T
NeilandOrca 73c5009b82 chore(dead-code): drop ~2k lines of unreachable exports and orphan modules (#12077)
* chore(dead-code): drop 2k lines of unreachable exports and orphan modules

Ran knip across every build entry (main, preload, renderer, popout, web,
cli, relay, workers, forked sidecars, config scripts) and removed what no
entry graph can reach.

- 11 orphan modules nothing imported, plus one test that only covered them
- 159 unused exports/types, with their now-dead helpers, imports and tests

Each candidate was verified against dynamic references before deletion.
42 knip hits were false positives and are kept: shared modules consumed by
the mobile/ workspace, the src/shared/plugins/** public API, vendored
shadcn primitives, and relay wire-protocol constants held for compatibility.

Adds knip.json + `pnpm audit:dead-code` so this stays measurable.

Verified: pnpm typecheck, pnpm lint, and 2081 tests across the 73 affected
test files all pass.

* chore(dead-code): move knip config under config/

Root-level additions are blocked by the root directory guard.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-08-02 00:33:57 -07:00

78 lines
2.4 KiB
TypeScript

import {
addEnvironmentFromPairingCode as addEnvironmentFromPairingCodeInStore,
getEnvironmentStorePath,
listEnvironments,
markEnvironmentUsed as markEnvironmentUsedInStore,
removeEnvironment as removeEnvironmentFromStore,
resolveEnvironment as resolveEnvironmentFromStore,
resolveEnvironmentPairingOffer as resolveEnvironmentPairingOfferFromStore,
RuntimeEnvironmentStoreError,
type RuntimeEnvironmentStoreErrorCode
} from '../../shared/runtime-environment-store'
import type {
KnownRuntimeEnvironment,
PublicKnownRuntimeEnvironment
} from '../../shared/runtime-environments'
import type { PairingOffer } from '../../shared/pairing'
import { RuntimeClientError } from './types'
export type EnvironmentAddResult = {
environment: PublicKnownRuntimeEnvironment
}
export type EnvironmentRemoveResult = {
removed: PublicKnownRuntimeEnvironment
}
export { getEnvironmentStorePath, listEnvironments }
export function addEnvironmentFromPairingCode(
userDataPath: string,
args: { name: string; pairingCode: string; now?: number }
): KnownRuntimeEnvironment {
return translateStoreError(() => addEnvironmentFromPairingCodeInStore(userDataPath, args))
}
export function removeEnvironment(userDataPath: string, selector: string): KnownRuntimeEnvironment {
return translateStoreError(() => removeEnvironmentFromStore(userDataPath, selector))
}
export function resolveEnvironment(
userDataPath: string,
selector: string
): KnownRuntimeEnvironment {
return translateStoreError(() => resolveEnvironmentFromStore(userDataPath, selector))
}
export function resolveEnvironmentPairingOffer(
userDataPath: string,
selector: string
): PairingOffer {
return translateStoreError(() => resolveEnvironmentPairingOfferFromStore(userDataPath, selector))
}
export function markEnvironmentUsed(
userDataPath: string,
selector: string,
args: { runtimeId?: string | null; now?: number } = {}
): void {
translateStoreError(() => markEnvironmentUsedInStore(userDataPath, selector, args))
}
function translateStoreError<TResult>(fn: () => TResult): TResult {
try {
return fn()
} catch (error) {
if (error instanceof RuntimeEnvironmentStoreError) {
throw new RuntimeClientError(toRuntimeClientErrorCode(error.code), error.message)
}
throw error
}
}
function toRuntimeClientErrorCode(
code: RuntimeEnvironmentStoreErrorCode
): 'invalid_argument' | 'runtime_error' {
return code
}