petshare-setup
GitHub用于快速搭建、分叉或定制基于React/Vite的像素宠物分享应用,支持动画上传、预览生成及多人房间功能。
Trigger Scenarios
Install
npx skills add portons/codex-pet-share --skill petshare-setup -g -y
SKILL.md
Frontmatter
{
"name": "petshare-setup",
"description": "Use when an agent needs to fork, rebrand, deploy, adapt, or rebuild a Codex Pet Share style app with animated pet uploads, generated previews, gallery downloads, provider adapters, and multiplayer playground rooms."
}
Petshare Setup
Use this skill when an agent is asked to spin up, fork, rebrand, deploy, or modify this repository or a close derivative. The app is a self-hostable React/Vite pixel-pet sharing surface: users upload Codex-compatible pet packages, browse animated previews, download packages/GIFs, and join multiplayer playground rooms.
This is a repo-scoped Codex skill. Keep it under
.agents/skills/petshare-setup/ so Codex can discover it from the repository.
First Read
Before editing, read:
README.mddocs/GETTING_STARTED.mddocs/PROVIDER_ADAPTERS.mdAGENTS.mdreferences/petshare-architecture.mdwhen touching app behavior, uploads, previews, animations, rooms, provider adapters, or deploymentreferences/security-boundary.mdwhen publishing, documenting public setup, reviewing exposure risk, or changing auth/moderation/provider surfaces
Non-Negotiables
- Keep changes literal to the request. Do not add fallbacks, backwards compatibility, provider-specific public env vars, or unrelated hardening.
- Keep the browser public contract provider-neutral. Public build vars are only:
VITE_APP_API_BASE_URL,VITE_PUBLIC_APP_ORIGIN,VITE_REALTIME_URL,VITE_REALTIME_PUBLIC_KEY,VITE_APP_NAME,VITE_APP_HANDLE,VITE_APP_TAGLINE, andVITE_APP_REPO_URL. - Never commit
.env,.env.local, API tokens, salts, database passwords, provider account identifiers, generated migration exports, or local auth data. - Use provider adapters as replaceable boundaries. Feature code under
src/should not branch on provider names. - Do not turn this skill into an abuse manual. Do not add copy-paste scripts, unauthenticated client examples, raw room-event payload recipes, rate-limit thresholds, bypass instructions, scraping loops, or moderation-evasion advice.
- For ports, follow
AGENTS.md: check a requested port before starting a process, and never kill reserved ports unless explicitly asked.
Core Workflow
- Identify whether the task is setup, provider work, upload/asset work, preview/GIF work, animation/playground work, multiplayer rooms, rebranding, or security/publication review.
- Load only the reference file needed for that surface.
- Inspect current source before deciding; this repo has explicit adapter and feature boundaries.
- Make the smallest code/doc changes that satisfy the user request.
- Run the relevant validation commands below.
- If publishing or handing off public code, run the exposure checks from
references/security-boundary.md.
Repository Map
src/domain/*: shared types, route parsing, API URLs, session storage, gallery constants, pet kind/tag config, and sprite atlas constants.src/app/*: SPA composition, route effects, API/session hooks, shell chrome, modal composition, and cross-feature refresh/navigation.src/uploads/*: file inputs, manifest parsing, slug normalization, upload validation preview, generatedshare.png, generatedpreview.webp, generatedposter.webp, andPOST /api/petsform assembly.src/pets/*: gallery/detail pet surfaces, sprite previews, cursor preview, metadata editing, tag/kind management, delete, share, and GIF export wiring.src/downloads/*: package modal, install command UI, spritesheet fetch, GIF encoding, and client-side blob download.src/gallery/*: browse/search/filter/sort/pagination, creator pages, collections, live room rail, and leaderboard.src/playground/*: Three.js playground, sprite animation, room overlays, realtime handlers, UI controls, minimap, chat, NPCs, ball, and trampoline.src/realtime/providerClient.tsandsrc/realtime/roomChannel.ts: generic frontend realtime exports.src/realtime/adapters/*: current provider-specific realtime implementation.adapters/cloudflare-worker/*: checked-in API, D1 schema, R2 storage, Durable Object realtime, Worker Assets hosting, and Cloudflare deployment.adapters/cloudflare-pages/*: optional crawler/social-share page functions for static hosts.scripts/*: public env validation and generated brand/social-card assets.
If a feature file starts absorbing unrelated behavior, extract into the matching feature folder rather than adding another section to a large component.
Setup Path
npm install
cp .env.example .env.local
node scripts/check-public-build-env.mjs
npm run build
npm run dev
Vite defaults to http://127.0.0.1:5173.
The build validator fails if required public env vars are missing, malformed, or
if a VITE_* name looks secret-like. For provider/env changes, verify
.env.example, scripts/check-public-build-env.mjs, docs, and adapter config
agree exactly.
Validation Before Handoff
Always run:
npx tsc -b --pretty false
npm run build
When the Cloudflare adapter changed, also run:
npm run adapter:cloudflare:typecheck
For frontend/UI/playground changes, open the changed route in a real browser and verify the interaction. For room changes, test at least one hosted room and one joined room with two sessions. For upload changes, upload or seed one valid pet and inspect detail, gallery preview, package download, GIF export, and playground load.
Common Change Recipes
Spin Up A New Fork
- Clone, install, and copy
.env.exampleto.env.local. - Set provider-neutral public env and brand env.
- Choose a backend provider.
- For Cloudflare, create Worker, D1, R2, and Durable Object resources; set
AUTH_SECRETandPET_STATS_SALTwith Wrangler secrets; update only the adapter config values that correspond to created resources. - Run D1 migrations.
- Build and run the app.
- Register, sign out, sign in, upload one valid pet, open detail, open playground, and open a room.
Add A New Backend Provider
- Add provider code under
adapters/<provider>/. - Implement the same HTTP response shapes from
src/domain/types.ts. - Implement the same upload asset contract and validation behavior.
- Add realtime code under
src/realtime/adapters/. - Update only
currentClient.tsandcurrentRoomChannel.tsto point to the new implementation after it satisfies the room interface. - Keep docs provider-neutral except for the adapter-specific README.
Change The Sprite Atlas
- Update
src/domain/config.tsandsrc/playground/core/config.tstogether. - Update backend validation dimensions in
adapters/cloudflare-worker/src/api/validation.ts. - Update preview generation and GIF export assumptions.
- Verify upload validation, gallery previews, detail previews, GIF export, solo playground, and room playback.
Change Multiplayer Behavior
- Start from
src/realtime/roomTypes.tsand theRoomHandlecontract. - Update the provider adapter and all room handlers together.
- Keep event payloads serializable and small.
- Verify host, guest, leave/close, pet swap, chat, position, NPCs, toys, and collection permanent rooms.
Change Uploads Or Asset Storage
- Keep
pet.jsonandspritesheet.webpas the package contract unless the user explicitly changes it. - Preserve generated
share.png,preview.webp, andposter.webpas app assets. - Update frontend generation, backend validation, storage writes, serializer URLs, and download endpoint together.
- Verify upload error messages, validation card, detail route, share image, preview strip, package zip, and room sprite loading.
Version History
- 2272509 Current 2026-08-27 09:05


