refactorai-cli 0.2.26__tar.gz → 0.2.27__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 (32) hide show
  1. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/PKG-INFO +2 -2
  2. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/README.md +1 -1
  3. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/pyproject.toml +1 -1
  4. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/__init__.py +1 -1
  5. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/setup_cmds.py +15 -0
  6. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/setup_flow.py +90 -9
  7. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli.egg-info/PKG-INFO +2 -2
  8. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/auth.py +0 -0
  9. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/client.py +0 -0
  10. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/__init__.py +0 -0
  11. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/auth_cmds.py +0 -0
  12. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/engine_cmds.py +0 -0
  13. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/model_cmds.py +0 -0
  14. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/rules_cmds.py +0 -0
  15. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/run_cmds.py +0 -0
  16. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/runtime_cmds.py +0 -0
  17. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/commands/runtime_proxy_cmds.py +0 -0
  18. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/control_plane.py +0 -0
  19. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/credentials.py +0 -0
  20. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/local_constitution.py +0 -0
  21. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/local_engine_runtime.py +0 -0
  22. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/local_paths.py +0 -0
  23. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/main.py +0 -0
  24. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/model_policy.py +0 -0
  25. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/runtime_manager.py +0 -0
  26. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli/settings.py +0 -0
  27. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli.egg-info/SOURCES.txt +0 -0
  28. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli.egg-info/dependency_links.txt +0 -0
  29. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli.egg-info/entry_points.txt +0 -0
  30. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli.egg-info/requires.txt +0 -0
  31. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/refactorai_cli.egg-info/top_level.txt +0 -0
  32. {refactorai_cli-0.2.26 → refactorai_cli-0.2.27}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: refactorai-cli
