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>
70 lines
2.4 KiB
Rust
70 lines
2.4 KiB
Rust
use akode_config::CONFIG_TOML_FILE;
|
|
use akode_config::ConfigLayerStack;
|
|
use akode_config::TomlValue;
|
|
use akode_core::config::Config;
|
|
use akode_features::Feature;
|
|
use akode_hooks::HookListEntry;
|
|
use akode_utils_absolute_path::AbsolutePathBuf;
|
|
|
|
pub fn trust_discovered_hooks(config: &mut Config) {
|
|
config
|
|
.features
|
|
.enable(Feature::CodexHooks)
|
|
.expect("test config should allow feature update");
|
|
|
|
let listed = akode_hooks::list_hooks(akode_hooks::HooksConfig {
|
|
feature_enabled: true,
|
|
config_layer_stack: Some(config.config_layer_stack.clone()),
|
|
..akode_hooks::HooksConfig::default()
|
|
});
|
|
assert!(
|
|
!listed.hooks.is_empty(),
|
|
"trusted hook fixture should discover at least one hook"
|
|
);
|
|
trust_hooks(config, listed.hooks);
|
|
}
|
|
|
|
pub fn trust_hooks(config: &mut Config, hooks: Vec<HookListEntry>) {
|
|
config.config_layer_stack =
|
|
trusted_config_layer_stack(&config.config_layer_stack, &config.codex_home, hooks);
|
|
}
|
|
|
|
pub fn trusted_config_layer_stack(
|
|
config_layer_stack: &ConfigLayerStack,
|
|
codex_home: &AbsolutePathBuf,
|
|
hooks: Vec<HookListEntry>,
|
|
) -> ConfigLayerStack {
|
|
let mut user_config = config_layer_stack
|
|
.get_active_user_layer()
|
|
.map(|layer| layer.config.clone())
|
|
.unwrap_or_else(|| TomlValue::Table(Default::default()));
|
|
let user_table = user_config
|
|
.as_table_mut()
|
|
.expect("user config should be a table");
|
|
let hooks_table = user_table
|
|
.entry("hooks")
|
|
.or_insert_with(|| TomlValue::Table(Default::default()))
|
|
.as_table_mut()
|
|
.expect("hooks config should be a table");
|
|
let state_table = hooks_table
|
|
.entry("state")
|
|
.or_insert_with(|| TomlValue::Table(Default::default()))
|
|
.as_table_mut()
|
|
.expect("hook state config should be a table");
|
|
for hook in hooks {
|
|
let mut hook_state = TomlValue::Table(Default::default());
|
|
let hook_state_table = hook_state
|
|
.as_table_mut()
|
|
.expect("hook state should be a table");
|
|
hook_state_table.insert(
|
|
"trusted_hash".to_string(),
|
|
TomlValue::String(hook.current_hash),
|
|
);
|
|
state_table.insert(hook.key, hook_state);
|
|
}
|
|
|
|
config_layer_stack
|
|
.with_user_config(&codex_home.join(CONFIG_TOML_FILE), user_config)
|
|
.expect("hook user config should be valid")
|
|
}
|