Bold questions

This commit is contained in:
Ian Gulliver
2026-10-14 19:35:34 -07:00
parent ab4c3d2c6f
commit 1ea055682b
54 changed files with 3696 additions and 762 deletions
+30 -1
View File
@@ -34,6 +34,7 @@ type Options struct {
ForkSession bool
GitName string
GitEmail string
Guidance string
Hooks map[string][]HookMatcher
MCPServers []*mcp.Server
Transcript io.Writer
@@ -127,6 +128,27 @@ func (e Event) Blocks() ([]Block, error) {
return blocks, nil
}
func (e Event) TextDelta() (string, error) {
msg := struct {
ParentToolUseID *string `json:"parent_tool_use_id"`
Event struct {
Type string `json:"type"`
Delta struct {
Type string `json:"type"`
Text string `json:"text"`
} `json:"delta"`
} `json:"event"`
}{}
err := json.Unmarshal(e.Raw, &msg)
if err != nil {
return "", err
}
if msg.ParentToolUseID != nil || msg.Event.Type != "content_block_delta" || msg.Event.Delta.Type != "text_delta" {
return "", nil
}
return msg.Event.Delta.Text, nil
}
func (e Event) Result() (Result, error) {
res := Result{}
err := json.Unmarshal(e.Raw, &res)
@@ -250,6 +272,7 @@ func (s *Session) buildArgs(opts Options) ([]string, error) {
"--output-format", "stream-json",
"--input-format", "stream-json",
"--verbose",
"--include-partial-messages",
"--permission-mode", "bypassPermissions",
"--allow-dangerously-skip-permissions",
"--settings", string(settings),
@@ -260,6 +283,10 @@ func (s *Session) buildArgs(opts Options) ([]string, error) {
args = append(args, "--model", opts.Model)
}
if opts.Guidance != "" {
args = append(args, "--append-system-prompt", opts.Guidance)
}
if opts.SessionID != "" {
args = append(args, "--session-id="+opts.SessionID)
}
@@ -464,7 +491,9 @@ func (s *Session) handleLine(line []byte) {
if env.Type == "control_response" {
s.learnScrub(env.Response)
}
s.record("recv", line)
if env.Type != "stream_event" {
s.record("recv", line)
}
s.writeMu.Unlock()
switch env.Type {