Expose the ECA version to hook payloads
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Summary
A hook script cannot tell which ECA it is running under. Every other piece of context is there — workspaces, cwd, the chat id, the executable — but not the version, so a plugin that must adapt its behaviour across ECA upgrades has no cheap, reliable way to know what its host supports. Adding :eca-version to base-hook-data fixes this with a one-line change, mirroring the existing :eca-executable.
Current behaviour
src/eca/features/hooks.clj builds the fields every hook receives:
(defn base-hook-data
"Returns common fields for ALL hooks: :workspaces, :cwd, :db-cache-path,
:session-id, and :eca-executable."
[db]
(let [workspaces (shared/get-workspaces db)
db-cache-path (shared/db-cache-path db)]
{:workspaces workspaces
:cwd (first workspaces)
:db-cache-path db-cache-path
:session-id (session-id-from-db-cache-path db-cache-path)
:eca-executable @shared/eca-executable*}))
There is no :eca-version. The version itself is available and cheap: config/eca-version is a memoized read of the ECA_VERSION resource.
Why it matters
Concrete case: the context-mode ECA plugin has to know whether the running ECA sends _meta.sessionId on MCP tools/call requests (added in #696, unreleased at the time of writing). When ECA sends it, the plugin should point the model at context-mode__ctx_resume; when it does not, it must point at context-mode__ctx_search(sort: "timeline") instead (see that plugin's README, limitation #1). The only signal that decides this is the ECA version.
Without a version in the payload the plugin has to either:
- spawn
$ECA_EXECUTABLE --versionfrom a hook and cache the result — one process per ECA upgrade, andECA_EXECUTABLEcan be a whole command line for a JVM launch (java -Xmx… -jar …), so it must be shell-split; or - run a proxy on the MCP boundary purely to sniff the request.
Both are heavier and more fragile than a field that is already known when the hook payload is built.
The need is not specific to context-mode: any plugin that wants to gate behaviour on an ECA capability — a new hook type, a new payload field, changed semantics — would want the version.
Proposed change
Add the version to base-hook-data:
(ns eca.features.hooks
(:require
...
[eca.config :as config]
...))
(defn base-hook-data
"Returns common fields for ALL hooks: :workspaces, :cwd, :db-cache-path,
:session-id, :eca-executable, and :eca-version."
[db]
(let [workspaces (shared/get-workspaces db)
db-cache-path (shared/db-cache-path db)]
{:workspaces workspaces
:cwd (first workspaces)
:db-cache-path db-cache-path
:session-id (session-id-from-db-cache-path db-cache-path)
:eca-executable @shared/eca-executable*
:eca-version (config/eca-version)}))
config/eca-version is memoized, so this costs at most one resource read per process. eca.config does not depend on eca.features.hooks (directly or indirectly), so there is no require cycle.
Hook scripts then receive eca_version next to eca_executable.
A hook that ignores the field is unaffected.
Alternatives considered
- Reuse
:eca-executable— it is a path, or a whole JVM command line, not a version; parsing it is unreliable. - Spawn
ECA_EXECUTABLE --versionfrom the hook — works, but pays a process per ECA upgrade and has to handle multi-token command lines. The value is already in memory at hook-build time. - Read
resources/ECA_VERSIONfrom the plugin — not reachable; the resource is baked into the binary. - Rely on the MCP
initializeclientInfo — reaches MCP servers (ECA already sends"ECA"+config/eca-versioninmcp.clj), but not hooks, and this decision is made on the hook side.
Acceptance criteria
- Every hook stdin payload contains
eca_versionequal to(config/eca-version)(e.g."0.171.0"). - It is present for base hooks (
handlers.clj) and for chat hooks (chat.clj,chat/tool_calls.clj,chat/lifecycle.clj). - Hooks that ignore the field are unaffected.
Notes
- Discovered while making the
context-modeplugin support_meta.sessionId(#696) without a proxy or a spawning the the commandeca --version, which will be a new PR on top of ECA plugin PR #14 - Related: #696 — send the chat id as
_meta.sessionIdontools/call. - A machine-readable capability list would also work, but a version is simpler: the plugin keeps the "since which version" threshold itself.