pocket-nexus/pocketjs/pocket3d-interface

Claude Code and agent skill by pocket-nexus/pocketjs

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Build the 2D interface of a Pocket3D game (title, HUD, menus, settings, touch controls, a second screen) as one PocketJS app drawn over the scene, with one presentation per device shape (PSP, PS Vita, Nintendo 3DS, iPod touch), and show every presentation on one browser page that changes device. Use when a Pocket3D game draws text, gauges or menus from its renderer, when debug text or a status line is what a player sees, when adding a console target, a browser tab, a menu, a setting or a touch…

Install

npx vskill@latest install pocket-nexus/pocketjs/pocket3d-interface

SKILL.md

The same SKILL.md was published earlier as pocket-nexus/pocketjs/pocket3d-interface.

Pocket3D interface

Overview

A Pocket3D game has two layers on the screen. The renderer draws the scene. Every 2D pixel that is not anchored to a point of the world comes from one PocketJS app, compiled per device and drawn over the scene by that device's PocketJS host library. The renderer draws no text.

LayerOwnsLives in
Renderer (Rust or C, per console)simulation, scene, marks anchored to the world (a target's distance, a lock-on ring)the game's device crates
Interface (PocketJS app)title, HUD readouts, lists, settings, map, touch controls, loading and error screensui/ in the game repository
Flow (one Rust type)which mode the screen is in, what the pad means in each mode, what a command doesone no_std crate shared by every device

A line of text drawn by the renderer for a developer (frame time, triangle count, key hints) is not an interface. It reaches the screen as a member of the state the interface is sent, behind a setting the player turns on.

Three documents state the rules this skill applies: `docs/MODALITY.md` (modality, large and small differences), `docs/HIG.md` (intents, the buttons guideline, the touch guideline) and `docs/POCKET3D-UI-OVERLAY.md` (the same overlay on the desktop renderer).

The parts

PartWhat it is
ui/app/protocol.tsThe state the renderer sends and the commands the interface sends.
ui/app/host.tsconnectOverlay from @pocketjs/framework/overlay-host, the state as one signal per member, the numbers that change every turn as a plain array with listeners.
ui/app/parts.tsxEvery readout, row, gauge and map once. A presentation places parts; it does not redraw one.
ui/app/presentations/<shape>/One presentation per device shape: its entry (main.tsx) and its pocket.host.config.ts, which lists the hosts of that shape and holds the app section.
crates/<game>-interfaceThe renderer's side: the state struct, the command parser, the channel, and Session, the flow.
tools/ui.tsCompiles the app for a device, writes every screen as a picture, runs the flow test.
ui/test/A mock renderer and the rig that runs a compiled bundle on the wasm UI core.

One presentation per device shape

A presentation is an entry module with its own pocket.host.config.ts. The config lists the hosts of one device shape and states the viewport, surfaces and features the entry is laid out for; pocket compile builds it for each host it lists. A game that ships on the four handhelds has three:

ts
// ui/app/presentations/single/pocket.host.config.ts: PSP, PS Vita
export default defineHostConfig({
hosts: ["psp", "vita"],
app: { entry: "main.tsx", framework: "solid",
viewport: { logical: [480, 272], presentation: "integer-fit" } },
});
// ui/app/presentations/dual-screen/pocket.host.config.ts: Nintendo 3DS
export default defineHostConfig({
host: "3ds-runtime",
app: { entry: "main.tsx", framework: "solid",
viewport: { fixed: { logical: [400, 240], presentation: "native" } },
surfaces: { auxiliary: { fixed: { logical: [320, 240], presentation: "native" } } },
features: ["display.auxiliary", "input.touch.auxiliary"] },
});
// ui/app/presentations/touch/pocket.host.config.ts: iPod touch
export default defineHostConfig({
host: "../../../hosts/ipod/pocket.host.json",
app: { entry: "main.tsx", framework: "solid",
viewport: { fixed: { logical: [480, 320], presentation: "native" } } },
});
PresentationDevicesWhat it must do
baseline (single)PSP; PS Vita at 2× rasterReadouts at the edges of the scene. Lists walked by the d-pad with one focus bar; a legend strip from useActions. On the Vita a list row also takes a tap.
dual-screenNintendo 3DSThe upper screen keeps the scene and the readouts. The lower screen is a second surface, not a copy: the map, the controls a stylus works (a slider, a toggle), and every list.
touchiPod touchNo buttons exist: every verb is drawn on the panel. A stick and keys at the lower corners, at least 44 logical pixels each, and a drag on the scene for the view. The title and the lists keep the baseline's layout with taller rows; the way back stands in a list's heading.

A device differs by its presentation. A small difference inside one entry reads modality, surfaceHasTouch() and glyph() from @pocketjs/framework/modality (a legend says ○ on a PSP and A on a 3DS from one source line). Do not fork a part per device: a presentation's entry places the shared parts.

One layout for the screens every device has

The title, a list, the menu over the scene and the strip under a list stand in the same place, built from the same parts, in every presentation. Two devices side by side then show one game. A presentation changes what its device's input changes:

Buttons (PSP, Vita, 3DS)Touch panel with no buttons
A row's height26 px or more (the HIG's floor on a 320-wide screen)44 px; 36 px where five rows share the title with the name (iOS's own bars are 32 points on a panel held sideways)
The list's markThe focus bar, moved by the d-padThe same bar, under the finger while a row is pressed
The strip under a listA notice at the left, the buttons' legend at the rightThe notice; useActions().legend() is empty where no button exists
The way back✕ in the legend‹ Back in the list's heading

A control one device alone has (a stick, keys under a thumb, a bar to drag, the lower screen's map) belongs to that presentation. A shared screen is not restyled for a device. A touch title made of large buttons beside a PSP title that is a list reads as another game. A list too long for rows a finger can press stands two abreast in the same rows (six hours as three rows of two) before it becomes a grid of buttons.

A device outside PocketJS's public registry (a 3DS host contract, an iPod drawable that shares the scene's 480 × 320) resolves through a host contract kept with the game's tool: the presentation's config lists the contract's path, or the tool calls resolveAppPlan from @pocketjs/framework/plan with a registry of one target (profileRegistry in tools/profile-resolver.ts builds one from a host contract).

A browser tab shows every presentation

A browser build has no presentation of its own. The page loads the bundle a device loads, with the `plan.json` PocketJS wrote for it, and shows the game as that device: its shell, its screens in the shell, its presentation, its keys under a pointer and from the keyboard. The browser kernel (`engine/pocket3d/crates/pocket-web-wgpu`) supplies the page itself, createPlayer: one page for every Pocket3D game. The game's page has an empty body and no line of its own.

The page doesWith
Reads the screens, the raster density and the surface that takes touch from the planscreens(plan) in pocket3d-interface.js. The page keeps no table of device sizes
Starts the device's guest in a realm of its ownopenInterface: programs/web/app-instance.html in a hidden frame, text: false, pocket.overlay declared. `simHz` is the turns a second the game gives the guest (30 where the device's host sets __simHz to 30); each turn then advances ticks sixtieths
Builds the page: the bar, the device's shell, the dock with the game's Download and Remix linkscreatePlayer({ title, tagline, devices, runsOn, pick }). The page links pocket3d-stage.css and pocket3d-player.css
Shows a device: its shell with one or two screens in itplayer.show(id, { width, height, lower, sticks, glyphs, touch, viewport }), from screens(plan) and the renderer's shape. The scene is drawn into player.canvas; the lower screen is player.stage.second
Reads the device's buttons and sticksplayer.controls.read(): the keyboard and the shell's own keys, d-pad and sticks under a pointer or a finger. The bits are PocketJS's, so one mask goes to the guest and to the game's pad mapping
Hands a pointer to the guest as a contact on the surface that takes touchplayer.show binds it from touch and viewport, in the surface's logical pixels
Says that the tab's picture differs from the device'sNothing: the mark Simulated opens the player's own sentence, the same for every game and device. A note on a device is not shown
Tells the player the first frame is drawnplayer.ready(): it then reads the other devices' shells

