2929 get_functions_within_git_diff ,
3030)
3131from codeflash .either import is_successful
32+ from codeflash .lsp .context import execution_context_vars
3233from codeflash .lsp .features .perform_optimization import get_cancelled_reponse , sync_perform_optimization
3334from codeflash .lsp .server import CodeflashLanguageServer , CodeflashLanguageServerProtocol
3435
@@ -71,11 +72,6 @@ class ValidateProjectParams:
7172 skip_validation : bool = False
7273
7374
74- @dataclass
75- class OnPatchAppliedParams :
76- task_id : str
77-
78-
7975@dataclass
8076class OptimizableFunctionsInCommitParams :
8177 commit_hash : str
@@ -90,6 +86,11 @@ class WriteConfigParams:
9086server = CodeflashLanguageServer ("codeflash-language-server" , "v1.0" , protocol_cls = CodeflashLanguageServerProtocol )
9187
9288
89+ @server .feature ("server/listFeatures" )
90+ def list_features (_params : any ) -> list [str ]:
91+ return list (server .protocol .fm .features )
92+
93+
9394@server .feature ("getOptimizableFunctionsInCurrentDiff" )
9495def get_functions_in_current_git_diff (_params : OptimizableFunctionsParams ) -> dict [str , str | dict [str , list [str ]]]:
9596 functions = get_functions_within_git_diff (uncommitted_changes = True )
@@ -250,7 +251,7 @@ def init_project(params: ValidateProjectParams) -> dict[str, str]:
250251 "existingConfig" : config ,
251252 }
252253
253- args = _init ()
254+ args = process_args ()
254255 return {"status" : "success" , "moduleRoot" : args .module_root , "pyprojectPath" : pyproject_toml_path , "root" : root }
255256
256257
@@ -268,8 +269,9 @@ def _check_api_key_validity(api_key: Optional[str]) -> dict[str, str]:
268269 if user_id is None :
269270 return {"status" : "error" , "message" : "api key not found or invalid" }
270271
271- if user_id .startswith ("Error: " ):
272- error_msg = user_id [7 :]
272+ error_prefix = "Error: "
273+ if user_id .startswith (error_prefix ):
274+ error_msg = user_id [len (error_prefix ) :]
273275 return {"status" : "error" , "message" : error_msg }
274276
275277 return {"status" : "success" , "user_id" : user_id }
@@ -336,12 +338,12 @@ def provide_api_key(params: ProvideApiKeyParams) -> dict[str, str]:
336338def execution_context (** kwargs : str ) -> None :
337339 """Temporarily set context values for the current async task."""
338340 # Create a fresh copy per use
339- current = {** server . execution_context_vars .get (), ** kwargs }
340- token = server . execution_context_vars .set (current )
341+ current = {** execution_context_vars .get (), ** kwargs }
342+ token = execution_context_vars .set (current )
341343 try :
342344 yield
343345 finally :
344- server . execution_context_vars .reset (token )
346+ execution_context_vars .reset (token )
345347
346348
347349@server .feature ("cleanupCurrentOptimizerSession" )
0 commit comments