Problem
The handle_prompt() function in main.rs (the -P / --prompt non-interactive path) manually constructs an AgentConfig and uses a hardcoded system prompt:
system_prompt: Some("You are Codi, a helpful AI coding assistant.".to_string()),
This means systemPromptAdditions and projectContext from .codi.json are ignored when running in non-interactive mode, even though the ResolvedConfig is available and other config fields (auto_approve, no_tools, max_context_tokens, etc.) are correctly wired.
Expected Behavior
-P mode should use the same build_system_prompt() logic as the interactive TUI, incorporating:
config.system_prompt_additions
config.project_context
Proposed Fix
Extract the system prompt building logic from App::build_system_prompt() into a standalone function (or a method on ResolvedConfig) so both run_repl and handle_prompt can share it. For example:
fn build_system_prompt(config: &ResolvedConfig) -> String {
let mut prompt = "You are Codi, a helpful AI coding assistant.".to_string();
if let Some(ref additions) = config.system_prompt_additions {
prompt.push_str("\n\n");
prompt.push_str(additions);
}
if let Some(ref ctx) = config.project_context {
prompt.push_str("\n\n## Project Context\n");
prompt.push_str(ctx);
}
prompt
}
Related
PR #261 — Wire config options, context compaction, and auto-index on startup
#262 — with_provider/with_provider_and_path bypass config wiring (same category of issue)
Problem
The
handle_prompt()function inmain.rs(the-P/--promptnon-interactive path) manually constructs anAgentConfigand uses a hardcoded system prompt:This means
systemPromptAdditionsandprojectContextfrom.codi.jsonare ignored when running in non-interactive mode, even though theResolvedConfigis available and other config fields (auto_approve,no_tools,max_context_tokens, etc.) are correctly wired.Expected Behavior
-Pmode should use the samebuild_system_prompt()logic as the interactive TUI, incorporating:config.system_prompt_additionsconfig.project_contextProposed Fix
Extract the system prompt building logic from
App::build_system_prompt()into a standalone function (or a method onResolvedConfig) so bothrun_replandhandle_promptcan share it. For example:Related
PR #261 — Wire config options, context compaction, and auto-index on startup
#262 —
with_provider/with_provider_and_pathbypass config wiring (same category of issue)