How muhammadtalha-prog/local-multi-agent-code-generator works
Purpose and entry point
This is a local-first CLI that converts a natural-language request into one generated, self-contained Python script. main.py is the executable entry point: it accepts interactive input or --prompt, selects a model/output path, and chooses standard versus fast orchestration.
Supervisor and pipeline control
main.py acts as the supervisor, sequencing agents, handling retry/review iterations, reporting progress, and persisting the final source file. Standard mode flows through interpretation, planning, generation, review, then static validation; --fast bypasses interpretation and planning for direct generation plus checking.
• main.py
• config.py
Prompt interpretation
The Interpreter converts an underspecified user request into a clearer technical specification suitable for downstream agents. This separates ambiguous user-facing input from the structured implementation context consumed by the Planner and Generator.
• agents/interpreter.py
• agents/__init__.py
Planning boundary
The Planner transforms the expanded specification into a stepwise implementation plan. Its output is an intermediate design artifact rather than executable code, enabling the Generator to operate from explicit requirements. Fast mode deliberately omits this stage.
• agents/planner.py
• agents/interpreter.py
Code generation and revision loop
The Generator produces Python source from the task context and plan. In standard mode, it participates in a bounded, multi-turn feedback loop with the Reviewer: review findings are returned with accumulated prior conversation so each revision addresses the complete history, not only the newest critique.
• agents/generator.py
• agents/reviewer.py
• main.py
Validation and output safety boundary
Generated source is statically inspected before being accepted: syntax is validated and imports/dependencies are identified. The system can optionally install missing packages, but does not execute generated code in a sandbox; runtime behavior remains outside the repository’s validation boundary.
• agents/syntax_checker.py
• agents/static_checker.py
• main.py
Runtime and external service
The application is a Python CLI running locally. LLM inference is delegated to a locally running Ollama service, accessed through a centralized client layer; the default intended model is a small local coder model. Configuration centralizes model/runtime defaults, while logging supports terminal-visible agent progress and diagnostics.
• utils/llm_client.py
• config.py
• utils/logger.py
Main entry points: main.py CLI supervisor · generator.py Generator · llm_client.py LLM client · interpreter.py Interpreter
Components 13
CLI Control
Local orchestration and output handling.
- User request
- CLI supervisor · Selects standard or fast orchestration and persists accepted source.
main.py - Generated Python script · One self-contained source file.
Agent Pipeline
Prompt-to-code stages.
- Interpreter · Expands ambiguous requests into a technical specification.
agents/interpreter.py - Planner · Produces a stepwise implementation plan.
agents/planner.py - Generator · Produces and revises Python source.
agents/generator.py - Reviewer · Returns critiques for bounded revision iterations.
agents/reviewer.py
Static Validation
Pre-acceptance source checks.
- Syntax checker · Validates generated source syntax.
agents/syntax_checker.py - Static checker · Identifies imports and dependencies.
agents/static_checker.py
Local Runtime
Shared local model and diagnostics services.
- Runtime configuration · Centralizes model and runtime defaults.
config.py - Progress logging
utils/logger.py - LLM client · Centralized access to local inference.
utils/llm_client.py - Ollama service · Runs the selected local coder model.
Connections 19
- User request → CLI supervisor: interactive input or --prompt
- Runtime configuration → CLI supervisor: defaults
- CLI supervisor → Progress logging: progress and diagnostics
- CLI supervisor → Interpreter: standard mode
- Interpreter → Planner: technical specification
- Planner → Generator: implementation plan
- CLI supervisor → Generator: fast mode: direct request
- Generator → Reviewer: generated source
- Reviewer → Generator: accumulated review feedback
- Generator → Syntax checker: candidate source
- Syntax checker → Static checker: syntax-valid source
- Static checker → CLI supervisor: validation result and dependencies
- CLI supervisor → Generated Python script: persist accepted source
- Interpreter → LLM client: inference
- Planner → LLM client: inference
- Generator → LLM client: inference
- Reviewer → LLM client: inference
- Runtime configuration → LLM client: model defaults
- LLM client → Ollama service: local model requests