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>
98 lines
3.2 KiB
Rust
98 lines
3.2 KiB
Rust
//! Composes synchronous review prompts from the host's captured context sections.
|
|
//! Full/delta selection, empty-transcript text, and cursor accounting preserve the existing layout.
|
|
|
|
use akode_guardian_context::CollectedContext;
|
|
use akode_guardian_context::ComposedContext;
|
|
use akode_guardian_context::ContextPresentation;
|
|
use akode_guardian_context::ContextProfile;
|
|
use akode_guardian_context::TranscriptCursor as GuardianTranscriptCursor;
|
|
use akode_guardian_context::TranscriptMode as GuardianPromptMode;
|
|
use akode_guardian_context::TranscriptSelection;
|
|
|
|
pub const GUARDIAN_TRANSCRIPT_START: &str = ">>> TRANSCRIPT START\n";
|
|
|
|
pub struct GuardianPromptItems {
|
|
pub context: ComposedContext,
|
|
pub transcript_cursor: GuardianTranscriptCursor,
|
|
pub node_repl_evidence_sequence: u64,
|
|
}
|
|
|
|
pub fn compose_guardian_prompt(
|
|
sections: CollectedContext,
|
|
profile: &ContextProfile,
|
|
mode: GuardianPromptMode,
|
|
history_version: u64,
|
|
session_id: &str,
|
|
node_repl_evidence_sequence: u64,
|
|
) -> anyhow::Result<GuardianPromptItems> {
|
|
let (offset, presentation, transcript_cursor) =
|
|
select_transcript(§ions, mode, history_version, session_id);
|
|
let context = akode_guardian_context::prepare_sync_context(
|
|
sections,
|
|
profile,
|
|
offset,
|
|
presentation,
|
|
akode_guardian_context::ContextBudgeting::Fixed,
|
|
)?;
|
|
Ok(GuardianPromptItems {
|
|
context,
|
|
transcript_cursor,
|
|
node_repl_evidence_sequence,
|
|
})
|
|
}
|
|
|
|
/// Prepares and composes any sync request after the host resolves reviewer/model facts.
|
|
pub async fn compose_guardian_prompt_with_preparation(
|
|
sections: CollectedContext,
|
|
profile: &ContextProfile,
|
|
mode: GuardianPromptMode,
|
|
history_version: u64,
|
|
session_id: &str,
|
|
node_repl_evidence_sequence: u64,
|
|
preparation: akode_guardian_context::SyncPreparation<'_>,
|
|
) -> anyhow::Result<GuardianPromptItems> {
|
|
let (offset, presentation, transcript_cursor) =
|
|
select_transcript(§ions, mode, history_version, session_id);
|
|
let context = akode_guardian_context::prepare_sync_context_with_facts(
|
|
sections,
|
|
profile,
|
|
offset,
|
|
presentation,
|
|
preparation,
|
|
)
|
|
.await?;
|
|
Ok(GuardianPromptItems {
|
|
context,
|
|
transcript_cursor,
|
|
node_repl_evidence_sequence,
|
|
})
|
|
}
|
|
|
|
fn select_transcript<'a>(
|
|
sections: &CollectedContext,
|
|
mode: GuardianPromptMode,
|
|
history_version: u64,
|
|
session_id: &'a str,
|
|
) -> (usize, ContextPresentation<'a>, GuardianTranscriptCursor) {
|
|
let (selection, transcript_cursor) =
|
|
mode.select(sections.transcript_entries(), history_version);
|
|
let (offset, presentation) = match selection {
|
|
TranscriptSelection::Full(_) => (0, ContextPresentation::SyncFull { session_id }),
|
|
TranscriptSelection::Delta { offset, .. } => {
|
|
(offset, ContextPresentation::SyncDelta { session_id })
|
|
}
|
|
};
|
|
(offset, presentation, transcript_cursor)
|
|
}
|
|
|
|
pub fn guardian_truncate_text(content: &str, token_cap: usize) -> (String, bool) {
|
|
(
|
|
akode_guardian_context::truncate_text(content, token_cap),
|
|
content.len() > akode_utils_output_truncation::approx_bytes_for_tokens(token_cap),
|
|
)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "prompt_tests.rs"]
|
|
mod tests;
|