Files
Elydora-Python-SDK/elydora/plugins/cline_io.py
T
雷电芽衣 407e4628a0 chore(python): audit providers kimi grok qwen letta
Move the four providers onto _runtime and _shell_command; expected
runtime scripts take the runtime config; add unique_preconditions.

Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
2026-09-02 23:58:10 -04:00

46 lines
1.5 KiB
Python

"""Physical Cline hook and managed runtime validation."""
from __future__ import annotations
import os
from typing import Tuple
from ._managed_files import physical_directory_exists, read_physical_file
from ._runtime import expected_runtime_scripts, runtime_contract_exists
from ._strict_json import JsonObject
from .cline_contract import AGENT_KEY, HookFile, RuntimeContract, parse_metadata
def validate_hook_tree(hooks_directory: str) -> None:
physical_directory_exists(os.path.dirname(hooks_directory), "Cline configuration directory")
physical_directory_exists(hooks_directory, "Cline hooks directory")
def read_hook_file(file_path: str) -> HookFile:
validate_hook_tree(os.path.dirname(file_path))
snapshot = read_physical_file(file_path, "Cline hook")
if snapshot is None:
return HookFile(False, file_path)
return HookFile(
exists=True,
file_path=file_path,
source=snapshot.contents,
metadata=parse_metadata(file_path, snapshot.contents),
)
def require_available_hook_file(file: HookFile) -> None:
if file.exists and file.metadata is None:
raise ValueError(
f"Cline hook at {file.file_path} already exists and is owned "
"by another integration"
)
def _expected_scripts(agent_id: str, _config: JsonObject) -> Tuple[str, str]:
return expected_runtime_scripts(AGENT_KEY, agent_id)
def runtime_files_exist(contract: RuntimeContract) -> bool:
return runtime_contract_exists(contract, AGENT_KEY, "Cline", _expected_scripts)