feat: inject global rules into AI system prompt and fix Rules UI seeding

- Load global rules (AIFact/AIMemory) from local CloudModel and inject
  them into the Bedrock/OpenAI system prompt as a '## Global Rules' section
  when memory is enabled.
- Fix rule seeding: always re-seed predefined rules when the CloudModel has
  none, regardless of the has_seeded_predefined_rules flag (handles case
  where flag was set but rules never persisted due to prior missing owner).
- Rename /context slash command to /copy-context: dumps the full context
  window (global rules, progressive summary, message history) to the
  clipboard for debugging.
This commit is contained in:
Ryan Ward
2026-07-16 12:25:56 -05:00
parent 66ef451115
commit 3d2d90fd4e
10 changed files with 188 additions and 15 deletions
+14 -1
View File
@@ -954,7 +954,7 @@ fn collect_tool_result_ids(content: &MessageContent, ids: &mut std::collections:
}
}
pub fn extract_system_prompt(request: &api::Request) -> Option<String> {
pub fn extract_system_prompt(request: &api::Request, global_rules: &[(String, String)]) -> Option<String> {
let mut prompt = String::with_capacity(2048);
prompt.push_str("You are Galaxy, an AI coding assistant embedded in a terminal application. You help users with software engineering tasks including writing code, debugging, explaining concepts, and navigating codebases.\n\n");
@@ -1009,6 +1009,19 @@ pub fn extract_system_prompt(request: &api::Request) -> Option<String> {
}
}
// Inject global rules from the local CloudModel (stored as AIFact/AIMemory)
if !global_rules.is_empty() {
prompt.push_str("## Global Rules\n");
prompt.push_str("The following rules have been configured by the user and should be followed:\n\n");
for (name, content) in global_rules {
if !name.is_empty() {
prompt.push_str(&format!("### {}\n", name));
}
prompt.push_str(content);
prompt.push_str("\n\n");
}
}
prompt.push_str("## Tool Usage\n");
prompt.push_str("You have been given every tool you need to complete your tasks. Use them to achieve results with as few calls and as little back-and-forth as possible.\n\n");
prompt.push_str("**How to choose tools:**\n");