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

Method to_backend_config

codewiki/cli/models/config.py:230–277  ·  view source on GitHub ↗

Convert CLI Configuration to Backend Config. This method bridges the gap between persistent user settings (CLI Configuration) and runtime job configuration (Backend Config). Args: repo_path: Path to the repository to document

(self, repo_path: str, output_dir: str, api_key: str, runtime_instructions: AgentInstructions = None)

Source from the content-addressed store, hash-verified

228 prompt_caching=data.get("prompt_caching", True),
229 agent_instructions=agent_instructions,
230 )
231
232 def is_complete(self) -> bool:
233 """Check if all required fields are set.
234
235 Subscription-mode providers (claude-code, codex) only require
236 ``main_model``; ``base_url``, ``cluster_model`` and ``fallback_model``
237 are unused.
238 """
239 from codewiki.src.be.backend import is_caw_provider
240
241 if is_caw_provider(self.provider):
242 return bool(self.main_model)
243 return bool(
244 self.base_url and self.main_model and self.cluster_model and self.fallback_model
245 )
246
247 def to_backend_config(
248 self,
249 repo_path: str,
250 output_dir: str,
251 api_key: str,
252 runtime_instructions: AgentInstructions = None,
253 ):
254 """
255 Convert CLI Configuration to Backend Config.
256
257 This method bridges the gap between persistent user settings (CLI Configuration)
258 and runtime job configuration (Backend Config).
259
260 Args:
261 repo_path: Path to the repository to document
262 output_dir: Output directory for generated documentation
263 api_key: LLM API key (from keyring)
264 runtime_instructions: Runtime agent instructions (override persistent settings)
265
266 Returns:
267 Backend Config instance ready for documentation generation
268 """
269 from codewiki.src.config import Config
270
271 # Merge runtime instructions with persistent settings
272 # Runtime instructions take precedence
273 final_instructions = self.agent_instructions
274 if runtime_instructions and not runtime_instructions.is_empty():
275 final_instructions = AgentInstructions(
276 include_patterns=runtime_instructions.include_patterns
277 or self.agent_instructions.include_patterns,
278 exclude_patterns=runtime_instructions.exclude_patterns
279 or self.agent_instructions.exclude_patterns,
280 focus_modules=runtime_instructions.focus_modules

Callers

nothing calls this directly

Calls 4

to_dictMethod · 0.95
AgentInstructionsClass · 0.85
is_emptyMethod · 0.80
from_cliMethod · 0.80

Tested by

no test coverage detected