mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
## Why `codex_core` is consistently a bottleneck for incremental builds during iteration. The simplest fix is to make the crate smaller. ## Summary `codex-core` owns several reusable prompt renderers and static prompt assets, which makes the crate harder to split apart. Rename `codex-review-prompts` to `codex-prompts` and move shared review, goal, permissions, compaction, realtime, hierarchical AGENTS.md, and `apply_patch` prompts into it. Move prompt-only tests and update consumers and `CODEOWNERS`. ## Validation - `just test -p codex-prompts -p codex-apply-patch` - `just test -p codex-core prompt_caching` - Bazel builds for the affected crates
37 lines
1.3 KiB
Rust
37 lines
1.3 KiB
Rust
use codex_utils_template::Template;
|
|
use std::borrow::Cow;
|
|
use std::sync::LazyLock;
|
|
|
|
const REVIEW_EXIT_SUCCESS_TEMPLATE_TEXT: &str =
|
|
include_str!("../templates/review/exit_success.xml");
|
|
const REVIEW_EXIT_INTERRUPTED_TEMPLATE_TEXT: &str =
|
|
include_str!("../templates/review/exit_interrupted.xml");
|
|
|
|
static REVIEW_EXIT_SUCCESS_TEMPLATE: LazyLock<Template> = LazyLock::new(|| {
|
|
let normalized = normalize_review_template_line_endings(REVIEW_EXIT_SUCCESS_TEMPLATE_TEXT);
|
|
Template::parse(normalized.as_ref())
|
|
.unwrap_or_else(|err| panic!("review exit success template must parse: {err}"))
|
|
});
|
|
|
|
pub fn render_review_exit_success(results: &str) -> String {
|
|
REVIEW_EXIT_SUCCESS_TEMPLATE
|
|
.render([("results", results)])
|
|
.unwrap_or_else(|err| panic!("review exit success template must render: {err}"))
|
|
}
|
|
|
|
pub fn render_review_exit_interrupted() -> String {
|
|
normalize_review_template_line_endings(REVIEW_EXIT_INTERRUPTED_TEMPLATE_TEXT).into_owned()
|
|
}
|
|
|
|
fn normalize_review_template_line_endings(template: &str) -> Cow<'_, str> {
|
|
if template.contains('\r') {
|
|
Cow::Owned(template.replace("\r\n", "\n").replace('\r', "\n"))
|
|
} else {
|
|
Cow::Borrowed(template)
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "review_exit_tests.rs"]
|
|
mod review_exit_tests;
|