aethis-cli 0.45.0__tar.gz → 0.47.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/PKG-INFO +1 -1
  2. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/_version.py +1 -1
  3. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/client.py +55 -0
  4. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/generate_cmd.py +61 -3
  5. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/publish_cmd.py +10 -0
  6. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/refine_cmd.py +4 -0
  7. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/config.py +12 -0
  8. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli.egg-info/PKG-INFO +1 -1
  9. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli.egg-info/SOURCES.txt +1 -0
  10. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/pyproject.toml +1 -1
  11. aethis_cli-0.47.0/tests/test_generation_models.py +268 -0
  12. aethis_cli-0.47.0/tests/test_publish_display_name.py +77 -0
  13. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_source_safeguards.py +3 -1
  14. aethis_cli-0.45.0/tests/test_generation_models.py +0 -129
  15. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/LICENSE +0 -0
  16. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/README.md +0 -0
  17. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/__init__.py +0 -0
  18. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/__main__.py +0 -0
  19. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/_terminal_safe.py +0 -0
  20. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/auth.py +0 -0
  21. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/auth_helpers.py +0 -0
  22. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/auth_providers.py +0 -0
  23. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/__init__.py +0 -0
  24. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/_id_utils.py +0 -0
  25. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/account_cmd.py +0 -0
  26. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/cancel_cmd.py +0 -0
  27. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/decide_cmd.py +0 -0
  28. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/explain_cmd.py +0 -0
  29. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/fields_cmd.py +0 -0
  30. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/guidance_cmd.py +0 -0
  31. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/init_cmd.py +0 -0
  32. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/login_cmd.py +0 -0
  33. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/mcp_cmd.py +0 -0
  34. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/profile_cmd.py +0 -0
  35. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/projects_cmd.py +0 -0
  36. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/review_cmd.py +0 -0
  37. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/rulebooks_cmd.py +0 -0
  38. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/rulesets_cmd.py +0 -0
  39. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/status_cmd.py +0 -0
  40. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/test_cmd.py +0 -0
  41. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/update_cmd.py +0 -0
  42. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/usage_cmd.py +0 -0
  43. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/commands/whoami_cmd.py +0 -0
  44. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/contract.py +0 -0
  45. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/decision_view.py +0 -0
  46. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/errors.py +0 -0
  47. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/generation_status.py +0 -0
  48. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/main.py +0 -0
  49. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/output.py +0 -0
  50. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/prompts.py +0 -0
  51. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/py.typed +0 -0
  52. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/render.py +0 -0
  53. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/source_safeguards.py +0 -0
  54. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/source_targets.py +0 -0
  55. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli/update_check.py +0 -0
  56. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli.egg-info/dependency_links.txt +0 -0
  57. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli.egg-info/entry_points.txt +0 -0
  58. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli.egg-info/requires.txt +0 -0
  59. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/aethis_cli.egg-info/top_level.txt +0 -0
  60. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/setup.cfg +0 -0
  61. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_acceptance_contract.py +0 -0
  62. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_account_cmd.py +0 -0
  63. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_auth.py +0 -0
  64. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_auth_providers.py +0 -0
  65. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_cancel_cmd.py +0 -0
  66. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_capability_boundary.py +0 -0
  67. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_client.py +0 -0
  68. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_config.py +0 -0
  69. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_contract_decide.py +0 -0
  70. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_contract_identity_and_sources.py +0 -0
  71. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_contract_request_surface.py +0 -0
  72. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_contract_rulebook_decide.py +0 -0
  73. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_credential_server.py +0 -0
  74. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_credential_url_parser.py +0 -0
  75. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_decide_cmd.py +0 -0
  76. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_documented_commands_run.py +0 -0
  77. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_empty_input_guards.py +0 -0
  78. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_explain_cmd.py +0 -0
  79. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_field_behaviour_metadata_transport.py +0 -0
  80. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_field_dependency_and_identity_transport.py +0 -0
  81. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_field_display_metadata_transport.py +0 -0
  82. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_field_notes_validation.py +0 -0
  83. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_fields_cmd.py +0 -0
  84. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_generate_failure_reporting.py +0 -0
  85. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_generate_fields.py +0 -0
  86. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_generate_no_publish.py +0 -0
  87. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_generate_replace_tests.py +0 -0
  88. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_generation_status.py +0 -0
  89. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_guidance_cli.py +0 -0
  90. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_id_utils.py +0 -0
  91. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_init.py +0 -0
  92. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_json_projection_pinning.py +0 -0
  93. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_lazy_auth.py +0 -0
  94. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_login_headless.py +0 -0
  95. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_main.py +0 -0
  96. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_mcp_cmd.py +0 -0
  97. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_output.py +0 -0
  98. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_profiles.py +0 -0
  99. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_project_file_trust.py +0 -0
  100. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_prompts.py +0 -0
  101. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_publish_force.py +0 -0
  102. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_publish_rulebook_flags.py +0 -0
  103. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_publish_source_targets.py +0 -0
  104. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_release_tooling.py +0 -0
  105. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_render.py +0 -0
  106. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_review_cmd.py +0 -0
  107. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_rulebooks_cmd.py +0 -0
  108. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_rulesets_b1b_lifecycle.py +0 -0
  109. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_spacecraft_example_pin.py +0 -0
  110. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_status_cmd.py +0 -0
  111. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_transport_error_rendering.py +0 -0
  112. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_update_check.py +0 -0
  113. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_update_cmd.py +0 -0
  114. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_usage.py +0 -0
  115. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_value_space_transport.py +0 -0
  116. {aethis_cli-0.45.0 → aethis_cli-0.47.0}/tests/test_whoami_cmd.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aethis-cli
3
- Version: 0.45.0
3
+ Version: 0.47.0
4
4
  Summary: CLI for the Aethis developer API — author, test, and publish rulesets
5
5
  Author-email: Aethis <eng@aethis.ai>
6
6
  License-Expression: MIT
@@ -1,3 +1,3 @@
1
1
  """Version info — updated per release."""
2
2
 
3
- __version__ = "0.45.0"
3
+ __version__ = "0.47.0"
@@ -22,6 +22,32 @@ KeyRefreshCallback = Callable[..., str]
22
22
  # True/False (asked, got an answer) and None (asked, could not tell) — the
23
23
  # three states a capability probe genuinely has.
24
24
  _UNPROBED = object()
25
+ # Distinguishes a caller omitting thinking from explicitly sending JSON null.
26
+ _UNSET = object()
27
+ # Keep this in lockstep with the engine's syntax-only guard. Leading zeroes
28
+ # are stripped before counting, so the limit bounds integer work rather than
29
+ # rejecting a canonicalisable spelling.
30
+ _MAX_THINKING_DIGITS = 10
31
+
32
+
33
+ def normalize_thinking(thinking: str | None | object = _UNSET) -> str | None | object:
34
+ """Validate only the public syntax; engine owns model capabilities/bounds."""
35
+ if thinking is _UNSET or thinking is None:
36
+ return thinking
37
+ if not isinstance(thinking, str):
38
+ raise ValueError("invalid_thinking: use disabled, adaptive, or enabled:ASCII-decimal>=1024")
39
+ value = thinking.strip()
40
+ if value in {"disabled", "adaptive"}:
41
+ return value
42
+ if not value.startswith("enabled:"):
43
+ raise ValueError("invalid_thinking: use disabled, adaptive, or enabled:ASCII-decimal>=1024")
44
+ digits = value[len("enabled:") :]
45
+ if not digits or not digits.isascii() or not digits.isdecimal():
46
+ raise ValueError("invalid_thinking: use disabled, adaptive, or enabled:ASCII-decimal>=1024")
47
+ canonical = digits.lstrip("0") or "0"
48
+ if len(canonical) > _MAX_THINKING_DIGITS or len(canonical) < 4 or (len(canonical) == 4 and canonical < "1024"):
49
+ raise ValueError("invalid_thinking: use disabled, adaptive, or enabled:ASCII-decimal>=1024")
50
+ return f"enabled:{canonical}"
25
51
 
26
52
 
27
53
  class GenerationModel(str, Enum):
@@ -418,6 +444,17 @@ class AethisClient:
418
444
  """
419
445
  return self._schema_properties("RulebookFieldSpec")
420
446
 
447
+ def generation_mode_request_properties(self, *, refresh: bool = False) -> Optional[set[str]]:
448
+ """Properties advertised for generation admission controls.
449
+
450
+ Unlike a harmless display property, an unknown thinking control could be
451
+ silently ignored by an older engine, so callers use this as a strict
452
+ compatibility gate before any authoring mutation.
453
+ """
454
+ if refresh:
455
+ self._field_spec_properties.pop("GenerationModeRequest", None)
456
+ return self._schema_properties("GenerationModeRequest")
457
+
421
458
  def set_field_spec(self, project_id: str, expected_fields: list[dict]) -> dict:
422
459
  """Pin the project's expected field vocabulary (key + type + enum values).
423
460
 
@@ -483,6 +520,7 @@ class AethisClient:
483
520
  *,
484
521
  model: Optional[GenerationModel] = None,
485
522
  deepseek_key: Optional[str] = None,
523
+ thinking: str | None | object = _UNSET,
486
524
  ) -> dict:
487
525
  """Trigger generation. ``mode="refine"`` seeds from the section's active
488
526
  ruleset and makes the minimal edit to fix failing tests; omitting ``mode``
@@ -496,6 +534,18 @@ class AethisClient:
496
534
  body["seed_ruleset_id"] = seed_ruleset_id
497
535
  if model is not None:
498
536
  body["model"] = GenerationModel(model).value
537
+ # Presence matters: JSON null inherits the engine setting; an explicit
538
+ # string is validated by the engine before it admits the job.
539
+ thinking = normalize_thinking(thinking)
540
+ if thinking is not _UNSET:
541
+ properties = self.generation_mode_request_properties(refresh=True)
542
+ if properties is None:
543
+ raise ValueError("The generation control schema could not be read; no generation was started")
544
+ if "thinking" not in properties:
545
+ raise ValueError(
546
+ "This engine does not advertise per-generation thinking controls; no generation was started"
547
+ )
548
+ body["thinking"] = thinking
499
549
  if deepseek_key and model != GenerationModel.deepseek:
500
550
  raise ValueError("A DeepSeek key requires model=deepseek-flash")
501
551
  kwargs: dict[str, Any] = {"json": body} if body else {}
@@ -550,10 +600,15 @@ class AethisClient:
550
600
  rulebook_id: str | None = None,
551
601
  ruleset_name: str | None = None,
552
602
  source_targets: dict[str, dict] | None = None,
603
+ name: str | None = None,
553
604
  ) -> dict:
554
605
  body: dict = {}
555
606
  if slug is not None:
556
607
  body["slug"] = slug
608
+ # Human-readable ruleset name. Omitted unless given, so the request is
609
+ # unchanged for callers that do not set it.
610
+ if name is not None:
611
+ body["name"] = name
557
612
  if force_unsafe:
558
613
  # Tell the server-side TDD gate (aethis-core 0.11+) to refuse a
559
614
  # publish when stored test cases fail; force_unsafe=True records
@@ -16,9 +16,11 @@ import httpx
16
16
  import rfc8785
17
17
  import typer
18
18
  import yaml
19
+ from rich.markup import escape
19
20
  from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn
20
21
 
21
- from aethis_cli.client import AethisClient, GenerationModel
22
+ from aethis_cli._terminal_safe import safe_text
23
+ from aethis_cli.client import AethisClient, GenerationModel, normalize_thinking
22
24
  from aethis_cli.config import (
23
25
  load_project_config,
24
26
  make_authed_client,
@@ -1284,6 +1286,9 @@ def _upload_rulebook_guidance(client: AethisClient, pid: str, project_dir: Path)
1284
1286
 
1285
1287
  def generate(
1286
1288
  model: Optional[GenerationModel] = typer.Option(None, "--model", help="Authoring model (default: claude-sonnet-5)"),
1289
+ thinking: Optional[str] = typer.Option(
1290
+ None, "--thinking", help="Per-generation thinking: disabled, adaptive, or enabled:N"
1291
+ ),
1287
1292
  project_id: Optional[str] = typer.Option(None, "--project-id", "-p"),
1288
1293
  poll: bool = typer.Option(True, "--poll/--no-poll", help="Poll until generation completes"),
1289
1294
  timeout: int = typer.Option(600, "--timeout", "-t", help="Polling timeout in seconds"),
@@ -1318,6 +1323,7 @@ def generate(
1318
1323
  no_publish=no_publish,
1319
1324
  model=model,
1320
1325
  acceptance_contract=acceptance_contract,
1326
+ thinking=thinking,
1321
1327
  )
1322
1328
 
1323
1329
 
@@ -1332,6 +1338,7 @@ def _run_generate(
1332
1338
  no_publish: bool = False,
1333
1339
  model: Optional[GenerationModel] = None,
1334
1340
  acceptance_contract: Optional[Path] = None,
1341
+ thinking: Optional[str] = None,
1335
1342
  ) -> None:
1336
1343
  """Shared machinery for ``aethis generate`` and ``aethis refine``.
1337
1344
 
@@ -1339,6 +1346,13 @@ def _run_generate(
1339
1346
  is the plumbing for one flag on one command, not a change of default for
1340
1347
  everything that shares the machinery.
1341
1348
  """
1349
+ # This must happen before config/auth/project work: malformed explicit
1350
+ # controls must not leave any local or remote authoring side effect.
1351
+ try:
1352
+ thinking = normalize_thinking(thinking)
1353
+ except ValueError as e:
1354
+ console.print(f"[red]{e}[/red]")
1355
+ raise typer.Exit(code=2) from None
1342
1356
  if model is not None:
1343
1357
  try:
1344
1358
  model = GenerationModel(model)
@@ -1357,6 +1371,15 @@ def _run_generate(
1357
1371
  client = make_authed_client(api_key, cfg.base_url, anthropic_key=anthropic_key)
1358
1372
  project_dir = cfg.config_path
1359
1373
 
1374
+ if thinking is not None:
1375
+ properties = client.generation_mode_request_properties()
1376
+ if properties is None or "thinking" not in properties:
1377
+ console.print(
1378
+ "[red]The target generation control schema is unavailable or does not advertise thinking. "
1379
+ "Stopping before any project, source, guidance, field, or test mutation.[/red]"
1380
+ )
1381
+ raise typer.Exit(code=1)
1382
+
1360
1383
  # Fail-fast on empty sources: generation without any source documents wastes
1361
1384
  # 60-120s on the server and produces a cryptic LLM failure.
1362
1385
  if not _collect_source_files(project_dir):
@@ -1437,9 +1460,16 @@ def _run_generate(
1437
1460
  generation_options["model"] = model
1438
1461
  if deepseek_key:
1439
1462
  generation_options["deepseek_key"] = deepseek_key
1440
- job = client.generate(pid, mode=mode, seed_ruleset_id=seed_ruleset_id, **generation_options)
1463
+ if thinking is not None:
1464
+ generation_options["thinking"] = thinking
1465
+ try:
1466
+ job = client.generate(pid, mode=mode, seed_ruleset_id=seed_ruleset_id, **generation_options)
1467
+ except ValueError as exc:
1468
+ console.print(f"[red]{escape(safe_text(str(exc)))}[/red]")
1469
+ raise typer.Exit(code=1) from None
1441
1470
  write_state(project_dir, {"project_id": pid, "job_id": job["job_id"]})
1442
1471
  info(f"Generation queued (job={job['job_id']})")
1472
+ shown_thinking_warnings = _render_thinking_warnings(job)
1443
1473
  # Surface the remaining generate budget from the POST's X-RateLimit-*
1444
1474
  # headers (epic #552) — captured now, before polling /status overwrites
1445
1475
  # it with the `read` class. `aethis usage` shows the full picture.
@@ -1455,7 +1485,9 @@ def _run_generate(
1455
1485
  return
1456
1486
 
1457
1487
  # Poll with progress spinner
1458
- outcome = _poll_until_done(client, pid, project_dir, timeout, no_publish=no_publish)
1488
+ outcome = _poll_until_done(
1489
+ client, pid, project_dir, timeout, no_publish=no_publish, shown_thinking_warnings=shown_thinking_warnings
1490
+ )
1459
1491
 
1460
1492
  # Surface how the produced field vocabulary compares to what was pinned,
1461
1493
  # rather than letting any drift pass silently. The comparison is always
@@ -1793,6 +1825,30 @@ class GenerationOutcome(NamedTuple):
1793
1825
  value_spaces_resolved: Optional[dict] = None
1794
1826
 
1795
1827
 
1828
+ def _render_thinking_warnings(payload: dict, seen: Optional[set[tuple[str, str]]] = None) -> set[tuple[str, str]]:
1829
+ """Render stable engine warnings without inventing local thinking semantics."""
1830
+ config = payload.get("authoring_config")
1831
+ if not isinstance(config, dict):
1832
+ config = (payload.get("job") or {}).get("authoring_config")
1833
+ if not isinstance(config, dict):
1834
+ return seen or set()
1835
+ seen = seen if seen is not None else set()
1836
+ warnings = config.get("warnings")
1837
+ if not isinstance(warnings, (list, tuple)):
1838
+ return seen
1839
+ for warning in warnings:
1840
+ if not isinstance(warning, dict):
1841
+ continue
1842
+ code = warning.get("code")
1843
+ message = warning.get("message")
1844
+ if isinstance(code, str) and isinstance(message, str):
1845
+ key = (code, message)
1846
+ if key not in seen:
1847
+ warn(escape(safe_text(f"{code}: {message}")))
1848
+ seen.add(key)
1849
+ return seen
1850
+
1851
+
1796
1852
  def _error_reason(e: Exception) -> str:
1797
1853
  """A readable reason for either error family this module now catches.
1798
1854
 
@@ -1906,6 +1962,7 @@ def _poll_until_done(
1906
1962
  timeout: int = 600,
1907
1963
  *,
1908
1964
  no_publish: bool = False,
1965
+ shown_thinking_warnings: Optional[set[tuple[str, str]]] = None,
1909
1966
  ) -> GenerationOutcome:
1910
1967
  """Poll a generation to completion and report how it ended.
1911
1968
 
@@ -1968,6 +2025,7 @@ def _poll_until_done(
1968
2025
  warn("Lost the connection to the API during the poll; recovered and carried on.")
1969
2026
  blips = 0
1970
2027
  job = result.get("job") or {}
2028
+ shown_thinking_warnings = _render_thinking_warnings(result, shown_thinking_warnings)
1971
2029
  pct = job.get("progress_percent", 0)
1972
2030
  if isinstance(pct, bool) or not isinstance(pct, (int, float)):
1973
2031
  pct = 0
@@ -125,6 +125,15 @@ def publish(
125
125
  "namespace is reserved for official rulesets."
126
126
  ),
127
127
  ),
128
+ name: Optional[str] = typer.Option(
129
+ None,
130
+ "--name",
131
+ help=(
132
+ "Human-readable name for this ruleset, shown to end users in "
133
+ "rulebook responses. Overrides an optional 'display_name:' key in "
134
+ "aethis.yaml. When neither is set the engine keeps its default name."
135
+ ),
136
+ ),
128
137
  rulebook: Optional[str] = typer.Option(
129
138
  None,
130
139
  "--rulebook",
@@ -259,6 +268,7 @@ def publish(
259
268
  rulebook_id=rulebook,
260
269
  ruleset_name=ruleset_name,
261
270
  source_targets=wire_targets or None,
271
+ name=name if name is not None else cfg.display_name,
262
272
  )
263
273
  except AethisAPIError as e:
264
274
  error_panel(e)
@@ -14,6 +14,9 @@ from aethis_cli.commands.generate_cmd import _run_generate
14
14
 
15
15
  def refine(
16
16
  model: Optional[GenerationModel] = typer.Option(None, "--model", help="Authoring model (default: claude-sonnet-5)"),
17
+ thinking: Optional[str] = typer.Option(
18
+ None, "--thinking", help="Per-generation thinking: disabled, adaptive, or enabled:N"
19
+ ),
17
20
  hint: Optional[str] = typer.Option(None, "--hint", help="Guidance hint to add before refining"),
18
21
  project_id: Optional[str] = typer.Option(None, "--project-id", "-p"),
19
22
  seed_ruleset_id: Optional[str] = typer.Option(
@@ -43,4 +46,5 @@ def refine(
43
46
  extra_hint=hint,
44
47
  model=model,
45
48
  acceptance_contract=acceptance_contract,
49
+ thinking=thinking,
46
50
  )
@@ -64,6 +64,7 @@ class ProjectConfig:
64
64
  config_path: Path = field(default_factory=lambda: Path.cwd())
65
65
  deepseek_key_env: str = "DEEPSEEK_API_KEY"
66
66
  project_base_url: Optional[str] = None # the project file's own value, exactly as written
67
+ display_name: Optional[str] = None # optional human-readable ruleset name, sent on publish
67
68
 
68
69
 
69
70
  def resolve_base_url_with_source() -> tuple[str, str]:
@@ -510,9 +511,20 @@ def load_project_config(path: Optional[Path] = None) -> ProjectConfig:
510
511
  project_id=project_id,
511
512
  config_path=project_dir,
512
513
  project_base_url=project_url,
514
+ display_name=_display_name_value(raw, yaml_path),
513
515
  )
514
516
 
515
517
 
518
+ def _display_name_value(raw: dict, yaml_path: Path) -> Optional[str]:
519
+ """The optional ``display_name`` key: a non-empty string, or absent."""
520
+ value = raw.get("display_name")
521
+ if value is None:
522
+ return None
523
+ if not isinstance(value, str) or not value.strip():
524
+ raise ConfigError(f"'display_name' in {yaml_path} must be a non-empty string.")
525
+ return value.strip()
526
+
527
+
516
528
  _ENV_REFUSED = (
517
529
  "{where} names a non-default key variable that you have not designated, so it was not read. Environment "
518
530
  "variables are read as keys only if you name them yourself: set {setting} to the variable name in your own "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aethis-cli
3
- Version: 0.45.0
3
+ Version: 0.47.0
4
4
  Summary: CLI for the Aethis developer API — author, test, and publish rulesets
5
5
  Author-email: Aethis <eng@aethis.ai>
6
6
  License-Expression: MIT
@@ -93,6 +93,7 @@ tests/test_output.py
93
93
  tests/test_profiles.py
94
94
  tests/test_project_file_trust.py
95
95
  tests/test_prompts.py
96
+ tests/test_publish_display_name.py
96
97
  tests/test_publish_force.py
97
98
  tests/test_publish_rulebook_flags.py
98
99
  tests/test_publish_source_targets.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aethis-cli"
3
- version = "0.45.0"
3
+ version = "0.47.0"
4
4
  description = "CLI for the Aethis developer API — author, test, and publish rulesets"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -0,0 +1,268 @@
1
+ """Per-generation model and credential boundaries."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from unittest.mock import MagicMock
7
+
8
+ import httpx
9
+ import pytest
10
+ import respx
11
+ from typer.testing import CliRunner
12
+
13
+ from aethis_cli.client import AethisClient, GenerationModel, normalize_thinking
14
+ from aethis_cli.commands import generate_cmd, refine_cmd
15
+ from aethis_cli.config import load_project_config, resolve_deepseek_key
16
+ from aethis_cli.main import app
17
+
18
+ BASE = "https://test.local"
19
+
20
+
21
+ @pytest.mark.parametrize("mode", ["fresh", "refine"])
22
+ @respx.mock
23
+ def test_deepseek_generation_header_is_request_scoped(mode: str) -> None:
24
+ generate = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={"job_id": "j"})
25
+ discover = respx.post(f"{BASE}/api/v1/public/projects/p/fields/discover").respond(200, json={})
26
+ review = respx.post(f"{BASE}/api/v1/public/projects/p/review").respond(200, json={})
27
+ with AethisClient("ak", BASE) as client:
28
+ client.generate("p", mode=mode, model=GenerationModel.deepseek, deepseek_key="secret")
29
+ client.discover_fields("p")
30
+ client.review("p", coach=True)
31
+ request = generate.calls.last.request
32
+ assert json.loads(request.content) == {"mode": mode, "model": "deepseek-flash"}
33
+ assert request.headers["X-DeepSeek-Key"] == "secret"
34
+ assert "X-Anthropic-Key" not in request.headers
35
+ for route in (discover, review):
36
+ assert "X-DeepSeek-Key" not in route.calls.last.request.headers
37
+
38
+
39
+ @respx.mock
40
+ def test_explicit_sonnet_keeps_anthropic_transport() -> None:
41
+ route = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={})
42
+ with AethisClient("ak", BASE, anthropic_key="anthropic") as client:
43
+ client.generate("p", model=GenerationModel.sonnet)
44
+ assert json.loads(route.calls.last.request.content) == {"model": "claude-sonnet-5"}
45
+ assert route.calls.last.request.headers["X-Anthropic-Key"] == "anthropic"
46
+ assert "X-DeepSeek-Key" not in route.calls.last.request.headers
47
+
48
+
49
+ def test_client_rejects_provider_key_mix() -> None:
50
+ with AethisClient("ak", BASE, anthropic_key="anthropic") as client:
51
+ with pytest.raises(ValueError, match="without an Anthropic"):
52
+ client.generate("p", model=GenerationModel.deepseek, deepseek_key="secret")
53
+ with AethisClient("ak", BASE) as client:
54
+ with pytest.raises(ValueError, match="requires model"):
55
+ client.generate("p", deepseek_key="secret")
56
+
57
+
58
+ @respx.mock
59
+ def test_thinking_serialization_preserves_omission_and_explicit_null() -> None:
60
+ respx.get(f"{BASE}/openapi.json").respond(
61
+ 200, json={"components": {"schemas": {"GenerationModeRequest": {"properties": {"thinking": {}}}}}}
62
+ )
63
+ route = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={})
64
+ with AethisClient("ak", BASE) as client:
65
+ client.generate("p")
66
+ assert route.calls.last.request.content == b""
67
+ client.generate("p", thinking=None)
68
+ assert json.loads(route.calls.last.request.content) == {"thinking": None}
69
+ client.generate("p", thinking="enabled:48000")
70
+ assert json.loads(route.calls.last.request.content) == {"thinking": "enabled:48000"}
71
+
72
+
73
+ def test_thinking_normalization_bounds_significant_digits() -> None:
74
+ assert normalize_thinking(" enabled:00001024 ") == "enabled:1024"
75
+ assert normalize_thinking("enabled:000000000009999999999") == "enabled:9999999999"
76
+ with pytest.raises(ValueError, match="invalid_thinking"):
77
+ normalize_thinking("enabled:10000000000")
78
+ with pytest.raises(ValueError, match="invalid_thinking"):
79
+ normalize_thinking("enabled:10_24")
80
+
81
+
82
+ @pytest.mark.parametrize("command", ["generate", "refine"])
83
+ def test_flags_forward_model(command: str, monkeypatch: pytest.MonkeyPatch) -> None:
84
+ run = MagicMock()
85
+ module = generate_cmd if command == "generate" else refine_cmd
86
+ monkeypatch.setattr(module, "_run_generate", run)
87
+ result = CliRunner().invoke(app, [command, "--model", "deepseek-flash", "--no-poll"])
88
+ assert result.exit_code == 0, result.output
89
+ assert run.call_args.kwargs["model"] == GenerationModel.deepseek
90
+ invalid = CliRunner().invoke(app, [command, "--model", "unknown"])
91
+ assert invalid.exit_code == 2
92
+ assert run.call_count == 1
93
+
94
+
95
+ @pytest.mark.parametrize("command", ["generate", "refine"])
96
+ def test_flags_forward_thinking(command: str, monkeypatch: pytest.MonkeyPatch) -> None:
97
+ run = MagicMock()
98
+ module = generate_cmd if command == "generate" else refine_cmd
99
+ monkeypatch.setattr(module, "_run_generate", run)
100
+ result = CliRunner().invoke(app, [command, "--thinking", "enabled:48000", "--no-poll"])
101
+ assert result.exit_code == 0, result.output
102
+ assert run.call_args.kwargs["thinking"] == "enabled:48000"
103
+
104
+
105
+ def test_thinking_warning_is_rendered(capsys: pytest.CaptureFixture[str]) -> None:
106
+ generate_cmd._render_thinking_warnings(
107
+ {
108
+ "authoring_config": {
109
+ "warnings": [{"code": "thinking_budget_ignored", "message": "budget does not bound reasoning"}]
110
+ }
111
+ }
112
+ )
113
+ assert "thinking_budget_ignored" in capsys.readouterr().out
114
+
115
+
116
+ def test_thinking_capability_rejection_precedes_project_mutation(tmp_path, monkeypatch: pytest.MonkeyPatch) -> None:
117
+ from tests.test_generate_no_publish import _engine, _project, _wire
118
+
119
+ _project(tmp_path)
120
+ client = _engine({})
121
+ client.generation_mode_request_properties.return_value = set()
122
+ _wire(monkeypatch, tmp_path, client)
123
+ with pytest.raises(__import__("typer").Exit) as rejected:
124
+ generate_cmd._run_generate(project_id="p", poll=False, timeout=30, thinking="disabled")
125
+ assert rejected.value.exit_code == 1
126
+ client.get_project.assert_not_called()
127
+ client.create_project.assert_not_called()
128
+
129
+
130
+ def test_configurable_deepseek_env(tmp_path, monkeypatch: pytest.MonkeyPatch) -> None:
131
+ config = tmp_path / "aethis.yaml"
132
+ config.write_text("project: example\ndeepseek_key_env: CUSTOM_DEEPSEEK\n")
133
+ monkeypatch.setenv("AETHIS_DEEPSEEK_KEY_ENV", "CUSTOM_DEEPSEEK") # the user designates it
134
+ monkeypatch.setenv("CUSTOM_DEEPSEEK", "secret")
135
+ assert resolve_deepseek_key(load_project_config(config)) == "secret"
136
+ config.write_text("project: example\n")
137
+ monkeypatch.delenv("AETHIS_DEEPSEEK_KEY_ENV")
138
+ monkeypatch.setenv("DEEPSEEK_API_KEY", "default-secret")
139
+ assert resolve_deepseek_key(load_project_config(config)) == "default-secret"
140
+
141
+
142
+ @pytest.mark.parametrize("model", [None, GenerationModel.sonnet, GenerationModel.deepseek])
143
+ def test_generation_resolves_only_selected_provider(model, tmp_path, monkeypatch) -> None:
144
+ from tests.test_generate_no_publish import SUCCESS, _engine, _project, _wire
145
+
146
+ _project(tmp_path)
147
+ client = _engine(SUCCESS)
148
+ _wire(monkeypatch, tmp_path, client)
149
+ anthropic = MagicMock(return_value="anthropic-secret")
150
+ deepseek = MagicMock(return_value="deepseek-secret")
151
+ factory = MagicMock(return_value=client)
152
+ monkeypatch.setattr(generate_cmd, "resolve_anthropic_key", anthropic)
153
+ monkeypatch.setattr(generate_cmd, "resolve_deepseek_key", deepseek)
154
+ monkeypatch.setattr(generate_cmd, "make_authed_client", factory)
155
+ generate_cmd._run_generate(project_id="p", poll=False, timeout=30, model=model)
156
+ if model == GenerationModel.deepseek:
157
+ anthropic.assert_not_called()
158
+ deepseek.assert_called_once()
159
+ assert factory.call_args.kwargs["anthropic_key"] is None
160
+ assert client.generate.call_args.kwargs["deepseek_key"] == "deepseek-secret"
161
+ else:
162
+ deepseek.assert_not_called()
163
+ anthropic.assert_called_once()
164
+ assert factory.call_args.kwargs["anthropic_key"] == "anthropic-secret"
165
+ assert "deepseek_key" not in client.generate.call_args.kwargs
166
+ if model is None:
167
+ assert "model" not in client.generate.call_args.kwargs
168
+ else:
169
+ assert client.generate.call_args.kwargs["model"] == model
170
+
171
+
172
+ def test_invalid_model_stops_before_project_loading(monkeypatch: pytest.MonkeyPatch) -> None:
173
+ import typer
174
+
175
+ load = MagicMock()
176
+ monkeypatch.setattr(generate_cmd, "load_project_config", load)
177
+ with pytest.raises(typer.Exit):
178
+ generate_cmd._run_generate(project_id="p", poll=False, timeout=30, model="typo")
179
+ load.assert_not_called()
180
+
181
+
182
+ def test_project_config_preserves_positional_arguments(tmp_path) -> None:
183
+ from aethis_cli.config import ProjectConfig
184
+
185
+ config = ProjectConfig("example", "API_KEY", "ANTHROPIC_KEY", BASE, "project-id", tmp_path)
186
+ assert config.base_url == BASE
187
+ assert config.project_id == "project-id"
188
+ assert config.config_path == tmp_path
189
+ assert config.deepseek_key_env == "DEEPSEEK_API_KEY"
190
+
191
+
192
+ @respx.mock
193
+ @pytest.mark.parametrize("thinking", [None, "disabled"])
194
+ def test_direct_client_refuses_explicit_thinking_on_old_engine(thinking):
195
+ respx.get(f"{BASE}/openapi.json").respond(
196
+ 200, json={"components": {"schemas": {"GenerationModeRequest": {"properties": {"mode": {}}}}}}
197
+ )
198
+ post = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={})
199
+ with AethisClient("ak", BASE) as client:
200
+ with pytest.raises(ValueError, match="no generation was started"):
201
+ client.generate("p", thinking=thinking)
202
+ assert not post.called
203
+
204
+
205
+ def test_warning_text_cannot_break_rich_markup_and_is_shown_once(capsys):
206
+ payload = {"authoring_config": {"warnings": [{"code": "future", "message": "x [/y]"}]}}
207
+ seen = generate_cmd._render_thinking_warnings(payload)
208
+ generate_cmd._render_thinking_warnings(payload, seen)
209
+ assert capsys.readouterr().out.count("x [/y]") == 1
210
+
211
+
212
+ @pytest.mark.parametrize("message", ["escape\x1b[2J", "surrogate\ud800", "bidi\u202e", "newline\nspoof"])
213
+ def test_warning_uses_terminal_sanitizer(message, capsys):
214
+ from aethis_cli._terminal_safe import safe_text
215
+
216
+ generate_cmd._render_thinking_warnings(
217
+ {"authoring_config": {"warnings": [{"code": "warning", "message": message}]}}
218
+ )
219
+ output = capsys.readouterr().out
220
+ assert safe_text(message) in output
221
+ assert message not in output
222
+
223
+
224
+ @respx.mock
225
+ def test_direct_generation_refreshes_cached_control_schema_before_post():
226
+ schema = respx.get(f"{BASE}/openapi.json").mock(
227
+ side_effect=[
228
+ httpx.Response(
229
+ 200, json={"components": {"schemas": {"GenerationModeRequest": {"properties": {"thinking": {}}}}}}
230
+ ),
231
+ httpx.Response(
232
+ 200, json={"components": {"schemas": {"GenerationModeRequest": {"properties": {"mode": {}}}}}}
233
+ ),
234
+ ]
235
+ )
236
+ post = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={})
237
+ with AethisClient("ak", BASE) as client:
238
+ assert "thinking" in client.generation_mode_request_properties()
239
+ with pytest.raises(ValueError, match="no generation was started"):
240
+ client.generate("p", thinking="disabled")
241
+ assert schema.call_count == 2
242
+ assert not post.called
243
+
244
+
245
+ def test_late_control_rejection_is_rendered_without_traceback(tmp_path, monkeypatch, capsys):
246
+ from tests.test_generate_no_publish import _engine, _project, _wire
247
+
248
+ _project(tmp_path)
249
+ client = _engine({})
250
+ client.generation_mode_request_properties.return_value = {"thinking"}
251
+ client.generate.side_effect = ValueError("Control schema could not be read; no generation was started")
252
+ _wire(monkeypatch, tmp_path, client)
253
+ with pytest.raises(__import__("typer").Exit) as rejected:
254
+ generate_cmd._run_generate(project_id="p", poll=False, timeout=30, thinking="disabled")
255
+ assert rejected.value.exit_code == 1
256
+ output = capsys.readouterr().out
257
+ assert "no generation was started" in output
258
+ assert "Traceback" not in output
259
+
260
+
261
+ @respx.mock
262
+ def test_unreadable_generation_control_schema_refuses_without_post():
263
+ respx.get(f"{BASE}/openapi.json").respond(500, json={})
264
+ post = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={})
265
+ with AethisClient("ak", BASE) as client:
266
+ with pytest.raises(ValueError, match="schema could not be read"):
267
+ client.generate("p", thinking="disabled")
268
+ assert not post.called
@@ -0,0 +1,77 @@
1
+ """`aethis publish --name` and the optional `display_name:` key in aethis.yaml.
2
+
3
+ Both set the human-readable ruleset name sent on publish. Absent => the
4
+ request is byte-identical to before.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from unittest.mock import MagicMock, patch
10
+
11
+ from typer.testing import CliRunner
12
+
13
+
14
+ def _invoke(args):
15
+ from aethis_cli.main import app
16
+
17
+ return CliRunner().invoke(app, args, catch_exceptions=False, env={})
18
+
19
+
20
+ def _project(tmp_path, extra=""):
21
+ (tmp_path / "aethis.yaml").write_text("project: test-project\napi_key_env: AETHIS_API_KEY\n" + extra)
22
+ (tmp_path / ".aethis").mkdir()
23
+ (tmp_path / ".aethis" / "state.json").write_text('{"project_id": "proj_test"}')
24
+
25
+
26
+ def _run(tmp_path, monkeypatch, args, extra=""):
27
+ monkeypatch.chdir(tmp_path)
28
+ monkeypatch.setenv("AETHIS_API_KEY", "ak_test")
29
+ _project(tmp_path, extra)
30
+ client = MagicMock()
31
+ client.run_tests.return_value = {"passed": 1, "failed": 0, "errors": 0, "total": 1}
32
+ client.publish.return_value = {"ruleset_id": "rs_x"}
33
+ with patch("aethis_cli.client.AethisClient", return_value=client):
34
+ result = _invoke(["publish", *args])
35
+ assert result.exit_code == 0, result.output
36
+ return client.publish.call_args.kwargs
37
+
38
+
39
+ def test_name_flag_is_sent(tmp_path, monkeypatch):
40
+ assert _run(tmp_path, monkeypatch, ["--name", "Life in the UK"])["name"] == "Life in the UK"
41
+
42
+
43
+ def test_display_name_key_is_sent(tmp_path, monkeypatch):
44
+ kw = _run(tmp_path, monkeypatch, [], extra="display_name: English language\n")
45
+ assert kw["name"] == "English language"
46
+
47
+
48
+ def test_flag_overrides_yaml(tmp_path, monkeypatch):
49
+ kw = _run(tmp_path, monkeypatch, ["--name", "Flag"], extra="display_name: Yaml\n")
50
+ assert kw["name"] == "Flag"
51
+
52
+
53
+ def test_absent_means_no_name(tmp_path, monkeypatch):
54
+ assert _run(tmp_path, monkeypatch, [])["name"] is None
55
+
56
+
57
+ def _body(**kw):
58
+ from aethis_cli.client import AethisClient
59
+
60
+ captured: dict = {}
61
+
62
+ class _Stub(AethisClient):
63
+ def _request(self, method, path, **k):
64
+ captured["kwargs"] = k
65
+ return {}
66
+
67
+ _Stub(base_url="http://test.invalid", api_key="ak_test").publish("proj_x", **kw)
68
+ return captured["kwargs"]
69
+
70
+
71
+ def test_client_sends_name_in_body():
72
+ assert _body(name="Personal information")["json"] == {"name": "Personal information"}
73
+
74
+
75
+ def test_client_body_unchanged_without_name():
76
+ assert "json" not in _body()
77
+ assert _body(slug="a/b")["json"] == {"slug": "a/b"}
@@ -178,7 +178,9 @@ def test_warning_text_is_never_parsed_as_markup(capsys):
178
178
 
179
179
 
180
180
  def _publish(publish_response: dict) -> str:
181
- cfg = SimpleNamespace(base_url="http://engine.test", project_id="proj_test", config_path="/tmp/.aethis")
181
+ cfg = SimpleNamespace(
182
+ base_url="http://engine.test", project_id="proj_test", config_path="/tmp/.aethis", display_name=None
183
+ )
182
184
  client = MagicMock()
183
185
  client.run_tests.return_value = {"passed": 1, "total": 1, "failed": 0, "errors": 0, "results": []}
184
186
  client.publish.return_value = publish_response
@@ -1,129 +0,0 @@
1
- """Per-generation model and credential boundaries."""
2
-
3
- from __future__ import annotations
4
-
5
- import json
6
- from unittest.mock import MagicMock
7
-
8
- import pytest
9
- import respx
10
- from typer.testing import CliRunner
11
-
12
- from aethis_cli.client import AethisClient, GenerationModel
13
- from aethis_cli.commands import generate_cmd, refine_cmd
14
- from aethis_cli.config import load_project_config, resolve_deepseek_key
15
- from aethis_cli.main import app
16
-
17
- BASE = "https://test.local"
18
-
19
-
20
- @pytest.mark.parametrize("mode", ["fresh", "refine"])
21
- @respx.mock
22
- def test_deepseek_generation_header_is_request_scoped(mode: str) -> None:
23
- generate = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={"job_id": "j"})
24
- discover = respx.post(f"{BASE}/api/v1/public/projects/p/fields/discover").respond(200, json={})
25
- review = respx.post(f"{BASE}/api/v1/public/projects/p/review").respond(200, json={})
26
- with AethisClient("ak", BASE) as client:
27
- client.generate("p", mode=mode, model=GenerationModel.deepseek, deepseek_key="secret")
28
- client.discover_fields("p")
29
- client.review("p", coach=True)
30
- request = generate.calls.last.request
31
- assert json.loads(request.content) == {"mode": mode, "model": "deepseek-flash"}
32
- assert request.headers["X-DeepSeek-Key"] == "secret"
33
- assert "X-Anthropic-Key" not in request.headers
34
- for route in (discover, review):
35
- assert "X-DeepSeek-Key" not in route.calls.last.request.headers
36
-
37
-
38
- @respx.mock
39
- def test_explicit_sonnet_keeps_anthropic_transport() -> None:
40
- route = respx.post(f"{BASE}/api/v1/public/projects/p/generate").respond(202, json={})
41
- with AethisClient("ak", BASE, anthropic_key="anthropic") as client:
42
- client.generate("p", model=GenerationModel.sonnet)
43
- assert json.loads(route.calls.last.request.content) == {"model": "claude-sonnet-5"}
44
- assert route.calls.last.request.headers["X-Anthropic-Key"] == "anthropic"
45
- assert "X-DeepSeek-Key" not in route.calls.last.request.headers
46
-
47
-
48
- def test_client_rejects_provider_key_mix() -> None:
49
- with AethisClient("ak", BASE, anthropic_key="anthropic") as client:
50
- with pytest.raises(ValueError, match="without an Anthropic"):
51
- client.generate("p", model=GenerationModel.deepseek, deepseek_key="secret")
52
- with AethisClient("ak", BASE) as client:
53
- with pytest.raises(ValueError, match="requires model"):
54
- client.generate("p", deepseek_key="secret")
55
-
56
-
57
- @pytest.mark.parametrize("command", ["generate", "refine"])
58
- def test_flags_forward_model(command: str, monkeypatch: pytest.MonkeyPatch) -> None:
59
- run = MagicMock()
60
- module = generate_cmd if command == "generate" else refine_cmd
61
- monkeypatch.setattr(module, "_run_generate", run)
62
- result = CliRunner().invoke(app, [command, "--model", "deepseek-flash", "--no-poll"])
63
- assert result.exit_code == 0, result.output
64
- assert run.call_args.kwargs["model"] == GenerationModel.deepseek
65
- invalid = CliRunner().invoke(app, [command, "--model", "unknown"])
66
- assert invalid.exit_code == 2
67
- assert run.call_count == 1
68
-
69
-
70
- def test_configurable_deepseek_env(tmp_path, monkeypatch: pytest.MonkeyPatch) -> None:
71
- config = tmp_path / "aethis.yaml"
72
- config.write_text("project: example\ndeepseek_key_env: CUSTOM_DEEPSEEK\n")
73
- monkeypatch.setenv("AETHIS_DEEPSEEK_KEY_ENV", "CUSTOM_DEEPSEEK") # the user designates it
74
- monkeypatch.setenv("CUSTOM_DEEPSEEK", "secret")
75
- assert resolve_deepseek_key(load_project_config(config)) == "secret"
76
- config.write_text("project: example\n")
77
- monkeypatch.delenv("AETHIS_DEEPSEEK_KEY_ENV")
78
- monkeypatch.setenv("DEEPSEEK_API_KEY", "default-secret")
79
- assert resolve_deepseek_key(load_project_config(config)) == "default-secret"
80
-
81
-
82
- @pytest.mark.parametrize("model", [None, GenerationModel.sonnet, GenerationModel.deepseek])
83
- def test_generation_resolves_only_selected_provider(model, tmp_path, monkeypatch) -> None:
84
- from tests.test_generate_no_publish import SUCCESS, _engine, _project, _wire
85
-
86
- _project(tmp_path)
87
- client = _engine(SUCCESS)
88
- _wire(monkeypatch, tmp_path, client)
89
- anthropic = MagicMock(return_value="anthropic-secret")
90
- deepseek = MagicMock(return_value="deepseek-secret")
91
- factory = MagicMock(return_value=client)
92
- monkeypatch.setattr(generate_cmd, "resolve_anthropic_key", anthropic)
93
- monkeypatch.setattr(generate_cmd, "resolve_deepseek_key", deepseek)
94
- monkeypatch.setattr(generate_cmd, "make_authed_client", factory)
95
- generate_cmd._run_generate(project_id="p", poll=False, timeout=30, model=model)
96
- if model == GenerationModel.deepseek:
97
- anthropic.assert_not_called()
98
- deepseek.assert_called_once()
99
- assert factory.call_args.kwargs["anthropic_key"] is None
100
- assert client.generate.call_args.kwargs["deepseek_key"] == "deepseek-secret"
101
- else:
102
- deepseek.assert_not_called()
103
- anthropic.assert_called_once()
104
- assert factory.call_args.kwargs["anthropic_key"] == "anthropic-secret"
105
- assert "deepseek_key" not in client.generate.call_args.kwargs
106
- if model is None:
107
- assert "model" not in client.generate.call_args.kwargs
108
- else:
109
- assert client.generate.call_args.kwargs["model"] == model
110
-
111
-
112
- def test_invalid_model_stops_before_project_loading(monkeypatch: pytest.MonkeyPatch) -> None:
113
- import typer
114
-
115
- load = MagicMock()
116
- monkeypatch.setattr(generate_cmd, "load_project_config", load)
117
- with pytest.raises(typer.Exit):
118
- generate_cmd._run_generate(project_id="p", poll=False, timeout=30, model="typo")
119
- load.assert_not_called()
120
-
121
-
122
- def test_project_config_preserves_positional_arguments(tmp_path) -> None:
123
- from aethis_cli.config import ProjectConfig
124
-
125
- config = ProjectConfig("example", "API_KEY", "ANTHROPIC_KEY", BASE, "project-id", tmp_path)
126
- assert config.base_url == BASE
127
- assert config.project_id == "project-id"
128
- assert config.config_path == tmp_path
129
- assert config.deepseek_key_env == "DEEPSEEK_API_KEY"
File without changes
File without changes
File without changes