Back to Find the Invisible Cow
SOURCE / PINNED RELEASE

Made of little things.

Find the Invisible Cow

Release
e48b3dced31c…
Author-recorded commit
cf79302f143d…
License
LICENSE
Author’s source reference
nostr://npub1p8rxwea4e0l4jml0q53n5mvh3n7pywq523jk3lm336v04r8ny9jqtq7ttf/wss%3A%2F%2Fgit.napplet.soy%2F/n-3b179f1d7df

Archive hash verified: f8e300eb672b5ee8…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

README.md
## napplet soyLI workspace

Read [docs/napplet-space.md](docs/napplet-space.md) first for this project's CLI commands, installed skills, preview cleanup and host capabilities. Read [docs/napplet-visual-design.md](docs/napplet-visual-design.md) before styling the creation and its UI. When implementing controller support, read [docs/napplet-controllers.md](docs/napplet-controllers.md) and cover the entire napplet, including menus, settings, pause, restart and back navigation. This project and its adapted skills are already installed; do not re-scaffold or reinstall them. Use soyli dev and its printed URL for hosted preview, and stop your preview session after testing. Use the upstream guidance below with those tooling mappings.

# Find the Invisible Cow (napplet)

A port of the classic "find the invisible cow" browser game: an invisible cow
hides somewhere in the pasture, and a synthesized moo gets **louder and more
frequent** as your listening position closes in. Catch the cow with a click,
tap, Enter or gamepad A, and it hides somewhere new. The napplet is a single
self-contained NIP-5D artifact — the moo is fully synthesized with Web Audio,
so there are no media assets to fetch, license or bundle.

## NAP boundaries used

- `media` (**required**, declared in `vite.config.ts`): the moo is the core
  experience, so NAP-MEDIA is a hard requirement. One napplet-owned session
  (`src/coordinated-audio.ts`, adapted from `docs/examples/coordinated-audio.ts`)
  brokers every audible branch; host pause/stop/volume commands silence the
  whole graph, and the in-app sound toggle stays available. If the host injects
  the domain but refuses a session, the game falls back to visual hints and
  says so in a notice — it never falls back to unregistered sound.
- `storage` (optional): best time, persisted under `best-time-ms`. Absent or
  failing storage degrades to an inline notice; the game stays playable.
- `config` (optional): two assistance settings declared in `config.schema.json`
  — visual hint mode (`off` / `subtle` / `full`) and catch-area size. Defaults
  keep the classic audio-only game; settings are validated and ignored if bogus.
- `identity` (optional): on account change the audio session is muted and the
  player is told to resume with the sound button; ordinary input never fights a
  retired session.
- Gamepad input follows the NAP-GAMEPAD draft through the standard Gamepad API
  (`src/gamepad.ts`, adapted from `docs/examples/gamepad.ts`): stick or d-pad
  moves the probe, the bottom face button catches, focus loss freezes input. No
  `gamepad` requires entry; pointer, touch and keyboard always work.

No `fetch`, `WebSocket`, `localStorage`, cookies or external URLs are used
anywhere; the artifact is one inlined `index.html` built by
`@napplet/vite-plugin` with `artifactMode: 'single-file'`.

## Visual direction (midnight pasture)

- **Character:** calm, slightly goofy night-time hide-and-seek. A dark field
  keeps the cow genuinely invisible (no texture can leak its position); the
  warm amber HUD reads like lantern light.
- **Main surface:** indigo night gradient, static stars and grass tufts, six
  drifting fireflies — all fixed decoration that carries no distance
  information, so no visual exploit substitutes for listening.
- **Interface:** rounded chunky type, pill HUD with tabular numerals, 48px
  touch targets, `#ffb648` amber accent over `#0b1026` night. The cow reveal is
  a hand-drawn inline SVG with a spring pop.
- **Theme policy:** app-owned (`FOLLOW_HOST_THEME` is not used; no theme
  handler exists), so host light/dark changes leave the pasture untouched.
