Skip to content

Commit a16537e

Browse files
authored
feat: Dynamic system prompt architecture with cortex-prompt-harness (#8)
* feat(prompt-harness): add dynamic tool injection support - Add ToolDefinition struct to context.rs with name, description, and optional category - Add tools field to PromptContext with add_tool() and with_tools() builder methods - Add build_dynamic_tools_section() function to sections.rs for markdown table rendering - Add with_tools() method to SystemPromptBuilder in builder.rs - Export ToolDefinition from lib.rs - Add comprehensive tests for all new functionality Tools are rendered as markdown tables, grouped by category when provided. * feat(prompt-harness): add CortexPromptBuilder for dynamic prompt construction - Add individual section constants extracted from CORTEX_MAIN_PROMPT: - SECTION_HEADER, SECTION_PRIME_DIRECTIVES, SECTION_COGNITIVE_ARCHITECTURE - SECTION_FAILURE_PROTOCOL, SECTION_CODE_DISCIPLINE, SECTION_QUALITY_CHECKPOINTS - SECTION_TOOLKIT, SECTION_RESPONSE_PATTERNS, SECTION_ANTI_PATTERNS, SECTION_OUTPUT_FORMAT - SECTION_NAMES constant listing all section names - Implement CortexPromptBuilder with fluent API: - new() creates builder with all default sections enabled - without_section() / with_section() to toggle sections - add_tool() / with_tools() to add custom tools to toolkit - with_custom_toolkit() to replace default toolkit entirely - add_custom_section() to append custom sections - is_section_enabled() / enabled_sections() for introspection - build() / build_with_token_estimate() for final output - Keep CORTEX_MAIN_PROMPT unchanged for backward compatibility - Add 24 comprehensive tests for the new builder - Export new types from prompts module * refactor(cortex-engine): use cortex-prompt-harness for system prompt * chore: remove cortex_prompt.txt (now in cortex-prompt-harness) - Remove cortex_prompt.txt from repository root - Update documentation in core.rs to reflect new architecture - System prompt is now centralized in cortex-prompt-harness crate The prompt content is now the canonical source in: cortex_prompt_harness::prompts::CORTEX_MAIN_PROMPT
1 parent f0bdd20 commit a16537e

11 files changed

Lines changed: 1297 additions & 277 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cortex_prompt.txt

Lines changed: 0 additions & 268 deletions
This file was deleted.

src/cortex-engine/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ cortex-hooks-ext = { path = "../cortex-hooks", package = "cortex-hooks" }
2828
cortex-share = { path = "../cortex-share" }
2929
cortex-plugins-ext = { path = "../cortex-plugins", package = "cortex-plugins" }
3030
cortex-batch = { path = "../cortex-batch" }
31+
cortex-prompt-harness = { path = "../cortex-prompt-harness" }
3132

3233
# New feature crates (Phase 2)
3334
cortex-ghost = { path = "../cortex-ghost" }

src/cortex-engine/src/prompt/system_prompt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub enum SystemPromptError {
1616

1717
pub type Result<T> = std::result::Result<T, SystemPromptError>;
1818

19-
const DEFAULT_SYSTEM_PROMPT: &str = include_str!("../../../../cortex_prompt.txt");
19+
const DEFAULT_SYSTEM_PROMPT: &str = cortex_prompt_harness::prompts::CORTEX_MAIN_PROMPT;
2020

2121
pub fn load_system_prompt(path: Option<&Path>) -> Result<String> {
2222
match path {

src/cortex-engine/src/session/prompt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::path::PathBuf;
44

55
use crate::config::Config;
66

7-
/// System prompt for the Cortex Agent - loaded from cortex_prompt.txt
8-
pub(crate) const SYSTEM_PROMPT: &str = include_str!("../../../../cortex_prompt.txt");
7+
/// System prompt for the Cortex Agent - loaded from cortex-prompt-harness
8+
pub(crate) const SYSTEM_PROMPT: &str = cortex_prompt_harness::prompts::CORTEX_MAIN_PROMPT;
99

1010
/// Build the system prompt for the agent.
1111
pub fn build_system_prompt(config: &Config) -> String {

0 commit comments

Comments
 (0)