Skip to content

Commit 0b056a2

Browse files
committed
refactor: use .opencode/opencoder/ directory structure
Move all opencoder files under .opencode/opencoder/ to keep all OpenCode-related files together in a shared parent directory. Changes: - .opencoder/ → .opencode/opencoder/ - opencoder.json → .opencode/opencoder/config.json - Updated fs.ts paths, config.ts loader, CLI help text - Updated .gitignore to ignore state/logs but allow config - Updated README.md and AGENTS.md documentation - Renamed opencoder.json.example → config.json.example Signed-off-by: leocavalcante <[email protected]>
1 parent 21025d6 commit 0b056a2

File tree

7 files changed

+50
-43
lines changed

7 files changed

+50
-43
lines changed

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
# OpenCoder
2-
.opencoder/
1+
# OpenCoder state and logs (config.json is user-managed)
2+
.opencode/opencoder/state.json
3+
.opencode/opencoder/current_plan.md
4+
.opencode/opencoder/logs/
5+
.opencode/opencoder/history/
6+
.opencode/opencoder/alerts.log
37

48
# Bun
59
node_modules/

AGENTS.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe("module", () => {
251251
### Config Priority (lowest to highest)
252252

253253
1. Defaults (hardcoded)
254-
2. `opencoder.json` in project directory
254+
2. `.opencode/opencoder/config.json` in project directory
255255
3. Environment variables (`OPENCODER_*`)
256256
4. CLI arguments
257257

@@ -267,7 +267,7 @@ OPENCODER_LOG_RETENTION=30
267267
OPENCODER_TASK_PAUSE_SECONDS=2
268268
```
269269

270-
### Config File (opencoder.json)
270+
### Config File (.opencode/opencoder/config.json)
271271

272272
```json
273273
{
@@ -301,7 +301,7 @@ Opencoder includes an **ideas queue system** that allows users to provide specif
301301

302302
### How It Works
303303

304-
1. **Ideas Directory**: `.opencoder/ideas/` - Users place `.md` files here
304+
1. **Ideas Directory**: `.opencode/opencoder/ideas/` - Users place `.md` files here
305305
2. **Plan Integration**: Before each plan cycle, the loop checks for ideas
306306
3. **Selection Logic**:
307307
- **1 idea**: Used directly (no AI selection call)
@@ -343,8 +343,8 @@ Steps:
343343
bun test tests/ideas.test.ts
344344

345345
# Test full integration
346-
mkdir -p test-project/.opencoder/ideas
347-
echo "# Test idea" > test-project/.opencoder/ideas/test.md
346+
mkdir -p test-project/.opencode/opencoder/ideas
347+
echo "# Test idea" > test-project/.opencode/opencoder/ideas/test.md
348348
bun run dev -- -m anthropic/claude-sonnet-4 -p test-project
349349
```
350350

@@ -361,7 +361,7 @@ bun run dev -- -m anthropic/claude-sonnet-4 -p test-project
361361
2. **Build Phase**: Build tasks from the plan one by one
362362
3. **Evaluation Phase**: AI evaluates if cycle is complete (COMPLETE/NEEDS_WORK)
363363

364-
State is persisted to `.opencoder/state.json` after each phase for resumability.
364+
State is persisted to `.opencode/opencoder/state.json` after each phase for resumability.
365365

366366
## CI Pipeline
367367

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
- **Autonomous Development Loop** - Continuously plans, builds, and evaluates without stopping
1010
- **OpenCode SDK Integration** - Direct SDK integration with real-time event streaming
11-
- **Ideas Queue** - Drop markdown files in `.opencoder/ideas/` to prioritize specific tasks before autonomous plan
11+
- **Ideas Queue** - Drop markdown files in `.opencode/opencoder/ideas/` to prioritize specific tasks before autonomous plan
1212
- **Two-Model Architecture** - Uses a high-capability model for plan and a faster model for building
1313
- **Live Output Streaming** - Real-time display of AI thinking, tool calls, and results
1414
- **State Persistence** - Resumes from where it left off after interruptions (JSON format)
@@ -163,9 +163,9 @@ The loop continues indefinitely until manually stopped (Ctrl+C).
163163

164164
## Configuration
165165

166-
### Config File (opencoder.json)
166+
### Config File (.opencode/opencoder/config.json)
167167

168-
Create an `opencoder.json` in your project directory:
168+
Create a `.opencode/opencoder/config.json` in your project:
169169

170170
```json
171171
{
@@ -195,27 +195,29 @@ Create an `opencoder.json` in your project directory:
195195
Configuration is merged in this order (later overrides earlier):
196196

197197
1. Defaults (hardcoded)
198-
2. `opencoder.json` in project directory
198+
2. `.opencode/opencoder/config.json` in project directory
199199
3. Environment variables (`OPENCODER_*`)
200200
4. CLI arguments
201201

202202
## Directory Structure
203203

204-
OpenCoder creates a `.opencoder/` directory in your project:
204+
OpenCoder creates a `.opencode/opencoder/` directory in your project:
205205

206206
```
207-
.opencoder/
208-
├── state.json # Current state (JSON)
209-
├── current_plan.md # Active task plan
210-
├── ideas/ # Drop .md files here to queue tasks
211-
│ ├── feature-x.md
212-
│ └── bugfix-y.md
213-
├── history/ # Archived completed plans
214-
│ └── plan_YYYYMMDD_HHMMSS_cycleN.md
215-
└── logs/
216-
├── main.log # Main rotating log
217-
└── cycles/ # Per-cycle detailed logs
218-
└── cycle_001.log
207+
.opencode/
208+
└── opencoder/
209+
├── config.json # Configuration file
210+
├── state.json # Current state (JSON)
211+
├── current_plan.md # Active task plan
212+
├── ideas/ # Drop .md files here to queue tasks
213+
│ ├── feature-x.md
214+
│ └── bugfix-y.md
215+
├── history/ # Archived completed plans
216+
│ └── plan_YYYYMMDD_HHMMSS_cycleN.md
217+
└── logs/
218+
├── main.log # Main rotating log
219+
└── cycles/ # Per-cycle detailed logs
220+
└── cycle_001.log
219221
```
220222

221223
## Plan Format
@@ -244,13 +246,13 @@ Using bcrypt for password hashing, JWT for tokens.
244246

245247
## Ideas Queue
246248

247-
Want to direct OpenCoder toward specific tasks? Drop markdown files in `.opencoder/ideas/` and OpenCoder will prioritize them before generating its own plans.
249+
Want to direct OpenCoder toward specific tasks? Drop markdown files in `.opencode/opencoder/ideas/` and OpenCoder will prioritize them before generating its own plans.
248250

249251
### Quick Start
250252

251253
```bash
252254
# Create an idea
253-
cat > .opencoder/ideas/add-dark-mode.md << 'EOF'
255+
cat > .opencode/opencoder/ideas/add-dark-mode.md << 'EOF'
254256
# Add Dark Mode
255257
256258
Add dark mode toggle with system preference detection.
@@ -267,7 +269,7 @@ opencoder -m anthropic/claude-sonnet-4
267269

268270
### How It Works
269271

270-
1. **Before Planning** - OpenCoder checks `.opencoder/ideas/` for `.md` files
272+
1. **Before Planning** - OpenCoder checks `.opencode/opencoder/ideas/` for `.md` files
271273
2. **Smart Selection**:
272274
- **1 idea**: Uses it directly (no extra API call)
273275
- **2+ ideas**: AI evaluates all and picks the simplest/quick-win, considering dependencies
@@ -301,10 +303,10 @@ The AI prioritizes based on:
301303
## Tips
302304

303305
- **Start with a clear hint** - The more specific your instruction, the better the initial plan
304-
- **Use ideas for focus** - Drop task files in `.opencoder/ideas/` to direct development
306+
- **Use ideas for focus** - Drop task files in `.opencode/opencoder/ideas/` to direct development
305307
- **Let it run** - OpenCoder is designed to run continuously; trust the loop
306-
- **Check the logs** - Detailed logs are in `.opencoder/logs/` if something goes wrong
307-
- **Review history** - Completed plans are archived in `.opencoder/history/`
308+
- **Check the logs** - Detailed logs are in `.opencode/opencoder/logs/` if something goes wrong
309+
- **Review history** - Completed plans are archived in `.opencode/opencoder/history/`
308310

309311
## Development
310312

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Environment variables:
7373
OPENCODER_VERBOSE Enable verbose logging (true/1)
7474
OPENCODER_PROJECT_DIR Default project directory
7575
76-
Config file (opencoder.json):
76+
Config file (.opencode/opencoder/config.json):
7777
{
7878
"planModel": "anthropic/claude-sonnet-4",
7979
"buildModel": "anthropic/claude-sonnet-4",

src/config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
*
44
* Priority (lowest to highest):
55
* 1. Defaults
6-
* 2. opencoder.json in project directory
6+
* 2. .opencode/opencoder/config.json in project directory
77
* 3. Environment variables
88
* 4. CLI arguments
99
*/
1010

1111
import { existsSync } from "node:fs"
1212
import { readFile } from "node:fs/promises"
13-
import { resolve } from "node:path"
13+
import { join, resolve } from "node:path"
1414
import type { CliOptions, Config, ConfigFile } from "./types.ts"
1515

1616
/** Default configuration values */
@@ -80,10 +80,10 @@ function resolveProjectDir(cliProject?: string): string {
8080
}
8181

8282
/**
83-
* Load configuration from opencoder.json file
83+
* Load configuration from .opencode/opencoder/config.json file
8484
*/
8585
async function loadConfigFile(projectDir: string): Promise<Partial<Config>> {
86-
const configPath = resolve(projectDir, "opencoder.json")
86+
const configPath = join(resolve(projectDir), ".opencode", "opencoder", "config.json")
8787

8888
if (!existsSync(configPath)) {
8989
return {}
@@ -103,7 +103,7 @@ async function loadConfigFile(projectDir: string): Promise<Partial<Config>> {
103103
taskPauseSeconds: parsed.taskPauseSeconds,
104104
}
105105
} catch (err) {
106-
console.warn(`Warning: Failed to parse opencoder.json: ${err}`)
106+
console.warn(`Warning: Failed to parse config.json: ${err}`)
107107
return {}
108108
}
109109
}
@@ -156,13 +156,13 @@ function loadEnvConfig(): Partial<Config> {
156156
function validateConfig(config: Config): void {
157157
if (!config.planModel) {
158158
throw new Error(
159-
"Missing plan model. Provide via --model, --plan-model, opencoder.json, or OPENCODER_PLAN_MODEL env var.",
159+
"Missing plan model. Provide via --model, --plan-model, .opencode/opencoder/config.json, or OPENCODER_PLAN_MODEL env var.",
160160
)
161161
}
162162

163163
if (!config.buildModel) {
164164
throw new Error(
165-
"Missing build model. Provide via --model, --build-model, opencoder.json, or OPENCODER_BUILD_MODEL env var.",
165+
"Missing build model. Provide via --model, --build-model, .opencode/opencoder/config.json, or OPENCODER_BUILD_MODEL env var.",
166166
)
167167
}
168168

src/fs.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { existsSync, mkdirSync, readdirSync, renameSync, statSync, unlinkSync }
66
import { join, resolve } from "node:path"
77
import type { Paths } from "./types.ts"
88

9-
/** Name of the workspace directory */
10-
const OPENCODER_DIR = ".opencoder"
9+
/** Name of the workspace directory (inside .opencode) */
10+
const OPENCODE_DIR = ".opencode"
11+
const OPENCODER_SUBDIR = "opencoder"
1112

1213
/**
1314
* Initialize all workspace paths for a project
1415
*/
1516
export function initializePaths(projectDir: string): Paths {
16-
const opencoderDir = join(resolve(projectDir), OPENCODER_DIR)
17+
const opencoderDir = join(resolve(projectDir), OPENCODE_DIR, OPENCODER_SUBDIR)
1718

1819
return {
1920
opencoderDir,
@@ -24,7 +25,7 @@ export function initializePaths(projectDir: string): Paths {
2425
alertsFile: join(opencoderDir, "alerts.log"),
2526
historyDir: join(opencoderDir, "history"),
2627
ideasDir: join(opencoderDir, "ideas"),
27-
configFile: join(resolve(projectDir), "opencoder.json"),
28+
configFile: join(opencoderDir, "config.json"),
2829
}
2930
}
3031

0 commit comments

Comments
 (0)