|
@@ -5,14 +5,12 @@ import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"io"
|
|
"io"
|
|
|
"os"
|
|
"os"
|
|
|
- "strings"
|
|
|
|
|
"sync"
|
|
"sync"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"log/slog"
|
|
"log/slog"
|
|
|
|
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
- "github.com/go-viper/mapstructure/v2"
|
|
|
|
|
zone "github.com/lrstanley/bubblezone"
|
|
zone "github.com/lrstanley/bubblezone"
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/cobra"
|
|
|
"github.com/sst/opencode/internal/app"
|
|
"github.com/sst/opencode/internal/app"
|
|
@@ -25,7 +23,6 @@ import (
|
|
|
"github.com/sst/opencode/internal/pubsub"
|
|
"github.com/sst/opencode/internal/pubsub"
|
|
|
"github.com/sst/opencode/internal/tui"
|
|
"github.com/sst/opencode/internal/tui"
|
|
|
"github.com/sst/opencode/internal/version"
|
|
"github.com/sst/opencode/internal/version"
|
|
|
- "github.com/sst/opencode/pkg/client"
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type SessionIDHandler struct {
|
|
type SessionIDHandler struct {
|
|
@@ -95,7 +92,7 @@ to assist developers in writing, debugging, and understanding code directly from
|
|
|
|
|
|
|
|
// Check if we're in non-interactive mode
|
|
// Check if we're in non-interactive mode
|
|
|
prompt, _ := cmd.Flags().GetString("prompt")
|
|
prompt, _ := cmd.Flags().GetString("prompt")
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Check for piped input if no prompt was provided via flag
|
|
// Check for piped input if no prompt was provided via flag
|
|
|
if prompt == "" {
|
|
if prompt == "" {
|
|
|
pipedInput, hasPipedInput := checkStdinPipe()
|
|
pipedInput, hasPipedInput := checkStdinPipe()
|
|
@@ -103,7 +100,7 @@ to assist developers in writing, debugging, and understanding code directly from
|
|
|
prompt = pipedInput
|
|
prompt = pipedInput
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// If we have a prompt (either from flag or piped input), run in non-interactive mode
|
|
// If we have a prompt (either from flag or piped input), run in non-interactive mode
|
|
|
if prompt != "" {
|
|
if prompt != "" {
|
|
|
outputFormatStr, _ := cmd.Flags().GetString("output-format")
|
|
outputFormatStr, _ := cmd.Flags().GetString("output-format")
|
|
@@ -347,7 +344,7 @@ func checkStdinPipe() (string, bool) {
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return "", false
|
|
return "", false
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// If we got data, return it
|
|
// If we got data, return it
|
|
|
if len(data) > 0 {
|
|
if len(data) > 0 {
|
|
|
return string(data), true
|
|
return string(data), true
|