cmd/sketch: remove -initial-commit flag configuration option
Remove the -initial-commit command-line flag to simplify the CLI interface
while preserving all internal agent functionality for tracking the initial
commit baseline through the existing SketchGitBase system.
Problem Analysis:
The -initial-commit flag allowed users to specify a different git commit
reference as the starting point for Sketch operations. This added complexity
to the command-line interface and created an incompatibility with the -unsafe
flag. Analysis showed that most users would use the default HEAD value, making
the flag unnecessary complexity.
Implementation Changes:
1. Command Line Interface:
- Removed -initial-commit flag definition from main.go
- Removed CLI flag struct field and validation logic
- Eliminated incompatibility check with -unsafe flag
- Cleaned up flag parsing to remove unused initialCommit field
2. Container Configuration:
- Removed InitialCommit field from dockerimg.ContainerConfig struct
- Updated git commit resolution to use "HEAD" directly instead of flag value
- Simplified container launch process by removing flag passthrough
3. Preserved Agent Functionality:
- Maintained all SketchGitBase and SketchGitBaseRef methods unchanged
- Preserved initial_commit field in server state and web UI for agent tracking
- Kept all git diff, log, and baseline functionality intact
- Agent continues to establish and track its own initial commit baseline
Technical Details:
- The agent's internal initial commit tracking remains fully functional
- Git operations continue to work with the sketch-base tag system
- Agent initialization still establishes proper git baseline using HEAD
- All existing git diff and log functionality preserved
- Container and unsafe modes both default to current HEAD commit
- Web UI continues to display the agent's tracked initial commit
Testing:
- All Go package tests pass (loop/server, dockerimg)
- Command-line flag parsing works correctly without -initial-commit
- Basic sketch startup functionality verified in both safe and unsafe modes
- Agent git operations and baseline tracking remain intact
Benefits:
- Simplified command-line interface with fewer flags to understand
- Removed artificial incompatibility between -initial-commit and -unsafe
- Reduced cognitive load for new users learning sketch CLI options
- Cleaner container configuration with less conditional logic
- Maintained all essential agent functionality while removing user complexity
This change removes only the user-facing configurability while preserving
all internal git tracking and baseline functionality that the agent relies on.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s962b916b2d3b6582k
diff --git a/cmd/sketch/main.go b/cmd/sketch/main.go
index 472eb8d..726e59a 100644
--- a/cmd/sketch/main.go
+++ b/cmd/sketch/main.go
@@ -117,11 +117,6 @@
// Detect if we're inside the sketch container
inInsideSketch := flagArgs.outsideHostname != ""
- // Validate initial commit and unsafe flag combination
- if flagArgs.unsafe && flagArgs.initialCommit != "HEAD" {
- return fmt.Errorf("cannot use -initial-commit with -unsafe, they are incompatible")
- }
-
// Dispatch to the appropriate execution path
if inInsideSketch {
// We're running inside the Docker container
@@ -157,25 +152,25 @@
}
type CLIFlags struct {
- addr string
- skabandAddr string
- unsafe bool
- openBrowser bool
- httprrFile string
- maxIterations uint64
- maxWallTime time.Duration
- maxDollars float64
- oneShot bool
- prompt string
- modelName string
- llmAPIKey string
- listModels bool
- verbose bool
- version bool
- workingDir string
- sshPort int
- forceRebuild bool
- initialCommit string
+ addr string
+ skabandAddr string
+ unsafe bool
+ openBrowser bool
+ httprrFile string
+ maxIterations uint64
+ maxWallTime time.Duration
+ maxDollars float64
+ oneShot bool
+ prompt string
+ modelName string
+ llmAPIKey string
+ listModels bool
+ verbose bool
+ version bool
+ workingDir string
+ sshPort int
+ forceRebuild bool
+
gitUsername string
gitEmail string
experimentFlag experiment.Flag
@@ -221,7 +216,7 @@
userFlags.BoolVar(&flags.version, "version", false, "print the version and exit")
userFlags.IntVar(&flags.sshPort, "ssh-port", 0, "the host port number that the container's ssh server will listen on, or a randomly chosen port if this value is 0")
userFlags.BoolVar(&flags.forceRebuild, "force-rebuild-container", false, "rebuild Docker container")
- userFlags.StringVar(&flags.initialCommit, "initial-commit", "HEAD", "the git commit reference to use as starting point (incompatible with -unsafe)")
+
userFlags.StringVar(&flags.dockerArgs, "docker-args", "", "additional arguments to pass to the docker create command (e.g., --memory=2g --cpus=2)")
userFlags.Var(&flags.mounts, "mount", "volume to mount in the container in format /path/on/host:/path/in/container (can be repeated)")
userFlags.BoolVar(&flags.termUI, "termui", true, "enable terminal UI")
@@ -363,15 +358,15 @@
OutsideWorkingDir: cwd,
OneShot: flags.oneShot,
Prompt: flags.prompt,
- InitialCommit: flags.initialCommit,
- Verbose: flags.verbose,
- DockerArgs: flags.dockerArgs,
- Mounts: flags.mounts,
- ExperimentFlag: flags.experimentFlag.String(),
- TermUI: flags.termUI,
- MaxDollars: flags.maxDollars,
- MaxIterations: flags.maxIterations,
- MaxWallTime: flags.maxWallTime,
+
+ Verbose: flags.verbose,
+ DockerArgs: flags.dockerArgs,
+ Mounts: flags.mounts,
+ ExperimentFlag: flags.experimentFlag.String(),
+ TermUI: flags.termUI,
+ MaxDollars: flags.maxDollars,
+ MaxIterations: flags.maxIterations,
+ MaxWallTime: flags.maxWallTime,
}
if err := dockerimg.LaunchContainer(ctx, config); err != nil {
diff --git a/dockerimg/dockerimg.go b/dockerimg/dockerimg.go
index ad18246..79d4b28 100644
--- a/dockerimg/dockerimg.go
+++ b/dockerimg/dockerimg.go
@@ -90,9 +90,6 @@
// Initial prompt
Prompt string
- // Initial commit to use as starting point. Resolved into Commit on the host.
- InitialCommit string
-
// Verbose enables verbose output
Verbose bool
@@ -198,8 +195,8 @@
// Get the current host git commit
var commit string
- if out, err := combinedOutput(ctx, "git", "rev-parse", config.InitialCommit); err != nil {
- return fmt.Errorf("git rev-parse %s: %w", config.InitialCommit, err)
+ if out, err := combinedOutput(ctx, "git", "rev-parse", "HEAD"); err != nil {
+ return fmt.Errorf("git rev-parse HEAD: %w", err)
} else {
commit = strings.TrimSpace(string(out))
}