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,97 @@
#[path = "enabled_extensions/shared_state_extension.rs"]
mod shared_state_extension;
use std::future::Future;
use std::pin::pin;
use std::task::Context;
use std::task::Poll;
use std::task::Waker;
use akode_extension_api::ExtensionData;
use akode_extension_api::ExtensionRegistryBuilder;
use shared_state_extension::recorded_style_contributions;
use shared_state_extension::recorded_usage_contributions;
fn main() {
// 1. Install the contributors for the thread-start input type this host exposes.
let mut builder = ExtensionRegistryBuilder::<()>::new();
shared_state_extension::install(&mut builder);
let registry = builder.build();
// 2. The host decides which stores are shared.
let session_store = ExtensionData::new("session");
let first_thread_store = ExtensionData::new("thread-1");
let second_thread_store = ExtensionData::new("thread-2");
// 3. Reusing the same session store shares session state across threads.
let first_thread_fragments = block_on_ready(contribute_prompt(
&registry,
&session_store,
&first_thread_store,
));
block_on_ready(contribute_prompt(
&registry,
&session_store,
&first_thread_store,
));
block_on_ready(contribute_prompt(
&registry,
&session_store,
&second_thread_store,
));
println!("first prompt fragments: {}", first_thread_fragments.len());
println!(
"session style contributions: {}",
recorded_style_contributions(&session_store)
);
println!(
"session usage contributions: {}",
recorded_usage_contributions(&session_store)
);
println!(
"first thread style contributions: {}",
recorded_style_contributions(&first_thread_store)
);
println!(
"first thread usage contributions: {}",
recorded_usage_contributions(&first_thread_store)
);
println!(
"second thread style contributions: {}",
recorded_style_contributions(&second_thread_store)
);
println!(
"second thread usage contributions: {}",
recorded_usage_contributions(&second_thread_store)
);
}
async fn contribute_prompt(
registry: &akode_extension_api::ExtensionRegistry<()>,
session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<akode_extension_api::PromptFragment> {
let mut fragments = Vec::new();
for contributor in registry.context_contributors() {
fragments.extend(
contributor
.contribute_thread_context(session_store, thread_store)
.await,
);
}
fragments
}
fn block_on_ready<F>(future: F) -> F::Output
where
F: Future,
{
let waker = Waker::noop();
let mut context = Context::from_waker(waker);
let mut future = pin!(future);
match future.as_mut().poll(&mut context) {
Poll::Ready(output) => output,
Poll::Pending => panic!("example context contributors should complete immediately"),
}
}

View File

@@ -0,0 +1,101 @@
use std::sync::Arc;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use akode_extension_api::ContentItemKind;
use akode_extension_api::ContextContributor;
use akode_extension_api::ExtensionData;
use akode_extension_api::ExtensionRegistryBuilder;
use akode_extension_api::PromptFragment;
/// Installs the tutorial contributors used by the example host.
pub fn install(registry: &mut ExtensionRegistryBuilder<()>) {
registry.prompt_contributor(Arc::new(StyleContributor));
registry.prompt_contributor(Arc::new(UsageContributor));
}
#[derive(Debug)]
struct StyleContributor;
impl ContextContributor for StyleContributor {
fn contribute_thread_context<'a>(
&'a self,
session_store: &'a ExtensionData,
thread_store: &'a ExtensionData,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<PromptFragment>> + Send + 'a>> {
Box::pin(async move {
contribution_counts(session_store).record_style();
contribution_counts(thread_store).record_style();
vec![PromptFragment::developer_policy(
"Prefer short answers unless the user asks for detail.",
ContentItemKind("example.style_instructions".to_string()),
)]
})
}
}
#[derive(Debug)]
struct UsageContributor;
impl ContextContributor for UsageContributor {
fn contribute_thread_context<'a>(
&'a self,
session_store: &'a ExtensionData,
thread_store: &'a ExtensionData,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<PromptFragment>> + Send + 'a>> {
Box::pin(async move {
contribution_counts(session_store).record_usage();
contribution_counts(thread_store).record_usage();
vec![PromptFragment::developer_capability(
"This extension can contribute more than one prompt fragment.",
ContentItemKind("example.usage_instructions".to_string()),
)]
})
}
}
/// Returns how many style contributions were recorded in `store`.
pub fn recorded_style_contributions(store: &ExtensionData) -> u64 {
store
.get::<ContributionCounts>()
.map(|counts| counts.style())
.unwrap_or_default()
}
/// Returns how many usage contributions were recorded in `store`.
pub fn recorded_usage_contributions(store: &ExtensionData) -> u64 {
store
.get::<ContributionCounts>()
.map(|counts| counts.usage())
.unwrap_or_default()
}
#[derive(Debug, Default)]
struct ContributionCounts {
style: AtomicU64,
usage: AtomicU64,
}
impl ContributionCounts {
fn record_style(&self) {
self.style.fetch_add(1, Ordering::Relaxed);
}
fn record_usage(&self) {
self.usage.fetch_add(1, Ordering::Relaxed);
}
fn style(&self) -> u64 {
self.style.load(Ordering::Relaxed)
}
fn usage(&self) -> u64 {
self.usage.load(Ordering::Relaxed)
}
}
fn contribution_counts(store: &ExtensionData) -> Arc<ContributionCounts> {
store.get_or_init::<ContributionCounts>(Default::default)
}