@vercel/dream 0.2.3 → 0.2.5
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 +27 -30
- package/package.json +4 -8
package/dist/dream.js
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
import * as fs from "fs";
|
|
5
5
|
import * as path from "path";
|
|
6
6
|
import { createOpencode } from "@opencode-ai/sdk/v2";
|
|
7
|
+
import { init } from "@vercel/dream-init";
|
|
7
8
|
import { program } from "commander";
|
|
8
9
|
var STOP_WORD = "<DREAM DONE>";
|
|
9
10
|
var SYSTEM_PROMPT = `# Dream Agent
|
|
10
11
|
|
|
11
|
-
You are an autonomous agent building a project from specifications. You run
|
|
12
|
+
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
|
|
|
13
14
|
## Environment
|
|
14
15
|
|
|
@@ -36,12 +37,14 @@ This ensures you can resume from any point if interrupted.
|
|
|
36
37
|
|
|
37
38
|
## Workflow
|
|
38
39
|
|
|
40
|
+
Each iteration follows this cycle:
|
|
41
|
+
|
|
39
42
|
1. **Read state**: Read all files in \`specs/\` and \`PROGRESS.md\` (if exists)
|
|
40
|
-
2. **Plan**: If no \`PROGRESS.md\`, create it with a task breakdown from the specs
|
|
41
|
-
3. **Execute**:
|
|
42
|
-
4. **Update**: Mark
|
|
43
|
-
5. **Verify**: Check your work meets the spec requirements
|
|
44
|
-
6. **
|
|
43
|
+
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.
|
|
44
|
+
3. **Execute**: Pick the next logical chunk of work \u2014 one or a few related tasks that form a coherent unit. Complete them fully.
|
|
45
|
+
4. **Update**: Mark completed tasks in \`PROGRESS.md\`. Add any notes that will help the next iteration.
|
|
46
|
+
5. **Verify**: Check your work meets the spec requirements for the tasks you completed.
|
|
47
|
+
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.
|
|
45
48
|
|
|
46
49
|
## Build Output API
|
|
47
50
|
|
|
@@ -128,19 +131,31 @@ agent-browser snapshot -i
|
|
|
128
131
|
- Use \`agent-browser errors\` and \`agent-browser console\` to check for JavaScript issues
|
|
129
132
|
- Use \`screenshot\` for visual verification when the snapshot alone isn't sufficient
|
|
130
133
|
|
|
134
|
+
## Iteration Sizing
|
|
135
|
+
|
|
136
|
+
Each iteration should complete a **meaningful chunk** of work \u2014 not a single trivial file write, but a coherent unit like:
|
|
137
|
+
- Scaffold the project structure and install dependencies
|
|
138
|
+
- Implement a full feature or page
|
|
139
|
+
- Build out a component system or styling layer
|
|
140
|
+
- Wire up interactivity and test it
|
|
141
|
+
|
|
142
|
+
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.
|
|
143
|
+
|
|
131
144
|
## Completion
|
|
132
145
|
|
|
133
|
-
**
|
|
146
|
+
**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.
|
|
147
|
+
|
|
148
|
+
**When ALL work is done**, you MUST output the completion signal. Check all of these before signaling:
|
|
134
149
|
- Every task in \`PROGRESS.md\` is marked complete \`[x]\`
|
|
135
150
|
- All specifications in \`specs/\` are fully implemented
|
|
136
151
|
- \`.vercel/output/config.json\` exists with \`"version": 3\`
|
|
137
152
|
- All required static files exist in \`.vercel/output/static/\`
|
|
138
153
|
|
|
139
|
-
When complete, output exactly:
|
|
154
|
+
When complete, output exactly this on its own line:
|
|
140
155
|
|
|
141
156
|
${STOP_WORD}
|
|
142
157
|
|
|
143
|
-
|
|
158
|
+
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.`;
|
|
144
159
|
var DEFAULT_TIMEOUT = 36e5;
|
|
145
160
|
var DEFAULT_MAX_ITERATIONS = 100;
|
|
146
161
|
var DEFAULT_MODEL = "vercel/anthropic/claude-opus-4.5";
|
|
@@ -153,34 +168,16 @@ var log = console.log;
|
|
|
153
168
|
program.name("dream").description("Run OpenCode in a loop until specs are complete").version("0.1.0").option("-d, --dir <directory>", "Working directory", ".");
|
|
154
169
|
program.command("init").description("Initialize a new dream project").action(() => {
|
|
155
170
|
const workDir = path.resolve(program.opts().dir);
|
|
156
|
-
const specsDir = path.join(workDir, "specs");
|
|
157
|
-
const packageJsonPath = path.join(workDir, "package.json");
|
|
158
171
|
log(`
|
|
159
172
|
${bold("\u25B2 dream")} ${dim("\xB7 init")}
|
|
160
173
|
`);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
if (!fs.existsSync(specsDir)) {
|
|
165
|
-
fs.mkdirSync(specsDir);
|
|
166
|
-
fs.writeFileSync(
|
|
167
|
-
path.join(specsDir, "sample.md"),
|
|
168
|
-
"# Sample Spec\n\n## Context\n\nDescribe what you want to build here.\n\n## Tasks\n\n- [ ] First task\n- [ ] Second task\n"
|
|
169
|
-
);
|
|
174
|
+
const result = init({ dir: workDir, version: "^0.2.1" });
|
|
175
|
+
if (result.specsCreated) {
|
|
170
176
|
log(` ${green("+")} specs/sample.md`);
|
|
171
177
|
} else {
|
|
172
178
|
log(` ${dim("\xB7")} specs/ ${dim("already exists")}`);
|
|
173
179
|
}
|
|
174
|
-
if (
|
|
175
|
-
const pkg = {
|
|
176
|
-
name: path.basename(workDir),
|
|
177
|
-
version: "0.1.0",
|
|
178
|
-
private: true,
|
|
179
|
-
scripts: { build: "dream" },
|
|
180
|
-
dependencies: { "@vercel/dream": "^0.1.0" }
|
|
181
|
-
};
|
|
182
|
-
fs.writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, " ")}
|
|
183
|
-
`);
|
|
180
|
+
if (result.packageJsonCreated) {
|
|
184
181
|
log(` ${green("+")} package.json`);
|
|
185
182
|
} else {
|
|
186
183
|
log(` ${dim("\xB7")} package.json ${dim("already exists")}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/dream",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A CLI that runs OpenCode in a loop until specs are complete",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,13 +14,11 @@
|
|
|
14
14
|
"@opencode-ai/sdk": "^1.1.0",
|
|
15
15
|
"agent-browser": ">=0.9.0",
|
|
16
16
|
"commander": "^12.0.0",
|
|
17
|
-
"opencode-ai": ">=1.0.0"
|
|
17
|
+
"opencode-ai": ">=1.0.0",
|
|
18
|
+
"@vercel/dream-init": "0.2.1"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
|
-
"@biomejs/biome": "^1.9.0",
|
|
21
|
-
"@changesets/cli": "^2.29.8",
|
|
22
21
|
"@types/node": "^22.0.0",
|
|
23
|
-
"lefthook": "^2.1.0",
|
|
24
22
|
"tsup": "^8.5.1",
|
|
25
23
|
"tsx": "^4.0.0",
|
|
26
24
|
"typescript": "^5.4.0"
|
|
@@ -37,8 +35,6 @@
|
|
|
37
35
|
"build": "tsup",
|
|
38
36
|
"dev": "tsx bin/dream.ts",
|
|
39
37
|
"check": "biome check .",
|
|
40
|
-
"check:fix": "biome check --write ."
|
|
41
|
-
"version": "changeset version",
|
|
42
|
-
"release": "pnpm build && changeset publish"
|
|
38
|
+
"check:fix": "biome check --write ."
|
|
43
39
|
}
|
|
44
40
|
}
|