Skip to content

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

Fix Windows line ending issues in context handling. Fixes #232

Dane Schneiderab69a5baf4f1
diff --git a/app/cli/lib/context_auto_load.go b/app/cli/lib/context_auto_load.go
index 33de68ac..303a5522 100644
--- a/app/cli/lib/context_auto_load.go
+++ b/app/cli/lib/context_auto_load.go
@@ -99,7 +99,7 @@ func AutoLoadContextFiles(ctx context.Context, files []string) (string, error) {
if isImage {
body = base64.StdEncoding.EncodeToString(b)
} else {
- body = string(b)
+ body = string(shared.NormalizeEOL(b))
}
mu.Lock()
diff --git a/app/cli/lib/context_update.go b/app/cli/lib/context_update.go
index fffa7e91..7e9b8627 100644
--- a/app/cli/lib/context_update.go
+++ b/app/cli/lib/context_update.go
@@ -388,6 +388,8 @@ func checkOutdatedAndMaybeUpdateContext(doUpdate bool, maybeContexts []*shared.C
errs = append(errs, fmt.Errorf("failed to read the file %s: %v", ctx.FilePath, err))
return
}
+ fileContent = shared.NormalizeEOL(fileContent)
+
fileInfo, err := os.Stat(ctx.FilePath)
if err != nil {
mu.Lock()
diff --git a/app/cli/stream_tui/update.go b/app/cli/stream_tui/update.go
index 94595d3b..3558c786 100644
--- a/app/cli/stream_tui/update.go
+++ b/app/cli/stream_tui/update.go
@@ -688,7 +688,7 @@ func (m *streamUIModel) checkMissingFile(msg *shared.StreamMessage) (tea.Model,
m.err = fmt.Errorf("failed to read file: %w", err)
return tea.Quit
}
- content := string(bytes)
+ content := string(shared.NormalizeEOL(bytes))
log.Println("checkMissingFile - calling RespondMissingFile")
apiErr := api.Client.RespondMissingFile(lib.CurrentPlanId, lib.CurrentBranch, shared.RespondMissingFileRequest{