agentleFS
PleasePromptoPleasePrompto/ductor/AGENTS.md

ductor

AGENTS.md457 starsChanged 9 months agoMITView on GitHub

This file gives coding agents a current map of the repository. ductor is a multi-transport chat orchestrator for the official provider CLIs (claude, codex, gemini, agy, grok). It runs Telegram and/or Matrix, can expose an optional direct WebSocket API, keeps state under ~/.ductor, and supervises the main agent plus optional sub-agents in one asyncio process. Background and async delivery:

  • Reads credentials
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All run as in-process asyncio tasks:

    line 103
  2. Distinctive:

    update observer (upgradeable installs)

    line 117

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

This file gives coding agents a current map of the repository.

Project Overview

ductor is a multi-transport chat orchestrator for the official provider CLIs (claude, codex, gemini, agy, grok). It runs Telegram and/or Matrix, can expose an optional direct WebSocket API, keeps state under ~/.ductor, and supervises the main agent plus optional sub-agents in one asyncio process.

Stack:

  • Python 3.11+
  • aiogram 3.x (Telegram)
  • matrix-nio (Matrix, optional extra)
  • aiohttp (webhook server, internal API, optional direct API)
  • Pydantic 2.x
  • asyncio

Development Commands

# Setup
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

# Run
ductor
ductor -v

# Tests
pytest
pytest -k "pattern"

# Quality
ruff format .
ruff check .
mypy ductor_bot

Runtime Flow

Telegram:
  Update -> AuthMiddleware -> SequentialMiddleware -> TelegramBot
  -> Orchestrator -> CLIService -> provider subprocess -> Telegram delivery

Matrix:
  sync event -> MatrixBot auth/room checks -> Orchestrator
  -> CLIService -> provider subprocess -> Matrix delivery

API (optional):
  /ws auth (token + e2e_pk + optional chat_id/channel_id)
  -> encrypted frames -> Orchestrator streaming -> encrypted result events

Background and async delivery:

Observer / TaskHub / InterAgentBus callback
  -> bus.adapters -> Envelope -> MessageBus
  -> optional shared lock + optional session injection
  -> registered transport adapters (TelegramTransport / MatrixTransport)

Module Map

ModulePurpose
cli_commands/CLI command implementations (service, docker, api, agents, lifecycle, install, status)
messenger/transport protocol, capabilities, notifications, registry, multi-transport adapter
messenger/telegram/Telegram transport: middleware, handlers, startup, callback routing, file/media UX
messenger/matrix/Matrix transport: sync loop, auth, segment streaming, reaction buttons, media
orchestrator/command routing, directives/hooks, flows, provider/session/task wiring, lifecycle split
bus/unified Envelope, MessageBus, shared LockPool, delivery adapters
cli/provider wrappers, stream parsing, auth detection, model caches, process registry
session/SessionKey(transport, chat_id, topic_id), provider-isolated session buckets, named sessions
tasks/delegated background task runtime (TaskHub) and persistent registry
background/named background session execution for /session
multiagent/supervisor, inter-agent bus, internal localhost API bridge, shared knowledge sync
api/optional direct WebSocket API and authenticated file endpoints
cron/, webhook/, heartbeat/, cleanup/in-process automation observers
workspace/~/.ductor path model, seeding, rule deployment/sync, skill sync
infra/PID lock, service backends, Docker manager, restart/update/recovery helpers
files/, security/, text/shared file/path safety, prompt safety, formatting helpers

Key Runtime Patterns

  • DuctorPaths in workspace/paths.py is the single source of truth for runtime paths.
  • Session identity is SessionKey(transport, chat_id, topic_id) across Telegram chats/topics, Matrix rooms (mapped int), and API channel isolation.
  • /new resets the configured default-provider bucket for the active session key.
  • /reset resets the currently active provider bucket for the active session key.
  • MessageBus is the single async delivery path for observers, task callbacks, webhook wake results, and async inter-agent responses.
  • Telegram ingress and MessageBus share one LockPool; ApiServer currently uses its own lock pool.
  • Workspace init is zone-based:
    • Zone 2 overwrite: CLAUDE.md, AGENTS.md, GEMINI.md, framework-managed tool scripts
    • Zone 3 seed-once: user-owned files
  • Rule sync is mtime-based for sibling CLAUDE.md / AGENTS.md / GEMINI.md; cron task folders additionally get missing rule backfill.
  • Skill sync spans ~/.ductor/workspace/skills, ~/.claude/skills, ~/.codex/skills, ~/.gemini/skills, ~/.grok/skills:
    • normal mode: links/junctions
    • Docker mode: managed copies (.ductor_managed)
  • ductor agents add is a Telegram-focused scaffold; Matrix sub-agents are supported through agents.json or the bundled agent tool scripts.

Background Systems

All run as in-process asyncio tasks:

  • BackgroundObserver (named sessions)
  • CronObserver
  • WebhookObserver
  • HeartbeatObserver
  • CleanupObserver
  • CodexCacheObserver
  • GeminiCacheObserver
  • AntigravityCacheObserver
  • GrokCacheObserver
  • config reloader
  • rule sync watcher
  • skill sync watcher
  • update observer (upgradeable installs)

The four model-cache observers start only for provider CLIs found by startup auth detection (installed_providers), not by a plain PATH lookup.

Service Backends

Platform dispatch lives in infra/service.py:

  • Linux: systemd user service (infra/service_linux.py)
  • macOS: launchd Launch Agent (infra/service_macos.py)
  • Windows: Task Scheduler (infra/service_windows.py)

Operational notes:

  • onboarding offers service install when a backend is available
  • stop_bot() stops the installed service first so it does not immediately respawn the process
  • ductor service logs behavior:
    • Linux: journalctl --user -u ductor -f
    • macOS/Windows: recent lines from ~/.ductor/logs/agent.log (fallback newest *.log)

CLI Surface

Core:

  • ductor, ductor onboarding, ductor reset
  • ductor status, ductor stop, ductor restart, ductor upgrade, ductor uninstall

Groups:

  • ductor service <install|status|start|stop|logs|uninstall>
  • ductor docker <rebuild|enable|disable|mount|unmount|mounts|extras|extras-add|extras-remove>
  • ductor api <enable|disable>
  • ductor agents <list|add|remove>
  • ductor install <matrix|slack|api>

Nuances:

  • ductor agents add interactively scaffolds Telegram sub-agents only
  • Matrix sub-agents are still first-class at runtime; define them in agents.json or via the bundled agent tools

Key Data Files (~/.ductor)

  • config/config.json
  • .env
  • sessions.json
  • named_sessions.json
  • tasks.json
  • cron_jobs.json
  • webhooks.json
  • agents.json
  • startup_state.json
  • inflight_turns.json
  • chat_activity.json
  • SHAREDMEMORY.md
  • logs/agent.log
  • workspace/

Conventions

  • asyncio_mode = "auto" in tests
  • line length 100
  • mypy strict mode
  • ruff strict lint profile
  • config deep-merge adds new defaults without dropping user keys
  • supervisor restart code is 42

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.