From 5d9a0bb5488eea4237051cc6dbd5ed6578f6011d Mon Sep 17 00:00:00 2001 From: mptyl Date: Sat, 27 Jun 2026 20:29:40 +0200 Subject: [PATCH] feat(harness): manifest provider/model/thinking/name + session new options (BE-6/7) Co-Authored-By: Claude Sonnet 4.6 --- harness/tests/test_manifest_pi_fields.py | 19 +++++++++++++++++++ harness/tht/cli/session_cmd.py | 11 ++++++++++- harness/tht/session/models.py | 4 ++++ harness/tht/session/store.py | 3 +++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 harness/tests/test_manifest_pi_fields.py diff --git a/harness/tests/test_manifest_pi_fields.py b/harness/tests/test_manifest_pi_fields.py new file mode 100644 index 00000000..89e9d158 --- /dev/null +++ b/harness/tests/test_manifest_pi_fields.py @@ -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 diff --git a/harness/tht/cli/session_cmd.py b/harness/tht/cli/session_cmd.py index c18faa1b..95f60962 100644 --- a/harness/tht/cli/session_cmd.py +++ b/harness/tht/cli/session_cmd.py @@ -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) diff --git a/harness/tht/session/models.py b/harness/tht/session/models.py index 89d8c154..6f4107f7 100644 --- a/harness/tht/session/models.py +++ b/harness/tht/session/models.py @@ -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): diff --git a/harness/tht/session/store.py b/harness/tht/session/store.py index ad8b00bd..33a1f0df 100644 --- a/harness/tht/session/store.py +++ b/harness/tht/session/store.py @@ -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)