Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
94
akode-rs/ext/extension-api/src/contributors/prompt.rs
Normal file
94
akode-rs/ext/extension-api/src/contributors/prompt.rs
Normal file
@@ -0,0 +1,94 @@
|
||||
//! Extension prompt placement with content and producer attribution kept together.
|
||||
|
||||
use akode_context_fragments::AnnotatedContent;
|
||||
use akode_context_fragments::ContextualUserFragment;
|
||||
use akode_context_fragments::RenderedFragment;
|
||||
use akode_protocol::models::ContentItem;
|
||||
use akode_protocol::models::ContentItemKind;
|
||||
use akode_protocol::models::ContentItemMetadata;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum PromptSlot {
|
||||
DeveloperPolicy,
|
||||
DeveloperCapabilities,
|
||||
/// Content inside the context-window message, supplied by `contribute_thread_context`.
|
||||
ContextWindow,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PromptFragment {
|
||||
slot: PromptSlot,
|
||||
content: AnnotatedContent,
|
||||
}
|
||||
|
||||
impl PromptFragment {
|
||||
/// Places a contextual fragment in the prompt, preserving its content, kind, and source.
|
||||
/// The slot determines placement within the developer message, regardless of its original role.
|
||||
pub fn from_fragment(slot: PromptSlot, fragment: &impl ContextualUserFragment) -> Self {
|
||||
Self {
|
||||
slot,
|
||||
content: fragment.render_fragment().into_parts().1,
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates harness-provided context for the given slot.
|
||||
pub fn new(slot: PromptSlot, text: impl Into<String>, content_kind: ContentItemKind) -> Self {
|
||||
Self {
|
||||
slot,
|
||||
content: AnnotatedContent::text(text, content_kind, ContentItemMetadata::harness()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates tool-supplied context without changing its prompt placement.
|
||||
pub fn tool(
|
||||
slot: PromptSlot,
|
||||
text: impl Into<String>,
|
||||
content_kind: ContentItemKind,
|
||||
namespace: String,
|
||||
) -> Self {
|
||||
Self {
|
||||
slot,
|
||||
content: AnnotatedContent::text(
|
||||
text,
|
||||
content_kind,
|
||||
ContentItemMetadata::tool(Some(namespace.into())),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a developer-policy prompt fragment.
|
||||
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>, content_kind: ContentItemKind) -> Self {
|
||||
Self::new(PromptSlot::DeveloperCapabilities, text, content_kind)
|
||||
}
|
||||
|
||||
/// Returns the target prompt slot.
|
||||
pub fn slot(&self) -> PromptSlot {
|
||||
self.slot
|
||||
}
|
||||
|
||||
/// Returns the model-visible content.
|
||||
pub fn content(&self) -> &ContentItem {
|
||||
self.content.content()
|
||||
}
|
||||
|
||||
/// Returns the producer-owned classification of the model-visible content.
|
||||
pub fn content_kind(&self) -> &ContentItemKind {
|
||||
self.content.kind()
|
||||
}
|
||||
|
||||
/// Consumes the placement wrapper when assembling a shared context message.
|
||||
pub fn into_content(self) -> AnnotatedContent {
|
||||
self.content
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PromptFragment> for RenderedFragment {
|
||||
fn from(fragment: PromptFragment) -> Self {
|
||||
Self::new("developer", fragment.content)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user