Imported from ZacWalk/platform-h (
AGENTS.md). Install upstream withnpx skills add ZacWalk/platform-h. Copyright stays with the author.
AGENTS.md
platform-h is the platform layer shared by every application in this workspace
(list0, ovrwin, potato, rethinkify-app, crypto-app, stuntcarracer,
equity-app). It is a library with no application of its own.
It ships two static libraries:
| Target | Alias | Source | Contents |
|---|---|---|---|
platform-core |
platform::core, platform::platform |
src/core |
The OS abstraction. Every app links it. |
platform-ui |
platform::ui |
src/ui |
Reusable presentation: widgets, text views, markdown, the agent chat panel. Opt-in. |
platform::platform remains an alias of platform-core because seven repositories
pin this package and acquire it four different ways. Do not remove it.
platform-ui operates on a UTF-8 text buffer the application hands it. It never opens a file, never knows a path, and never names an application.
Non-negotiables
src/core/platform.hincludes no OS headers. Notwindows.h, not transitively. The Windows SDK appears only insrc/core/platform_win.cppandsrc/core/platform_win_audio.cpp.- The API must be expressible on another OS. Nothing Win32-shaped may leak
into a signature: no
HWND, noHRESULT, no hundredths-of-a-decibel volume, no resource IDs. Prefer neutral units — linear gain, normalised pan, Hz, UTF-8string_view. If a concept only makes sense on one platform, it belongs in the app. - App-specific knowledge stays out. No app names, no resource identifiers,
no game constants.
config_set_app_nameexists precisely so the layer never has to know who is calling. - A change here breaks seven repos. Adding to
window_frameorframe_reactoris a breaking change for every app and their test stubs. Build all of them before you consider a change done — see below.platform::platformis an alias every one of them links; it does not move. - Add a test with a capability.
tests/platform_tests.cppandtests/ui_tests.cppare console programs; anything checkable without a window belongs in one of them.
Layout
| File | Contents |
|---|---|
src/core/platform.h |
The whole pf:: surface. Declarations, plus inline text/geometry helpers |
src/core/platform_common.cpp |
Backend-independent implementation (the embedded-resource registry, line_splitter) |
src/core/platform_win.cpp |
Win32 backend: WinMain, message loop, GDI drawing, WIC, WinINet/WinHTTP, dialogs, clipboard, spell check, child processes |
src/core/platform_win_audio.cpp |
XAudio2 backend, isolated from the rest |
src/ui/ui.h |
platform-ui umbrella header |
src/ui/theme.h / .cpp |
The pf::ui::colors table, the theme metrics, the style palette and the heading fonts |
src/ui/text_types.h |
text_location, text_selection, text_style, text_block, highlight_fn |
src/ui/view_host.h |
What a view asks of the application: invalidation, ensure_visible, status |
src/ui/widgets.h |
edit_box, caret_blinker, splitter, custom_scrollbar, edit_box_widget |
src/ui/table_layout.h / .cpp |
Table cell parsing and rendering, shared by the markdown and CSV views |
src/ui/syntax.h / .cpp |
The syntax highlighters; language choice is the caller's |
src/ui/spell.h / .cpp |
The process-wide spell checker and its cache |
src/ui/text_line.h, text_buffer.h / .cpp |
The UTF-8 line and the editing model: lines, selection, undo |
src/ui/markdown.h |
pf::ui::md — the Markdown model, its parser and the HTML reducer |
src/ui/view_base.h → view_text.h → view_doc.h |
The view hierarchy: scrolling, selection and the clipboard, then the caret, wrap and hit testing |
src/ui/view_doc_edit.h, view_doc_readonly.h, view_markdown.h, view_csv.h, view_hex.h |
The views an application shows: editable, read-only, rendered Markdown, CSV tables and bytes |
src/ui/view_list.h |
list_view and list_item — the panel list: rows, selection, hover, keyboard and copy |
src/ui/test_support.h |
Headless fakes — measure_context, draw_context, view_host, window_frame |
cmake/platform_app.cmake |
platform_add_app() — the function apps use to declare themselves |
cmake/embed_resources.cmake |
Turns data files into a generated C++ byte-array TU |
cmake/app.manifest.in |
The manifest every app gets |
tests/platform_tests.cpp |
The platform-core suite (CTest label platform) |
tests/ui_tests.cpp |
The platform-ui suite (CTest label platform-ui) |
Build and test
This repo uses the vendored dd build system. dd has two modes:
CLI mode — the default; each verb runs once and exits:
.\dd.ps1 test # build both configs and run the suite
.\dd.ps1 build debug
.\dd.ps1 doctor --json
MCP mode — .\dd.ps1 mcp turns the process into a stdio JSON-RPC server for an
MCP client, adapting typed requests onto CLI mode. It owns stdout for protocol
messages, so it prints no result envelope and rejects --json. Register it with
.\dd.ps1 ide --mcp.
Project settings live in dd.psd1; dependency pins live in
cmake/dd-dependencies.json (dependencies.owner = 'dd').
To check nothing downstream broke, from the workspace root:
foreach ($r in 'platform-h','list0','ovrwin','potato','rethinkify-app','crypto-app','stuntcarracer') {
Push-Location $r; .\dd.ps1 build release; Pop-Location
}
equity-app also consumes this package, but through its own pinned acquisition
(EQUITY_PLATFORM_SOURCE_DIR), which requires a clean tree at the declared pin.
Build it separately with .\dd.ps1 build both.
Each app finds a sibling ../platform-h checkout automatically, so a local edit
here is picked up by all of them with no publish step.
Adding a capability
- Declare it in
src/core/platform.h, in neutral terms (see rule 2). - Implement it in the backend.
- Add a case to
tests/platform_tests.cppif it can run without a window. - Rebuild every app. If you added a pure virtual to
window_frame, expect to updatestub_window_frameinrethinkify-app/src/tests.cpptoo.
Adding to platform-ui
- It goes in
src/ui/, inpf::ui, reached as#include "ui/<file>.h". - It may use
pf::. It may not name an application, open a file, know a path, or speak a protocol — those belong to the app. - Anything pure gets a case in
tests/ui_tests.cpp. Layout and hit testing are testable without a window becausepf::measure_contextis an interface. - An app opts in with
platform_add_app(<target> UI ...).
Conventions
- Modern C++20 in
snake_case;pf::for everything public. - Comments explain why, in one line. Do not narrate the next line.
- Diagnose failures with
pf::debug_traceand the real error code rather than failing silently. dd.ps1is duplicated in each repo by design — it has to run before CMake, so it cannot come from this package.
