mirror of
https://github.com/openai/codex.git
synced 2026-11-23 15:18:14 +00:00
Require content kinds for extension prompt fragments (#40177)
## What changed - Require each `PromptFragment` to include a producer-owned `ContentItemKind`. - Re-export `ContentItemKind` from `codex_extension_api` and assign stable kinds to skills, memories, examples, and test contributors. - Limit prompt slots to developer policy and developer capabilities, and combine contributed fragments into a single developer update. ## Testing - Update extension registry tests to verify fragment ordering with the new content-kind metadata. GitOrigin-RevId: ef8624a9b4ae9dce025bca9c0954d91dd8075e85
This commit is contained in:
1 parent
eff640f458
commit
546eed94ac
9 files changed
+67
-83
No files matched your search
@@ -1,41 +1,38 @@
|
||||
// All this file should be replaced by the existing fragment implementation ofc
|
||||
|
||||
use codex_protocol::models::ContentItemKind;
|
||||
|
||||
#[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,
|
||||
content_kind: ContentItemKind,
|
||||
}
|
||||
|
||||
impl PromptFragment {
|
||||
/// Creates a prompt fragment for the given slot.
|
||||
pub fn new(slot: PromptSlot, text: impl Into<String>) -> Self {
|
||||
pub fn new(slot: PromptSlot, text: impl Into<String>, content_kind: ContentItemKind) -> Self {
|
||||
Self {
|
||||
slot,
|
||||
text: text.into(),
|
||||
content_kind,
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a developer-policy prompt fragment.
|
||||
pub fn developer_policy(text: impl Into<String>) -> Self {
|
||||
Self::new(PromptSlot::DeveloperPolicy, text)
|
||||
pub fn developer_policy(text: impl Into<String>, content_kind: ContentItemKind) -> Self {
|
||||
Self::new(PromptSlot::DeveloperPolicy, text, content_kind)
|
||||
}
|
||||
|
||||
/// 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)
|
||||
pub fn developer_capability(text: impl Into<String>, content_kind: ContentItemKind) -> Self {
|
||||
Self::new(PromptSlot::DeveloperCapabilities, text, content_kind)
|
||||
}
|
||||
|
||||
/// Returns the target prompt slot.
|
||||
@@ -47,4 +44,9 @@ impl PromptFragment {
|
||||
pub fn text(&self) -> &str {
|
||||
&self.text
|
||||
}
|
||||
|
||||
/// Returns the producer-owned classification of the model-visible text.
|
||||
pub fn content_kind(&self) -> &ContentItemKind {
|
||||
&self.content_kind
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user