chore: anchor fresh-start history to upstream
This commit is contained in:
@@ -9,8 +9,6 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
|
||||
from agent.transports.hermes_tools_mcp_server import HERMES_TOOLS_MCP_SERVER_NAME
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -376,9 +374,21 @@ def _build_hermes_tools_mcp_entry() -> dict:
|
||||
|
||||
|
||||
def _write_atomic(target: Path, text: str) -> None:
|
||||
"""Atomic rewrite so a crash mid-write never leaves a half-written config.toml codex refuses to load."""
|
||||
from utils import atomic_write_text
|
||||
atomic_write_text(target, text, tmp_prefix=".config.toml.", preserve_mode=True)
|
||||
"""Write via a same-directory temp file + rename (atomic on POSIX, ReplaceFile on Windows) so a
|
||||
crash mid-write never leaves a half-written config.toml that codex would refuse to load."""
|
||||
import tempfile
|
||||
tmp_fd, tmp_path_str = tempfile.mkstemp(prefix=".config.toml.", dir=str(target.parent))
|
||||
tmp_path = Path(tmp_path_str)
|
||||
try:
|
||||
with os.fdopen(tmp_fd, "w", encoding="utf-8") as fh:
|
||||
fh.write(text)
|
||||
tmp_path.replace(target)
|
||||
except Exception:
|
||||
try:
|
||||
tmp_path.unlink(missing_ok=True)
|
||||
except Exception:
|
||||
pass
|
||||
raise
|
||||
|
||||
|
||||
def migrate(
|
||||
@@ -427,9 +437,9 @@ def migrate(
|
||||
if default_permission_profile:
|
||||
report.wrote_permissions_default = default_permission_profile
|
||||
if expose_hermes_tools:
|
||||
translated[HERMES_TOOLS_MCP_SERVER_NAME] = _build_hermes_tools_mcp_entry()
|
||||
if HERMES_TOOLS_MCP_SERVER_NAME not in report.migrated:
|
||||
report.migrated.append(HERMES_TOOLS_MCP_SERVER_NAME)
|
||||
translated["hermes-tools"] = _build_hermes_tools_mcp_entry()
|
||||
if "hermes-tools" not in report.migrated:
|
||||
report.migrated.append("hermes-tools")
|
||||
managed_block = render_codex_toml_section(
|
||||
translated, plugins=plugins, default_permission_profile=default_permission_profile)
|
||||
new_text = managed_block
|
||||
|
||||
Reference in New Issue
Block a user