- **Proof frames:** the start card and hunt HUD are checked at 200×160,
  320×560, 900×600 and full screen in the host, plus portrait/landscape touch
  viewports per `docs/napplet-mobile.md`.

## Verification

```bash
pnpm verify             # guidance test + type-check + single-file build
pnpm test:conformance   # real Chromium + reference shell against ./dist
```

`napplet.json` also carries a `preview.recording` recipe (Enter to start,
ArrowRight to wander) so `soyli check` exercises the core interaction, and
`soyli record` can replay it into a clip. Report conformance, `soyli check`,
hosted-preview and independent-shell (Paja) results separately; skipped checks
are not coverage.

## Start

```bash
soyli setup
soyli dev
```

Build and verify the production artifact:

```bash
pnpm verify
```

`soyli build` uses the pinned Vite plugin to produce one inlined `index.html`.
`soyli publish` signs the standalone NIP-5D manifest; its `x` is the HTML
SHA-256. Do not use the plugin's optional legacy manifest for publication.
Read `docs/napplet-manifest.md` for editable capabilities, discovery metadata
and icons.

## Conformance Testing

Verify the napplet conforms to the NAP protocol before publishing. Two
variants, mirroring `vitest` vs `vitest --ui`:

```bash
pnpm test:conformance      # headless: build + check; non-zero exit on failure (CI)
pnpm test:conformance:ui   # live web runtime; re-runs on every source change
```

It loads the build into a real `sandbox="allow-scripts"` iframe and drives the
protocol with a reference shell. Boot, forbidden-global, and degradation checks
run for a local directory; manifest, wire, and lifecycle checks report `SKIP`
unless the invocation supplies the evidence they require.

Exacting requirements for a passing build:

- Build to a **single self-contained `index.html`** (`@napplet/vite-plugin`
  `artifactMode: 'single-file'` in `vite.config.ts`). NIP-5D loads a napplet
  via `iframe.srcdoc` with `sandbox="allow-scripts"` and no `allow-same-origin`
  (an opaque origin) — there is no served origin from which to fetch an
  external `<script src>`, so the JS must be inlined into the one file.
  External-asset builds do not boot.
- Do not import `@napplet/shim` from app code. The runtime injects
  `window.napplet`; conformance verifies boot and emitted envelopes through the
  reference runtime.
- Emit only well-formed envelopes via `@napplet/sdk`. Declare only hard NAP
  requirements in `vite.config.ts`; guard optional domains with
  `window.napplet?.domain` checks and a graceful fallback.
- Do not reference `window.nostr` or use direct `fetch`/`WebSocket`/`localStorage`.

The executable `index.html` does **not** carry its own manifest hash. Before
execution, the runtime verifies the signed manifest and the HTML SHA-256
against its `x` tag. Earlier manifests remain readable through the legacy
validator.

## Authoring Context

Read these before changing protocol-facing behavior:

- `docs/nip-5d.md`
- `docs/boundaries.md`
- `docs/design-patterns.md`
- `docs/package-surfaces.md`
- `docs/new-nap-proposals.md`
- `docs/authoring-checklist.md`

The living NIP-5D source is referenced from `docs/nip-5d.md`; this template
does not treat its local notes as normative protocol text.

For agent-driven work, use the installed `napplet-make` skill. Read
`docs/napplet-space.md` first; `soyli skills update` refreshes managed guidance
while preserving your edits. Living NIP-5D and NAP documents remain protocol
truth.

## Text Selection

The napplet disables accidental text selection by default. To change the whole
napplet, set `--napplet-text-selection: text` in `src/styles.css`. To opt in
one region, add `data-napplet-select="text"` or `data-napplet-select="all"`.

## Package Scripts

```bash
pnpm dev          # local Vite dev server
pnpm type-check   # TypeScript strict-mode check
pnpm build        # Vite production build
pnpm preview      # preview dist/
pnpm test:guidance       # stale-guidance and optional-domain regression checks
pnpm verify       # guidance test + type-check + build
pnpm test:conformance     # headless NAP conformance (build + check, CI exit code)
pnpm test:conformance:ui  # live conformance web runtime, re-runs on change
```