keel

module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: AGPL-3.0

README

Keel

Keel

用纯 Go 写桌面界面,不需要 HTML、CSS、JavaScript 或 WebView。界面由 Gio 绘制;Gio 没有的原生能力(权限、截图、合成输入、全局快捷键)在 native/ 下。

type hello struct {
    name   *kit.InputView
    result string
}

func (h *hello) Render(cx *el.Context) el.Element {
    return el.Div().P(24).Gap(12).Child(
        h.name.Render(cx),
        el.Div().Row().Child(kit.Button("打招呼", func() { h.result = "你好," + h.name.Value() }).Render(cx)),
        el.Text(h.result),
    )
}

window.Open(window.Options{Title: "Hello", Content: el.Root(&hello{name: kit.Input("你的名字")})})
window.Main()
go run ./examples/hello
go run ./examples/multiwindow
go run ./examples/hotkey
go run ./examples/chat -sample=all
go run ./examples/components   # 组件库:侧栏选择、搜索
go test -race ./...

需要 Go 1.26+;macOS 上需要 Xcode Command Line Tools。

模块

模块 做什么
ui/core 地基:Widget 接口、回调、线程规则
ui/theme 颜色、字号、字体
ui/locale 框架文字,中英文切换
ui/el GPUI 风格:视图 + 链式样式元素 + flexbox
ui/kit 组件:Button、Input、Table、Dialog、Chart …
ui/window 窗口:Open、Main、快捷键、截图
ui/markdown Markdown 渲染,针对 AI 流式输出优化
native/permission 检查、申请系统权限
native/screen 显示器列表、截图
native/input 合成鼠标、键盘事件
native/hotkey 全局快捷键

另有工具 cmd/keel-mcp:MCP server,让 Agent 对应用做端到端测试(启动、读元素、点击、输入、滚动、截图),见 Agent 端到端测试。

依赖只往下走、同层不互相引用,ui 和 native 互不依赖,由 go test ./... 里的边界测试保证。每个模块目录下有 README。总览见 ui/README.md 和 native/README.md。

文档

完整文档在 docs/:

授权

Keel 采用 AGPL-3.0 与商业授权双授权。开源项目和个人自用按 AGPL 免费使用;在闭源软件里使用 Keel 需要购买商业授权。详见 LICENSING.md,参与贡献见 CONTRIBUTING.md。

Directories

