Skip to content

Latest commit

 

History

History
239 lines (208 loc) · 19.2 KB

AGENTS.md

File metadata and controls

239 lines (208 loc) · 19.2 KB

NETworkManager - Repository Guide for AI Agents

NETworkManager is a network management and troubleshooting application for Windows (C#, .NET 10, WPF with MahApps.Metro): remote access (Remote Desktop, PuTTY, PowerShell, TigerVNC, Web Console), scanners (IP Scanner, Port Scanner, WiFi), diagnostics (Ping Monitor, Traceroute, DNS Lookup, ...) and system tools (Firewall, Hosts File Editor, ...), with profiles for hosts and groups.

Project Structure

Source/                           # Solution NETworkManager.sln (15 projects)
├── NETworkManager/               # WPF application (Views, ViewModels, Controls, Resources/Styles)
├── NETworkManager.Models/        # Business logic and data models (network tools, export, run command parser)
├── NETworkManager.Utilities/     # Helpers (no WPF)
├── NETworkManager.Utilities.WPF/ # WPF helpers (attached properties, behaviors)
├── NETworkManager.Converters/    # WPF value converters
├── NETworkManager.Validators/    # Input validation (one validator per input format)
├── NETworkManager.Controls/      # Custom controls (LucideIcon, ObservableRangeCollection, ...)
├── NETworkManager.Localization/  # Strings.resx (+ translations from Transifex)
├── NETworkManager.Settings/      # Settings (SettingsInfo, GlobalStaticConfiguration, SettingsManager)
├── NETworkManager.Profiles/      # Profiles and groups
├── NETworkManager.Update/        # Update check
├── NETworkManager.Documentation/ # Help links, licenses of third-party code
├── NETworkManager.Setup/         # WiX installer
├── NETworkManager.Tests/         # xUnit tests (run by AppVeyor)
└── 3rdparty/Dragablz/            # Dragablz (MIT), stripped to what we use, modified (README.md / CHANGELOG.md)
Website/                          # Docusaurus website: docs/application (tools), docs/settings, docs/faq, docs/changelog, docs/img
Scripts/                          # PowerShell scripts: update lists (OUI, ports, WHOIS servers, public suffixes, world map),
                                  # Lucide icons, release table / SHA256SUMS, PNG optimization, pre-build
Tests/Environments/               # Test environments for manual testing (SNMP, Active Directory)
.claude/skills/feature-review/    # Review skill + the app's conventions (references/conventions.md, dashboard.md)

Also: Chocolatey/, WinGet/ (package definitions), Images/. 18 languages (English + 17 translations; the enabled languages are listed in LocalizationManager.cs).

Key libraries: MahApps.Metro (+ SimpleChildWindow), Dragablz (tabs), gong-wpf-dragdrop, LiveChartsCore (charts), DnsClient, IPNetwork2, Lextm.SharpSnmpLib, Microsoft.PowerShell.SDK, Microsoft.Windows.CsWinRT (e.g. WiFi), WebView2, Octokit (update check), log4net, System.Text.Json (settings / profiles), Newtonsoft.Json (JSON export), NetBeauty2 (dependency folder), WiX (installer). Distribution: setup (MSI), portable and archive on GitHub Releases, Chocolatey, WinGet, Evergreen.

Build, Test and CI

  • Windows only: the solution can't be built on Linux / macOS (WPF, Windows SDK, CsWinRT). Say so when a change couldn't be compiled, and list what must be tested on Windows.
  • Prerequisites: .NET 10 SDK (version pinned in Source/global.json, updated by Dependabot), Visual Studio 2026 with .NET desktop development and Universal Windows Platform development (or Rider + the UWP workload).
  • Target net10.0-windows, TargetPlatformVersion 10.0.22621.0 (not in the TFM - otherwise Dependabot can't update the NuGet packages), runtime identifiers win-x64 / win-arm64. Source/Directory.Build.props: CS0108 / CS0114 (a member hiding an inherited one) are errors - WPF binds by name, a hiding property silently replaces e.g. ProfileSearch of ProfileHostViewModelBase.
  • Line endings: .gitattributes normalizes to LF in the repository (* text=auto).
dotnet build .\Source\NETworkManager.sln --configuration Release
dotnet test --project .\Source\NETworkManager.Tests
cd Website; yarn install; yarn start     # docs preview (Node.js LTS); yarn build = production build

AppVeyor (appveyor.yml, Visual Studio 2022 image): restores, builds Release and runs the unit tests. PRs build x64 and only NETworkManager.csproj (the setup only if Source/NETworkManager.Setup/ changed); branch builds only for main and tags; tags build x64 + ARM64 (setup, portable, archive), signed via SignPath.io. Builds that only change Website/, .github/, .claude/, Images/, Chocolatey/, WinGet/, Tests/Environments/, *.md or LICENSE end green without building (branch builds only for squash merges, subject ends with (#1234)). Version: yyyy.M.d.0.

GitHub Actions: CodeQL (codeql.yml, weekly / on demand), website (deploy_website.yml: Node.js 22 + yarn, Docusaurus Faster; all @docusaurus/* packages must have the same version; build on PRs, deploy only from main / releases; onBrokenAnchors fails the build), label / milestone automation (label.yml, milestone.yml).

Bots: Dependabot (weekly NuGet, .NET SDK, npm, Actions; label :heavy_check_mark: dependencies), Mergify (mergify.yml: merges PRs with LGTM after AppVeyor passes, bot PRs automatically except major Dependabot updates; website changes also need Build Website), Transifex (transifex.yml: syncs the RESX files).

Code Conventions

  • MVVM: views in Source/NETworkManager/Views/, view models (ViewModelBase, RelayCommand) in ViewModels/, logic in NETworkManager.Models. No logic in code-behind, no DI container. Style: Source/.editorconfig.
  • UI and code conventions (commands, refresh / modify, admin rights, context menus, dialogs, tooltips, layout, export, settings, profiles, HTTP requests, PowerShell, shared helpers): .claude/skills/feature-review/references/conventions.md
    • read it before changing UI or view model code. Follow existing patterns; keep the code simple (no abstraction for a single use).
  • Localization: never hard-code user-visible text (also not in Models: map exceptions to localized strings in the view model). Add strings only to Strings.resx (English) and, in alphabetical order, to Strings.Designer.cs; reuse existing strings. Translations come from Transifex.
  • Icons: Lucide only - {icons:Lucide Kind=Router} (xmlns:icons="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"), usually as Visual of a VisualBrush (opacity mask of a 16 × 16 Rectangle, fill MahApps.Brushes.Gray3), in C# new LucideIcon { Kind = LucideIconKind.Router }. A new icon: add it to $Icons in Scripts/Create-LucideIcons.ps1 and run the script (don't edit LucideIcons.cs).
  • Third-party code: license in Source/NETworkManager.Documentation/Licenses/ (+ Content entry in the csproj), an entry in LibraryManager and in the README; embedded single files keep their license header (e.g. AirspacePanel.cs). Source/3rdparty/Dragablz: change only when needed, keep changes small, don't reformat, add an entry to its CHANGELOG.md.
  • Generated lists (OUI, ports, WHOIS servers, public suffixes, world map, Lucide icons) are updated with the scripts in Scripts/, not by hand.
  • Tests: xUnit in Source/NETworkManager.Tests/<Area>/<Class>Tests.cs. Put testable logic (parsing, mapping, decisions) in small public static methods in NETworkManager.Models (no InternalsVisibleTo); helpers that NETworkManager.Controls uses go to NETworkManager.Utilities (Models references Controls), e.g. InputConverter. UI, system APIs and network behaviour are tested manually on Windows.
  • Plans and reviews: local, not committed: .claude/plans/ and .claude/reviews/ (e.g. ping-monitor.md). Read the file of the area first - it records verified findings, decisions and open items.

UI Design System

Calm look on top of MahApps.Metro (no WPF Fluent / WPF-UI). Use the existing tokens and styles instead of local colors, sizes or templates; theme-dependent brushes always with DynamicResource.

Themes (NETworkManager.Settings): MahApps Light / Dark plus own themes from ThemeVariants (dark Black, Midnight, Steel, Indigo; light Mist, Soft, Paper) and own accents (Sky, Ocean, Mint, Rose, Coral, Gold, Lavender, Slate, Graphite), created on demand in AppearanceManager.ChangeTheme (on failure: the default theme). A theme is dark by the brightness of its background (ThemeVariants.IsDark), not by its name. Default accent: Mint. Settings: Appearance_Theme, Appearance_Accent, Appearance_AccentGlowIntensity (Off / Subtle / Medium (default) / Strong), Appearance_Animations (System / On / Off). The embedded consoles get the theme colors (AppearanceManager.ConsoleBackground / ConsoleForeground / ConsoleBoldForeground, event ConsoleColorsChanged).

Brushes computed by AppearanceManager on every theme change:

Key Use
Brushes.Surface.Frame window frame, title bar, navigation
Brushes.Surface.Window / .Inactive FrameWindow background with the accent glow (half when inactive)
Brushes.Surface.Border all lines and surface borders (boxes, cards, separators, tabs, grid headers, popups, tooltips, dialogs); inputs / check boxes keep MahApps.Brushes.Gray8
Brushes.Navigation.Selected selected tool in the navigation
Brushes.Control.MouseOver / .Pressed / .Border.MouseOver hover / pressed of icon buttons, lists, tabs; input border on hover
Brushes.Button.Background / .MouseOver / .Pressed secondary buttons, title bar fields
Brushes.Status.Success / .Warning / .Error status icons, texts, validation - never hard-code these colors
MahApps.Brushes.DataGrid.Selection.* data grid selection (accent tinted)

Charts use ChartColors (theme-aware palettes, gradient AreaFill).

Tokens (Resources/Styles/Theme.xaml): font Segoe UI Variable Text, Segoe UI; Fonts.Family.Mono (Cascadia Mono, Consolas) for technical values (IP / MAC addresses, hostnames, ports, subnets, DNS servers, BSSID, OIDs, URLs, DNS records, raw output and inputs with such a watermark) - names, descriptions, states, times and paths use the UI font. Corner radii CornerRadius.Control 4, .Control.Inner 3, .Overlay / .Card 8. Brushes.Overlay (dialog overlay), FocusVisual.Ring (gray, no accent). Type scale (TextBlockStyles.xaml): DefaultTextBlock 14, HeaderTextBlock 16 SemiBold, MessageTextBlock 16 gray.

Layout: the window frame (FrameWindow) holds the navigation and rounded boxes (ViewBox, gap 6) for the view and the profiles; host views set ViewLayoutHelper.HasOwnBoxes. Cards (dashboard widgets, Ping Monitor hosts): CardBorder; groups: SectionExpander. Headers 36 high. Tabs (VS Code-like, Dragablz): change the tab look only in DragablzStyles.xaml; a single tab is shown as the view title; dragged-out tabs merge on the whole tab bar (MergeTargetArea="HeaderPanel", ShowMergeHint) - features of our modified Dragablz. Data grids: rows 30 high. Windows have rounded corners on Windows 11 (WindowCornerHelper.RoundCorners).

Controls:

  • Buttons: HighlightedButton (accent, the main action, e.g. Scan), DefaultButton / ImageWithTextButton (min. width 100), ImageButton / ImageDropDrownButton (transparent icon buttons).
  • Disabled = Opacity 0.55, no veil. Read-only inputs while a task runs: IsReadOnly + ComboBoxReadOnlyBehavior.
  • Drop-downs: ComboBoxPopupBehavior. Dialogs: DefaultChildWindow for all dialogs.
  • Progress: DefaultMetroProgressBar, ProgressRingSmall / Medium / Large (16 inline / 24 dialogs / 48 centered); scanner progress and countdowns via SmoothProgress.Value.
  • Status values in lists: StatusDot (Tag = StatusLevel via a *ToStatusLevelConverter; template columns set ClipboardContentBinding).
  • Empty areas: EmptyStateMessage (Icon, Text); loading texts stay MessageTextBlock. Not elevated: AdminNotice (*AdminMessage + restart button) below the list.
  • Status messages below the input: StatusMessageText (Text, Level = StatusLevel); the view model sets StatusMessageLevel with every StatusMessage. Never the accent color for messages.
  • Template copies of MahApps / SimpleChildWindow (keep in sync when updating these packages): ComboBox toggle, ToolTip, ContextMenu / submenu, scrollbar thumb, DefaultChildWindowTemplate, MahApps.Styles.DataGridRow.

Motion: only Opacity / RenderTransform, 150-250 ms, quadratic ease-out, no bounce, no staggered lists, no view transitions when switching tools; check AppearanceManager.AnimationsEnabled when an animation starts. Existing: ChildWindowAnimation, SelectionIndicatorAnimation, ExpanderAnimation, SmoothProgress, notification slide-in, tab reorder slide (Dragablz StackOrganiser, Canvas.Left, switch set in App.xaml.cs). Short color / opacity fades (hover layers, tooltip, overlay) are always shown. The accent glow is only in the window frame. Native windows (Remote Desktop, PuTTY, PowerShell, TigerVNC, WebView2) can't be animated, clipped or put in per-pixel transparent windows (AllowsTransparency); the whole window can be transparent (WindowTransparencyHelper, uniform alpha).

Architecture

  • Profiles: JSON files (legacy XML migrated), optionally AES-encrypted (.encrypted); settings are JSON too. Profile fields <Tool>_* in ProfileInfo, group defaults in GroupInfo (profile → group → settings), resolved in NETworkManager.Profiles/Application/<Tool>.cs. A reference to a named list entry of the settings (DNS server, port profile) stores its ID and the values as fallback (INamedReference, NamedReferenceInput), so a renamed entry is still found and a shared profile file works without it. The tool lists of the profile / group dialog are sorted by the ProfileName / GroupViewName enum value: add a new value at its visible position.
  • Settings: <Tool>_<Name> in SettingsInfo, defaults in GlobalStaticConfiguration. Migrations in SettingsManager: UpgradeToLatest runs on every update until the release - its blocks move into the dated UpgradeTo_<version> method at release, otherwise e.g. deleted default entries come back. Default list entries with an ID are added on the first start / in the upgrade step, not in the property initializer (new IDs on every start would break references). A changed default only applies to new installations.
  • Open a tool from code: NavigationManager.Open(new ApplicationRequest(ApplicationName.X) { Target = ... }) or a derived request (ApplicationRequest.cs: PortScannerRequest, DNSLookupRequest, RDAPRequest, WakeOnLANRequest, SubnetCalculatorRequest, LookupRequest). Profile runs a profile, Start = false only fills in the input. MainWindow calls IApplicationRequestHandler.Open(request) on the tool's view (host views: AddTab(...)). Don't reference other tools' views or view models.
  • Run command (Ctrl+Shift+P, title bar box, optional global hotkey): parser in NETworkManager.Models/RunCommand/, commands, validation and requests in Source/NETworkManager/RunCommandManager.cs, dialog RunCommandViewModel / RunCommandChildWindow, docs Website/docs/run-command.md. A target is validated with the same validator as the tool's input field and profile dialog.
  • Large lists: ObservableRangeCollection<T>.ReplaceAll(items) for lists that are reloaded completely (one Reset); results appended while a scan runs are buffered and flushed by a timer (IPScannerViewModel).
  • Embedded tools: Remote Desktop (AxMSTSCLib, WindowsFormsHost), PuTTY, PowerShell and TigerVNC (process window embedding with WindowsFormsHost), Web Console (WebView2).
  • Dashboard: widgets <Name>WidgetView + <Name>WidgetViewModel in Views/DashboardView.xaml(.cs). Privacy: anything that sends the IP address to a web service or runs continuously is opt-in. Rules for showing / checking, sizes and layout and adding a widget: .claude/skills/feature-review/references/dashboard.md.
  • Security / privacy: no telemetry; optional third-party services (GitHub API, ipify.org, ip-api.com, Cloudflare); official binaries signed via SignPath.io; vulnerability reports via SECURITY.md.

Common Scenarios

New network tool

  1. Model in NETworkManager.Models/, view model in ViewModels/, view in Views/.
  2. Register it in ApplicationName / ApplicationManager, show / hide it in MainWindow.xaml.cs (OnApplicationViewVisible / OnApplicationViewHide) and add it to the application list of existing users in SettingsManager (upgrade step).
  3. A tool that accepts a target or profile: implement IApplicationRequestHandler in its (host) view and add a run command in RunCommandManager (command, aliases, the input field's validator, TargetApplications).
  4. Docs in Website/docs/application/ (+ the command table in run-command.md), mapped in DocumentationManager; strings and a changelog entry.

New setting

  1. <Tool>_<Name> in SettingsInfo + default in GlobalStaticConfiguration.
  2. UI on the tool's settings page (<Tool>SettingsView.xaml + view model). A new settings page: register it in SettingsViewManager (SettingsName.<Tool>), SettingsViewModel and DocumentationManager.
  3. A tool that must react while it is open subscribes to SettingsManager.Current.PropertyChanged (reference: FirewallViewModel). Options that need explanation get a help icon (HelpImageRectangle + HelpMessage_*).
  4. Document it in the ## Settings section of Website/docs/application/<tool>.md and add a changelog entry.

Documentation

  • Docs in Website/docs/ (Markdown / MDX, relative links, code blocks with a language), screenshots in Website/docs/img/ (../img/<name>.png from docs/application/), new sections in Website/sidebars.js. docs/application/<tool>.md documents toolbar, context menu, shortcuts and every setting / dialog field (Type / Default / Example). Broken anchors fail the website build.
  • Changelog (Website/docs/changelog/next-release.md): every user-visible change gets an entry with a PR or commit link. Keep it short and simple - users skim it:
    • One line per change, usually one sentence (at most two), written for users: what changed and why it matters, not how it was implemented (no thread counts, internal class names, timings, translation details).
    • Merge related changes into one entry (several fixes of one area, the same change in several tools); a merged entry keeps all its PR / commit links. Prefer merging over dropping.
    • Put an entry under the tool it affects (**Tool** heading), changes of several tools at the top of the section.
    • Breaking changes keep every fact users need to adapt (renamed settings, export columns / keys, changed formats).
    • Link the docs (See [Section](../application/<tool>.md#anchor)) only for new features or settings, with existing anchors.