GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — petx/docs/AI_AGENT_INTEGRATION.md at main · IchenDEV/petx

Expand file tree

/

AI_AGENT_INTEGRATION.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
406 lines (303 loc) · 10.3 KB
/

AI_AGENT_INTEGRATION.md

Copy path

File metadata and controls

406 lines (303 loc) · 10.3 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

PetX AI Agent Integration Guide

Use this document as the instruction source for a code agent. Give the agent this GitHub link or paste the whole file into its task prompt.

Goal: add PetX to an existing app so it renders an animated Codex pet from a spritesheet.webp atlas.

Agent Task Prompt

Copy this block into the target project's code agent:

Integrate PetX into this app.

Use the PetX AI Agent Integration Guide as the source of truth.

Requirements:
- Detect the app framework from package.json and source files.
- Install the matching PetX package.
- Import the PetX CSS once, if the selected package has CSS.
- Add one visible animated Codex pet preview to the most appropriate page or component.
- Use /pets/frieren/spritesheet.webp as the default asset path unless the app already has a pet asset URL or the user provides another one.
- Do not publish packages, change unrelated UI, or rewrite the app structure.
- Run the app's typecheck, build, or test command after the change.
- Report changed files and verification output.

Package Selection

Read the target app's package.json and choose one package:

App signal Install
react or next @petx/react
react-native or expo @petx/react-native
vue or nuxt @petx/vue
svelte or @sveltejs/kit @petx/svelte
solid-js or solid-start @petx/solid
no framework, mixed framework, static HTML, or unknown @petx/webcomponent

Use the target project's package manager:

npm i @petx/react
pnpm add @petx/react
yarn add @petx/react
bun add @petx/react

Replace @petx/react with the selected package.

Asset Setup

PetX renders a spritesheet URL. It does not bundle pet images.

To create custom Codex pet assets, use the official Codex pets guide: https://learn.chatgpt.com/docs/pets?surface=app

The Codex app guide tells users to install the hatch-pet skill and then ask it to create a pet. Use the generated spritesheet.webp and pet.json files as the PetX asset source.

Preferred public asset layout:

public/
  pets/
    frieren/
      pet.json
      spritesheet.webp

Use this URL in components:

/pets/frieren/spritesheet.webp

If the target app already stores static assets somewhere else, keep its convention and pass that URL to src.

Supported Codex pet atlas formats:

Version Manifest Grid Full spritesheet
V1 omit spriteVersionNumber 8 x 9 1536 x 1872 px
V2 spriteVersionNumber: 2 8 x 11 1536 x 2288 px

Both versions use 192 x 208 px frames. V2 rows 9-10 contain 16 clockwise look directions in 22.5-degree steps; 000° means up. Keep the version field from the generated pet.json. Omitting it intentionally preserves V1 behavior.

Default animation names:

idle
runningRight
runningLeft
waving
jumping
failed
waiting
running
review

For V2, prefer passing the parsed manifest through pet; the renderer then derives the 11-row atlas automatically. lookDirection accepts clockwise degrees from up or a screen-space vector where positive x points right and positive y points down. With only a direct src, pass spriteVersionNumber={2} explicitly.

React

Install:

npm i @petx/react

Import CSS once, usually in src/main.tsx, src/App.tsx, app/layout.tsx, or the existing global CSS entry:

import '@petx/react/styles.css';

Render:

import { PetX } from '@petx/react';

export function PetPreview() {
  return (
    <PetX
      src="/pets/frieren/spritesheet.webp"
      animation="idle"
      size={192}
      title="Frieren Codex pet"
    />
  );
}

React Native

Install:

npm i @petx/react-native

Bundled app assets should use the native source prop:

import { PetX } from '@petx/react-native';

export function PetPreview() {
  return (
    <PetX
      source={require('./assets/pets/frieren/spritesheet.webp')}
      animation="idle"
      size={192}
      title="Frieren Codex pet"
    />
  );
}

Remote spritesheets can use src:

import { PetX } from '@petx/react-native';

export function PetPreview() {
  return (
    <PetX
      src="https://example.com/pets/frieren/spritesheet.webp"
      animation="waving"
      size={192}
      title="Frieren Codex pet"
    />
  );
}

React Native uses numeric layout values and does not need a PetX CSS import.

Vue

Install:

npm i @petx/vue

Import CSS once, usually in src/main.ts, src/App.vue, or the app's global CSS entry:

import '@petx/vue/styles.css';

Render:

<script setup lang="ts">
import { PetX } from '@petx/vue';
</script>

<template>
  <PetX
    src="/pets/frieren/spritesheet.webp"
    animation="waving"
    :size="192"
    title="Frieren Codex pet"
  />
</template>

Svelte

Install:

npm i @petx/svelte

