Summary
Make dual init an interactive setup wizard that detects existing devcontainer.json or guides the user through creating one. The result is both .dual/settings.json and .devcontainer/devcontainer.json fully configured.
Interactive Flow
Step 1: Detect existing devcontainer
Detected .devcontainer/devcontainer.json
Use this as your container config? [Y/n]
If yes → set devcontainer path in settings.json, skip to Step 5.
If no existing devcontainer detected → proceed to Step 2.
Step 2: Select base image
Select base image:
1. node:20 (Node.js)
2. python:3.12 (Python)
3. rust:latest (Rust)
4. Custom (enter image name)
>
Step 3: Ports
Which ports does your dev server use? (comma-separated, or empty for none)
> 3000
Step 4: Setup command
Setup command after container creation? (e.g., pnpm install, or empty for none)
> pnpm install
Step 5: Summary & confirm
Configuration:
Image: node:20
Ports: 3000
Setup: pnpm install
.dual/settings.json (Dual config)
.devcontainer/devcontainer.json (container config)
Create these files? [Y/n]
Implementation
- New
src/init.rs module — interactive prompts using stdin/stdout
cmd_init() rewrite — call init module, write both config files
- Non-interactive mode —
dual init --yes or dual init -y accepts all defaults (node:20, no ports, no setup)
- Writes:
.dual/settings.json with devcontainer path + defaults
.devcontainer/devcontainer.json with user selections (only if creating new)
- Existing behavior preserved — still registers workspace in global state, installs shell hook
Edge Cases
.dual/settings.json already exists → warn and ask to overwrite
.devcontainer/devcontainer.json already exists → use it, don't overwrite
- Not in a git repo → error (same as current
dual add)
Tests
- Non-interactive mode (
--yes) creates correct defaults
- Existing devcontainer detection works
- Generated devcontainer.json is valid JSON
- Generated settings.json has correct devcontainer path
Summary
Make
dual initan interactive setup wizard that detects existing devcontainer.json or guides the user through creating one. The result is both.dual/settings.jsonand.devcontainer/devcontainer.jsonfully configured.Interactive Flow
Step 1: Detect existing devcontainer
If yes → set
devcontainerpath in settings.json, skip to Step 5.If no existing devcontainer detected → proceed to Step 2.
Step 2: Select base image
Step 3: Ports
Step 4: Setup command
Step 5: Summary & confirm
Implementation
src/init.rsmodule — interactive prompts using stdin/stdoutcmd_init()rewrite — call init module, write both config filesdual init --yesordual init -yaccepts all defaults (node:20, no ports, no setup).dual/settings.jsonwith devcontainer path + defaults.devcontainer/devcontainer.jsonwith user selections (only if creating new)Edge Cases
.dual/settings.jsonalready exists → warn and ask to overwrite.devcontainer/devcontainer.jsonalready exists → use it, don't overwritedual add)Tests
--yes) creates correct defaults