An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): register all emitted response types in the --json envelope union (#4272)
Joey16ddd24f3b1e
diff --git a/.changeset/json-response-union-complete.md b/.changeset/json-response-union-complete.mdnew file mode 100644index 0000000000..67a088ce71--- /dev/null+++ b/.changeset/json-response-union-complete.md@@ -0,0 +1,9 @@+---+'@astryxdesign/cli': patch+---++[fix] Register all emitted response types in the `--json` envelope union++Three response types were defined, exported, and emitted by commands but never added to `CLIAnyResponse` — the union that `jsonOut()` type-checks payloads against: `component.full`, `component.detail.blocks`, and `upgrade.status`. Because their discriminators were missing from the map, `jsonOut('upgrade.status', …)` (and the two component variants) were rejected by the type-checker, and their payload shapes weren't actually being validated. `build.help` had no response type at all. Added a `BuildHelpResponse` type and wired all four into the union so every `--json` envelope the CLI can emit is now type-checked against a declared shape.++@josephfarinadiff --git a/packages/cli/src/types/base.d.ts b/packages/cli/src/types/base.d.tsindex d48c3e912c..799d0c6bfc 100644--- a/packages/cli/src/types/base.d.ts+++ b/packages/cli/src/types/base.d.ts@@ -11,10 +11,12 @@import type {ComponentListResponse,ComponentBriefResponse,+ ComponentFullResponse,ComponentDetailResponse,ComponentDetailPropsResponse,ComponentDetailSourceResponse,ComponentDetailShowcaseResponse,+ ComponentDetailBlocksResponse,} from './component';import type {DiscoverListResponse,@@ -42,8 +44,13 @@ import type {} from './hook';import type {SwizzleListResponse, SwizzleCopyResponse} from './swizzle';import type {ThemeBuildResponse} from './theme';-import type {UpgradeListResponse, UpgradeRunResponse} from './upgrade';+import type {+ UpgradeListResponse,+ UpgradeRunResponse,+ UpgradeStatusResponse,+} from './upgrade';import type {SearchResponse} from './search';+import type {BuildHelpResponse} from './build';import type {ErrorCode} from './error-codes';import type {ManifestResponse} from './manifest';import type {DoctorResponse} from './doctor';@@ -74,10 +81,12 @@ export type CLIResult<T> = T | CLIError | CLIUnsupportedError;export type CLIAnyResponse =| ComponentListResponse| ComponentBriefResponse+ | ComponentFullResponse| ComponentDetailResponse| ComponentDetailPropsResponse| ComponentDetailSourceResponse| ComponentDetailShowcaseResponse+ | ComponentDetailBlocksResponse| DiscoverListResponse| DiscoverDetailResponse| DiscoverDetailDocResponse@@ -99,7 +108,9 @@ export type CLIAnyResponse =| ThemeBuildResponse| UpgradeListResponse| UpgradeRunResponse+ | UpgradeStatusResponse| SearchResponse+ | BuildHelpResponse| ManifestResponse| DoctorResponse| ValidateIntegrationResponse;diff --git a/packages/cli/src/types/build.d.ts b/packages/cli/src/types/build.d.tsnew file mode 100644index 0000000000..47da337679--- /dev/null+++ b/packages/cli/src/types/build.d.ts@@ -0,0 +1,23 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * Build command JSON responses.+ *+ * `astryx build` is the "assemble a page" verb. With no query it emits the+ * workflow playbook; with a query it delegates to the search pipeline and+ * emits a `search` response (see search.d.ts).+ *+ * Invocation -> type discriminator+ * ---------------------------------------------------+ * xds --json build -> build.help+ * xds --json build "<idea>" -> search+ */++/** xds --json build (no query) — the "how to build a page" playbook signal. */+export interface BuildHelpResponse {+ type: 'build.help';+ data: {+ /** Always true; marks this envelope as the playbook rather than a result set. */+ playbook: true;+ };+}diff --git a/packages/cli/src/types/index.d.ts b/packages/cli/src/types/index.d.tsindex ac1ae61472..9fb467f9de 100644--- a/packages/cli/src/types/index.d.ts+++ b/packages/cli/src/types/index.d.ts@@ -10,6 +10,7 @@ export * from './swizzle';export * from './theme';export * from './upgrade';export * from './search';+export * from './build';export * from './error-codes';export * from './manifest';export * from './doctor';