agentleFS
kagan-shkagan-sh/kagan-legacy/AGENTS.md

kagan-legacy

AGENTS.md106 starsChanged 9 months agoMITArchived repositoryView on GitHub

Generated: 2026-03-13 Commit: ddf5c5f Branch: feat/remote-clients Kagan — AI-powered Kanban TUI (Python 3.12+/Textual) that orchestrates coding agents on your codebase. Supports 14 agent backends, auto/pair execution modes, MCP protocol, and a bundled web dashboard (React 19).

  • 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

Show its rules and text

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

14 rules. About 0 are common, 1 is distinctive, and 13 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 13

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    DB access: Always via _db_sync/_db_async helpers wrapping SQLModel sessions

    line 60
  2. Very specific:

    Error hierarchy: All errors inherit KaganError (see core/errors.py)

    line 63
  3. Distinctive:

    Type annotations: All public functions typed.

    line 66
  4. Very specific:

    NEVER: add direct SQLAlchemy session usage — always use _db_sync/_db_async

    line 89
  5. Very specific:

    NEVER: import from _-prefixed modules outside their parent package

    line 90
  6. Very specific:

    DO NOT: use stdlib logging — use loguru

    line 92
  7. Very specific:

    DO NOT: put test fixtures in test files — use tests/helpers/

    line 93
  8. Very specific:

    DO NOT: write task.status = X outside a _db_sync/_db_async callback or the files listed above — use transition_task instead

    line 94
  9. Very specific:

    DO NOT: use /api/chat/sessions/{id}/watch or /messages?after_id= — these were removed in W9a cleanup.

    line 95
  10. Very specific:

    DO NOT: write task.status or session.status directly in EventLog frame producers — frames are supplementary.

    line 96
  11. Very specific:

    Do not bypass apiClient; keep HTTP calls centralized in src/lib/api/client.ts.

    line 160
  12. Very specific:

    Do not add global styles outside src/app.css.

    line 161
  13. Very specific:

    Use @/ path alias for imports (maps to src/).

    line 162
  14. Very specific:

    All HTTP calls go through KaganClient — no raw fetch in providers.

    line 169

≈ “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

PROJECT KNOWLEDGE BASE

Generated: 2026-03-13 Commit: ddf5c5f Branch: feat/remote-clients

OVERVIEW

Kagan — AI-powered Kanban TUI (Python 3.12+/Textual) that orchestrates coding agents on your codebase. Supports 14 agent backends, auto/pair execution modes, MCP protocol, and a bundled web dashboard (React 19).

STRUCTURE

kagan/
├── src/kagan/           # Python package (core logic, TUI, CLI, MCP, server)
│   ├── core/            # Domain: DB, models, agents, tasks, sessions, worktrees
│   ├── tui/             # Textual TUI: screens/, widgets/, styles/
│   ├── cli/             # Click CLI surface (entrypoint: `kagan`/`kg`)
│   ├── mcp/             # MCP server: toolsets/, prompts, resources
│   ├── server/          # HTTP server: REST API, SSE streaming, auth, web UI
│   ├── chat/            # CLI chat REPL: ACP streaming, commands, sessions
│   ├── crypto/          # X25519 key exchange, TLS, tokens, QR
│   ├── wire/            # (compat shim) Re-exports envelope types
│   └── integrations/    # Typed native integrations (GitHub, future: Jira/Linear)
├── packages/
│   ├── vscode/          # VS Code extension: chat participant, tree view, SCM, reviews
│   ├── web/             # React 19 + jotai + Tailwind CSS 4 web dashboard (SPA)
│   └── wire/            # (removed — TS types now generated from response models)
├── tests/               # pytest: core/, tui/, mcp/, server/, unit/, helpers/
├── scripts/             # Build/quality scripts (LOC budget, web build)
├── docs/                # MkDocs documentation site
├── registry/            # Persona repo whitelist
└── references/          # External reference repos (NOT part of build)

WHERE TO LOOK

TaskLocationNotes
Add CLI commandsrc/kagan/cli/Click group in main.py, lazy-loaded modules
Add MCP toolsrc/kagan/mcp/toolsets/One file per domain, use get_context()
Add TUI screensrc/kagan/tui/screens/Register in app.py SCREENS dict
Add TUI widgetsrc/kagan/tui/widgets/Follow Textual compose pattern
Modify task lifecyclesrc/kagan/core/_transitions.pyState machine for task status
Add agent backendsrc/kagan/core/_agent.pyAGENT_BACKENDS registry dict
Add DB migrationalembic -c alembic.ini revision --autogenerate -m "msg"Via poe db-migration-generate
Wire protocol changesrc/kagan/server/responses.pyResponse models → JSON Schema → TypeScript via scripts/generate_wire_types.py
Add SSE event channelsrc/kagan/server/_event_routes.pyRegister route + hook into register_event_routes(mcp) in server.py
Add frame consumersrc/kagan/tui/_event_source.py / packages/web/src/lib/hooks/use-entry-stream.ts / packages/vscode/src/api/event-source.tsTUI: implement InProcEventSource/HttpEventSource interface; Web: use useEntryStream; VS Code: use KaganEventSource
Web UI featurepackages/web/src/React 19 + jotai + Tailwind CSS 4
API endpointsrc/kagan/server/_routes.pyStarlette routes via FastMCP
Add integrationsrc/kagan/core/integrations/Implement Integration protocol, register in all_enabled()
VS Code featurepackages/vscode/src/providers/One provider per VS Code API surface
VS Code commandpackages/vscode/src/commands/Register in extension.ts
Modify prompt systemsrc/kagan/core/_prompts.pyThree-layer resolution: dotfile → defaults + behavioral → additional instructions

CONVENTIONS

  • Private modules: Underscore prefix (_tasks.py, _agent.py) = internal; client.py, models.py, enums.py = public API
  • DB access: Always via _db_sync/_db_async helpers wrapping SQLModel sessions
  • Async pattern: asyncio.to_thread for DB ops, native async for I/O
  • Logging: loguru.logger everywhere (not stdlib logging)
  • Error hierarchy: All errors inherit KaganError (see core/errors.py)
  • LOC budget: 2500 lines max per Python file (enforced via poe check-loc)
  • Complexity cap: McCabe max-complexity = 20 (ruff C90)
  • Type annotations: All public functions typed; pyrefly for typechecking (not mypy)
  • MCP annotations: TC001/TC002/TC003 suppressed in src/kagan/mcp/ — MCP evaluates annotations at runtime
  • Prompt resolution: Three-layer pipeline in core/_prompts.py — dotfile override → code defaults + behavioral settings → additional instructions
  • Settings keys: Behavioral controls (default_execution_mode, review_strictness, planning_depth, auto_confirm_single_tasks) + single additional_instructions field

Status mutations

task.status and session.status may only be written through kagan.core.transitions.transition_task and transition_session. Direct assignments (task.status = ...) bypass review gates and are forbidden in external-facing code paths (REST routes, MCP tools, CLI commands). The funnel functions enforce the (from, to) matrix at runtime; if you encounter a transition the matrix does not cover, add a match arm with the appropriate guard rather than working around the funnel.

Exceptions: raw DB writes inside _db_sync / _db_async callbacks that operate at the SQLAlchemy layer (e.g. _orphan_reap.py, _sessions.py internal helpers) may assign .status directly when they cannot call the async funnel from within a sync transaction context.

ANTI-PATTERNS (THIS PROJECT)

  • NEVER suppress types with as any / @ts-ignore / # type: ignore without documented reason
  • NEVER add direct SQLAlchemy session usage — always use _db_sync/_db_async
  • NEVER import from _-prefixed modules outside their parent package
  • NEVER modify migration files after they ship — generate a new migration
  • DO NOT use stdlib logging — use loguru
  • DO NOT put test fixtures in test files — use tests/helpers/
  • DO NOT write task.status = X outside a _db_sync/_db_async callback or the files listed above — use transition_task instead
  • DO NOT use /api/chat/sessions/{id}/watch or /messages?after_id= — these were removed in W9a cleanup; subscribe via GET /api/sessions/{id}/events with Last-Event-ID for resume
  • DO NOT write task.status or session.status directly in EventLog frame producers — frames are supplementary; status transitions still go through transition_task / transition_session
  • RUF012 / RUF006 / SIM102 / SIM117 intentionally suppressed (see pyproject.toml)

COMMANDS

# Development
uv run poe dev             # Run TUI in dev mode (textual dev server)
uv run poe test            # Run all tests (pytest, parallel)
uv run poe lint            # Ruff lint
uv run poe format          # Ruff format
uv run poe typecheck       # Pyrefly typecheck
uv run poe deadcode        # Vulture dead code detection
uv run poe check           # All: lint + typecheck + deadcode + test
uv run poe check-guardrails # LOC budget + complexity check
uv run poe fix             # Auto-fix lint + format

# Database
uv run poe db-migration-generate "migration message"
uv run poe db-migrations-check

# Web
uv run poe web-build       # Build React app → src/kagan/server/_web_static/
uv run poe docs-dev        # MkDocs dev server

# Install
uv run poe install-local   # Install as local CLI tool
uv run poe dev-setup       # Install + reset DB + stop daemon

# Snapshots
uv run poe snapshot-update # Update TUI snapshot tests

DEEP DIVE DOCS

ModuleArchitecture DocFeatures Doc
coredocs/internal/architecture/core.mddocs/internal/features/core.md
tuidocs/internal/architecture/tui.mddocs/internal/features/tui.md
serverdocs/internal/architecture/server.mddocs/internal/features/server.md
webdocs/internal/architecture/web.mddocs/internal/features/web.md
vscodedocs/internal/architecture/vscode.mddocs/internal/features/vscode.md

TypeScript / Web Checks

cd packages/web && pnpm exec vitest run
cd packages/web && pnpm exec playwright test   # requires running server (`kagan web`)
cd packages/web && pnpm run build

TypeScript / VS Code Extension Checks

cd packages/vscode && pnpm run check-types
cd packages/vscode && pnpm run test:unit
cd packages/vscode && pnpm run test:integration
cd packages/vscode && pnpm run test:e2e

Module Pitfalls

web

  • Do not bypass apiClient; keep HTTP calls centralized in src/lib/api/client.ts.
  • Do not add global styles outside src/app.css; keep overrides inside component <style> blocks.
  • Use @/ path alias for imports (maps to src/).
  • State management via jotai atoms — no class-based stores.

vscode

  • Event type strings come from EVENT_TYPE / SSE_TYPE consts in api/types.ts — never hand-type event strings.
  • ACP payloads nest tool data under payload.acp — use acpPayload() helpers, not direct field access.
  • All HTTP calls go through KaganClient — no raw fetch in providers.
  • One provider per VS Code API surface — do not mix concerns.

NOTES

  • references/ contains external repos for study — excluded from build/test/lint
  • .claude/worktrees/ are agent worktrees — excluded from analysis
  • CLAUDE.md is a symlink to AGENTS.md
  • Pre-commit runs: gitleaks, ruff lint/format, pyrefly, mdformat, uv-lock
  • CI pipeline: lint → fast-gate (unit) → test-pr (full suite, matrix: py3.12-3.14, ubuntu/macos/windows)
  • Semantic release on main: conventional commits, beta prereleases
  • Web UI is bundled as static files into the Python package at build time

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.