stevensDemogenerateFunFacts.ts8 matches
11* @returns Array of previous fun facts
12*/
13async function getPreviousFunFacts() {
14try {
15const result = await sqlite.execute(
32* @param dates Array of date strings in ISO format
33*/
34async function deleteExistingFunFacts(dates) {
35try {
36for (const date of dates) {
51* @param factText The fun fact text
52*/
53async function insertFunFact(date, factText) {
54try {
55await sqlite.execute(
75* @returns Array of generated fun facts
76*/
77async function generateFunFacts(previousFacts) {
78try {
79// Get API key from environment
197* @returns Array of parsed facts
198*/
199function parseFallbackFacts(responseText, expectedDates) {
200// Try to extract facts using regex
201const factPattern = /(\d{4}-\d{2}-\d{2})["']?[,:]?\s*["']?(.*?)["']?[,}]/gs;
260261/**
262* Main function to generate and store fun facts for the next 7 days
263*/
264export async function generateAndStoreFunFacts() {
265try {
266// Get previous fun facts
301* Intended to be used as a Val Town cron job
302*/
303export default async function() {
304console.log("Running fun facts generation cron job...");
305return await generateAndStoreFunFacts();
stevensDemo.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
stevensDemocronDailyBrief.ts1 match
1import { sendDailyBriefing } from "./sendDailyBrief.ts";
23export async function cronDailyBrief() {
4try {
5const chatId = Deno.env.get("TELEGRAM_CHAT_ID");
aab65694896_.cursorrules12 matches
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4243```ts
44export default async function () {
45// Scheduled task code
46}
5657```ts
58export default async function (email: Email) {
59// Process email
60}
66## Val Town Standard Libraries
6768Val Town provides several hosted services and utility functions.
6970### Blob Storage
120```
121122## Val Town Utility Functions
123124Val Town provides several utility functions to help with common project tasks.
125126### Importing Utilities
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
203โ โ โโโ README.md
204โ โโโ routes/ # Route modules
219โโโ shared/
220โโโ README.md
221โโโ utils.ts # Shared types and functions
222```
223226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
229```ts
230import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263264## Common Gotchas and Solutions
vtEditorFiles.cursorrules12 matches
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4243```ts
44export default async function () {
45// Scheduled task code
46}
5657```ts
58export default async function (email: Email) {
59// Process email
60}
66## Val Town Standard Libraries
6768Val Town provides several hosted services and utility functions.
6970### Blob Storage
120```
121122## Val Town Utility Functions
123124Val Town provides several utility functions to help with common project tasks.
125126### Importing Utilities
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
203โ โ โโโ README.md
204โ โโโ routes/ # Route modules
219โโโ shared/
220โโโ README.md
221โโโ utils.ts # Shared types and functions
222```
223226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
229```ts
230import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263264## Common Gotchas and Solutions
FarcasterMiniAppStoreimage.tsx3 matches
5import satori from "npm:satori";
67export function handleImageEndpoints(app: Hono) {
8const headers = {
9"Content-Type": "image/png",
15}
1617export async function homeImage() {
18return await ogImage(
19<div
53//////////
5455export async function ogImage(body) {
56const svg = await satori(
57body,
17* Custom hook to fetch and manage project files
18*/
19export function useProjectFiles({
20projectId,
21branchId,
OpenTowniexuseChatLogic.ts1 match
13}
1415export function useChatLogic({
16project,
17branchId,
OpenTowniextext-editor.ts7 matches
3import fileWithLinesNumbers from "../utils/fileWithLinesNumbers.ts";
45function printFileType(file: any){
6if (file.type === "interval")
7return " (cron)"
14* View a file or directory in a Val Town project
15*/
16async function view(
17vt: ValTown,
18project: any,
71* Replace a string in a file in a Val Town project
72*/
73async function str_replace(
74vt: ValTown,
75project: any,
133* Create a new file in a Val Town project
134*/
135async function create(vt: ValTown, project: any, branch_id: string | undefined, path: string, file_text?: string) {
136let type_: "file" | "http" | "script";
137if (path.includes("backend/index.ts")) type_ = "http";
167* Insert a string at a specific line in a file in a Val Town project
168*/
169async function insert(
170vt: ValTown,
171project: any,
210* Undo the last edit to a file in a Val Town project (not implemented)
211*/
212async function undo_edit(vt: ValTown, project: any, branch_id: string | undefined) {
213return {
214type: "error",
220* Creates a text editor tool for editing files in a Val Town project
221*/
222export function getTextEditorTool(bearerToken: string, project: any, branch_id: string | undefined) {
223const vt = new ValTown({ bearerToken });
224return anthropic.tools.textEditor_20250124({
OpenTowniexsystem_prompt.txt12 matches
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4041```ts
42export default async function () {
43// Scheduled task code
44}
5253```ts
54export default async function (email: Email) {
55// Process email
56}
60## Val Town Standard Libraries
6162Val Town provides several hosted services and utility functions.
6364### Blob Storage
114```
115116## Val Town Utility Functions
117118Val Town provides several utility functions to help with common project tasks.
119120### Importing Utilities
194โ โโโ database/
195โ โ โโโ migrations.ts # Schema definitions
196โ โ โโโ queries.ts # DB query functions
197โ โ โโโ README.md
198โ โโโ routes/ # Route modules
213โโโ shared/
214โโโ README.md
215โโโ utils.ts # Shared types and functions
216```
217220- Hono is the recommended API framework
221- Main entry point should be `backend/index.ts`
222- **Static asset serving:** Use the utility functions to read and serve project files:
223```ts
224import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
254- Run migrations on startup or comment out for performance
255- Change table names when modifying schemas rather than altering
256- Export clear query functions with proper TypeScript typing
257258## Common Gotchas and Solutions