feat: add onboard reset option

This commit is contained in:
Peter Steinberger
2026-01-11 05:04:36 +01:00
parent 9046296ed3
commit 343b6ac31b
4 changed files with 19 additions and 0 deletions

View File

@@ -244,6 +244,10 @@ export function buildProgram() {
"Interactive wizard to set up the gateway, workspace, and skills",
)
.option("--workspace <dir>", "Agent workspace directory (default: ~/clawd)")
.option(
"--reset",
"Reset config + credentials + sessions + workspace before running wizard",
)
.option("--non-interactive", "Run without prompts", false)
.option("--flow <flow>", "Wizard flow: quickstart|advanced")
.option("--mode <mode>", "Wizard mode: local|remote")

View File

@@ -33,6 +33,7 @@ export type OnboardOptions = {
flow?: "quickstart" | "advanced";
workspace?: string;
nonInteractive?: boolean;
reset?: boolean;
authChoice?: AuthChoice;
/** Used when `authChoice=token` in non-interactive mode. */
tokenProvider?: string;

View File

@@ -1,6 +1,9 @@
import { readConfigFileSnapshot } from "../config/config.js";
import { assertSupportedRuntime } from "../infra/runtime-guard.js";
import type { RuntimeEnv } from "../runtime.js";
import { defaultRuntime } from "../runtime.js";
import { resolveUserPath } from "../utils.js";
import { DEFAULT_WORKSPACE, handleReset } from "./onboard-helpers.js";
import { runInteractiveOnboarding } from "./onboard-interactive.js";
import { runNonInteractiveOnboarding } from "./onboard-non-interactive.js";
import type { OnboardOptions } from "./onboard-types.js";
@@ -15,6 +18,16 @@ export async function onboardCommand(
const normalizedOpts =
authChoice === opts.authChoice ? opts : { ...opts, authChoice };
if (normalizedOpts.reset) {
const snapshot = await readConfigFileSnapshot();
const baseConfig = snapshot.valid ? snapshot.config : {};
const workspaceDefault =
normalizedOpts.workspace ??
baseConfig.agents?.defaults?.workspace ??
DEFAULT_WORKSPACE;
await handleReset("full", resolveUserPath(workspaceDefault), runtime);
}
if (process.platform === "win32") {
runtime.log(
[