Skip to content

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

no need to generate new files in confirmation. basis for install script

Dane Schneiderc5679516be92
diff --git a/cli/install.sh b/cli/install.sh
new file mode 100644
index 00000000..12fd7aac
--- /dev/null
+++ b/cli/install.sh
@@ -0,0 +1,136 @@
+#!/usr/bin/env bash
+
+set -e
+
+SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
+
+PLATFORM=
+ARCH=
+VERSION=
+RELEASES_URL="https://github.com/user/plandex/releases/download"
+
+# Set platform
+case "$(uname -s)" in
+ Darwin)
+ PLATFORM='darwin'
+ ;;
+
+ Linux)
+ PLATFORM='linux'
+ ;;
+
+ FreeBSD)
+ PLATFORM='freebsd'
+ ;;
+
+ CYGWIN*|MINGW*|MSYS*)
+ PLATFORM='windows'
+ ;;
+
+ *)
+ echo "Platform may or may not be supported. Will attempt to install."
+ PLATFORM='linux'
+ ;;
+esac
+
+# Set arch
+if [[ "$(uname -m)" == 'x86_64' ]]; then
+ ARCH="amd64"
+elif [[ "$(uname -m)" == armv5* ]]; then
+ ARCH="armv5"
+elif [[ "$(uname -m)" == armv6* ]]; then
+ ARCH="armv6"
+elif [[ "$(uname -m)" == armv7* ]]; then
+ ARCH="armv7"
+elif [[ "$(uname -m)" == 'arm64' || "$(uname -m)" == 'aarch64' ]]; then
+ ARCH="arm64"
+else
+ ARCH="386"
+fi
+
+if [[ "$(cat /proc/1/cgroup 2> /dev/null | grep docker | wc -l)" > 0 ]] || [ -f /.dockerenv ]; then
+ IS_DOCKER=true
+else
+ IS_DOCKER=false
+fi
+
+# Set Version
+if [[ -z "${PLANDEX_VERSION}" ]]; then
+ VERSION=$(curl -s "https://api.github.com/repos/user/plandex/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
+else
+ VERSION=$PLANDEX_VERSION
+ echo "Using custom version $VERSION"
+fi
+
+
+welcome_plandex () {
+ echo "Plandex $VERSION Quick Install"
+ echo "Copyright (c) 2023 Plandex Inc."
+ echo ""
+}
+
+cleanup () {
+ echo "Cleaning up..."
+ cd "${SCRIPT_DIR}"
+ rm -rf plandex_install_tmp
+}
+
+download_plandex () {
+ url="${RELEASES_URL}/${VERSION}/plandex_${VERSION}_${PLATFORM}_${ARCH}.tar.gz"
+
+ mkdir plandex_install_tmp
+ cd plandex_install_tmp
+
+ echo "Downloading Plandex tarball from $url"
+ curl -s -L -o plandex.tar.gz "${url}"
+
+ tar zxf plandex.tar.gz 1> /dev/null
+
+ if [ "$PLATFORM" == "darwin" ] || $IS_DOCKER ; then
+ if [[ -d /usr/local/bin ]]; then
+ mv plandex /usr/local/bin/
+ echo "Plandex is installed in /usr/local/bin"
+ else
+ echo >&2 'Error: /usr/local/bin does not exist. Create this directory with appropriate permissions, then re-install.'
+ cleanup
+ exit 1
+ fi
+ elif [ "$PLATFORM" == "windows" ]; then
+ # ensure $HOME/bin exists (it's in PATH but not present in default git-bash install)
+ mkdir "$HOME/bin" 2> /dev/null
+ mv plandex.exe "$HOME/bin/"
+ echo "Plandex is installed in '$HOME/bin'"
+ else
+ if [ $UID -eq 0 ]
+ then
+ # we are root
+ mv plandex /usr/local/bin/
+ elif hash sudo 2>/dev/null;
+ then
+ # not root, but can sudo
+ sudo mv plandex /usr/local/bin/
+ else
+ echo "ERROR: This script must be run as root or be able to sudo to complete the installation."
+ exit 1
+ fi
+
+ echo "Plandex is installed in /usr/local/bin"
+ fi
+
+ # create 'pdx' alias, but don't ovewrite existing pdx command
+ if [ ! -x "$(command -v pdx)" ]; then
+ echo "creating pdx alias"
+ LOC=$(which plandex)
+ BIN_DIR=$(dirname $LOC)
+ error_msg=$(ln -s "$LOC" "$BIN_DIR/pdx" 2>&1) || { echo "Failed to create 'pdx' alias for Plandex. Error: $error_msg. Please create it manually if needed."; }
+ fi
+}
+
+welcome_plandex
+download_plandex
+cleanup
+
+echo "Installation complete. Info:"
+echo ""
+plandex -h
+
diff --git a/cli/lib/context_load.go b/cli/lib/context_load.go
index 4bf77e8d..381ff2a3 100644
--- a/cli/lib/context_load.go
+++ b/cli/lib/context_load.go
@@ -86,9 +86,13 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {
if totalTokens > maxTokens {
if params.Truncate {
- log.Printf("The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating input text.", totalTokens, maxTokens)
+ s.Stop()
+ ClearCurrentLine()
+ fmt.Fprintf(os.Stderr, "The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating input text.\n", totalTokens, maxTokens)
numTokens = maxTokens - (totalTokens - numTokens)
+ s.Start()
+
// If the number of tokens is less than or equal to 0, then we can stop processing files
if numTokens <= 0 {
return
@@ -161,9 +165,13 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {
tokensAdded += numTokens
if totalTokens > maxTokens {
if params.Truncate {
- log.Printf("The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating piped data.", totalTokens, maxTokens)
+ s.Stop()
+ ClearCurrentLine()
+ fmt.Fprintf(os.Stderr, "The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating piped data.\n", totalTokens, maxTokens)
numTokens = maxTokens - (totalTokens - numTokens)
+ s.Start()
+
if numTokens <= 0 {
return
}
@@ -243,9 +251,13 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {
if totalTokens > maxTokens {
if params.Truncate {
- log.Printf("The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating filenames.", totalTokens, maxTokens)
+ s.Stop()
+ ClearCurrentLine()
+ fmt.Fprintf(os.Stderr, "The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating directory layout.\n", totalTokens, maxTokens)
numTokens = maxTokens - (totalTokens - numTokens)
+ s.Start()
+
// If the number of tokens is less than or equal to 0, then we can stop processing files
if numTokens <= 0 {
return
@@ -299,9 +311,13 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {
if totalTokens > maxTokens {
if params.Truncate {
- log.Printf("The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating the file %s.", totalTokens, maxTokens, path)
+ s.Stop()
+ ClearCurrentLine()
+ fmt.Fprintf(os.Stderr, "The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating the file %s.\n", totalTokens, maxTokens, path)
numTokens = maxTokens - (totalTokens - numTokens)
+ s.Start()
+
// If the number of tokens is less than or equal to 0, then we can stop processing files
if numTokens <= 0 {
return
@@ -362,9 +378,13 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {
tokensAdded += numTokens
if totalTokens > maxTokens {
if params.Truncate {
- log.Printf("The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating content from URL %s.", totalTokens, maxTokens, url)
+ s.Stop()
+ ClearCurrentLine()
+ fmt.Fprintf(os.Stderr, "The total number of tokens (%d) exceeds the maximum allowed (%d). Truncating content from URL %s.\n", totalTokens, maxTokens, url)
numTokens = maxTokens - (totalTokens - numTokens)
+ s.Start()
+
// If the number of tokens is less than or equal to 0, then we can stop processing content
if numTokens <= 0 {
return
@@ -389,6 +409,7 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {
contextPart := shared.ModelContextPart{
Name: SanitizeAndClipURL(url, 70),
+ Url: url,
Body: body,
Sha: sha,
NumTokens: numTokens,
@@ -501,7 +522,7 @@ func LoadContextOrDie(params *types.LoadContextParams) (int, int) {
}
s.Stop()
- clearCurrentLine()
+ ClearCurrentLine()
fmt.Fprintln(os.Stderr, "✅ "+msg)
return tokensAdded, totalTokens
diff --git a/cli/lib/proposal.go b/cli/lib/proposal.go
index 2fb662d2..22e7ba18 100644
--- a/cli/lib/proposal.go
+++ b/cli/lib/proposal.go
@@ -94,8 +94,8 @@ func Propose(prompt string) error {
}()
printReply := func() {
- clearScreen()
- moveCursorToTopLeft()
+ ClearScreen()
+ MoveCursorToTopLeft()
mdFull, _ := GetMarkdown(reply)
fmt.Println(mdFull)
fmt.Printf(displayHotkeys())
@@ -119,14 +119,13 @@ func Propose(prompt string) error {
endReply := func() {
replyUpdateTimer.Stop()
printReply()
- backToMain()
+ BackToMain()
fmt.Print(termState)
s = spinner.New(spinner.CharSets[33], 100*time.Millisecond)
s.Prefix = " "
s.Start()
var totalTokens int
- // _, tokensAddedByFile, totalTokens = replyTokenCounter.FinishAndRead()
- _, _, totalTokens = replyTokenCounter.FinishAndRead()
+ _, _, _, totalTokens = replyTokenCounter.FinishAndRead()
err := appendConversation(types.AppendConversationParams{
Timestamp: timestamp,
Prompt: prompt,
@@ -141,19 +140,6 @@ func Propose(prompt string) error {
}
- showUpdatedPlanCmds := func() {
- fmt.Println()
- for _, cmd := range []string{"apply", "preview", "diffs"} {
- clearCurrentLine()
- PrintCmds(" ", cmd)
- }
- clearCurrentLine()
- PrintCustomCmd(" ", "tell", "t", "update the plan, give more info, or chat")
-
- clearCurrentLine()
- PrintCmds(" ", "next")
- }
-
contextByFilePath := make(map[string]shared.ModelContextPart)
running := false
@@ -182,7 +168,7 @@ func Propose(prompt string) error {
content := params.Content
onError := func(err error) {
- backToMain()
+ BackToMain()
fmt.Fprintln(os.Stderr, "Error:", err)
cancelKeywatch()
close(done)
@@ -225,7 +211,7 @@ func Propose(prompt string) error {
}
s.Stop()
- clearCurrentLine()
+ ClearCurrentLine()
alternateScreen()
replyStarted = true
@@ -245,9 +231,6 @@ func Propose(prompt string) error {
streamFinished = true
if filesFinished {
- if desc.MadePlan && len(desc.Files) > 0 {
- showUpdatedPlanCmds()
- }
close(done)
}
return
@@ -299,9 +282,9 @@ func Propose(prompt string) error {
// Clear previous lines
if filesFinished {
- moveUpLines(len(files))
+ MoveUpLines(len(files))
} else {
- moveUpLines(len(files) + 4)
+ MoveUpLines(len(files) + 4)
}
for _, filePath := range files {
@@ -316,7 +299,7 @@ func Propose(prompt string) error {
fmtStr += " | done ✅"
}
- clearCurrentLine()
+ ClearCurrentLine()
fmt.Printf(fmtStr+"\n", fmtArgs...)
}
@@ -327,7 +310,6 @@ func Propose(prompt string) error {
filesFinished = true
if streamFinished {
- showUpdatedPlanCmds()
close(done)
}
}
@@ -345,7 +327,7 @@ func Propose(prompt string) error {
apiReq, err = Api.Propose(prompt, parentProposalId, handleStream)
if err != nil {
- backToMain()
+ BackToMain()
return fmt.Errorf("failed to send prompt to server: %s\n", err)
}
for _, part := range apiReq.ModelContext {
@@ -389,6 +371,21 @@ Loop:
}
}
+ fmt.Println()
+
+ if desc.MadePlan && len(desc.Files) > 0 {
+ for _, cmd := range []string{"apply", "diffs", "preview"} {
+ ClearCurrentLine()
+ PrintCmds(" ", cmd)
+ }
+ }
+
+ ClearCurrentLine()
+ PrintCustomCmd(" ", "tell", "t", "update the plan, give more info, or chat")
+
+ ClearCurrentLine()
+ PrintCmds(" ", "next")
+
return nil
}
diff --git a/cli/lib/stream.go b/cli/lib/stream.go
index 87aa7ffa..a5aa63b6 100644
--- a/cli/lib/stream.go
+++ b/cli/lib/stream.go
@@ -37,7 +37,7 @@ func receiveFileToken(params *receiveFileChunkParams) (bool, error) {
buffer += chunk.Content
jsonBuffers[chunk.Path] = buffer
- numStreamedTokensByPath[chunk.Path]++
+ numStreamedTokensByPath[chunk.Path] += chunk.NumTokens
// log.Println("Received file chunk: " + chunk.Path)
// log.Println("Number of tokens: " + fmt.Sprintf("%d", numStreamedTokensByPath[chunk.Path]))
diff --git a/cli/lib/term.go b/cli/lib/term.go
index 845a1407..b1d20a1e 100644
--- a/cli/lib/term.go
+++ b/cli/lib/term.go
@@ -50,23 +50,23 @@ func alternateScreen() {
fmt.Print("\x1b[?1049h\x1b[?25l")
}
-func clearScreen() {
+func ClearScreen() {
fmt.Print("\x1b[2J")
}
-func moveCursorToTopLeft() {
+func MoveCursorToTopLeft() {
fmt.Print("\x1b[H")
}
-func clearCurrentLine() {
+func ClearCurrentLine() {
fmt.Print("\033[2K")
}
-func moveUpLines(numLines int) {
+func MoveUpLines(numLines int) {
fmt.Printf("\033[%dA", numLines)
}
-func backToMain() {
+func BackToMain() {
// Switch back to main screen and show the cursor on exit
fmt.Print("\x1b[?1049l\x1b[?25h")
}
diff --git a/server/model/proposal/confirm.go b/server/model/proposal/confirm.go
index 7dc5b239..134e5653 100644
--- a/server/model/proposal/confirm.go
+++ b/server/model/proposal/confirm.go
@@ -160,7 +160,7 @@ You apply changes from a plan to a given code file. Use 'writeEntireFile' functi
[END INSTRUCTIONS]`
-func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
+func confirmProposal(proposalId string, fileContents map[string]string, numTokensByFile map[string]int, onStream types.OnStreamFunc) error {
goEnv := os.Getenv("GOENV")
if goEnv == "test" {
streamFilesLoremIpsum(onStream)
@@ -200,10 +200,6 @@ func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
}
go func(filePath string) {
- fmt.Println("Getting file from model: " + filePath)
-
- _, fileInProject := proposal.Request.ProjectPaths[filePath]
-
// get relevant file context (if any)
var fileContext *shared.ModelContextPart
for _, part := range proposal.Request.ModelContext {
@@ -213,6 +209,56 @@ func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
}
}
+ _, fileInCurrentPlan := proposal.Request.CurrentPlan.Files[filePath]
+
+ if fileContext == nil && !fileInCurrentPlan {
+ // new file
+ streamed := shared.StreamedFile{
+ Content: fileContents[filePath],
+ }
+ bytes, err := json.Marshal(streamed)
+
+ if err != nil {
+ onError(fmt.Errorf("error marshalling streamed file: %v", err))
+ return
+ }
+
+ chunk := &shared.PlanChunk{
+ Path: filePath,
+ Content: string(bytes),
+ NumTokens: numTokensByFile[filePath],
+ }
+
+ // fmt.Printf("%s: %s", filePath, content)
+ chunkJson, err := json.Marshal(chunk)
+ if err != nil {
+ onError(fmt.Errorf("error marshalling plan chunk: %v", err))
+ return
+ }
+ onStream(string(chunkJson), nil)
+
+ finished := false
+ plans.Update(proposalId, func(plan *types.Plan) {
+ plan.FilesFinished[filePath] = true
+ plan.Files[filePath] = string(bytes)
+
+ if plan.DidFinish() {
+ plan.Finish()
+ finished = true
+ }
+ })
+
+ if finished {
+ fmt.Println("Stream finished")
+ onStream(shared.STREAM_FINISHED, nil)
+ return
+ }
+
+ return
+ }
+
+ fmt.Println("Getting file from model: " + filePath)
+
fmtStr := "\nCurrent state of %s:\n```\n%s\n```"
fmtArgs := []interface{}{filePath}
@@ -224,26 +270,29 @@ func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
}
fileMessages := []openai.ChatCompletionMessage{}
+
+ var msg string
+ if fileContext != nil {
+ msg = replacementSystemPrompt
+ } else {
+ msg = writeFileOnlySystemPrompt
+ }
+
if fileContext != nil || currentState != "" {
- if fileInProject {
- fileMessages = append(fileMessages, openai.ChatCompletionMessage{
- Role: openai.ChatMessageRoleSystem,
- Content: replacementSystemPrompt + "\n\n" + fmt.Sprintf(fmtStr, fmtArgs...),
- })
- } else {
- fileMessages = append(fileMessages, openai.ChatCompletionMessage{
- Role: openai.ChatMessageRoleSystem,
- Content: writeFileOnlySystemPrompt + "\n\n" + fmt.Sprintf(fmtStr, fmtArgs...),
- })
- }
+ msg += "\n\n" + fmt.Sprintf(fmtStr, fmtArgs...)
}
+ fileMessages = append(fileMessages, openai.ChatCompletionMessage{
+ Role: openai.ChatMessageRoleSystem,
+ Content: msg,
+ })
+
fileMessages = append(fileMessages, openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleAssistant,
Content: proposal.Content,
})
- if fileInProject {
+ if fileContext != nil {
fileMessages = append(fileMessages,
openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
@@ -282,7 +331,7 @@ func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
},
}
- if fileInProject {
+ if fileContext != nil {
functions = append(functions, openai.FunctionDefinition{
Name: "writeReplacements",
Parameters: &jsonschema.Definition{
@@ -353,12 +402,12 @@ func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
}
if err != nil {
- onError(fmt.Errorf("Stream error: %v", err))
+ onError(fmt.Errorf("stream error: %v", err))
return
}
if len(response.Choices) == 0 {
- onError(fmt.Errorf("Stream error: no choices"))
+ onError(fmt.Errorf("stream error: no choices"))
return
}
@@ -383,7 +432,7 @@ func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
}
} else {
- onError(fmt.Errorf("Stream finished without a function call. Reason: %s", choice.FinishReason))
+ onError(fmt.Errorf("stream finished without a function call. Reason: %s", choice.FinishReason))
return
}
}
@@ -405,8 +454,9 @@ func confirmProposal(proposalId string, onStream types.OnStreamFunc) error {
})
chunk := &shared.PlanChunk{
- Path: filePath,
- Content: content,
+ Path: filePath,
+ Content: content,
+ NumTokens: 1,
}
// fmt.Printf("%s: %s", filePath, content)
diff --git a/server/model/proposal/create.go b/server/model/proposal/create.go
index db8fa1f1..be3cedd1 100644
--- a/server/model/proposal/create.go
+++ b/server/model/proposal/create.go
@@ -221,7 +221,7 @@ func CreateProposal(req shared.PromptRequest, onStream types.OnStreamFunc) error
if choice.FinishReason != "" {
onStream(shared.STREAM_DESCRIPTION_PHASE, nil)
- files, _, _ := replyInfo.FinishAndRead()
+ files, fileContents, numTokensByFile, _ := replyInfo.FinishAndRead()
if len(files) == 0 {
planDescription := &shared.PlanDescription{
@@ -270,7 +270,7 @@ func CreateProposal(req shared.PromptRequest, onStream types.OnStreamFunc) error
onStream(planDescriptionJson, nil)
onStream(shared.STREAM_BUILD_PHASE, nil)
- err = confirmProposal(proposalId, onStream)
+ err = confirmProposal(proposalId, fileContents, numTokensByFile, onStream)
if err != nil {
onError(fmt.Errorf("failed to confirm proposal: %v", err))
}
diff --git a/server/model/proposal/lorem_ipsum.go b/server/model/proposal/lorem_ipsum.go
index 314acd09..cf5aa965 100644
--- a/server/model/proposal/lorem_ipsum.go
+++ b/server/model/proposal/lorem_ipsum.go
@@ -63,7 +63,7 @@ func streamLoremIpsum(onStream types.OnStreamFunc) {
onStream(planDescriptionJson, nil)
onStream(shared.STREAM_BUILD_PHASE, nil)
- confirmProposal("", onStream)
+ confirmProposal("", map[string]string{}, map[string]int{}, onStream)
}
diff --git a/shared/reply.go b/shared/reply.go
index 6ca557bc..a2cac626 100644
--- a/shared/reply.go
+++ b/shared/reply.go
@@ -11,6 +11,7 @@ type replyInfo struct {
maybeFilePath string
currentFilePath string
files map[string]bool
+ fileContents map[string]string
numTokens int
numTokensByFile map[string]int
}
@@ -20,6 +21,7 @@ func NewReplyInfo() *replyInfo {
lines: []string{""},
currentFileLines: []string{},
files: make(map[string]bool),
+ fileContents: make(map[string]string),
numTokensByFile: make(map[string]int),
}
@@ -127,6 +129,7 @@ func (r *replyInfo) AddToken(token string, addToTotal bool) {
// fmt.Println("Exited file block.")
} else {
r.files[r.currentFilePath] = true
+ r.fileContents[r.currentFilePath] += prevFullLine + "\n"
r.currentFileLines = append(r.currentFileLines, prevFullLine)
// r.contentByFile[r.currentFilePath] += prevFullLine + "\n"
@@ -135,7 +138,7 @@ func (r *replyInfo) AddToken(token string, addToTotal bool) {
}
}
-func (r *replyInfo) FinishAndRead() ([]string, map[string]int, int) {
+func (r *replyInfo) FinishAndRead() ([]string, map[string]string, map[string]int, int) {
r.AddToken("\n", false)
files := make([]string, 0, len(r.files))
@@ -143,5 +146,5 @@ func (r *replyInfo) FinishAndRead() ([]string, map[string]int, int) {
files = append(files, file)
}
- return files, r.numTokensByFile, r.numTokens
+ return files, r.fileContents, r.numTokensByFile, r.numTokens
}
diff --git a/shared/reply_test.go b/shared/reply_test.go
index 84b28ce9..981348bb 100644
--- a/shared/reply_test.go
+++ b/shared/reply_test.go
@@ -85,22 +85,23 @@ func TestReplyTokenCounter(t *testing.T) {
i = end
}
- files, tokensByFilePath, totalCounted := counter.FinishAndRead()
+ files, fileContents, tokensByFilePath, totalCounted := counter.FinishAndRead()
fmt.Printf("Total tokens counted: %d\n", totalCounted)
fmt.Printf("%d files: %v\n", len(files), files)
+ fmt.Printf("%d file content: %v\n", len(fileContents), fileContents)
fmt.Println("Tokens by file path:")
for filePath, tokens := range tokensByFilePath {
fmt.Printf("%s: %d\n", filePath, tokens)
}
if totalCounted != totalTokens {
- t.Error(fmt.Sprintf("Expected %d tokens, got %d", totalTokens, totalCounted))
+ t.Errorf("Expected %d tokens, got %d", totalTokens, totalCounted)
}
for filePath, tokens := range example.TokensByFilePath {
if tokensByFilePath[filePath] != tokens {
- t.Error(fmt.Sprintf("Expected %d tokens for %s", tokens, filePath))
+ t.Errorf("Expected %d tokens for %s", tokens, filePath)
}
}
}
diff --git a/shared/types.go b/shared/types.go
index 5103e12f..a7f40619 100644
--- a/shared/types.go
+++ b/shared/types.go
@@ -17,7 +17,6 @@ type PromptRequest struct {
Prompt string `json:"prompt"`
ModelContext ModelContext `json:"modelContext"`
CurrentPlan CurrentPlanFiles `json:"currentPlan"`
- ProjectPaths map[string]bool `json:"projectPaths"`
Conversation []ConversationMessage `json:"conversation"`
ParentProposalId string `json:"parentProposalId"`
}
@@ -50,8 +49,9 @@ type ModelContextPart struct {
type ModelContext []ModelContextPart
type PlanChunk struct {
- Path string `json:"path"`
- Content string `json:"content"`
+ Path string `json:"path"`
+ Content string `json:"content"`
+ NumTokens int `json:"numTokens"`
}
type PlanDescription struct {