refactor(commands): centralize shared command formatting helpers

This commit is contained in:
Peter Steinberger
2026-02-22 21:18:10 +00:00
parent 06bdd53658
commit 4bf67ab698
15 changed files with 406 additions and 115 deletions

View File

@@ -6,7 +6,12 @@ import type { RuntimeEnv } from "../runtime.js";
import { selectStyled } from "../terminal/prompt-select-styled.js";
import { stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
import { resolveCleanupPlanFromDisk } from "./cleanup-plan.js";
import { listAgentSessionDirs, removePath } from "./cleanup-utils.js";
import {
listAgentSessionDirs,
removePath,
removeStateAndLinkedPaths,
removeWorkspaceDirs,
} from "./cleanup-utils.js";
export type ResetScope = "config" | "config+creds+sessions" | "full";
@@ -129,16 +134,12 @@ export async function resetCommand(runtime: RuntimeEnv, opts: ResetOptions) {
}
if (scope === "full") {
await removePath(stateDir, runtime, { dryRun, label: stateDir });
if (!configInsideState) {
await removePath(configPath, runtime, { dryRun, label: configPath });
}
if (!oauthInsideState) {
await removePath(oauthDir, runtime, { dryRun, label: oauthDir });
}
for (const workspace of workspaceDirs) {
await removePath(workspace, runtime, { dryRun, label: workspace });
}
await removeStateAndLinkedPaths(
{ stateDir, configPath, oauthDir, configInsideState, oauthInsideState },
runtime,
{ dryRun },
);
await removeWorkspaceDirs(workspaceDirs, runtime, { dryRun });
runtime.log(`Next: ${formatCliCommand("openclaw onboard --install-daemon")}`);
return;
}