Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cursor/rules/create-game.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Game `render()` output becomes a PS **page** via `user.pageHTML` (`src/ps/games/
**Measure before you ship UI:**

1. Point `src/ps/games/test.tsx` at your `render` with a **stress mock** — not an empty board. Include max realistic tray size, selected piece, orientation row, and a generous `validAnchors` / valid-move list.
2. `npm run debug` — watcher logs `HTML N / 99500 (pct%)` (`src/ps/games/debug.ts`). Debug page shows `HTML {HTML_LENGTH} / {HTML_LIMIT}` (`scripts/debug-games/templates/page.html`).
2. `bun run debug` — watcher logs `HTML N / 99500 (pct%)` (`src/ps/games/debug.ts`). Debug page shows `HTML {HTML_LENGTH} / {HTML_LIMIT}` (`scripts/debug-games/templates/page.html`).
3. If over **80%**, shrink HTML before polishing pixels. Re-measure after every structural change.

**Shrink HTML without ugly UI** (prefer these over shrinking the board or removing affordances):
Expand Down Expand Up @@ -176,7 +176,7 @@ Do **not** rely on CSS classes or external stylesheets — game HTML is inline-o
1. Point `test.tsx` at the new `render` (Azul in that file is the N-player example).
2. Build a **stress mock** — worst realistic `RenderCtx` (full tray, selection UI, many valid moves). Check HTML length (see **HTML page size** above); must be **under ~80%** of `MAX_PAGE_HTML_LENGTH`.
3. `jsxToHTML(render.bind({ msg: 'test', simpleMsg: 'test' })(...))` — same path production uses.
4. `npm run debug` — `http://localhost:8081`, live-reload 8082, Desktop/Mobile/Ruka widths. Console + page header show `HTML N / 99500`.
4. `bun run debug` — `http://localhost:8081`, live-reload 8082, Desktop/Mobile/Ruka widths. Console + page header show `HTML N / 99500`.
5. Clicks do not play; layout only.

**Stale HTML is common.** The watcher may not refresh `scripts/debug-games/live/page.html` after render changes — hard refresh is not enough if the file itself is old. Regenerate manually (run `test()` + replace `{HTML}` in the template), then open `localhost:8081/page.html` in a browser. Do not assume layout is correct until you have seen the live page.
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/ps/__tests__/games/html-snapshots/*.html text eol=lf
13 changes: 6 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ jobs:
test:
strategy:
matrix:
node-version: [24]
bun-version: [1.4.3]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Use Bun ${{ matrix.bun-version }}
uses: oven-sh/setup-bun@v2
with:
cache: npm
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
bun-version: ${{ matrix.bun-version }}
- run: bun install
- run: bun run test
8 changes: 4 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ bash <<EOF
set -e
TO_PRETTIFY="$(git diff --diff-filter=ACMTUXB --name-only --staged | grep -E -e '\.[jt]sx?$' -e '\.md$' -e '\.html$' -e '\.json$' || :)"
if [[ -n "\$TO_PRETTIFY" ]]; then
npm run prettify -- \$TO_PRETTIFY
bun run prettify -- \$TO_PRETTIFY
git add -- \$TO_PRETTIFY
fi
npm run test:staged
FAIL_ON_PENDING=true npm run notify-unpushed -- src/secrets
npm run secrets-check
bun run test:staged
FAIL_ON_PENDING=true bun run notify-unpushed -- src/secrets
bun run secrets-check
EOF
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ docs.

## System Requirements and Setup

PartBot requires Node.js v18+ (v16+ may work but v18+ is recommended) to run, and uses `npm` as the package manager.
PartBot requires [Bun](https://bun.sh) v1.4.3+ to run.

To install, clone this repository and install dependencies.

```bash
$ git clone https://github.com/PartMan7/PartBot.git PartBot
$ cd PartBot
$ npm install
$ bun install
```

This will also run the `prepare` script, which installs Husky hooks and patches TypeScript.
Expand All @@ -35,11 +35,11 @@ the environment variables. The full list of supported env variables is below:

## Running

You can start the chatbot using `npm start`.
You can start the chatbot using `bun start`.

## Testing

Currently, PartBot's tests are only a lint test (`npm run lint`) and TypeScript validity (`npm exec tsc`). These will
Currently, PartBot's tests are a lint test (`bun run lint`), type checking (`bun run typecheck`), and `bun test`. These will
automatically run on every pull request.

---
Expand Down
1,100 changes: 1,100 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[test]
preload = ["./src/ps/__tests__/setup.ts"]
2 changes: 1 addition & 1 deletion docs/STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The Web module provides HTTP server functionality using Express.js. It serves st
The `loaders` directory contains various loader modules that set up different aspects of the web server:

- `api.ts` - Loads API endpoints
- `bundles.ts` - Loads webpack bundles
- `bundles.ts` - Loads compiled React bundles
- `static.ts` - Serves static files (images, CSS)
- `ui.ts` - Loads UI routes
- `errors.ts` - Sets up error handling
Expand Down
12 changes: 7 additions & 5 deletions docs/WORKAROUNDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
```json
{
"compilerOptions": {
"module": "commonjs", // 'require' syntax makes HMR possible; 'import' doesn't
"esModuleInterop": true // Allow default-importing stuff like path
},
"ts-node": {
"require": ["tsconfig-paths/register"] // For path aliases
"module": "preserve",
"esModuleInterop": true,
"types": ["bun", "node"]
}
}
```

Path aliases (`@/*`) are read from `paths` by Bun at runtime and by `bun check` for type checking.

Hot reload uses `require.cache` eviction in [src/utils/cachebust.ts](../src/utils/cachebust.ts); always resolve paths with `require.resolve` so cache keys match the loader (notably `/private/var` vs `/var` on macOS).
Loading
Loading