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
+63
View File
@@ -0,0 +1,63 @@
package agents
import (
"context"
"encoding/json"
"regexp"
"g.fc.run/misc/byre/internal/claude"
)
const guidance = `You are running inside byre. The human reads your work in byre's web UI, not a terminal.
- Ask every question with mcp__byre__ask_human, never in prose.
- End every turn with a short final message for the human: what you did, anything you departed from in the plan or instructions, risks, and what's next. byre shows it as the turn's summary in the transcript and the inbox. State every departure from the plan.
- Don't commit. byre commits everything in the worktree at the end of each turn, using the turn's final message.
- Don't push, don't switch or touch other branches, and don't run git maintenance (gc, prune, worktree prune). byre handles merging and pushing.`
const proseQuestionNudge = "Your final message asks the human something in prose. Ask it with mcp__byre__ask_human " +
"(context, question, options, recommended_option, why_blocked), then end your turn with a short summary."
var (
fencedCode = regexp.MustCompile("(?s)```.*?```")
inlineCode = regexp.MustCompile("`[^`\n]*`")
quoted = regexp.MustCompile(`"[^"\n]*"|“[^”\n]*”`)
blockquote = regexp.MustCompile(`(?m)^\s*>.*$`)
endsQuestion = regexp.MustCompile(`\?[*_)\]]*(\s|$)`)
)
func asksQuestion(text string) bool {
text = fencedCode.ReplaceAllString(text, "")
text = inlineCode.ReplaceAllString(text, "")
text = quoted.ReplaceAllString(text, "")
text = blockquote.ReplaceAllString(text, "")
return endsQuestion.MatchString(text)
}
func (m *Manager) bounceProseQuestion(l *live) claude.HookFunc {
return func(ctx context.Context, input json.RawMessage) (map[string]any, error) {
in := struct {
LastAssistantMessage string `json:"last_assistant_message"`
}{}
err := json.Unmarshal(input, &in)
if err != nil {
return nil, err
}
m.mu.Lock()
defer m.mu.Unlock()
if l.asked || l.bounced || l.compacting || !asksQuestion(in.LastAssistantMessage) {
return map[string]any{}, nil
}
l.bounced = true
return map[string]any{"decision": "block", "reason": proseQuestionNudge}, nil
}
}
func remindGuidance(ctx context.Context, input json.RawMessage) (map[string]any, error) {
return map[string]any{
"hookSpecificOutput": map[string]any{
"hookEventName": "UserPromptSubmit",
"additionalContext": guidance,
},
}, nil
}