From 343b6ac31bcaefd46927fa8ca8e88e036491117c Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 11 Jan 2026 05:04:36 +0100 Subject: [PATCH] feat: add onboard reset option --- docs/cli/index.md | 1 + src/cli/program.ts | 4 ++++ src/commands/onboard-types.ts | 1 + src/commands/onboard.ts | 13 +++++++++++++ 4 files changed, 19 insertions(+) diff --git a/docs/cli/index.md b/docs/cli/index.md index d424f9d3b..d5926e42a 100644 --- a/docs/cli/index.md +++ b/docs/cli/index.md @@ -194,6 +194,7 @@ Interactive wizard to set up gateway, workspace, and skills. Options: - `--workspace ` +- `--reset` (reset config + credentials + sessions + workspace before wizard) - `--non-interactive` - `--mode ` - `--flow ` diff --git a/src/cli/program.ts b/src/cli/program.ts index 3401e2aa1..e6c0689aa 100644 --- a/src/cli/program.ts +++ b/src/cli/program.ts @@ -244,6 +244,10 @@ export function buildProgram() { "Interactive wizard to set up the gateway, workspace, and skills", ) .option("--workspace ", "Agent workspace directory (default: ~/clawd)") + .option( + "--reset", + "Reset config + credentials + sessions + workspace before running wizard", + ) .option("--non-interactive", "Run without prompts", false) .option("--flow ", "Wizard flow: quickstart|advanced") .option("--mode ", "Wizard mode: local|remote") diff --git a/src/commands/onboard-types.ts b/src/commands/onboard-types.ts index bc5cfeebf..d6afd410f 100644 --- a/src/commands/onboard-types.ts +++ b/src/commands/onboard-types.ts @@ -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; diff --git a/src/commands/onboard.ts b/src/commands/onboard.ts index 2608e80c1..5fd02bbee 100644 --- a/src/commands/onboard.ts +++ b/src/commands/onboard.ts @@ -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( [