chore(design): emit SERVE_STARTED back-compat alias; drop dead import

design/src/cli.ts publishToDaemon now emits `SERVE_STARTED: port=N html=<path>`
as a third stderr line alongside DAEMON_STARTED/DAEMON_ATTACHED + BOARD_URL.
Any out-of-tree script that grepped the legacy line still gets the port —
they'd still fail at the reload step (the endpoint moved to /boards/<id>/
api/reload) but they no longer fail at the port-detection step. Combined with
the resolver updates one commit back, this is belt-and-suspenders compat.

Fixed the stale docstring at cli.ts:316 that claimed back-compat without
actually emitting the alias. The maintainability specialist flagged it.

Dropped a dead `DaemonState` import from daemon-client.ts. Same review pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-05-25 19:43:47 -07:00
parent 8d534cd95c
commit 280eade6ea
2 changed files with 14 additions and 5 deletions
+14 -4
View File
@@ -323,11 +323,17 @@ async function main(): Promise<void> {
* publish the board, open the browser to its URL, then exit. The daemon * publish the board, open the browser to its URL, then exit. The daemon
* survives. * survives.
* *
* Backward-compatible stderr lines for any external script that scraped the * Stderr lines (in order):
* old `SERVE_STARTED` output: * - "DAEMON_STARTED port=N version=V" (or "DAEMON_ATTACHED port=N ..."
* - "DAEMON_ATTACHED port=N" or "DAEMON_STARTED port=N" (one or the other) * if a daemon was already running)
* - "BOARD_PUBLISHED: http://127.0.0.1:N/boards/<id>/" * - "BOARD_PUBLISHED: http://127.0.0.1:N/boards/<id>/"
* - "BOARD_URL: <same url>" (alias for grep-friendliness) * - "BOARD_URL: <same url>" (alias for grep-friendliness)
* - "SERVE_STARTED: port=N html=<path>" (legacy back-compat alias for
* any external script that scraped the pre-daemon output — note the
* daemon hosts boards under /boards/<id>/, not /, so scripts that
* ALSO POSTed /api/reload at the parsed port need to switch to
* BOARD_URL + ./api/reload to work end-to-end. Emitting the legacy
* line keeps port-only consumers from breaking outright.)
*/ */
async function publishToDaemon(opts: { html: string; title?: string }): Promise<void> { async function publishToDaemon(opts: { html: string; title?: string }): Promise<void> {
if (!opts.html) { if (!opts.html) {
@@ -345,6 +351,10 @@ async function publishToDaemon(opts: { html: string; title?: string }): Promise<
}); });
console.error(`BOARD_PUBLISHED: ${result.url}`); console.error(`BOARD_PUBLISHED: ${result.url}`);
console.error(`BOARD_URL: ${result.url}`); console.error(`BOARD_URL: ${result.url}`);
// Legacy alias so anything still grepping `SERVE_STARTED: port=` gets the
// port. The full back-compat story requires the caller to ALSO learn the
// per-board path; see publishToDaemon docstring above.
console.error(`SERVE_STARTED: port=${ensured.port} html=${opts.html}`);
console.log(JSON.stringify({ id: result.id, url: result.url, sourceDir: result.sourceDir }, null, 2)); console.log(JSON.stringify({ id: result.id, url: result.url, sourceDir: result.sourceDir }, null, 2));
openBrowser(result.url); openBrowser(result.url);
// Short-lived publisher process exits; daemon keeps serving. // Short-lived publisher process exits; daemon keeps serving.
-1
View File
@@ -33,7 +33,6 @@ import { setTimeout as delay } from "timers/promises";
import { import {
acquireLock, acquireLock,
CMDLINE_MARKER, CMDLINE_MARKER,
DaemonState,
healthCheck, healthCheck,
isProcessAlive, isProcessAlive,
readStateFile, readStateFile,