Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Hdandria <henri.dandria@mistral.ai>
Co-authored-by: Ivana Dunisijevic <ivana.dunisijevic@mistral.ai>
Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Mert Unsal <mert.unsal@mistral.ai>
Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com>
Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Val <102326092+vdeva@users.noreply.github.com>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Clément Drouin 2026-06-19 11:01:24 +02:00 committed by GitHub
parent 564a14365e
commit 6bedf271ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
223 changed files with 10533 additions and 6947 deletions

View file

@ -1,16 +1,15 @@
from __future__ import annotations
import os
from pathlib import Path
import tempfile
import tomllib
from vibe.core.config.fingerprint import capture_stable_file
import tomli_w
from vibe.core.config.fingerprint import capture_stable_file, create_file_fingerprint
from vibe.core.config.layer import ConfigLayer, RawConfig
from vibe.core.config.patch import ConfigPatch
from vibe.core.config.types import (
EMPTY_CONFIG_SNAPSHOT,
ConflictStrategy,
LayerConfigSnapshot,
)
from vibe.core.config.types import EMPTY_CONFIG_SNAPSHOT, LayerConfigSnapshot
from vibe.core.paths._vibe_home import VIBE_HOME
@ -37,10 +36,29 @@ class UserConfigLayer(ConfigLayer[RawConfig]):
return LayerConfigSnapshot(data=data, fingerprint=fingerprint)
async def apply(
self,
patch: ConfigPatch,
*,
on_conflict: ConflictStrategy = ConflictStrategy.CANCEL,
) -> None:
raise NotImplementedError("UserConfigLayer.apply() is not implemented (M2)")
async def _save_to_store(self, next_config: RawConfig) -> str:
if not self._path.exists():
raise FileNotFoundError(self._path)
tmp_path: Path | None = None
try:
with tempfile.NamedTemporaryFile(
mode="wb",
dir=self._path.parent,
prefix=f".{self._path.name}.",
suffix=".tmp",
delete=False,
) as tmp_file:
tmp_path = Path(tmp_file.name)
tomli_w.dump(next_config.model_dump(), tmp_file)
tmp_file.flush() # Flush Python buffers.
os.fsync(tmp_file.fileno()) # Flush OS buffers.
fingerprint = create_file_fingerprint(tmp_file)
tmp_path.replace(self._path)
tmp_path = None
finally:
if tmp_path is not None:
tmp_path.unlink(missing_ok=True)
return fingerprint