Imported from mattemangia/GeoscientistToolkit (
AGENTS.md). Install upstream withnpx skills add mattemangia/GeoscientistToolkit. Copyright stays with the author.
AGENTS.md
Guidance for AI agents working in the GAIA (Geoscience Analysis, Imaging & Automation) codebase. GAIA is a cross-platform .NET 10 desktop application for geoscientific data analysis, visualization, and simulation, built on ImGui.NET + Veldrid with a custom scripting language (GeoScript).
Note: Much of the in-repo documentation (README, wiki,
docs/CODEBASE_ANALYSIS.md) still references ".NET 8.0". The solution was upgraded to .NET 10 (net10.0). TrustGAIA.sln/*.csprojover docs.
Build, Run, Test
# Restore + build the entire solution (what CI does)
dotnet restore GAIA.sln
dotnet build GAIA.sln -c Release --no-restore
# Build only the main app (faster feedback loop)
dotnet build GAIA.csproj
# Run the desktop app
dotnet run --project GAIA.csproj
# ...or with CLI flags / a project file:
dotnet run --project GAIA.csproj -- --ai-diagnostic
dotnet run --project GAIA.csproj -- --gui-diagnostic
dotnet run --project GAIA.csproj -- --test=all
dotnet run --project GAIA.csproj -- --test=SlopeStability_GravityDrop_MatchesAnalyticalFreeFall
dotnet run --project GAIA.csproj -- path/to/project.gtp
Tests
The verification suite lives in Tests/VerificationTests/ and uses xUnit ([Fact], global using Xunit;).
Tests exercise the real GAIA.Analysis.* solvers and compare results against peer-reviewed literature
(sources + tolerances documented in Tests/VerificationTests/TEST_README.MD and per-test Reports/*.md).
# Standard xUnit run via dotnet test
dotnet test Tests/VerificationTests/VerificationTests.csproj
# Standalone runner (no test SDK required) — used by the installer bundle
dotnet run --project Tests/VerificationTestsRunner/VerificationTestsRunner.csproj -- [filters]
VerificationTestsRunner discovers/runs VerificationTests via xunit.runner.utility and is what the
BuildVerificationTests MSBuild target (in GAIA.csproj) copies into publish output so --test=...
works in shipped binaries. SkipVerificationTests=true is set on the main project by default, so normal
builds do not trigger the test-bundling target.
Other projects: Tests/BenchmarkTests/ (commercial-software comparisons) and
VerificationTests/RealCaseVerifier/ (real-data verification harness).
Solution Architecture
GAIA.sln contains multiple projects that intentionally share source files rather than always using
project references. This is the single most error-prone aspect of the build — read GAIA.csproj before
assuming how something compiles.
| Project | Type | Purpose |
|---|---|---|
GAIA (GAIA.csproj, root) |
Exe | Main app: ImGui + Veldrid desktop UI, all datasets, simulations, GeoScript |
GAIA.Api (Api/) |
Library | Headless automation DLL wrapping loaders, GeoScript, verification sims (see Api/README.md) |
NodeEndpoint (NodeEndpoint/) |
ASP.NET Core Exe | Distributed compute server. Cherry-picks .cs files from main project via <Compile Include="..\..."> to avoid UI deps |
GAIA.Gtk (GTK/) |
Exe | Alternative GTK frontend referencing the main project |
InstallerWizard / InstallerPackager |
Exe | TUI installer + packaging tool for dotnet publish outputs |
VerificationTests / BenchmarkTests / RealCaseVerifier |
Test | xUnit verification suites |
Critical source-sharing rules (gotchas)
-
The root
GAIA.csprojexcludes all sibling projects' folders with<Compile Remove="NodeEndpoint\**" />,<Compile Remove="Api\**" />,<Compile Remove="GTK\**" />,<Compile Remove="Tests\**" />, etc. If you add a new sibling project, you must add a<Compile Remove>here or you'll hit duplicate-attribute errors. -
AddIns/Development/**is compiled in Debug but removed in Release (<Compile Remove="AddIns\Development\**\*.cs" />underCondition="'$(Configuration)' == 'Release'"). Development add-ins ship only in debug builds. -
Data/TwoDGeology/Geomechanics/TwoDGeomechanicsGtkViewer.csis excluded from the main project but included inGAIA.Gtk— it has GTK dependencies. Don't move non-GTK code into it. -
NodeEndpointdoes not referenceGAIA.csproj. It selectively<Compile Include>s headless files (Network, Settings, OpenCL,Analysis/Geomechanics/*CPU*.cs,Analysis/AcousticSimulation/*CPU*.cs, etc.). Any UI-dependent file added to those folders will break the NodeEndpoint build. There's a comment in its csproj noting e.g.PNMDataset.cswas excluded for "91 errors due to missing TableDataset UI dependencies". -
Assembly info is generated manually (
GenerateAssemblyInfo=false,GenerateTargetFrameworkAttribute=falseinDirectory.Build.props+ every csproj). This is required because shared source files would otherwise emit duplicateAssemblyVersion/TargetFrameworkattributes across projects. Keep these flagsfalse.
Code Organization & Layering
Namespaces mirror folders (GAIA.Data, GAIA.UI, GAIA.Business, GAIA.Analysis.*, GAIA.Util, GAIA.Settings).
File-scoped namespaces are used throughout.
Program.cs / Application.cs Entry point, window + graphics device lifecycle, splash/loading screens
UI/ ImGui windows, panels, viewers, dialogs (ImGuiController, ImGuiDockBuilder)
Data/ Dataset model + per-type datasets, Loaders/, Exporters/
Data/Loaders/ IDataLoader implementations + DataLoaderFactory (extension→loader mapping)
Analysis/ Simulation engines (CPU + GPU variants per domain)
Business/ Domain logic: GeoScript engine, MaterialLibrary, CompoundLibrary, ProjectManager
Scripting/GeoScript/ GeoScript language runtime (lexer/parser/AST) + Operations
AddIns/ Plugin framework (IAddIn, AddInManager) + sample/dev add-ins
Network/ Distributed node discovery/messaging
Settings/ AppSettings (JSON) + SettingsManager singleton
Util/ Logger, image decoders/exporters, VeldridManager, cross-platform helpers
OpenCL/, Shaders/ GPU kernels + GLSL/SPIR-V shaders
The Dataset pipeline (central abstraction)
Everything revolves around Data/Dataset.cs:
DatasetTypeenum + abstractDataset(Load(),Unload(),GetSizeInBytes()).- To add a dataset type: add the enum value, create a subclass in
Data/<Type>/, register a loader inData/Loaders/DataLoaderFactory.cs, and wire UI viaUI/DatasetUIFactory.cs+IDatasetViewer/IDatasetTools/IDatasetPropertiesRenderer. Seewiki/Developer-Guide.mdfor the full recipe. DataLoaderFactorymaps file extensions → loader types. Some extensions are ambiguous (.tif/.tiff→ SingleImage and CtImageStack;.wav→ Audio and AcousticVolume). PasspreferredTypeto disambiguate; otherwise last-registered wins, with a hardcoded.tif→SingleImage default.
Simulation module convention
Analysis modules under Analysis/<Domain>/ follow a split-file convention (not partial classes — separate files):
MyDomainParameters.cs Input configuration (POCO)
MyDomainResults.cs Output data
MyDomainSimulationCPU.cs CPU solver
MyDomainSimulationGPU.cs OpenCL GPU solver (optional)
MyDomainTool.cs / *UI.cs ImGui interface wrapper
Tests construct parameters/results directly and call the CPU solver (e.g. SlopeStabilitySimulator(dataset, parameters).RunSimulation()),
so you can verify numerics without the UI.
GeoScript — two command systems (important)
GeoScript is a pipeline DSL (dataset |> COMMAND key=value). There are two separate registries — don't confuse them:
-
Scripting/GeoScript/Operations/—IOperation+OperationRegistry(static ctor). Image/table/GIS/generic operations used by the pipeline runtime. Registered perDatasetType. -
Business/GeoScript.cs—IGeoScriptCommand+CommandRegistry(static ctor inBusiness/GeoScript.cs). This is the larger system: ~150 commands across tables, GIS, thermodynamics, petrology, PhysicoChem, PNM, images, CT, borehole, seismic, mesh, etc. Commands live inBusiness/GeoScript/Commands/<Domain>/and inBusiness/GeoScript<Domain>Commands.cspartial-style files.
Both registries are populated by manually new-ing each command in a static constructor — there is NO reflection-based
auto-discovery. When you add a command, you must add it to the appropriate list in the static constructor or it won't be found.
Key GeoScript helpers:
GeoScriptArgumentParser(Business/GeoScriptArgumentParser.cs) —key=valueparsing withGetString/GetFloat/GetDouble/GetInt/GetBool, invariant culture, and variable resolution against theGeoScriptContext.GeoScriptEngine.ExecuteAsync(script, inputDataset, contextDatasets)— main entry point.UI/GeoScriptInterpreter.cs— the in-app REPL terminal (separate from the engine).
Conventions & Patterns
- C# style: file-scoped namespaces,
ImplicitUsingsenabled,Nullableis disabled in the mainGAIAproject (but enabled in tests, API, NodeEndpoint, GTK). Be aware nullable annotations are inconsistent across the codebase. AllowUnsafeBlocksis on (ImGui callbacks, GPU interop, image buffers).- Singletons:
ProjectManager,AddInManager.Instance,SettingsManager.Instance,GlobalPerformanceManager.Instance,Logger(static). State is process-global. - Logging: always use
GAIA.Util.Logger(Logger.Log/LogWarning/LogError). It's a thread-safe static queue + optional file writer initialized from settings. There's an explicitusing LogLevel = GAIA.Settings.LogLevel;alias to avoid clashing withMicrosoft.Extensions.Logging.LogLevelin the ASP.NET Core projects — preserve that alias. - UI: inherit
BasePanelfor dockable/pop-out panels (it manages OS-window pop-out viaPopOutWindow). Dataset UIs implementIDatasetViewer/IDatasetTools/IDatasetPropertiesRenderer. ImGui docking is enabled (DefineConstants=IMGUI_HAS_DOCK_BUILDER). - Graphics:
VeldridManager(Util/) holds the shared device/window.Application.Run()tries platform-default backends with explicit fallbacks (D3D11 → ... on Windows; Vulkan/OpenGL on Linux/macOS). macOS picks up HomebrewlibSDL2.dylibvia theCopyMacSDL2publish target. - Warnings are heavily suppressed:
Directory.Build.propssets<WarningLevel>0</WarningLevel>and every csproj carries a long<NoWarn>list (CS86xx nullability, CS0169/CS0414 unused fields, CA1416 platform, etc.). Don't be alarmed by what looks like unaddressed warnings — but also don't rely on the compiler to catch nullability issues in the main project.
Platform / Dependency Notes
- OpenCV (
OpenCvSharp4) uses different runtime packages per OS/RID — Windows,linux-x64,linux-arm64,osx-x64, andosx-arm64each resolve to a different NuGet package via MSBuild conditions inGAIA.csproj. When publishing, always pass a-r <RID>(e.g.-r linux-x64), or the wrong/missing native runtime will be selected. - ONNX Runtime: GPU package (
Microsoft.ML.OnnxRuntime.Gpu) forwin-x64/linux-x64; CPU package for ARM64/macOS/no-RID. AI segmentation models (SAM2, MicroSAM, Grounding DINO) are optional — seeONNX/README.mdandprepare-onnx.sh/.cmd. - GDAL +
MaxRev.Gdal.MacosRuntime.Minimalfor cross-platform geospatial.NetTopologySuite/ProjNETfor vector/projections. - Native deps on Linux/macOS: SDL2, OpenCV, Vulkan/OpenGL drivers are expected to be system-installed (see
docs/DEPENDENCIES.md). - RuntimeIdentifiers:
win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64.
Where to look first
- Architecture deep-dive:
docs/CODEBASE_ANALYSIS.md(module map, dataset hierarchy, tech stack). - Extending the app:
wiki/Developer-Guide.md(add dataset type, add analysis module, add GeoScript command, UI patterns). - GeoScript language:
GEOSCRIPT_MANUAL.md,docs/GEOSCRIPT_IMAGE_OPERATIONS.md,wiki/GeoScript-Manual.md. - User onboarding flow:
START_HERE.md→GUIDE.md. - Per-domain docs:
docs/(e.g.SLOPE_STABILITY_SIMULATION.md,DUAL_PNM_IMPLEMENTATION.md,ORC_SYSTEM_GUIDE.md) andwiki/(feature wikis). - API usage:
Api/README.md(headless automation examples).
Multi-agent system
GAIA ships six specialised, directly-activatable agents. Each agent enforces ALWAYS-ON online verification against authoritative peer-reviewed sources and can innovate/contribute to the scientific community.
Canonical source
.agents/*.md is the single source of truth. Run bash scripts/sync-agents.sh to distribute to .claude/agents/ and .cursor/agents/.
| Agent | File | Domain |
|---|---|---|
geotechnical-engineer |
.agents/geotechnical-engineer.md |
Soil/rock mechanics, slope stability (3D DEM + 2D), triaxial simulation, Hoek-Brown/Mohr-Coulomb, bearing capacity, damage mechanics |
geophysical-engineer |
.agents/geophysical-engineer.md |
Seismic processing (SEG-Y), acoustic FDTD simulation, earthquake wave propagation, thermal conductivity, rock physics |
geology-interpreter |
.agents/geology-interpreter.md |
Stratigraphy (8 national + international systems), structural restoration, borehole correlation, geological consistency gates |
ai-vision-engineer |
.agents/ai-vision-engineer.md |
ONNX AI segmentation (SAM2, MicroSAM, Grounding DINO), NeRF training (Instant-NGP), texture classification, CT/image AI pipelines |
frontend-builder |
.agents/frontend-builder.md |
ImGui.NET + Veldrid UI, dock layouts, pop-out windows, dataset viewer/tools/properties panels, screenshot/PNG export |
photogrammetry-specialist |
.agents/photogrammetry-specialist.md |
SfM pipeline (real-time + offline), SuperPoint/LightGlue/MiDaS, SIFT SIMD, dense reconstruction, mesh generation, georeferencing |
How agents work together
Each agent is directly activatable and owns its domain end-to-end. Typical collaboration:
- Domain agents (geophysicist, geologist, geotechnical engineer) specify what must be verified/built, with references and diagnostic requirements.
ai-vision-engineerimplements the ONNX/NeRF/segmentation architecture and inference pipeline.frontend-builderimplements the UI, visualisation, and export from the domain agents' specifications.photogrammetry-specialistowns the 3D reconstruction pipeline end-to-end.
All agents share two operating axes: Verify → Certify → Defend (trust) and Innovate (frontier). Every claim must be verified online or labeled VERIFY/UNVERIFIED-FORBIDDEN.