Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

lots of work on prompting for a missing file--mostly there now

Dane Schneider270d30434e72
diff --git a/.gitignore b/.gitignore
index 828381d0..8636fb0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
.plandex/
+.plandex-dev/
plandex
plandex-server
-.aider*
node_modules/
\ No newline at end of file
diff --git a/app/cli/api/methods.go b/app/cli/api/methods.go
index 59b7ffd5..5eabc4bc 100644
--- a/app/cli/api/methods.go
+++ b/app/cli/api/methods.go
@@ -457,6 +457,41 @@ func (a *Api) TellPlan(planId, branch string, req shared.TellPlanRequest, onStre
return nil
}
+func (a *Api) RespondMissingFile(planId, branch string, req shared.RespondMissingFileRequest) *shared.ApiError {
+ serverUrl := fmt.Sprintf("%s/plans/%s/%s/respond_missing_file", getApiHost(), planId, branch)
+
+ reqBytes, err := json.Marshal(req)
+ if err != nil {
+ return &shared.ApiError{Msg: fmt.Sprintf("error marshalling request: %v", err)}
+ }
+
+ request, err := http.NewRequest(http.MethodPost, serverUrl, bytes.NewBuffer(reqBytes))
+ if err != nil {
+ return &shared.ApiError{Msg: fmt.Sprintf("error creating request: %v", err)}
+ }
+ request.Header.Set("Content-Type", "application/json")
+
+ resp, err := authenticatedFastClient.Do(request)
+ if err != nil {
+ return &shared.ApiError{Msg: fmt.Sprintf("error sending request: %v", err)}
+ }
+
+ if resp.StatusCode >= 400 {
+ errorBody, _ := io.ReadAll(resp.Body)
+ apiErr := handleApiError(resp, errorBody)
+
+ didRefresh, apiErr := refreshTokenIfNeeded(apiErr)
+
+ if didRefresh {
+ return a.RespondMissingFile(planId, branch, req)
+ }
+ return apiErr
+ }
+
+ return nil
+
+}
+
func (a *Api) ConnectPlan(planId, branch string, onStream types.OnStreamPlan) *shared.ApiError {
serverUrl := fmt.Sprintf("%s/plans/%s/%s/connect", getApiHost(), planId, branch)
diff --git a/app/cli/auth/org.go b/app/cli/auth/org.go
index ea59c427..d7e102ec 100644
--- a/app/cli/auth/org.go
+++ b/app/cli/auth/org.go
@@ -87,7 +87,7 @@ func promptAutoAddUsersIfValid(email string) (bool, error) {
var autoAddDomainUsers bool
var err error
if !shared.IsEmailServiceDomain(userDomain) {
- fmt.Println("With domain auto-join, you can allow any user with an email ending in @", userDomain, "to auto-join this org")
+ fmt.Println("With domain auto-join, you can allow any user with an email ending in @"+userDomain, "to auto-join this org")
autoAddDomainUsers, err = term.ConfirmYesNo(fmt.Sprintf("Enable auto-join for %s?", userDomain))
if err != nil {
diff --git a/app/cli/cmd/continue.go b/app/cli/cmd/continue.go
index 3ae09b81..4f20154e 100644
--- a/app/cli/cmd/continue.go
+++ b/app/cli/cmd/continue.go
@@ -26,7 +26,7 @@ func init() {
RootCmd.AddCommand(nextCmd)
nextCmd.Flags().BoolVar(&tellBg, "bg", false, "Execute autonomously in the background")
- tellCmd.Flags().BoolVar(&tellStep, "step", false, "Pause after a single step or reply")
+ nextCmd.Flags().BoolVar(&tellStep, "step", false, "Pause after a single step or reply")
}
func doContinue(cmd *cobra.Command, args []string) {
diff --git a/app/cli/cmd/log.go b/app/cli/cmd/log.go
index 4cf2ca20..980d3e50 100644
--- a/app/cli/cmd/log.go
+++ b/app/cli/cmd/log.go
@@ -2,7 +2,6 @@ package cmd
import (
"fmt"
- "log"
"plandex/api"
"plandex/auth"
"plandex/lib"
@@ -69,16 +68,9 @@ func convertTimestampsToLocal(input string) (string, error) {
return match
}
- log.Println("t: ", t)
-
localDt := t.Local()
-
- log.Println("localDt: ", localDt)
-
formattedTs := localDt.Format("Mon Jan 2, 2006 | 3:04:05pm")
- log.Println("formattedTs: ", formattedTs)
-
if localDt.Day() == time.Now().Day() {
formattedTs = localDt.Format("Today | 3:04:05pm")
} else if localDt.Day() == time.Now().AddDate(0, 0, -1).Day() {
diff --git a/app/cli/cmd/rewind.go b/app/cli/cmd/rewind.go
index 9490cd93..13f23c82 100644
--- a/app/cli/cmd/rewind.go
+++ b/app/cli/cmd/rewind.go
@@ -59,8 +59,9 @@ func rewind(cmd *cobra.Command, args []string) {
// log.Println("shas:", logsRes.Shas)
steps, err := strconv.Atoi(stepsOrSha)
+ isSha := false
- if err == nil && steps > 0 {
+ if err == nil && steps > 0 && steps < 999 {
// log.Println("steps:", steps)
// Rewind by the specified number of steps
targetSha = logsRes.Shas[steps]
@@ -68,9 +69,11 @@ func rewind(cmd *cobra.Command, args []string) {
// log.Println("sha provided:", sha)
// Rewind to the specified Sha
targetSha = sha
+ isSha = true
} else if stepsOrSha == "" {
// log.Println("No steps or sha provided, rewinding by 1 step")
// Rewind by 1 step
+ steps = 1
targetSha = logsRes.Shas[1]
} else {
fmt.Fprintln(os.Stderr, "Invalid steps or sha. Steps must be a positive integer, and sha must be a valid commit hash.")
@@ -88,7 +91,7 @@ func rewind(cmd *cobra.Command, args []string) {
}
var msg string
- if steps == 0 {
+ if isSha {
msg = "✅ Rewound to " + targetSha
} else {
postfix := "s"
diff --git a/app/cli/fs/fs.go b/app/cli/fs/fs.go
index b2788cb3..c47af8b7 100644
--- a/app/cli/fs/fs.go
+++ b/app/cli/fs/fs.go
@@ -6,6 +6,7 @@ import (
"os/exec"
"path/filepath"
"strings"
+ "sync"
ignore "github.com/sabhiram/go-gitignore"
)
@@ -120,53 +121,110 @@ func GetProjectPaths() (map[string]bool, *ignore.GitIgnore, error) {
}
func GetPaths(dir string) (map[string]bool, *ignore.GitIgnore, error) {
+ ignored, err := GetPlandexIgnore()
+
+ if err != nil {
+ return nil, nil, err
+ }
+
paths := map[string]bool{}
+ dirs := map[string]bool{}
+
+ isGitRepo := ProjectRootIsGitRepo()
- if ProjectRootIsGitRepo() {
+ errCh := make(chan error)
+ var mu sync.Mutex
+ numRoutines := 0
+
+ if isGitRepo {
// combine `git ls-files` and `git ls-files --others --exclude-standard`
// to get all files in the repo
- // get all tracked files in the repo
- cmd := exec.Command("git", "ls-files")
- cmd.Dir = dir
- out, err := cmd.Output()
+ numRoutines++
+ go func() {
+ // get all tracked files in the repo
+ cmd := exec.Command("git", "ls-files")
+ cmd.Dir = dir
+ out, err := cmd.Output()
- if err != nil {
- return nil, nil, fmt.Errorf("error getting files in git repo: %s", err)
- }
+ if err != nil {
+ errCh <- fmt.Errorf("error getting files in git repo: %s", err)
+ return
+ }
- files := strings.Split(string(out), "\n")
+ files := strings.Split(string(out), "\n")
- for _, file := range files {
- paths[file] = true
- }
+ mu.Lock()
+ defer mu.Unlock()
+ for _, file := range files {
+ if ignored != nil && ignored.MatchesPath(file) {
+ continue
+ }
- // get all untracked files non-ignored files in the repo
- cmd = exec.Command("git", "ls-files", "--others", "--exclude-standard")
- cmd.Dir = dir
- out, err = cmd.Output()
+ paths[file] = true
+ }
- if err != nil {
- return nil, nil, fmt.Errorf("error getting untracked files in git repo: %s", err)
- }
+ errCh <- nil
+ }()
- files = strings.Split(string(out), "\n")
+ // get all untracked non-ignored files in the repo
+ numRoutines++
+ go func() {
+ cmd := exec.Command("git", "ls-files", "--others", "--exclude-standard")
+ cmd.Dir = dir
+ out, err := cmd.Output()
- for _, file := range files {
- paths[file] = true
- }
- } else {
- // get all files in the directory
- err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ errCh <- fmt.Errorf("error getting untracked files in git repo: %s", err)
+ return
+ }
+
+ files := strings.Split(string(out), "\n")
+
+ mu.Lock()
+ defer mu.Unlock()
+ for _, file := range files {
+ if ignored != nil && ignored.MatchesPath(file) {
+ continue
+ }
+
+ paths[file] = true
+ }
+
+ errCh <- nil
+ }()
+ }
+
+ // get all paths in the directory
+ numRoutines++
+ go func() {
+ err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
- if !info.IsDir() {
+ if info.IsDir() {
+ relPath, err := filepath.Rel(dir, path)
+ if err != nil {
+ return err
+ }
+
+ if ignored != nil && ignored.MatchesPath(relPath) {
+ return filepath.SkipDir
+ }
+
+ dirs[relPath] = true
+ } else if !isGitRepo {
relPath, err := filepath.Rel(dir, path)
if err != nil {
return err
}
+
+ if ignored != nil && ignored.MatchesPath(relPath) {
+ return nil
+ }
+
+ // lock isn't need here because isGitRepo is false, which makes this the only routine
paths[relPath] = true
}
@@ -174,22 +232,22 @@ func GetPaths(dir string) (map[string]bool, *ignore.GitIgnore, error) {
})
if err != nil {
- return nil, nil, fmt.Errorf("error getting files in directory: %s", err)
+ errCh <- fmt.Errorf("error walking directory: %s", err)
+ return
}
- }
- ignored, err := GetPlandexIgnore()
+ errCh <- nil
+ }()
- if err != nil {
- return nil, nil, err
+ for i := 0; i < numRoutines; i++ {
+ err := <-errCh
+ if err != nil {
+ return nil, nil, err
+ }
}
- if ignored != nil {
- for path := range paths {
- if ignored.MatchesPath(path) {
- delete(paths, path)
- }
- }
+ for dir := range dirs {
+ paths[dir] = true
}
return paths, ignored, nil
diff --git a/app/cli/go.mod b/app/cli/go.mod
index 0c7cdd13..10195057 100644
--- a/app/cli/go.mod
+++ b/app/cli/go.mod
@@ -5,6 +5,7 @@ go 1.21.3
require (
github.com/atotto/clipboard v0.1.4
github.com/charmbracelet/lipgloss v0.9.1
+ github.com/davecgh/go-spew v1.1.1
github.com/fatih/color v1.16.0
github.com/muesli/reflow v0.3.0
github.com/olekukonko/tablewriter v0.0.5
diff --git a/app/cli/go.sum b/app/cli/go.sum
index 5f9b9e70..af2a89c9 100644
--- a/app/cli/go.sum
+++ b/app/cli/go.sum
@@ -231,15 +231,11 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/charmbracelet/bubbles v0.7.5/go.mod h1:IRTORFvhEI6OUH7WhN2Ks8Z8miNGimk1BE6cmHijOkM=
github.com/charmbracelet/bubbles v0.15.0/go.mod h1:Y7gSFbBzlMpUDR/XM9MhZI374Q+1p1kluf1uLl8iK74=
-github.com/charmbracelet/bubbles v0.16.1 h1:6uzpAAaT9ZqKssntbvZMlksWHruQLNxg49H5WdeuYSY=
-github.com/charmbracelet/bubbles v0.16.1/go.mod h1:2QCp9LFlEsBQMvIYERr7Ww2H2bA7xen1idUDIzm/+Xc=
github.com/charmbracelet/bubbles v0.17.2-0.20240108170749-ec883029c8e6 h1:6nVCV8pqGaeyxetur3gpX3AAaiyKgzjIoCPV3NXKZBE=
github.com/charmbracelet/bubbles v0.17.2-0.20240108170749-ec883029c8e6/go.mod h1:9HxZWlkCqz2PRwsCbYl7a3KXvGzFaDHpYbSYMJ+nE3o=
github.com/charmbracelet/bubbletea v0.12.2/go.mod h1:3gZkYELUOiEUOp0bTInkxguucy/xRbGSOcbMs1geLxg=
github.com/charmbracelet/bubbletea v0.23.1/go.mod h1:JAfGK/3/pPKHTnAS8JIE2u9f61BjWTQY57RbT25aMXU=
github.com/charmbracelet/bubbletea v0.23.2/go.mod h1:FaP3WUivcTM0xOKNmhciz60M6I+weYLF76mr1JyI7sM=
-github.com/charmbracelet/bubbletea v0.24.2 h1:uaQIKx9Ai6Gdh5zpTbGiWpytMU+CfsPp06RaW2cx/SY=
-github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FDaJmO3l2nejekbsgg=
github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM=
github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
github.com/charmbracelet/charm v0.8.7/go.mod h1:ApJYwJljEjODkOYJgFDzbUqztLrCWQct9zyPD+xcVr4=
diff --git a/app/cli/lib/context_load.go b/app/cli/lib/context_load.go
index f5c9b426..8cb74cbf 100644
--- a/app/cli/lib/context_load.go
+++ b/app/cli/lib/context_load.go
@@ -12,6 +12,7 @@ import (
"plandex/url"
"strings"
+ "github.com/fatih/color"
"github.com/plandex/plandex/shared"
ignore "github.com/sabhiram/go-gitignore"
)
@@ -84,7 +85,7 @@ func MustLoadContext(resources []string, params *types.LoadContextParams) {
var filteredPaths []string
for _, inputFilePath := range inputFilePaths {
if _, ok := projectPaths[inputFilePath]; !ok {
- if plandexIgnored.MatchesPath(inputFilePath) {
+ if plandexIgnored != nil && plandexIgnored.MatchesPath(inputFilePath) {
ignoredPaths[inputFilePath] = "plandex"
} else {
ignoredPaths[inputFilePath] = "git"
@@ -239,8 +240,7 @@ func MustLoadContext(resources []string, params *types.LoadContextParams) {
fmt.Println("✅ " + res.Msg)
if len(ignoredPaths) > 0 {
+ fmt.Println("ℹ️ " + color.New(color.FgWhite).Sprint("Due to .gitignore or .plandexignore, some paths weren't loaded.\nUse --force / -f to load ignored paths."))
fmt.Println()
- fmt.Println("ℹ️ Due to .gitignore or .plandexignore, some paths weren't loaded. Use --force / -f to load ignored paths.")
-
}
}
diff --git a/app/cli/main.go b/app/cli/main.go
index 9ef80e47..bbf5fcdc 100644
--- a/app/cli/main.go
+++ b/app/cli/main.go
@@ -16,6 +16,7 @@ func init() {
// set up a file logger
// TODO: log rotation
+
file, err := os.OpenFile(filepath.Join(fs.HomePlandexDir, "plandex.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
fmt.Fprintf(os.Stderr, "Error opening log file: %v\n", err)
diff --git a/app/cli/lib/stream.go b/app/cli/stream/stream.go
similarity index 73%
rename from app/cli/lib/stream.go
rename to app/cli/stream/stream.go
index a5433f5b..6461659c 100644
--- a/app/cli/lib/stream.go
+++ b/app/cli/stream/stream.go
@@ -1,4 +1,4 @@
-package lib
+package stream
import (
"log"
@@ -12,5 +12,8 @@ var OnStreamPlan types.OnStreamPlan = func(params types.OnStreamPlanParams) {
return
}
+ // log.Println("Stream message:")
+ // log.Println(spew.Sdump(*params.Msg))
+
streamtui.Send(*params.Msg)
}
diff --git a/app/cli/stream_tui/model.go b/app/cli/stream_tui/model.go
index 7f10059a..e89d303d 100644
--- a/app/cli/stream_tui/model.go
+++ b/app/cli/stream_tui/model.go
@@ -5,10 +5,28 @@ import (
"github.com/charmbracelet/bubbles/spinner"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
- "github.com/charmbracelet/huh"
"github.com/charmbracelet/lipgloss"
+ "github.com/plandex/plandex/shared"
)
+const (
+ MissingFileLoadLabel = "Load the file into context"
+ MissingFileSkipLabel = "Skip generating this file"
+ MissingFileOverwriteLabel = "Allow Plandex to overwrite this file"
+)
+
+var promptChoices = []shared.RespondMissingFileChoice{
+ shared.RespondMissingFileChoiceLoad,
+ shared.RespondMissingFileChoiceSkip,
+ shared.RespondMissingFileChoiceOverwrite,
+}
+
+var missingFileSelectOpts = []string{
+ MissingFileLoadLabel,
+ MissingFileSkipLabel,
+ MissingFileOverwriteLabel,
+}
+
type streamUIModel struct {
keymap keymap
@@ -31,7 +49,15 @@ type streamUIModel struct {
atScrollBottom bool
- missingFilePrompt *huh.Select[string]
+ promptingMissingFile bool
+ missingFilePath string
+ missingFileSelectedIdx int
+ promptedMissingFile bool
+ missingFileContent string
+ missingFileTokens int
+
+ err error
+ apiErr *shared.ApiError
}
type keymap = struct {
@@ -40,6 +66,9 @@ type keymap = struct {
scrollDown,
pageUp,
pageDown,
+ up,
+ down,
+ enter,
quit bubbleKey.Binding
}
@@ -84,14 +113,28 @@ func initialModel() *streamUIModel {
quit: bubbleKey.NewBinding(
bubbleKey.WithKeys("ctrl+c"),
),
+
+ up: bubbleKey.NewBinding(
+ bubbleKey.WithKeys("up"),
+ bubbleKey.WithHelp("up", "prev"),
+ ),
+
+ down: bubbleKey.NewBinding(
+ bubbleKey.WithKeys("down"),
+ bubbleKey.WithHelp("down", "next"),
+ ),
+
+ enter: bubbleKey.NewBinding(
+ bubbleKey.WithKeys("enter"),
+ bubbleKey.WithHelp("enter", "select"),
+ ),
},
- tokensByPath: make(map[string]int),
- finishedByPath: make(map[string]bool),
- spinner: s,
- atScrollBottom: true,
- starting: true,
- missingFilePrompt: nil,
+ tokensByPath: make(map[string]int),
+ finishedByPath: make(map[string]bool),
+ spinner: s,
+ atScrollBottom: true,
+ starting: true,
}
return &initialState
diff --git a/app/cli/stream_tui/run.go b/app/cli/stream_tui/run.go
index e80d7942..52f02d53 100644
--- a/app/cli/stream_tui/run.go
+++ b/app/cli/stream_tui/run.go
@@ -20,13 +20,17 @@ func StartStreamUI() error {
mu.Unlock()
wg.Add(1)
- _, err := ui.Run()
+ m, err := ui.Run()
wg.Done()
if err != nil {
return fmt.Errorf("error running changes UI: %v", err)
}
+ if m.(streamUIModel).err != nil {
+ return fmt.Errorf("error in changes UI: %v", m.(streamUIModel).err)
+ }
+
return nil
}
@@ -40,6 +44,7 @@ func Quit() {
ui.Quit()
wg.Wait() // Wait for the UI to fully terminate
+
}
func Send(msg tea.Msg) {
diff --git a/app/cli/stream_tui/update.go b/app/cli/stream_tui/update.go
index f463e6b3..f44389cc 100644
--- a/app/cli/stream_tui/update.go
+++ b/app/cli/stream_tui/update.go
@@ -1,7 +1,13 @@
package streamtui
import (
+ "fmt"
+ "log"
+ "os"
+ "plandex/api"
+ "plandex/lib"
"plandex/term"
+ "strings"
"time"
bubbleKey "github.com/charmbracelet/bubbles/key"
@@ -12,7 +18,7 @@ import (
"github.com/plandex/plandex/shared"
)
-func (m *streamUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+func (m streamUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// log.Println("Update received message:", spew.Sdump(msg))
switch msg := msg.(type) {
@@ -34,24 +40,35 @@ func (m *streamUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.finishedByPath[msg.path] = false
case tea.MouseMsg:
- if msg.Type == tea.MouseWheelUp {
- m.replyViewport.LineUp(3)
- } else if msg.Type == tea.MouseWheelDown {
- m.replyViewport.LineDown(3)
+ if !m.promptingMissingFile {
+ if msg.Type == tea.MouseWheelUp {
+ m.replyViewport.LineUp(3)
+ } else if msg.Type == tea.MouseWheelDown {
+ m.replyViewport.LineDown(3)
+ }
}
case tea.KeyMsg:
switch {
case bubbleKey.Matches(msg, m.keymap.quit):
return m, tea.Quit
- case bubbleKey.Matches(msg, m.keymap.scrollDown):
+ case bubbleKey.Matches(msg, m.keymap.scrollDown) && !m.promptingMissingFile:
m.scrollDown()
- case bubbleKey.Matches(msg, m.keymap.scrollUp):
+ case bubbleKey.Matches(msg, m.keymap.scrollUp) && !m.promptingMissingFile:
m.scrollUp()
- case bubbleKey.Matches(msg, m.keymap.pageDown):
+ case bubbleKey.Matches(msg, m.keymap.pageDown) && !m.promptingMissingFile:
m.pageDown()
- case bubbleKey.Matches(msg, m.keymap.pageUp):
+ case bubbleKey.Matches(msg, m.keymap.pageUp) && !m.promptingMissingFile:
m.pageUp()
+ case bubbleKey.Matches(msg, m.keymap.up):
+ m.up()
+ case bubbleKey.Matches(msg, m.keymap.down):
+ m.down()
+ case m.promptingMissingFile && bubbleKey.Matches(msg, m.keymap.enter):
+ m.selectedMissingFileOpt()
+
+ default:
+ m.resolveEscapeSequence(msg.String())
}
}
@@ -141,7 +158,31 @@ func (m *streamUIModel) pageUp() {
}
func (m *streamUIModel) streamUpdate(msg *shared.StreamMessage) (tea.Model, tea.Cmd) {
+ // log.Println("streamUI received message:", msg.Type)
switch msg.Type {
+
+ case shared.StreamMessagePromptMissingFile:
+ m.promptingMissingFile = true
+ m.missingFilePath = msg.MissingFilePath
+
+ bytes, err := os.ReadFile(m.missingFilePath)
+ if err != nil {
+ log.Println("failed to read file:", err)
+ m.err = fmt.Errorf("failed to read file: %w", err)
+ return m, nil
+ }
+ m.missingFileContent = string(bytes)
+
+ numTokens, err := shared.GetNumTokens(m.missingFileContent)
+
+ if err != nil {
+ log.Println("failed to get num tokens:", err)
+ m.err = fmt.Errorf("failed to get num tokens: %w", err)
+ return m, nil
+ }
+
+ m.missingFileTokens = numTokens
+
case shared.StreamMessageReply:
if m.starting {
m.starting = false
@@ -149,9 +190,15 @@ func (m *streamUIModel) streamUpdate(msg *shared.StreamMessage) (tea.Model, tea.
if m.processing {
m.processing = false
- m.reply += "\n\n👉 "
+ if m.promptedMissingFile {
+ m.promptedMissingFile = false
+ } else {
+ m.reply += "\n\n👉 "
+ }
}
+ // log.Println("reply chunk:", msg.ReplyChunk)
+
m.reply += msg.ReplyChunk
m.updateReplyDisplay()
@@ -200,3 +247,86 @@ func startDelay(path string, delay time.Duration) tea.Cmd {
return delayFileRestartMsg{path: path}
}
}
+
+var escReceivedAt time.Time
+var escSeq string
+
+func (m *streamUIModel) resolveEscapeSequence(val string) {
+ if val == "esc" || val == "alt+[" {
+ escReceivedAt = time.Now()
+ go func() {
+ time.Sleep(51 * time.Millisecond)
+ escReceivedAt = time.Time{}
+ escSeq = ""
+ }()
+ }
+
+ if !escReceivedAt.IsZero() {
+ elapsed := time.Since(escReceivedAt)
+
+ if elapsed < 50*time.Millisecond {
+ escSeq += val
+
+ if escSeq == "esc[A" || escSeq == "alt+[A" {
+ // log.Println("up")
+ m.up()
+
+ escReceivedAt = time.Time{}
+ escSeq = ""
+ } else if escSeq == "esc[B" || escSeq == "alt+[B" {
+ // log.Println("down")
+ m.down()
+
+ escReceivedAt = time.Time{}
+ escSeq = ""
+ }
+ }
+ }
+}
+
+func (m *streamUIModel) up() {
+ if m.promptingMissingFile {
+ m.missingFileSelectedIdx = max(m.missingFileSelectedIdx-1, 0)
+ }
+}
+
+func (m *streamUIModel) down() {
+ if m.promptingMissingFile {
+ m.missingFileSelectedIdx = min(m.missingFileSelectedIdx+1, len(missingFileSelectOpts)-1)
+ }
+
+}
+
+func (m *streamUIModel) selectedMissingFileOpt() {
+ choice := promptChoices[m.missingFileSelectedIdx]
+
+ if choice == "" {
+ return
+ }
+
+ apiErr := api.Client.RespondMissingFile(lib.CurrentPlanId, lib.CurrentBranch, shared.RespondMissingFileRequest{
+ Choice: choice,
+ FilePath: m.missingFilePath,
+ Body: m.missingFileContent,
+ })
+
+ if apiErr != nil {
+ log.Println("missing file prompt api error:", apiErr)
+ m.apiErr = apiErr
+ return
+ }
+
+ if choice == shared.RespondMissingFileChoiceSkip {
+ replyLines := strings.Split(m.reply, "\n")
+ m.reply = strings.Join(replyLines[:len(replyLines)-3], "\n")
+ m.updateReplyDisplay()
+ }
+
+ m.promptingMissingFile = false
+ m.missingFilePath = ""
+ m.missingFileSelectedIdx = 0
+ m.missingFileContent = ""
+ m.missingFileTokens = 0
+ m.promptedMissingFile = true
+ m.processing = true
+}
diff --git a/app/cli/stream_tui/view.go b/app/cli/stream_tui/view.go
index a0062a6e..eb8f1f28 100644
--- a/app/cli/stream_tui/view.go
+++ b/app/cli/stream_tui/view.go
@@ -13,6 +13,10 @@ var borderColor = lipgloss.Color("#444")
var helpTextColor = lipgloss.Color("#ddd")
func (m streamUIModel) View() string {
+ if m.promptingMissingFile {
+ return m.renderMissingFilePrompt()
+ }
+
return lipgloss.JoinVertical(lipgloss.Left,
m.renderMainView(),
m.renderProcessing(),
@@ -99,3 +103,38 @@ func (m streamUIModel) renderBuild() string {
return style.Render(strings.Join(resRows, "\n"))
}
+
+func (m streamUIModel) renderMissingFilePrompt() string {
+ style := lipgloss.NewStyle().Padding(1).BorderStyle(lipgloss.NormalBorder()).BorderForeground(lipgloss.Color(borderColor)).Width(m.width - 2).Height(m.height - 2)
+
+ prompt := "📄 " + color.New(color.Bold, color.FgHiYellow).Sprint(m.missingFilePath) + " isn't in context."
+
+ prompt += "\n\n"
+
+ desc := "This file exists in your project, but isn't loaded into context. Unless you load it into context or skip generating it, Plandex will fully overwrite the existing file rather than applying updates."
+
+ words := strings.Split(desc, " ")
+ for i, word := range words {
+ words[i] = color.New(color.FgWhite).Sprint(word)
+ }
+
+ prompt += strings.Join(words, " ")
+
+ prompt += "\n\n" + color.New(color.FgHiMagenta, color.Bold).Sprintln("🧐 What do you want to do?")
+
+ for i, opt := range missingFileSelectOpts {
+ if i == m.missingFileSelectedIdx {
+ prompt += color.New(color.FgHiCyan, color.Bold).Sprint(" > " + opt)
+ } else {
+ prompt += " " + opt
+ }
+
+ if opt == MissingFileLoadLabel {
+ prompt += fmt.Sprintf(" | %d 🪙", m.missingFileTokens)
+ }
+
+ prompt += "\n"
+ }
+
+ return style.Render(prompt)
+}
diff --git a/app/cli/tell/tell.go b/app/cli/tell/tell.go
index 9be53a29..6c0b7acb 100644
--- a/app/cli/tell/tell.go
+++ b/app/cli/tell/tell.go
@@ -7,6 +7,7 @@ import (
"plandex/auth"
"plandex/fs"
"plandex/lib"
+ "plandex/stream"
streamtui "plandex/stream_tui"
"plandex/term"
@@ -45,7 +46,7 @@ func TellPlan(prompt string, tellBg, tellStep bool) {
AutoContinue: !tellStep,
ProjectPaths: projectPaths,
ApiKey: os.Getenv("OPENAI_API_KEY"),
- }, lib.OnStreamPlan)
+ }, stream.OnStreamPlan)
if apiErr != nil {
if apiErr.Type == shared.ApiErrorTypeTrialMessagesExceeded {
promptingTrialExceeded = true
diff --git a/app/cli/types/api.go b/app/cli/types/api.go
index ee77e06b..c267561d 100644
--- a/app/cli/types/api.go
+++ b/app/cli/types/api.go
@@ -50,6 +50,8 @@ type ApiClient interface {
CreatePlan(projectId string, req shared.CreatePlanRequest) (*shared.CreatePlanResponse, *shared.ApiError)
TellPlan(planId, branch string, req shared.TellPlanRequest, onStreamPlan OnStreamPlan) *shared.ApiError
+ RespondMissingFile(planId, branch string, req shared.RespondMissingFileRequest) *shared.ApiError
+
DeletePlan(planId string) *shared.ApiError
DeleteAllPlans(projectId string) *shared.ApiError
ConnectPlan(planId, branch string, onStreamPlan OnStreamPlan) *shared.ApiError
diff --git a/app/server/handlers/plans_exec.go b/app/server/handlers/plans_exec.go
index ff9c7ff5..02b2a53d 100644
--- a/app/server/handlers/plans_exec.go
+++ b/app/server/handlers/plans_exec.go
@@ -227,7 +227,10 @@ func RespondMissingFileHandler(w http.ResponseWriter, r *http.Request) {
return
}
+ log.Println("missing file choice:", requestBody.Choice)
+
if requestBody.Choice == shared.RespondMissingFileChoiceLoad {
+ log.Println("loading missing file")
res, dbContexts := loadContexts(w, r, auth, &shared.LoadContextRequest{
&shared.LoadContextParams{
ContextType: shared.ContextFileType,
@@ -248,6 +251,7 @@ func RespondMissingFileHandler(w http.ResponseWriter, r *http.Request) {
}
// This will resume model stream
+ log.Println("Resuming model stream")
active.MissingFileResponseCh <- requestBody.Choice
log.Println("Successfully processed request for RespondMissingFileHandler")
diff --git a/app/server/model/client.go b/app/server/model/client.go
index 9199ce78..fbc3526e 100644
--- a/app/server/model/client.go
+++ b/app/server/model/client.go
@@ -9,5 +9,6 @@ import (
const OPENAI_STREAM_CHUNK_TIMEOUT = time.Duration(30) * time.Second
func NewClient(apiKey string) *openai.Client {
- return openai.NewClient(apiKey)
+ config := openai.DefaultConfig(apiKey)
+ return openai.NewClientWithConfig(config)
}
diff --git a/app/server/model/plan/tell.go b/app/server/model/plan/tell.go
index c9c9b87f..42de5a68 100644
--- a/app/server/model/plan/tell.go
+++ b/app/server/model/plan/tell.go
@@ -24,7 +24,7 @@ import (
func Tell(client *openai.Client, plan *db.Plan, branch string, auth *types.ServerAuth, req *shared.TellPlanRequest) error {
log.Printf("Tell: Called with plan ID %s on branch %s\n", plan.Id, branch) // Log the function call with plan ID and branch
- log.Println("Tell: Starting Tell operation") // Log start of Tell operation
+ log.Println("Tell: Starting Tell operation") // Log start of Tell operation
// goEnv := os.Getenv("GOENV") // Fetch the GOENV environment variable
// log.Println("GOENV: " + goEnv)
@@ -79,7 +79,7 @@ func Tell(client *openai.Client, plan *db.Plan, branch string, auth *types.Serve
func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *types.ServerAuth, req *shared.TellPlanRequest, active *types.ActivePlan, iteration int, missingFileResponse shared.RespondMissingFileChoice) {
log.Printf("execTellPlan: Called for plan ID %s on branch %s, iteration %d\n", plan.Id, branch, iteration) // Log the function call with plan ID, branch, and iteration
- log.Printf("execTellPlan: Starting execTellPlan operation, iteration: %d\n", iteration) // Log start of execTellPlan operation
+ log.Printf("execTellPlan: Starting execTellPlan operation, iteration: %d\n", iteration) // Log start of execTellPlan operation
currentUserId := auth.User.Id
currentOrgId := auth.OrgId
@@ -305,6 +305,23 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
})
}
+ // if any skipped paths have since been added to context, remove them from skipped paths
+ if len(active.SkippedPaths) > 0 {
+ var toUnskipPaths []string
+ for contextPath := range active.ContextsByPath {
+ if active.SkippedPaths[contextPath] {
+ toUnskipPaths = append(toUnskipPaths, contextPath)
+ }
+ }
+ if len(toUnskipPaths) > 0 {
+ UpdateActivePlan(planId, branch, func(ap *types.ActivePlan) {
+ for _, path := range toUnskipPaths {
+ delete(ap.SkippedPaths, path)
+ }
+ })
+ }
+ }
+
modelContextText, modelContextTokens, err := lib.FormatModelContext(modelContext)
if err != nil {
err = fmt.Errorf("error formatting model modelContext: %v", err)
@@ -324,6 +341,13 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
Content: systemMessageText,
}
+ if len(active.SkippedPaths) > 0 {
+ systemMessageText += "\n\nSome files have been skipped by the user and *must not* be generated. The user will handle any updates to these files themselves. Skip any parts of the plan that require generating these files. You *must not* generate a file block for any of these files.\nSkipped files:\n"
+ for skippedPath := range active.SkippedPaths {
+ systemMessageText += fmt.Sprintf("- %s\n", skippedPath)
+ }
+ }
+
messages := []openai.ChatCompletionMessage{
systemMessage,
}
@@ -529,22 +553,19 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
replyParser = types.NewReplyParser()
replyParser.AddChunk(replyContent, true)
- userAction := fmt.Sprintf("\n\n**User action.** You chose not to update the file `%s`, so I'll skip this update.\n\n", currentFile)
-
- replyParser.AddChunk(userAction, false)
- replyContent += userAction
-
UpdateActivePlan(planId, branch, func(ap *types.ActivePlan) {
ap.CurrentReplyContent = replyContent
ap.NumTokens = numTokens
+ ap.SkippedPaths[currentFile] = true
})
- } else if missingFileResponse == shared.RespondMissingFileChoiceOverwrite {
- UpdateActivePlan(planId, branch, func(ap *types.ActivePlan) {
- ap.AllowOverwritePaths[currentFile] = true
- })
+ } else {
+ if missingFileResponse == shared.RespondMissingFileChoiceOverwrite {
+ UpdateActivePlan(planId, branch, func(ap *types.ActivePlan) {
+ ap.AllowOverwritePaths[currentFile] = true
+ })
+ }
}
-
}
messages = append(messages, openai.ChatCompletionMessage{
@@ -552,6 +573,23 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
Content: active.CurrentReplyContent,
})
+ if missingFileResponse != "" {
+ if missingFileResponse == shared.RespondMissingFileChoiceSkip {
+ res := replyParser.Read()
+
+ messages = append(messages, openai.ChatCompletionMessage{
+ Role: openai.ChatMessageRoleUser,
+ Content: fmt.Sprintf(`You *must not* generate content for the file %s. Skip this file and continue with the plan according to the 'Your instructions' section if there are any remaining tasks or subtasks. Don't repeat any part of the previous message. If there are no remaining tasks or subtasks, say "All tasks have been completed." per your instructions`, res.CurrentFilePath),
+ })
+
+ } else {
+ messages = append(messages, openai.ChatCompletionMessage{
+ Role: openai.ChatMessageRoleUser,
+ Content: "Continue generating exactly where you left off in the previous message. Don't produce any other output before continuing or repeat any part of the previous message. Do *not* duplicate the last line of the previous response before continuing. Do *not* include triple backticks and a language name like '```python' or '```yaml' at the start of the response, since these have already been included in the previous message. Continue from where you left off seamlessly to generate the rest of the file block. You must include closing triple backticks at the end of the file block. When the file block is finished, continue with the plan according to the 'Your instructions' sections if there are any remaining tasks or subtasks. If there are no remaining tasks or subtasks, say 'All tasks have been completed.' per your instructions.",
+ })
+ }
+ }
+
replyNumTokens = active.NumTokens
replyFiles = active.Files
@@ -707,6 +745,8 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
choice := response.Choices[0]
if choice.FinishReason != "" {
+ log.Println("Model stream finished")
+
active.Stream(shared.StreamMessage{
Type: shared.StreamMessageDescribing,
})
@@ -837,6 +877,9 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
active.RepliesFinished = true
})
}
+
+ // Wait briefly allow last stream message to be sent
+ time.Sleep(100 * time.Millisecond)
}
return
@@ -849,7 +892,7 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
active.NumTokens++
})
- // log.Printf("%s", content)
+ // log.Printf("Sending stream msg: %s", content)
active.Stream(shared.StreamMessage{
Type: shared.StreamMessageReply,
ReplyChunk: content,
@@ -865,7 +908,9 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
if currentFile != "" &&
active.ContextsByPath[currentFile] == nil &&
- req.ProjectPaths[currentFile] {
+ req.ProjectPaths[currentFile] && !active.AllowOverwritePaths[currentFile] {
+ log.Printf("Attempting to overwrite a file that isn't in context: %s\n", currentFile)
+
// attempting to overwrite a file that isn't in context
// we will stop the stream and ask the user what to do
err := db.SetPlanStatus(planId, branch, shared.PlanStatusPrompting, "")
@@ -880,17 +925,31 @@ func execTellPlan(client *openai.Client, plan *db.Plan, branch string, auth *typ
return
}
+ log.Printf("Prompting user for missing file: %s\n", currentFile)
+
active.Stream(shared.StreamMessage{
Type: shared.StreamMessagePromptMissingFile,
MissingFilePath: currentFile,
})
+ log.Printf("Stopping stream for missing file: %s\n", currentFile)
+
+ log.Printf("Current reply content: %s\n", active.CurrentReplyContent)
+
// stop stream for now
active.CancelModelStreamFn()
+ log.Printf("Stopped stream for missing file: %s\n", currentFile)
+
// wait for user response to come in
userChoice := <-active.MissingFileResponseCh
+ log.Printf("User choice for missing file: %s\n", userChoice)
+
+ active.ResetModelCtx()
+
+ log.Println("Continuing stream")
+
// continue plan
execTellPlan(
client,
@@ -939,7 +998,7 @@ type summarizeConvoParams struct {
func summarizeConvo(client *openai.Client, params summarizeConvoParams) error {
log.Printf("summarizeConvo: Called for plan ID %s on branch %s\n", params.planId, params.branch) // Log the function call with plan ID and branch
- log.Printf("summarizeConvo: Starting summarizeConvo for planId: %s\n", params.planId) // Log start of summarizeConvo
+ log.Printf("summarizeConvo: Starting summarizeConvo for planId: %s\n", params.planId) // Log start of summarizeConvo
planId := params.planId
branch := params.branch
convo := params.convo
@@ -1014,7 +1073,7 @@ func summarizeConvo(client *openai.Client, params summarizeConvoParams) error {
})
if err != nil {
- log.Printf("summarizeConvo: Error generating summary for plan ID %s: %v\n", params.planId, err) // Log error generating summary
+ log.Printf("summarizeConvo: Error generating summary for plan ID %s: %v\n", params.planId, err) // Log error generating summary
log.Printf("summarizeConvo: Error generating plan summary for plan %s: %v\n", params.planId, err) // Log error generating plan summary
return err
}
diff --git a/app/server/model/prompts/create.go b/app/server/model/prompts/create.go
index 021b08c2..7bd47b39 100644
--- a/app/server/model/prompts/create.go
+++ b/app/server/model/prompts/create.go
@@ -58,19 +58,19 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context
At the end of your response, you can suggest additional iterations to make the plan better. You can also ask the user to load more files into context or give you more information if it would help you make a better plan.
At the *very* end of your response, in a final, separate paragraph, you *must* decide whether the plan is completed and if not, whether it should be automatically continued.
- - If all the steps in a plan are completed (even if there is only one step), you must explictly say "All tasks have been completed."
+
+ - If all the subtasks in a plan are completed (including if there is a single task and no subtasks), you must explictly say "All tasks have been completed."
Otherwise:
- - If there is a clear next step that definitely needs to be done to finish the plan (and has not already been completed), output a sentence starting with "Next, " and then give a brief description of the next step.
- - If there is no clear next step, or the user needs to take some action before you can continue, explicitly say "The plan cannot be continued." Then finish with a brief description of what the user needs to do for the plan to proceed.
- You must not output any other text after this final paragraph. It *must* be the last thing in your response, and it *must* begin with one of the three options above ("All tasks have been completed.", "Next, ", or "The plan cannot be continued.").
+ - If there is a clear next subtask that definitely needs to be done to finish the plan (and has not already been completed), output a sentence starting with "Next, " and then give a brief description of the next subtask.
+ - If there is no clear next subtask, or the user needs to take some action before you can continue, explicitly say "The plan cannot be continued." Then finish with a brief description of what the user needs to do for the plan to proceed.
+
+ - You must not output any other text after this final paragraph. It *must* be the last thing in your response, and it *must* begin with one of the three options above ("All tasks have been completed.", "Next, ", or "The plan cannot be continued.").
- You should lean toward considering the plan complete if all the subtasks are completed to a decent standard. Even if there are additional steps that *could* be taken, if you have completed the tasks you were asked to do, you should consider the plan complete. Be cautious about suggesting additional steps (with the "Next, " syntax) that are not strictly necessary to complete the task at hand. Only suggest additional steps if the next step is clear and has already been well established in the conversation.
+ - You should consider the plan complete if all the subtasks are completed to a decent standard. Even if there are additional steps that *could* be taken, if you have completed all the subtasks, you should consider the plan complete.
- Don't consider the user verifying or testing the code as a next step. If all that's left is for the user to verify or test the code, consider the plan complete. Unless *you* can make clear progress on the plan *yourself* without the user's input, the plan should be considered complete.
-
- Remember that when you suggest a next step, the plan will continue automatically. Being over-eager to continue can cause infinite loops and other problems.
+ - Don't consider the user verifying or testing the code as a next step. If all that's left is for the user to verify or test the code, consider the plan complete.
- Remember not to ask the user to do anything that you can do yourself, or anything that isn't strictly necessary for completing the plan to a decent standard. It's preferable to finish the plan with either the "All tasks have been completed." option or the "Next, " option if possible. Only if the plan clearly isn't completed and has no clear next step that you can do yourself should you use the "The plan cannot be continued." option.
+ Remember not to ask the user to do anything that you can do yourself, or anything that isn't strictly necessary for completing the plan to a decent standard.
Be aware that since the plan started, the context may have been updated. It may have been updated by the user implementing your suggestions, by the user implementing their own work, or by the user adding more files or information to context. Be sure to consider the current state of the context when continuing with the plan, and whether the plan needs to be updated to reflect the latest context. For example, if you are working on a plan that has been broken up into subtasks, and you've reached the point of implementing a particular subtask, first consider whether the subtask is still necessary looking at the files in context. If it has already been implemented or is no longer necessary, say so, revise the plan if needed, and move on. Otherwise, implement the subtask.
` +
@@ -79,6 +79,6 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context
var CreateSysMsgNumTokens, _ = shared.GetNumTokens(SysCreate)
-const PromptWrapperFormatStr = "The user's latest prompt:\n```\n%s\n```\n\n Please respond according to the 'Your instructions' section above. If you're making a plan, remember to precede code blocks with the file path *exactly* as described in 2a, and do not use any other formatting for file paths."
+const PromptWrapperFormatStr = "The user's latest prompt:\n```\n%s\n```\n\n Please respond according to the 'Your instructions' section above. If you're making a plan, remember to precede code blocks with the file path *exactly* as described in 2a, and do not use any other formatting for file paths. If you're making a plan, also remember to end every response with either " + `"All tasks have been completed.", "Next, " (plus a brief descripton of the next step), or "The plan cannot be continued." according to your instructions for ending a response.`
var PromptWrapperTokens, _ = shared.GetNumTokens(fmt.Sprintf(PromptWrapperFormatStr, ""))
diff --git a/app/server/model/prompts/describe.go b/app/server/model/prompts/describe.go
index 35b69d72..88d9da61 100644
--- a/app/server/model/prompts/describe.go
+++ b/app/server/model/prompts/describe.go
@@ -5,7 +5,7 @@ import (
"github.com/sashabaranov/go-openai/jsonschema"
)
-const SysDescribe = "You are an AI parser. You turn an AI's plan for a programming task into a structured description. You call the 'describePlan' function with a valid JSON object that includes the 'commitMsg' key. Only call the 'describePlan' function in your response. Don't call any other function."
+const SysDescribe = "You are an AI parser. You turn an AI's plan for a programming task into a structured description. You *must* call the 'describePlan' function with a valid JSON object that includes the 'commitMsg' key. Don't produce any other output. Don't call any other function."
var DescribePlanFn = openai.FunctionDefinition{
Name: "describePlan",
diff --git a/app/server/routes.go b/app/server/routes.go
index 8f7f1eb5..3c63deb0 100644
--- a/app/server/routes.go
+++ b/app/server/routes.go
@@ -83,4 +83,5 @@ func routes() *mux.Router {
r.HandleFunc("/plans/{planId}/{branch}/branches", handlers.CreateBranchHandler).Methods("POST")
return r
+
}
diff --git a/app/server/types/active_plan.go b/app/server/types/active_plan.go
index f123a2f5..c5fc714c 100644
--- a/app/server/types/active_plan.go
+++ b/app/server/types/active_plan.go
@@ -43,6 +43,7 @@ type ActivePlan struct {
IsBackground bool
MissingFileResponseCh chan shared.RespondMissingFileChoice
AllowOverwritePaths map[string]bool
+ SkippedPaths map[string]bool
streamCh chan string
subscriptions map[string]chan string
}
@@ -69,6 +70,7 @@ func NewActivePlan(planId, branch, prompt string) *ActivePlan {
StreamDoneCh: make(chan *shared.ApiError),
MissingFileResponseCh: make(chan shared.RespondMissingFileChoice),
AllowOverwritePaths: map[string]bool{},
+ SkippedPaths: map[string]bool{},
streamCh: make(chan string),
subscriptions: map[string]chan string{},
}
@@ -107,7 +109,7 @@ func (ap *ActivePlan) Stream(msg shared.StreamMessage) {
}
func (ap *ActivePlan) ResetModelCtx() {
- ap.ModelStreamCtx, ap.CancelModelStreamFn = context.WithCancel(context.Background())
+ ap.ModelStreamCtx, ap.CancelModelStreamFn = context.WithCancel(ap.Ctx)
}
func (ap *ActivePlan) BuildFinished() bool {
diff --git a/app/shared/req_res.go b/app/shared/req_res.go
index efc09485..85954638 100644
--- a/app/shared/req_res.go
+++ b/app/shared/req_res.go
@@ -106,10 +106,9 @@ const (
)
type RespondMissingFileRequest struct {
- Choice RespondMissingFileChoice `json:"choice"`
- ModelStreamId string `json:"modelStreamId"`
- FilePath string `json:"filePath"`
- Body string `json:"body"`
+ Choice RespondMissingFileChoice `json:"choice"`
+ FilePath string `json:"filePath"`
+ Body string `json:"body"`
}
type LoadContextParams struct {
diff --git a/test_prompts/robust-logging.txt b/test_prompts/robust-logging.txt
new file mode 100644
index 00000000..9d39ea58
--- /dev/null
+++ b/test_prompts/robust-logging.txt
@@ -0,0 +1,16 @@
+insert simple log statements throughout the operations of the 'app/server/model/plan/tell.go' file so it's easy to track the flow of logic. add detailed and rigorous logging to all branches of control flow. log using log.Printf / log.Println
+
+only log key data and don't log anything that will show too large of an
+output. the goal is to be able to follow the flow of the logic, not see *all
+* the data.
+
+especially add comprehensive logging to anything related to the 'missingFileResponse' functionality. as well as everything within spitting distance of this code:
+
+ active.Stream(shared.StreamMessage{ Type:
+ shared.StreamMessagePromptMissingFile, MissingFilePath: currentFile, })
+
+ // stop stream for now
+ active.CancelModelStreamFn()
+
+ // wait for user response to come in
+ userChoice := <-active.MissingFileResponseCh
\ No newline at end of file