From bc97f82d3e5483dd9d582d7705a7b6e868540d5d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 26 Apr 2026 17:59:17 -0500 Subject: [PATCH] Add edit-profile skill for Nostr profile editing form Moves src/components/EditProfileForm.tsx into a new edit-profile skill at .agents/skills/edit-profile/, with a SKILL.md covering installation, the kind 0 fields it edits (name, about, picture, banner, website, nip05, bot), and the existing template hooks it plugs into (useCurrentUser, useNostrPublish, useUploadFile, useToast). Also removes the 'Nostr Edit Profile' section from AGENTS.md since the component is no longer part of the default template surface. --- .agents/skills/edit-profile/SKILL.md | 93 +++++++++++++++++++ .../files}/components/EditProfileForm.tsx | 0 AGENTS.md | 20 ---- 3 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 .agents/skills/edit-profile/SKILL.md rename {src => .agents/skills/edit-profile/files}/components/EditProfileForm.tsx (100%) diff --git a/.agents/skills/edit-profile/SKILL.md b/.agents/skills/edit-profile/SKILL.md new file mode 100644 index 0000000..1aeeef7 --- /dev/null +++ b/.agents/skills/edit-profile/SKILL.md @@ -0,0 +1,93 @@ +--- +name: edit-profile +description: Add a form that lets users edit their Nostr profile metadata (NIP-01 kind 0). Provides EditProfileForm with fields for name, about, picture, banner, website, nip05, and a bot flag, plus Blossom image uploads wired up through useUploadFile. +--- + +# Edit Profile Form + +This skill provides `EditProfileForm`, a drop-in React component that lets a logged-in user update their Nostr profile metadata (NIP-01 kind 0). The form covers the common metadata fields, handles image uploads through the project's existing `useUploadFile` hook, publishes a new kind 0 event on save, and invalidates the relevant TanStack Query caches so the rest of the app reflects the change. + +**This component is not included in the project by default.** When the user wants profile editing, follow the setup instructions below to install the component. + +## Files Provided by This Skill + +| Skill file | Copy to | +|---|---| +| `files/components/EditProfileForm.tsx` | `src/components/EditProfileForm.tsx` | + +## Setup Instructions + +### 1. Dependencies + +No extra npm packages are required. The component uses packages already present in the template: + +- `react-hook-form` + `@hookform/resolvers` — form state and validation +- `zod` (via `NSchema` in `@nostrify/nostrify`) — metadata schema validation +- `@tanstack/react-query` — cache invalidation after publish +- `@nostrify/nostrify` — `NSchema.metadata()` Zod schema + `NostrMetadata` type +- `lucide-react` — icons +- shadcn/ui — `Button`, `Form`, `Input`, `Textarea`, `Switch` + +### 2. Copy the Skill File Into `src/` + +Copy `.agents/skills/edit-profile/files/components/EditProfileForm.tsx` into `src/components/EditProfileForm.tsx`. The component imports: + +- `@/hooks/useCurrentUser` — current logged-in user and their existing metadata +- `@/hooks/useNostrPublish` — publishes the kind 0 event +- `@/hooks/useToast` — success/error feedback +- `@/hooks/useUploadFile` — Blossom uploads for picture/banner + +All of these are standard in the template; no extra work is needed beyond copying the file. + +## Usage + +Place the component anywhere a logged-in user should be able to edit their profile. It renders the form itself, with no surrounding layout: + +```tsx +import { EditProfileForm } from '@/components/EditProfileForm'; + +export default function EditProfilePage() { + return ( +
+

Edit Profile

+ +
+ ); +} +``` + +The component takes no props. It reads the current user's existing metadata via `useCurrentUser` and pre-populates every field, so the user can tweak values without losing anything else on their profile. + +## Fields + +| Field | NIP-01 key | Input | Notes | +|---|---|---|---| +| Name | `name` | text | Short handle | +| About | `about` | textarea | Bio / description | +| Picture | `picture` | URL + upload button | Profile avatar. Upload button calls `useUploadFile` and sets the resulting URL. | +| Banner | `banner` | URL + upload button | Profile banner. Same upload flow as picture. | +| Website | `website` | URL | Any related web URL | +| NIP-05 | `nip05` | text | Email-like Nostr identifier (e.g. `alice@example.com`) | +| Bot | `bot` | switch | Marks the account as automated (NIP-24) | + +On submit, the component publishes a kind 0 event whose `content` is the JSON-stringified metadata, and invalidates any `useAuthor`/profile queries so the UI reflects the new values immediately. + +## Routing + +The form is just a component. If you want a dedicated route for it, wire it up in `AppRouter.tsx`: + +```tsx +// AppRouter.tsx +import EditProfilePage from './pages/EditProfilePage'; + +} /> +``` + +## Related Hooks + +If you're building a profile page that *displays* the user's metadata (as opposed to editing it), use: + +- `useCurrentUser` — the logged-in user and their metadata +- `useAuthor(pubkey)` — any user's metadata by pubkey + +Both are part of the core template. diff --git a/src/components/EditProfileForm.tsx b/.agents/skills/edit-profile/files/components/EditProfileForm.tsx similarity index 100% rename from src/components/EditProfileForm.tsx rename to .agents/skills/edit-profile/files/components/EditProfileForm.tsx diff --git a/AGENTS.md b/AGENTS.md index 3580096..9d1d0ad 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -800,26 +800,6 @@ const events = await nostr.query( 4. **Security considerations**: Always use `naddr1` for addressable events instead of just the `d` tag value, as `naddr1` contains the author pubkey needed to create secure filters 5. **Error handling**: Gracefully handle invalid or unsupported NIP-19 identifiers with 404 responses -### Nostr Edit Profile - -To include an Edit Profile form, place the `EditProfileForm` component in the project: - -```tsx -import { EditProfileForm } from "@/components/EditProfileForm"; - -function EditProfilePage() { - return ( -
- {/* you may want to wrap this in a layout or include other components depending on the project ... */} - - -
- ); -} -``` - -The `EditProfileForm` component displays just the form. It requires no props, and will "just work" automatically. - ### Uploading Files on Nostr Use the `useUploadFile` hook to upload files. This hook uses Blossom servers for file storage and returns NIP-94 compatible tags.