Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion openadapt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,12 @@ def ask(prompt: str) -> str:
"--out) and exit. Runs nothing."
),
)
@click.option(
"-y",
"--yes",
is_flag=True,
help="Run straight through without pausing for Enter or prompts.",
)
# --headed is the older spelling of --watch. --headless was the opt-out when
# the window showed by default; hidden is the default now, so it changes
# nothing and is kept so older commands still run.
Expand Down Expand Up @@ -960,6 +966,7 @@ def quickstart(
no_break: bool,
verbose: bool,
more: bool,
yes: bool,
own: bool,
url: Optional[str],
task: Optional[str],
Expand Down Expand Up @@ -1078,7 +1085,7 @@ def quickstart(
openemr is None and _agent_serves_tutorial(),
keep=_keep_command(),
shadow=_shadowing_openadapt if _under_uvx() else None,
offer_publish=_quickstart_publish_offer(),
offer_publish=None if yes else _quickstart_publish_offer(),
)
try:
with _synthetic_scrub_off():
Expand All @@ -1088,6 +1095,7 @@ def quickstart(
break_it=not no_break,
verbose=verbose,
steps=steps,
interactive=False if yes else None,
openemr=openemr,
open_seal=open_seal,
)
Expand Down
6 changes: 5 additions & 1 deletion openadapt/quickstart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ def run_quickstart(

stream = stream or sys.stdout
if interactive is None:
interactive = bool(sys.stdin.isatty() and getattr(stream, "isatty", bool)())
from openadapt.seal_publish import in_ci

interactive = bool(
not in_ci() and sys.stdin.isatty() and getattr(stream, "isatty", bool)()
)
engine: Any
if openemr is not None:
from openadapt.quickstart.openemr import OpenEMREngine
Expand Down
2 changes: 1 addition & 1 deletion openadapt/quickstart/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ def write_run_receipts(run_dirs: list[Path]) -> int:
return 0
written = 0
for run_dir in run_dirs:
if not (Path(run_dir) / "report.json").is_file():
if not _artifact_is_file(Path(run_dir) / "report.json"):
continue
try:
note = receipt_after_run(Path(run_dir))
Expand Down
1 change: 1 addition & 0 deletions packages/flow/tests/test_quickstart_encrypted.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ def test_quickstart_on_a_fresh_machine_seals_every_run(
assert b'"execution_outcome":"VERIFIED"' in report.replace(b" ", b"")
# The run sealed: this is the step that failed on Flow 4.0.0.
assert (run_dir / "seal.json").is_file()
assert (run_dir / "receipt.json").is_file()
assert sealed_set.open_set(run_dir).is_file("run-summary.json")
63 changes: 63 additions & 0 deletions tests/test_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,3 +1432,66 @@ def test_next_steps_bridge_uses_record_and_checked_write(root):
"https://your-app.example --out my-task"
)
assert 'checked_write("verify.yaml", values)' in uvx_steps.verify_snippet


def test_quickstart_yes_flag_disables_interactive_and_publish_offer(
tmp_path, monkeypatch
):
"""``openadapt quickstart --yes`` runs straight through without prompts."""
from click.testing import CliRunner

captured: dict[str, object] = {}

def fake_run_quickstart(root, **kwargs):
captured["interactive"] = kwargs.get("interactive")
captured["steps"] = kwargs["steps"](Outcome(root=root))
return Outcome(root=root)

monkeypatch.setattr(cli, "_flow_runs_quickstart", lambda: True)
monkeypatch.setattr(cli, "_quickstart_publish_offer", lambda: lambda *a, **k: False)
monkeypatch.setattr("openadapt.quickstart.run_quickstart", fake_run_quickstart)

result = CliRunner().invoke(
cli.main, ["quickstart", "--yes", "--out", str(tmp_path / "qs")]
)
assert result.exit_code == 0, result.output
assert captured["interactive"] is False
assert captured["steps"].offer_publish is None


def test_quickstart_defaults_non_interactive_under_ci_even_with_tty(
tmp_path, monkeypatch
):
"""A PTY in CI must not block on ``Press Enter``."""
import openadapt.quickstart as quickstart_mod
from openadapt.quickstart.scene import MOCKMED

seen: dict[str, object] = {}

class FakeEngine:
root = tmp_path / "qs"
visible = False
scene = MOCKMED

def __init__(self, root, *, visible, pace_s=0.0):
self.root = root
self.visible = visible

def fake_run_story(engine, view, **kwargs):
seen["interactive"] = kwargs["interactive"]
return Outcome(root=engine.root)

monkeypatch.setenv("CI", "true")
monkeypatch.setattr(sys, "stdin", _Terminal())
monkeypatch.setattr("openadapt.quickstart.engine.FlowEngine", FakeEngine)
monkeypatch.setattr(quickstart_mod, "run_story", fake_run_story)

quickstart_mod.run_quickstart(
tmp_path / "qs",
visible=False,
break_it=True,
verbose=False,
steps=lambda o: NextSteps(verify=None, record="r", agent="a"),
stream=_Terminal(),
)
assert seen["interactive"] is False
54 changes: 54 additions & 0 deletions tests/test_quickstart_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,57 @@ def test_write_run_receipts_respects_openadapt_receipt_off(tmp_path, monkeypatch
assert written == 0
assert not (run / "receipt.json").exists()
assert not (run / "receipt.private.json").exists()


def test_write_run_receipts_writes_receipt_for_sealed_run(tmp_path, monkeypatch):
"""Encrypted quickstart runs store report.json as report.json.enc; receipts still write."""
pytest.importorskip("openadapt_flow.sealed_set")
pytest.importorskip("openadapt_types.receipt")
from openadapt_flow import at_rest, crypto, sealed_set

from openadapt.quickstart.engine import write_run_receipts

for name in (
at_rest.OPT_OUT_ENV,
at_rest.MODE_ENV,
at_rest.ENCRYPT_ENV,
crypto.ENV_KEY,
sealed_set.RECORDING_ENV_KEY,
"OPENADAPT_POLICY",
"OPENADAPT_RECEIPT",
):
monkeypatch.delenv(name, raising=False)
monkeypatch.setenv(at_rest.HOME_ENV, str(tmp_path / "at-rest-home"))
monkeypatch.setenv("OPENADAPT_SEAL_HOME", str(tmp_path / "seal-home"))
monkeypatch.setenv("OPENADAPT_FLOW_KEY_STORE", "file")
at_rest._reset_for_tests()
try:
run_dir = tmp_path / "run-1"
payload = json.dumps(
{
"workflow_name": "local-quickstart",
"started_at": "2026-11-25T00:00:00Z",
"execution_outcome": "VERIFIED",
"transaction_outcome": "VERIFIED",
"results": [],
}
).encode("utf-8")
with sealed_set.writing(run_dir, "run", crypto.resolve_key(None)):
sealed_set.write_bytes(run_dir / "report.json", payload)
assert not (run_dir / "report.json").exists()
assert (run_dir / "report.json.enc").is_file()

written = write_run_receipts([run_dir])
assert written == 1
assert (run_dir / "receipt.json").is_file()
assert sealed_set.is_file(run_dir / "receipt.private.json")

opened = sealed_set.open_set(run_dir)
opened.verify_all()
indexed = {
sealed_set._physical(rel, entry["codec"])
for rel, entry in opened._files.items()
}
assert set(sealed_set._disk_files(run_dir)) <= indexed
finally:
at_rest._reset_for_tests()