How aigc-open/tender-cli works
1. Repository purpose
Tender CLI is a Python command-line assistant for end-to-end tender/bid document work: analyze source tender files, plan tasks, generate section content, and export a final Word/PDF deliverable. The architecture is centered on a conversational AI orchestrator rather than a traditional CRUD application.
2. Top-level runtime entrypoint
src/tender_cli/main.py is the CLI entry. It likely boots the interactive shell, loads configuration, initializes logging, and hands control to the main AI workflow. From there, the user stays in a conversation loop rather than moving through discrete screens.
3. Core orchestration layer
src/tender_cli/core/tender_ai.py is the main application brain. It coordinates:
- user intent parsing,
- task planning,
- tool invocation,
- progress updates,
- and final response assembly.
This module sits above the rest of the system and acts as the integration point between AI, project state, and MCP tools.
4. Conversation and state management
core/conversation.py manages multi-turn dialog context, so the assistant can remember prior turns and incremental decisions. This is important because the workflow is iterative: analysis leads to planning, planning leads to chapter generation, and later user corrections feed back into the same project state.
5. Project/workspace boundary
core/project_manager.py encapsulates the bid/project lifecycle: creating projects, selecting active projects, managing directory structure, backups, and assembling chapter files into outputs. The repository treats each tender as a workspace with persistent artifacts on disk:
sections, assets, temp files, backups, and final exports.
6. Configuration boundary
core/config.py centralizes configuration loading and precedence. The README shows config coming from environment variables, .env files, YAML config, and interactive setup. This module is the boundary between runtime behavior and deployment-specific settings such as AI provider, model name, API base URL, workspace path, and debug mode.
7. AI integration layer
utils/ai_client.py is the abstraction over the model provider. It connects the assistant to OpenAI-compatible endpoints or custom model servers, using config values from the configuration layer. In the architecture diagram, this is the outbound external dependency for generation and reasoning.
8. Prompt subsystem
prompts/prompt_library.py stores reusable prompt templates for the different phases of the workflow: analysis, outlining, chapter drafting, refinement, and possibly tool-selection behavior. This is a pure application-layer dependency consumed by the orchestrator and AI client, not by the file/document tools directly.
9. MCP tool subsystem
The mcp_tools/ package is the execution layer for concrete operations. It is split into focused tool groups:
- file_tools.py for reading/writing content and directory structure management
- tender_tools.py for tender document parsing and requirement extraction
- content_tools.py for outline and section generation
- document_tools.py for Word/PDF export and formatting
- base.py as the shared tool abstraction
- mcp_server.py as the server-facing registry/dispatcher
- mcp_agent.py for agent-side integration
These tools are the bridge between AI decisions and filesystem/document side effects.
10. Data flow through the system
The main flow is: user command in CLI → TenderAI interprets intent → conversation state updates → prompt is assembled → AI client requests model output → model selects a plan or tool action → MCP tool executes file/document work in the project workspace → results are fed back into the conversation and surfaced to the user. The final output is usually persistent files under the project workspace, not just console text.
11. Document assembly model
The README’s project structure shows a chapter-oriented content model: each third-level heading is a separate markdown file, grouped under section folders. This enables parallel generation and granular editing. The document export layer then merges these modular content files into a single formatted deliverable, typically a .docx in the project output/ directory.
12. External interfaces and deployment assumptions
The system depends on an OpenAI-compatible API endpoint, but the README also allows custom local model endpoints. The project is therefore architecture-agnostic at the model layer: the same AI client can target a hosted API or a self-hosted service as long as it speaks the expected interface.
13. Examples and test surface
examples/ demonstrates the main integration points: basic usage, custom tools, math client/server, and MCP base usage. This suggests the repo is designed to support both internal CLI operation and standalone MCP-style tool experimentation. tests/test_basic.py indicates the test suite is currently lightweight and likely focused on smoke-level validation rather than deep tool integration.
14. What to show in an architecture diagram
A clear diagram should depict:
- the CLI entrypoint,
- the core AI orchestrator,
- configuration and conversation state,
- the AI model endpoint,
- the MCP tool layer split into file/content/tender/document capabilities,
- and the workspace filesystem where projects, chapter files, backups, and exported documents live.
The key architectural boundary is between “reasoning/planning” and “filesystem/document side effects.”
Main entry points: tender_ai.py Tender AI · mcp_server.py MCP Server · project_manager.py Project Manager · file_tools.py File Tools
Components 15
Runtime
CLI entrypoint and interactive application flow
- CLI · Starts the command-line assistant and hands control to the AI workflow
src/tender_cli/main.py
Core
Conversation, configuration, project lifecycle, and orchestration
- Tender AI · Main application brain for intent parsing, planning, tool use, and response assembly
src/tender_cli/core/tender_ai.py - Conversation · Maintains multi-turn context and incremental decisions
src/tender_cli/core/conversation.py - Project Manager · Creates and selects projects, manages directories, backups, and assembled outputs
src/tender_cli/core/project_manager.py - Config · Loads configuration from env, .env, YAML, and interactive setup
src/tender_cli/core/config.py
MCP Tools
Execution layer for file, tender, content, and document actions
- Tool Base · Shared base layer for MCP-style tool definitions and invocation
src/tender_cli/mcp_tools/base.py - MCP Server · Server-facing dispatcher and registry for exposed tools
src/tender_cli/mcp_tools/mcp_server.py - MCP Agent · Agent-side integration for tool execution and coordination
src/tender_cli/mcp_tools/mcp_agent.py - File Tools · Reads, writes, and manages project files and directories
src/tender_cli/mcp_tools/file_tools.py - Tender Tools · Parses tender documents and extracts requirements
src/tender_cli/mcp_tools/tender_tools.py - Content Tools · Generates outlines and section content for tender chapters
src/tender_cli/mcp_tools/content_tools.py - Document Tools · Formats and exports final Word/PDF deliverables
src/tender_cli/mcp_tools/document_tools.py
AI Layer
Model client and prompt templates
Workspace
Persistent project files and exports
- Workspace Files · Persistent tender projects, sections, backups, temp files, and exports
Connections 19
- CLI → Tender AI: bootstraps · CLI hands control to the conversational orchestrator
- Tender AI → Conversation: reads/writes · Maintains turn context and iterative decisions
- Tender AI → Config: loads · Uses runtime settings for model and workspace behavior
- Tender AI → AI Client: calls model · Requests generation and reasoning from the AI endpoint
- Tender AI → Prompts: assembles prompts · Builds phase-specific prompts for analysis and drafting
- Tender AI → MCP Agent: invokes tools · Delegates concrete operations to the MCP execution layer
- Project Manager → Workspace Files: manages · Creates project structure, backups, and output locations
- MCP Agent → MCP Server: dispatches · Routes tool requests through the server registry
- MCP Server → Tool Base: exposes · Uses the shared abstraction for tool definitions
- MCP Server → File Tools: registers · File and directory operations
- MCP Server → Tender Tools: registers · Tender analysis and requirement extraction
- MCP Server → Content Tools: registers · Outline and section drafting
- MCP Server → Document Tools: registers · Word/PDF formatting and export
- File Tools → Workspace Files: reads/writes · Persists chapter files and supporting assets
- Content Tools → Workspace Files: produces · Creates modular section content in the project workspace
- Document Tools → Workspace Files: exports · Assembles final deliverables from workspace artifacts
- Tender Tools → Workspace Files: analyzes · Consumes source tender documents from the project workspace
- Project Manager → File Tools: coordinates · Relies on file operations for workspace lifecycle actions
- Tender AI → Project Manager: orchestrates · Coordinates project selection and artifact lifecycle