agentleFS
Lugia123Lugia123/polter/windows/AGENTS.md

polter / windows

AGENTS.md15 starsChanged 9 months agoMITView on GitHub

Two crates live here, deliberately separate: host/ declares polter-split-tree as a path dependency and calls it: the tab model holds a Tree per tab and splits go through tree.insert (host/src/tabs.rs:2087, Tree imported at host/src/tabs.rs:37). It is a dependency rather than a copy because copying would throw away the reason the algorithm is testable on macOS, and would create a second copy to keep in agreement -- this directory already paid once for a fork that had to be merged back…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,691 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository5 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read the header comment of each before changing it: the contracts that wgl.zig and TSF impose on this host are written there, and not one …

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Polter on Windows

Two crates live here, deliberately separate:

host/the application shell -- windows, tabs, keyboard, IME, libghostty
split-tree/the split layout algorithm, ported from SplitTree.swift. Zero dependencies on purpose, so it is testable with cargo test on the machine the port is written on rather than only on the Windows box.

host/ declares polter-split-tree as a path dependency and calls it: the tab model holds a Tree per tab and splits go through tree.insert (host/src/tabs.rs:2087, Tree imported at host/src/tabs.rs:37). It is a dependency rather than a copy because copying would throw away the reason the algorithm is testable on macOS, and would create a second copy to keep in agreement -- this directory already paid once for a fork that had to be merged back by hand.

One surface, one HWND -- and what that forces

A libghostty surface is bound to the HWND it was created with for its whole life, and wgl.zig takes a CS_OWNDC device context for that window and keeps it until the context is destroyed.

So a split on Windows is necessarily several child windows, and cannot be one surface drawing into several regions. macOS can nest NSViews inside a single surface's view, so the SwiftUI side is free to treat a split as a layout detail; here it is a window-management fact. Anyone arriving from the macOS code will reach for "draw two panes in one surface" first, and that wall is where they will stop.

The same fact is why a tab is a child window rather than a repaint, and why tabs.rs is a tree of leaves each owning one HWND plus one surface.

Two more consequences, both of which cost a real-machine round trip to find:

  • A surface window must be created at its final size before ghostty_surface_new; a later set_size does not repair it. See dev-docs/windows/development.md section 5.2, item 4.
  • Identity is PaneId / TabId out of one shared counter, never an index. Panes and tabs are reordered and removed, and an index quietly starts naming a different one.

[profile] belongs in windows/Cargo.toml, not in a member. Cargo ignores a member's profile inside a workspace and only warns; the symptom is a release binary that quietly went back to unwinding panics.

host/ is the Windows application shell: a Rust binary that opens the windows, owns the tabs, the keyboard and the input method, and drives the terminal through libghostty's C API. It is to Windows what macos/ is to macOS -- the shared core stays in src/, and nothing here is built by zig build.

Build

windows/ is a Cargo workspace; build from here, not from a member.

cd windows
cargo build --release --target x86_64-pc-windows-gnu -p polter-host
cargo test -p polter-split-tree        # native, runs anywhere
  • -gnu, not -msvc. The core is built with Zig's mingw-w64 target and the two have to agree.
  • The target directory must not contain a space. dlltool splits its arguments on whitespace, so a checkout under a path like ~/claude code/ghostty -- the space is the whole point of the example -- fails during dependency compilation with can't open ...dllh.o, before any of this code is looked at. Build with CARGO_TARGET_DIR pointing somewhere without spaces. Two people hit this independently in one night and both first read it as a broken dependency.

The host loads two DLLs at runtime: ghostty-internal.dll (the surface API) and ghostty-vt.dll (the width table the IME needs). Both must sit next to polter-host.exe. There is no import library, which is why every entry point is resolved with GetProcAddress in main.rs.

Names

User-visible strings are Polter -- window classes, default title, log header, binary name. Internal artifacts keep the upstream Ghostty names, so merging upstream stays cheap. See dev-docs/windows/development.md section 4.2; the Windows-only places that are easy to miss (window class, AppUserModelID, mutex, registry) are listed there.

Files

main.rslibghostty startup, the frame window, the TSF-aware message pump, the action callback
tabs.rsthe tab model, one HWND per surface, the queued window mutations, the surface window procedure
keys.rsWindows key events to ghostty_surface_key, and the host accelerators
tsf.rsthe ITextStoreACP the IME composes into
ffi.rsthe hand-written C ABI, with the measured struct sizes asserted at compile time

Read the header comment of each before changing it: the contracts that wgl.zig and TSF impose on this host are written there, and not one of them fails loudly when broken.

Where the ground truth is

dev-docs/windows/status.md -- what is verified on a real machine and what is still owed. Claims there are marked 实测 or not; unmarked means untested.

提交前要跑的检查

windows/tools/ 下每一个 .py 都是一道闸,提交前全部跑一遍——不是挑着跑:

for t in windows/tools/*.py; do python3 "$t" || echo "FAILED: $t"; done
for t in tools/*.py;         do python3 "$t" || echo "FAILED: $t"; done   # 仓库根那几道

这里不列它们的名字,也不列个数。 上一版文档写了「三个 lint」并把名字抄了一遍, 当天就多了第四个,而那句话没人改——一份会过期的清单比没有清单更糟, 因为读的人以为它是全的。glob 不会过期。

⚠️ 第二行原本写的是 python3 tools/no-local-identifiers.py——点了名。 于是仓库根新增第二道闸(translations-still-attach.py,任务 309)时,它不在任何人 的清单上,而这一节自己刚说过点名会过期。换成 glob,理由和上一句一模一样。 仓库根的 tools/ 里还有 .sh,glob 只取 .py,那是有意的:那些不是闸。

读输出,不要只读退出码:其中几道是棘轮——数字比基线低也会失败, 消息会告诉你把基线改成多少。no-local-identifiers.py 还带一个正控制。

许多闸打一行 probe self-test: OK,那是它在说自己的读取器还认得被测的形状; 打了这一行的闸,它不出现就说明检查器本身没工作——那时下面的判定一个字都不算数。 ⚠️ 但不是每道闸都打这一行,所以「没有这一行」本身不是坏消息。 原话写的是「每一道闸都带自我检查,那一行不出现就说明检查器没工作」, 而今天七十多道里有二十几道根本不打——照那句话读,会把一批正常的闸判成坏的。 要知道某一道有没有自检,去读那一道;这里不写个数,理由和上面 glob 那条一样。

⚠️ 自检通过不等于检查器还看得见被测对象。 the-frames-permit-comes-back.py 栽过:上游把 swap_chain 改成 optional、写法多了一个 .?,它的正则就再也匹配不上, 于是它对着一棵正确的树喊「根本没有归还许可」。自检当时是 OK 的, 因为探针和被测代码是同一种写法——探针跟着被测对象一起写,就测不出写法变了。 所以探针要连不再使用的和新出现的拼法一起放,别只放今天这一种。

⚠️ 在一棵已经红的树上做地板注入时,比对具体那一行,不要看退出码: 树本来就是红的,于是任何地板都看起来响了。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.