mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
d2c3ebac1f
## Why `codex-core` still owns a growing amount of product-specific behavior. This PR starts the extraction path by introducing a small, typed first-party extension seam: features can install the contribution families they actually own, while the host keeps lifecycle and state ownership instead of pushing a broad service locator into the API. See the `examples/` for illustration ## Known limitations * Tool contract definition will be shared with core * Fragments must be extracted * Missing some contributors
51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
// All this file should be replaced by the existing fragment implementation ofc
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
pub enum PromptSlot {
|
|
DeveloperPolicy,
|
|
DeveloperCapabilities,
|
|
ContextualUser,
|
|
SeparateDeveloper,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub struct PromptFragment {
|
|
slot: PromptSlot,
|
|
text: String,
|
|
}
|
|
|
|
impl PromptFragment {
|
|
/// Creates a prompt fragment for the given slot.
|
|
pub fn new(slot: PromptSlot, text: impl Into<String>) -> Self {
|
|
Self {
|
|
slot,
|
|
text: text.into(),
|
|
}
|
|
}
|
|
|
|
/// Creates a developer-policy prompt fragment.
|
|
pub fn developer_policy(text: impl Into<String>) -> Self {
|
|
Self::new(PromptSlot::DeveloperPolicy, text)
|
|
}
|
|
|
|
/// Creates a developer-capabilities prompt fragment.
|
|
pub fn developer_capability(text: impl Into<String>) -> Self {
|
|
Self::new(PromptSlot::DeveloperCapabilities, text)
|
|
}
|
|
|
|
/// Creates a separate top-level developer prompt fragment.
|
|
pub fn separate_developer(text: impl Into<String>) -> Self {
|
|
Self::new(PromptSlot::SeparateDeveloper, text)
|
|
}
|
|
|
|
/// Returns the target prompt slot.
|
|
pub fn slot(&self) -> PromptSlot {
|
|
self.slot
|
|
}
|
|
|
|
/// Returns the model-visible text.
|
|
pub fn text(&self) -> &str {
|
|
&self.text
|
|
}
|
|
}
|