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:
andrea.difonzo
2026-11-17 12:37:52 +01:00
parent e37a0deba9
commit 7c1c6dfa8d
10306 changed files with 748026 additions and 748088 deletions

View File

@@ -0,0 +1,76 @@
//! Check that multiline warnings omit payloads and preserve first-line rendering.
use std::collections::BTreeMap;
use std::sync::Arc;
use std::sync::Mutex;
use pretty_assertions::assert_eq;
use ratatui::style::Stylize;
use ratatui::text::Line;
use tracing::Event;
use tracing::Level;
use tracing::Subscriber;
use tracing::field::Field;
use tracing::field::Visit;
use tracing_subscriber::Layer;
use tracing_subscriber::layer::Context;
use tracing_subscriber::layer::SubscriberExt;
use super::ansi_escape_line;
#[derive(Debug, PartialEq, Eq)]
struct CapturedEvent {
level: Level,
fields: BTreeMap<String, String>,
}
impl Visit for CapturedEvent {
fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) {
self.fields
.insert(field.name().to_string(), format!("{value:?}"));
}
}
struct CaptureLayer(Arc<Mutex<Vec<CapturedEvent>>>);
impl<S: Subscriber> Layer<S> for CaptureLayer {
fn on_event(&self, event: &Event<'_>, _ctx: Context<'_, S>) {
let mut captured = CapturedEvent {
level: *event.metadata().level(),
fields: BTreeMap::new(),
};
event.record(&mut captured);
self.0.lock().expect("capture events").push(captured);
}
}
#[test]
fn multiline_warning_contains_counts_and_preserves_the_styled_first_line() {
let events = Arc::new(Mutex::new(Vec::new()));
let subscriber = tracing_subscriber::registry().with(CaptureLayer(Arc::clone(&events)));
let mut expected_events = Vec::new();
tracing::subscriber::with_default(subscriber, || {
for tail_bytes in [8, 128 * 1024] {
let tail = "x".repeat(tail_bytes);
let input = format!("\x1b[31mfirst\x1b[0m\n{tail}\nlast");
assert_eq!(ansi_escape_line(&input), Line::from("first".red()));
expected_events.push(CapturedEvent {
level: Level::WARN,
fields: BTreeMap::from([
("input_bytes".to_string(), input.len().to_string()),
("line_count".to_string(), "3".to_string()),
(
"message".to_string(),
"ansi_escape_line: expected a single line".to_string(),
),
]),
});
}
});
assert_eq!(
*events.lock().expect("read captured events"),
expected_events
);
}

View File

@@ -0,0 +1,66 @@
use ansi_to_tui::Error;
use ansi_to_tui::IntoText;
use ratatui::text::Line;
use ratatui::text::Text;
// Expand tabs in a best-effort way for transcript rendering.
// Tabs can interact poorly with left-gutter prefixes in our TUI and CLI
// transcript views (e.g., `nl` separates line numbers from content with a tab).
// Replacing tabs with spaces avoids odd visual artifacts without changing
// semantics for our use cases.
fn expand_tabs(s: &str) -> std::borrow::Cow<'_, str> {
if s.contains('\t') {
// Keep it simple: replace each tab with 4 spaces.
// We do not try to align to tab stops since most usages (like `nl`)
// look acceptable with a fixed substitution and this avoids stateful math
// across spans.
std::borrow::Cow::Owned(s.replace('\t', " "))
} else {
std::borrow::Cow::Borrowed(s)
}
}
/// This function should be used when the contents of `s` are expected to match
/// a single line. If multiple lines are found, a warning is logged and only the
/// first line is returned.
pub fn ansi_escape_line(s: &str) -> Line<'static> {
// Normalize tabs to spaces to avoid odd gutter collisions in transcript mode.
let s = expand_tabs(s);
let text = ansi_escape(&s);
match text.lines.as_slice() {
[] => "".into(),
[only] => only.clone(),
[first, rest @ ..] => {
tracing::warn!(
input_bytes = s.len(),
line_count = rest.len() + 1,
"ansi_escape_line: expected a single line"
);
first.clone()
}
}
}
pub fn ansi_escape(s: &str) -> Text<'static> {
// to_text() claims to be faster, but introduces complex lifetime issues
// such that it's not worth it.
match s.into_text() {
Ok(text) => text,
Err(err) => match err {
Error::NomError(message) => {
tracing::error!(
"ansi_to_tui NomError docs claim should never happen when parsing `{s}`: {message}"
);
panic!();
}
Error::Utf8Error(utf8error) => {
tracing::error!("Utf8Error: {utf8error}");
panic!();
}
},
}
}
#[cfg(test)]
#[path = "ansi_escape_tests.rs"]
mod tests;