3
- Version: 0.2.26
3
+ Version: 0.2.27
4
4
  Summary: Local-first CLI for the refactor platform
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -53,6 +53,6 @@ python -m twine upload ./refactorai-cli/dist/*
53
53
  ## Install test (local)
54
54
 
55
55
  ```bash
56
- python -m pip install ./refactorai-cli/dist/refactorai_cli-0.2.26-py3-none-any.whl
56
+ python -m pip install ./refactorai-cli/dist/refactorai_cli-0.2.27-py3-none-any.whl
57
57
  refactor --version
58
58
  ```
@@ -42,6 +42,6 @@ python -m twine upload ./refactorai-cli/dist/*
42
42
  ## Install test (local)
43
43
 
44
44
  ```bash
45
- python -m pip install ./refactorai-cli/dist/refactorai_cli-0.2.26-py3-none-any.whl
45
+ python -m pip install ./refactorai-cli/dist/refactorai_cli-0.2.27-py3-none-any.whl
46
46
  refactor --version
47
47
  ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "refactorai-cli"
3
- version = "0.2.26"
3
+ version = "0.2.27"
4
4
  description = "Local-first CLI for the refactor platform"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -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.2.26"
8
+ __version__ = "0.2.27"
@@ -18,6 +18,19 @@ def _ask_approval(auto_approve: bool, prompt: str) -> bool:
18
18
  return True
19
19
 
20
20
 
21
+ def _applehv_fallback_applied() -> bool:
22
+ """Return True when S1 precheck applied Podman applehv fallback."""
23
+ payload = get_setup_diagnostics()
24
+ stages = payload.get("stages") or {}
25
+ s1 = stages.get("S1") or {}
26
+ if not isinstance(s1, dict):
27
+ return False
28
+ output = s1.get("output") or {}
29
+ if not isinstance(output, dict):
30
+ return False
31
+ return bool(output.get("podman_applehv_fallback_applied"))
32
+
33
+
21
34
  def setup(
22
35
  yes: bool = typer.Option(False, "--yes", help="Auto-approve setup actions."),
23
36
  resume: bool = typer.Option(False, "--resume", help="Resume from last incomplete stage."),
@@ -72,5 +85,7 @@ def setup(
72
85
  elif result.sandbox_ready is False:
73
86
  detail = result.sandbox_reason or "Podman missing or not ready."
74
87
  console.print(f"[yellow]sandbox[/yellow]: not ready ({detail})")
88
+ if _applehv_fallback_applied():
89
+ console.print("[yellow]sandbox fallback[/yellow]: applied provider=applehv")
75
90
  console.print(f"[bold]completed stages[/bold]: {', '.join(result.completed_stages)}")
76
91
  console.print("[bold]next[/bold]: run `refactor init` and then `refactor review .`")
@@ -193,6 +193,24 @@ def _host_runtime_repair_plan(runtime: str) -> list[str]:
193
193
  return []
194
194
 
195
195
 
196
+ def _is_krunkit_missing_error(detail: str) -> bool:
197
+ """Detect Podman startup failures caused by missing krunkit on macOS."""
198
+ text = str(detail or "").strip().lower()
199
+ return "krunkit" in text and ("not found" in text or "executable file" in text)
200
+
201
+
202
+ def _podman_applehv_fallback_plan() -> list[str]:
203
+ """Return recovery commands to recreate Podman machine with applehv."""
204
+ if sys.platform != "darwin":
205
+ return []
206
+ return [
207
+ "podman machine stop >/dev/null 2>&1 || true",
208
+ "podman machine rm --force >/dev/null 2>&1 || true",
209
+ "podman machine init --provider applehv",
210
+ "podman machine start",
211
+ ]
212
+
213
+
196
214
  def _run_host_plan(commands: list[str], emit: Callable[[str], None] | None = None) -> tuple[bool, str]:
197
215
  """Run host-level setup commands sequentially."""
198
216
  for command in commands:
@@ -250,12 +268,59 @@ def _stage_s1_precheck(_ask_approval: Callable[[str], bool], _emit: Callable[[st
250
268
  podman_repair_plan: list[str] = []
251
269
  podman_repair_approved = False
252
270
  podman_repair_attempted = False
271
+ podman_applehv_fallback_plan: list[str] = []
272
+ podman_applehv_fallback_approved = False
273
+ podman_applehv_fallback_attempted = False
274
+ podman_applehv_fallback_applied = False
275
+ podman_applehv_fallback_error = ""
253
276
  disk = shutil.disk_usage(str(refactor_home()))
254
277
  blockers: list[str] = []
255
278
  if disk.free < 2 * 1024 * 1024 * 1024:
256
279
  blockers.append("Less than 2GB free disk available in REFACTOR_HOME filesystem.")
257
280
  if blockers:
258
281
  raise SetupError("Precheck failed: " + "; ".join(blockers))
282
+
283
+ def _attempt_applehv_fallback(failure_detail: str) -> bool:
284
+ nonlocal podman_applehv_fallback_plan
285
+ nonlocal podman_applehv_fallback_approved
286
+ nonlocal podman_applehv_fallback_attempted
287
+ nonlocal podman_applehv_fallback_applied
288
+ nonlocal podman_applehv_fallback_error
289
+ if not _is_krunkit_missing_error(failure_detail):
290
+ return False
291
+ if not podman_applehv_fallback_plan:
292
+ podman_applehv_fallback_plan = _podman_applehv_fallback_plan()
293
+ if not podman_applehv_fallback_plan:
294
+ return False
295
+ if _emit:
296
+ _emit(
297
+ "Detected Podman startup failure due to missing `krunkit`. "
298
+ "Offering Apple Hypervisor fallback..."
299
+ )
300
+ podman_applehv_fallback_approved = _ask_approval(
301
+ "Podman start failed because `krunkit` is missing. "
302
+ "Recreate Podman machine with `applehv` provider now? "
303
+ "This can remove existing Podman machine state."
304
+ )
305
+ if not podman_applehv_fallback_approved:
306
+ podman_applehv_fallback_error = "fallback_not_approved"
307
+ return False
308
+ podman_applehv_fallback_attempted = True
309
+ if _emit:
310
+ _emit("Applying Podman fallback with `applehv` provider...")
311
+ ok, fallback_detail = _run_host_plan(podman_applehv_fallback_plan, emit=_emit)
312
+ if not ok:
313
+ podman_applehv_fallback_error = fallback_detail
314
+ return False
315
+ podman_applehv_fallback_applied = True
316
+ podman_applehv_fallback_error = ""
317
+ return True
318
+
319
+ def _applehv_manual_hint() -> str:
320
+ if not podman_applehv_fallback_plan:
321
+ return ""
322
+ return " To recover on macOS, run: " + "; ".join(podman_applehv_fallback_plan) + "."
323
+
259
324
  if not runtime:
260
325
  podman_install_plan = _host_runtime_install_plan("podman")
261
326
  if podman_install_plan:
@@ -268,11 +333,21 @@ def _stage_s1_precheck(_ask_approval: Callable[[str], bool], _emit: Callable[[st
268
333
  _emit("Podman was not found. Running guided host install plan...")
269
334
  ok, detail = _run_host_plan(podman_install_plan, emit=_emit)
270
335
  if not ok:
271
- raise SetupError(
272
- "Podman host install failed: "
273
- f"{detail}. Install manually and retry (`refactor doctor --sandbox`)."
274
- )
275
- runtime, reason = resolve_engine_runtime("podman")
336
+ if _attempt_applehv_fallback(detail):
337
+ runtime, reason = resolve_engine_runtime("podman")
338
+ if not runtime:
339
+ raise SetupError(
340
+ "Apple Hypervisor fallback completed but Podman is still unavailable. "
341
+ "Verify PATH and retry (`refactor doctor --sandbox`)."
342
+ )
343
+ else:
344
+ fallback_hint = _applehv_manual_hint()
345
+ raise SetupError(
346
+ "Podman host install failed: "
347
+ f"{detail}.{fallback_hint} Install manually and retry (`refactor doctor --sandbox`)."
348
+ )
349
+ if not runtime:
350
+ runtime, reason = resolve_engine_runtime("podman")
276
351
  if not runtime:
277
352
  raise SetupError(
278
353
  "Podman install completed but runtime is still unavailable. "
@@ -297,10 +372,11 @@ def _stage_s1_precheck(_ask_approval: Callable[[str], bool], _emit: Callable[[st
297
372
  _emit("Podman is installed but not ready. Running repair plan...")
298
373
  ok, detail = _run_host_plan(podman_repair_plan, emit=_emit)
299
374
  if not ok:
300
- raise SetupError(
301
- "Podman runtime repair failed: "
302
- f"{detail}. Run `podman machine start` and retry."
303
- )
375
+ if not _attempt_applehv_fallback(detail):
376
+ raise SetupError(
377
+ "Podman runtime repair failed: "
378
+ f"{detail}.{_applehv_manual_hint()} Run `podman machine start` and retry."
379
+ )
304
380
  podman_ready, podman_ready_reason = _podman_runtime_ready(str(runtime))
305
381
  if not podman_ready:
306
382
  raise SetupError(
@@ -332,6 +408,11 @@ def _stage_s1_precheck(_ask_approval: Callable[[str], bool], _emit: Callable[[st
332
408
  "podman_repair_plan": podman_repair_plan,
333
409
  "podman_repair_approved": podman_repair_approved,
334
410
  "podman_repair_attempted": podman_repair_attempted,
411
+ "podman_applehv_fallback_plan": podman_applehv_fallback_plan,
412
+ "podman_applehv_fallback_approved": podman_applehv_fallback_approved,
413
+ "podman_applehv_fallback_attempted": podman_applehv_fallback_attempted,
414
+ "podman_applehv_fallback_applied": podman_applehv_fallback_applied,
415
+ "podman_applehv_fallback_error": podman_applehv_fallback_error,
335
416
  "disk_free_mb": int(disk.free / (1024 * 1024)),
336
417
  }
337
418
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: refactorai-cli
3
- Version: 0.2.26
3
+ Version: 0.2.27
4
4
  Summary: Local-first CLI for the refactor platform
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -53,6 +53,6 @@ python -m twine upload ./refactorai-cli/dist/*
53
53
  ## Install test (local)
54
54
 
55
55
  ```bash
56
- python -m pip install ./refactorai-cli/dist/refactorai_cli-0.2.26-py3-none-any.whl
56
+ python -m pip install ./refactorai-cli/dist/refactorai_cli-0.2.27-py3-none-any.whl
57
57
  refactor --version
58
58
  ```