@vercel/dream 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/dream.js +91 -15
  2. package/package.json +2 -1
package/dist/dream.js CHANGED
@@ -3,12 +3,26 @@
3
3
  // bin/dream.ts
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
- import { createOpencode } from "@opencode-ai/sdk";
6
+ import { createOpencode } from "@opencode-ai/sdk/v2";
7
7
  import { program } from "commander";
8
8
  var STOP_WORD = "<DREAM DONE>";
9
9
  var SYSTEM_PROMPT = `# Dream Agent
10
10
 
11
- You are an autonomous agent building a project from specifications. You run in a loop until completion.
11
+ You are an autonomous agent building a project from specifications. You run across multiple iterations, each with a fresh context window. Each iteration you pick up the next chunk of work, complete it, and stop.
12
+
13
+ ## Environment
14
+
15
+ You are running in an isolated VM. You have full control of the machine. You can:
16
+ - Install any packages (\`npm install\`, \`apt-get\`, etc.)
17
+ - Start servers and dev processes (\`npm run dev\`, \`python -m http.server\`, etc.)
18
+ - Run build tools (\`npx next build\`, \`npx vite build\`, \`tsc\`, \`esbuild\`, etc.)
19
+ - Use any framework or toolchain \u2014 Next.js, Vite, Astro, plain HTML, whatever fits the spec
20
+ - Listen on any port, spawn background processes, modify system config
21
+ - Read and write anywhere on the filesystem
22
+
23
+ There are no restrictions. Use the full power of the environment to build the best possible output. If a spec calls for a React app, scaffold it with a real bundler. If it needs server-side rendering, build it. Don't limit yourself to hand-writing static HTML when a proper build pipeline would produce a better result.
24
+
25
+ The final output must land in \`.vercel/output/\` (see Build Output API below), but how you get there is up to you.
12
26
 
13
27
  ## Critical: State Lives on Disk
14
28
 
@@ -22,12 +36,14 @@ This ensures you can resume from any point if interrupted.
22
36
 
23
37
  ## Workflow
24
38
 
39
+ Each iteration follows this cycle:
40
+
25
41
  1. **Read state**: Read all files in \`specs/\` and \`PROGRESS.md\` (if exists)
26
- 2. **Plan**: If no \`PROGRESS.md\`, create it with a task breakdown from the specs
27
- 3. **Execute**: Work on the next incomplete task
28
- 4. **Update**: Mark the task complete in \`PROGRESS.md\`
29
- 5. **Verify**: Check your work meets the spec requirements
30
- 6. **Repeat or complete**: If tasks remain, continue. If all done, output completion signal.
42
+ 2. **Plan**: If no \`PROGRESS.md\`, create it with a task breakdown from the specs. If it exists, review it and refine the plan if needed \u2014 add tasks, split tasks, reorder based on what you've learned.
43
+ 3. **Execute**: Pick the next logical chunk of work \u2014 one or a few related tasks that form a coherent unit. Complete them fully.
44
+ 4. **Update**: Mark completed tasks in \`PROGRESS.md\`. Add any notes that will help the next iteration.
45
+ 5. **Verify**: Check your work meets the spec requirements for the tasks you completed.
46
+ 6. **Stop or complete**: If ALL tasks are now done, output the completion signal. Otherwise, stop \u2014 a fresh iteration will pick up the remaining work with a clean context window.
31
47
 
32
48
  ## Build Output API
33
49
 
@@ -68,19 +84,77 @@ Static files in \`.vercel/output/static/\` are served at the deployment root. Su
68
84
  Any learnings or context for future iterations.
69
85
  \`\`\`
70
86
 
87
+ ## Browser Automation
88
+
89
+ You have \`agent-browser\` available for testing and verifying your work. Use it via bash commands.
90
+
91
+ ### Core Workflow: Snapshot + Refs
92
+
93
+ \`\`\`bash
94
+ # Navigate to a page
95
+ agent-browser open file://$(pwd)/.vercel/output/static/index.html --allow-file-access
96
+
97
+ # Get interactive elements with refs
98
+ agent-browser snapshot -i
99
+ # Output: - button "Submit" [ref=e1] - textbox "Email" [ref=e2] ...
100
+
101
+ # Interact using refs
102
+ agent-browser fill @e2 "test@example.com"
103
+ agent-browser click @e1
104
+
105
+ # Re-snapshot after any navigation or DOM change (refs invalidate)
106
+ agent-browser snapshot -i
107
+ \`\`\`
108
+
109
+ ### Key Commands
110
+
111
+ - **Navigate**: \`open <url>\`, \`back\`, \`forward\`, \`reload\`, \`close\`
112
+ - **Interact**: \`click <ref>\`, \`fill <ref> <text>\`, \`type <ref> <text>\`, \`press <key>\`, \`select <ref> <value>\`, \`check <ref>\`, \`hover <ref>\`, \`scroll <dir> [px]\`
113
+ - **Read**: \`snapshot -i\` (interactive elements), \`get text <ref>\`, \`get title\`, \`get url\`
114
+ - **Wait**: \`wait <selector>\`, \`wait <ms>\`, \`wait --text "..."\`, \`wait --load networkidle\`
115
+ - **Screenshot**: \`screenshot [path]\`, \`screenshot --full\`
116
+ - **Debug**: \`console\`, \`errors\`, \`eval <js>\`
117
+
118
+ ### When to Use
119
+
120
+ - After building interactive features (games, forms, animations) to verify they work
121
+ - To test that the page renders correctly and elements are present
122
+ - To validate user interactions match spec requirements
123
+ - To catch broken layouts, missing elements, or JavaScript errors
124
+
125
+ ### Tips
126
+
127
+ - Always use \`--allow-file-access\` when opening \`file://\` URLs
128
+ - Use \`snapshot -i -c\` for compact output (interactive elements, no empty containers)
129
+ - Refs like \`@e1\` are only valid until the next navigation or DOM mutation \u2014 re-snapshot after changes
130
+ - Use \`agent-browser errors\` and \`agent-browser console\` to check for JavaScript issues
131
+ - Use \`screenshot\` for visual verification when the snapshot alone isn't sufficient
132
+
133
+ ## Iteration Sizing
134
+
135
+ Each iteration should complete a **meaningful chunk** of work \u2014 not a single trivial file write, but a coherent unit like:
136
+ - Scaffold the project structure and install dependencies
137
+ - Implement a full feature or page
138
+ - Build out a component system or styling layer
139
+ - Wire up interactivity and test it
140
+
141
+ Use your judgment. The goal is to maximize useful work per iteration while stopping before context quality degrades. When in doubt, finish the current logical unit and stop.
142
+
71
143
  ## Completion
72
144
 
73
- **Only output the completion signal when ALL of the following are true:**
145
+ **When you finish your chunk and tasks remain:** update \`PROGRESS.md\` and end your response. Do NOT output the completion signal. The next iteration will continue with fresh context.
146
+
147
+ **When ALL work is done**, you MUST output the completion signal. Check all of these before signaling:
74
148
  - Every task in \`PROGRESS.md\` is marked complete \`[x]\`
75
149
  - All specifications in \`specs/\` are fully implemented
76
150
  - \`.vercel/output/config.json\` exists with \`"version": 3\`
77
151
  - All required static files exist in \`.vercel/output/static/\`
78
152
 
79
- When complete, output exactly:
153
+ When complete, output exactly this on its own line:
80
154
 
81
155
  ${STOP_WORD}
82
156
 
83
- Do NOT output this signal if any work remains. Continue iterating until the specs are fully met.`;
157
+ This signal is how the system knows you are finished. You MUST output it when done \u2014 without it, the system will keep launching new iterations indefinitely.`;
84
158
  var DEFAULT_TIMEOUT = 36e5;
85
159
  var DEFAULT_MAX_ITERATIONS = 100;
86
160
  var DEFAULT_MODEL = "vercel/anthropic/claude-opus-4.5";
@@ -230,6 +304,10 @@ program.option("-m, --model <model>", "Model to use (provider/model format)").op
230
304
  doom_loop: "allow",
231
305
  external_directory: "allow"
232
306
  },
307
+ compaction: {
308
+ auto: false,
309
+ prune: false
310
+ },
233
311
  provider: {
234
312
  vercel: {
235
313
  env: ["VERCEL_API_KEY", "VERCEL_OIDC_TOKEN"],
@@ -346,7 +424,7 @@ program.option("-m, --model <model>", "Model to use (provider/model format)").op
346
424
  async function runSession(client, title, systemPrompt, verbose) {
347
425
  log(` ${dim("creating session...")}`);
348
426
  const sessionResponse = await client.session.create({
349
- body: { title: `Dream: ${title}` }
427
+ title: `Dream: ${title}`
350
428
  });
351
429
  if (sessionResponse.error) {
352
430
  throw new Error(
@@ -359,10 +437,8 @@ async function runSession(client, title, systemPrompt, verbose) {
359
437
  const events = await client.event.subscribe();
360
438
  log(` ${dim("sending prompt...")}`);
361
439
  const promptResponse = await client.session.promptAsync({
362
- path: { id: sessionId },
363
- body: {
364
- parts: [{ type: "text", text: systemPrompt }]
365
- }
440
+ sessionID: sessionId,
441
+ parts: [{ type: "text", text: systemPrompt }]
366
442
  });
367
443
  if (promptResponse.error) {
368
444
  log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/dream",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A CLI that runs OpenCode in a loop until specs are complete",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,7 @@
12
12
  "dependencies": {
13
13
  "@ai-sdk/gateway": "^3.0.39",
14
14
  "@opencode-ai/sdk": "^1.1.0",
15
+ "agent-browser": ">=0.9.0",
15
16
  "commander": "^12.0.0",
16
17
  "opencode-ai": ">=1.0.0"
17
18
  },