Co-authored-by: Carlo <carloantonio.patti@mistral.ai>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Clement Sirieix <clem.sirieix@gmail.com>
Co-authored-by: Michel Thomazo <michel.thomazo@mistral.ai>
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Vincent Guilloux <vincent.guilloux@mistral.ai>
Co-authored-by: Thomas Kenbeek <thomas.kenbeek@mistral.ai>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Quentin 2026-02-27 17:31:58 +01:00 committed by GitHub
parent a560a47ce8
commit 5d2e01a6d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
139 changed files with 7152 additions and 1457 deletions

View file

@ -4,6 +4,7 @@ from pathlib import Path
from typing import Literal
from vibe.core.paths.global_paths import VIBE_HOME, GlobalPath
from vibe.core.paths.local_config_walk import walk_local_config_dirs_all
from vibe.core.trusted_folders import trusted_folders_manager
_config_paths_locked: bool = True
@ -31,30 +32,24 @@ def _resolve_config_path(basename: str, type: Literal["file", "dir"]) -> Path:
return VIBE_HOME.path / basename
def resolve_local_tools_dir(dir: Path) -> Path | None:
if not trusted_folders_manager.is_trusted(dir):
return None
if (candidate := dir / ".vibe" / "tools").is_dir():
return candidate
return None
def _discover_local_config_dirs_all(
root: Path,
) -> tuple[tuple[Path, ...], tuple[Path, ...], tuple[Path, ...]]:
if not trusted_folders_manager.is_trusted(root):
return ((), (), ())
return walk_local_config_dirs_all(root)
def resolve_local_skills_dirs(dir: Path) -> list[Path]:
if not trusted_folders_manager.is_trusted(dir):
return []
return [
candidate
for candidate in [dir / ".vibe" / "skills", dir / ".agents" / "skills"]
if candidate.is_dir()
]
def discover_local_tools_dirs(root: Path) -> list[Path]:
return list(_discover_local_config_dirs_all(root)[0])
def resolve_local_agents_dir(dir: Path) -> Path | None:
if not trusted_folders_manager.is_trusted(dir):
return None
if (candidate := dir / ".vibe" / "agents").is_dir():
return candidate
return None
def discover_local_skills_dirs(root: Path) -> list[Path]:
return list(_discover_local_config_dirs_all(root)[1])
def discover_local_agents_dirs(root: Path) -> list[Path]:
return list(_discover_local_config_dirs_all(root)[2])
def unlock_config_paths() -> None:

View file

@ -0,0 +1,39 @@
from __future__ import annotations
from functools import cache
import os
from pathlib import Path
from vibe.core.autocompletion.file_indexer.ignore_rules import WALK_SKIP_DIR_NAMES
_VIBE_DIR = ".vibe"
_TOOLS_SUBDIR = Path(_VIBE_DIR) / "tools"
_VIBE_SKILLS_SUBDIR = Path(_VIBE_DIR) / "skills"
_AGENTS_SUBDIR = Path(_VIBE_DIR) / "agents"
_AGENTS_DIR = ".agents"
_AGENTS_SKILLS_SUBDIR = Path(_AGENTS_DIR) / "skills"
@cache
def walk_local_config_dirs_all(
root: Path,
) -> tuple[tuple[Path, ...], tuple[Path, ...], tuple[Path, ...]]:
tools_dirs: list[Path] = []
skills_dirs: list[Path] = []
agents_dirs: list[Path] = []
resolved_root = root.resolve()
for dirpath, dirnames, _ in os.walk(resolved_root, topdown=True):
dir_set = frozenset(dirnames)
path = Path(dirpath)
if _VIBE_DIR in dir_set:
if (candidate := path / _TOOLS_SUBDIR).is_dir():
tools_dirs.append(candidate)
if (candidate := path / _VIBE_SKILLS_SUBDIR).is_dir():
skills_dirs.append(candidate)
if (candidate := path / _AGENTS_SUBDIR).is_dir():
agents_dirs.append(candidate)
if _AGENTS_DIR in dir_set:
if (candidate := path / _AGENTS_SKILLS_SUBDIR).is_dir():
skills_dirs.append(candidate)
dirnames[:] = sorted(d for d in dirnames if d not in WALK_SKIP_DIR_NAMES)
return (tuple(tools_dirs), tuple(skills_dirs), tuple(agents_dirs))