Skip to content

Commit 9508d05

Browse files
committed
mcp: add log and diff tools
Signed-off-by: Andrea Luzzardi <al@dagger.io>
1 parent 8cb3037 commit 9508d05

File tree

11 files changed

+366
-131
lines changed

11 files changed

+366
-131
lines changed

cmd/cu/checkout.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
)
99

1010
var checkoutCmd = &cobra.Command{
11-
Use: "checkout <env>",
12-
Short: "Switch to an environment's branch locally",
11+
Use: "checkout <env>",
12+
Short: "Switch to an environment's branch locally",
1313
Long: `Bring an environment's work into your local git workspace.
1414
This creates a local branch from the environment's state so you can
1515
explore files in your IDE, make changes, or continue development.`,
@@ -48,4 +48,4 @@ cu checkout fancy-mallard -b my-review-branch`,
4848
func init() {
4949
checkoutCmd.Flags().StringP("branch", "b", "", "Local branch name to use")
5050
rootCmd.AddCommand(checkoutCmd)
51-
}
51+
}

cmd/cu/delete.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
)
99

1010
var deleteCmd = &cobra.Command{
11-
Use: "delete [<env>...]",
12-
Short: "Delete environments and start fresh",
11+
Use: "delete [<env>...]",
12+
Short: "Delete environments and start fresh",
1313
Long: `Delete one or more environments and their associated resources.
1414
This permanently removes the environment's branch and container state.
1515
Use this when starting over with a different approach.
@@ -80,4 +80,4 @@ cu delete --all`,
8080
func init() {
8181
rootCmd.AddCommand(deleteCmd)
8282
deleteCmd.Flags().Bool("all", false, "Delete all environments")
83-
}
83+
}

cmd/cu/diff.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ import (
88
)
99

1010
var diffCmd = &cobra.Command{
11-
Use: "diff <env>",
12-
Short: "Show what files an agent changed",
11+
Use: "diff <env>",
12+
Short: "Show what files an agent changed",
1313
Long: `Display the code changes made by an agent in an environment.
14-
Shows a git diff between the environment's state and your current branch.`,
14+
Shows a git diff of all changes made since the environment was created.
15+
Use -b to compare against a specific branch instead of showing full diff.`,
1516
Args: cobra.ExactArgs(1),
1617
ValidArgsFunction: suggestEnvironments,
17-
Example: `# See what changes the agent made
18+
Example: `# See what changes the agent made (full diff)
1819
cu diff fancy-mallard
1920
21+
# Compare against main branch
22+
cu diff fancy-mallard -b main
23+
2024
# Quick assessment before merging
21-
cu diff backend-api`,
25+
cu diff backend-api -b main`,
2226
RunE: func(app *cobra.Command, args []string) error {
2327
ctx := app.Context()
2428

@@ -28,10 +32,13 @@ cu diff backend-api`,
2832
return err
2933
}
3034

31-
return repo.Diff(ctx, args[0], os.Stdout)
35+
branch, _ := app.Flags().GetString("branch")
36+
37+
return repo.Diff(ctx, args[0], branch, os.Stdout)
3238
},
3339
}
3440

3541
func init() {
42+
diffCmd.Flags().StringP("branch", "b", "", "Compare against specified branch (uses merge-base)")
3643
rootCmd.AddCommand(diffCmd)
3744
}

cmd/cu/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ func init() {
5757
listCmd.Flags().BoolP("quiet", "q", false, "Display only environment IDs")
5858
listCmd.Flags().BoolP("no-trunc", "", false, "Don't truncate output")
5959
rootCmd.AddCommand(listCmd)
60-
}
60+
}

cmd/cu/log.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,25 @@ import (
88
)
99

1010
var logCmd = &cobra.Command{
11-
Use: "log <env>",
12-
Short: "View what an agent did step-by-step",
11+
Use: "log <env>",
12+
Short: "View what an agent did step-by-step",
1313
Long: `Display the complete development history for an environment.
1414
Shows all commits made by the agent plus command execution notes.
15-
Use -p to include code patches in the output.`,
15+
Use -p to include code patches in the output.
16+
Use -b to compare against a specific branch instead of showing full history.`,
1617
Args: cobra.ExactArgs(1),
1718
ValidArgsFunction: suggestEnvironments,
18-
Example: `# See what agent did
19+
Example: `# See what agent did (full history)
1920
cu log fancy-mallard
2021
2122
# Include code changes
22-
cu log fancy-mallard -p`,
23+
cu log fancy-mallard -p
24+
25+
# Compare against main branch
26+
cu log fancy-mallard -b main
27+
28+
# Compare against main with patches
29+
cu log fancy-mallard -b main -p`,
2330
RunE: func(app *cobra.Command, args []string) error {
2431
ctx := app.Context()
2532

@@ -30,12 +37,14 @@ cu log fancy-mallard -p`,
3037
}
3138

3239
patch, _ := app.Flags().GetBool("patch")
40+
branch, _ := app.Flags().GetString("branch")
3341

34-
return repo.Log(ctx, args[0], patch, os.Stdout)
42+
return repo.Log(ctx, args[0], patch, branch, os.Stdout)
3543
},
3644
}
3745

3846
func init() {
3947
logCmd.Flags().BoolP("patch", "p", false, "Generate patch")
48+
logCmd.Flags().StringP("branch", "b", "", "Compare against specified branch (uses merge-base)")
4049
rootCmd.AddCommand(logCmd)
4150
}

cmd/cu/watch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ cu watch`,
3535

3636
func init() {
3737
rootCmd.AddCommand(watchCmd)
38-
}
38+
}

0 commit comments

Comments
 (0)