heph.nvim: RPC client + buffer editing + wiki-links + journal (slice 11a)
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>
2026-06-01 20:33:29 -07:00
|
|
|
-- Workflow (c): follow a [[link]] under the cursor on <CR> to the target doc.
|
|
|
|
|
|
|
|
|
|
local h = require("e2e.helpers")
|
|
|
|
|
|
|
|
|
|
describe("follow link", function()
|
|
|
|
|
local ctx
|
|
|
|
|
before_each(function()
|
|
|
|
|
ctx = h.start()
|
|
|
|
|
end)
|
|
|
|
|
after_each(function()
|
|
|
|
|
h.stop(ctx)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("follows [[B]] under the cursor to doc B", function()
|
|
|
|
|
local b = h.create_doc("B", "the B doc")
|
|
|
|
|
local a = h.create_doc("A", "see [[B]] here")
|
|
|
|
|
|
|
|
|
|
local buf = h.open(a.id)
|
2026-06-03 11:44:39 -07:00
|
|
|
local lnum, col = h.find(buf, "%[%[B") -- the body line, below the frontmatter
|
|
|
|
|
assert.is_truthy(lnum)
|
heph.nvim: RPC client + buffer editing + wiki-links + journal (slice 11a)
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>
2026-06-01 20:33:29 -07:00
|
|
|
-- Put the cursor on the target inside the brackets.
|
2026-06-03 11:44:39 -07:00
|
|
|
vim.api.nvim_win_set_cursor(0, { lnum, col + 2 })
|
heph.nvim: RPC client + buffer editing + wiki-links + journal (slice 11a)
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>
2026-06-01 20:33:29 -07:00
|
|
|
|
|
|
|
|
require("heph.link").follow()
|
|
|
|
|
|
|
|
|
|
local cur = vim.api.nvim_get_current_buf()
|
|
|
|
|
assert.are.equal("heph://node/" .. b.id, vim.api.nvim_buf_get_name(cur))
|
|
|
|
|
assert.are.equal(b.id, vim.b[cur].heph_node_id)
|
|
|
|
|
end)
|
|
|
|
|
|
2026-06-02 11:07:09 -07:00
|
|
|
it("creates the target doc when following an unresolved [[link]]", function()
|
|
|
|
|
local a = h.create_doc("Daily", "see [[New Topic]]")
|
heph.nvim: RPC client + buffer editing + wiki-links + journal (slice 11a)
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>
2026-06-01 20:33:29 -07:00
|
|
|
local buf = h.open(a.id)
|
2026-06-03 11:44:39 -07:00
|
|
|
local lnum, col = h.find(buf, "%[%[New")
|
|
|
|
|
vim.api.nvim_win_set_cursor(0, { lnum, col + 2 }) -- inside [[New Topic]]
|
2026-06-02 11:07:09 -07:00
|
|
|
|
heph.nvim: RPC client + buffer editing + wiki-links + journal (slice 11a)
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>
2026-06-01 20:33:29 -07:00
|
|
|
require("heph.link").follow()
|
2026-06-02 11:07:09 -07:00
|
|
|
|
|
|
|
|
-- A new doc titled "New Topic" was created and opened.
|
|
|
|
|
local created = ctx.q:call("node.resolve", { title = "New Topic" })
|
|
|
|
|
assert.is_truthy(created, "expected the target doc to be created")
|
|
|
|
|
assert.are.equal("heph://node/" .. created.id, vim.api.nvim_buf_get_name(0))
|
|
|
|
|
|
|
|
|
|
-- ...and the source now backlinks it (the wiki-link materialized).
|
|
|
|
|
local linked = false
|
|
|
|
|
for _, l in ipairs(ctx.q:call("links.backlinks", { id = created.id })) do
|
|
|
|
|
if l.src_id == a.id and l.link_type == "wiki" then
|
|
|
|
|
linked = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
assert.is_true(linked, "expected the source to backlink the created doc")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("creates + links from an unsaved [[link]] just typed into the buffer", function()
|
|
|
|
|
-- The real gesture: open a note, type a new [[link]], <CR> without :w.
|
|
|
|
|
local a = h.create_doc("Journalish", "")
|
|
|
|
|
local buf = h.open(a.id)
|
|
|
|
|
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "ref [[Fresh Note]]" })
|
|
|
|
|
assert.is_true(vim.bo[buf].modified)
|
|
|
|
|
local at = vim.api.nvim_buf_get_lines(buf, 0, 1, false)[1]:find("%[%[Fresh")
|
|
|
|
|
vim.api.nvim_win_set_cursor(0, { 1, at + 1 })
|
|
|
|
|
|
|
|
|
|
require("heph.link").follow()
|
|
|
|
|
|
|
|
|
|
local created = ctx.q:call("node.resolve", { title = "Fresh Note" })
|
|
|
|
|
assert.is_truthy(created)
|
|
|
|
|
assert.are.equal("heph://node/" .. created.id, vim.api.nvim_buf_get_name(0))
|
|
|
|
|
-- The source's pending edit was persisted and the backlink materialized.
|
|
|
|
|
assert.are.equal("ref [[Fresh Note]]", ctx.q:call("node.get", { id = a.id }).body)
|
|
|
|
|
local linked = false
|
|
|
|
|
for _, l in ipairs(ctx.q:call("links.backlinks", { id = created.id })) do
|
|
|
|
|
if l.src_id == a.id and l.link_type == "wiki" then
|
|
|
|
|
linked = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
assert.is_true(linked, "expected the source edit saved and backlink materialized")
|
heph.nvim: RPC client + buffer editing + wiki-links + journal (slice 11a)
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>
2026-06-01 20:33:29 -07:00
|
|
|
end)
|
|
|
|
|
end)
|