Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/fifty-lobsters-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@proofkit/cli": patch
---

Fix FileMaker webviewer init flow to install local addon files before prompting that no FileMaker file is open in the local MCP server.
1 change: 1 addition & 0 deletions packages/cli/src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export interface FileMakerBootstrapArtifacts {

export interface FileMakerService {
readonly detectLocalFmMcp: (baseUrl?: string) => Eff<FmMcpStatus, CliError>;
readonly installLocalWebViewerAddon: () => Eff<void, CliError>;
readonly validateHostedServerUrl: (
serverUrl: string,
ottoPort?: number | null,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/core/resolveInitRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ function resolveFileMakerInputs({

while (true) {
const localFmMcp = yield* fileMakerService.detectLocalFmMcp();
yield* fileMakerService.installLocalWebViewerAddon();
const selectedFile = localFmMcp.healthy ? yield* resolveLocalFmMcpFile(localFmMcp.connectedFiles) : undefined;
if (localFmMcp.healthy && selectedFile) {
console.info(`Using local ProofKit MCP file: ${selectedFile}`);
Expand Down
12 changes: 12 additions & 0 deletions packages/cli/src/services/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from "~/core/context.js";
import { ExternalCommandError, FileMakerSetupError, FileSystemError, UserCancelledError } from "~/core/errors.js";
import type { AppType, FileMakerInputs, ProofKitSettings, UIType } from "~/core/types.js";
import { installFmAddonExplicitly } from "~/installers/install-fm-addon.js";
import { openBrowser } from "~/utils/browserOpen.js";
import { deleteJson, getJson, postJson } from "~/utils/http.js";
import { detectUserPackageManager } from "~/utils/packageManager.js";
Expand Down Expand Up @@ -357,6 +358,17 @@ const fileMakerService = {
cause,
}),
}),
installLocalWebViewerAddon: () =>
Effect.tryPromise({
try: async () => {
await installFmAddonExplicitly({ addonName: "wv" });
},
catch: (cause) =>
new FileMakerSetupError({
message: "Unable to install local ProofKit WebViewer add-on files.",
cause,
}),
}).pipe(Effect.asVoid),
validateHostedServerUrl: (serverUrl: string, ottoPort?: number | null) =>
Effect.gen(function* () {
const normalizedUrl = normalizeUrl(serverUrl);
Expand Down
18 changes: 18 additions & 0 deletions packages/cli/tests/resolve-init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ describe("resolveInitRequest", () => {
multiSearchSelect: [],
confirm: [],
};
const tracker = {
commands: [],
gitInits: 0,
codegens: 0,
filemakerBootstraps: 0,
addonInstalls: 0,
};

const request = await Effect.runPromise(
resolveInitRequest("demo", {
Expand All @@ -408,6 +415,7 @@ describe("resolveInitRequest", () => {
cwd: "/tmp",
packageManager: "pnpm",
nonInteractive: false,
tracker,
prompts: {
select: ["skip"],
},
Expand All @@ -424,6 +432,7 @@ describe("resolveInitRequest", () => {

expect(request.fileMaker).toBeUndefined();
expect(request.skipFileMakerSetup).toBe(true);
expect(tracker.addonInstalls).toBe(1);
expect(promptTranscript.select).toContainEqual({
message:
"ProofKit MCP Server is running, but no FileMaker file is open yet. Open one, then choose how to continue.",
Expand All @@ -439,6 +448,13 @@ describe("resolveInitRequest", () => {
success: [],
note: [],
};
const tracker = {
commands: [],
gitInits: 0,
codegens: 0,
filemakerBootstraps: 0,
addonInstalls: 0,
};

const request = await Effect.runPromise(
resolveInitRequest("demo", {
Expand All @@ -455,6 +471,7 @@ describe("resolveInitRequest", () => {
cwd: "/tmp",
packageManager: "pnpm",
nonInteractive: false,
tracker,
prompts: {
select: ["retry"],
},
Expand All @@ -479,6 +496,7 @@ describe("resolveInitRequest", () => {
mode: "local-fm-mcp",
fileName: "RetryConnected.fmp12",
});
expect(tracker.addonInstalls).toBe(2);
expect(consoleTranscript.info).toContain("Using local ProofKit MCP file: RetryConnected.fmp12");
});

Expand Down
7 changes: 7 additions & 0 deletions packages/cli/tests/test-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function makeTestLayer(options: {
gitInits: number;
codegens: number;
filemakerBootstraps: number;
addonInstalls?: number;
};
fileMaker?: {
localFmMcp?:
Expand Down Expand Up @@ -400,6 +401,12 @@ export function makeTestLayer(options: {
connectedFiles: next?.connectedFiles ?? [],
});
},
installLocalWebViewerAddon: () => {
if (tracker) {
tracker.addonInstalls = (tracker.addonInstalls ?? 0) + 1;
}
return Effect.void;
},
validateHostedServerUrl: (serverUrl: string) => {
if (options.failures?.validateHostedServerUrl) {
return Effect.fail(options.failures.validateHostedServerUrl as FileMakerSetupError);
Expand Down
Loading