Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,594 changes: 1,594 additions & 0 deletions apps/cli/src/commands/system/install-core.ts

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions apps/cli/src/commands/system/install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { confirm, intro, isCancel, log, outro } from "@clack/prompts";
import pc from "picocolors";

import { CLIError } from "@/presentation/errors";
import { renderTitle } from "@/presentation/render-title";

import type { InstallAgentInputId, InstallOnly, InstallReceipt } from "./install-core";

import { runInstall } from "./install-core";

export interface InstallCommandOptions {
only?: InstallOnly;
agent?: InstallAgentInputId[];
dryRun?: boolean;
json?: boolean;
uninstall?: boolean;
yes?: boolean;
}

function statusMark(target: InstallReceipt["targets"][number]) {
if (target.status === "failed") return pc.red("✗");
if (target.status === "unchanged") return pc.dim("-");
if (target.status === "cancelled") return pc.yellow("-");
if (target.status === "planned") return pc.cyan("◇");
return pc.green("✓");
}

function printHumanReceipt(receipt: InstallReceipt) {
renderTitle();
intro(
pc.magenta(
receipt.action === "uninstall" ? "Better Fullstack uninstall" : "Better Fullstack install",
),
);
for (const target of receipt.targets) {
const detail = target.message ? `: ${target.message}` : "";
log.message(`${statusMark(target)} ${target.name}${detail}`);
}
outro(`Try: ${receipt.tryPrompt}`);
}

export async function installCommand(options: InstallCommandOptions): Promise<InstallReceipt> {
const interactive = Boolean(process.stdin.isTTY) && !options.yes && !options.json;
const receipt = await runInstall(
{
only: options.only,
agents: options.agent,
dryRun: options.dryRun,
uninstall: options.uninstall,
},
{
stdinIsTTY: interactive,
confirm: interactive
? async (message) => {
const answer = await confirm({ message, initialValue: true });
return !isCancel(answer) && answer;
}
: undefined,
},
);

if (options.json) process.stdout.write(`${JSON.stringify(receipt, null, 2)}\n`);
else printHumanReceipt(receipt);

if (!receipt.success) {
throw new CLIError("Every requested Better Fullstack install target failed.");
}
return receipt;
}
51 changes: 51 additions & 0 deletions apps/cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import {
getStarterTracksResult,
} from "@/commands/stack/starter-tracks";
import { historyHandler } from "@/commands/system/history";
import {
INSTALL_AGENT_INPUT_IDS,
type InstallReceipt,
} from "@/commands/system/install-core";
import { telemetryHandler } from "@/commands/system/telemetry";
import { BUILDER_URL } from "@/constants";
import { CreateCommandInputSchema, CreateCommandOptionsSchema } from "@/create-command-input";
Expand Down Expand Up @@ -203,6 +207,11 @@ const OPTION_ENTRY_COUNT = Object.values(OPTION_CATEGORY_METADATA).reduce(
0,
);

function statusFromInstallResult(result: InstallReceipt | undefined) {
if (result?.targets.some((target) => target.status === "cancelled")) return "cancelled";
return statusFromCommandResult(result);
}

const AddCommandInputSchema = CreateCommandOptionsSchema.omit({
template: true,
shape: true,
Expand Down Expand Up @@ -355,6 +364,48 @@ export const router = os.router({
{ source: "cli-flags" },
);
}),
install: os
.meta({
description:
"Install or uninstall Better Fullstack MCP and skills for detected coding agents and editors",
})
.input(
z.object({
only: z
.enum(["mcp", "skills"])
.optional()
.describe("Install only the MCP connection or only the skills"),
agent: z
.array(z.enum(INSTALL_AGENT_INPUT_IDS))
.optional()
.default([])
.describe("Restrict installation to an agent; repeat for more than one"),
dryRun: z
.boolean()
.optional()
.default(false)
.describe("Print every planned file and command without changing anything"),
json: z.boolean().optional().default(false).describe("Output a machine-readable receipt"),
uninstall: z
.boolean()
.optional()
.default(false)
.describe("Remove only entries and skill folders created by this command"),
yes: z.boolean().optional().default(false).describe("Skip the confirmation prompt"),
}),
)
.handler(async ({ input }) => {
const { installCommand } = await import("@/commands/system/install.js");
await withCommandTelemetry("install", () => installCommand(input), {
source: "cli-flags",
mode: input.dryRun ? "dry-run" : input.uninstall ? "uninstall" : "install",
resultStatus: statusFromInstallResult,
resultDetails: (result) => ({
capabilityCount: result.summary.requested,
issueCount: result.summary.failed,
}),
});
}),
add: os
.meta({
description:
Expand Down
1 change: 1 addition & 0 deletions apps/cli/test/generation/docs-scaffold-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const NON_SCAFFOLD_COMMANDS = new Set([
"evidence",
"gen",
"history",
"install",
"mcp",
"recommend",
"recovery",
Expand Down
Loading
Loading