aKode 0.5.0: riepilogo della memoria a inizio sessione, sollecito alle azioni annunciate, daemon allineato al CLI
- ext/memoria: legge una volta per sessione la risorsa memoria://briefing (file di git status, budget di token, timeout breve), accetta solo un blocco <memoria_briefing> chiuso e limitato, lo inserisce dopo le istruzioni del plugin e lo tiene in cache per il thread (prefisso del prompt stabile). Impostazioni [memoria] briefing, briefing_timeout_ms, briefing_max_tokens. - Turno: se il modello chiude con un messaggio che annuncia un'azione senza chiamare strumenti, un solo sollecito per turno ([agent] announce_nudges, predefinito 1, 0 lo disattiva), con avviso visibile e test sui messaggi osservati con Qwen. - Daemon: sync_with_cli confronta l'eseguibile del CLI con il pacchetto del daemon e, se diverso, lo seleziona e riavvia solo quando non ci sono sessioni caricate; altrimenti avviso. Usato all'avvio della TUI, da `akode update`, da install.sh e da `akode app-server daemon update --from-cli --if-idle`. Prima un daemon preparato una volta restava alla versione vecchia (CLI 0.4.0 con app server 0.3.1). - Test: snapshot del doctor indipendenti dalla versione; snapshot della TUI aggiornati alla 0.5.0 e allo schema dei tool appiattiti della 0.4.0. - Versione 0.5.0 e sezione Novità nel README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -616,6 +616,10 @@ enum AppServerDaemonSubcommand {
|
||||
/// Confirm replacing the daemon package without an interactive prompt.
|
||||
#[arg(short = 'y', long, requires = "from_cli")]
|
||||
yes: bool,
|
||||
/// Only if the daemon runs another executable and has no session loaded; otherwise
|
||||
/// leave it running and print why (used by `akode update` and install.sh).
|
||||
#[arg(long, requires = "from_cli", conflicts_with = "yes")]
|
||||
if_idle: bool,
|
||||
},
|
||||
|
||||
/// Stop the local app server daemon.
|
||||
@@ -1209,9 +1213,21 @@ async fn dispatch_cli(
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
AppServerDaemonSubcommand::Update {
|
||||
from_cli: true,
|
||||
if_idle: true,
|
||||
..
|
||||
} => {
|
||||
let sync = akode_app_server_daemon::sync_with_cli().await?;
|
||||
match sync.warning() {
|
||||
Some(message) => println!("{message}"),
|
||||
None => println!("Server in background di aKode già allineato."),
|
||||
}
|
||||
}
|
||||
AppServerDaemonSubcommand::Update {
|
||||
from_cli: true,
|
||||
yes,
|
||||
if_idle: false,
|
||||
} => {
|
||||
let result = akode_app_server_daemon::update_from_cli(|request| {
|
||||
daemon_install::confirm_install(request, yes)
|
||||
|
||||
@@ -68,14 +68,38 @@ pub async fn run(cmd: UpdateCommand, config: &Config) -> anyhow::Result<()> {
|
||||
.symlink_metadata()
|
||||
.is_ok()
|
||||
{
|
||||
println!(
|
||||
"Il server in background usa ancora il pacchetto precedente: esegui \"akode app-server daemon update --from-cli\" per allinearlo."
|
||||
);
|
||||
// The daemon runs its own copy of the package: align it with the new CLI (only when
|
||||
// no session is loaded) using the binary just installed.
|
||||
sync_daemon(&install.exe);
|
||||
}
|
||||
println!("Riavvia aKode per usare la nuova versione.");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Runs `<new akode> app-server daemon update --from-cli --if-idle` and reports its outcome.
|
||||
fn sync_daemon(new_exe: &std::path::Path) {
|
||||
let output = std::process::Command::new(new_exe)
|
||||
.args(["app-server", "daemon", "update", "--from-cli", "--if-idle"])
|
||||
.stdin(std::process::Stdio::null())
|
||||
.output();
|
||||
match output {
|
||||
Ok(out) if out.status.success() => {
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
let text = text.trim();
|
||||
if !text.is_empty() {
|
||||
println!("{text}");
|
||||
}
|
||||
}
|
||||
Ok(out) => println!(
|
||||
"Il server in background non è stato allineato ({}): esegui \"akode app-server daemon update --from-cli\".",
|
||||
String::from_utf8_lossy(&out.stderr).trim()
|
||||
),
|
||||
Err(err) => println!(
|
||||
"Il server in background non è stato allineato ({err}): esegui \"akode app-server daemon update --from-cli\"."
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// The real file behind the running binary, and its package directory if it is packaged.
|
||||
fn install_target() -> anyhow::Result<InstallTarget> {
|
||||
let exe = std::env::current_exe()
|
||||
@@ -88,3 +112,21 @@ fn install_target() -> anyhow::Result<InstallTarget> {
|
||||
.map(|layout| PathBuf::from(layout.package_dir.as_path()));
|
||||
Ok(InstallTarget { exe, package_dir })
|
||||
}
|
||||
|
||||
#[cfg(all(test, unix))]
|
||||
mod tests {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
#[test]
|
||||
fn daemon_sync_runs_the_new_binary_only_if_idle() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let exe = dir.path().join("akode");
|
||||
std::fs::write(&exe, "#!/bin/sh\nprintf '%s\\n' \"$@\" > \"$0.args\"\n").expect("write");
|
||||
std::fs::set_permissions(&exe, std::fs::Permissions::from_mode(0o700)).expect("chmod");
|
||||
super::sync_daemon(&exe);
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(dir.path().join("akode.args")).expect("args"),
|
||||
"app-server\ndaemon\nupdate\n--from-cli\n--if-idle\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user