fix(conductor): Apply review suggestions for track 'history_segregation'
This commit is contained in:
@@ -16,6 +16,7 @@ import re
|
|||||||
import glob
|
import glob
|
||||||
from pathlib import Path, PureWindowsPath
|
from pathlib import Path, PureWindowsPath
|
||||||
import summarize
|
import summarize
|
||||||
|
import project_manager
|
||||||
|
|
||||||
def find_next_increment(output_dir: Path, namespace: str) -> int:
|
def find_next_increment(output_dir: Path, namespace: str) -> int:
|
||||||
pattern = re.compile(rf"^{re.escape(namespace)}_(\d+)\.md$")
|
pattern = re.compile(rf"^{re.escape(namespace)}_(\d+)\.md$")
|
||||||
@@ -224,9 +225,6 @@ def run(config: dict) -> tuple[str, Path, list[dict]]:
|
|||||||
return markdown, output_file, file_items
|
return markdown, output_file, file_items
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
import project_manager
|
|
||||||
import tomllib
|
|
||||||
|
|
||||||
# Load global config to find active project
|
# Load global config to find active project
|
||||||
config_path = Path("config.toml")
|
config_path = Path("config.toml")
|
||||||
if not config_path.exists():
|
if not config_path.exists():
|
||||||
|
|||||||
89
manual_slop_history.toml
Normal file
89
manual_slop_history.toml
Normal file
File diff suppressed because one or more lines are too long
@@ -122,11 +122,16 @@ def default_project(name: str = "unnamed") -> dict:
|
|||||||
# ── load / save ──────────────────────────────────────────────────────────────
|
# ── load / save ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def get_history_path(project_path: str | Path) -> Path:
|
def get_history_path(project_path: str | Path) -> Path:
|
||||||
|
"""Return the Path to the sibling history TOML file for a given project."""
|
||||||
p = Path(project_path)
|
p = Path(project_path)
|
||||||
return p.parent / f"{p.stem}_history.toml"
|
return p.parent / f"{p.stem}_history.toml"
|
||||||
|
|
||||||
|
|
||||||
def load_project(path) -> dict:
|
def load_project(path: str | Path) -> dict:
|
||||||
|
"""
|
||||||
|
Load a project TOML file.
|
||||||
|
Automatically migrates legacy 'discussion' keys to a sibling history file.
|
||||||
|
"""
|
||||||
with open(path, "rb") as f:
|
with open(path, "rb") as f:
|
||||||
proj = tomllib.load(f)
|
proj = tomllib.load(f)
|
||||||
|
|
||||||
@@ -150,6 +155,7 @@ def load_project(path) -> dict:
|
|||||||
|
|
||||||
|
|
||||||
def load_history(project_path: str | Path) -> dict:
|
def load_history(project_path: str | Path) -> dict:
|
||||||
|
"""Load the segregated discussion history from its dedicated TOML file."""
|
||||||
hist_path = get_history_path(project_path)
|
hist_path = get_history_path(project_path)
|
||||||
if hist_path.exists():
|
if hist_path.exists():
|
||||||
with open(hist_path, "rb") as f:
|
with open(hist_path, "rb") as f:
|
||||||
@@ -157,7 +163,11 @@ def load_history(project_path: str | Path) -> dict:
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def save_project(proj: dict, path, disc_data: dict | None = None):
|
def save_project(proj: dict, path: str | Path, disc_data: dict | None = None):
|
||||||
|
"""
|
||||||
|
Save the project TOML.
|
||||||
|
If 'discussion' is present in proj, it is moved to the sibling history file.
|
||||||
|
"""
|
||||||
# Ensure 'discussion' is NOT in the main project dict
|
# Ensure 'discussion' is NOT in the main project dict
|
||||||
if "discussion" in proj:
|
if "discussion" in proj:
|
||||||
# If disc_data wasn't provided, use the one from proj
|
# If disc_data wasn't provided, use the one from proj
|
||||||
|
|||||||
Reference in New Issue
Block a user