style: biome fixes
This commit is contained in:
@@ -478,7 +478,11 @@ export function buildProgram() {
|
|||||||
"config|config+creds+sessions|full (default: interactive prompt)",
|
"config|config+creds+sessions|full (default: interactive prompt)",
|
||||||
)
|
)
|
||||||
.option("--yes", "Skip confirmation prompts", false)
|
.option("--yes", "Skip confirmation prompts", false)
|
||||||
.option("--non-interactive", "Disable prompts (requires --scope + --yes)", false)
|
.option(
|
||||||
|
"--non-interactive",
|
||||||
|
"Disable prompts (requires --scope + --yes)",
|
||||||
|
false,
|
||||||
|
)
|
||||||
.option("--dry-run", "Print actions without removing files", false)
|
.option("--dry-run", "Print actions without removing files", false)
|
||||||
.action(async (opts) => {
|
.action(async (opts) => {
|
||||||
try {
|
try {
|
||||||
@@ -501,11 +505,7 @@ export function buildProgram() {
|
|||||||
.option("--state", "Remove state + config", false)
|
.option("--state", "Remove state + config", false)
|
||||||
.option("--workspace", "Remove workspace dirs", false)
|
.option("--workspace", "Remove workspace dirs", false)
|
||||||
.option("--app", "Remove the macOS app", false)
|
.option("--app", "Remove the macOS app", false)
|
||||||
.option(
|
.option("--all", "Remove service + state + workspace + app", false)
|
||||||
"--all",
|
|
||||||
"Remove service + state + workspace + app",
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
.option("--yes", "Skip confirmation prompts", false)
|
.option("--yes", "Skip confirmation prompts", false)
|
||||||
.option("--non-interactive", "Disable prompts (requires --yes)", false)
|
.option("--non-interactive", "Disable prompts (requires --yes)", false)
|
||||||
.option("--dry-run", "Print actions without removing files", false)
|
.option("--dry-run", "Print actions without removing files", false)
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js";
|
||||||
import type { ClawdbotConfig } from "../config/config.js";
|
import type { ClawdbotConfig } from "../config/config.js";
|
||||||
import type { RuntimeEnv } from "../runtime.js";
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js";
|
|
||||||
import { resolveHomeDir, resolveUserPath } from "../utils.js";
|
import { resolveHomeDir, resolveUserPath } from "../utils.js";
|
||||||
|
|
||||||
export type RemovalResult = {
|
export type RemovalResult = {
|
||||||
@@ -34,7 +33,10 @@ export function collectWorkspaceDirs(
|
|||||||
|
|
||||||
export function isPathWithin(child: string, parent: string): boolean {
|
export function isPathWithin(child: string, parent: string): boolean {
|
||||||
const relative = path.relative(parent, child);
|
const relative = path.relative(parent, child);
|
||||||
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
return (
|
||||||
|
relative === "" ||
|
||||||
|
(!relative.startsWith("..") && !path.isAbsolute(relative))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUnsafeRemovalTarget(target: string): boolean {
|
function isUnsafeRemovalTarget(target: string): boolean {
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
import { cancel, confirm, isCancel, select } from "@clack/prompts";
|
import { cancel, confirm, isCancel, select } from "@clack/prompts";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
isNixMode,
|
||||||
loadConfig,
|
loadConfig,
|
||||||
resolveConfigPath,
|
resolveConfigPath,
|
||||||
resolveOAuthDir,
|
resolveOAuthDir,
|
||||||
resolveStateDir,
|
resolveStateDir,
|
||||||
isNixMode,
|
|
||||||
} from "../config/config.js";
|
} from "../config/config.js";
|
||||||
import { resolveGatewayService } from "../daemon/service.js";
|
import { resolveGatewayService } from "../daemon/service.js";
|
||||||
import type { RuntimeEnv } from "../runtime.js";
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
|
import {
|
||||||
import { collectWorkspaceDirs, isPathWithin, listAgentSessionDirs, removePath } from "./cleanup-utils.js";
|
stylePromptHint,
|
||||||
|
stylePromptMessage,
|
||||||
|
stylePromptTitle,
|
||||||
|
} from "../terminal/prompt-style.js";
|
||||||
|
import {
|
||||||
|
collectWorkspaceDirs,
|
||||||
|
isPathWithin,
|
||||||
|
listAgentSessionDirs,
|
||||||
|
removePath,
|
||||||
|
} from "./cleanup-utils.js";
|
||||||
|
|
||||||
export type ResetScope = "config" | "config+creds+sessions" | "full";
|
export type ResetScope = "config" | "config+creds+sessions" | "full";
|
||||||
|
|
||||||
@@ -26,7 +35,9 @@ const selectStyled = <T>(params: Parameters<typeof select<T>>[0]) =>
|
|||||||
...params,
|
...params,
|
||||||
message: stylePromptMessage(params.message),
|
message: stylePromptMessage(params.message),
|
||||||
options: params.options.map((opt) =>
|
options: params.options.map((opt) =>
|
||||||
opt.hint === undefined ? opt : { ...opt, hint: stylePromptHint(opt.hint) },
|
opt.hint === undefined
|
||||||
|
? opt
|
||||||
|
: { ...opt, hint: stylePromptHint(opt.hint) },
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,26 @@
|
|||||||
import { cancel, confirm, isCancel, multiselect } from "@clack/prompts";
|
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import { cancel, confirm, isCancel, multiselect } from "@clack/prompts";
|
||||||
|
|
||||||
import { loadConfig, resolveConfigPath, resolveOAuthDir, resolveStateDir, isNixMode } from "../config/config.js";
|
import {
|
||||||
|
isNixMode,
|
||||||
|
loadConfig,
|
||||||
|
resolveConfigPath,
|
||||||
|
resolveOAuthDir,
|
||||||
|
resolveStateDir,
|
||||||
|
} from "../config/config.js";
|
||||||
import { resolveGatewayService } from "../daemon/service.js";
|
import { resolveGatewayService } from "../daemon/service.js";
|
||||||
import type { RuntimeEnv } from "../runtime.js";
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
|
import {
|
||||||
|
stylePromptHint,
|
||||||
|
stylePromptMessage,
|
||||||
|
stylePromptTitle,
|
||||||
|
} from "../terminal/prompt-style.js";
|
||||||
import { resolveHomeDir } from "../utils.js";
|
import { resolveHomeDir } from "../utils.js";
|
||||||
import { collectWorkspaceDirs, isPathWithin, removePath } from "./cleanup-utils.js";
|
import {
|
||||||
|
collectWorkspaceDirs,
|
||||||
|
isPathWithin,
|
||||||
|
removePath,
|
||||||
|
} from "./cleanup-utils.js";
|
||||||
|
|
||||||
type UninstallScope = "service" | "state" | "workspace" | "app";
|
type UninstallScope = "service" | "state" | "workspace" | "app";
|
||||||
|
|
||||||
@@ -21,14 +35,14 @@ export type UninstallOptions = {
|
|||||||
dryRun?: boolean;
|
dryRun?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const multiselectStyled = <T>(
|
const multiselectStyled = <T>(params: Parameters<typeof multiselect<T>>[0]) =>
|
||||||
params: Parameters<typeof multiselect<T>>[0],
|
|
||||||
) =>
|
|
||||||
multiselect({
|
multiselect({
|
||||||
...params,
|
...params,
|
||||||
message: stylePromptMessage(params.message),
|
message: stylePromptMessage(params.message),
|
||||||
options: params.options.map((opt) =>
|
options: params.options.map((opt) =>
|
||||||
opt.hint === undefined ? opt : { ...opt, hint: stylePromptHint(opt.hint) },
|
opt.hint === undefined
|
||||||
|
? opt
|
||||||
|
: { ...opt, hint: stylePromptHint(opt.hint) },
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -101,7 +115,9 @@ export async function uninstallCommand(
|
|||||||
|
|
||||||
if (!hadExplicit) {
|
if (!hadExplicit) {
|
||||||
if (!interactive) {
|
if (!interactive) {
|
||||||
runtime.error("Non-interactive mode requires explicit scopes (use --all).");
|
runtime.error(
|
||||||
|
"Non-interactive mode requires explicit scopes (use --all).",
|
||||||
|
);
|
||||||
runtime.exit(1);
|
runtime.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -115,12 +131,18 @@ export async function uninstallCommand(
|
|||||||
},
|
},
|
||||||
{ value: "state", label: "State + config", hint: "~/.clawdbot" },
|
{ value: "state", label: "State + config", hint: "~/.clawdbot" },
|
||||||
{ value: "workspace", label: "Workspace", hint: "agent files" },
|
{ value: "workspace", label: "Workspace", hint: "agent files" },
|
||||||
{ value: "app", label: "macOS app", hint: "/Applications/Clawdbot.app" },
|
{
|
||||||
|
value: "app",
|
||||||
|
label: "macOS app",
|
||||||
|
hint: "/Applications/Clawdbot.app",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
initialValues: ["service", "state", "workspace"],
|
initialValues: ["service", "state", "workspace"],
|
||||||
});
|
});
|
||||||
if (isCancel(selection)) {
|
if (isCancel(selection)) {
|
||||||
cancel(stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.");
|
cancel(
|
||||||
|
stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.",
|
||||||
|
);
|
||||||
runtime.exit(0);
|
runtime.exit(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -137,7 +159,9 @@ export async function uninstallCommand(
|
|||||||
message: stylePromptMessage("Proceed with uninstall?"),
|
message: stylePromptMessage("Proceed with uninstall?"),
|
||||||
});
|
});
|
||||||
if (isCancel(ok) || !ok) {
|
if (isCancel(ok) || !ok) {
|
||||||
cancel(stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.");
|
cancel(
|
||||||
|
stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.",
|
||||||
|
);
|
||||||
runtime.exit(0);
|
runtime.exit(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -184,7 +208,10 @@ export async function uninstallCommand(
|
|||||||
|
|
||||||
if (scopes.has("state") && !scopes.has("workspace")) {
|
if (scopes.has("state") && !scopes.has("workspace")) {
|
||||||
const home = resolveHomeDir();
|
const home = resolveHomeDir();
|
||||||
if (home && workspaceDirs.some((dir) => dir.startsWith(path.resolve(home)))) {
|
if (
|
||||||
|
home &&
|
||||||
|
workspaceDirs.some((dir) => dir.startsWith(path.resolve(home)))
|
||||||
|
) {
|
||||||
runtime.log(
|
runtime.log(
|
||||||
"Tip: workspaces were preserved. Re-run with --workspace to remove them.",
|
"Tip: workspaces were preserved. Re-run with --workspace to remove them.",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user