generated from eblume/project-template
heph.nvim: RPC client + buffer editing + wiki-links + journal (slice 11a)
Some checks failed
Build / validate (pull_request) Failing after 4s
Some checks failed
Build / validate (pull_request) Failing after 4s
The primary surface begins (tech-spec §8): a Neovim plugin that is a thin
client of the local hephd over its unix-socket JSON-RPC.
- node.resolve {title} → Node|null (heph-core Store + dispatch): exact,
owner-scoped, non-tombstoned alias-then-title match — the same mapping that
materializes wiki links, so follow-link jumps to the node the stored link
points at (never fuzzy search). Unit + rpc_socket integration tests.
- heph.nvim/: vim.uv unix-socket JSON-RPC client (blocking call via vim.wait,
id-demuxed, partial-line buffered, luanil so JSON null → Lua nil; isolated
Sessions for tests). Buffer-backed nodes (heph://node/<id>, acwrite;
BufReadCmd→node.get / BufWriteCmd→node.update, whole-buffer body round-trips
exactly through the CRDT). [[wiki-link]] follow on <CR>. Daily journal.
:Heph command surface + completion.
- Headless e2e (§9): a self-contained busted-style runner (tests/e2e/runner.lua)
— no external plugins, no network, deterministic CI exit codes. Specs: journal
round-trip, follow-link (+ unresolved no-op), link-two-docs/backlink.
`make -C heph.nvim test` builds hephd and runs it.
Docs: heph-nvim reference card, §14 tracker (11a done; 11b/11c/11d queued),
changelog fragment.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
87c76da659
commit
ee865e5635
29 changed files with 1240 additions and 10 deletions
58
heph.nvim/lua/heph/daemon.lua
Normal file
58
heph.nvim/lua/heph/daemon.lua
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
--- Locate, spawn, and wait on a `hephd` daemon. Shared by optional autostart
|
||||
--- and by the e2e harness (so test readiness uses the same definition the
|
||||
--- plugin does).
|
||||
|
||||
local uv = vim.uv or vim.loop
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Spawn a `local`-mode hephd against `opts.db` listening on `opts.socket`.
|
||||
--- `opts.bin` defaults to `hephd` on PATH. Returns `{ handle, pid }`.
|
||||
function M.spawn(opts)
|
||||
local args = { "--mode", "local" }
|
||||
if opts.db then
|
||||
table.insert(args, "--db")
|
||||
table.insert(args, opts.db)
|
||||
end
|
||||
if opts.socket then
|
||||
table.insert(args, "--socket")
|
||||
table.insert(args, opts.socket)
|
||||
end
|
||||
local handle, pid = uv.spawn(opts.bin or "hephd", {
|
||||
args = args,
|
||||
stdio = { nil, nil, opts.stderr },
|
||||
}, function(code, signal)
|
||||
if opts.on_exit then
|
||||
opts.on_exit(code, signal)
|
||||
end
|
||||
end)
|
||||
if not handle then
|
||||
error("heph: failed to spawn hephd (bin=" .. (opts.bin or "hephd") .. ")")
|
||||
end
|
||||
return { handle = handle, pid = pid }
|
||||
end
|
||||
|
||||
--- Wait until `socket` both exists and accepts a real RPC (`health`). The
|
||||
--- existence check alone races the daemon's bind→accept, so we prove liveness
|
||||
--- with a round-trip on a throwaway session. Returns `true`, or `false, reason`.
|
||||
function M.wait_ready(socket, timeout)
|
||||
timeout = timeout or 5000
|
||||
if not vim.wait(timeout, function()
|
||||
return uv.fs_stat(socket) ~= nil
|
||||
end, 20) then
|
||||
return false, "socket never appeared: " .. socket
|
||||
end
|
||||
local session = require("heph.rpc").new_session(socket)
|
||||
local ok = vim.wait(timeout, function()
|
||||
return pcall(function()
|
||||
session:call("health", vim.empty_dict(), { timeout = 200 })
|
||||
end)
|
||||
end, 50)
|
||||
session:close()
|
||||
if not ok then
|
||||
return false, "socket present but not accepting rpc: " .. socket
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue