How marcus/nightshift works
Nightshift is a Go CLI for scheduled, budget-aware AI maintenance of configured repositories, with changes delivered as branches or PRs. The principal workflow is configure projects and providers, preview eligible work, select tasks within budget and cooldown constraints, execute an agent plan/implement/review loop, then report results without writing to the primary branch. The map also preserves setup, security, integrations, and run-history capabilities. Preview and orchestration excerpts support some links; where command wiring was not sampled, workflow links are documented at the product level rather than asserted as specific calls.
Main entry points: commands CLI commands · orchestrator.go Run orchestrator · db.go SQLite database · integrations.go Repository integrations
Components 22
CLI and setup
- CLI commands
cmd/nightshift/commands - Configuration
internal/config/config.go - Guided setup
internal/setup/presets.go
Planning and budgets
- Schedule
internal/scheduler/scheduler.go - Projects
internal/projects/projects.go - Task catalog
internal/tasks/tasks.go - Task selection
internal/tasks/selector.go - Budget allocation
internal/budget/budget.go
Task execution
- Run orchestrator
internal/orchestrator/orchestrator.go - Agent adapters
internal/agents/agent.go - Security controls
internal/security/security.go
State and reporting
- SQLite database
internal/db/db.go - Run state
internal/state/state.go - Run reports
internal/reporting/run_report.go - Analysis and trends
internal/analysis/analyzer.go - Budget snapshots
internal/snapshots/collector.go
External integrations
- Usage providers
internal/providers/provider.go - Repository integrations
internal/integrations/integrations.go
Other components
- Operator
- Configured repositories
- AI CLIs
- GitHub
Connections 25
- Operator → CLI commands: invokes
- CLI commands → Configuration: loads settings
- CLI commands → Guided setup: configures
- CLI commands → Schedule: previews schedule
- CLI commands → Projects: selects projects
- CLI commands → Budget allocation: checks allowance
- CLI commands → Task selection: previews tasks
- Task selection → Task catalog: scores definitions
- Budget allocation → Usage providers: reads usage
- CLI commands → Run orchestrator: starts runs
- Run orchestrator → Agent adapters: executes phases
- Agent adapters → AI CLIs: runs agent CLI
- Run orchestrator → Security controls: applies controls
- Run orchestrator → Configured repositories: works in
- Run orchestrator → Run state: records progress
- Run state → SQLite database: reads and writes
- CLI commands → Run reports: presents results
- Run reports → SQLite database: persists run data
- CLI commands → Analysis and trends: requests analysis
- Analysis and trends → SQLite database: reads run data
- CLI commands → Budget snapshots: captures usage
- Budget snapshots → SQLite database: stores snapshots
- Run orchestrator → Repository integrations: uses integrations
- Repository integrations → GitHub: creates PRs
- Repository integrations → Configured repositories: inspects repository