opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: Add `opencode init` command with interactive setup and AI-powered AGENTS.md generation

Open roerohan opened this issue 2 weeks ago • 1 comments

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.md by analyzing the codebase using the /init command
  • Automatic .gitignore management for opencode.jsonc
  • Non-interactive mode with --skip flag for automation

Behavior

Interactive Mode (opencode init)

  1. Permission Configuration: Prompts for bash, edit, webfetch, and skill permissions
  2. Config File:
    • Creates opencode.jsonc with selected permissions
    • If exists, asks to overwrite (default: No)
  3. 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
  4. Gitignore: Adds opencode.jsonc to .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

roerohan avatar Dec 26 '25 10:12 roerohan