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,28 @@
//! Exposes file copying independently of which environments a turn selects.
use std::sync::Arc;
use akode_extension_api::ExtensionData;
use akode_extension_api::ExtensionRegistryBuilder;
use akode_extension_api::ToolCall;
use akode_extension_api::ToolContributor;
use akode_extension_api::ToolExecutor;
use crate::tool::CopyFileTool;
struct FileCopyExtension;
impl ToolContributor for FileCopyExtension {
fn tools(
&self,
_session_store: &ExtensionData,
_thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
vec![Arc::new(CopyFileTool)]
}
}
/// Installs file copying after the host checks its feature flag.
pub fn install<C: Sync>(registry: &mut ExtensionRegistryBuilder<C>) {
registry.tool_contributor(Arc::new(FileCopyExtension));
}

View File

@@ -0,0 +1,4 @@
mod extension;
mod tool;
pub use extension::install;

View File

@@ -0,0 +1,166 @@
//! Copies one file between selected environments using each endpoint's captured permissions.
//! Paths are absolute and bytes stay outside model context; failed copies may leave a partial target.
use std::collections::BTreeMap;
use akode_tools::FunctionCallError;
use akode_tools::JsonSchema;
use akode_tools::JsonToolOutput;
use akode_tools::ResponsesApiTool;
use akode_tools::ToolCall;
use akode_tools::ToolEnvironment;
use akode_tools::ToolExecutor;
use akode_tools::ToolName;
use akode_tools::ToolPayload;
use akode_tools::ToolSpec;
use akode_utils_path_uri::LegacyAppPathString;
use futures::StreamExt;
use serde::Deserialize;
use serde_json::json;
const TOOL_NAME: &str = "multi_env_copy_file";
const TOOL_DESCRIPTION: &str = "Copy a file between two different environments without loading it into context. Returns bytes copied after completion. Interrupted copies may leave files partially written.";
pub(crate) struct CopyFileTool;
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct CopyFileArgs {
source_environment_id: String,
source_path: String,
target_environment_id: String,
target_path: String,
}
impl CopyFileArgs {
fn parse(arguments: &str) -> Result<Self, FunctionCallError> {
serde_json::from_str(arguments)
.map_err(|error| FunctionCallError::RespondToModel(error.to_string()))
}
}
impl<'call> ToolExecutor<ToolCall<'call>> for CopyFileTool {
fn tool_name(&self) -> ToolName {
ToolName::plain(TOOL_NAME)
}
fn spec(&self) -> ToolSpec {
let fields = [
(
"source_environment_id",
"Source environment ID from <environment_context>.",
),
(
"source_path",
"Absolute file path in the source environment. Parent directories must exist.",
),
(
"target_environment_id",
"Target environment ID from <environment_context>.",
),
(
"target_path",
"Absolute file path in the target environment. Parent directories must exist.",
),
];
let properties = fields
.iter()
.map(|(name, description)| {
(
name.to_string(),
JsonSchema::string(Some(description.to_string())),
)
})
.collect::<BTreeMap<_, _>>();
ToolSpec::Function(ResponsesApiTool {
name: TOOL_NAME.to_string(),
description: TOOL_DESCRIPTION.to_string(),
strict: false,
defer_loading: None,
parameters: JsonSchema::object(
properties,
Some(fields.iter().map(|(name, _)| name.to_string()).collect()),
Some(false.into()),
),
output_schema: None,
})
}
fn environment_arguments(
&self,
payload: &ToolPayload,
) -> Result<Vec<(&'static str, String)>, FunctionCallError> {
let ToolPayload::Function { arguments } = payload else {
return Err(FunctionCallError::Fatal(
"expected copy arguments".to_string(),
));
};
let args = CopyFileArgs::parse(arguments)?;
if args.source_environment_id == args.target_environment_id {
return Err(FunctionCallError::RespondToModel(
"source and target environment IDs must differ. To copy within one environment, use a shell command.".to_string(),
));
}
Ok(vec![
("source_environment_id", args.source_environment_id),
("target_environment_id", args.target_environment_id),
])
}
fn handle<'a>(&'a self, call: ToolCall<'call>) -> akode_tools::ToolExecutorFuture<'a>
where
'call: 'a,
{
Box::pin(async move {
let args = CopyFileArgs::parse(call.function_arguments()?)?;
let [source, target] = call.environments.as_slice() else {
return Err(FunctionCallError::Fatal(
"copy requires a source and a target environment".to_string(),
));
};
let resolve_path = |environment: &ToolEnvironment<'_>, path: &str| {
let id = &environment.environment_id;
let convention = environment.cwd.infer_path_convention().ok_or_else(|| {
FunctionCallError::RespondToModel(format!(
"invalid working directory path for environment {id}"
))
})?;
LegacyAppPathString::from_string(path)
.to_path_uri(convention)
.map_err(|_| {
FunctionCallError::RespondToModel(format!(
"provide an absolute {convention} file path for environment {id}"
))
})
};
let source_path = resolve_path(source, &args.source_path)?;
let target_path = resolve_path(target, &args.target_path)?;
// The target writer pulls one block at a time when it supports streaming writes.
// For an older executor it buffers this stream and sends a single write instead.
// Report only the I/O error kind to the model. Executor connection errors can
// include credentials from a signed websocket URL in their message.
let contents = source
.fs()
.read_file_stream(&source_path)
.await
.map_err(|error| {
FunctionCallError::RespondToModel(format!(
"could not open copy source: {}",
error.kind()
))
})?;
let bytes_copied = target
.fs()
.write_file_stream(&target_path, contents.boxed())
.await
.map_err(|error| {
FunctionCallError::RespondToModel(format!(
"copy failed; target may be truncated or partially written: {}",
error.kind()
))
})?;
let output = json!({"bytes_copied": bytes_copied});
Ok(Box::new(JsonToolOutput::new(output)) as Box<dyn akode_tools::ToolOutput>)
})
}
}