Skip to content

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

chore: fix minor issues and improve documentation

Dane Schneidercd4b0ae4a935
diff --git a/app/cli/cmd/diffs.go b/app/cli/cmd/diffs.go
index 408a3cfb..d4bffad2 100644
--- a/app/cli/cmd/diffs.go
+++ b/app/cli/cmd/diffs.go
@@ -72,7 +72,7 @@ func diffs(cmd *cobra.Command, args []string) {
}
if len(diffs) == 0 {
- term.OutputErrorAndExit("🤷‍♂️ No pending changes")
+ fmt.Println("🤷‍♂️ No pending changes")
return
}
diff --git a/app/cli/cmd/repl.go b/app/cli/cmd/repl.go
index b59708c2..88aea45f 100644
--- a/app/cli/cmd/repl.go
+++ b/app/cli/cmd/repl.go
@@ -179,6 +179,9 @@ func runRepl(cmd *cobra.Command, args []string) {
var modeIcon string
if lib.CurrentReplState.Mode == lib.ReplModeTell {
modeIcon = "⚡️"
+ if config.AutoApply && config.AutoExec {
+ modeIcon += "❗️" // warning reminder for auto apply and auto exec
+ }
} else if lib.CurrentReplState.Mode == lib.ReplModeChat {
modeIcon = "💬"
}
diff --git a/app/cli/cmd/rewind.go b/app/cli/cmd/rewind.go
index cd7f26e4..2f0bab95 100644
--- a/app/cli/cmd/rewind.go
+++ b/app/cli/cmd/rewind.go
@@ -422,22 +422,27 @@ func rewind(cmd *cobra.Command, args []string) {
shouldCommit := false
needsPrompt := true
- if cmd.Flags().Changed("commit") || cmd.Flags().Changed("skip-commit") {
- if skipCommit {
- shouldCommit = false
- } else {
- shouldCommit = autoCommit
- }
+ if !fs.ProjectRootIsGitRepo() {
+ shouldCommit = false
needsPrompt = false
} else {
- if config == nil {
- config, apiErr = api.Client.GetPlanConfig(lib.CurrentPlanId)
- if apiErr != nil {
- term.OutputErrorAndExit("Error getting plan config: %v", apiErr)
+ if cmd.Flags().Changed("commit") || cmd.Flags().Changed("skip-commit") {
+ if skipCommit {
+ shouldCommit = false
+ } else {
+ shouldCommit = autoCommit
+ }
+ needsPrompt = false
+ } else {
+ if config == nil {
+ config, apiErr = api.Client.GetPlanConfig(lib.CurrentPlanId)
+ if apiErr != nil {
+ term.OutputErrorAndExit("Error getting plan config: %v", apiErr)
+ }
}
+ shouldCommit = config.AutoCommit
+ needsPrompt = false
}
- shouldCommit = config.AutoCommit
- needsPrompt = false
}
if needsPrompt {
@@ -465,6 +470,7 @@ func rewind(cmd *cobra.Command, args []string) {
term.OutputErrorAndExit("Error committing changes: %v", err)
}
}
+
} else {
printNoChanges()
}
diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.go
index eb34b97f..f0972125 100644
--- a/app/cli/lib/apply.go
+++ b/app/cli/lib/apply.go
@@ -1,4 +1,3 @@
-
package lib
import (
@@ -388,7 +387,7 @@ func execApplyScript(
execCmd.Dir = fs.ProjectRoot
execCmd.Env = os.Environ()
execCmd.Stdin = os.Stdin
-
+
// Set up process group isolation
execCmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
@@ -418,40 +417,47 @@ func execApplyScript(
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
+ var interruptHandled atomic.Bool
+ var interruptWG sync.WaitGroup
+
+ // Start the interrupt handler goroutine
+ interruptWG.Add(1)
go func() {
- select {
- case <-sigChan:
- fmt.Println("\n⚠️ Interrupt received, terminating subprocess...")
- interrupted.Store(true)
-
- // Send SIGINT to the process group to attempt graceful shutdown
- if err := syscall.Kill(-execCmd.Process.Pid, syscall.SIGINT); err != nil {
- log.Printf("Failed to send SIGINT to process group: %v", err)
- }
-
- // Wait for a grace period, then force kill if still running
+ defer interruptWG.Done()
+
+ for {
select {
- case <-time.After(2 * time.Second):
- fmt.Println("❌ Subprocess unresponsive; force-killing now.")
- if err := syscall.Kill(-execCmd.Process.Pid, syscall.SIGKILL); err != nil {
- log.Printf("Failed to send SIGKILL to process group: %v", err)
+ case <-sigChan:
+ if interruptHandled.CompareAndSwap(false, true) {
+ fmt.Println()
+ color.New(term.ColorHiYellow, color.Bold).Println("\n👉 Caught interrupt. Exiting gracefully...")
+ fmt.Println()
+ interrupted.Store(true)
+
+ if err := syscall.Kill(-execCmd.Process.Pid, syscall.SIGINT); err != nil {
+ log.Printf("Failed to send SIGINT to process group: %v", err)
+ }
+
+ select {
+ case <-time.After(2 * time.Second):
+ fmt.Println()
+ color.New(term.ColorHiYellow, color.Bold).Println("👉 Commands didn't exit after 2 seconds. Sending SIGKILL.")
+ fmt.Println()
+ if err := syscall.Kill(-execCmd.Process.Pid, syscall.SIGKILL); err != nil {
+ log.Printf("Failed to send SIGKILL to process group: %v", err)
+ }
+ case <-ctx.Done():
+ return
+ }
}
+
case <-ctx.Done():
- // Context was cancelled, no need to force kill
+ // If no interrupts occurred, this will be the normal exit path
return
}
- case <-ctx.Done():
- // Exit the goroutine when context is cancelled
- return
}
}()
- defer func() {
- cancel() // Cancel context to clean up goroutine
- signal.Stop(sigChan) // Stop catching signals
- close(sigChan) // Close the channel
- }()
-
// Read and display output in real-time
scanner := bufio.NewScanner(pipe)
var outputBuilder strings.Builder
@@ -460,7 +466,7 @@ func execApplyScript(
fmt.Println(line)
outputBuilder.WriteString(line + "\n")
}
-
+
// Check for scanner errors
if scanErr := scanner.Err(); scanErr != nil {
log.Printf("⚠️ Scanner error reading subprocess output: %v", scanErr)
@@ -468,6 +474,12 @@ func execApplyScript(
err = execCmd.Wait()
+ // Ensure interrupt handler fully completes before proceeding
+ cancel() // cancel the context, if not already
+ interruptWG.Wait() // wait until the interrupt handler goroutine finishes
+ signal.Stop(sigChan)
+ close(sigChan)
+
success := err == nil
if interrupted.Load() {
diff --git a/app/server/db/context_helpers.go b/app/server/db/context_helpers.go
index e393a66c..8fbebaca 100644
--- a/app/server/db/context_helpers.go
+++ b/app/server/db/context_helpers.go
@@ -1036,8 +1036,14 @@ func UpdateContexts(params UpdateContextsParams) (*shared.UpdateContextResponse,
return nil, fmt.Errorf("error adding plan context tokens: %v", err)
}
- commitMsg := shared.SummaryForUpdateContext(updateRes) + "\n\n" + shared.TableForContextUpdate(updateRes)
-
+ commitMsg := shared.SummaryForUpdateContext(shared.SummaryForUpdateContextParams{
+ NumFiles: numFiles,
+ NumTrees: numTrees,
+ NumUrls: numUrls,
+ NumMaps: numMaps,
+ TokensDiff: aggregateTokensDiff,
+ TotalTokens: totalTokens,
+ }) + "\n\n" + shared.TableForContextUpdate(updateRes)
return &shared.LoadContextResponse{
TokensAdded: aggregateTokensDiff,
TotalTokens: totalTokens,
diff --git a/app/server/db/data_models.go b/app/server/db/data_models.go
index 2186093a..366e0deb 100644
--- a/app/server/db/data_models.go
+++ b/app/server/db/data_models.go
@@ -497,7 +497,7 @@ type ConvoMessageDescription struct {
PlanId string `json:"planId"`
ConvoMessageId string `json:"convoMessageId"`
SummarizedToMessageId string `json:"summarizedToMessageId"`
- MadePlan bool `json:"madePlan"`
+ WroteFiles bool `json:"wroteFiles"`
CommitMsg string `json:"commitMsg"`
// Files []string `json:"files"`
Operations []*shared.Operation `json:"operations"`
@@ -514,7 +514,7 @@ func (desc *ConvoMessageDescription) ToApi() *shared.ConvoMessageDescription {
Id: desc.Id,
ConvoMessageId: desc.ConvoMessageId,
SummarizedToMessageId: desc.SummarizedToMessageId,
- MadePlan: desc.MadePlan,
+ WroteFiles: desc.WroteFiles,
CommitMsg: desc.CommitMsg,
// Files: desc.Files,
Operations: desc.Operations,
diff --git a/app/server/db/result_helpers.go b/app/server/db/result_helpers.go
index 5bdd1224..dd85cbe5 100644
--- a/app/server/db/result_helpers.go
+++ b/app/server/db/result_helpers.go
@@ -303,7 +303,7 @@ func GetConvoMessageDescriptions(orgId, planId string) ([]*ConvoMessageDescripti
case err := <-errCh:
return nil, fmt.Errorf("error reading description files: %v", err)
case description := <-descCh:
- if description.MadePlan && description.AppliedAt == nil {
+ if description.WroteFiles && description.AppliedAt == nil {
descriptions = append(descriptions, description)
}
}
diff --git a/app/server/hooks/hooks.go b/app/server/hooks/hooks.go
index f54aed2e..41ec536a 100644
--- a/app/server/hooks/hooks.go
+++ b/app/server/hooks/hooks.go
@@ -1,6 +1,7 @@
package hooks
import (
+ "context"
"plandex-server/db"
"plandex-server/types"
"time"
@@ -25,6 +26,7 @@ const (
Authenticate = "authenticate"
GetIntegratedModels = "get_integrated_models"
GetApiOrgs = "get_api_orgs"
+ CallFastApply = "call_fast_apply"
)
type WillSendModelRequestParams struct {
@@ -117,6 +119,18 @@ type AuthenticateHookRequestParams struct {
Path string
}
+type FastApplyParams struct {
+ InitialCode string `json:"initialCode"`
+ EditSnippet string `json:"editSnippet"`
+
+ InitialCodeTokens int
+ EditSnippetTokens int
+
+ Language shared.Language
+
+ Ctx context.Context
+}
+
type HookParams struct {
Auth *types.ServerAuth
Plan *db.Plan
@@ -128,6 +142,7 @@ type HookParams struct {
GetApiOrgIds []string
AuthenticateHookRequestParams *AuthenticateHookRequestParams
DidFinishBuilderRunParams *DidFinishBuilderRunParams
+ FastApplyParams *FastApplyParams
}
type GetIntegratedModelsResult struct {
@@ -135,9 +150,14 @@ type GetIntegratedModelsResult struct {
ApiKeys map[string]string
}
+type FastApplyResult struct {
+ MergedCode string
+}
+
type HookResult struct {
GetIntegratedModelsResult *GetIntegratedModelsResult
ApiOrgsById map[string]*shared.Org
+ FastApplyResult *FastApplyResult
}
type Hook func(params HookParams) (HookResult, *shared.ApiError)
diff --git a/app/server/model/plan/commit_msg.go b/app/server/model/plan/commit_msg.go
index ba18f3b9..841903cf 100644
--- a/app/server/model/plan/commit_msg.go
+++ b/app/server/model/plan/commit_msg.go
@@ -240,7 +240,7 @@ func GenCommitMsgForPendingResults(auth *types.ServerAuth, plan *db.Plan, client
num := 0
for _, desc := range current.ConvoMessageDescriptions {
- if desc.MadePlan && desc.DidBuild && len(desc.BuildPathsInvalidated) == 0 && desc.AppliedAt == nil {
+ if desc.WroteFiles && desc.DidBuild && len(desc.BuildPathsInvalidated) == 0 && desc.AppliedAt == nil {
s += desc.CommitMsg + "\n"
num++
}
diff --git a/app/server/model/plan/tell_stream_error.go b/app/server/model/plan/tell_stream_error.go
index 1b310d5e..d9affa7f 100644
--- a/app/server/model/plan/tell_stream_error.go
+++ b/app/server/model/plan/tell_stream_error.go
@@ -147,7 +147,7 @@ func (state *activeTellStreamState) onError(params onErrorParams) onErrorResult
OrgId: currentOrgId,
PlanId: planId,
SummarizedToMessageId: summarizedToMessageId,
- MadePlan: false,
+ WroteFiles: false,
ConvoMessageId: convoMessageId,
BuildPathsInvalidated: map[string]bool{},
Error: streamErr.Error(),
diff --git a/app/server/model/plan/tell_stream_status.go b/app/server/model/plan/tell_stream_status.go
index 4e83ef98..d5f76168 100644
--- a/app/server/model/plan/tell_stream_status.go
+++ b/app/server/model/plan/tell_stream_status.go
@@ -48,7 +48,7 @@ func (state *activeTellStreamState) handleDescAndExecStatus() handleDescAndExecS
generatedDescription = res
generatedDescription.OrgId = currentOrgId
generatedDescription.SummarizedToMessageId = summarizedToMessageId
- generatedDescription.MadePlan = true
+ generatedDescription.WroteFiles = true
generatedDescription.Operations = replyOperations
log.Println("Generated plan description.")
diff --git a/app/server/model/plan/tell_stream_store.go b/app/server/model/plan/tell_stream_store.go
index de533cd7..f0ec3605 100644
--- a/app/server/model/plan/tell_stream_store.go
+++ b/app/server/model/plan/tell_stream_store.go
@@ -145,6 +145,7 @@ func (state *activeTellStreamState) storeOnFinished(params storeOnFinishedParams
flags.DidMakePlan = true
}
if len(removedSubtasks) > 0 {
+ flags.DidMakePlan = true
flags.DidRemoveTasks = true
}
if len(autoLoadContextResult.autoLoadPaths) > 0 {
@@ -186,7 +187,7 @@ func (state *activeTellStreamState) storeOnFinished(params storeOnFinishedParams
ConvoMessageId: assistantMsg.Id,
SummarizedToMessageId: summarizedToMessageId,
BuildPathsInvalidated: map[string]bool{},
- MadePlan: false,
+ WroteFiles: false,
}
} else {
description = generatedDescription
diff --git a/app/shared/data_models.go b/app/shared/data_models.go
index 4deb41c6..223fb070 100644
--- a/app/shared/data_models.go
+++ b/app/shared/data_models.go
@@ -211,7 +211,7 @@ type ConvoMessageDescription struct {
Id string `json:"id"`
ConvoMessageId string `json:"convoMessageId"`
SummarizedToMessageId string `json:"summarizedToMessageId"`
- MadePlan bool `json:"madePlan"`
+ WroteFiles bool `json:"wroteFiles"`
CommitMsg string `json:"commitMsg"`
// Files []string `json:"files"`
Operations []*Operation `json:"operations"`
diff --git a/app/shared/req_res.go b/app/shared/req_res.go
index e7618741..3d74a946 100644
--- a/app/shared/req_res.go
+++ b/app/shared/req_res.go
@@ -136,6 +136,7 @@ type TellPlanRequest struct {
OpenAIOrgId string `json:"openAIOrgId"`
ProjectPaths map[string]bool `json:"projectPaths"`
IsImplementationOfChat bool `json:"isImplementationOfChat"`
+ IsGitRepo bool `json:"isGitRepo"`
}
type BuildPlanRequest struct {
diff --git a/docs/docs/cli-reference.md b/docs/docs/cli-reference.md
index 43b7ec5a..b255a9e1 100644
--- a/docs/docs/cli-reference.md
+++ b/docs/docs/cli-reference.md
@@ -449,6 +449,8 @@ pdx ap # alias
`--skip-commit`: Don't commit changes to git. Defaults to opposite of config value `auto-commit`.
+`--full-auto`: Apply the plan and debug in full auto mode.
+
### reject
Reject pending changes to one or more project files.
diff --git a/docs/docs/core-concepts/reviewing-changes.md b/docs/docs/core-concepts/reviewing-changes.md
index 09d614a5..e70f39e3 100644
--- a/docs/docs/core-concepts/reviewing-changes.md
+++ b/docs/docs/core-concepts/reviewing-changes.md
@@ -73,7 +73,15 @@ If commands fail, the changes are rolled back. Depending on the autonomy level a
## Auto-Applying Changes
-When `auto-apply` is enabled, Plandex will automatically apply changes after a plan is complete without prompting or review. This is enabled at the `full` autonomy level, and also during auto-debugging.
+When `auto-apply` is enabled, Plandex will automatically apply changes after a plan is complete without prompting or review. This is enabled at the `full` [autonomy level](./autonomy.md), and also during auto-debugging.
+
+## Apply + Full Auto
+
+You can also apply changes and debug in full auto mode with the `--full-auto` flag:
+
+```bash
+plandex apply --full-auto
+```
## Autonomy Matrix