Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
"""Central app directory convention.
Dodaios writes user data (skills, memory, logs, session file) to a
single canonical location. On Windows this is ``%LOCALAPPDATA%\\Dodaios``; when
the ENV variable is absent (portable scripts, tests) it is ``~/.dodaios-data``.
An installation from before the rename keeps its directory under the earlier
name (``Jarvis`` / ``.jarvis``) for as long as that is a real directory; the
primary instance moves it at boot and leaves a link behind
(``dodaios.core.identity_boot``).
This module replaces the scattered ``Path.home() / ".jarvis"`` literals and the
local ``_app_data_dir()`` in ``dodaios.ui.shell.single_instance``. All consumers
go through the getters defined here.
"""
from __future__ import annotations
import sys
import sysconfig
from pathlib import Path
from dodaios.core.branding import (
DESKTOP_OUTPUT_MIRROR_DIR_NAME,
DISTRIBUTION_NAMES,
LEGACY_DESKTOP_OUTPUT_MIRROR_DIR_NAMES,
)
from dodaios.core.identity_boot import resolve_named_dir, resolve_pair, user_data_dir_pair
def user_data_dir() -> Path:
"""App data directory in the user context.
- Windows: ``%LOCALAPPDATA%\\Dodaios`` (standard convention for local app data).
- Fallback: ``~/.dodaios-data`` — relevant when ``LOCALAPPDATA`` is not set
(e.g. in some CI environments, Unix dev setups, test runs).
A real directory under the earlier name (``Jarvis`` / ``.jarvis``) wins
while it exists: that is an installation whose data has not been moved
yet. Resolved with a few ``stat`` calls and cached per process
(``dodaios.core.identity_boot.resolve_pair``).
Does NOT create the directory — use ``ensure_user_dirs()`` for that.
"""
return resolve_pair(user_data_dir_pair())
def user_skills_dir() -> Path:
"""Directory for user skills (also contains copied built-ins after the first run)."""
return user_data_dir() / "skills"
def user_memory_dir() -> Path:
"""SQLite recall store and ChromaDB archival data land here."""
return user_data_dir() / "memory"
def user_logs_dir() -> Path:
"""Flight recorder JSONL and other log files."""
return user_data_dir() / "logs"
def user_clis_dir() -> Path:
"""Directory for user-defined custom CLI specs and CLI usage artefacts."""
return user_data_dir() / "clis"
def chat_workspace_dir() -> Path:
"""Where a typed Jarvis chat works when nobody picked a folder for it.
The Jarvis chat hands the turn file and shell tools scoped to a working
directory (``dodaios.agent_chat.folder_tools``), and a CLI-backed seat needs
a directory to start in at all. The fallback used to be :func:`Path.home` —
the entire user profile, with the read-only tools (``Read``/``Ls``/``Glob``/
``Grep``) running inside it unprompted because their risk tier is ``safe``.
A directory of its own keeps that default reach small; pointing a chat at a
real project folder stays a per-session choice.
Does NOT create the directory — the caller does, so a read-only install can
fall back instead of failing (see ``dodaios.ui.web.server``).
"""
return user_data_dir() / "chat-workspace"
def workspace_clis_dir() -> Path:
"""Where the user's own terminal CLIs and their logos are kept.
Deliberately NOT :func:`user_clis_dir`, which holds specs for the shared CLI
catalog — those become brain-callable tools. An entry here is only ever
something a workspace terminal RUNS (see ``dodaios.workspace.custom_clis``),
and keeping the two directories apart is what keeps a command the user typed
into a terminal picker from quietly becoming a tool an LLM may call.
"""
return user_data_dir() / "workspace-clis"
def workspace_clis_path() -> Path:
"""JSON file listing the user's own terminal CLIs."""
return workspace_clis_dir() / "custom.json"
def cli_usage_db_path() -> Path:
"""SQLite database containing CLI invocation metadata (CLI integration)."""
return user_data_dir() / "cli_usage.db"
def cli_custom_catalog_path() -> Path:
"""JSON file containing user-registered custom CLI specs."""
return user_clis_dir() / "custom.json"
def skill_link_health_db_path() -> Path:
"""SQLite database caching reachability status for skill URLs (homepage/source/docs)."""
return user_data_dir() / "data" / "skill_link_health.sqlite"
def docs_index_db_path() -> Path:
"""SQLite FTS5 index for the documentation section (Phase Docs-Tier-1)."""
return user_data_dir() / "data" / "docs_index.sqlite"
def skill_prefs_path() -> Path:
"""JSON sidecar storing per-skill on/off overrides and the custom list order.
Kept OUTSIDE ``user_skills_dir()`` (which the registry watcher observes for
``*.md`` changes) so a preference write never triggers a skill hot-reload.
"""
return user_data_dir() / "data" / "skill_prefs.json"
def repo_root() -> Path:
"""Path to the repository root (local Dodaios working tree).
Derived from the location of this file: ``dodaios/core/paths.py`` ->
``parents[2]``. With an editable install (``pip install -e .``) this
points to the repo working tree, not to the site-packages mirror — which
is intentional for doc discovery.
"""
return Path(__file__).resolve().parents[2]
def runtime_data_dir() -> Path:
"""The runtime data dir: ``JARVIS_DATA_DIR``, else the checkout's instance dir.
The same rule as ``dodaios.core.config.DATA_DIR`` (both resolve through
``dodaios.core.instance.resolve_data_dir``), for modules that must not
import the config. Read on every call. The app runs from the checkout, so
without an override this is the ``data/`` a bare relative path meant;
unlike one, it does not depend on the process cwd (#458).
"""
from dodaios.core.instance import resolve_data_dir
return resolve_data_dir(repo_root())
def flight_recorder_dir() -> Path:
"""``<data dir>/flight_recorder``: the event JSONL files and their ``blobs/``."""
return runtime_data_dir() / "flight_recorder"
def default_doc_roots() -> list[Path]:
"""Default discovery roots for the documentation registry.
``docs/product/`` is the curated reader library. The wider ``docs/`` tree
remains an engineering source archive and is never exposed in the reader.
"""
root = repo_root()
# The desktop reader intentionally indexes only the curated product guide.
# Engineering plans, ADRs, audits, and forensic reports remain under
# ``docs/`` as source material, but they are not reader documentation.
product_docs = root / "docs" / "product"
if product_docs.exists():
return [product_docs]
# Wheels install the reader library as platform data. Check the active
# environment, a ``pip --target``-style root, and the user-install scheme.
# This keeps discovery portable without scanning a home directory.
data_prefixes = [Path(sysconfig.get_path("data")), root]
try:
user_scheme = sysconfig.get_preferred_scheme("user")
data_prefixes.append(Path(sysconfig.get_path("data", scheme=user_scheme)))
except (KeyError, TypeError, ValueError):
pass
# A wheel under the earlier distribution name installs under that
# ``share/<name>``; the current name wins where both exist.
seen_prefixes: set[Path] = set()
for prefix in data_prefixes:
if prefix in seen_prefixes:
continue
seen_prefixes.add(prefix)
for distribution in DISTRIBUTION_NAMES:
installed_docs = prefix / "share" / distribution / "docs"
if installed_docs.exists():
return [installed_docs]
# Fail closed if the packaged reader library is missing. Falling back to
# the engineering archive could expose plans, audits, or local diagnostics.
return []
def board_db_path() -> Path:
"""SQLite database with aggregated board stats (Personal Mastery Dashboard).
Phase A reads flight recorder JSONL from ``user_logs_dir()`` and writes
aggregated safe fields here. The database is strictly local — no sync, no
cloud upload.
"""
return user_data_dir() / "data" / "board" / "personal.db"
def user_outputs_dir() -> Path:
"""Canonical output directory for sub-agent sessions."""
d = user_data_dir() / "outputs"
d.mkdir(parents=True, exist_ok=True)
return d
def desktop_mirror_dir() -> Path:
"""Desktop junction root for direct access to sub-agent outputs.
``~/Desktop/Dodaios-Output``, or the folder under its earlier name while
that one exists: a folder on the Desktop is never renamed under the user.
"""
return resolve_named_dir(
Path.home() / "Desktop",
DESKTOP_OUTPUT_MIRROR_DIR_NAME,
LEGACY_DESKTOP_OUTPUT_MIRROR_DIR_NAMES,
)
def ensure_session_output_dir(slug: str) -> tuple[Path, Path]:
"""Create the canonical session directory and (on Windows) a Desktop junction.
Returns:
(canonical, mirror) — on Windows ``mirror`` is a directory junction into
``canonical`` for one-click Desktop access. On macOS/Linux (including a
headless server with no Desktop) the junction is skipped and ``mirror``
equals ``canonical``, so callers always receive a usable path and no
stray ``~/Desktop/Dodaios-Output`` folder is created.
"""
import subprocess
from dodaios.core.process_utils import NO_WINDOW_CREATIONFLAGS
canonical = user_outputs_dir() / slug
canonical.mkdir(parents=True, exist_ok=True)
# The Desktop mirror is a Windows directory junction (``mklink /J``) — a
# convenience, never a core path. Skip it entirely off Windows so a headless
# VPS or a Mac never grows an empty ``~/Desktop/Dodaios-Output`` directory.
if sys.platform != "win32":
return canonical, canonical
mirror_root = desktop_mirror_dir()
mirror_root.mkdir(parents=True, exist_ok=True)
mirror = mirror_root / slug
if not mirror.exists():
try:
subprocess.run(
["cmd", "/c", "mklink", "/J", str(mirror), str(canonical)],
check=False,
capture_output=True,
timeout=5.0,
creationflags=NO_WINDOW_CREATIONFLAGS,
)
except Exception: # noqa: BLE001
pass # Mirror is nice-to-have, not a fatal failure
return canonical, mirror
def ensure_user_dirs() -> Path:
"""Create all user directories. Idempotent — safe to call on every start.
Returns the root directory (``user_data_dir()``) so callers can use it
immediately.
"""
root = user_data_dir()
for p in (root, user_skills_dir(), user_memory_dir(), user_logs_dir(), user_clis_dir()):
p.mkdir(parents=True, exist_ok=True)
return root
__all__ = [
"user_data_dir",
"user_skills_dir",
"user_memory_dir",
"user_logs_dir",
"user_clis_dir",
"chat_workspace_dir",
"workspace_clis_dir",
"workspace_clis_path",
"cli_usage_db_path",
"cli_custom_catalog_path",
"skill_link_health_db_path",
"skill_prefs_path",
"docs_index_db_path",
"repo_root",
"runtime_data_dir",
"flight_recorder_dir",
"default_doc_roots",
"board_db_path",
"ensure_user_dirs",
"user_outputs_dir",
"desktop_mirror_dir",
"ensure_session_output_dir",
]