stevens-openaiqueries.ts4 matches
6const tableName = "memories_demo";
78export async function getAllMemories(): Promise<Memory[]> {
9const result = await sqlite.execute(
10`SELECT id, date, text, createdBy, createdDate, tags FROM ${tableName}
23}
2425export async function createMemory(
26memory: Omit<Memory, "id">
27): Promise<Memory> {
51}
5253export async function updateMemory(
54id: string,
55memory: Partial<Omit<Memory, "id">>
70}
7172export async function deleteMemory(id: string): Promise<void> {
73await sqlite.execute(`DELETE FROM ${tableName} WHERE id = ?`, [id]);
74}
4import { nanoid } from "https://esm.sh/nanoid@5.0.5";
56export default async function populateMemoryIds() {
7try {
8// Import SQLite module
stevens-openaipopulateDemo.ts5 matches
56// Create the memories_demo table
7async function createMemoriesDemoTable() {
8try {
9await sqlite.execute(`
2526// Create a fake memory with proper ID and timestamps
27function createMemory(date, text, createdBy, tags, createdDateOffset = 0) {
28const id = nanoid(10);
29// Base date is April 5, 2025
375376// Insert memories into the database
377async function insertDemoMemories() {
378try {
379// Clear existing data if any
406}
407408// Main function to populate demo data
409export default async function populateDemo() {
410try {
411// Create the table
2// Run this script manually to set createdBy based on memory content
34export default async function populateCreatedBy() {
5try {
6// Import SQLite module
54}
5556export function NotebookView({ onClose, avatarUrl }: NotebookViewProps) {
57const [memories, setMemories] = useState<Memory[]>([]);
58const [loading, setLoading] = useState(true);
2// Run this script manually to add new columns to the memories table
34export default async function migrateMemoriesDb() {
5try {
6// Import SQLite module
stevens-openaimemoryUtils.ts3 matches
7* @returns Array of memory objects
8*/
9export async function getAllMemories(includeDate = true, startDate = null) {
10try {
11const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
41* @returns Array of memory objects
42*/
43export async function getRelevantMemories() {
44try {
45// Get today's date in US Eastern Time
59* @returns Formatted string of memories
60*/
61export function formatMemoriesForPrompt(memories) {
62if (!memories || memories.length === 0) {
63return "No stored memories are available.";
stevens-openaihandleUSPSEmail.ts3 matches
4const RECIPIENTS = ["Geoffrey", "Maggie"] as const;
56function parseDateFromSubject(subject: string): string | null {
7const match = subject.match(/(\w{3}), (\d{1,2}\/\d{1,2})/);
8if (match) {
19};
2021async function analyzeHtmlContent(
22anthropic: Anthropic,
23htmlContent: string,
80}
8182export default async function (e: Email) {
83console.log("email content");
84console.log(e.html);
stevens-openaigetCalendarEvents.ts6 matches
6const LOCAL_TIMEZONE = "America/New_York";
78async function deleteExistingCalendarEvents() {
9await sqlite.execute(
10`
15}
1617// Helper function to extract time from ISO string without timezone conversion
18function extractTimeFromISO(isoString) {
19// Match the time portion of the ISO string
20const timeMatch = isoString.match(/T(\d{2}):(\d{2}):/);
31}
3233function formatEventToNaturalLanguage(event) {
34const summary = event.summary || "Untitled event";
3583}
8485async function insertCalendarEvent(date, eventText) {
86const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
8797}
9899export default async function getCalendarEvents() {
100try {
101const events = await getEvents(
stevens-openai.cursorrules15 matches
8### 1. Script Vals
910- Basic JavaScript/TypeScript functions
11- Can be imported by other vals
12- Example structure:
1314```typescript
15export function myFunction() {
16// Your code here
17}
2526```typescript
27export default async function (req: Request) {
28return new Response("Hello World");
29}
3738```typescript
39export default async function () {
40// Scheduled task code
41}
4950```typescript
51export default async function (email: Email) {
52// Process email
53}
5758- Ask clarifying questions when requirements are ambiguous
59- Provide complete, functional solutions rather than skeleton implementations
60- Test your logic against edge cases before presenting the final solution
61- Ensure all code follows Val Town's specific platform requirements
70- **Never bake in secrets into the code** - always use environment variables
71- Include comments explaining complex logic (avoid commenting obvious operations)
72- Follow modern ES6+ conventions and functional programming practices if possible
7374## Val Town Standard Libraries
7576Val Town provides several hosted services and utility functions.
7778### Blob Storage
124```
125126## Val Town Utility Functions
127128Val Town provides several utility functions to help with common project tasks.
129130### Importing Utilities
176{
177name: "should add numbers correctly",
178function: () => {
179expect(1 + 1).toBe(2);
180},
210โ โโโ database/
211โ โ โโโ migrations.ts # Schema definitions
212โ โ โโโ queries.ts # DB query functions
213โ โ โโโ README.md
214โ โโโ index.ts # Main entry point
226โโโ shared/
227โโโ README.md
228โโโ utils.ts # Shared types and functions
229```
230232- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
233- Main entry point should be `backend/index.ts`
234- **Static asset serving:** Use the utility functions to read and serve project files:
235```ts
236// Use the serveFile utility to handle content types automatically
273- Run migrations on startup or comment out for performance
274- Change table names when modifying schemas rather than altering
275- Export clear query functions with proper TypeScript typing
276- Follow the queries and migrations pattern from the example
277