refactorai-cli 0.2.7__tar.gz → 0.2.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.
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/PKG-INFO +1 -1
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/pyproject.toml +1 -1
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/__init__.py +1 -1
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/run_cmds.py +57 -12
- refactorai_cli-0.2.9/refactorai_cli/commands/runtime_proxy_cmds.py +138 -0
- refactorai_cli-0.2.9/refactorai_cli/main.py +69 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli.egg-info/PKG-INFO +1 -1
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli.egg-info/SOURCES.txt +1 -0
- refactorai_cli-0.2.7/refactorai_cli/main.py +0 -160
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/README.md +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/auth.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/client.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/__init__.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/auth_cmds.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/engine_cmds.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/model_cmds.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/rules_cmds.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/runtime_cmds.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/commands/setup_cmds.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/control_plane.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/credentials.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/local_constitution.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/local_engine_runtime.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/local_paths.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/model_policy.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/runtime_manager.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/settings.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli/setup_flow.py +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli.egg-info/dependency_links.txt +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli.egg-info/entry_points.txt +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli.egg-info/requires.txt +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/refactorai_cli.egg-info/top_level.txt +0 -0
- {refactorai_cli-0.2.7 → refactorai_cli-0.2.9}/setup.cfg +0 -0
|
@@ -61,9 +61,12 @@ from refactor_core.sandbox_runtime import (
|
|
|
61
61
|
DEFAULT_IMAGE as SANDBOX_DEFAULT_IMAGE,
|
|
62
62
|
DEFAULT_SHELL as SANDBOX_DEFAULT_SHELL,
|
|
63
63
|
attach_shell as attach_sandbox_shell,
|
|
64
|
+
command_exists_in_container,
|
|
64
65
|
command_exists_in_sandbox,
|
|
66
|
+
detect_installer_in_container,
|
|
65
67
|
detect_installer_in_sandbox,
|
|
66
68
|
ensure_sandbox,
|
|
69
|
+
exec_in_container,
|
|
67
70
|
exec_in_sandbox,
|
|
68
71
|
remove_sandbox_container,
|
|
69
72
|
sandbox_name,
|
|
@@ -854,13 +857,47 @@ def _sandbox_preflight(
|
|
|
854
857
|
config_settings: dict,
|
|
855
858
|
auto_approve: bool,
|
|
856
859
|
no_install: bool,
|
|
860
|
+
runtime: str | None = None,
|
|
861
|
+
container_name: str | None = None,
|
|
862
|
+
workdir: str | None = None,
|
|
857
863
|
) -> tuple[bool, str]:
|
|
858
864
|
"""Run sandbox preflight and optionally perform approved install plan."""
|
|
865
|
+
|
|
866
|
+
has_container_ctx = bool(runtime and container_name)
|
|
867
|
+
resolved_workdir = str(workdir or "/workspace")
|
|
868
|
+
|
|
869
|
+
def _binary_exists(binary: str) -> bool:
|
|
870
|
+
if has_container_ctx:
|
|
871
|
+
return command_exists_in_container(
|
|
872
|
+
runtime=str(runtime),
|
|
873
|
+
container_name=str(container_name),
|
|
874
|
+
binary=binary,
|
|
875
|
+
workdir=resolved_workdir,
|
|
876
|
+
)
|
|
877
|
+
return command_exists_in_sandbox(project_root=project_root, binary=binary)
|
|
878
|
+
|
|
879
|
+
def _exec(command: str) -> tuple[bool, str]:
|
|
880
|
+
if has_container_ctx:
|
|
881
|
+
return exec_in_container(
|
|
882
|
+
runtime=str(runtime),
|
|
883
|
+
container_name=str(container_name),
|
|
884
|
+
command=command,
|
|
885
|
+
workdir=resolved_workdir,
|
|
886
|
+
)
|
|
887
|
+
return exec_in_sandbox(project_root=project_root, command=command)
|
|
888
|
+
|
|
889
|
+
def _detect_installer() -> str | None:
|
|
890
|
+
if has_container_ctx:
|
|
891
|
+
return detect_installer_in_container(
|
|
892
|
+
runtime=str(runtime),
|
|
893
|
+
container_name=str(container_name),
|
|
894
|
+
workdir=resolved_workdir,
|
|
895
|
+
)
|
|
896
|
+
return detect_installer_in_sandbox(project_root=project_root)
|
|
897
|
+
|
|
859
898
|
test_command = resolve_test_command(project_root, config_settings)
|
|
860
899
|
required_lsp = _required_lsp_commands(project_root)
|
|
861
|
-
missing_lsp = [
|
|
862
|
-
cmd for cmd in sorted(required_lsp) if not command_exists_in_sandbox(project_root=project_root, binary=cmd)
|
|
863
|
-
]
|
|
900
|
+
missing_lsp = [cmd for cmd in sorted(required_lsp) if not _binary_exists(cmd)]
|
|
864
901
|
missing_binary = ""
|
|
865
902
|
test_command_present = ""
|
|
866
903
|
if test_command:
|
|
@@ -877,7 +914,7 @@ def _sandbox_preflight(
|
|
|
877
914
|
)
|
|
878
915
|
return False, f"Could not parse test command: {test_command!r}"
|
|
879
916
|
test_command_present = binary
|
|
880
|
-
if not
|
|
917
|
+
if not _binary_exists(binary):
|
|
881
918
|
missing_binary = binary
|
|
882
919
|
|
|
883
920
|
if not missing_binary and not missing_lsp:
|
|
@@ -896,7 +933,7 @@ def _sandbox_preflight(
|
|
|
896
933
|
return True, "No test command configured."
|
|
897
934
|
return True, f"Preflight ok: found '{test_command_present}' and required LSP server(s) in sandbox."
|
|
898
935
|
|
|
899
|
-
installer =
|
|
936
|
+
installer = _detect_installer()
|
|
900
937
|
plan: list[str] = []
|
|
901
938
|
if missing_binary:
|
|
902
939
|
plan.extend(
|
|
@@ -1007,7 +1044,7 @@ def _sandbox_preflight(
|
|
|
1007
1044
|
"results": [],
|
|
1008
1045
|
}
|
|
1009
1046
|
for cmd in plan:
|
|
1010
|
-
ok, output =
|
|
1047
|
+
ok, output = _exec(cmd)
|
|
1011
1048
|
entry["results"].append({"command": cmd, "ok": ok, "output": (output or "")[:500]})
|
|
1012
1049
|
if not ok:
|
|
1013
1050
|
detail = output[:400] if output else "unknown error"
|
|
@@ -1027,7 +1064,7 @@ def _sandbox_preflight(
|
|
|
1027
1064
|
return False, f"Install command failed: `{cmd}` -> {detail}"
|
|
1028
1065
|
append_sandbox_install_history(project_root, entry)
|
|
1029
1066
|
|
|
1030
|
-
if missing_binary and not
|
|
1067
|
+
if missing_binary and not _binary_exists(missing_binary):
|
|
1031
1068
|
write_sandbox_preflight(
|
|
1032
1069
|
project_root,
|
|
1033
1070
|
{
|
|
@@ -1041,9 +1078,7 @@ def _sandbox_preflight(
|
|
|
1041
1078
|
},
|
|
1042
1079
|
)
|
|
1043
1080
|
return False, f"Preflight still failed after install: '{missing_binary}' not found."
|
|
1044
|
-
still_missing_lsp = [
|
|
1045
|
-
cmd for cmd in missing_lsp if not command_exists_in_sandbox(project_root=project_root, binary=cmd)
|
|
1046
|
-
]
|
|
1081
|
+
still_missing_lsp = [cmd for cmd in missing_lsp if not _binary_exists(cmd)]
|
|
1047
1082
|
if still_missing_lsp:
|
|
1048
1083
|
write_sandbox_preflight(
|
|
1049
1084
|
project_root,
|
|
@@ -1140,6 +1175,9 @@ def _ensure_sandbox_ready(
|
|
|
1140
1175
|
config_settings=settings,
|
|
1141
1176
|
auto_approve=auto_approve_install,
|
|
1142
1177
|
no_install=no_install,
|
|
1178
|
+
runtime=resolved_runtime,
|
|
1179
|
+
container_name=str(state.get("container_name", "") or ""),
|
|
1180
|
+
workdir=str(state.get("workdir") or workdir),
|
|
1143
1181
|
)
|
|
1144
1182
|
if not preflight_ok:
|
|
1145
1183
|
console.print(f"[red]{stage}: {preflight_msg}[/red]")
|
|
@@ -1149,6 +1187,7 @@ def _ensure_sandbox_ready(
|
|
|
1149
1187
|
"ephemeral": ephemeral,
|
|
1150
1188
|
"runtime": resolved_runtime,
|
|
1151
1189
|
"container_name": state.get("container_name", ""),
|
|
1190
|
+
"workdir": str(state.get("workdir") or workdir),
|
|
1152
1191
|
"stage": stage,
|
|
1153
1192
|
}
|
|
1154
1193
|
|
|
@@ -1233,6 +1272,9 @@ def start(
|
|
|
1233
1272
|
config_settings=settings,
|
|
1234
1273
|
auto_approve=yes,
|
|
1235
1274
|
no_install=no_install,
|
|
1275
|
+
runtime=resolved_runtime,
|
|
1276
|
+
container_name=str(state.get("container_name", "") or ""),
|
|
1277
|
+
workdir=str(state.get("workdir") or workdir),
|
|
1236
1278
|
)
|
|
1237
1279
|
if not preflight_ok:
|
|
1238
1280
|
console.print(f"[red]{preflight_msg}[/red]")
|
|
@@ -1497,8 +1539,11 @@ def code(
|
|
|
1497
1539
|
constitution=constitution,
|
|
1498
1540
|
provider=selected_provider,
|
|
1499
1541
|
requests=requests,
|
|
1500
|
-
config=
|
|
1501
|
-
|
|
1542
|
+
config=(
|
|
1543
|
+
dict(getattr(project_config, "settings", {}) or {})
|
|
1544
|
+
| ({"sandbox": {"enabled": True}} if sandbox_on else {})
|
|
1545
|
+
| ({"_sandbox_context": sandbox_ctx} if sandbox_ctx else {})
|
|
1546
|
+
)
|
|
1502
1547
|
or dict(getattr(constitution, "settings", {}) or {}),
|
|
1503
1548
|
progress_cb=_rr_progress_logger(status=status),
|
|
1504
1549
|
approval_cb=_rr_approval_prompt(auto_approve=auto_approve),
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""Top-level run commands proxied to the downloaded proprietary runtime binary.
|
|
2
|
+
|
|
3
|
+
The public CLI package is intentionally thin; operational commands are executed
|
|
4
|
+
by the activated runtime artifact under ``~/.refactor/runtime``.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import subprocess
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
import typer
|
|
13
|
+
from rich.console import Console
|
|
14
|
+
|
|
15
|
+
from refactorai_cli.runtime_manager import runtime_artifact_path, runtime_status
|
|
16
|
+
|
|
17
|
+
console = Console()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _active_runtime_artifact() -> Path:
|
|
21
|
+
status = runtime_status()
|
|
22
|
+
version = str(status.get("active_version") or "").strip()
|
|
23
|
+
if not version:
|
|
24
|
+
console.print(
|
|
25
|
+
"[red]No active runtime found.[/red] "
|
|
26
|
+
"Run `refactor setup` or `refactor runtime update` first."
|
|
27
|
+
)
|
|
28
|
+
raise typer.Exit(code=1)
|
|
29
|
+
artifact = runtime_artifact_path(version)
|
|
30
|
+
if not artifact.is_file():
|
|
31
|
+
console.print(
|
|
32
|
+
f"[red]Active runtime artifact is missing:[/red] {artifact}\n"
|
|
33
|
+
"Run `refactor runtime update` to recover."
|
|
34
|
+
)
|
|
35
|
+
raise typer.Exit(code=1)
|
|
36
|
+
return artifact
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _exec_runtime(command_name: str, passthrough_args: list[str]) -> None:
|
|
40
|
+
artifact = _active_runtime_artifact()
|
|
41
|
+
# Best-effort ensure executable bit for artifacts downloaded on Linux/macOS.
|
|
42
|
+
try:
|
|
43
|
+
mode = artifact.stat().st_mode
|
|
44
|
+
artifact.chmod(mode | 0o111)
|
|
45
|
+
except OSError:
|
|
46
|
+
pass
|
|
47
|
+
probe = subprocess.run(
|
|
48
|
+
[str(artifact), command_name, "--help"],
|
|
49
|
+
check=False,
|
|
50
|
+
capture_output=True,
|
|
51
|
+
text=True,
|
|
52
|
+
)
|
|
53
|
+
probe_text = f"{probe.stdout}\n{probe.stderr}".lower()
|
|
54
|
+
if "unrecognized arguments" in probe_text and command_name in probe_text:
|
|
55
|
+
console.print(
|
|
56
|
+
"[red]Active runtime artifact does not support command dispatch yet.[/red]\n"
|
|
57
|
+
"Run `refactor runtime update` (or rerun setup from S3) to install the "
|
|
58
|
+
"latest runtime binary from your server."
|
|
59
|
+
)
|
|
60
|
+
raise typer.Exit(code=2)
|
|
61
|
+
proc = subprocess.run([str(artifact), command_name, *passthrough_args], check=False)
|
|
62
|
+
if proc.returncode != 0:
|
|
63
|
+
raise typer.Exit(code=proc.returncode)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def init(ctx: typer.Context) -> None:
|
|
67
|
+
"""Initialize project state via proprietary runtime."""
|
|
68
|
+
_exec_runtime("init", list(ctx.args))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def start(ctx: typer.Context) -> None:
|
|
72
|
+
"""Start runtime-managed workflow via proprietary runtime."""
|
|
73
|
+
_exec_runtime("start", list(ctx.args))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def stop(ctx: typer.Context) -> None:
|
|
77
|
+
"""Stop runtime-managed workflow via proprietary runtime."""
|
|
78
|
+
_exec_runtime("stop", list(ctx.args))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def shell(ctx: typer.Context) -> None:
|
|
82
|
+
"""Open runtime shell via proprietary runtime."""
|
|
83
|
+
_exec_runtime("shell", list(ctx.args))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def review(ctx: typer.Context) -> None:
|
|
87
|
+
"""Run review via proprietary runtime."""
|
|
88
|
+
_exec_runtime("review", list(ctx.args))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def code(ctx: typer.Context) -> None:
|
|
92
|
+
"""Run code mode via proprietary runtime."""
|
|
93
|
+
_exec_runtime("code", list(ctx.args))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def requests(ctx: typer.Context) -> None:
|
|
97
|
+
"""Inspect/manage requests via proprietary runtime."""
|
|
98
|
+
_exec_runtime("requests", list(ctx.args))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def apply(ctx: typer.Context) -> None:
|
|
102
|
+
"""Apply pending changes via proprietary runtime."""
|
|
103
|
+
_exec_runtime("apply", list(ctx.args))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def revert(ctx: typer.Context) -> None:
|
|
107
|
+
"""Revert pending changes via proprietary runtime."""
|
|
108
|
+
_exec_runtime("revert", list(ctx.args))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def status(ctx: typer.Context) -> None:
|
|
112
|
+
"""Show runtime status via proprietary runtime."""
|
|
113
|
+
_exec_runtime("status", list(ctx.args))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def diff(ctx: typer.Context) -> None:
|
|
117
|
+
"""Show diff via proprietary runtime."""
|
|
118
|
+
_exec_runtime("diff", list(ctx.args))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def gc(ctx: typer.Context) -> None:
|
|
122
|
+
"""Run runtime GC/cleanup."""
|
|
123
|
+
_exec_runtime("gc", list(ctx.args))
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def check(ctx: typer.Context) -> None:
|
|
127
|
+
"""Run checks via proprietary runtime."""
|
|
128
|
+
_exec_runtime("check", list(ctx.args))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def doctor(ctx: typer.Context) -> None:
|
|
132
|
+
"""Run diagnostics via proprietary runtime."""
|
|
133
|
+
_exec_runtime("doctor", list(ctx.args))
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def config(ctx: typer.Context) -> None:
|
|
137
|
+
"""Manage config via proprietary runtime."""
|
|
138
|
+
_exec_runtime("config", list(ctx.args))
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""`refactor` CLI entry point."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from refactorai_cli import __version__
|
|
8
|
+
from refactorai_cli.commands import auth_cmds, engine_cmds, model_cmds, runtime_cmds, runtime_proxy_cmds, setup_cmds
|
|
9
|
+
|
|
10
|
+
app = typer.Typer(
|
|
11
|
+
name="refactor",
|
|
12
|
+
help="Local-first AI code review and refactor, run from your project folder.",
|
|
13
|
+
no_args_is_help=True,
|
|
14
|
+
add_completion=False,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _version_callback(value: bool) -> None:
|
|
19
|
+
if value:
|
|
20
|
+
typer.echo(f"refactor {__version__}")
|
|
21
|
+
raise typer.Exit()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@app.callback()
|
|
25
|
+
def main(
|
|
26
|
+
version: bool = typer.Option(
|
|
27
|
+
False,
|
|
28
|
+
"--version",
|
|
29
|
+
"-V",
|
|
30
|
+
help="Show the CLI version and exit.",
|
|
31
|
+
callback=_version_callback,
|
|
32
|
+
is_eager=True,
|
|
33
|
+
),
|
|
34
|
+
) -> None:
|
|
35
|
+
"""refactor CLI."""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# Auth (R7.1)
|
|
39
|
+
app.command()(auth_cmds.login)
|
|
40
|
+
app.command()(auth_cmds.whoami)
|
|
41
|
+
|
|
42
|
+
# Project / run surface (proxied to activated runtime artifact)
|
|
43
|
+
_RUNTIME_CTX = {"allow_extra_args": True, "ignore_unknown_options": True}
|
|
44
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.init)
|
|
45
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.start)
|
|
46
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.stop)
|
|
47
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.shell)
|
|
48
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.review)
|
|
49
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.code)
|
|
50
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.requests)
|
|
51
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.apply)
|
|
52
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.revert)
|
|
53
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.status)
|
|
54
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.diff)
|
|
55
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.gc)
|
|
56
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.check)
|
|
57
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.doctor)
|
|
58
|
+
app.command(context_settings=_RUNTIME_CTX)(runtime_proxy_cmds.config)
|
|
59
|
+
|
|
60
|
+
app.command()(setup_cmds.setup)
|
|
61
|
+
|
|
62
|
+
# Runtime/engine/model operations.
|
|
63
|
+
app.add_typer(runtime_cmds.app, name="runtime")
|
|
64
|
+
app.add_typer(engine_cmds.app, name="engine")
|
|
65
|
+
app.add_typer(model_cmds.app, name="model")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
app()
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"""`refactor` CLI entry point."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import typer
|
|
6
|
-
|
|
7
|
-
from refactorai_cli import __version__
|
|
8
|
-
from refactorai_cli.commands import auth_cmds, engine_cmds, model_cmds, runtime_cmds, setup_cmds
|
|
9
|
-
|
|
10
|
-
app = typer.Typer(
|
|
11
|
-
name="refactor",
|
|
12
|
-
help="Local-first AI code review and refactor, run from your project folder.",
|
|
13
|
-
no_args_is_help=True,
|
|
14
|
-
add_completion=False,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def _version_callback(value: bool) -> None:
|
|
19
|
-
if value:
|
|
20
|
-
typer.echo(f"refactor {__version__}")
|
|
21
|
-
raise typer.Exit()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@app.callback()
|
|
25
|
-
def main(
|
|
26
|
-
version: bool = typer.Option(
|
|
27
|
-
False,
|
|
28
|
-
"--version",
|
|
29
|
-
"-V",
|
|
30
|
-
help="Show the CLI version and exit.",
|
|
31
|
-
callback=_version_callback,
|
|
32
|
-
is_eager=True,
|
|
33
|
-
),
|
|
34
|
-
) -> None:
|
|
35
|
-
"""refactor CLI."""
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def _core_feature_unavailable(feature: str) -> None:
|
|
39
|
-
typer.echo(
|
|
40
|
-
f"{feature} is unavailable in this standalone CLI install because "
|
|
41
|
-
"core runtime modules are not installed in Python. Run `refactor setup` "
|
|
42
|
-
"to complete machine bootstrap, then retry."
|
|
43
|
-
)
|
|
44
|
-
raise typer.Exit(code=2)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
try:
|
|
48
|
-
from refactorai_cli.commands import run_cmds as _run_cmds
|
|
49
|
-
except ModuleNotFoundError:
|
|
50
|
-
_run_cmds = None
|
|
51
|
-
|
|
52
|
-
try:
|
|
53
|
-
from refactorai_cli.commands import rules_cmds as _rules_cmds
|
|
54
|
-
except ModuleNotFoundError:
|
|
55
|
-
_rules_cmds = None
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# Auth (R7.1)
|
|
59
|
-
app.command()(auth_cmds.login)
|
|
60
|
-
app.command()(auth_cmds.whoami)
|
|
61
|
-
|
|
62
|
-
if _run_cmds is not None:
|
|
63
|
-
# Project / run surface
|
|
64
|
-
app.command()(_run_cmds.init)
|
|
65
|
-
app.command()(_run_cmds.start)
|
|
66
|
-
app.command()(_run_cmds.stop)
|
|
67
|
-
app.command()(_run_cmds.shell)
|
|
68
|
-
app.command()(_run_cmds.review)
|
|
69
|
-
app.command()(_run_cmds.code)
|
|
70
|
-
app.command()(_run_cmds.requests)
|
|
71
|
-
app.command()(_run_cmds.apply)
|
|
72
|
-
app.command()(_run_cmds.revert)
|
|
73
|
-
app.command()(_run_cmds.status)
|
|
74
|
-
app.command()(_run_cmds.diff)
|
|
75
|
-
app.command()(_run_cmds.gc)
|
|
76
|
-
app.command()(_run_cmds.check)
|
|
77
|
-
app.command()(_run_cmds.doctor)
|
|
78
|
-
app.command()(_run_cmds.config)
|
|
79
|
-
else:
|
|
80
|
-
@app.command("init")
|
|
81
|
-
def _init_stub() -> None:
|
|
82
|
-
_core_feature_unavailable("`refactor init`")
|
|
83
|
-
|
|
84
|
-
@app.command("start")
|
|
85
|
-
def _start_stub() -> None:
|
|
86
|
-
_core_feature_unavailable("`refactor start`")
|
|
87
|
-
|
|
88
|
-
@app.command("stop")
|
|
89
|
-
def _stop_stub() -> None:
|
|
90
|
-
_core_feature_unavailable("`refactor stop`")
|
|
91
|
-
|
|
92
|
-
@app.command("shell")
|
|
93
|
-
def _shell_stub() -> None:
|
|
94
|
-
_core_feature_unavailable("`refactor shell`")
|
|
95
|
-
|
|
96
|
-
@app.command("review")
|
|
97
|
-
def _review_stub() -> None:
|
|
98
|
-
_core_feature_unavailable("`refactor review`")
|
|
99
|
-
|
|
100
|
-
@app.command("code")
|
|
101
|
-
def _code_stub() -> None:
|
|
102
|
-
_core_feature_unavailable("`refactor code`")
|
|
103
|
-
|
|
104
|
-
@app.command("requests")
|
|
105
|
-
def _requests_stub() -> None:
|
|
106
|
-
_core_feature_unavailable("`refactor requests`")
|
|
107
|
-
|
|
108
|
-
@app.command("apply")
|
|
109
|
-
def _apply_stub() -> None:
|
|
110
|
-
_core_feature_unavailable("`refactor apply`")
|
|
111
|
-
|
|
112
|
-
@app.command("revert")
|
|
113
|
-
def _revert_stub() -> None:
|
|
114
|
-
_core_feature_unavailable("`refactor revert`")
|
|
115
|
-
|
|
116
|
-
@app.command("status")
|
|
117
|
-
def _status_stub() -> None:
|
|
118
|
-
_core_feature_unavailable("`refactor status`")
|
|
119
|
-
|
|
120
|
-
@app.command("diff")
|
|
121
|
-
def _diff_stub() -> None:
|
|
122
|
-
_core_feature_unavailable("`refactor diff`")
|
|
123
|
-
|
|
124
|
-
@app.command("gc")
|
|
125
|
-
def _gc_stub() -> None:
|
|
126
|
-
_core_feature_unavailable("`refactor gc`")
|
|
127
|
-
|
|
128
|
-
@app.command("check")
|
|
129
|
-
def _check_stub() -> None:
|
|
130
|
-
_core_feature_unavailable("`refactor check`")
|
|
131
|
-
|
|
132
|
-
@app.command("doctor")
|
|
133
|
-
def _doctor_stub() -> None:
|
|
134
|
-
_core_feature_unavailable("`refactor doctor`")
|
|
135
|
-
|
|
136
|
-
@app.command("config")
|
|
137
|
-
def _config_stub() -> None:
|
|
138
|
-
_core_feature_unavailable("`refactor config`")
|
|
139
|
-
|
|
140
|
-
app.command()(setup_cmds.setup)
|
|
141
|
-
|
|
142
|
-
# Runtime/engine/model operations.
|
|
143
|
-
if _rules_cmds is not None:
|
|
144
|
-
app.add_typer(_rules_cmds.app, name="rules")
|
|
145
|
-
else:
|
|
146
|
-
rules_stub_app = typer.Typer(help="Rules commands unavailable in this install.")
|
|
147
|
-
|
|
148
|
-
@rules_stub_app.callback(invoke_without_command=True)
|
|
149
|
-
def _rules_stub_callback() -> None:
|
|
150
|
-
_core_feature_unavailable("`refactor rules`")
|
|
151
|
-
|
|
152
|
-
app.add_typer(rules_stub_app, name="rules")
|
|
153
|
-
|
|
154
|
-
app.add_typer(runtime_cmds.app, name="runtime")
|
|
155
|
-
app.add_typer(engine_cmds.app, name="engine")
|
|
156
|
-
app.add_typer(model_cmds.app, name="model")
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if __name__ == "__main__":
|
|
160
|
-
app()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|