Changing device replaces the guest and keeps the game. The page removes the current realm, starts the next device's bundle in a new one, and the renderer opens its channel again: the new guest receives the whole state on its first turn and shows the mode the game is in. The flow stays in Session; the renderer changes its screen's size and its pad mapping. The first device is the touch presentation for a browser whose pointer is a finger and the baseline at two samples a pixel otherwise.

A difference between the tab and a device is the page's or the shell's, not a branch in `ui/`. Do not add a web presentation, and do not compile a bundle for the browser alone.

What the page says is the player's, and what the game says is in its interface. Credits, sources and a control legend of the game's own belong to a sheet of the interface (an About list reached from the title), where every device shows them. The page carries no footer, no attribution line and no key legend of a game: the player lists the keys and the notices itself.

The protocol

Both sides speak JSON lines over PocketJS's pocket.overlay service, answered inside the process. The renderer sends the members of its state that changed since the last line; the interface sends flat commands (numbers, booleans, short strings), which the renderer parses with a scanner of a few dozen lines and no allocator-heavy JSON library.

ts
// ui/app/host.ts
const overlay = connectOverlay<Partial<HostState>, Command>((state) => { /* write signals */ });
overlay.send({ type: "menu", on: true });

The guest calls ui.svcOpen, ui.svcPoll and ui.svcSend. A game answers them from its channel in one of two ways:

HostHow the game answers
Rust hosts (programs/psp, programs/vita)After the host registered its ops and before the bundle is evaluated, set svcOpen, svcPoll, svcSend on the guest's ui object to C functions that read and write the channel (JS_NewCFunction2, JS_SetPropertyStr).
C hosts (the 3DS product host in pocket-nexus/pocket-shell, programs/native/quickjs/pocket_qjs_program.c with POCKET_SVC_WIRE)Link the six functions of `platforms/posix/svc-wire/include/svcwire.h` (svcwire_open, svcwire_recv_lines, svcwire_send_line, …) from the game's interface crate in place of the network client.

Rules for the state:

  • Numbers that change every turn travel as one array (t), and each is

written to its node with text() and prop() from @pocketjs/framework/hot, in a cell of fixed size with the text at its left. That is one native call and no layout. A value set through a signal costs milliseconds per update on a PSP.

  • Everything else is one signal per member, so a statistics line once a

second does not re-run what reads the settings.

  • Settings are a list the renderer sends ({ key, value, choices? }); the

interface renders whatever the device lists. A device that has no bloom lists no bloom.

  • What is kept between runs is one text the interface hands to the renderer

(prefs), which stores it and hands it back at the start.

The flow, once

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1,820
Repository forks
102
7-day trend score
42

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/pocket-nexus/pocketjs/pocket3d-interface/badge)](https://verified-skill.com/skills/pocket-nexus/pocketjs/pocket3d-interface)

Something wrong with this skill or its page? Tell us.