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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,9 @@ async fn network_only_human_output() -> Result<()> {
|
||||
"--no-color",
|
||||
])
|
||||
.output()?;
|
||||
let stdout = String::from_utf8(output.stdout)?;
|
||||
// The version changes with every release: keep the snapshots stable.
|
||||
let stdout = String::from_utf8(output.stdout)?
|
||||
.replace(concat!("Doctor v", env!("CARGO_PKG_VERSION")), "Doctor v<VERSION>");
|
||||
assert!(output.status.success(), "{stdout}");
|
||||
insta::assert_snapshot!("network_only_human_output", stdout);
|
||||
Ok(())
|
||||
@@ -233,7 +235,9 @@ async fn network_only_config_failure_human_output() -> Result<()> {
|
||||
let output = local_command(&home)?
|
||||
.args(["doctor", "--network-only", "--all", "--ascii", "--no-color"])
|
||||
.output()?;
|
||||
let stdout = String::from_utf8(output.stdout)?;
|
||||
// The version changes with every release: keep the snapshots stable.
|
||||
let stdout = String::from_utf8(output.stdout)?
|
||||
.replace(concat!("Doctor v", env!("CARGO_PKG_VERSION")), "Doctor v<VERSION>");
|
||||
assert_eq!(output.status.code(), Some(1));
|
||||
assert!(!stdout.contains("sk-config-credential-fixture"));
|
||||
// Config loading may canonicalize the directory, rendering may shorten it,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source: cli/tests/doctor_enterprise_network.rs
|
||||
expression: stdout
|
||||
---
|
||||
aKode Doctor v0.1.0
|
||||
aKode Doctor v<VERSION>
|
||||
|
||||
Notes
|
||||
[XX] config config could not be loaded - Fix the reported config error, then rerun akode doctor.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source: cli/tests/doctor_enterprise_network.rs
|
||||
expression: stdout
|
||||
---
|
||||
aKode Doctor v0.1.0
|
||||
aKode Doctor v<VERSION>
|
||||
|
||||
Configuration
|
||||
[ok] config loaded
|
||||
|
||||
Reference in New Issue
Block a user