refactor(commands): share cleanup plan resolver

This commit is contained in:
Peter Steinberger
2026-02-15 17:49:30 +00:00
parent 1f1e97674f
commit 813b96a804
3 changed files with 35 additions and 36 deletions

View File

@@ -0,0 +1,25 @@
import type { OpenClawConfig } from "../config/config.js";
import {
loadConfig,
resolveConfigPath,
resolveOAuthDir,
resolveStateDir,
} from "../config/config.js";
import { buildCleanupPlan } from "./cleanup-utils.js";
export function resolveCleanupPlanFromDisk(): {
cfg: OpenClawConfig;
stateDir: string;
configPath: string;
oauthDir: string;
configInsideState: boolean;
oauthInsideState: boolean;
workspaceDirs: string[];
} {
const cfg = loadConfig();
const stateDir = resolveStateDir();
const configPath = resolveConfigPath();
const oauthDir = resolveOAuthDir();
const plan = buildCleanupPlan({ cfg, stateDir, configPath, oauthDir });
return { cfg, stateDir, configPath, oauthDir, ...plan };
}