feat(harness): port CLI skeleton + nsp phase meta --json (F2, kills JS/Python drift)
nsp.cli app registers phase_app (the gate's workflow-fact source). phase meta
--json emits {schema_version, max_phase, phases:[{num,id,name,advance,artifacts_out}]}
from load_workflow() -- the single source of truth. F8/datamart is present (the
exact JS-drift bug in ChironeWp3, PHASE_NAMES truncated to 7, is structurally gone).
Scope: the 12 other command groups land in their porting tasks (A9 ports
db/mschema/_guards; B1 vectorstore; B3 search/lshindex). Eager-importing them now
would break the app on unported deps -- deferred to keep the suite green at each commit.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""nsp phase -- workflow HITL gate commands.
|
||||
|
||||
`meta` is the single source the gate (nsp-gate.js) reads workflow facts from,
|
||||
killing the JS/Python PHASE_NAMES drift (F2). advance/reopen/show land with the
|
||||
session/db ports (A9) -- they need current_phase + load_session_or_exit which
|
||||
depend on the not-yet-ported session store helpers.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import typer
|
||||
|
||||
from nsp.workflow import load_workflow
|
||||
|
||||
phase_app = typer.Typer(help="Fase del workflow HITL (gate di avanzamento/ritorno)")
|
||||
|
||||
|
||||
@phase_app.command("meta")
|
||||
def meta_cmd(
|
||||
as_json: bool = typer.Option(
|
||||
False,
|
||||
"--json",
|
||||
help="Emette i metadati del workflow come JSON (usato dall'estensione gate).",
|
||||
),
|
||||
) -> None:
|
||||
"""Stampa i metadati del workflow derivati da workflow.yaml (F2)."""
|
||||
wf = load_workflow()
|
||||
if not as_json:
|
||||
typer.echo(f"max_phase: {wf.max_phase}")
|
||||
for p in wf.phases:
|
||||
typer.echo(f" {p.id} ({p.num}/{wf.max_phase}) {p.name} advance={p.advance}")
|
||||
return
|
||||
typer.echo(
|
||||
json.dumps(
|
||||
{
|
||||
"schema_version": wf.schema_version,
|
||||
"max_phase": wf.max_phase,
|
||||
"phases": [
|
||||
{
|
||||
"num": p.num,
|
||||
"id": p.id,
|
||||
"name": p.name,
|
||||
"advance": p.advance,
|
||||
"artifacts_out": p.artifacts_out,
|
||||
}
|
||||
for p in wf.phases
|
||||
],
|
||||
}
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user