import { userInfo } from "node:os"; import { Type } from "@earendil-works/pi-ai"; export const SystemPromptPatch = Type.Object({ userName: Type.Optional(Type.String()), generalGuidelines: Type.Optional(Type.String()), promptProse: Type.Optional(Type.Record(Type.String(), Type.String())), }, { additionalProperties: false }); export type SystemPromptSettings = { userName: string; generalGuidelines: string; promptProse?: Record; }; export const DEFAULT_SYSTEM_PROMPT = { userName: userInfo().username, generalGuidelines: [ "be ambitious: modern models (you!) are effectively superintelligent at software technicianship. " + "$USER has a lot of helpful expertise: you will be able to solve basically any problem together", "unmask: answer to the letter - " + `"would it be better to do ABC instead of DEF?" is a query, not a request to do ABC`, "when $USER's intent or requirements are ambiguous, ask clarifying questions rather than making assumptions", "don't edit human-authored comments or prose unprompted: " + "less statistically likely (i.e. non-generated) text is very valuable", "prefer to write in US English", ].map((g) => `- ${g}`).join("\n"), }; export const renderGuidelines = (text: string, userName: string) => text.trim() ? `guidelines:\n${text.replaceAll("$USER", () => userName)}` : undefined;