Import CSS once, usually in src/routes/+layout.svelte, src/App.svelte, or the app's global CSS entry:

import '@petx/svelte/styles.css';

Render:

<script lang="ts">
  import PetX from '@petx/svelte';
</script>

<PetX
  src="/pets/frieren/spritesheet.webp"
  animation="jumping"
  size={192}
  title="Frieren Codex pet"
/>

SolidJS

Install:

npm i @petx/solid

Import CSS once, usually in src/index.tsx, src/App.tsx, or the app's global CSS entry:

import '@petx/solid/styles.css';

Render:

import { PetX } from '@petx/solid';

export function PetPreview() {
  return (
    <PetX
      src="/pets/frieren/spritesheet.webp"
      animation="review"
      size={192}
      title="Frieren Codex pet"
    />
  );
}

Web Component

Install:

npm i @petx/webcomponent

Define the custom element once, usually in the app entry file:

import { definePetXElement } from '@petx/webcomponent';

definePetXElement();

Render in HTML:

<pet-x
  src="/pets/frieren/spritesheet.webp"
  animation="idle"
  size="192"
  title="Frieren Codex pet"
></pet-x>

The Web Component package does not require a CSS import.

Common Props

Prop Type Default Use
src string none Spritesheet URL.
source ImageSourcePropType none React Native bundled asset or native image source.
pet CodexPetManifest none Manifest object with spritesheetPath.
manifestUrl string none Base URL for resolving relative manifest paths.
animation string idle Animation key.
frame number auto Fixed frame. Set this for static previews.
playing boolean true Turn animation on or off.
frameInterval number animation default Milliseconds per frame.
size `number string` atlas frame width
offsetX `number string` 0
offsetY `number string` 0
atlas Partial<CodexPetAtlas> default atlas Use for non-default frame sizes.
animations CodexPetAnimations default animations Use for custom row or frame counts.
spriteVersionNumber number manifest value or V1 Set to 2 for a direct V2 spritesheet without pet.
lookDirection number | { x: number; y: number } none Select one of the 16 V2 look cells. Degrees run clockwise from up.
lookDeadzone number 0 Vector magnitude at or below this value falls back to the standard animation.
title string none Accessible image label.

For React Native, size, offsetX, and offsetY use numeric layout values.

Web Component attribute names use kebab case:

<pet-x
  frame-interval="140"
  offset-x="0"
  offset-y="0"
  sprite-version-number="2"
  look-direction='{"x":1,"y":0}'
></pet-x>

Placement Guidance

Choose the smallest useful integration:

  • For dashboards or docs, add a small PetPreview component near an existing preview, toolbar, empty state, or demo panel.
  • For picker UIs, render multiple PetX instances in a grid and change animation on hover or selection.
  • For a desktop companion or mascot, place the pet in a fixed or sticky layer and keep pointer-events behavior aligned with the host app.
  • Keep the pet container large enough for a 192 x 208 frame. If the image looks clipped, increase container height or allow overflow: visible.

Minimal wrapper:

.petx-preview {
  display: inline-grid;
  place-items: center;
  width: 240px;
  min-height: 260px;
  overflow: visible;
}

Verification Checklist

After integration, run the target app's normal checks. Prefer existing scripts in this order:

npm run typecheck
npm run build
npm test

Use the matching package manager if the repo uses pnpm, yarn, or bun.

Then verify in a browser:

  • The page contains an element with class codex-pet, or a <pet-x> custom element.
  • The rendered element has --codex-pet-src pointing at the spritesheet URL.
  • V1 renders a 1872px background height; V2 renders 2288px when the manifest/version is supplied.
  • A V2 cardinal look input maps to row 9 or 10, while an omitted/zero/deadzone input returns to the selected standard animation.
  • The pet is visible and not clipped.
  • The selected animation changes frames unless playing={false} or frame is set.
  • The browser network panel can load spritesheet.webp with HTTP 200.

Troubleshooting

Symptom Fix
Nothing visible Check src, confirm the asset URL returns 200, and import the package CSS for React, Vue, Svelte, or SolidJS.
The pet is clipped Increase wrapper height or set overflow: visible on the preview container.
Wrong animation row Use one of the default animation names or pass a custom animations map.
Animation does not move Check playing, frame, reduced-motion settings, and frameInterval.
TypeScript cannot find CSS imports Add the app's usual CSS module declaration or import CSS from a global entry already accepted by the bundler.
SSR warning Import and render the framework component normally. For the Web Component, call definePetXElement() only in browser code if the host framework renders on the server.

Completion Report Format

The code agent should finish with:

Changed files:
- ...

Installed package:
- ...

Pet asset path:
- ...

Verification:
- npm run typecheck: ...
- npm run build: ...
- browser check: ...
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.