This guide explains how Chronos fits together so you can extend it confidently.
- CLI Entrypoint —
modules/console.py- Adds project paths, sets UTF-8, and loads
commands/*.pydynamically. - Parses interactive input, CLI args, and
.chsscripts (supports nestedif/elseif/else/endand loop blocks). - Uses
modules/variables.pyfor in-memory variables and token expansion (e.g.,@nickname,@status_energy). - Macro hooks: command execution is wrapped with BEFORE/AFTER hooks via
modules/macro_engine.py(enabled byuser/scripts/macros/macros.yml). Dashboard calls also pass through these hooks. - Autosuggest and autocomplete are registry-driven; see
docs/dev/autosuggest.mdfor the slot model and refresh workflow.
- Adds project paths, sets UTF-8, and loads
Items are the atoms of Chronos. They are stored as YAML files in the user/ directory.
- Polymorphic: Any item can have
tasks,subroutines,inventory_items, ormilestones. - Fractal: Items can nest indefinitely. The
Schedulercreates a flattened view for execution but preserves the hierarchy for planning. - Defaults: Each item type has a
_defaults.yml(e.g.,task_defaults.yml) that defines its initial state.
- Command Router:
commands/today.pydispatches three modes:- active Kairos (
today,today reschedule) - explicit Kairos tooling (
today kairos ...) - legacy fallback (
today legacy ...)
- active Kairos (
- Kairos Engine:
modules/scheduler/kairos.pyis the active daily scheduler.- Loads runtime context (status, settings, trends, completion logs)
- Selects template/windows with strict place+status compatibility
- Gathers/filter/scores executable backlog from
chronos_core.db - Constructs timeline (anchors, injections, windows, gaps, synthetic buffers/breaks)
- Runs overlap repair + dependency shift passes
- Emits decision logs in
user/logs/kairos_decision_log_*
- Weekly Planner:
modules/scheduler/weekly_generator.pypowerstoday kairos week. - Compatibility Layer: Active Kairos output is adapted into legacy schedule row shape in
commands/today.pyso existing dashboard/API/manual-modification flows continue to work. - Manual Modifications: Persisted in
user/schedules/manual_modifications_YYYY-MM-DD.ymland translated into Kairos context (notably manualinjectactions).
A recursive descent parser that evaluates logic strings in scripts and triggers.
- Grammar: Supports
( ... ),AND,OR,XOR,NOT. - Operators:
==,!=,>,<,matches(Regex). - Targets: Can check file existence (
exists file:...), environment variables (exists env:...), or item properties (task:MyTask:status == completed).
The "Long-Term Memory" of Chronos.
-
Mirroring: Mirrors the YAML data into SQLite databases (
chronos_behavior.db,chronos_journal.db) for performant querying. -
Trends: Analyzes history to build
chronos_trends.dband generates atrends.mddigest. -
Automation: Runs automatically via
automation.pyhook during the nightly rollover. -
Cleanup Integration: The
clearcommand provides surgical control over Sequence Mirrors:clear cache- Deletes all.dbfiles, forcing full rebuildclear db:<name>- Deletes specific mirror (e.g.,chronos_matrix.db), auto-rebuilds on next accessclear registry:<name>- Clears in-memory registry caches (wizards, themes, etc.) to force YAML reload- See Admin Tools for full cleanup reference
-
Listener —
modules/listener/listener.py- Monitors time for alarms/reminders, triggers sounds (pygame.mixer), handles timer ticks.
- Can execute scripts and target actions (e.g., complete task on trigger).
-
Dashboard —
utilities/dashboard- Server (
server.py) serves assets and JSON/YAML APIs (ThreadingHTTPServer over plain HTTP). - UI is plain ES modules + a small loader (
core/runtime.js) to mount views (Calendar,TemplateBuilder,Cockpit), widgets (Scheduler/Today widget, Item Manager, Variables, Terminal, Habit Tracker, Goal Tracker, Commitments, Rewards, Achievements, Milestones, Notes, Journal, Profile, Review, Timer, Settings, Clock, Status, Debug), and dock gadgets (utilities/dashboard/gadgets/*). - Widgets mount via attributes, e.g.,
data-widget="Notes", and exportmount(el, context). Cockpit panels register viawindow.__cockpitPanelRegisterand render inside the drag-and-drop canvas.
- Server (
The Dashboard is a hybrid Desktop/Web application.
A ThreadingHTTPServer that acts as the bridge between the browser and the file system.
- API: Provides JSON endpoints (
/api/profile,/api/cockpit/matrix,/api/media/mp3) to read/write system state. - Streaming: Streams MP3s from
user/mediafor the music player. - Bundler: The
dashboardCLI command pre-bundles static settings intogenerated/settings_bundle.jsfor fast startup.
A generic Vanilla JS Single Page Application (SPA).
-
Module Loader: Dynamically imports "Panels" (views) and "Wizards" to keep the initial bundle small.
-
View System: Manages a tiling window interface (
view-panes) where users can open multiple tools side-by-side. -
Widgets: Persistence-aware widgets (Notes, Timer, Status) that float over the UI.
-
Theming: Supports hot-swappable CSS themes (Blue, Amber, Emerald, Rose).
- Endpoints (selected):
- Health:
GET /health. - Today API:
GET /api/today,POST /api/today/reschedule. - CLI bridge:
POST /api/cli— invokes the console pipeline in-process (falls back to subprocess if needed). - Profile & Theme:
GET /api/profile,GET /api/theme?name=.... - Variables:
GET/POST /api/vars,POST /api/vars/expand. - Items:
GET /api/items,GET /api/item,POST /api/item,POST /api/item/copy|rename|delete, bulkPOST /api/items/delete|setprop|copy|export,POST /api/open-in-editor. - Template Builder:
GET /api/template/list,GET /api/template,POST /api/template. - Habits & Goals:
GET /api/habits,GET /api/goals,GET /api/goal?name=.... - Commitments & Milestones:
GET /api/commitments,GET /api/milestones,POST /api/milestone/update. - Rewards & Points:
GET /api/points,GET /api/rewards,POST /api/reward/redeem. - Achievements:
GET /api/achievements,POST /api/achievement/update. - Timer:
GET /api/timer/status|profiles|settings,POST /api/timer/start|pause|resume|stop|cancel|confirm. - Settings:
GET /api/settings,GET /api/settings?file=Name.yml,POST /api/settings?file=Name.yml(raw YAML preserved).
- Health:
- Security: permissive CORS for local dev; do not expose publicly without adding auth and controls.
- Endpoints (selected):
-
UI runtime (
utilities/dashboard/app.js+ widgets/views)- Views: Calendar, Template Builder, and the Cockpit canvas (panels under
utilities/dashboard/panels/). - Widgets: Scheduler (Today widget), Item Manager, Variables, Terminal, Habit Tracker, Goal Tracker, Commitments, Rewards, Achievements, Milestones, Notes, Journal, Profile, Review, Timer, Settings, Clock, Status, Debug Console.
- Gadgets + Dock: Bottom dock (
#chronosDock) populated by gadget registry (GET /api/registry?name=gadgets); gadgets mount viamountGadget()and can be toggled from the topbar Gadgets menu. - Event bus:
mount(el, context)receives acontext.busused by widgets (e.g., emitvars:changed,widget:show,calendar:selected). - Terminal: runs CLI via
/api/cli, supports history, Ctrl+L, optional variable expansion. - Item Manager: search/sort/multi-select, YAML editor, copy/rename/delete; bulk delete/set property/copy/export (exports to
/temp/exports_items_*.zip).
- Views: Calendar, Template Builder, and the Cockpit canvas (panels under
- Items are YAML files with a
name,type, and optional fields. - Hierarchy allows nested children (routines → subroutines → microroutines → items).
- Schedules store computed blocks for the current day; completions are tracked.
- Location:
user/settings/ - Conventions:
- Prefer lowercase filenames, e.g.,
points_settings.yml,achievement_defaults.yml,<item>_defaults.yml.
- Prefer lowercase filenames, e.g.,
- Timer files use lowercase canonical names (for example
timer_settings.ymlandtimer_profiles.yml). - The Settings widget and
/api/settingssimplify editing.
- CLI:
POST /api/cli— runs commands in-process; subprocess fallback. - Variables:
GET/POST /api/vars,POST /api/vars/expand. - Profile/Theme:
GET /api/profile,GET /api/theme?name=.... - Items:
GET /api/items,GET /api/item,POST /api/item*, bulk ops includingexport. - Today API:
GET /api/today,POST /api/today/reschedule. - Timer:
GET /api/timer/status|profiles|settings,POST /api/timer/start|pause|resume|stop|cancel|confirm. - Settings:
GET/POST /api/settingsandGET /api/settings?file=....
-
Add a command
- Create
commands/my_command.pywithrun(args, properties). - Add
get_help_message()to integrate withhelp.
- Create
-
Add an item module
- Create
modules/my_item/main.pywithhandle_<verb>orhandle_command. - Reuse
ItemManagerfor common behaviors (new,append,delete).
- Create
-
Add a widget, view, panel, popup, or gadget
- Create folder in
utilities/dashboard/widgets/<Name>/(or Views/Panels/Popups/Gadgets) - Create
index.jswith appropriate export function (mount()for widgets/views/popups/gadgets,register()for panels) - (Optional) Add metadata YAML file for custom labels or post-release badges
- Refresh dashboard - component auto-discovered and added to menu
- Add server endpoints if needed; prefer JSON responses for easy parsing
- Create folder in
-
Add a Wizard or Theme
- Wizards: Create folder in
utilities/dashboard/wizards/<Name>/withindex.js - Themes: Drop CSS file into
utilities/dashboard/themes/ - Component auto-discovered on server restart
- See
docs/dev/extensibility.mdfor the full specification
- Wizards: Create folder in
- Keep modules small and composable.
- Prefer JSON over YAML for HTTP responses (clients parse easier); YAML is OK for human-readable responses.
- Validate inputs on the server; sanitize paths; avoid blocking I/O in handlers.
- For long-running or external operations, apply timeouts and consider subprocess isolation.