wip fixing regressions, removing hardcoded paths

This commit is contained in:
2026-03-06 19:24:08 -05:00
parent cb1440d61c
commit f439b5c525
5 changed files with 43 additions and 53 deletions

View File

@@ -1,16 +1,21 @@
from __future__ import annotations
import tomllib
import os
from dataclasses import dataclass, field
from typing import List, Optional, Dict, Any, Union
from pathlib import Path
from src.paths import get_config_path
CONFIG_PATH = Path(os.environ.get("SLOP_CONFIG", "config.toml"))
CONFIG_PATH = get_config_path()
def load_config() -> dict[str, Any]:
with open(CONFIG_PATH, "rb") as f:
return tomllib.load(f)
def save_config(config: dict[str, Any]) -> None:
import tomli_w
with open(CONFIG_PATH, "wb") as f:
tomli_w.dump(config, f)
# Global constants for agent tools
AGENT_TOOL_NAMES = [
"read_file",
@@ -32,29 +37,6 @@ AGENT_TOOL_NAMES = [
"py_get_hierarchy"
]
def parse_history_entries(history_strings: list[str], roles: list[str]) -> list[dict[str, Any]]:
"""Parse stored history strings back to disc entry dicts."""
import re
entries = []
for raw in history_strings:
ts = ""
rest = raw
if rest.startswith("@"):
nl = rest.find("\n")
if nl != -1:
ts = rest[1:nl]
rest = rest[nl + 1:]
known = roles or ["User", "AI"]
role_pat = re.compile(r"^(" + "|".join(re.escape(r) for r in known) + r"):", re.IGNORECASE)
match = role_pat.match(rest)
role = match.group(1) if match else "User"
if match:
content = rest[match.end():].strip()
else:
content = rest
entries.append({"role": role, "content": content, "collapsed": False, "ts": ts})
return entries
@dataclass
class Ticket:
"""