History

Improve executor up output

Rhys Sullivan committed 7 months ago

Commit fb045991 parent 4d51a6c2 files · +38 −4Browse files

Unified · Split

2 files
  1. .changeset/tidy-pandas-fix.md +5 −0
  2. apps/executor/src/cli/main.ts +33 −4
.changeset/tidy-pandas-fix.md+5−0
@@ -0,0 +1,5 @@
1+---
2+"executor": patch
3+---
4+
5+Make `executor up` output more helpful and less debug-oriented.
apps/executor/src/cli/main.ts+33−4
@@ -606,6 +606,26 @@ const renderStatus = (status: LocalServerStatus): string => · 605 unmodified lines
606606 `workspaceId: ${status.installation?.workspaceId ?? "unavailable"}`,
607607 ].join("\n");
608608
609+const appendUrlPath = (baseUrl: string, pathname: string): string =>
610+ new URL(pathname, baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`).toString();
611+
612+const renderUpSummary = (input: {
613+ started: boolean;
614+ status: LocalServerStatus;
615+}): string =>
616+ [
617+ input.started ? "Executor is ready." : "Executor is already running.",
618+ `API: ${input.status.baseUrl}`,
619+ `MCP: ${appendUrlPath(input.status.baseUrl, "mcp")}`,
620+ `OpenAPI: ${appendUrlPath(input.status.baseUrl, "v1/openapi.json")}`,
621+ `Workspace: ${input.status.installation?.workspaceId ?? "unavailable"}`,
622+ "",
623+ "Try next:",
624+ ` ${CLI_NAME} call 'return 1 + 1'`,
625+ ` ${CLI_NAME} status`,
626+ ` ${CLI_NAME} down`,
627+ ].join("\n");
628+
609629 const getDoctorReport = (baseUrl: string) =>
610630 getServerStatus(baseUrl).pipe(
611631 Effect.map((status) => {
@@ -696,7 +716,9 @@ const ensureServer = (baseUrl: string = DEFAULT_SERVER_BASE_URL) => · 84 unmodified lines
696716 Effect.gen(function* () {
697717 const reachable = yield* isServerReachable(baseUrl);
698718 if (reachable) {
699− return;
719+ return {
720+ started: false,
721+ } as const;
700722 }
701723
702724 const url = new URL(baseUrl);
@@ -704,6 +726,10 @@ const ensureServer = (baseUrl: string = DEFAULT_SERVER_BASE_URL) => · 1 unmodified line
704726 yield* startServerInBackground(port);
705727
706728 yield* waitForReachability(baseUrl, true);
729+
730+ return {
731+ started: true,
732+ } as const;
707733 });
708734
709735
@@ -1142,10 +1168,13 @@ const upCommand = Command.make( · 432 unmodified lines
11421168 },
11431169 ({ baseUrl }) =>
11441170 ensureServer(baseUrl).pipe(
1145− Effect.zipRight(getServerStatus(baseUrl)),
1146− Effect.flatMap((status) => printText(renderStatus(status))),
1171+ Effect.flatMap(({ started }) =>
1172+ getServerStatus(baseUrl).pipe(
1173+ Effect.flatMap((status) => printText(renderUpSummary({ started, status }))),
1174+ )
1175+ ),
11471176 ),
1148−).pipe(Command.withDescription("Ensure the local executor server is running"));
1177+).pipe(Command.withDescription("Start the local executor server if needed and show how to use it"));
11491178
11501179 const downCommand = Command.make(
11511180 "down",