Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
plan diffs command
Dane Schneider85c39ff2018e
diff --git a/cli/cmd/diffs.go b/cli/cmd/diffs.gonew file mode 100644index 00000000..71e3f813--- /dev/null+++ b/cli/cmd/diffs.go@@ -0,0 +1,51 @@+package cmd++import (+ "bytes"+ "fmt"+ "os/exec"+ "plandex/lib"++ "github.com/spf13/cobra"+)++func init() {+ RootCmd.AddCommand(diffsCmd)+}++var diffsCmd = &cobra.Command{+ Use: "diffs",+ Aliases: []string{"d"},+ Short: "Show differences between plan and project files",+ Run: diffs,+}++func diffs(cmd *cobra.Command, args []string) {+ err := showDiffs()+ if err != nil {+ fmt.Println("An error occurred while generating diffs:", err)+ }+}++// Show differences in 'git diff' style between plan files and project files.+func showDiffs() error {+ // Check git installed+ if !lib.IsCommandAvailable("git") {+ return fmt.Errorf("git is required to generate diffs")+ }++ // Run git diff command+ cmd := exec.Command("git", "diff", lib.PlanFilesDir, lib.ProjectRoot)+ var out bytes.Buffer+ cmd.Stdout = &out+ err := cmd.Run()++ if err != nil {+ return fmt.Errorf("error generating diff: %v", err)+ }++ // Print output+ fmt.Println(out.String())++ return nil+}\ No newline at end of filediff --git a/cli/lib/context_load.go b/cli/lib/context_load.goindex f7d8b4b9..dfcd7c2e 100644--- a/cli/lib/context_load.go+++ b/cli/lib/context_load.go@@ -483,7 +483,7 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {}}}- msg += fmt.Sprintf(" into context | %d πͺ added | %d πͺ total", tokensAdded, totalTokens)+ msg += fmt.Sprintf(" into context | added β %d ./πͺ | total β %d πͺ", tokensAdded, totalTokens)if err != nil {log.Fatalf("Failed to get total tokens: %v", err)diff --git a/cli/lib/term.go b/cli/lib/term.goindex db4ec081..4cb1bd93 100644--- a/cli/lib/term.go+++ b/cli/lib/term.go@@ -18,6 +18,7 @@ var cmdDesc = map[string][2]string{"apply": {"a", "apply the plan to your project files"},"next": {"n", "continue to next step of the plan"},"status": {"s", "show status of the plan"},+ "rewind": {"r", "rewind the plan to a previous step or state"},}func PrintCmds(prefix string, cmds ...string) {