MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / config_agent

Function config_agent

codewiki/cli/commands/config.py:737–861  ·  view source on GitHub ↗

Configure default agent instructions for documentation generation. These settings are used as defaults when running 'codewiki generate'. Runtime options (--include, --exclude, etc.) override these defaults. Examples: \b # Set include patterns for C# projects

(
    include: Optional[str],
    exclude: Optional[str],
    focus: Optional[str],
    doc_type: Optional[str],
    instructions: Optional[str],
    clear: bool
)

Source from the content-addressed store, hash-verified

735 """
736 try:
737 click.echo()
738 click.secho("Validating configuration...", fg="blue", bold=True)
739 click.echo()
740
741 manager = ConfigManager()
742
743 # Step 1: Check config file
744 if verbose:
745 click.echo("[1/5] Checking configuration file...")
746 click.echo(f" Path: {manager.config_file_path}")
747
748 if not manager.load():
749 click.secho("✗ Configuration file not found", fg="red")
750 click.echo()
751 click.echo(
752 "Error: Configuration is incomplete. Run 'codewiki config set --help' for setup instructions."
753 )
754 sys.exit(EXIT_CONFIG_ERROR)
755
756 if verbose:
757 click.secho(" ✓ File exists", fg="green")
758 click.secho(" ✓ Valid JSON format", fg="green")
759 else:
760 click.secho("✓ Configuration file exists", fg="green")
761
762 # Load config early so we know the provider for the rest of the checks.
763 config = manager.get_config()
764 from codewiki.src.be.backend import (
765 is_caw_provider,
766 is_google_provider,
767 needs_api_key,
768 needs_base_url,
769 )
770
771 caw_mode = bool(config) and is_caw_provider(config.provider)
772 key_needed = bool(config) and needs_api_key(config.provider)
773 url_needed = bool(config) and needs_base_url(config.provider)
774 api_key = None
775
776 # Step 2: Check API key (skipped for subscription providers and Vertex AI)
777 if verbose:
778 click.echo()
779 click.echo("[2/5] Checking API key...")
780
781 if not key_needed:
782 reason = "subscription mode" if caw_mode else "Google credentials"
783 if verbose:
784 click.secho(f" ✓ API key not required ({reason})", fg="green")
785 else:
786 click.secho(f"✓ API key not required ({reason})", fg="green")
787 else:
788 if verbose:
789 storage = "system keychain" if manager.keyring_available else "encrypted file"
790 click.echo(f" Storage: {storage}")
791
792 api_key = manager.get_api_key()
793 if not api_key:
794 click.secho("✗ API key missing", fg="red")

Callers

nothing calls this directly

Calls 8

loadMethod · 0.95
get_configMethod · 0.95
saveMethod · 0.95
ConfigManagerClass · 0.90
AgentInstructionsClass · 0.90
handle_errorFunction · 0.90
is_emptyMethod · 0.80
parse_patternsFunction · 0.70

Tested by

no test coverage detected