mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
feat(cli/demo): add --demo developer message injection
This commit is contained in:
@@ -88,6 +88,10 @@ struct MultitoolCli {
|
||||
#[clap(long = "auto", global = true, default_value_t = false)]
|
||||
auto_drive: bool,
|
||||
|
||||
/// Developer-role message to prepend to every turn for demos.
|
||||
#[clap(long = "demo", global = true, value_name = "TEXT")]
|
||||
demo_developer_message: Option<String>,
|
||||
|
||||
#[clap(subcommand)]
|
||||
subcommand: Option<Subcommand>,
|
||||
}
|
||||
@@ -406,10 +410,12 @@ async fn cli_main(code_linux_sandbox_exe: Option<PathBuf>) -> anyhow::Result<()>
|
||||
config_overrides: root_config_overrides,
|
||||
mut interactive,
|
||||
auto_drive,
|
||||
demo_developer_message,
|
||||
subcommand,
|
||||
} = MultitoolCli::parse();
|
||||
|
||||
interactive.finalize_defaults();
|
||||
interactive.demo_developer_message = demo_developer_message.clone();
|
||||
|
||||
match subcommand {
|
||||
None => {
|
||||
@@ -439,6 +445,7 @@ async fn cli_main(code_linux_sandbox_exe: Option<PathBuf>) -> anyhow::Result<()>
|
||||
if auto_drive {
|
||||
exec_cli.auto_drive = true;
|
||||
}
|
||||
exec_cli.demo_developer_message = demo_developer_message.clone();
|
||||
prepend_config_flags(
|
||||
&mut exec_cli.config_overrides,
|
||||
root_config_overrides.clone(),
|
||||
@@ -450,6 +457,7 @@ async fn cli_main(code_linux_sandbox_exe: Option<PathBuf>) -> anyhow::Result<()>
|
||||
if !exec_cli.full_auto && !exec_cli.dangerously_bypass_approvals_and_sandbox {
|
||||
exec_cli.full_auto = true;
|
||||
}
|
||||
exec_cli.demo_developer_message = demo_developer_message.clone();
|
||||
prepend_config_flags(
|
||||
&mut exec_cli.config_overrides,
|
||||
root_config_overrides.clone(),
|
||||
|
||||
@@ -222,6 +222,7 @@ pub(crate) struct TurnContext {
|
||||
pub(crate) cwd: PathBuf,
|
||||
pub(crate) base_instructions: Option<String>,
|
||||
pub(crate) user_instructions: Option<String>,
|
||||
pub(crate) demo_developer_message: Option<String>,
|
||||
pub(crate) compact_prompt_override: Option<String>,
|
||||
pub(crate) approval_policy: AskForApproval,
|
||||
pub(crate) sandbox_policy: SandboxPolicy,
|
||||
@@ -999,6 +1000,7 @@ impl Codex {
|
||||
notify: config.notify.clone(),
|
||||
cwd: config.cwd.clone(),
|
||||
resume_path: resume_path.clone(),
|
||||
demo_developer_message: config.demo_developer_message.clone(),
|
||||
};
|
||||
|
||||
let config = Arc::new(config);
|
||||
@@ -1364,6 +1366,7 @@ pub(crate) struct Session {
|
||||
cwd: PathBuf,
|
||||
base_instructions: Option<String>,
|
||||
user_instructions: Option<String>,
|
||||
demo_developer_message: Option<String>,
|
||||
compact_prompt_override: Option<String>,
|
||||
approval_policy: AskForApproval,
|
||||
sandbox_policy: SandboxPolicy,
|
||||
@@ -2131,6 +2134,7 @@ impl Session {
|
||||
cwd: self.cwd.clone(),
|
||||
base_instructions: self.base_instructions.clone(),
|
||||
user_instructions: self.user_instructions.clone(),
|
||||
demo_developer_message: self.demo_developer_message.clone(),
|
||||
compact_prompt_override: self.compact_prompt_override.clone(),
|
||||
approval_policy: self.approval_policy,
|
||||
sandbox_policy: self.sandbox_policy.clone(),
|
||||
@@ -4263,6 +4267,7 @@ async fn submission_loop(
|
||||
notify,
|
||||
cwd,
|
||||
resume_path,
|
||||
demo_developer_message,
|
||||
} => {
|
||||
debug!(
|
||||
"Configuring session: model={model}; provider={provider:?}; resume={resume_path:?}"
|
||||
@@ -4596,6 +4601,7 @@ async fn submission_loop(
|
||||
tx_event: tx_event.clone(),
|
||||
user_instructions: effective_user_instructions.clone(),
|
||||
base_instructions,
|
||||
demo_developer_message: demo_developer_message.clone(),
|
||||
compact_prompt_override: config.compact_prompt_override.clone(),
|
||||
approval_policy,
|
||||
sandbox_policy,
|
||||
@@ -5131,6 +5137,7 @@ async fn spawn_review_thread(
|
||||
cwd: parent_turn_context.cwd.clone(),
|
||||
base_instructions: Some(REVIEW_PROMPT.to_string()),
|
||||
user_instructions: None,
|
||||
demo_developer_message: parent_turn_context.demo_developer_message.clone(),
|
||||
compact_prompt_override: parent_turn_context.compact_prompt_override.clone(),
|
||||
approval_policy: parent_turn_context.approval_policy,
|
||||
sandbox_policy: parent_turn_context.sandbox_policy.clone(),
|
||||
@@ -5749,7 +5756,11 @@ async fn run_turn(
|
||||
status_items, // Include status items with this request
|
||||
base_instructions_override: tc.base_instructions.clone(),
|
||||
include_additional_instructions: true,
|
||||
prepend_developer_messages: Vec::new(),
|
||||
prepend_developer_messages: tc
|
||||
.demo_developer_message
|
||||
.clone()
|
||||
.into_iter()
|
||||
.collect(),
|
||||
text_format: tc.text_format_override.clone(),
|
||||
model_override: None,
|
||||
model_family_override: None,
|
||||
|
||||
@@ -272,6 +272,10 @@ pub struct Config {
|
||||
/// User-provided instructions from AGENTS.md.
|
||||
pub user_instructions: Option<String>,
|
||||
|
||||
/// Optional developer-role message to prepend to every turn for demos.
|
||||
/// Set by the CLI via `--demo`; not loaded from disk.
|
||||
pub demo_developer_message: Option<String>,
|
||||
|
||||
/// Base instructions override.
|
||||
pub base_instructions: Option<String>,
|
||||
|
||||
@@ -2898,6 +2902,7 @@ impl Config {
|
||||
notify: cfg.notify,
|
||||
notices: cfg.notice.unwrap_or_default(),
|
||||
user_instructions,
|
||||
demo_developer_message: None,
|
||||
base_instructions,
|
||||
compact_prompt_override,
|
||||
mcp_servers: cfg.mcp_servers,
|
||||
|
||||
@@ -116,6 +116,12 @@ pub enum Op {
|
||||
/// Path to a rollout file to resume from.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
resume_path: Option<std::path::PathBuf>,
|
||||
|
||||
/// Optional developer-role message to prepend to every turn for demos.
|
||||
/// This is a CLI-only knob; it is not persisted in config files.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(default)]
|
||||
demo_developer_message: Option<String>,
|
||||
},
|
||||
|
||||
/// Abort current task.
|
||||
|
||||
@@ -76,6 +76,11 @@ pub struct Cli {
|
||||
#[clap(skip)]
|
||||
pub config_overrides: CliConfigOverrides,
|
||||
|
||||
/// Optional developer-role message to prepend to every turn for demos.
|
||||
/// Set by the multitool root CLI via `--demo`.
|
||||
#[clap(skip)]
|
||||
pub demo_developer_message: Option<String>,
|
||||
|
||||
/// Specifies color settings for use in the output.
|
||||
#[arg(long = "color", value_enum, default_value_t = Color::Auto)]
|
||||
pub color: Color,
|
||||
|
||||
@@ -276,6 +276,7 @@ pub async fn run_main(cli: Cli, code_linux_sandbox_exe: Option<PathBuf>) -> anyh
|
||||
};
|
||||
|
||||
let mut config = Config::load_with_cli_overrides(cli_kv_overrides, overrides)?;
|
||||
config.demo_developer_message = cli.demo_developer_message.clone();
|
||||
let slash_context = SlashContext {
|
||||
agents: &config.agents,
|
||||
subagent_commands: &config.subagent_commands,
|
||||
|
||||
@@ -1628,6 +1628,7 @@ fn configure_session_op_from_config(config: &Config) -> Op {
|
||||
notify: config.notify.clone(),
|
||||
cwd: config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: config.demo_developer_message.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20634,6 +20634,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
self.submit_op(op);
|
||||
|
||||
@@ -21260,6 +21261,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
self.submit_op(op);
|
||||
}
|
||||
@@ -21284,6 +21286,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
self.submit_op(op);
|
||||
}
|
||||
@@ -21488,6 +21491,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
let _ = self.code_op_tx.send(op);
|
||||
} else {
|
||||
@@ -21630,6 +21634,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
|
||||
self.submit_op(op);
|
||||
@@ -21669,6 +21674,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
|
||||
self.submit_op(op);
|
||||
@@ -22719,6 +22725,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
self.submit_op(op);
|
||||
|
||||
@@ -34163,6 +34170,7 @@ impl ChatWidget<'_> {
|
||||
notify: self.config.notify.clone(),
|
||||
cwd: self.config.cwd.clone(),
|
||||
resume_path: None,
|
||||
demo_developer_message: self.config.demo_developer_message.clone(),
|
||||
};
|
||||
self.submit_op(op);
|
||||
|
||||
|
||||
@@ -99,6 +99,11 @@ pub struct Cli {
|
||||
#[clap(skip)]
|
||||
pub config_overrides: CliConfigOverrides,
|
||||
|
||||
/// Optional developer-role message to prepend to every turn for demos.
|
||||
/// Set by the multitool root CLI via `--demo`.
|
||||
#[clap(skip)]
|
||||
pub demo_developer_message: Option<String>,
|
||||
|
||||
/// Start in resume picker mode when true (used by `code resume`).
|
||||
#[clap(skip)]
|
||||
pub resume_picker: bool,
|
||||
|
||||
+10
-2
@@ -480,6 +480,8 @@ pub async fn run_main(
|
||||
}
|
||||
};
|
||||
|
||||
config.demo_developer_message = cli.demo_developer_message.clone();
|
||||
|
||||
let cli_model_override = cli.model.is_some()
|
||||
|| cli_kv_overrides
|
||||
.iter()
|
||||
@@ -508,7 +510,10 @@ pub async fn run_main(
|
||||
cli_kv_overrides.clone(),
|
||||
overrides.clone(),
|
||||
) {
|
||||
Ok(updated) => config = updated,
|
||||
Ok(updated) => {
|
||||
config = updated;
|
||||
config.demo_developer_message = cli.demo_developer_message.clone();
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error reloading configuration: {err}");
|
||||
std::process::exit(1);
|
||||
@@ -532,7 +537,10 @@ pub async fn run_main(
|
||||
cli_kv_overrides.clone(),
|
||||
overrides.clone(),
|
||||
) {
|
||||
Ok(updated) => config = updated,
|
||||
Ok(updated) => {
|
||||
config = updated;
|
||||
config.demo_developer_message = cli.demo_developer_message.clone();
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error reloading configuration: {err}");
|
||||
std::process::exit(1);
|
||||
|
||||
Reference in New Issue
Block a user