feat(adapters): add Mistral Vibe platform adapter - #1044
Open
xavierpestel-ai wants to merge 2 commits into
Open
Conversation
Add support for Mistral AI's official coding CLI, Mistral Vibe (https://github.com/mistralai/mistral-vibe, package: mistral-vibe on PyPI, command: vibe). ## What's added - New `MistralVibeAdapter` (`src/adapters/mistral-vibe/`) implementing the `HookAdapter` contract for Vibe's JSON stdin/stdout hook paradigm over TOML-declared hooks (`~/.vibe/hooks.toml`). - Hook scripts (`hooks/mistral-vibe/{pretooluse,posttooluse}.mjs`) that translate between Vibe's wire format and context-mode's routing/session event pipelines. - Vibe formatter added to `hooks/core/formatters.mjs` and namer added to `hooks/core/tool-naming.mjs`. - Platform registration in `types.ts`, `detect.ts` (env-var, config-dir, session-dir, and getAdapter switch), `client-map.ts`, `cli.ts` (hook dispatcher), and `platform-detect.mjs` (hook-side mirror). - Routing instructions at `configs/mistral-vibe/AGENTS.md` (Vibe's default instruction file). - Adapter test suite (`tests/adapters/mistral-vibe.test.ts`, 49 tests). - README + `docs/platform-support.md` sections. ## Design notes - **Paradigm**: json-stdio over TOML `[[hooks]]` array tables. Same subprocess-with-JSON-payload model as Claude Code / Codex / Kimi, but hooks live in a sibling `hooks.toml` distinct from `config.toml`. - **Capabilities**: `preToolUse` and `postToolUse` true; `canModifyArgs` true (via `hook_specific_output.tool_input`); `canModifyOutput`, `preCompact`, `sessionStart`, and `canInjectSessionContext` false — Vibe exposes only `pre_tool`, `post_tool`, and `post_agent`, and `post_tool`'s `additional_context` is append-only. - **Session continuity**: no PreCompact/SessionStart hook available. The routing block in AGENTS.md provides model-side memory queries as the compaction-recovery workaround. - **Detection**: relies on `$VIBE_HOME` env var + `~/.vibe/` directory presence, NOT MCP `clientInfo.name`. Vibe uses the MCP SDK default `Implementation(name="mcp", version="0.1.0")` because it does not pass `client_info` to `ClientSession` — that name is too generic to safely map to any platform. Client-map entries are placeholders that will match if Vibe ever ships a proper client_info. - **Coexistence with rtk**: both context-mode and rtk register `pre_tool bash` hooks. Vibe runs hooks in TOML declaration order; users should keep `context-mode-pretool` first so redirected commands never reach rtk. The two coexist cleanly; context-mode's redirect is a no-op passthrough when it does not apply. - **VIBE_HOME env var** is registered with `detect: false` so an unrelated shell with the var set does not misclassify a non-Vibe host. ## Testing - 49 new adapter tests all pass - Baseline (main): 4688/4742 pass, 25 pre-existing failures - With PR: 4737/4791 pass, 25 pre-existing failures - Delta: +49 tests, zero regressions (all pre-existing failures are git-config / test-env issues unrelated to this change; verified by before/after diff) - Fix to `tests/util/project-dir-matrix.test.ts` adds `"mistral-vibe"` to the platform sanity list (matches the pattern documented in the existing comment: "When adding a new adapter, append it here"). - Verified end-to-end with a live `vibe --output json` session: `context-mode-pretool` and `context-mode-posttool` hooks fire, MCP server reachable, `context-mode_ctx_stats` tool responds. ## References - Vibe hook docs: https://docs.mistral.ai/vibe/code/cli/hooks - Vibe MCP docs: https://docs.mistral.ai/vibe/code/cli/mcp-servers - Upstream hook schema: vibe/core/hooks/models.py in mistralai/mistral-vibe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for Mistral Vibe (mistralai/mistral-vibe) — Mistral AI's official open-source coding CLI. Package
mistral-vibeon PyPI, commandvibe, Python 3.12+, MIT-licensed.Zero changes required in Vibe itself — the integration uses Vibe's stable public surfaces:
[[hooks]]array tables in~/.vibe/hooks.tomland[[mcp_servers]]in~/.vibe/config.toml.Why
Vibe ships with MCP support and a hook system nearly identical to Claude Code / Codex / Kimi (JSON stdin/stdout over subprocesses), so it slots naturally into the existing adapter pattern. It's the 18th supported platform and the first Python-based one in the JSON-stdio group.
What's added
src/adapters/mistral-vibe/)index.ts—MistralVibeAdapterimplementingHookAdapterhooks.ts— hook type constants + wire-protocol docstringpaths.ts—resolveVibeConfigDir()honoring$VIBE_HOMEconfig.ts— thin re-exports (parity with sibling adapters)hooks/mistral-vibe/{pretooluse,posttooluse}.mjs) translating Vibe wire format ↔ context-mode routing/session pipelineshooks/core/formatters.mjs+ namer inhooks/core/tool-naming.mjstypes.ts,detect.ts(env-var, config-dir, session-dir,getAdapterswitch),client-map.ts,cli.ts(hook dispatcher), andhooks/core/platform-detect.mjs(hook-side mirror)configs/mistral-vibe/AGENTS.mdtests/adapters/mistral-vibe.test.ts, 49 tests)docs/platform-support.mdplatform sectionDesign notes
json-stdio(TOML[[hooks]])hooks.tomldistinct fromconfig.tomlpreToolUse: true,postToolUse: true,canModifyArgs: truepre_toolrewrite viahook_specific_output.tool_inputand deny viadecision: "deny"preCompact,sessionStart,canModifyOutput,canInjectSessionContextpre_tool,post_tool,post_agent.post_tooladditional_contextis append-only, not a rewrite$VIBE_HOMEenv var +~/.vibe/dirclientInfo.nameAGENTS.mdMCP clientInfo caveat
Vibe uses the MCP SDK's default
Implementation(name="mcp", version="0.1.0")because it does not passclient_infotoClientSession(seevibe/core/tools/mcp/tools.py). That name is too generic to safely map to any platform, so detection relies on env-var + config-dir signals instead. Theclient-map.tsentries for"mistral-vibe"/"Mistral Vibe"/"vibe"are placeholders that will match if Vibe ever ships a properclient_info.Coexistence with
rtkBoth context-mode and
rtk(a token-optimization CLI) registerpre_tool bashhooks. Vibe runs hooks in TOML declaration order — users should keepcontext-mode-pretoolfirst so redirected commands never reach rtk. The two coexist cleanly; context-mode's redirect is a no-op passthrough when it doesn't apply. This is documented inconfigs/mistral-vibe/AGENTS.mdand the README section.Session continuity trade-off
Vibe lacks PreCompact / SessionStart hooks, so full snapshot-based session restore is not available. The routing block in
AGENTS.mdprovides model-side memory queries (viactx_searchon the persisted session events) as the compaction-recovery workaround. Session events are captured normally viapost_tooland searchable throughctx_search— only the automatic "restore after compact" pipeline is missing.Testing
Ran the full suite before and after:
mainstill fail on this branch (all env-related:git commitwithout localuser.name,IDEA_INITIAL_DIRECTORYunset, macOS-specific casing checks). Zero regressions caused by this PR.tests/util/project-dir-matrix.test.ts: added"mistral-vibe"to the platform sanity list (the file's existing comment says "When adding a new adapter, append it here").npm run typecheck) ✅npm run build—tsc+ esbuild bundles + assert-bundle + assert-asymmetric-drift) ✅End-to-end validation
Verified against a live
vibe --output jsonsession with the adapter'shooks.toml+config.tomlinstalled:context-mode-pretoolhook fires on everybashinvocation (statusok, ~1ms)context-mode-posttoolhook fires on every tool call (statusok, ~80ms)context-mode_ctx_statsreturnedcontext-mode < 1 min 0 calls ... v1.0.169Config snippets (from the manual test, now generated by
configureAllHooks):References
vibe/core/hooks/models.pyChecklist (per CONTRIBUTING.md)
tests/adapters/mistral-vibe.test.ts, one file per adapter per convention)npm run typecheck)npm run build)main(before/after diff of full suite)server.bundle.mjs,cli.bundle.mjs,hooks/security.bundle.mjs)docs/platform-support.mdupdatedconfigs/mistral-vibe/AGENTS.md)