Spaces:
Configuration error
Configuration error
File size: 4,725 Bytes
3a65265 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
import type { Command } from "commander";
import { dashboardCommand } from "../../commands/dashboard.js";
import { doctorCommand } from "../../commands/doctor.js";
import { resetCommand } from "../../commands/reset.js";
import { uninstallCommand } from "../../commands/uninstall.js";
import { defaultRuntime } from "../../runtime.js";
import { formatDocsLink } from "../../terminal/links.js";
import { theme } from "../../terminal/theme.js";
import { runCommandWithRuntime } from "../cli-utils.js";
export function registerMaintenanceCommands(program: Command) {
program
.command("doctor")
.description("Health checks + quick fixes for the gateway and channels")
.addHelpText(
"after",
() =>
`\n${theme.muted("Docs:")} ${formatDocsLink("/cli/doctor", "docs.molt.bot/cli/doctor")}\n`,
)
.option("--no-workspace-suggestions", "Disable workspace memory system suggestions", false)
.option("--yes", "Accept defaults without prompting", false)
.option("--repair", "Apply recommended repairs without prompting", false)
.option("--fix", "Apply recommended repairs (alias for --repair)", false)
.option("--force", "Apply aggressive repairs (overwrites custom service config)", false)
.option("--non-interactive", "Run without prompts (safe migrations only)", false)
.option("--generate-gateway-token", "Generate and configure a gateway token", false)
.option("--deep", "Scan system services for extra gateway installs", false)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
await doctorCommand(defaultRuntime, {
workspaceSuggestions: opts.workspaceSuggestions,
yes: Boolean(opts.yes),
repair: Boolean(opts.repair) || Boolean(opts.fix),
force: Boolean(opts.force),
nonInteractive: Boolean(opts.nonInteractive),
generateGatewayToken: Boolean(opts.generateGatewayToken),
deep: Boolean(opts.deep),
});
});
});
program
.command("dashboard")
.description("Open the Control UI with your current token")
.addHelpText(
"after",
() =>
`\n${theme.muted("Docs:")} ${formatDocsLink("/cli/dashboard", "docs.molt.bot/cli/dashboard")}\n`,
)
.option("--no-open", "Print URL but do not launch a browser", false)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
await dashboardCommand(defaultRuntime, {
noOpen: Boolean(opts.noOpen),
});
});
});
program
.command("reset")
.description("Reset local config/state (keeps the CLI installed)")
.addHelpText(
"after",
() =>
`\n${theme.muted("Docs:")} ${formatDocsLink("/cli/reset", "docs.molt.bot/cli/reset")}\n`,
)
.option("--scope <scope>", "config|config+creds+sessions|full (default: interactive prompt)")
.option("--yes", "Skip confirmation prompts", false)
.option("--non-interactive", "Disable prompts (requires --scope + --yes)", false)
.option("--dry-run", "Print actions without removing files", false)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
await resetCommand(defaultRuntime, {
scope: opts.scope,
yes: Boolean(opts.yes),
nonInteractive: Boolean(opts.nonInteractive),
dryRun: Boolean(opts.dryRun),
});
});
});
program
.command("uninstall")
.description("Uninstall the gateway service + local data (CLI remains)")
.addHelpText(
"after",
() =>
`\n${theme.muted("Docs:")} ${formatDocsLink("/cli/uninstall", "docs.molt.bot/cli/uninstall")}\n`,
)
.option("--service", "Remove the gateway service", false)
.option("--state", "Remove state + config", false)
.option("--workspace", "Remove workspace dirs", false)
.option("--app", "Remove the macOS app", false)
.option("--all", "Remove service + state + workspace + app", false)
.option("--yes", "Skip confirmation prompts", false)
.option("--non-interactive", "Disable prompts (requires --yes)", false)
.option("--dry-run", "Print actions without removing files", false)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
await uninstallCommand(defaultRuntime, {
service: Boolean(opts.service),
state: Boolean(opts.state),
workspace: Boolean(opts.workspace),
app: Boolean(opts.app),
all: Boolean(opts.all),
yes: Boolean(opts.yes),
nonInteractive: Boolean(opts.nonInteractive),
dryRun: Boolean(opts.dryRun),
});
});
});
}
|