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,78 @@
#![cfg(target_os = "windows")]
use anyhow::Context;
use anyhow::Result;
use akode_utils_cargo_bin::cargo_bin;
use std::io;
use std::os::windows::ffi::OsStrExt;
use windows_sys::Win32::Foundation::FreeLibrary;
use windows_sys::Win32::System::LibraryLoader::FindResourceW;
use windows_sys::Win32::System::LibraryLoader::LOAD_LIBRARY_AS_DATAFILE;
use windows_sys::Win32::System::LibraryLoader::LOAD_LIBRARY_AS_IMAGE_RESOURCE;
use windows_sys::Win32::System::LibraryLoader::LoadLibraryExW;
use windows_sys::Win32::System::LibraryLoader::LoadResource;
use windows_sys::Win32::System::LibraryLoader::LockResource;
use windows_sys::Win32::System::LibraryLoader::SizeofResource;
use windows_sys::Win32::UI::WindowsAndMessaging::CREATEPROCESS_MANIFEST_RESOURCE_ID;
use windows_sys::Win32::UI::WindowsAndMessaging::RT_MANIFEST;
/// The setup executable must expose an asInvoker manifest through the Windows resource API.
#[test]
fn setup_helper_embeds_as_invoker_manifest() -> Result<()> {
let setup_executable = cargo_bin("akode-windows-sandbox-setup")
.context("locate the Windows sandbox setup executable")?;
let setup_path = setup_executable
.as_os_str()
.encode_wide()
.chain(std::iter::once(0))
.collect::<Vec<_>>();
let module = unsafe {
LoadLibraryExW(
setup_path.as_ptr(),
std::ptr::null_mut(),
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE,
)
};
if module.is_null() {
return Err(io::Error::last_os_error())
.with_context(|| format!("load setup helper {}", setup_executable.display()));
}
let resource = unsafe {
FindResourceW(
module,
std::ptr::without_provenance(CREATEPROCESS_MANIFEST_RESOURCE_ID as usize),
std::ptr::without_provenance(RT_MANIFEST as usize),
)
};
if resource.is_null() {
return Err(io::Error::last_os_error()).context("find numeric RT_MANIFEST resource ID 1");
}
let resource_size = unsafe { SizeofResource(module, resource) };
let loaded_resource = unsafe { LoadResource(module, resource) };
if loaded_resource.is_null() {
return Err(io::Error::last_os_error()).context("load setup helper manifest resource");
}
let resource_data = unsafe { LockResource(loaded_resource) };
if resource_data.is_null() {
return Err(io::Error::last_os_error()).context("read setup helper manifest resource");
}
let manifest_bytes =
unsafe { std::slice::from_raw_parts(resource_data.cast::<u8>(), resource_size as usize) };
let manifest = std::str::from_utf8(manifest_bytes).context("decode setup helper manifest")?;
assert!(
manifest.contains("requestedExecutionLevel level=\"asInvoker\""),
"setup helper manifest does not request asInvoker: {manifest}",
);
assert!(
manifest.contains("uiAccess=\"false\""),
"setup helper manifest does not disable UI access: {manifest}",
);
if unsafe { FreeLibrary(module) } == 0 {
return Err(io::Error::last_os_error()).context("unload setup helper resource module");
}
Ok(())
}

View File

@@ -0,0 +1,8 @@
load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "support",
crate_name = "akode_windows_sandbox_test_support",
# This support library has no tests of its own.
test_tags = ["manual"],
)

View File

@@ -0,0 +1,15 @@
[package]
name = "akode-windows-sandbox-test-support"
version.workspace = true
edition.workspace = true
license.workspace = true
[lib]
test = false
doctest = false
[lints]
workspace = true
[target.'cfg(windows)'.dependencies]
dirs = { workspace = true }

View File

@@ -0,0 +1,49 @@
//! Coordinates tests that share the runner's Windows sandbox accounts across processes.
#![cfg(windows)]
use std::fs::File;
use std::fs::OpenOptions;
use std::io;
/// Serializes tests that provision or use the runner's shared Windows sandbox accounts.
/// Hold this from before setup until all sandbox commands and cleanup have finished.
#[must_use = "the account lock is released when the guard is dropped"]
pub struct WindowsSandboxAccountTestGuard {
_file: File,
}
impl WindowsSandboxAccountTestGuard {
/// Acquires the same file lock across all test processes run by this Windows user.
pub fn acquire() -> io::Result<Self> {
let directory = dirs::data_local_dir().ok_or_else(|| {
io::Error::new(
io::ErrorKind::NotFound,
"Windows local application data directory is unavailable",
)
})?;
// Bazel uses per-test temporary directories, so the lock lives in the runner user's
// Windows known folder instead. It is separate from the production setup lock.
let path = directory.join("codex-windows-sandbox-integration-test.lock");
// Leave the file in place: deleting it would let processes lock different files at this path.
let file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.truncate(false)
.open(path)
.map_err(|error| {
io::Error::new(
error.kind(),
format!("open Windows sandbox test lock: {error}"),
)
})?;
file.lock().map_err(|error| {
io::Error::new(
error.kind(),
format!("lock Windows sandbox test accounts: {error}"),
)
})?;
Ok(Self { _file: file })
}
}