refactor(commands): dedupe session target resolution and fs tool test setup

This commit is contained in:
Peter Steinberger
2026-03-02 14:35:26 +00:00
parent b85facfb5d
commit 3efd224ec6
5 changed files with 137 additions and 169 deletions

View File

@@ -7,7 +7,7 @@ import { info } from "../globals.js";
import { parseAgentSessionKey } from "../routing/session-key.js";
import type { RuntimeEnv } from "../runtime.js";
import { isRich, theme } from "../terminal/theme.js";
import { resolveSessionStoreTargets } from "./session-store-targets.js";
import { resolveSessionStoreTargetsOrExit } from "./session-store-targets.js";
import {
formatSessionAgeCell,
formatSessionFlagsCell,
@@ -95,16 +95,16 @@ export async function sessionsCommand(
cfg.agents?.defaults?.contextTokens ??
lookupContextTokens(displayDefaults.model) ??
DEFAULT_CONTEXT_TOKENS;
let targets: ReturnType<typeof resolveSessionStoreTargets>;
try {
targets = resolveSessionStoreTargets(cfg, {
const targets = resolveSessionStoreTargetsOrExit({
cfg,
opts: {
store: opts.store,
agent: opts.agent,
allAgents: opts.allAgents,
});
} catch (error) {
runtime.error(error instanceof Error ? error.message : String(error));
runtime.exit(1);
},
runtime,
});
if (!targets) {
return;
}