77from pathlib import Path
88from typing import Any
99
10- from Core .Configs import (
11- ArkConfigError ,
12- ArkConfigValidationResult ,
13- load_ark_config as _load_ark_config ,
14- new_workspace_config ,
15- validate_ark_config as _validate_ark_config ,
16- write_ark_config ,
17- )
18- from Core .Locking import (
19- BuildContext ,
20- build_context_from_ark_config as _build_context_from_ark_config ,
21- build_context_from_lock as _build_context_from_lock ,
22- build_lock_payload as _build_lock_payload ,
23- cache_rebuild_lock as _cache_rebuild_lock ,
24- compare_lock_payloads as _compare_lock_payloads ,
25- default_lock_path as _default_lock_path ,
26- ensure_workspace_layout ,
27- load_yaml_file ,
28- write_lock_files as _write_lock_files ,
29- )
3010from Core .Compiler .engine_runner import run_engine_compile as _core_run_engine_compile
3111from Core .Configs import (
3212 CONFIG_KEYS ,
3313 DEFAULT_USER_DIRS ,
14+ ArkConfigError ,
15+ ArkConfigValidationResult ,
3416 UserConfigError ,
35- config_home as _config_home ,
36- ensure_config_home as _ensure_config_home ,
37- config_file_for as _config_file_for ,
17+ )
18+ from Core .Configs import config_file_for as _config_file_for
19+ from Core .Configs import config_home as _config_home
20+ from Core .Configs import ensure_config_home as _ensure_config_home
21+ from Core .Configs import load_ark_config as _load_ark_config
22+ from Core .Configs import (
23+ new_workspace_config ,
3824 resolve_config_value ,
3925 set_config_value ,
4026 unset_config_value ,
4127)
28+ from Core .Configs import validate_ark_config as _validate_ark_config
29+ from Core .Configs import write_ark_config
30+ from Core .Locking import BuildContext
31+ from Core .Locking import build_context_from_ark_config as _build_context_from_ark_config
32+ from Core .Locking import build_context_from_lock as _build_context_from_lock
33+ from Core .Locking import build_lock_payload as _build_lock_payload
34+ from Core .Locking import cache_rebuild_lock as _cache_rebuild_lock
35+ from Core .Locking import compare_lock_payloads as _compare_lock_payloads
36+ from Core .Locking import default_lock_path as _default_lock_path
37+ from Core .Locking import ensure_workspace_layout , load_yaml_file
38+ from Core .Locking import write_lock_files as _write_lock_files
39+
4240from .discovery import (
4341 bcasl_list_payload ,
4442 engine_info_payload ,
@@ -63,6 +61,7 @@ class ArkValidationResult:
6361# resolve_config_value / set_config_value / unset_config_value are imported
6462# directly from Core.Configs above and re-exported as-is.
6563
64+
6665def config_home () -> Path :
6766 """Return the ARK user config root (delegates to Core.Configs)."""
6867 return _config_home ()
@@ -162,7 +161,9 @@ def init_workspace(
162161 text = True ,
163162 )
164163 if result .returncode != 0 :
165- raise CliSpecError (result .stderr .strip () or "requirements installation failed" )
164+ raise CliSpecError (
165+ result .stderr .strip () or "requirements installation failed"
166+ )
166167
167168 return {
168169 "workspace" : str (workspace ),
@@ -204,7 +205,12 @@ def validate_ark_config(workspace: Path, config: dict[str, Any]) -> ArkValidatio
204205def engine_version (engine_id : str ) -> str :
205206 try :
206207 payload = engine_info_payload (engine_id )
207- return str (((payload .get ("engine" ) or {}) if payload .get ("found" ) else {}).get ("version" ) or "unknown" )
208+ return str (
209+ ((payload .get ("engine" ) or {}) if payload .get ("found" ) else {}).get (
210+ "version"
211+ )
212+ or "unknown"
213+ )
208214 except Exception :
209215 return "unknown"
210216
@@ -301,16 +307,19 @@ def run_bcasl_before_compile_sync(workspace: Path) -> bool:
301307 Returns:
302308 True if compilation can proceed (success or BCASL disabled), False otherwise.
303309 """
304- from .output import info , error , success , log
305310 from bcasl .Loader import run_pre_compile
306311
312+ from .output import error , info , log , success
313+
307314 class CliBcaslHost :
308315 def __init__ (self , ws_dir : Path ):
309316 self .workspace_dir = str (ws_dir )
317+
310318 class Logger :
311319 def append (self , msg : str ):
312320 # Strip trailing newline as our log() adds one
313321 log ("BCASL" , msg .rstrip ())
322+
314323 self .log = Logger ()
315324
316325 host = CliBcaslHost (workspace )
@@ -337,25 +346,28 @@ def append(self, msg: str):
337346
338347def run_bcasl_headless (args : list [str ]) -> int :
339348 """Run BCASL in headless mode for the current workspace."""
340- from .output import error , success
341349 from bcasl .Loader import run_pre_compile
342350
351+ from .output import error , success
352+
343353 workspace = Path .cwd ()
344354 if "run" in args :
345355 # If workspace path is provided in args, use it
346356 for i , arg in enumerate (args ):
347357 if arg == "run" and i + 1 < len (args ):
348- candidate = Path (args [i + 1 ])
358+ candidate = Path (args [i + 1 ])
349359 if candidate .is_dir ():
350360 workspace = candidate .resolve ()
351361 break
352362
353363 class CliBcaslHost :
354364 def __init__ (self , ws_dir : Path ):
355365 self .workspace_dir = str (ws_dir )
366+
356367 class Logger :
357368 def append (self , msg : str ):
358369 print (msg , end = "" , flush = True )
370+
359371 self .log = Logger ()
360372
361373 host = CliBcaslHost (workspace )
@@ -370,6 +382,7 @@ def append(self, msg: str):
370382 error (f"BCASL failed: { exc } " )
371383 return 1
372384
385+
373386def launch_gui (* , legacy : bool = False ) -> int :
374387 return launch_main_application (
375388 no_splash = False ,
0 commit comments