Path Synopsis
cmd
keel-mcp command
Command keel-mcp is an MCP server that lets an agent run end-to-end tests against a Keel app: launch it, read what is on screen, click, type, press keys, scroll and take screenshots.
Command keel-mcp is an MCP server that lets an agent run end-to-end tests against a Keel app: launch it, read what is on screen, click, type, press keys, scroll and take screenshots.
examples
chat command
Chat shows streaming Markdown answers the way an AI assistant produces them: text arrives a few characters at a time, the view follows it to the bottom unless you scroll up, and the answer can be stopped.
Chat shows streaming Markdown answers the way an AI assistant produces them: text arrives a few characters at a time, the view follows it to the bottom unless you scroll up, and the answer can be stopped.
components command
Components is the kit gallery: a sidebar of every component, the selected one beside it.
Components is the kit gallery: a sidebar of every component, the selected one beside it.
frameless command
Frameless draws its own title bar: the window has no system title bar, the app puts a search box and buttons in the bar, and its empty part moves the window.
Frameless draws its own title bar: the window has no system title bar, the app puts a search box and buttons in the bar, and its empty part moves the window.
hello command
hotkey command
Hotkey shows a system-wide shortcut and a background goroutine updating the UI.
Hotkey shows a system-wide shortcut and a background goroutine updating the UI.
multiwindow command
notification command
orders command
Orders is a small order desk: search and filter a table, sort it, select rows with the mouse or keyboard, delete with confirmation, add orders through a form, and see totals per status.
Orders is a small order desk: search and filter a table, sort it, select rows with the mouse or keyboard, delete with confirmation, add orders through a form, and see totals per status.
internal
deps
Package deps only holds a test that enforces the module boundaries listed in docs/architecture.md: each module may import only what its README declares.
Package deps only holds a test that enforces the module boundaries listed in docs/architecture.md: each module may import only what its README declares.
site command
Command site builds Keel's documentation website: every Markdown file in docs/ and every module and example README becomes a static HTML page, the component pages embed the live component gallery (the WebAssembly build of examples/components), and a search index covers all of it.
Command site builds Keel's documentation website: every Markdown file in docs/ and every module and example README becomes a static HTML page, the component pages embed the live component gallery (the WebAssembly build of examples/components), and a search index covers all of it.
Package native holds the errors shared by Keel's platform capabilities.
Package native holds the errors shared by Keel's platform capabilities.
clipboard
Package clipboard reads a bounded snapshot of text, encoded images and file paths without linking to the UI.
Package clipboard reads a bounded snapshot of text, encoded images and file paths without linking to the UI.
hotkey
Package hotkey registers system-wide shortcuts that fire even when another application is in front.
Package hotkey registers system-wide shortcuts that fire even when another application is in front.
input
Package input synthesizes mouse and keyboard events.
Package input synthesizes mouse and keyboard events.
internal/sys
Package sys binds the platform code.
Package sys binds the platform code.
internal/wlclip
Package wlclip reads the Wayland clipboard through an application's own wl_display.
Package wlclip reads the Wayland clipboard through an application's own wl_display.
notification
Package notification posts local operating-system notifications independently of Keel's UI.
Package notification posts local operating-system notifications independently of Keel's UI.
permission
Package permission checks and requests macOS privacy permissions.
Package permission checks and requests macOS privacy permissions.
screen
Package screen lists displays and captures screenshots.
Package screen lists displays and captures screenshots.
ui
base
Package base holds the behavior of Keel's components without their look: keyboard navigation over a list, type-to-find, multi-selection with ranges, and open/closed state.
Package base holds the behavior of Keel's components without their look: keyboard navigation over a list, type-to-find, multi-selection with ranges, and open/closed state.
core
Package core is the foundation every UI module builds on: what a Widget is, how a component runs a user callback, and how other goroutines change the UI.
Package core is the foundation every UI module builds on: what a Widget is, how a component runs a user callback, and how other goroutines change the UI.
el
internal/editorstyle
Package editorstyle supplies the shared input appearance for widget and el.
Package editorstyle supplies the shared input appearance for widget and el.
internal/imageload
Package imageload loads images off the UI thread and draws them with a placeholder until they arrive.
Package imageload loads images off the UI thread and draws them with a placeholder until they arrive.
internal/inputcontent
Package inputcontent keeps editable text and atomic references together.
Package inputcontent keeps editable text and atomic references together.
internal/loop
Package loop owns the state shared by every window: one lock that serializes rendering and callbacks, a queue of updates from other goroutines, and the windows to redraw.
Package loop owns the state shared by every window: one lock that serializes rendering and callbacks, a queue of updates from other goroutines, and the windows to redraw.
internal/uitest
Package uitest drives UI code without a window: it lays it out through a real Gio input router, so tests click and type as the platform would.
Package uitest drives UI code without a window: it lays it out through a real Gio input router, so tests click and type as the platform would.
kit
Package kit provides components built on ui/el.
Package kit provides components built on ui/el.
locale
Package locale holds the text Keel itself shows or reports to agents: button captions such as 确定 and 复制, accessible names such as 关闭, placeholders and counts.
Package locale holds the text Keel itself shows or reports to agents: button captions such as 确定 and 复制, accessible names such as 关闭, placeholders and counts.
markdown
Package markdown renders Markdown as ui/el elements, built for AI chat: text that streams in a few characters at a time.
Package markdown renders Markdown as ui/el elements, built for AI chat: text that streams in a few characters at a time.
plot
Package plot provides scales, data layouts and immediate-mode chart drawing.
Package plot provides scales, data layouts and immediate-mode chart drawing.
theme
Package theme holds the colors, text sizes and fonts every UI module reads.
Package theme holds the colors, text sizes and fonts every UI module reads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL