MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / clear_dev_command

Function clear_dev_command

server/services/project_config.py:388–430  ·  view source on GitHub ↗

Remove the custom dev command, reverting to auto-detection. If no config file exists or no custom command is set, this function does nothing (no error is raised). Args: project_dir: Path to the project directory. Raises: ValueError: If project_dir is not a val

(project_dir: Path)

Source from the content-addressed store, hash-verified

386
387
388def clear_dev_command(project_dir: Path) -> None:
389 """
390 Remove the custom dev command, reverting to auto-detection.
391
392 If no config file exists or no custom command is set,
393 this function does nothing (no error is raised).
394
395 Args:
396 project_dir: Path to the project directory.
397
398 Raises:
399 ValueError: If project_dir is not a valid directory.
400 """
401 project_dir = _validate_project_dir(project_dir)
402 config_path = _get_config_path(project_dir)
403
404 if not config_path.exists():
405 return
406
407 config = _load_config(project_dir)
408
409 if "dev_command" not in config:
410 return
411
412 del config["dev_command"]
413
414 # If config is now empty, delete the file
415 if not config:
416 try:
417 config_path.unlink(missing_ok=True)
418 logger.info("Removed empty config file for %s", project_dir.name)
419
420 # Also remove .autoforge directory if empty
421 autoforge_dir = config_path.parent
422 if autoforge_dir.exists() and not any(autoforge_dir.iterdir()):
423 autoforge_dir.rmdir()
424 logger.debug("Removed empty .autoforge directory for %s", project_dir.name)
425 except OSError as e:
426 logger.warning("Failed to clean up config for %s: %s", project_dir.name, e)
427 else:
428 _save_config(project_dir, config)
429
430 logger.info("Cleared custom dev command for %s", project_dir.name)
431
432
433def get_project_config(project_dir: Path) -> ProjectConfig:

Callers 1

update_devserver_configFunction · 0.85

Calls 4

_validate_project_dirFunction · 0.85
_get_config_pathFunction · 0.85
_load_configFunction · 0.85
_save_configFunction · 0.85

Tested by

no test coverage detected