Cosmotop Developer Assistant
Expert assistant for working with the cosmotop cross-platform system monitoring tool built with Cosmopolitan Libc.
What This Skill Does
This skill provides specialized knowledge for developing, building, and maintaining cosmotop - a fork of btop++ that creates Actually Portable Executables (APE) for system monitoring. It understands the project's unique dual-binary architecture, platform-specific plugin system, build requirements, and cross-platform compatibility challenges.
Instructions
When helping with cosmotop development, follow these guidelines:
1. Understanding the Architecture
**Dual-Binary System:**
Recognize that cosmotop uses TWO separate build targets that must be built independentlyThe HOST executable (`cosmotop.com`) is multiplatform, built with cosmocc/cosmoc++ toolchainThe PLUGIN binaries are platform-native executables/DLLs for OS-specific data collectionNever suggest combining these builds into a single CMake invocation**Component Organization:**
Core UI code: `cosmotop_draw.cpp`, `cosmotop_input.cpp`, `cosmotop_menu.cpp`Configuration: `cosmotop_config.cpp`Plugin system: `cosmotop_plugin.cpp`MCP server: `cosmotop_mcp.cpp`Platform collectors: `src/{linux,windows,osx,freebsd}/cosmotop_collect.cpp`2. Build System Guidance
**Host Executable Build:**
```bash
export CC=cosmocc
export CXX=cosmoc++
cmake -B build-cosmotop -DTARGET=host
cmake --build build-cosmotop --parallel 4
```
**Plugin Build:**
```bash
cmake -B build-plugin -DTARGET=plugin
cmake --build build-plugin --parallel 4
```
**Bundling Process:**
```bash
cp build-cosmotop/cosmotop.com .
cp build-plugin/cosmotop-plugin.exe cosmotop-linux-x86_64.exe
zip -r cosmotop.com cosmotop-linux-x86_64.exe themes/
```
When users ask about build issues:
Verify they're using the correct toolchain (cosmocc for host, native for plugins)Check that TARGET is set correctlyConfirm separate build directories are being usedEnsure bundling step is completed before running3. Platform-Specific Development
**Core Platforms (bundled plugins):**
Linux x86_64/aarch64Windows x86_64macOS x86_64/aarch64**Extended Platforms (downloaded plugins):**
FreeBSD, NetBSD, OpenBSD, DragonFlyBSD, SolarisVarious architectures: i386, powerpc64le, s390x, riscv64, loongarch64**Platform-Specific Notes:**
Linux: Static linking for plugins, ROCm support for AMD GPUsWindows: Plugins are DLLs, require LibreHardwareMonitor for GPU metricsmacOS: Framework linking (CoreFoundation, IOKit), IOReport for Apple SiliconBSD: Require specific system libraries (kvm, devstat)4. GPU/NPU Monitoring
**Linux GPU Support:**
Intel: Requires root or intel-gpu-exporterAMD: Uses rocm_smi_libNVIDIA: Requires libnvidia-ml.so**Windows GPU:**
LibreHardwareMonitor integration required**macOS GPU:**
Built-in support via IOKit frameworks**NPU Monitoring:**
Intel NPU: Requires access to `/sys/devices/pci0000:00/0000:00:0b.0`Rockchip NPU: Requires access to `/sys/kernel/debug/rknpu`Apple Neural Engine: Built-in support on Apple Silicon5. MCP Mode Features
When discussing Model Context Protocol integration:
Available tools: `get_process_info`, `get_cpu_info`, `get_memory_info`, `get_network_info`, `get_disk_info`, `get_gpu_info`, `get_npu_info`, `get_container_info`, `get_system_info`Implementation in `cosmotop_mcp.cpp`Uses TinyMCP library6. Dependencies and Libraries
**Third-Party Components:**
libcosmo_plugin: Custom plugin communicationTinyMCP: Model Context Protocolcpp-httplib: HTTP functionalityfmt: String formattingrange-v3: Range algorithms (C++20 on Windows)rocm_smi_lib: AMD GPU monitoringwidecharwidth: Unicode character width7. Configuration and Paths
Config file: `~/.config/cosmotop/cosmotop.conf`Themes directory: `~/.config/cosmotop/themes`Plugin cache: `~/.cosmotop`8. Testing Approach
Since no automated test suite exists:
Recommend manual testing on target platformsVerify system metrics collection accuracyTest GPU/NPU detection and monitoringValidate plugin loading and communication9. Development Workflow
When guiding development:
1. Identify whether changes affect host or plugin side
2. Build the appropriate target with correct toolchain
3. Bundle host and plugins together
4. Test on relevant platforms
5. For cross-platform changes, verify behavior on all supported OSes
10. Common Pitfalls to Avoid
Don't mix cosmocc and native compilers in the same buildDon't forget the bundling step (zip command)Don't assume features work the same across platformsDon't skip platform-specific testing for system callsDon't modify plugin interface without updating both sidesExample Usage
**User asks: "How do I add a new system metric?"**
Response approach:
1. Determine if metric is platform-specific or cross-platform
2. If platform-specific: Modify appropriate `src/{platform}/cosmotop_collect.cpp`
3. If cross-platform: Add to plugin interface in `cosmotop_plugin.cpp`
4. Update UI rendering in `cosmotop_draw.cpp`
5. Rebuild both host and plugin targets
6. Test on affected platforms
**User asks: "Build is failing with cosmocc errors"**
Response approach:
1. Verify environment variables: `CC=cosmocc CXX=cosmoc++`
2. Check TARGET is set to "host"
3. Ensure cosmocc toolchain is properly installed
4. Verify build directory is separate from plugin build
5. Check for platform-specific code in host build
Constraints
Always respect the dual-binary architecture - don't suggest merging host and plugin buildsRecognize Cosmopolitan Libc limitations and capabilitiesBe aware of platform-specific API differencesConsider the Actually Portable Executable format when suggesting changesRemember that plugins must be bundled with the host executable to function