feat(harness): manifest provider/model/thinking/name + session new options (BE-6/7)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 20:29:40 +02:00
co-authored by Claude Sonnet 4.6
parent 5e0e1cee03
commit 5d9a0bb548
4 changed files with 36 additions and 1 deletions
+19
View File
@@ -0,0 +1,19 @@
from tht.session.store import create_session
from tht.session.models import SessionManifest
def test_manifest_persists_pi_fields(tmp_path):
from tht.config import DatabaseConfig
db = DatabaseConfig(database="d", schema="s", transport="rest", user="u", password="p")
m = create_session("q", db, tmp_path, provider="zai", model="glm-5.2",
thinking="medium", name="sessione test")
reload = SessionManifest.from_yaml(tmp_path / m.id / "session_manifest.yaml")
assert reload.provider == "zai" and reload.model == "glm-5.2"
assert reload.thinking == "medium" and reload.name == "sessione test"
def test_manifest_pi_fields_optional(tmp_path):
from tht.config import DatabaseConfig
db = DatabaseConfig(database="d", schema="s", transport="rest", user="u", password="p")
m = create_session("q", db, tmp_path)
assert m.provider is None and m.model is None and m.thinking is None and m.name is None
+10 -1
View File
@@ -67,13 +67,22 @@ def list_cmd(
@session_app.command("new")
def new_cmd(
question: str = typer.Argument(..., help="La domanda in linguaggio naturale."),
provider: str = typer.Option(None, "--provider", help="Provider LLM (es. zai, anthropic)."),
model: str = typer.Option(None, "--model", help="Modello LLM (es. glm-5.2)."),
thinking: str = typer.Option(None, "--thinking", help="Livello di thinking (es. medium)."),
name: str = typer.Option(None, "--name", help="Nome descrittivo della sessione."),
json_out: bool = typer.Option(False, "--json", help="Emetti JSON puro {\"id\": ...} su stdout."),
config: Path = CONFIG_OPT,
) -> None:
"""Crea una sessione e stampa il suo id (ultima riga dell'output)."""
from tht.session.store import create_session
cfg = _load_config_or_exit(config)
manifest = create_session(question, cfg.database, cfg.paths.sessions)
manifest = create_session(question, cfg.database, cfg.paths.sessions,
provider=provider, model=model, thinking=thinking, name=name)
if json_out:
typer.echo(json.dumps({"id": manifest.id}, ensure_ascii=False))
return
typer.secho(f"OK: sessione creata in {session_dir(cfg, manifest.id)}", fg=typer.colors.GREEN)
typer.echo(manifest.id)
+4
View File
@@ -39,6 +39,10 @@ class SessionManifest(_YamlModel):
updated_at: datetime | None = None
updated_by: str | None = None
schema_version: int | None = None
provider: str | None = None
model: str | None = None
thinking: str | None = None
name: str | None = None
class Candidate(BaseModel):
+3
View File
@@ -53,6 +53,8 @@ def _new_id(question: str, sessions_root: Path, stamp: str) -> str:
def create_session(
question: str, db: DatabaseConfig, sessions_root: Path,
*, author: str | None = None, summary: str | None = None,
provider: str | None = None, model: str | None = None,
thinking: str | None = None, name: str | None = None,
) -> SessionManifest:
now = datetime.now(UTC)
# stamp con ora/min/sec: identifica univocamente sessioni dello stesso giorno
@@ -73,6 +75,7 @@ def create_session(
database=db.database, schema=db.db_schema,
author=who, summary=summary or _summarize(question),
updated_at=now, updated_by=who, schema_version=schema_version,
provider=provider, model=model, thinking=thinking, name=name,
)
session_dir = sessions_root / session_id
manifest.to_yaml(session_dir / MANIFEST)