Skip to content
Draft
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
11 changes: 11 additions & 0 deletions .changeset/design-system-index-endpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@agent-native/core": patch
---

Update Builder design-system indexing to call the current `/design-systems/v1/index`
endpoint with a structured `sources` array (uploaded files, public repos, connected
projects) instead of the retired `generate` endpoint and its flat `uploads` payload.
File selections are now attached per source, and the incomplete-response guard only
requires a `designSystemId`. "Open in Builder" now links into the actual
project/branch (`branchUrl`) when the service returns one, falling back to the
design-system-intelligence docs URL.
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
"@assistant-ui/react-markdown": "^0.12.6",
"@assistant-ui/store": ">=0.2.9 <0.2.14",
"@assistant-ui/tap": "^0.5.14",
"@builder.io/ai-utils": "^0.84.0",
"@clack/prompts": "^1.4.0",
"@codemirror/lang-sql": "^6.10.0",
"@codemirror/theme-one-dark": "^6.1.3",
Expand Down
68 changes: 45 additions & 23 deletions packages/core/src/server/builder-design-systems.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { DesignSystemSourceInput } from "@builder.io/ai-utils";

import { withBuilderUtmTrackingParams } from "../shared/builder-link-tracking.js";
import { FeatureNotConfiguredError } from "./credential-provider.js";
import {
Expand Down Expand Up @@ -123,10 +125,12 @@ interface UploadStartResponse {
uploads?: Array<{ idx: number; uploadUrl: string; uploadToken: string }>;
}

interface GenerateResponse {
projectId?: string;
jobId?: string;
interface IndexResponse {
designSystemId?: string;
jobId?: string;
projectId?: string;
branchUrl?: string;
branchName?: string;
}

const DEFAULT_MAX_CODE_FILES = 50;
Expand Down Expand Up @@ -592,7 +596,7 @@ export async function startBuilderDesignSystemIndex(
}

const credentials = await resolveBuilderDesignSystemCredentials();
let uploadTokens: string[] = [];
const sources: DesignSystemSourceInput[] = [];
if (files.length > 0) {
const uploadStart = await fetchWithTimeout(
makeBuilderDesignSystemUrl("upload/start", credentials),
Expand Down Expand Up @@ -623,38 +627,54 @@ export async function startBuilderDesignSystemIndex(
}
await uploadToResumableUrl(slots[i], files[i]);
}
uploadTokens = slots.map((slot) => slot.uploadToken);
for (let i = 0; i < slots.length; i++) {
const name = files[i].name;
const fileSelection = options.selection?.[name];
sources.push({
kind: "file",
uploadToken: slots[i].uploadToken,
...(fileSelection && fileSelection.length > 0
? { selection: { [name]: fileSelection } }
: {}),
});
}
}

const generate = await fetchWithTimeout(
makeBuilderDesignSystemUrl("generate", credentials),
if (options.githubRepoUrl?.trim()) {
sources.push({
kind: "public-repo",
repoUrl: options.githubRepoUrl.trim(),
});
}
if (options.connectedProjectId?.trim()) {
sources.push({
kind: "connected-repo",
fusionProjectId: options.connectedProjectId.trim(),
});
}

const index = await fetchWithTimeout(
makeBuilderDesignSystemUrl("index", credentials),
{
method: "POST",
headers: {
...makeBuilderHeaders(credentials),
"Content-Type": "application/json",
},
body: JSON.stringify({
uploads: uploadTokens,
sources,
...(options.projectName?.trim()
? { projectName: options.projectName.trim() }
: {}),
...(options.githubRepoUrl?.trim()
? { githubRepoUrl: options.githubRepoUrl.trim() }
: {}),
...(options.connectedProjectId?.trim()
? { connectedProjectId: options.connectedProjectId.trim() }
? { designSystemName: options.projectName.trim() }
: {}),
...(options.selection ? { selection: options.selection } : {}),
...(options.devToolsVersion?.trim()
? { devToolsVersion: options.devToolsVersion.trim() }
: {}),
}),
},
);
await assertOk(generate, "Builder design-system indexing failed");
const generated = (await generate.json()) as GenerateResponse;
if (!generated.projectId || !generated.jobId || !generated.designSystemId) {
await assertOk(index, "Builder design-system indexing failed");
const indexed = (await index.json()) as IndexResponse;
if (!indexed.designSystemId) {
throw new Error(
"Builder design-system indexing returned an incomplete response.",
);
Expand All @@ -663,11 +683,13 @@ export async function startBuilderDesignSystemIndex(
return {
ok: true,
source: "builder",
projectId: generated.projectId,
jobId: generated.jobId,
designSystemId: generated.designSystemId,
projectId: indexed.projectId ?? "",
jobId: indexed.jobId ?? "",
designSystemId: indexed.designSystemId,
suggestedTitle: options.projectName?.trim() || null,
builderUrl: builderDesignSystemUrl(generated.designSystemId),
builderUrl: indexed.branchUrl?.trim()
? indexed.branchUrl.trim()
: builderDesignSystemUrl(indexed.designSystemId),
status: "in-progress",
};
}
78 changes: 31 additions & 47 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions templates/design/app/pages/DesignSystemSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1112,18 +1112,6 @@ function BuilderIndexPreview({
<dd className="truncate font-mono !text-[11px] text-foreground/80">
{result.projectId}
</dd>
<dt className="text-muted-foreground">
{"Job" /* i18n-ignore Builder indexing field */}
</dt>
<dd className="truncate font-mono !text-[11px] text-foreground/80">
{result.jobId}
</dd>
<dt className="text-muted-foreground">
{"Design system" /* i18n-ignore Builder indexing field */}
</dt>
<dd className="truncate font-mono !text-[11px] text-foreground/80">
{result.designSystemId}
</dd>
</dl>

<div className="flex items-center gap-2 border-t border-border pt-4">
Expand Down
Loading
Loading