feat: Add `opencode init` command with interactive setup and AI-powered AGENTS.md generation
Summary
Adds a new opencode init command that provides an interactive setup wizard for initializing OpenCode in a project. Currently, by default, all projects have "allow all" permissions for everything (webfetch, bash, edit, etc.), which is risky. Most people don't create an opencode.jsonc file on their own because they probably don't even know it exists (reading docs has become a thing of the past lol). The opencode init command solves this by walking users through permission configuration interactively and also performs the same codebase analysis that the /init slash command does to generate project-specific AGENTS.md instructions.
Changes
New Command: opencode init
Features:
- Interactive permission configuration for bash, edit, webfetch, and skill tools
- AI-powered generation of
AGENTS.mdby analyzing the codebase using the/initcommand - Automatic
.gitignoremanagement foropencode.jsonc - Non-interactive mode with
--skipflag for automation
Behavior
Interactive Mode (opencode init)
- Permission Configuration: Prompts for bash, edit, webfetch, and skill permissions
- Config File:
- Creates
opencode.jsoncwith selected permissions - If exists, asks to overwrite (default: No)
- Creates
- AGENTS.md Generation:
- If doesn't exist: "Generate AGENTS.md by analyzing your codebase with AI?" (default: Yes)
- If exists: "AGENTS.md already exists. Regenerate by re-analyzing your codebase with AI?" (default: No)
- Uses AI to analyze codebase and generate project-specific instructions
- Shows spinner during generation with 2-minute timeout
- Gitignore: Adds
opencode.jsoncto.gitignore(or creates it) Skip Mode (opencode init --skip)
- Uses default "allow all" permissions
- Skips all prompts for scripting/automation
- Minimal console output
- Skips AGENTS.md generation
Testing
Tested both interactive and skip modes:
Interactive mode
opencode init
Skip mode for automation
opencode init --skip