Imported from pengqian089/Dpz.ServiceHub (
AGENTS.md). Install upstream withnpx skills add pengqian089/Dpz.ServiceHub. Copyright stays with the author.
Dpz.ServiceHub - Agent Instructions
Build & Run
# Solution uses .slnx format
cd src/Dpz.ServiceHub/Dpz.ServiceHub
dotnet run
dotnet build
dotnet publish -c Release -r win-x64 --self-contained
No tests exist in the repo; dotnet test does nothing.
Architecture
Single-project Avalonia desktop app (WinExe, .NET 10.0) for managing local dev services with an xterm.js terminal for ANSI log viewing.
- Entry:
Program.cs(single-instance viaGlobal\Dpz.ServiceHub.Singletonmutex) - MVVM:
CommunityToolkit.Mvvmwith source generators ([ObservableProperty],[RelayCommand]— needspartialon classes) - View resolution:
ViewLocator.csmapsFooViewModel->FooViewby convention (string replace) - DI: None —
MainWindowmanually instantiatesMainWindowViewModel, which createsServiceManagerandAppSettingsStore - Terminal:
Assets/terminal.htmlloaded byAvalonia.Controls.WebView(xterm.js 5.3.0 from CDN). Marked asCopyToOutputDirectory=PreserveNewest, NOT as an AvaloniaResource.
Framework-Specific Quirks
- CommunityToolkit.Mvvm source generators require a design-time build for IDE support. Generated partial methods (e.g.
OnIsStoppingServicesChanged) must be declared aspartial. .slnxsolution format: usedotnet build/dotnet rundirectly on the.csproj, notmsbuildordevenv .sln.- Single-instance: the app silently exits if already running. Add
ReleaseMutex()on close. - WebView2 focus exception:
ArgumentExceptionwithICoreWebView2Controller.MoveFocusin the stack is silently swallowed inProgram.cs.
Logging & Config State
- App logs:
%APPDATA%/Dpz.ServiceHub/logs/servicehub-\*.log(Serilog, WARNING minimum, daily rolling, 14 files/10MB each) - Service config:
%APPDATA%/Dpz.ServiceHub/services.json(typedList<ServiceConfig>) - App settings:
%APPDATA%/Dpz.ServiceHub/appsettings.json(typedAppSettings) - Use structured logging — no string interpolation in log messages.
Platform Constraints
- External process detection (
ServiceManager.cs) uses WMI (Win32_Process) andcmd.exe /c netstat -ano— Windows-only. The cross-platform UI/MVVM layer is portable but detection degrades on Linux/macOS. - Port-based process resolution works through a sentinel: if a port is in use but the PID can't be resolved,
Environment.ProcessIdis used as a placeholder.
Code Conventions
_prefix for private fields (camelCase); camelCase for params/vars; PascalCase for types/methods/properties- Async methods MUST end with
Asyncand SHOULD includeCancellationToken cancellationToken = default - File-scoped namespaces, 4-space indent, 100-char line max
- Always braces on
if/for/foreach/whileblocks (even single-line) - Prefer primary constructors when only one constructor exists
- No trailing comments; no public fields
- Return empty collections (not null) for collection return types
- Don't re-enumerate
IEnumerable<T>