Skip to content

Commit 524de87

Browse files
committed
feat: auto-detect project dependencies with AI agent integration
Add `openboot init` auto-detection: scans project files (package.json, go.mod, Cargo.toml, docker-compose.yml, etc.) to detect missing dependencies and install them via Homebrew. Three modes designed for AI coding agents: - `--check --json`: report missing deps as JSON (exit 1 if missing) - `--auto`: auto-install all missing deps without prompts - Interactive TUI for human users Add `openboot setup-agent` command that writes global rules to Claude Code and OpenAI Codex so agents automatically use openboot when they encounter missing dependencies. New package: internal/detector/ with 15 detection rules, version extraction, docker-compose service parsing, and 25 unit tests.
1 parent d05d8e9 commit 524de87

File tree

13 files changed

+1711
-6
lines changed

13 files changed

+1711
-6
lines changed

internal/cli/init.go

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cli
22

33
import (
4+
"errors"
45
"fmt"
56
"os"
67
"path/filepath"
@@ -11,15 +12,37 @@ import (
1112
"github.com/spf13/cobra"
1213
)
1314

15+
var (
16+
initCheck bool
17+
initAuto bool
18+
initJSON bool
19+
)
20+
1421
var initCmd = &cobra.Command{
1522
Use: "init [directory]",
16-
Short: "Set up project environment from .openboot.yml",
17-
Long: `Read .openboot.yml from the project directory and install declared dependencies,
18-
run init scripts, and verify the environment is ready.`,
19-
Example: ` # Initialize from current directory
23+
Short: "Detect and install project dependencies",
24+
Long: `Scan project files to detect required dependencies and install missing ones.
25+
26+
Works without any config file — auto-detects from package.json, go.mod,
27+
Cargo.toml, docker-compose.yml, and 15+ other project file types.
28+
29+
If .openboot.yml exists, uses that instead (explicit config takes priority).
30+
31+
Designed for AI coding agents: run "openboot init --auto" before starting
32+
work on any project to ensure all dependencies are satisfied.`,
33+
Example: ` # Auto-detect and interactively select (human mode)
2034
openboot init
2135
22-
# Initialize from specific directory
36+
# Auto-install all missing dependencies (agent/CI mode)
37+
openboot init --auto
38+
39+
# Check what's missing without installing (returns exit code 1 if missing)
40+
openboot init --check
41+
42+
# JSON output for AI agents
43+
openboot init --check --json
44+
45+
# Use explicit .openboot.yml config
2346
openboot init /path/to/project
2447
2548
# Preview changes without installing
@@ -42,8 +65,18 @@ run init scripts, and verify the environment is ready.`,
4265
return fmt.Errorf("directory does not exist: %s", absDir)
4366
}
4467

68+
// If --check, --auto, or --json is used, go straight to auto-detect
69+
if initCheck || initAuto || initJSON {
70+
return runAutoDetect(absDir)
71+
}
72+
73+
// Try .openboot.yml first
4574
projectCfg, err := config.LoadProjectConfig(absDir)
4675
if err != nil {
76+
// .openboot.yml not found — fall back to auto-detection
77+
if errors.Is(err, config.ErrConfigNotFound) {
78+
return runAutoDetect(absDir)
79+
}
4780
return err
4881
}
4982

@@ -62,6 +95,9 @@ run init scripts, and verify the environment is ready.`,
6295

6396
func init() {
6497
initCmd.Flags().SortFlags = false
98+
initCmd.Flags().BoolVar(&initCheck, "check", false, "check dependencies without installing (exit 1 if missing)")
99+
initCmd.Flags().BoolVar(&initAuto, "auto", false, "auto-install all detected missing dependencies")
100+
initCmd.Flags().BoolVar(&initJSON, "json", false, "output results as JSON (for AI agents and scripts)")
65101
initCmd.Flags().BoolVar(&cfg.DryRun, "dry-run", false, "preview changes without installing")
66102
initCmd.Flags().BoolVarP(&cfg.Silent, "silent", "s", false, "non-interactive mode (for CI/CD)")
67103
initCmd.Flags().BoolVar(&cfg.Update, "update", false, "update Homebrew before installing")

0 commit comments

Comments
 (0)