feat: add a version RPC returning the daemon build version
Some checks failed
Build / validate (pull_request) Failing after 15s

RPC clients (the hephaestus.nvim plugin, for its `:Heph version`
command) had no way to learn which hephd they are talking to — `health`
returns counts, not a version. Add a tiny `version` method returning
`{ version: heph_core::VERSION }`, the same `X.Y.Z (sha)` string the
binaries print for --version. No store access needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-06-04 11:13:47 -07:00
commit 7914232ec4
3 changed files with 33 additions and 0 deletions

View file

@ -417,6 +417,7 @@ pub fn dispatch(store: &mut dyn Store, method: &str, params: Value) -> Result<Va
let p: ViewParams = parse(params)?; let p: ViewParams = parse(params)?;
json!(store.resolve_project(&p.name)?) json!(store.resolve_project(&p.name)?)
} }
"version" => json!({ "version": heph_core::VERSION }),
"health" => json!(store.health()?), "health" => json!(store.health()?),
"search" => { "search" => {
let p: SearchParams = parse(params)?; let p: SearchParams = parse(params)?;

View file

@ -109,6 +109,37 @@ fn node_resolve_is_exact_not_fuzzy_over_socket() {
assert_eq!(missing, Value::Null); assert_eq!(missing, Value::Null);
} }
#[test]
fn version_rpc_returns_build_version() {
let (socket, _dir) = spawn_daemon();
let mut c = client(&socket);
let got = c.call("version", json!({})).unwrap();
assert_eq!(got["version"], heph_core::VERSION);
}
#[test]
fn project_resolve_is_case_insensitive_and_prefix_fuzzy_over_socket() {
let (socket, _dir) = spawn_daemon();
let mut c = client(&socket);
let proj = c
.call("node.create", json!({ "kind": "project", "title": "Hephaestus" }))
.unwrap();
let pid = proj["id"].as_str().unwrap().to_string();
// Case-insensitive exact and unambiguous prefix both resolve to the project.
for name in ["Hephaestus", "hephaestus", "heph"] {
let got = c.call("project.resolve", json!({ "name": name })).unwrap();
assert_eq!(got["id"], pid, "resolving {name:?}");
}
// An unknown name is JSON null, not an error.
let missing = c
.call("project.resolve", json!({ "name": "nope" }))
.unwrap();
assert_eq!(missing, Value::Null);
}
#[test] #[test]
fn task_create_appears_in_next_with_context_link() { fn task_create_appears_in_next_with_context_link() {
let (socket, _dir) = spawn_daemon(); let (socket, _dir) = spawn_daemon();

View file

@ -0,0 +1 @@
New `version` RPC returns the daemon's build version (`heph_core::VERSION`, e.g. `1.0.0 (ab6701d12)`), so RPC clients — notably the `hephaestus.nvim` plugin's `:Heph version` command — can report which `hephd` they are talking to without shelling out to the binary.