Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(vibe-tests): per-agent isolated project environments (#1590)

Cindy Zhangf7931705c64a
diff --git a/internal/vibe-tests/environments/project-baseline/package.json b/internal/vibe-tests/environments/project-baseline/package.json
new file mode 100644
index 0000000000..91c313e198
--- /dev/null
+++ b/internal/vibe-tests/environments/project-baseline/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "my-app",
+ "private": true,
+ "dependencies": {
+ "react": "^19",
+ "react-dom": "^19",
+ "tailwindcss": "^4",
+ "class-variance-authority": "^0.7",
+ "clsx": "^2",
+ "tailwind-merge": "^2",
+ "lucide-react": "^0.400",
+ "@radix-ui/react-slot": "^1.1"
+ }
+}
diff --git a/internal/vibe-tests/environments/project-html/package.json b/internal/vibe-tests/environments/project-html/package.json
new file mode 100644
index 0000000000..05c9a8bfa8
--- /dev/null
+++ b/internal/vibe-tests/environments/project-html/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "my-app",
+ "private": true,
+ "dependencies": {
+ "react": "^19",
+ "react-dom": "^19"
+ }
+}
diff --git a/internal/vibe-tests/environments/project-xds/package.json b/internal/vibe-tests/environments/project-xds/package.json
new file mode 100644
index 0000000000..968a6e9fea
--- /dev/null
+++ b/internal/vibe-tests/environments/project-xds/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "my-app",
+ "private": true,
+ "dependencies": {
+ "@xds/core": "*",
+ "@xds/theme-default": "*",
+ "@stylexjs/stylex": "^0.10",
+ "react": "^19",
+ "react-dom": "^19"
+ },
+ "devDependencies": {
+ "@xds/cli": "*"
+ }
+}
diff --git a/internal/vibe-tests/src/collect-results.mjs b/internal/vibe-tests/src/collect-results.mjs
new file mode 100644
index 0000000000..9802a5bab9
--- /dev/null
+++ b/internal/vibe-tests/src/collect-results.mjs
@@ -0,0 +1,59 @@
+#!/usr/bin/env node
+/**
+ * @file collect-results.mjs
+ *
+ * Copies agent output from per-agent project directories into the
+ * standard results/ path that the evaluation pipeline expects.
+ *
+ * Usage:
+ * node internal/vibe-tests/src/collect-results.mjs <iteration-id>
+ *
+ * Copies: results/<id>/projects/<pid>/<pid>.tsx → results/<id>/results/<pid>.tsx
+ * results/<id>/projects/<pid>/<pid>.json → results/<id>/results/<pid>.json
+ */
+
+import * as fs from 'node:fs';
+import * as path from 'node:path';
+import {fileURLToPath} from 'node:url';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const RESULTS_DIR = path.resolve(__dirname, '..', 'results');
+
+const iterationId = process.argv[2];
+if (!iterationId) {
+ console.error('Usage: node collect-results.mjs <iteration-id>');
+ process.exit(1);
+}
+
+const iterDir = path.join(RESULTS_DIR, iterationId);
+const projectsDir = path.join(iterDir, 'projects');
+const resultsDir = path.join(iterDir, 'results');
+
+if (!fs.existsSync(projectsDir)) {
+ console.error(`No projects/ directory found at ${projectsDir}`);
+ process.exit(1);
+}
+
+fs.mkdirSync(resultsDir, {recursive: true});
+
+let copied = 0;
+let missing = 0;
+
+for (const pid of fs.readdirSync(projectsDir)) {
+ const projectDir = path.join(projectsDir, pid);
+ if (!fs.statSync(projectDir).isDirectory()) continue;
+
+ for (const ext of ['.tsx', '.json']) {
+ const src = path.join(projectDir, `${pid}${ext}`);
+ const dest = path.join(resultsDir, `${pid}${ext}`);
+ if (fs.existsSync(src)) {
+ fs.copyFileSync(src, dest);
+ copied++;
+ } else {
+ missing++;
+ console.warn(` ⚠ Missing: ${pid}${ext}`);
+ }
+ }
+}
+
+console.log(`✓ Collected ${copied} files from ${fs.readdirSync(projectsDir).length} projects${missing ? ` (${missing} missing)` : ''}`);
diff --git a/internal/vibe-tests/src/setup-environment.mjs b/internal/vibe-tests/src/setup-environment.mjs
new file mode 100644
index 0000000000..bbb3e80421
--- /dev/null
+++ b/internal/vibe-tests/src/setup-environment.mjs
@@ -0,0 +1,93 @@
+#!/usr/bin/env node
+/**
+ * @file setup-environment.mjs
+ *
+ * Creates isolated project directories for vibe test agents.
+ * Each agent gets its own clone of the project template with
+ * real package contents symlinked in.
+ *
+ * Templates live in environments/ — named generically so agent
+ * prompts don't leak what system is being tested.
+ *
+ * Usage (from setup-nightly.mjs):
+ * import {createAgentProject} from './setup-environment.mjs';
+ * const projectDir = createAgentProject('xds', iterDir, 'fwc-1');
+ */
+
+import * as fs from 'node:fs';
+import * as path from 'node:path';
+import {fileURLToPath} from 'node:url';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const VIBE_DIR = path.resolve(__dirname, '..');
+const REPO_ROOT = path.resolve(VIBE_DIR, '../..');
+const ENV_TEMPLATES = path.join(VIBE_DIR, 'environments');
+
+function ensureDir(dir) {
+ fs.mkdirSync(dir, {recursive: true});
+}
+
+function copyFile(src, dest) {
+ ensureDir(path.dirname(dest));
+ fs.copyFileSync(src, dest);
+}
+
+/**
+ * Create an isolated project directory for a single agent.
+ * Returns the absolute path to the project directory.
+ *
+ * @param {'xds' | 'baseline' | 'html'} target
+ * @param {string} iterDir - The iteration results directory
+ * @param {string} promptId - The prompt ID (used to name the clone)
+ */
+export function createAgentProject(target, iterDir, promptId) {
+ const projectDir = path.join(iterDir, 'projects', promptId);
+ ensureDir(projectDir);
+
+ const templateMap = {xds: 'project-xds', baseline: 'project-baseline', html: 'project-html'};
+ const template = templateMap[target];
+ if (!template) throw new Error(`Unknown target: ${target}`);
+
+ // Copy package.json from template
+ copyFile(
+ path.join(ENV_TEMPLATES, template, 'package.json'),
+ path.join(projectDir, 'package.json'),
+ );
+
+ if (target === 'xds') {
+ // Symlink node_modules/@xds/core → packages/core
+ const coreLink = path.join(projectDir, 'node_modules', '@xds', 'core');
+ ensureDir(path.dirname(coreLink));
+ fs.symlinkSync(path.join(REPO_ROOT, 'packages', 'core'), coreLink, 'dir');
+
+ // Symlink node_modules/@xds/cli → packages/cli
+ const cliLink = path.join(projectDir, 'node_modules', '@xds', 'cli');
+ fs.symlinkSync(path.join(REPO_ROOT, 'packages', 'cli'), cliLink, 'dir');
+
+ // Symlink node_modules/.bin/xds → cli bin so npx xds works
+ const binDir = path.join(projectDir, 'node_modules', '.bin');
+ ensureDir(binDir);
+ fs.symlinkSync(path.join(REPO_ROOT, 'packages', 'cli', 'bin', 'xds.mjs'), path.join(binDir, 'xds'), 'file');
+ }
+
+ if (target === 'baseline') {
+ // Symlink components/ui/ → .baseline/components/ui
+ const uiLink = path.join(projectDir, 'components', 'ui');
+ ensureDir(path.dirname(uiLink));
+ fs.symlinkSync(path.join(VIBE_DIR, '.baseline', 'components', 'ui'), uiLink, 'dir');
+
+ // Symlink lib/ → .baseline/lib
+ const libLink = path.join(projectDir, 'lib');
+ fs.symlinkSync(path.join(VIBE_DIR, '.baseline', 'lib'), libLink, 'dir');
+
+ // Copy baseline README
+ const readme = path.join(VIBE_DIR, '.baseline', 'README.md');
+ if (fs.existsSync(readme)) {
+ copyFile(readme, path.join(projectDir, 'README.md'));
+ }
+ }
+
+ // HTML gets just package.json — no libraries, no docs
+
+ return projectDir;
+}
diff --git a/internal/vibe-tests/src/setup-nightly.mjs b/internal/vibe-tests/src/setup-nightly.mjs
index 1ddb1e0bca..65f8582232 100644
--- a/internal/vibe-tests/src/setup-nightly.mjs
+++ b/internal/vibe-tests/src/setup-nightly.mjs
@@ -22,6 +22,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
const VIBE_DIR = path.resolve(__dirname, '..');
const RESULTS_DIR = path.join(VIBE_DIR, 'results');
+import {createAgentProject} from './setup-environment.mjs';
+
// ── Helpers ──────────────────────────────────────────────────────────
function generateId() {
@@ -77,11 +79,9 @@ function samplePrompts(prompts, n) {
// ── Task prompt templates ────────────────────────────────────────────
-function generateXdsTaskPrompt(prompt, iterDir) {
+function generateXdsTaskPrompt(prompt, projectDir) {
return `You are generating React/TSX code using the XDS design system.
-
-Read the package README at ${path.resolve(VIBE_DIR, '../../packages/core/README.md')} for how to look up
-component docs. Use what you find there to discover the components you need.
+Your project is at ${projectDir}. Explore it to find how to look up component docs.
## Task
@@ -89,18 +89,16 @@ ${prompt.prompt}
## Output
-Write the TSX code to: ${path.join(iterDir, 'results', `${prompt.id}.tsx`)}
-Write metadata to: ${path.join(iterDir, 'results', `${prompt.id}.json`)}
+Write the TSX code to: ${path.join(projectDir, `${prompt.id}.tsx`)}
+Write metadata to: ${path.join(projectDir, `${prompt.id}.json`)}
Metadata: {"completedAt": "<ISO timestamp>", "docsRead": [<component names you looked up>]}
Write ONLY valid TSX. No markdown fences, no explanation.`;
}
-function generateBaselineTaskPrompt(prompt, iterDir) {
+function generateBaselineTaskPrompt(prompt, projectDir) {
return `You are generating React/TSX code using shadcn/ui components with Tailwind CSS.
-
-Read the README at ${VIBE_DIR}/.baseline/README.md for component guidance.
-The actual component sources are in ${VIBE_DIR}/.baseline/components/ui/.
+Your project is at ${projectDir}. Explore it to find available components.
## Task
@@ -108,17 +106,17 @@ ${prompt.prompt}
## Output
-Write the TSX code to: ${path.join(iterDir, 'results', `${prompt.id}.tsx`)}
-Write metadata to: ${path.join(iterDir, 'results', `${prompt.id}.json`)}
+Write the TSX code to: ${path.join(projectDir, `${prompt.id}.tsx`)}
+Write metadata to: ${path.join(projectDir, `${prompt.id}.json`)}
Metadata: {"completedAt": "<ISO timestamp>", "docsRead": [<docs you read>]}
Write ONLY valid TSX. No markdown fences, no explanation.`;
}
-function generateHtmlTaskPrompt(prompt, iterDir) {
+function generateHtmlTaskPrompt(prompt, projectDir) {
return `You are generating React/TSX code using ONLY plain HTML elements and inline CSS.
-Do NOT use any component library. Use standard HTML elements (div, button, input, etc.)
-with inline styles or a styles object.
+Your project is at ${projectDir}. Do NOT use any component library.
+Use standard HTML elements (div, button, input, etc.) with inline styles or a styles object.
## Task
@@ -126,8 +124,8 @@ ${prompt.prompt}
## Output
-Write the TSX code to: ${path.join(iterDir, 'results', `${prompt.id}.tsx`)}
-Write metadata to: ${path.join(iterDir, 'results', `${prompt.id}.json`)}
+Write the TSX code to: ${path.join(projectDir, `${prompt.id}.tsx`)}
+Write metadata to: ${path.join(projectDir, `${prompt.id}.json`)}
Metadata: {"completedAt": "<ISO timestamp>", "docsRead": []}
Write ONLY valid TSX. No markdown fences, no explanation.`;
@@ -165,7 +163,8 @@ function createIteration(target, prompts, generateFn) {
);
for (const prompt of prompts) {
- const taskPrompt = generateFn(prompt, iterDir);
+ const agentProject = createAgentProject(target, iterDir, prompt.id);
+ const taskPrompt = generateFn(prompt, agentProject);
const task = {
promptId: prompt.id,
category: prompt.category,
@@ -248,6 +247,11 @@ for (const p of prompts) {
}
console.log(`\n## After all agents complete:\n`);
+console.log(` # Collect results from agent project dirs`);
+console.log(` node src/collect-results.mjs ${xds.iterationId}`);
+console.log(` node src/collect-results.mjs ${baseline.iterationId}`);
+console.log(` node src/collect-results.mjs ${html.iterationId}`);
+console.log(``);
console.log(` # tsc type-checking`);
console.log(` npx tsx src/build-previews.ts --iterations "${xds.iterationId},${baseline.iterationId},${html.iterationId}" --tsc-only`);
console.log(`\n # Evaluation`);
diff --git a/packages/core/README.md b/packages/core/README.md
index ef9f2ef6a9..d1742a9eee 100644
--- a/packages/core/README.md
+++ b/packages/core/README.md
@@ -12,16 +12,36 @@ node node_modules/@xds/core/docs.mjs --list # list all components
node node_modules/@xds/core/docs.mjs --list --brief # brief summaries
```
+## Page Layouts
+
+Building a full page? Start with a template rather than composing from scratch.
+Templates show how to combine `XDSAppShell`, `XDSLayout`, `XDSTopNav`, and `XDSSideNav`
+into common page patterns (dashboards, settings, forms, detail pages).
+
+Requires `@xds/cli` (`npm install -D @xds/cli`):
+
+```bash
+npx xds template --list # browse all page and block templates
+npx xds template dashboard # emit full page source
+npx xds template settings --skeleton # layout skeleton with spatial annotations
+```
+
## XDS CLI
-For richer documentation including templates, scaffolding, and tooling utilities, install the XDS CLI:
+The CLI (`@xds/cli`) provides additional tooling:
```bash
-npx xds --help # full listing of CLI capabilities
-npx xds component Button # full docs + related templates
-npx xds template --list # browse page and block templates
-npx xds template Dashboard --skeleton # scaffold a template
-npx xds docs # principles, tokens, theming, and styling reference
+npx xds --help # full listing of all commands
+npx xds component Button # full docs + related block templates
+npx xds docs # reference docs (principles, tokens, theming, styling)
+npx xds docs theme # theming guide (XDSTheme, defineTheme, light/dark)
+npx xds docs tokens # spacing, color, radius, typography token reference
+npx xds init # initialize XDS in your project
+npx xds theme build # build theme CSS for production
+npx xds swizzle Button # eject component source for customization
+npx xds upgrade --apply # run codemods to migrate between versions
+npx xds discover # discover external XDS packages
+npx xds gap-report # report a missing capability
```
## Resources