diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index b52b967f..1fa6725d 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -80,7 +80,7 @@ export const ChatPane = forwardRef(({ const [searchParams, setSearchParams] = useSearchParams(); const { fs: browserFS } = useFS(); - const { user } = useCurrentUser(); + const { user, metadata } = useCurrentUser(); const { models } = useProviderModels(); // Initialize AI chat with tools @@ -152,8 +152,10 @@ export const ChatPane = forwardRef(({ name: "Shakespeare", profession: "software extraordinaire", tools: Object.values(tools), + user, + metadata, }).then(setSystemPrompt) - }, [browserFS, cwd, tools]); + }, [browserFS, cwd, tools, user, metadata]); const { messages, diff --git a/src/lib/system.ts b/src/lib/system.ts index c57f5a97..6f7652cf 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -1,6 +1,8 @@ +import { NUser } from "@nostrify/react/login"; +import { NostrMetadata } from "@nostrify/nostrify"; import { join } from "@std/path"; - import OpenAI from "openai"; +import { nip19 } from "nostr-tools"; import { JSRuntimeFS } from "./JSRuntime"; export interface MakeSystemPromptOpts { @@ -10,10 +12,12 @@ export interface MakeSystemPromptOpts { mode: "init" | "agent"; fs: JSRuntimeFS; cwd: string; + user?: NUser; + metadata?: NostrMetadata; } export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise { - const { name, profession, tools, mode, fs, cwd } = opts; + const { name, profession, tools, mode, fs, cwd, user, metadata } = opts; let system = mode === "init" ? `You are ${name}, an expert ${profession}. The files in the current directory are a template. Your goal is to transform this template into a working project according to the user's request.` @@ -27,6 +31,26 @@ export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise