refactorai-cli 0.7.7__tar.gz → 0.7.9__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 (53) hide show
  1. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/PKG-INFO +2 -2
  2. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/pyproject.toml +2 -2
  3. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/__init__.py +1 -1
  4. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/cloud_rr.py +74 -15
  5. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/watch_cmds.py +64 -1
  6. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli.egg-info/PKG-INFO +2 -2
  7. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli.egg-info/requires.txt +1 -1
  8. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/README.md +0 -0
  9. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/auth.py +0 -0
  10. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/client.py +0 -0
  11. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/__init__.py +0 -0
  12. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/account_cmds.py +0 -0
  13. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/auth_cmds.py +0 -0
  14. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/branch_cmds.py +0 -0
  15. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/cloud_cmds.py +0 -0
  16. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/engine_cmds.py +0 -0
  17. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/hook_cmds.py +0 -0
  18. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/model_cmds.py +0 -0
  19. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/policy_cmds.py +0 -0
  20. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/pre_push_cmds.py +0 -0
  21. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/request_cmds.py +0 -0
  22. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/rules_cmds.py +0 -0
  23. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/run_cmds.py +0 -0
  24. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/runtime_cmds.py +0 -0
  25. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/runtime_proxy_cmds.py +0 -0
  26. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/setup_cmds.py +0 -0
  27. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/toolchains_cmds.py +0 -0
  28. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commands/workspace_cmds.py +0 -0
  29. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commit_queue.py +0 -0
  30. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/commit_telemetry.py +0 -0
  31. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/control_plane.py +0 -0
  32. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/credentials.py +0 -0
  33. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/dotenv_loader.py +0 -0
  34. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/git_scope.py +0 -0
  35. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/local_constitution.py +0 -0
  36. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/local_engine_runtime.py +0 -0
  37. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/local_paths.py +0 -0
  38. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/main.py +0 -0
  39. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/model_policy.py +0 -0
  40. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/pre_push_gate.py +0 -0
  41. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/refactor_branch_store.py +0 -0
  42. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/review_runner.py +0 -0
  43. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/runtime_manager.py +0 -0
  44. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/settings.py +0 -0
  45. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/setup_flow.py +0 -0
  46. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/watch_ledger.py +0 -0
  47. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/watch_state.py +0 -0
  48. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli/watch_supervisor.py +0 -0
  49. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli.egg-info/SOURCES.txt +0 -0
  50. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli.egg-info/dependency_links.txt +0 -0
  51. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli.egg-info/entry_points.txt +0 -0
  52. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/refactorai_cli.egg-info/top_level.txt +0 -0
  53. {refactorai_cli-0.7.7 → refactorai_cli-0.7.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: refactorai-cli
3
- Version: 0.7.7
3
+ Version: 0.7.9
4
4
  Summary: Local-first CLI for the refactor platform
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -8,7 +8,7 @@ Requires-Dist: typer>=0.12.0
8
8
  Requires-Dist: httpx>=0.27.0
9
9
  Requires-Dist: rich>=13.7.0
10
10
  Requires-Dist: PyYAML>=6.0.1
11
- Requires-Dist: refactorai-core>=3.2.19
11
+ Requires-Dist: refactorai-core>=3.2.20
12
12
 
13
13
  # refactorai-cli
14
14
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "refactorai-cli"
3
- version = "0.7.7"
3
+ version = "0.7.9"
4
4
  description = "Local-first CLI for the refactor platform"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -12,7 +12,7 @@ dependencies = [
12
12
  "httpx>=0.27.0",
13
13
  "rich>=13.7.0",
14
14
  "PyYAML>=6.0.1",
15
- "refactorai-core>=3.2.19",
15
+ "refactorai-core>=3.2.20",
16
16
  ]
17
17
 
18
18
  [project.scripts]
@@ -5,4 +5,4 @@ the shared `refactor_core` pipeline from a project folder while staying
5
5
  authenticated to the hosted platform via a developer key.
6
6
  """
7
7
 
8
- __version__ = "0.7.7"
8
+ __version__ = "0.7.9"
@@ -328,6 +328,20 @@ def _missing_binaries(command: str | None, *, env: dict | None = None) -> list[s
328
328
  return [b for b in _required_binaries(command) if not _binary_on_path(b, env=env)]
329
329
 
330
330
 
331
+ def _command_runtimes(command: str | None) -> list[str]:
332
+ """Managed runtime ids implied by the command's required binaries."""
333
+ if not command:
334
+ return []
335
+ from refactor_core.host_toolchain import binary_to_runtime
336
+
337
+ out: list[str] = []
338
+ for binary in _required_binaries(command):
339
+ runtime = binary_to_runtime(binary)
340
+ if runtime and runtime not in out:
341
+ out.append(runtime)
342
+ return out
343
+
344
+
331
345
  def _normalize_command_interpreters(command: str | None, *, env: dict | None = None) -> str | None:
332
346
  """Rewrite a bare ``python`` command token to ``python3`` when needed.
333
347
 
@@ -521,12 +535,12 @@ def _provision_toolchain(
521
535
  ) -> tuple[dict | None, str]:
522
536
  """Provision managed runtimes for every missing binary in ``test_command``.
523
537
 
524
- Returns ``(env, note)``. ``env`` (with the toolchain(s) on ``PATH``) is
525
- returned only when at least one runtime was actually provisioned; otherwise
526
- ``None`` (the caller runs with the inherited environment). Composite commands
527
- are handled per segment so a monorepo runner like ``cd client && npm test &&
528
- cd server && pytest`` provisions BOTH node and python. No-ops when the command
529
- is already runnable, has no managed runtime, or provisioning is disabled.
538
+ Returns ``(env, note)``. ``env`` (with provisioned toolchain(s) on ``PATH``)
539
+ is returned only when at least one runtime was provisioned; otherwise
540
+ ``None`` (caller uses inherited env). Composite commands are handled per
541
+ segment so e.g. ``cd client && npm test && cd server && pytest`` can
542
+ provision BOTH node and python. Dependency restore is run-level and handled
543
+ by the caller after provisioning.
530
544
  """
531
545
  if not test_command or not _managed_toolchain_enabled(config):
532
546
  return None, ""
@@ -570,10 +584,6 @@ def _provision_toolchain(
570
584
  continue
571
585
  _emit(progress_cb, phase="rr", event="toolchain_ready", runtime=runtime)
572
586
  merged_env = _merge_toolchain_env(merged_env, env)
573
- _restore_dependencies(
574
- execution_root, runtime, merged_env, progress_cb,
575
- config=config, dep_locator_cb=dep_locator_cb,
576
- )
577
587
 
578
588
  return merged_env, " ".join(n for n in notes if n).strip()
579
589
 
@@ -1607,10 +1617,18 @@ def run_cloud_refactor_requests(
1607
1617
  if toolchain_note:
1608
1618
  notes.append(toolchain_note)
1609
1619
 
1610
- if not requests:
1611
- return _build_artifact(
1612
- run_store, run_id, constitution, model_id, outcomes, counts,
1613
- notes, stopped=False, stop_reason="", test_command=test_command,
1620
+ # Run-level dependency preflight: always attempt dependency restoration for
1621
+ # runtimes implied by the configured test command, even when binaries are
1622
+ # already present on PATH. This prevents import-time baseline failures from
1623
+ # deferring requests one-by-one later in the loop.
1624
+ for runtime in _command_runtimes(test_command):
1625
+ _restore_dependencies(
1626
+ execution_root,
1627
+ runtime,
1628
+ toolchain_env,
1629
+ progress_cb,
1630
+ config=config,
1631
+ dep_locator_cb=_dep_locator,
1614
1632
  )
1615
1633
 
1616
1634
  # Fail-fast: if a test command is configured but STILL not runnable after
@@ -1642,6 +1660,43 @@ def run_cloud_refactor_requests(
1642
1660
  notes, stopped=True, stop_reason=reason, test_command=test_command,
1643
1661
  )
1644
1662
 
1663
+ # Run-level baseline characterization: execute ONCE and reuse for all RR
1664
+ # steps. If baseline is red, stop the run before opening the RR session so
1665
+ # requests are not deferred one-by-one for dependency/env failures.
1666
+ baseline_ok, baseline_detail = _run_test(execution_root, test_command, env=toolchain_env)
1667
+ _emit(
1668
+ progress_cb,
1669
+ phase="rr",
1670
+ event="baseline_test",
1671
+ rr_id="",
1672
+ passed=baseline_ok,
1673
+ detail=baseline_detail,
1674
+ execution_env="host+toolchain" if toolchain_env else "host",
1675
+ )
1676
+ if not baseline_ok:
1677
+ reason = (
1678
+ "baseline characterization test is not green. "
1679
+ f"Fix test/dependency issues, then retry. Detail: {baseline_detail}"
1680
+ )
1681
+ _emit(
1682
+ progress_cb,
1683
+ phase="rr",
1684
+ event="preflight_failed",
1685
+ reason=reason,
1686
+ test_command=test_command or "",
1687
+ )
1688
+ notes.append(reason)
1689
+ return _build_artifact(
1690
+ run_store, run_id, constitution, model_id, outcomes, counts,
1691
+ notes, stopped=True, stop_reason=reason, test_command=test_command,
1692
+ )
1693
+
1694
+ if not requests:
1695
+ return _build_artifact(
1696
+ run_store, run_id, constitution, model_id, outcomes, counts,
1697
+ notes, stopped=False, stop_reason="", test_command=test_command,
1698
+ )
1699
+
1645
1700
  session = _Session(
1646
1701
  auth_ctx=auth_ctx,
1647
1702
  execution_mode=execution_mode,
@@ -1704,6 +1759,10 @@ def run_cloud_refactor_requests(
1704
1759
 
1705
1760
  guard = 0
1706
1761
  max_iters = max(50, len(requests) * 25)
1762
+ # Cache the single run-level baseline result and reuse it whenever the
1763
+ # server asks for `run_baseline_test` for a specific RR.
1764
+ cached_baseline: tuple[bool, str] = (baseline_ok, baseline_detail)
1765
+
1707
1766
  while guard < max_iters:
1708
1767
  guard += 1
1709
1768
  act = str(action.get("action", ""))
@@ -1716,7 +1775,7 @@ def run_cloud_refactor_requests(
1716
1775
  current_rr_id = action.get("rr_id", "") or current_rr_id
1717
1776
  _emit(progress_cb, phase="rr", event="test_generating", rr_id=current_rr_id)
1718
1777
  _write_generated_test(project_root, current_rr_id, action, by_id)
1719
- passed, detail = _run_test(execution_root, test_command, env=toolchain_env)
1778
+ passed, detail = cached_baseline
1720
1779
  _emit(progress_cb, phase="rr", event="baseline_test", rr_id=current_rr_id,
1721
1780
  passed=passed, detail=detail,
1722
1781
  execution_env="host+toolchain" if toolchain_env else "host")
@@ -13,6 +13,7 @@ headless). The heavy lifting (state machine, rendering, review parsing) lives in
13
13
 
14
14
  from __future__ import annotations
15
15
 
16
+ import contextlib
16
17
  import json
17
18
  import os
18
19
  import select
@@ -294,6 +295,36 @@ def _ingest_event(project_root: Path, state: WatchState, event: dict) -> None:
294
295
  node.rr_preview = preview
295
296
 
296
297
 
298
+ def _has_refactor_merge_evidence(project_root: Path, node, fin: FinalizeInfo) -> bool:
299
+ """True when this finalize branch has concrete evidence of refactor commits.
300
+
301
+ Guards against false "merged" labels when a branch exists but carries no
302
+ applied RR commits (for example, a deferred/no-op run where the branch tip is
303
+ still the same as the source commit).
304
+ """
305
+ # Strongest signal: persisted per-request commits for this branch.
306
+ if getattr(fin, "commits", None):
307
+ return True
308
+ # Fallback signal: branch tip diverged from the source commit.
309
+ source_sha = str(getattr(fin, "source_sha", "") or getattr(node, "sha", "") or "")
310
+ try:
311
+ branch_tip = git_scope.resolve_sha(project_root, fin.refactor_branch) or ""
312
+ except Exception:
313
+ branch_tip = ""
314
+ return bool(branch_tip and source_sha and not _shas_match(branch_tip, source_sha))
315
+
316
+
317
+ def _is_still_merged(project_root: Path, fin: FinalizeInfo, primary: str) -> bool:
318
+ """Best-effort check that a branch is really merged into primary."""
319
+ try:
320
+ # Use deep=True to also preserve squash/rebase merges.
321
+ return git_scope.branch_merged_into(
322
+ project_root, fin.refactor_branch, primary, deep=True
323
+ )
324
+ except Exception:
325
+ return True
326
+
327
+
297
328
  def reconcile_merged(project_root: Path, state: WatchState, *, deep: bool = False) -> None:
298
329
  """Detect refactor branches integrated into the primary branch out-of-band.
299
330
 
@@ -310,7 +341,18 @@ def reconcile_merged(project_root: Path, state: WatchState, *, deep: bool = Fals
310
341
  fin = getattr(node, "finalize", None)
311
342
  if fin is None or not fin.branch_exists:
312
343
  continue
313
- if fin.outcome in (refactor_branch_store.OUTCOME_MERGED, refactor_branch_store.OUTCOME_DROPPED):
344
+ if fin.outcome == refactor_branch_store.OUTCOME_MERGED:
345
+ # Self-heal stale metadata: if a prior run marked merged incorrectly
346
+ # but the branch is still not merged, clear the terminal outcome.
347
+ if not _is_still_merged(project_root, fin, primary):
348
+ refactor_branch_store.set_outcome(project_root, fin.refactor_branch, "")
349
+ node.finalize = resolve_finalize(project_root, node)
350
+ watch_ledger.record_commit(project_root, node)
351
+ continue
352
+ if fin.outcome == refactor_branch_store.OUTCOME_DROPPED:
353
+ continue
354
+ # Don't infer merged for empty/no-op branches.
355
+ if not _has_refactor_merge_evidence(project_root, node, fin):
314
356
  continue
315
357
  try:
316
358
  merged = git_scope.branch_merged_into(project_root, fin.refactor_branch, primary, deep=deep)
@@ -632,6 +674,25 @@ def _launch_interactive(cmd: list[str], cwd: Path) -> int:
632
674
  return 130
633
675
 
634
676
 
677
+ def _wait_for_return_key() -> None:
678
+ """Block until one key is pressed before returning to the watch TUI.
679
+
680
+ Used for short-lived actions like ``diff`` so output does not flash and
681
+ disappear when the live screen resumes.
682
+ """
683
+ if not sys.stdin.isatty():
684
+ # Fallback for non-tty stdin where `_read_key` cannot detect a raw key.
685
+ with contextlib.suppress(EOFError, KeyboardInterrupt):
686
+ typer.prompt("Press Enter to return to the Refactor Terminal", default="")
687
+ return
688
+
689
+ console.print("[dim]watch: press any key to return to the Refactor Terminal...[/dim]")
690
+ while True:
691
+ key = _read_key(0.1)
692
+ if key:
693
+ return
694
+
695
+
635
696
  def _run_json_stream(project_root: Path, state: WatchState, runner: ReviewRunner, once: bool) -> None:
636
697
  """Emit a newline-delimited JSON node-event stream (agents / headless)."""
637
698
  emitted: dict[str, str] = {}
@@ -703,6 +764,8 @@ def _run_action(
703
764
  console.print(f"\n[bold bright_cyan]watch:[/bold bright_cyan] {action} for "
704
765
  f"[yellow]{node.short_sha}[/yellow] ({node.branch or 'detached'})\n")
705
766
  _launch_interactive(cmd, project_root)
767
+ if action == "diff":
768
+ _wait_for_return_key()
706
769
  if action == "refresh":
707
770
  # `[f]` explicitly regenerates requests, so re-review this commit on the
708
771
  # next pass (also clears any `[b] back` override).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: refactorai-cli
3
- Version: 0.7.7
3
+ Version: 0.7.9
4
4
  Summary: Local-first CLI for the refactor platform
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -8,7 +8,7 @@ Requires-Dist: typer>=0.12.0
8
8
  Requires-Dist: httpx>=0.27.0
9
9
  Requires-Dist: rich>=13.7.0
10
10
  Requires-Dist: PyYAML>=6.0.1
11
- Requires-Dist: refactorai-core>=3.2.19
11
+ Requires-Dist: refactorai-core>=3.2.20
12
12
 
13
13
  # refactorai-cli
14
14
 
@@ -2,4 +2,4 @@ typer>=0.12.0
2
2
  httpx>=0.27.0
3
3
  rich>=13.7.0
4
4
  PyYAML>=6.0.1
5
- refactorai-core>=3.2.19
5
+ refactorai-core>=3.2.20
File without changes
File without changes