feat(daemon): serve a live-only prompt-history read

The web composer's ↑/↓ recall needs the plugin's prompt history, so the browser
and nvim walk one list instead of two. The daemon relays it and stores nothing:
it is a router, and the plugin stays the authority (AGENTS.md rule 2).

- plugin `hello` advertises the new `promptHistory` capability; the daemon never
  relays the read to a plugin that did not advertise it
- `workspace.query{kind:"promptHistory",limit}` is answered by the plugin from
  its own `prompt.history` archive (workspace cwd), oldest-first
- `GET /api/v1/workspaces/:id/prompt-history?limit=` → `{v, workspaceId, live,
  supported, entries}`; `limit` defaults to 200 and clamps to 500, an unknown
  workspace is a 404, and malformed entries are dropped
- the read deliberately does **not** call `instances.ensure()`: recall is a
  keystroke, not a lifecycle event, so a workspace with no connected plugin
  answers `{live:false, supported:false, entries:[]}` instead of booting an nvim
- `PluginConnection.capabilities` joins the interface the daemon sees, and the
  fake connection grows a writable one so the gate is testable

No event or reducer change: `fixtures/` are untouched.
This commit is contained in:
yuez committed 2026-11-02 11:12:21 +08:00
1 parent c24f30fe71
commit 32292873f9
6 files changed
+204

No files matched your search

+2
View File
@@ -31,6 +31,8 @@ export class FakeConnection implements PluginConnection {
readonly hasUI = true;
readonly listenAddr: string | null = null;
readonly pluginVersion = "test-1.0.0";
/** Writable so a test can model a plugin that predates a capability. */
capabilities: string[] = ["promptHistory"];
subscribed = new Set<string>();
snapshots = new Map<string, SessionState>();