Files
backnotprop__plannotator/apps/opencode-plugin/devcontainer.md
T
Michael Ramos 14e9aea0ec Fix/devcontainer & plan auto switching (opencode) (#31)
* Refactor: shared server package with PLANNOTATOR_REMOTE env var

- Create packages/server/ with shared server implementation
- Add PLANNOTATOR_REMOTE=1 env var for devcontainer/SSH mode
- Deprecate SSH_CONNECTION detection (still works with warning)
- Both Claude Code and OpenCode now use identical server logic
- OpenCode gains Obsidian/Bear integrations and remote detection
- Update documentation with environment variables section

Fixes #27

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove PLANNOTATOR_ORIGIN env var, fix onReady callback timing

- Remove PLANNOTATOR_ORIGIN hack from Claude Code hook (hardcode "claude-code")
- Fix onReady callback to pass port directly (was referencing undefined server)
- Create tests/manual/test-server.ts for testing either origin
- Update test-hook-2.sh to use new test server with opencode origin

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add devcontainer test setup, reduce logging verbosity

- Add tests/devcontainer/ with devcontainer.json for testing remote mode
- Add tests/opencode-local/ for local OpenCode testing
- Update package.json build script for proper bundling
- Remove verbose multi-line error messages, keep useful errors
- Clean up unused deprecationWarned variable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add devcontainer support and documentation

- Add PLANNOTATOR_REMOTE env var for container/remote detection
- Remove console logging (silent operation)
- Add devcontainer.md with full setup instructions
- Add devcontainer section to OpenCode plugin README
- Add port-only test setup to reproduce common misconfiguration
- Update test devcontainers to forward port 4096 for opencode web
- Bump version to 0.4.1

Fixes #27

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update CLAUDE.md: legacy SSH detection, not deprecated

Removed incorrect mention of deprecation warning - SSH_TTY/SSH_CONNECTION
detection is silent by design.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix OpenCode agent switching after plan approval

After approving a plan, the conversation context stayed in "plan" mode
even though the TUI showed "build". This caused edits to fail because
the plan agent has edit permissions denied.

The fix uses session.prompt() to inject a message with agent: "build",
which triggers a new agentic loop with proper build agent permissions.

Fixes #29

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 14:25:19 -08:00

1.9 KiB

Devcontainer / Docker Setup

Plannotator works in devcontainers and Docker environments with minimal configuration.

Required Environment Variables

Add these to your devcontainer.json:

{
  "containerEnv": {
    "PLANNOTATOR_REMOTE": "1",
    "PLANNOTATOR_PORT": "9999"
  },
  "forwardPorts": [9999]
}
Variable Purpose
PLANNOTATOR_REMOTE=1 Tells Plannotator not to open a browser (required in containers)
PLANNOTATOR_PORT=9999 Fixed port for the UI (required for port forwarding)

Both are required. Just setting the port isn't enough.

Port Forwarding

Ensure port 9999 (or your chosen port) is forwarded to your host. In VS Code devcontainers, add it to forwardPorts as shown above.

Usage

  1. Run OpenCode in your container (opencode or opencode web)
  2. Ask the agent to create a plan
  3. When submit_plan is called, Plannotator starts on port 9999
  4. Open http://localhost:9999 in your host browser
  5. Approve or deny the plan

Note: There's no browser auto-open or notification in remote mode. You'll need to manually navigate to the URL when you see the agent call submit_plan.

OpenCode Web

opencode web works in devcontainers. Forward port 4096 (default) for the OpenCode UI, and port 9999 for Plannotator:

{
  "forwardPorts": [4096, 9999]
}

Legacy Support

If your environment already has SSH_TTY or SSH_CONNECTION set (common in SSH sessions), Plannotator will detect remote mode automatically. The PLANNOTATOR_REMOTE env var is preferred for Docker/devcontainer setups where those aren't present.

Troubleshooting

Plugin not updating?

rm -rf ~/.cache/opencode/node_modules/@plannotator

OpenCode crashes on startup?

rm -rf ~/.cache/opencode

Port not accessible? Check your devcontainer's port forwarding. In VS Code, check the "Ports" tab.