From 7dfb19d1a9b42dba35ea1da2fdf2ea438ecd0bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sun, 11 Oct 2026 15:18:33 -0400 Subject: [PATCH] Bootstrap module, rules and license --- .gitignore | 10 +++++++ AGENTS.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ LICENSE | 21 ++++++++++++++ README.md | 11 ++++++++ go.mod | 8 ++++++ go.sum | 4 +++ 6 files changed, 134 insertions(+) create mode 100644 .gitignore create mode 100644 AGENTS.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2218146 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +/.claude/ +/.wrangler/ +PRD.md +docs/prd/ +TASKS.md +/web/dist/ +/web/node_modules/ +/web/test-results/ +/web/playwright-report/ diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..60c7b27 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,80 @@ +# AGENTS.md + +8bitMyGoUI: pixel-art components in the manner of 16-bit consoles, for MyGo native UI. Go module `git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI`. +Progress truth: `TASKS.md`. Requirements: `PRD.md` and `docs/prd/components-*.md`. + +## Stack + +| Item | Value | +| --- | --- | +| Go | 1.27.1 | +| MyGo | `github.com/egoist/mygo v0.2.10`, pinned in go.mod | +| Font | Ark Pixel Font 12px proportional zh_Hans (OFL-1.1), packed into `pixel/font12.bin` by `tools/fontpack` | +| Web | `cmd/web` built with `GOOS=js GOARCH=wasm`; the browser runs the gallery under `ui.Tester` and blits frames to a canvas | +| Hosting | Cloudflare Workers static assets from `web/dist`; code on Gitea `git.zacharyzhang.com` | + +Read MyGo source before using an API: `$(go env GOMODCACHE)/github.com/egoist/mygo@v0.2.10` (`ui/*.go`, `docs/ui/*.md`). Never guess. + +## Layout + +```text +pixel/ engine: settings, palette, canvas, dither, font, sprites, clock, editor, messages +icon/ hand-placed sprites +/ one component per file, package = folder name +gallery/ registry, demos (demos_.go), app view, invariant tests +cmd/gallery/ native window +cmd/web/ js/wasm host +web/ shell, glue JS, build.sh, Playwright tests; web/dist is build output +tools/fontpack/ BDF to font12.bin +internal/archtest/ import and API rules +``` + +## Tiers + +Imports point down only. Same-tier imports are forbidden. `internal/archtest` enforces it. + +0 pixel · 1 icon · 2 layout, text, display · 3 input, feedback · 4 navigation, data, overlay, datetime, chart, fx · 5 game, chat, media, code, account, files, project, shop, agent, desk, tabletop · 6 gallery · 7 cmd + +## Style rules + +- Draw on the dot grid through `pixel.Canvas`. One dot is `Dot` DIPs. +- Name palette slots, never colors. Every pixel must be a palette color. +- Only axis-aligned rectangles reach the screen: no radius, path, shadow, gradient, opacity, scaled bitmap. +- Tone comes from Bayer dither between two slots. +- Animation steps through `Canvas.Step`, `Canvas.Busy` or `Kit.Tick`. No easing. +- Text through the pixel font only. + +## MyGo rules + +- Use Bases, containers, `List`, `GridView`, `Outline`, `Router`, `Overlay`, `DialogBase`, `PopoverBase`, `FocusGroup`, `Local`, `HandleInput`, `TextCaret`, `Shortcut`, clipboard. Full list: PRD §2.4. +- Never call styled widgets, `Background`, `Border*`, `Radius`, `Shadow`, `Gradient`, `Opacity`, `Stripes`, `Tooltip`, `Menu`, `ContextMenu`, `Transition`, `Animate*`, `Loop`, `c.Toast*`, or painter drawing other than `Fill`. Only `pixel` calls `After`. +- A disabled element never paints. Interactive components draw on an enabled shell; the base inside fills it, carries behavior, label and `Disabled`, and turns MyGo's focus ring off. + +## Component rules + +- Signatures and results: PRD §5.1. Zero options give the default look. Sizes in options are dots. +- `k := pixel.K(c)` once per component; layout sizes through `k.D(n)`. +- Copy shown by a component comes from `k.Msg`; business copy comes from the caller. +- Fail fast: panic on programmer errors such as bad options. Never swallow an error. +- Composites log state changes: `slog.Debug("8bit: ", …)`. Never log secrets. +- No cross-frame `*ui.Element` caching. No goroutines touching elements. +- Files under 500 lines. Comments: one line, ten words at most, only when needed. No dead code, no versioned APIs. + +## Gallery entry + +Each component adds one `Entry` in `gallery/demos_.go`: ID, Name, Zh, Category, Summary, Demo. The demo reports every event through `log`. The code panel shows the demo function's own source. + +## Tests + +- `go vet ./... && go test ./...` before reporting done. +- Behavior tests drive `ui.Tester` and assert values. +- `gallery` checks every entry under every palette: only palette colors, whole dots. `PIXEL_SHOTS= go test ./gallery -run TestInvariants` writes PNGs for visual review. +- Web: `web/build.sh`, then `npx playwright test` in `web/`. + +## Review + +Each TASKS.md item is reviewed in a Herdr pane split to the right, by `codex --yolo -m gpt-6.1-sol -c model_reasoning_effort=high -c service_tier=fast`. At most three rounds. The reviewer reports defects against PRD and this file, ends with `VERDICT: PASS` or `VERDICT: FAIL`, and does not reject work for missing enhancements. + +## Secrets + +The Gitea token lives only in the environment (`GITEA_TOKEN`). Never write it to a file, a commit or a log. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fb66bc9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 8bitMyGoUI contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cb51982 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# 8bitMyGoUI + +16 位游戏风格的像素组件库,建立在 [MyGo](https://mygo.egoist.dev/docs/ui) 原生 UI 之上。每个点落在点阵上,颜色只来自 16 格调色板,没有抗锯齿。轮换调色板,同一画面就有昼夜和四季。 + +展示页把同一份 Go 代码编译成 WebAssembly,在浏览器里逐点绘制。 + +开发中。进度见仓库提交。 + +## 许可 + +MIT。 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..cda7b73 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI + +go 1.27.1 + +require ( + github.com/ebitengine/purego v0.11.1 // indirect + github.com/egoist/mygo v0.2.10 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3f55274 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/ebitengine/purego v0.11.1 h1:2zpWRSQNVKN4eKsKO9eM1ILDgWfYMY9GwqRmK6XeQ/0= +github.com/ebitengine/purego v0.11.1/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ= +github.com/egoist/mygo v0.2.10 h1:Mfe6SpQngC9kLjrejpGM7L/k3Q62BdBAyJ8MrHfL6bQ= +github.com/egoist/mygo v0.2.10/go.mod h1:1sRzZ6jEhKE7iuEQXjyoXDgxyxQ1uTgMHDcDKZvoDIU=