How totaljs-es/totem works
Totem is a Total.js AI coding environment: users open a project, choose a model, chat with an agent, review proposed edits and commands, and accept or reject changes. The agent coordinates model calls, project tools, permissions, and session history; supporting capabilities include Total.js knowledge, MCP, terminals, worktrees, schedules, and provider discovery. The graph follows documented routes and relationships visible in excerpts. Several substantial modules were not sampled, so their nodes are included where README capabilities or the tree support them, without asserting unverified calls.
Main entry points: sessions.js Session actions · agent.js Agent loop · tools.js Project tools · api.js API and socket routes
Components 24
Entry and interface
- Totem CLI
bin/totem.js - Total.js server
index.js - API and socket routes
controllers/api.js - Browser interface
public/js/default.js - Chat interface
plugins/chat/index.js
Projects and sessions
- Project management
schemas/projects.js - Session actions
schemas/sessions.js - Session records
schemas/sessions.js
Agent and tools
- Agent loop
modules/agent.js - Project tools
schemas/tools.js - Permission gates
modules/permissions.js - Change history
modules/snapshots.js - Total.js knowledge
modules/knowledge.js - Convention checks
modules/conventions.js
Models and integrations
- Model providers
modules/provider.js - Local model discovery
modules/discovery.js - MCP client
modules/mcpclient.js - MCP servers
Runtime operations
- Interactive terminal
modules/terminal.js - Git worktrees
modules/worktrees.js - Scheduled prompts
modules/schedules.js - Background jobs
modules/jobs.js - Application database
definitions/db.js
Other components
- Developer
Connections 25
- Developer → Browser interface: uses
README.md - Developer → Totem CLI: runs prompt
README.md - Totem CLI → Total.js server: starts
README.md - Browser interface → API and socket routes: requests actions
README.md - API and socket routes → Session actions: routes session actions
controllers/api.js - API and socket routes → Project management: routes project actions
controllers/api.js - API and socket routes → Scheduled prompts: routes schedules
controllers/api.js - Browser interface → Chat interface: forwards events
public/js/default.js - Session actions → Session records: reads and writes
schemas/sessions.js - Session actions → Agent loop: starts agent
schemas/sessions.js - Agent loop → Model providers: requests model
README.md - Agent loop → Project tools: runs tools
modules/agent.js - Agent loop → MCP client: connects MCP
modules/agent.js - Agent loop → Total.js knowledge: adds Forge context
README.md - Project tools → Permission gates: checks authorization
README.md - Project tools → Change history: records prior files
schemas/tools.js - Project tools → Convention checks: reviews edits
schemas/tools.js - Project tools → Interactive terminal: starts commands
README.md - MCP client → MCP servers: calls tools
modules/mcpclient.js - Session actions → Interactive terminal: opens shell
schemas/sessions.js - Session actions → Git worktrees: checks worktree
schemas/sessions.js - Session actions → Background jobs: stops job
schemas/sessions.js - Session actions → Application database: loads project
schemas/sessions.js - Local model discovery → Model providers: detects local models
README.md - Scheduled prompts → Agent loop: runs prompts