@vercel/dream 0.2.1 → 0.2.3
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.
- package/dist/dream.js +68 -6
- package/package.json +43 -37
package/dist/dream.js
CHANGED
|
@@ -3,13 +3,27 @@
|
|
|
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
11
|
You are an autonomous agent building a project from specifications. You run in a loop until completion.
|
|
12
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.
|
|
26
|
+
|
|
13
27
|
## Critical: State Lives on Disk
|
|
14
28
|
|
|
15
29
|
Each iteration starts with fresh context. You must:
|
|
@@ -68,6 +82,52 @@ Static files in \`.vercel/output/static/\` are served at the deployment root. Su
|
|
|
68
82
|
Any learnings or context for future iterations.
|
|
69
83
|
\`\`\`
|
|
70
84
|
|
|
85
|
+
## Browser Automation
|
|
86
|
+
|
|
87
|
+
You have \`agent-browser\` available for testing and verifying your work. Use it via bash commands.
|
|
88
|
+
|
|
89
|
+
### Core Workflow: Snapshot + Refs
|
|
90
|
+
|
|
91
|
+
\`\`\`bash
|
|
92
|
+
# Navigate to a page
|
|
93
|
+
agent-browser open file://$(pwd)/.vercel/output/static/index.html --allow-file-access
|
|
94
|
+
|
|
95
|
+
# Get interactive elements with refs
|
|
96
|
+
agent-browser snapshot -i
|
|
97
|
+
# Output: - button "Submit" [ref=e1] - textbox "Email" [ref=e2] ...
|
|
98
|
+
|
|
99
|
+
# Interact using refs
|
|
100
|
+
agent-browser fill @e2 "test@example.com"
|
|
101
|
+
agent-browser click @e1
|
|
102
|
+
|
|
103
|
+
# Re-snapshot after any navigation or DOM change (refs invalidate)
|
|
104
|
+
agent-browser snapshot -i
|
|
105
|
+
\`\`\`
|
|
106
|
+
|
|
107
|
+
### Key Commands
|
|
108
|
+
|
|
109
|
+
- **Navigate**: \`open <url>\`, \`back\`, \`forward\`, \`reload\`, \`close\`
|
|
110
|
+
- **Interact**: \`click <ref>\`, \`fill <ref> <text>\`, \`type <ref> <text>\`, \`press <key>\`, \`select <ref> <value>\`, \`check <ref>\`, \`hover <ref>\`, \`scroll <dir> [px]\`
|
|
111
|
+
- **Read**: \`snapshot -i\` (interactive elements), \`get text <ref>\`, \`get title\`, \`get url\`
|
|
112
|
+
- **Wait**: \`wait <selector>\`, \`wait <ms>\`, \`wait --text "..."\`, \`wait --load networkidle\`
|
|
113
|
+
- **Screenshot**: \`screenshot [path]\`, \`screenshot --full\`
|
|
114
|
+
- **Debug**: \`console\`, \`errors\`, \`eval <js>\`
|
|
115
|
+
|
|
116
|
+
### When to Use
|
|
117
|
+
|
|
118
|
+
- After building interactive features (games, forms, animations) to verify they work
|
|
119
|
+
- To test that the page renders correctly and elements are present
|
|
120
|
+
- To validate user interactions match spec requirements
|
|
121
|
+
- To catch broken layouts, missing elements, or JavaScript errors
|
|
122
|
+
|
|
123
|
+
### Tips
|
|
124
|
+
|
|
125
|
+
- Always use \`--allow-file-access\` when opening \`file://\` URLs
|
|
126
|
+
- Use \`snapshot -i -c\` for compact output (interactive elements, no empty containers)
|
|
127
|
+
- Refs like \`@e1\` are only valid until the next navigation or DOM mutation \u2014 re-snapshot after changes
|
|
128
|
+
- Use \`agent-browser errors\` and \`agent-browser console\` to check for JavaScript issues
|
|
129
|
+
- Use \`screenshot\` for visual verification when the snapshot alone isn't sufficient
|
|
130
|
+
|
|
71
131
|
## Completion
|
|
72
132
|
|
|
73
133
|
**Only output the completion signal when ALL of the following are true:**
|
|
@@ -230,6 +290,10 @@ program.option("-m, --model <model>", "Model to use (provider/model format)").op
|
|
|
230
290
|
doom_loop: "allow",
|
|
231
291
|
external_directory: "allow"
|
|
232
292
|
},
|
|
293
|
+
compaction: {
|
|
294
|
+
auto: false,
|
|
295
|
+
prune: false
|
|
296
|
+
},
|
|
233
297
|
provider: {
|
|
234
298
|
vercel: {
|
|
235
299
|
env: ["VERCEL_API_KEY", "VERCEL_OIDC_TOKEN"],
|
|
@@ -346,7 +410,7 @@ program.option("-m, --model <model>", "Model to use (provider/model format)").op
|
|
|
346
410
|
async function runSession(client, title, systemPrompt, verbose) {
|
|
347
411
|
log(` ${dim("creating session...")}`);
|
|
348
412
|
const sessionResponse = await client.session.create({
|
|
349
|
-
|
|
413
|
+
title: `Dream: ${title}`
|
|
350
414
|
});
|
|
351
415
|
if (sessionResponse.error) {
|
|
352
416
|
throw new Error(
|
|
@@ -359,10 +423,8 @@ async function runSession(client, title, systemPrompt, verbose) {
|
|
|
359
423
|
const events = await client.event.subscribe();
|
|
360
424
|
log(` ${dim("sending prompt...")}`);
|
|
361
425
|
const promptResponse = await client.session.promptAsync({
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
parts: [{ type: "text", text: systemPrompt }]
|
|
365
|
-
}
|
|
426
|
+
sessionID: sessionId,
|
|
427
|
+
parts: [{ type: "text", text: systemPrompt }]
|
|
366
428
|
});
|
|
367
429
|
if (promptResponse.error) {
|
|
368
430
|
log(
|
package/package.json
CHANGED
|
@@ -1,38 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
2
|
+
"name": "@vercel/dream",
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"description": "A CLI that runs OpenCode in a loop until specs are complete",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"dream": "./dist/dream.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@ai-sdk/gateway": "^3.0.39",
|
|
14
|
+
"@opencode-ai/sdk": "^1.1.0",
|
|
15
|
+
"agent-browser": ">=0.9.0",
|
|
16
|
+
"commander": "^12.0.0",
|
|
17
|
+
"opencode-ai": ">=1.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@biomejs/biome": "^1.9.0",
|
|
21
|
+
"@changesets/cli": "^2.29.8",
|
|
22
|
+
"@types/node": "^22.0.0",
|
|
23
|
+
"lefthook": "^2.1.0",
|
|
24
|
+
"tsup": "^8.5.1",
|
|
25
|
+
"tsx": "^4.0.0",
|
|
26
|
+
"typescript": "^5.4.0"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"cli",
|
|
30
|
+
"opencode",
|
|
31
|
+
"ai",
|
|
32
|
+
"automation"
|
|
33
|
+
],
|
|
34
|
+
"author": "",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"dev": "tsx bin/dream.ts",
|
|
39
|
+
"check": "biome check .",
|
|
40
|
+
"check:fix": "biome check --write .",
|
|
41
|
+
"version": "changeset version",
|
|
42
|
+
"release": "pnpm build && changeset publish"
|
|
43
|
+
}
|
|
44
|
+
}
|