How ydiaz1699/nas-dotfiles works
Purpose and operating model
nas-dotfiles is a personal Linux/NAS operations framework centered on Docker service management. It exposes the same NAS state through Bash shell shortcuts, two svc CLIs, and a natural-language Python agent. It manages local Compose projects, persistent service documentation, backups, diagnostics, and notifications rather than serving a web application.
Primary entry points
• Installation and shell bootstrap: install.sh, shell/init.sh.
• Default Bash service CLI: docker/cli/svc.sh; it dispatches operational libraries under docker/cli/lib/.
• Optional Python svc CLI: svc_py/__main__.py, svc_py/app.py.
• Interactive AI agent: agent/nas_agent.py; background process: agent/daemon.py.
• Persistent deployment unit: systemd/nas-agent.service.
Shell and service-control layer
The shell layer installs aliases, prompt/navigation, Docker convenience commands, and lifecycle shortcuts. The Bash svc command is the default operational interface and delegates Compose lifecycle, health, backup, discovery, menus, catalog synchronization, and ntfy notifications to focused shell modules.
• shell/init.sh
• docker/cli/svc.sh
• docker/cli/lib/docker.sh
The Python CLI is an alternative presentation/control layer using Typer, Rich, and InquirerPy. It wraps Docker/Compose and discovery behavior behind command modules, with a Bash bridge where shared shell behavior is needed.
• svc_py/app.py
• svc_py/core/docker.py
• svc_py/core/bash_bridge.py
Service catalog as source of operational truth
The catalog stores service-specific Compose definitions, environment templates, and operational “ficha” documentation. It supports a synchronization pipeline that derives or updates catalog/documentation artifacts when Compose definitions change, with optional DebMenux integration.
• agent/catalog/catalog.json
• agent/catalog/_index.py
• agent/catalog/services/homeassistant/compose.yml
Shared runtime settings belong in external /docker/.env; service secrets are intended to remain in per-service .env files. Docker Compose v2 is the core infrastructure boundary; managed services include Home Assistant, EMQX/MQTT, ESPHome, Node-RED, ntfy, Homepage, Filebrowser, and DataSQL.
AI agent orchestration
The agent converts natural-language requests into tool calls. Its core managers coordinate Compose operations, service state, backups, and persistent memory; tools are the execution boundary for shell/Docker, diagnostics, discovery, search, and catalog actions.
• agent/nas_agent.py
• agent/core/compose_manager.py
• agent/tools/docker_tools.py
AI provider configuration supports Gemini, AWS Bedrock, and local Ollama. The agent’s durable operator context is file-backed, allowing learned service facts and user preferences to persist across sessions.
• agent/core/memory.py
• agent/memory/MEMORY.md
• agent/config/defaults.yml
Events, daemon, and plugins
The daemon runs continuously under systemd, starting a scheduler and extensible plugins. Plugins isolate background capabilities—Docker monitoring, backups, networking, Home Assistant discovery, memory, and notifications—while the event bus and MQTT listener provide asynchronous event ingress.
• agent/daemon.py
• agent/scheduler/runner.py
• agent/plugins/loader.py
External integrations include Docker Engine/Compose, MQTT via EMQX and paho-mqtt, Home Assistant discovery, ntfy push notifications, systemd, and optional local Ollama/AWS/Gemini APIs.
• agent/events/bus.py
• agent/events/mqtt_listener.py
• agent/plugins/notification_plugin.py
Key boundaries and control flow
User command or agent request → CLI/tool/manager → Docker Compose, filesystem, or system command → normalized result → terminal output, memory update, event, or notification. The shell CLI and Python CLI are peer interfaces; the agent is a higher-level orchestrator that reuses equivalent operational primitives. Catalog files define service intent and documentation, while runtime state is obtained from Docker and host diagnostics.
Main entry points: daemon.py Agent Daemon · nas_agent.py NAS Agent · docker_tools.py Docker Tools · _index.py Catalog Index
Components 24
Operator Interfaces
- Shell Bootstrap · Installs shell aliases and shortcuts.
shell/init.sh - Bash svc CLI · Default Docker service operations interface.
docker/cli/svc.sh - Python svc CLI · Alternative interactive service interface.
svc_py/app.py - Bash Bridge
svc_py/core/bash_bridge.py
Service Control
- Shell Docker Library · Shared Compose lifecycle and health operations.
docker/cli/lib/docker.sh - Python Docker Core
svc_py/core/docker.py
AI Agent
- Compose Manager · Coordinates Compose operations and service state.
agent/core/compose_manager.py - NAS Agent · Turns natural-language requests into operational tool calls.
agent/nas_agent.py - Docker Tools · Executes Docker, diagnostics, discovery, and catalog actions.
agent/tools/docker_tools.py - Memory Manager · Persists learned service facts and user preferences.
agent/core/memory.py - Operator Memory
agent/memory/MEMORY.md
Background Automation
- nas-agent Service · Persistent deployment unit for the daemon.
systemd/nas-agent.service - Agent Daemon · Runs scheduler and plugin capabilities.
agent/daemon.py - Scheduler
agent/scheduler/runner.py - Plugin Loader · Loads monitoring, backup, network, memory, and notification plugins.
agent/plugins/loader.py - Event Bus
agent/events/bus.py - MQTT Listener
agent/events/mqtt_listener.py - Notification Plugin · Delivers ntfy push notifications.
agent/plugins/notification_plugin.py
Service Catalog
- Catalog Index · Indexes service intent and documentation.
agent/catalog/_index.py - Catalog Metadata
agent/catalog/catalog.json - Service Compose Definitions · Per-service deployment definitions and templates.
agent/catalog/services/homeassistant/compose.yml
Other components
- Docker Engine / Compose · Runs managed NAS containers and obtains runtime state.
- EMQX / MQTT · Asynchronous event ingress.
- ntfy
Connections 24
- Shell Bootstrap → Bash svc CLI: exposes
- Bash svc CLI → Shell Docker Library: dispatches
- Shell Docker Library → Docker Engine / Compose: controls
- Python svc CLI → Python Docker Core: uses
- Python svc CLI → Bash Bridge: bridges shared behavior
- Python Docker Core → Docker Engine / Compose: controls
- NAS Agent → Docker Tools: invokes
- NAS Agent → Compose Manager: coordinates through
- Compose Manager → Docker Engine / Compose: manages
- Docker Tools → Docker Engine / Compose: executes operations
- NAS Agent → Memory Manager: updates context
- Memory Manager → Operator Memory: persists
- Docker Tools → Catalog Index: reads and synchronizes
- Catalog Index → Catalog Metadata: indexes
- Catalog Index → Service Compose Definitions: resolves services
- Service Compose Definitions → Docker Engine / Compose: defines deployments
- nas-agent Service → Agent Daemon: starts
- Agent Daemon → Scheduler: runs
- Agent Daemon → Plugin Loader: loads
- Agent Daemon → Event Bus: publishes events
- MQTT Listener → Event Bus: ingresses events
- EMQX / MQTT → MQTT Listener: delivers messages
- Plugin Loader → Notification Plugin: loads
- Notification Plugin → ntfy: sends pushes