This document provides detailed reference documentation for all CogSol command-line interface (CLI) commands.
CogSol provides two CLI entry points:
Global command available after installing the package. Used for creating new projects.
cogsol-admin <command> [options]Project-specific script generated in each CogSol project. Used for all project operations.
python manage.py <command> [options]# List available commands
cogsol-admin
# Get help for a specific command
python manage.py <command> --helpCreate a new CogSol project with the standard directory structure.
cogsol-admin startproject <name> [directory]| Argument | Required | Description |
|---|---|---|
name |
Yes | Project name (used in settings and documentation) |
directory |
No | Target directory. Defaults to <name>/ in current directory |
<project-name>/
├── manage.py # Project CLI entry point
├── settings.py # Project configuration
├── README.md # Project documentation
├── .env.example # Environment template
├── agents/ # Agents application
│ ├── __init__.py
│ ├── tools.py # Shared tool definitions
│ ├── searches.py # Retrieval tool definitions
│ └── migrations/
│ └── __init__.py
└── data/ # Data application
├── __init__.py
├── formatters.py # Reference formatter definitions
├── ingestion.py # Ingestion configuration definitions
├── retrievals.py # Retrieval configuration definitions
└── migrations/
└── __init__.py
#!/usr/bin/env python
import sys
from pathlib import Path
from cogsol.core.management import execute_from_command_line
def main():
project_path = Path(__file__).resolve().parent
execute_from_command_line(sys.argv, project_path=project_path)
if __name__ == "__main__":
main()from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent
PROJECT_NAME = "<project-name>"
AGENTS_APP = "agents"Contains a commented ExampleTool class demonstrating proper tool implementation.
Contains a commented example retrieval tool definition.
Contains commented examples of reference formatters.
Contains commented examples of ingestion configs.
Contains commented examples of retrieval configurations.
Stores configuration variables for CogSol credentials.
# Create project in new directory
cogsol-admin startproject myassistants
# Create project in specific location
cogsol-admin startproject myassistants /path/to/projects/my-ai| Error | Cause | Solution |
|---|---|---|
| "Destination is not empty" | Target directory contains files | Choose different directory or empty it |
Create a new agent package with all required files.
python manage.py startagent <name> [app]| Argument | Required | Default | Description |
|---|---|---|---|
name |
Yes | - | Agent class name (e.g., SalesAgent, Support) |
app |
No | agents |
Application directory name |
agents/<slug>/
├── __init__.py # Exports agent class
├── agent.py # Main agent definition
├── faqs.py # FAQ definitions
├── fixed.py # Fixed response definitions
├── lessons.py # Lesson definitions
└── prompts/
└── <slug>.md # System prompt template
The command processes the agent name:
- Class Name: Ensures name ends with
Agent(e.g.,Sales→SalesAgent) - Slug: Converts to lowercase with underscores (e.g.,
SalesAgent→salesagent)
from cogsol.agents import BaseAgent, genconfigs
from cogsol.prompts import Prompts
from ..tools import ExampleTool
class SalesAgent(BaseAgent):
system_prompt = Prompts.load("salesagent.md")
generation_config = genconfigs.QA()
tools = [ExampleTool()]
max_responses = 5
max_msg_length = 2048
max_consecutive_tool_calls = 3
temperature = 0.3
class Meta:
name = "SalesAgent"
chat_name = "SalesAgent Chat"from cogsol.tools import BaseFAQ
#
# class GreetingFAQ(BaseFAQ):
# question = "How do I start?"
# answer = "Just type your question and I'll help you."from cogsol.tools import BaseFixedResponse
#
# class FallbackFixed(BaseFixedResponse):
# key = "fallback"
# response = "I'm here to help! Could you rephrase that?"from cogsol.tools import BaseLesson
#
# class ContextLesson(BaseLesson):
# name = "Context"
# content = "Keep responses concise and focused on the user's request."
# context_of_application = "general"You are SalesAgent, a helpful agent. Answer clearly and concisely.# Create with auto-suffix
python manage.py startagent Sales # Creates SalesAgent
# Create with explicit name
python manage.py startagent CustomerSupport # Creates CustomerSupportAgent
# Create in custom app
python manage.py startagent Sales assistants- Skips existing files (does not overwrite)
- Creates directory structure automatically
- Imports
ExampleToolfromtools.py(uncomment the example tool or replace the import) - FAQs, fixed responses, and lessons are commented examples by default
Create a new topic folder under data/ for organizing documents.
python manage.py starttopic <name> [--path <parent-path>]| Argument | Required | Default | Description |
|---|---|---|---|
name |
Yes | - | Topic name (used as folder name) |
--path |
No | - | Parent path for nested topics |
data/<topic>/
├── __init__.py # Topic class definition
└── metadata.py # Metadata configuration definitions
Topic names must:
- Start with a letter or underscore
- Contain only letters, numbers, and underscores
- Be valid Python identifiers
from cogsol.content import BaseTopic
class DocumentationTopic(BaseTopic):
"""Topic node for organizing documentation documents."""
name = "documentation"
class Meta:
description = "documentation topic - add a description here."from cogsol.content import BaseMetadataConfig, MetadataType
# Define metadata configurations for this topic.
# Example:
#
# class CategoryMetadata(BaseMetadataConfig):
# name = "category"
# type = MetadataType.STRING
# possible_values = ["General", "Technical", "FAQ"]
# filtrable = True
# required = False
# # If required is True, default_value must be set.
# # default_value = "General"# Create a root topic
python manage.py starttopic documentation
# Create nested topics
python manage.py starttopic tutorials --path documentation
# Creates: data/documentation/tutorials/
python manage.py starttopic advanced --path documentation/tutorials
# Creates: data/documentation/tutorials/advanced/- Parent path must exist before creating nested topics
- Topics map to Nodes in the Content API
- Run
makemigrations dataandmigrate dataafter creating topics
Generate migration files based on changes to agent, tool, and topic definitions.
python manage.py makemigrations [app] [--name <suffix>]| Argument | Required | Default | Description |
|---|---|---|---|
app |
No | - | Application to scan for changes (agents or data, omitted runs both) |
--name |
No | Auto-generated | Custom migration name suffix |
- Load Previous State: Replay all existing migrations to compute state
- Collect Current Definitions: Import and introspect project modules
- Compute Diff: Compare states to identify changes
- Generate Migration: Create Python file with operations
<number>_<name>.py
- number: 4-digit sequential (e.g.,
0001,0002) - name: User-provided or auto-generated (e.g.,
initial,auto_20240115_1030)
# Generated by CogSol 0.2.1 on 2026-01-08 10:30
from cogsol.db import migrations
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateAgent(name='SalesAgent', fields={
'system_prompt': 'You are a helpful sales assistant.',
'temperature': 0.3,
'generation_config': 'QA',
'tools': ['ExampleTool'],
'faqs': [...],
'fixed_responses': [...],
'lessons': [...],
}, meta={
'name': 'SalesAgent',
'chat_name': 'Sales Agent Chat',
}),
migrations.CreateTool(name='ExampleTool', fields={
'name': 'ExampleTool',
'description': 'Demo tool that echoes the provided text.',
'parameters': {
'text': {'description': 'Text to echo', 'type': 'string', 'required': True},
'count': {'description': 'Times to repeat', 'type': 'integer', 'required': False},
},
'__code__': '...',
}),
]# Generate with auto-name
python manage.py makemigrations
# Generate with custom name
python manage.py makemigrations --name add_sales_tools
# Generate for specific app
python manage.py makemigrations myapp --name initialApply pending migrations and synchronize with the remote CogSol API.
python manage.py migrate [app]| Argument | Required | Default | Description |
|---|---|---|---|
app |
No | - | Application to migrate (agents or data, omitted runs both) |
COGSOL_API_KEY=your-api-key
COGSOL_AUTH_CLIENT_ID=your-client-id
COGSOL_AUTH_SECRET=your-client-secret- Load Applied: Read
.applied.jsonto find already-applied migrations - Find Pending: Compare with migration files to find new ones
- Apply Operations: Execute migration operations to build state
- Sync with API: Push definitions to remote CogSol API
- Update Tracking: Write
.state.jsonand.applied.json
For each entity type, the command performs upserts:
| Entity | API Endpoint | Operation |
|---|---|---|
| Tools | POST/PUT /tools/scripts/ |
Create or update script |
| Retrieval Tools | POST/PUT /tools/retrievals/ |
Create or update retrieval tool |
| Agents | POST/PUT /assistants/ |
Create or update assistant |
| FAQs | POST/PUT /assistants/{id}/common_questions/ |
Create or update FAQ |
| Fixed Responses | POST/PUT /assistants/{id}/fixed_questions/ |
Create or update fixed |
| Lessons | POST/PUT /assistants/{id}/lessons/ |
Create or update lesson |
For the data app, the command syncs with the Content API:
| Entity | API Endpoint | Operation |
|---|---|---|
| Topics | POST/PUT /nodes/ |
Create or update node |
| Metadata Configs | POST/PUT /nodes/{id}/metadata_configs/ |
Create or update config |
| Reference Formatters | POST/PUT /reference_formatters/ |
Create or update formatter |
| Ingestion Configs | POST/PUT /ingestion-configs/ |
Create or update ingestion config |
| Retrievals | POST/PUT /retrievals/ |
Create or update retrieval |
If API sync fails, the command attempts to rollback:
- Delete newly created resources (in reverse order)
- Return error exit code
- State files remain unchanged
Tracks applied migrations:
["0001_initial", "0002_add_tool"]Stores state and remote ID mappings:
{
"state": {...},
"remote": {
"agents": {"SalesAgent": 42},
"tools": {"ExampleTool": 15}
}
}# Apply all pending migrations
python manage.py migrate
# Apply for specific app
python manage.py migrate agents
# Apply data migrations (Content API)
python manage.py migrate data| Message | Meaning |
|---|---|
| "No migrations folder found" | Create migrations first |
| "No migrations to apply" | All migrations applied |
| "No pending migrations" | Already up to date |
| "Applying agents.0002..." | Processing migration |
| "Applied N migration(s) and synced" | Success |
| "API error while applying..." | Remote sync failed |
Upload documents to a topic in the Content API.
python manage.py ingest <topic> <files...> [options]| Argument | Required | Default | Description |
|---|---|---|---|
topic |
Yes | - | Topic path (e.g., docs or parent/child) |
files |
Yes | - | Files, directories, or glob patterns |
Use slash-separated paths for nested topics during ingestion (for example:
documentation/tutorials). For a topic-aligned workflow, place files under
data/<topic-path>/ and ingest from that matching path (for example:
./data/documentation/*.pdf and ./data/documentation/tutorials/*.pdf).
| Option | Default | Description |
|---|---|---|
--doc-type |
Text Document |
Document type string |
--ingestion-config |
- | Name of ingestion config from data/ingestion.py |
--pdf-mode |
both |
PDF parsing: manual, OpenAI, both, ocr, ocr_openai |
--chunking |
langchain |
Chunking: langchain, ingestor |
--max-size-block |
1500 |
Maximum characters per block |
--chunk-overlap |
0 |
Overlap between blocks |
--separators |
- | Comma-separated chunk separators |
--ocr |
- | Enable OCR parsing |
--additional-prompt-instructions |
- | Extra parsing instructions |
--assign-paths-as-metadata |
- | Assign file paths as metadata |
--dry-run |
- | Preview without uploading |
.pdf, .docx, .doc, .txt, .md, .html, .htm,
.pptx, .ppt, .xlsx, .xls, .csv, .json, .xml
Define reusable configurations in data/ingestion.py:
from cogsol.content import BaseIngestionConfig, PDFParsingMode, ChunkingMode
class HighQualityConfig(BaseIngestionConfig):
name = "high_quality"
pdf_parsing_mode = PDFParsingMode.OCR
chunking_mode = ChunkingMode.AGENTIC_SPLITTER
max_size_block = 2000
chunk_overlap = 100Then use with:
python manage.py ingest documentation ./data/documentation/ --ingestion-config high_quality# Ingest all PDFs in a directory
python manage.py ingest documentation ./data/documentation/*.pdf
# Ingest into a child topic using parent/child path
python manage.py ingest documentation/tutorials ./data/documentation/tutorials/*.pdf
# Ingest an entire directory recursively
python manage.py ingest documentation ./data/documentation/
# Use custom settings
python manage.py ingest documentation ./data/documentation/reports/ \
--doc-type "Text Document" \
--pdf-mode ocr \
--chunking ingestor \
--max-size-block 2000
# Preview what would be ingested
python manage.py ingest documentation ./data/documentation/ --dry-run| Message | Meaning |
|---|---|
| "Found N file(s) to ingest" | Files detected |
| "OK filename -> document_id=X" | Upload successful |
| "ERR filename: error" | Upload failed |
| "Topic 'X' not found" | Topic not migrated |
List topics from the API or local definitions.
python manage.py topics [options]| Option | Description |
|---|---|
--local |
Show topics from local data/ definitions |
--sync-status |
Compare local definitions with API state |
# List topics from API
python manage.py topics
# List local topic definitions
python manage.py topics --local
# Show sync status
python manage.py topics --sync-statusTopics from API:
documentation (id=1)
└── tutorials (id=2)
└── reference (id=3)
faq (id=4)
Import an existing assistant from the remote CogSol API into local code.
python manage.py importagent <assistant_id> [app]| Argument | Required | Default | Description |
|---|---|---|---|
assistant_id |
Yes | - | Remote assistant ID (integer) |
app |
No | agents |
Target application |
COGSOL_API_BASE=https://apis-imp.cogsol.ai/cognitive # Required
COGSOL_API_KEY=your-api-key # Optional
COGSOL_CONTENT_API_BASE=https://apis-imp.cogsol.ai/content # Required if importing retrievals| Remote Resource | Local Destination |
|---|---|
| Assistant config | <slug>/agent.py |
| System prompt | <slug>/prompts/<slug>.md |
| Script tools | tools.py (appended) |
| Retrieval tools | searches.py (appended) |
| FAQs | <slug>/faqs.py |
| Fixed responses | <slug>/fixed.py |
| Lessons | <slug>/lessons.py |
| Content topics + metadata | data/<topic>/__init__.py + data/<topic>/metadata.py |
| Content retrievals | data/retrievals.py (appended) |
| Reference formatters | data/formatters.py (appended) |
| Data migration state | data/migrations/.state.json + migration file |
The command transforms API-style code to class-based code:
API Style (remote):
text = params.get('text')
response = text.upper()Class Style (local):
class EchoTool(BaseTool):
@tool_params(text={"description": "Text", "type": "string", "required": True})
def run(self, chat=None, data=None, secrets=None, log=None, text: str = ""):
response = text.upper()
return response# Import assistant #42
python manage.py importagent 42
# Import into custom app
python manage.py importagent 42 myagentsImported assistant 42 as CustomerSupportAgent in agents/customer_support
The command also creates a migration marking the import as applied, preventing duplicate creation on next migrate. When retrievals or topics are imported, a data migration is created and marked applied as well.
Start an interactive chat session with a deployed agent.
python manage.py chat --agent <identifier> [app]| Argument | Required | Default | Description |
|---|---|---|---|
--agent |
Yes | - | Agent name or remote ID |
app |
No | agents |
Application name |
COGSOL_API_BASE=https://apis-imp.cogsol.ai/cognitive # Required
COGSOL_API_KEY=your-api-key # OptionalThe --agent value is resolved in order:
- Numeric ID: Used directly as remote assistant ID
- Class Name: Looked up in
.state.jsonremote mappings
The command provides a styled terminal interface:
██████╗ ██████╗ ██████╗ ███████╗ ██████╗ ██╗
██╔════╝██╔═══██╗██╔════╝ ██╔════╝██╔═══██╗██║
██║ ██║ ██║██║ ███╗███████╗██║ ██║██║
██║ ██║ ██║██║ ██║╚════██║██║ ██║██║
╚██████╗╚██████╔╝╚██████╔╝███████║╚██████╔╝███████╗
╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🤖 Agent: SalesAgent #42
📅 January 15, 2024 • 10:30
╭─────────────────────────────────────────╮
│ Commands: │
│ /exit or Ctrl+C → Quit chat │
│ /new → Start a new chat │
╰─────────────────────────────────────────╯
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭─ Message
╰─▶
| Command | Aliases | Description |
|---|---|---|
/exit |
exit, quit, :q, Ctrl+C |
End chat session |
/new |
new, /restart, /reset |
Start new conversation |
- User messages: Right-aligned cyan bubbles
- AI messages: Left-aligned green bubbles with robot emoji
- Timestamps: Shown below each message
# Chat by agent name
python manage.py chat --agent SalesAgent
# Chat by remote ID
python manage.py chat --agent 42
# Chat with custom app
python manage.py chat --agent Support assistantsAll commands return standard exit codes:
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Error (check output for details) |
# Wrong
cogsol-admin
# Right
cogsol-admin startproject myprojectEnsure you're in a directory with manage.py:
cd myproject
python manage.py makemigrationsCreate or update your .env file:
echo "COGSOL_API_BASE=https://apis-imp.cogsol.ai/cognitive" >> .env- Run
migratefirst to sync and get remote IDs - Check
.state.jsonfor the correct agent name - Use the numeric ID directly:
--agent 42
Check for Python syntax errors in your agent/tool code:
python -c "from agents.myagent.agent import *"Add or update your API Key:
COGSOL_API_KEY=your-valid-api-keyIf it doesn't work and you have the token auth configured, check if your credentials are valid.
- Check state files: Look at
agents/migrations/.state.jsonfor current mappings - Review migrations: Open
agents/migrations/*.pyto see generated operations - Test imports: Verify your code imports correctly before making migrations
- API connectivity: Test with
curl $COGSOL_API_BASE/health