Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.19.0
CoderG β Autonomous Multi-Agent Technical Architecture & Documentation Agent
CoderG is an agentic, multi-worker workflow orchestrator designed to analyze software repositories, generate comprehensive course content or developer documentation, and autonomously manage the version control deployment lifecycle.
CoderG is a high-performance, modular AI agentic application designed to process source repositories, generate production-grade technical engineering document architectures, compile modular asset packages, and autonomously manage the deployment life cycle.
Constructed on a foundation of First Principles Thinking and constrained by Ockham's Razor, CoderG divides high-complexity generative operations from structural file modification and remote system mutations. It introduces a strict human-in-the-loop authorization tower to review, authenticate, and commit assets safely.
π― Project Profile
1. Project Scope
The core boundary of CoderG encompasses providing an automated, terminal-isolated development helper that acts as a technical partner and instructor. The application reads codebase contexts, dynamically builds comprehensive learning or deployment documentation frameworks, writes files natively across diverse extensions, provisions remote endpoints, and manages full git versioning pipelines securely.
2. Core Requirements
- Context Token Safety: Must dynamically handle dense repository files without triggering Context Length or Tokens Per Minute (TPM) failures.
- Decoupled Responsibilities: Code execution, file construction, git transportation, and logging must reside in fully decoupled, isolated scripts.
- Visual Progress Feedback: Provide instant, transparent status tracking of ongoing localized mutations using distinct UI presentation techniques.
- Explicit Gatekeeping: No automated generation is allowed to interact with external git platforms without manual credential approval from the workspace tower.
- Destruction Resilience: Must preserve historical artifact records using shadow copies (
_-1) before fresh write events occur.
3. Expected Outcome
A production-ready orchestration workflow tool that cuts code asset production time by automating file creation, organization, and remote repository hosting.
π οΈ Core Tools & Tech-Stack Employed
- Presentation Engine:
Gradio (v5+)β Used for its reactive state mechanics, streaming token interface pipelines, and robust asynchronous event handshaking loops. - Inference Core:
Groq Client SDK(llama-3.1-8b-instant) β Running at zero temperature to guarantee technical predictability and programmatic format compliance. - Transport Driver:
GitPython Framework&Native Git Coreβ Powers local repository instantiation, metadata index additions, and tracking system commits. - Infrastructure Layer:
GitHub REST API v3 Engineβ Automates remote cloud platform discovery, profile querying, and repository initialization on headless systems. - Format Compilation Compilers:
PyYAML,TOML,python-docxβ Decodes plaintext generator responses directly into precise configuration scripts and professional document layouts.
ποΈ Core Architecture Overview
CoderG bypasses monolithic script patterns by delegating tasks across highly specialized micro-agents:
The blueprint maps out the decoupled Manager-Worker design pattern, illustrating presentation layer's controlling specialized modules while piping structural logs to an audit trail
+---------------------------------------+
| app.py (Manager) | <--- Gradio Presentation Control
+---------------------------------------+
|
+------------------------+------------------------+
| | |
v v v
+-----------------------++-----------------------++-----------------------+
| core_logic.py || file_agent.py || git_agent.py |
| (The Brain) || (The Writer) || (The Courier) |
+-----------------------++-----------------------++-----------------------+
| | |
+------------------------+------------------------+
|
v
+---------------------------------------+
| agent_logging.py (Audit) | ---> outputs/agent.log
+---------------------------------------+
π System Flowchart & Interaction Model
The architectural diagram below traces an instruction's path as it travels through CoderG's isolated processing channels:
The flowchart tracks the - Run-time Execution Flow - exact lifecycle of a user request, tracing token streaming, workspace generation, remote repository initialization, and the final zero-footprint directory purge.
[ User Input ]
|
v
+------------+ Streams Text Tokens
| app.py | <-------------------------------------------------------+
+------------+ |
| |
| Invokes Event Processing |
v |
+------------+ Passes Raw Artifacts +---------------+ |
| core_logic | ---------------------------------> | file_agent | ---+
+------------+ +---------------+
| |
| Writes Workspace Files | Creates Backups
v v
+------------+ Executes Remote Push +---------------+
| git_agent | <--------------------------------- | outputs/ |
+------------+ via Control Tower +---------------+
|
+---> [ API Provision Check ] ---> Pushes Assets to Remote GitHub Target
|
v
+------------+
| temp_repo/ | ---> Purges Folder Completely on Termination (Zero Footprint)
+------------+
Module Component Breakdown/Descriptions
app.py(Control Tower / UI Layer): A 3-column asymmetric Gradio interface managing dynamic conversation sessions, asynchronous text streaming execution, state tracking, and explicit telemetry log piping.
- Status: Fully Functional.
- Core Logic: Implements a stable 3-column structural view layout. The left column acts as a persistent dataset navigation engine for conversation histories. The central window coordinates text message rendering. The right panel houses the interactive authorization settings controlling repository creation parameters.
- Key Mechanisms: Orchestrates async
.then()processing chains to cleanly refresh components sequentially while tracking persistent chat identifiers.
core_logic.py(Brain / LLM / Reasoning Engine): Handles user request context routing, applies token-safety cutoff mechanisms, injects system architectures via systemic prompt directives, and calls modern inference pipelines (Groq API).
- Status: Fully Functional.
- Core Logic: Handles file reading, content truncation thresholds (~3000 tokens), system prompt rules, and calls the Groq client platform.
- Key Mechanisms: Slices long conversational histories down to the last 3 active turns to maintain strict token boundaries. Integrates a shadow copying mechanism that copies pre-existing assets into a historical
_-1backup state right before overwriting files.
file_agent.py(Workspace Writer): A localized multi-format parser handling safe disk input/output actions. It automatically isolates content streams and securely compiles data structures into native.md,.txt,.yaml,.toml, or.docxlayouts.
- Status: Fully Functional.
- Core Logic: A script dedicated solely to local file modification. It handles raw text parsing and safely organizes formatting boundaries for distinct output types.
- Key Mechanisms: Maps extension rules dynamically to protect data layout parsing when building structures across text, markdown, configuration tables, or document packages.
git_agent.py(Transport Courier): Performs hybrid automated Git routines. It queries the remote GitHub REST API v3 engine to provision missing public/private code workspaces dynamically under a dedicated robot account, tracks changes, handles file staging, and executes local cleanup routines.
- Status: Fully Functional.
- Core Logic: Encapsulates external remote connections. It polls GitHub endpoints via REST queries, builds missing public repositories under a dedicated robot account profile, handles staging, and commits files.
- Key Mechanisms: Uses explicit
finallycleanup paths to run full directory purges ontemp_repo/, leaving a zero storage footprint inside host containers.
agent_logging.py(System Auditor): A zero-dependency, transactional time-stamped tracker writing every systemic action, error, observation, or confirmation out to a safe operational log file (outputs/agent.log).
- Status: Fully Functional.
- Core Logic: A file utility tracking internal state changes.
- Key Mechanisms: Appends structured, timestamped logs out to
outputs/agent.logto track initialization tasks, file events, or deployment problems.
Worker Module - Detailed Analysis:
- agent_logging.py,
- file_agent.py,
- git_agent.py
The application relies on an isolated Manager-Worker pattern.
app.py sets up the interface, core_logic.py makes strategic architectural decisions, and the Worker Module (agent_logging.py, file_agent.py, git_agent.py) executes the concrete file system and network operations.
Here is exactly how each worker behaves, executes tasks, and intersects with the application core:
- agent_logging.py (The Audit Trail)
Core Function: This script provides unified telemetry and observability for the entire application. It handles raw I/O operations to append formatted structural logs into outputs/agent.log with high-precision timestamps (%Y-%m-%d %H:%M:%S).
Relation to app.py & core_logic.py: It acts as a passive background layer. Rather than interacting with the user interface, it listens to the other agents. Whenever core_logic.py hits an inference issue or a worker finishes a physical action, they call log_agent_action() to register the event.
Detailed Operation:
- Accepts an action_type (e.g., FILE_CREATION, GIT_ERROR) and a detailed message string.
- Proactively checks if the outputs folder exists; if missing, it runs an on-the-fly directory creation. 3. Opens the log file in append mode ("a"), writing the log payload in an explicit format: [TIMESTAMP] [ACTION] Message.
- file_agent.py (The Document Writer)
Core Function: This is your disk serialization worker. It takes raw text tokens or structural payloads generated by your LLM core and turns them into actual physical workspace formats on disk (.md, .txt, .yaml, .toml, .docx).
Relation to app.py & core_logic.py: Once core_logic.py finishes streaming its raw textual architectural insights back to app.py for user presentation, it immediately calls file_agent.write_document(). This saves the generated material locally before any remote actions take place.
Detailed Operation:
- Inspects the file extension of the target file.
- Runs type-safe routing branches:
- For text formats (.md, .txt), it uses standard safe file system streams.
- For configuration files (.yaml, .toml), it evaluates whether the data stream is a string or a dict and runs safe serialization tools (yaml.safe_dump or toml.dump).
- For Microsoft Word structures (.docx), it spawns a clean virtual XML processing model via python-docx.
- Fires a completion signal to agent_logging.py or returns an explicit error string up to the core loop if a permissions block occurs.
- git_agent.py (The Cloud Courier)
Core Function: This is your external networking and synchronization engine. It handles all calls to the remote GitHub REST API and coordinates local Git repository staging tree changes via native GitPython bindings.
Relation to app.py & core_logic.py: This worker is directly wired to the Agentic Control Tower UI panel in app.py. When the human operator clicks Approve & Push to GitHub, app.py bypasses core_logic.py entirely and passes your staged file lists directly into this worker to execute the deployment.
Detailed Operation:
- Reads GITHUB_TOKEN and GITHUB_USERNAME from environment variables, throwing an authentication failure log if missing.
- Remote Provisioning Check: Hits the GitHub API (/repos/{username}/{repo_name}). If it catches a 404 Not Found, it switches to a POST routine to create a new repository under the user account automatically.
- Staging & Sync: Safely spins up a local folder called temp_repo/. It clones the destination repository, copies the staged target assets across from your local staging environment (outputs/), tracks changes (repo.index.add), commits the delta with the custom commit message, and pushes the local state up to the origin remote branch.
- Dynamic Purge (finally block): To ensure zero footprint and prevent disk space buildup, a mandatory shutil.rmtree routine runs at the end of the operation, wiping out the temp_repo/ workspace completely regardless of whether the push succeeded or failed.
In a Gist: When a user interacts with CoderG:
app.py receives the user instruction and kicks off the visual stream.
core_logic.py thinks, researches, generates the documentation strategy, and sends text back to the screen; calls file_agent.py to stage those files into the local outputs/ workspace.
The user clicks approval in the Control Tower, prompting git_agent.py to clone down the repository into a temporary folder, transfer the files over, push them to GitHub, and instantly clean up after itself.
agent_logging.py silently captures every single successful step and edge-case exception along the way to make debugging straightforward.
π οΈ Tech-Stack & Framework Layering
| Core Domain | Technology Component | Purpose |
|---|---|---|
| User Interface | Gradio (v5+) | State persistence, streaming Markdown token rendering, and split control-column configuration. |
| Inference Core | Groq SDK (llama-3.1-8b-instant) |
Ultra-low latency chat completion engine with streaming iterations at zero temperature for predictive consistency. |
| Version Control | GitPython Framework & Native Git Core | Facilitates execution of low-level clone, add, commit, and push actions within local filesystems. |
| Cloud Provisioning | GitHub REST API v3 Engine | Automates remote repository discovery and programmatic user account setup. |
| Structure Storage | PyYAML, TOML, python-docx | Parses plaintext outputs into production configuration files and office-compliant word documents. |
ποΈ Implemented System Configurations
1. The Token-Safe History Slicing Mirror
To circumvent Context Window exhaustion (TPM limits) when processing dense codebases, core_logic.py dynamically intercepts file contexts, applies hard char limits (~3,000 tokens), and strictly slices ongoing history states to keep only the last 3 message turns active during inference.
2. Autonomous Repository Provisioning
The system does not expect target GitHub workspaces to exist in advance. When the deployment button fires, git_agent.py sends a network request to look for the repository profile. If a 404 Not Found returns, it builds the project repository programmatically under the automated account credentials before tracking your files.
3. Historical Version State Backup (_-1 Directive)
To prevent destructive loss of material during active prompt generations, the workspace performs file version tracking. Prior to writing a newly compiled file (e.g., COURSE_README.md), any pre-existing copy inside the workspace folder is replicated and moved to a historical shadow file matching a _-1 naming convention (COURSE_README_-1.md).
4. Zero-Footprint Dynamic Storage Purification
To keep internal host resources, containers, or Hugging Face spaces lean and unbloated by redundant tracking configurations, git_agent.py uses explicit finally execution trees to forcefully execute a deep shutil.rmtree() on temporary clone workspaces (temp_repo/) immediately following successful network pushes.
User-directed Git Repository Control
The Visual Intimation: User notified for Git Repo Management
The system uses two distinct visual indicators on the interface to signal that it has paused and is explicitly awaiting a human decision:
- The Main Chat Status Intercept At the very bottom of the streamed response text in the central chat window, a bold status flag appears:
π€ Silicon Architect:
[Generated content here...]
β
Files successfully generated in localized staging environment.
β Awaiting authorization control panel to push to GitHub.
This is the user's explicit cue. The chat stream stops moving, and the text explicitly tells them that the material has transitioned from a theoretical response to an active, localized artifact awaiting deployment.
- The Control Tower Telemetry Log Concurrently, the right-hand panel (π Deployment Telemetry Logs) changes its state. Instead of its initial generic state, it reflects a holding state:
_Awaiting local environment staging completion..._
The Human-in-the-Loop Operational Flow
Because the application separates Generation (core_logic.py) from Transport (git_agent.py), the workspace naturally freezes in a secure state until a human interacts with it.
[ Step 1: Model Streams Content ]
β
βΌ
[ Step 2: Local File Staged Automatically ]
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β SYSTEM PAUSES & PRINTS INTERCEPT NOTICE β ββββ User sees "Awaiting authorization..."
βββββββββββββββββββββββ¬ββββββββββββββββββββββ
β
Is the user satisfied?
β
ββββββββββββββ΄βββββββββββββ
βΌ βΌ
[ YES ] [ NO ]
β β
User clicks "Approve User types a adjustment
& Push to GitHub" prompt in chat box
β β
βΌ βΌ
`git_agent` executes `core_logic` overwrites
and flushes workspace staging with updated data
In a Gist:
The end-user knows it is time to use the Control Tower because the agent literally concludes its response with an explicit message stating that it is now waiting for their authorization click. If the user is unhappy with the code or document layout on screen, they simply ignore the button, reply with corrections in the chat input, and the agent will overwrite the staged files with the corrected versionsβstarting the approval cycle over again.
π Planned & Strategic Enhancements
Phase 1: Context Capture Optimizations
- Recursive Repository Ingestion Tooling: Replace generic truncations with an iterative script map that traverses subdirectory code layers using structured AST parsing, distilling entire code repositories down to highly accurate technical profiles.
- Intelligent File Template Identification: Teach the system to automatically analyze output patterns. If the LLM generates structure strings starting with
title:or[tool.poetry], the system will bypass standard markdown strings and save them as.yamlor.tomlvariants dynamically.
Phase 2: Workflow Security & Collaboration Controls
- Branch-Based Multi-Staging (PR Workflows): Transition from making forced commits onto primary branches to pushing automated code changes onto a structured sandbox branch (e.g.,
coderg-patch-v1), followed by raising formal GitHub Pull Requests automatically for team audits. - Dynamic Webhook Observability: Set up structural web listeners inside the interface. If an external user changes or commits code changes to the target repository directly from GitHub, CoderG can immediately read the webhook updates and synchronize its localized working directories.
Phase 3: Advanced Diagnostic Monitoring
- Live Telemetry Streams: Upgrade the standard markdown logger block inside the interface
Active Webhook Synchronizer
- Concept: Set up explicit network listener endpoints inside the backend. If an outside team member modifies or changes files on the remote GitHub target branch directly, CoderG will capture the payload notice and immediately update its local data spaces.
Deep Abstract Syntax Tree (AST) Mapping
- Concept: Move past basic text truncation methods. Implement a file processing pipeline that scans target directories, strips out junk text blocks, and uses Python's built-in
astmodule to condense whole repositories down to clear functional maps before prompting the model.
Dynamic Structural Template Matching
- Concept: Upgrade the file compilation engine. Teach
core_logic.pyto identify technical structures programmatically. If an asset block starts with properties like[tool.poetry]orversion:, the agent will bypass generic formatting fallback parameters and write the data directly out under matching.tomlor.yamlfile configurations.
Real-Time Telemetry Streaming
- Concept: Connect a live log viewer component directly onto the Gradio Presentation Tower, streaming changes from
outputs/agent.logto the UI panel so developers can watch background agent tasks unfold live.