Skip to content

Conversation

@roerohan
Copy link
Contributor

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
Copy link
Contributor Author

/review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant