feat(cli)!: rename --prompt to --temp-role
Completes the .prompt/.temp-role split: --prompt set an ad-hoc system role, which is what .temp-role now means everywhere. The --prompt name is left unbound so a future one-shot MCP prompt flag can take it with properly designed non-interactive semantics. use_prompt follows the rename as use_temp_role. BREAKING CHANGE: invocations using --prompt <text> must switch to --temp-role <text>; clap rejects the old flag loudly.
This commit is contained in:
+6
-6
@@ -47,7 +47,7 @@ pub enum McpScopeArg {
|
|||||||
.args(["sandbox", "fresh"])
|
.args(["sandbox", "fresh"])
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.conflicts_with_all([
|
.conflicts_with_all([
|
||||||
"model", "prompt", "role", "session", "agent", "rag", "rebuild_rag",
|
"model", "temp_role", "role", "session", "agent", "rag", "rebuild_rag",
|
||||||
"macro_name", "execute", "code", "file", "no_stream", "no_memory",
|
"macro_name", "execute", "code", "file", "no_stream", "no_memory",
|
||||||
"init_memory", "dry_run", "info", "build_tools", "install",
|
"init_memory", "dry_run", "info", "build_tools", "install",
|
||||||
"install_builtins", "sync_models", "list_models", "list_roles",
|
"install_builtins", "sync_models", "list_models", "list_roles",
|
||||||
@@ -70,9 +70,9 @@ pub struct Cli {
|
|||||||
/// Select a LLM model
|
/// Select a LLM model
|
||||||
#[arg(short, long, add = ArgValueCompleter::new(model_completer))]
|
#[arg(short, long, add = ArgValueCompleter::new(model_completer))]
|
||||||
pub model: Option<String>,
|
pub model: Option<String>,
|
||||||
/// Use the system prompt
|
/// Set a temporary role (an ad-hoc system prompt) for this invocation
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub prompt: Option<String>,
|
pub temp_role: Option<String>,
|
||||||
/// Select a role
|
/// Select a role
|
||||||
#[arg(short, long, add = ArgValueCompleter::new(role_completer))]
|
#[arg(short, long, add = ArgValueCompleter::new(role_completer))]
|
||||||
pub role: Option<String>,
|
pub role: Option<String>,
|
||||||
@@ -705,9 +705,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_prompt_flag() {
|
fn parse_temp_role_flag() {
|
||||||
let cli = parse(&["--prompt", "be a pirate"]);
|
let cli = parse(&["--temp-role", "be a pirate"]);
|
||||||
assert_eq!(cli.prompt, Some("be a pirate".to_string()));
|
assert_eq!(cli.temp_role, Some("be a pirate".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -2341,7 +2341,7 @@ impl RequestContext {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn use_prompt(&mut self, _app: &AppConfig, prompt: &str) -> Result<()> {
|
pub fn use_temp_role(&mut self, _app: &AppConfig, prompt: &str) -> Result<()> {
|
||||||
let mut role = Role::new(TEMP_ROLE_NAME, prompt);
|
let mut role = Role::new(TEMP_ROLE_NAME, prompt);
|
||||||
role.set_model(self.current_model().clone());
|
role.set_model(self.current_model().clone());
|
||||||
self.use_role_obj(role)
|
self.use_role_obj(role)
|
||||||
@@ -4852,10 +4852,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn use_prompt_creates_temp_role() {
|
fn use_temp_role_creates_temp_role() {
|
||||||
let mut ctx = create_test_ctx();
|
let mut ctx = create_test_ctx();
|
||||||
let app = ctx.app.config.clone();
|
let app = ctx.app.config.clone();
|
||||||
ctx.use_prompt(&app, "you are a pirate").unwrap();
|
ctx.use_temp_role(&app, "you are a pirate").unwrap();
|
||||||
assert!(ctx.role.is_some());
|
assert!(ctx.role.is_some());
|
||||||
assert_eq!(ctx.role.as_ref().unwrap().name(), "temp");
|
assert_eq!(ctx.role.as_ref().unwrap().name(), "temp");
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
+2
-2
@@ -380,8 +380,8 @@ async fn run(
|
|||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
let app: Arc<AppConfig> = Arc::clone(&ctx.app.config);
|
let app: Arc<AppConfig> = Arc::clone(&ctx.app.config);
|
||||||
if let Some(prompt) = &cli.prompt {
|
if let Some(prompt) = &cli.temp_role {
|
||||||
ctx.use_prompt(app.as_ref(), prompt)?;
|
ctx.use_temp_role(app.as_ref(), prompt)?;
|
||||||
} else if let Some(name) = &cli.role {
|
} else if let Some(name) = &cli.role {
|
||||||
ctx.use_role(app.as_ref(), name, abort_signal.clone())
|
ctx.use_role(app.as_ref(), name, abort_signal.clone())
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
+1
-1
@@ -819,7 +819,7 @@ pub async fn run_repl_command(
|
|||||||
".temp-role" => match args {
|
".temp-role" => match args {
|
||||||
Some(text) => {
|
Some(text) => {
|
||||||
let app = Arc::clone(&ctx.app.config);
|
let app = Arc::clone(&ctx.app.config);
|
||||||
ctx.use_prompt(app.as_ref(), text)?;
|
ctx.use_temp_role(app.as_ref(), text)?;
|
||||||
}
|
}
|
||||||
None => println!("Usage: .temp-role <text>..."),
|
None => println!("Usage: .temp-role <text>..."),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user