Load organization-level config from ~/.autoforge/config.yaml. Falls back to ~/.autocoder/config.yaml for backward compatibility. Returns: Dict with parsed org config, or None if file doesn't exist or is invalid
()
| 566 | |
| 567 | |
| 568 | def load_org_config() -> Optional[dict]: |
| 569 | """ |
| 570 | Load organization-level config from ~/.autoforge/config.yaml. |
| 571 | |
| 572 | Falls back to ~/.autocoder/config.yaml for backward compatibility. |
| 573 | |
| 574 | Returns: |
| 575 | Dict with parsed org config, or None if file doesn't exist or is invalid |
| 576 | """ |
| 577 | config_path = get_org_config_path() |
| 578 | |
| 579 | if not config_path.exists(): |
| 580 | return None |
| 581 | |
| 582 | try: |
| 583 | with open(config_path, "r", encoding="utf-8") as f: |
| 584 | config = yaml.safe_load(f) |
| 585 | |
| 586 | if not config: |
| 587 | logger.warning(f"Org config at {config_path} is empty") |
| 588 | return None |
| 589 | |
| 590 | # Validate structure |
| 591 | if not isinstance(config, dict): |
| 592 | logger.warning(f"Org config at {config_path} must be a YAML dictionary") |
| 593 | return None |
| 594 | |
| 595 | if "version" not in config: |
| 596 | logger.warning(f"Org config at {config_path} missing required 'version' field") |
| 597 | return None |
| 598 | |
| 599 | # Validate allowed_commands if present |
| 600 | if "allowed_commands" in config: |
| 601 | if not _validate_command_list(config["allowed_commands"], config_path, "allowed_commands"): |
| 602 | return None |
| 603 | |
| 604 | # Validate blocked_commands if present |
| 605 | if "blocked_commands" in config: |
| 606 | blocked = config["blocked_commands"] |
| 607 | if not isinstance(blocked, list): |
| 608 | logger.warning(f"Org config at {config_path}: 'blocked_commands' must be a list") |
| 609 | return None |
| 610 | for i, cmd in enumerate(blocked): |
| 611 | if not isinstance(cmd, str): |
| 612 | logger.warning(f"Org config at {config_path}: blocked_commands[{i}] must be a string") |
| 613 | return None |
| 614 | |
| 615 | # Validate pkill_processes if present |
| 616 | normalized = _validate_pkill_processes(config, config_path) |
| 617 | if normalized is None: |
| 618 | return None |
| 619 | if normalized: |
| 620 | config["pkill_processes"] = normalized |
| 621 | |
| 622 | return config |
| 623 | |
| 624 | except yaml.YAMLError as e: |
| 625 | logger.warning(f"Failed to parse org config at {config_path}: {e}") |