Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/agent_instructions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const BEAR_INSTRUCTIONS: &str = "You are working in Bear, a desktop app for running coding agents.

Keep the conversation’s checkout on its current branch unless the task calls for switching or renaming it. Use git show or git diff to inspect other branches.

Make the final reply self-contained. Include the outcome, what you verified, and any blockers the user needs to know about.";

const FOLLOW_UP_INSTRUCTIONS: &str = r#"After answering, suggest up to three follow-up actions when the result makes a specific next step useful. Prefer one and put the most useful action first. Ground each suggestion in the current task and known state.

Suggest committing verified, uncommitted changes or opening a PR when the branch is ready for review and has no open PR. If opening the PR would include the same changes, suggest that action alone. Other useful follow-ups include addressing a specific blocker outside the requested work or choosing a concrete option when progress depends on the user's decision.

Skip generic advice, speculative or overlapping options, and work already requested or completed. Omit the block when no action fits.

Append the block at the very end on its own line, without a code fence or any text after it. Each <label> is a clear action in 1–3 words. Each <prompt> is the full follow-up written in the user's voice, with as much context as needed. Use XML escaping inside fields, including &amp; for &, &lt; for <, and &gt; for >. Repeat <follow_up> for each option.

<follow_ups>
<follow_up>
<label>Commit changes</label>
<prompt>Commit the verified changes from this task with a descriptive message.</prompt>
</follow_up>
</follow_ups>"#;

#[derive(Debug)]
pub(crate) struct AgentInstructions(String);

impl AgentInstructions {
pub(crate) fn new(prompt_suggestions: bool) -> Self {
let mut instructions = BEAR_INSTRUCTIONS.to_owned();
if prompt_suggestions {
instructions.push_str("\n\n");
instructions.push_str(FOLLOW_UP_INSTRUCTIONS);
}
Self(instructions)
}
}

impl huggler::AgentText for AgentInstructions {
fn developer_instructions(&self) -> Option<&str> {
Some(&self.0)
}
}
20 changes: 0 additions & 20 deletions src/conversation/follow_ups.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
#[derive(Debug)]
pub(crate) struct FollowUpInstructions;

impl huggler::AgentText for FollowUpInstructions {
fn developer_instructions(&self) -> Option<&str> {
Some(
r#"Write your final answer as usual. If the conversation strongly suggests a concrete next prompt the user is very likely to send, append up to three distinct options. Rank them by likelihood. Skip generic advice, speculative ideas, and work the user already asked you to complete. If unsure, omit the entire block.

Append the block at the very end on its own line, without a code fence or any text after it. Each <label> is a clear action in 1–3 words. Each <prompt> is the full follow-up written in the user's voice, with as much context as needed. Use XML escaping inside fields, including &amp; for &, &lt; for <, and &gt; for >. Repeat <follow_up> for each option.

<follow_ups>
<follow_up>
<label>Review changes</label>
<prompt>Review the changes you just made against the original requirements and flag any regressions.</prompt>
</follow_up>
</follow_ups>"#,
)
}
}

use roxmltree::{Document, Node};

const START: &str = "\n<follow_ups>";
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ macro_rules! control {
}};
}

mod agent_instructions;
mod assets;
mod changes;
mod file_icons;
Expand Down Expand Up @@ -100,9 +101,10 @@ fn main() -> Result<()> {
};
let mut options = paths.runtime_options()?;
options.agent_tools = true;
if std::env::var("HUGGLER_PROMPT_SUGGESTIONS").as_deref() != Ok("0") {
options.output.text = Arc::new(conversation::follow_ups::FollowUpInstructions);
}
let prompt_suggestions = std::env::var("HUGGLER_PROMPT_SUGGESTIONS").as_deref() != Ok("0");
options.output.text = Arc::new(agent_instructions::AgentInstructions::new(
prompt_suggestions,
));
options.codex.workspace_write = true;
let state = paths.state_dir();
options.codex.executable = std::env::var_os("HUGGLER_CODEX")
Expand Down
Loading