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");
stevensDemoApp.tsx2 matches
62};
6364export function App() {
65const [memories, setMemories] = useState<Memory[]>([]);
66const [loading, setLoading] = useState(true);
139const data = await response.json();
140141// Change the sorting function to show memories in chronological order
142const sortedMemories = [...data].sort((a, b) => {
143const dateA = a.createdDate || 0;
untitled-1572main.tsx3 matches
1// src/pages/api/tool.tsx
23export default async function httpHandler(req: Request): Promise<Response> {
4// 1οΈβ£ Only accept POST
5if (req.method !== "POST") {
22console.log(body.message.toolCalls);
23console.log("arguments:");
24let args: any = body.message.toolCalls[0]?.function.arguments;
25console.log(args);
2650* Map your incoming args to Zendesk customβfield IDs
51*/
52function mapToZendeskFields(
53args: Args,
54sessionId: string, // hard-coded per your example
ChatStreamingChat.tsx1 match
47};
4849export default function StreamingChat({
50config,
51messages,
ChatEnhancedCommandPalette.tsx2 matches
71}
7273// Helper functions for JSON Schema handling
74const getDefaultValue = (schema: any): any => {
75if (schema.default !== undefined) return schema.default;
151};
152153export default function EnhancedCommandPalette({
154servers,
155query,
56/**
7* Main cron function - always looks at the last 7 days
8*/
9export default async function githubChangelogNotifier(): Promise<void> {
10const now = new Date();
11const sevenDaysAgo = new Date(now.getTime() - SEVEN_DAYS_MS);
Change-Logs-Generatorprocess-commits.tsx11 matches
1/**
2* Helper functions for cron (gh-to-discord.tsx) and playground.tsx
3*/
450* Check if a commit author should be skipped (bots, etc.)
51*/
52function shouldSkipAuthor(commit: any): boolean {
53const authorUsername = commit.author?.login || commit.commit.author.name || "";
54return SKIP_AUTHORS.some((skipAuthor) => authorUsername.toLowerCase().includes(skipAuthor.toLowerCase()));
58* Generate a user-focused summary of a commit using GPT
59*/
60async function generateUserFocusedSummary(
61fullCommitMessage: string,
62commitType: string,
6566const prompt =
67`You are documenting commit changes for Steel, a browser API for AI agents. Write a clear, descriptive one-line summary of what this commit actually changed. Be specific about components and functionality, but avoid unnecessary repetition.
6869Commit message:
113* Format a single commit into a clean message with category
114*/
115export async function formatCommit(commit: any) {
116const fullMessage = commit.commit.message; // Get full message including description
117const originalMessage = fullMessage.split("\n")[0];
146* Categorize commits into organized groups
147*/
148export async function categorizeCommits(commits: any[]) {
149const categorizedCommits: Record<string, { messages: string[] }> = {};
150178* Build the Discord message from categorized commits
179*/
180export function buildDiscordMessage(
181categorizedCommits: Record<string, { messages: string[] }>,
182repoName: string,
246* Split a long Discord message into multiple messages respecting Discord's character limit
247*/
248function splitDiscordMessage(content: string): string[] {
249if (content.length <= DISCORD_MESSAGE_LIMIT) {
250return [content];
303* Fetch commits from GitHub for the given date range
304*/
305export async function fetchCommits(
306since: string,
307until: string,
392* Fetch commits and post to Discord
393*/
394export async function fetchAndPostCommits(
395since: string,
396until: string,
416const discordMessageContent = buildDiscordMessage(
417categorizedCommits,
418"", // No longer needed since we build repo list inside the function
419since,
420until,
4// Handles the initial cancellation event and sends a Discord notification
5// with customer details, subscription info, and cancellation reason
6async function handleCancellation(subscription: any, stripeKey: string) {
7const amount = subscription.items?.data?.[0]?.price?.unit_amount ||
8subscription.plan?.amount || 0;
simple-imagespage.ts4 matches
29</style>
30<script>
31function edit(task, origin) {
32return "https://image.pollinations.ai/prompt/" + encodeURIComponent(task) + "?model=" + document.getElementById("editModel").value + "&image=" + encodeURIComponent(origin) + "&referrer=tgpt&nofeed=true&nologo=true";
33}
34
35function create(task) {
36return "https://image.pollinations.ai/prompt/" + encodeURIComponent(task) + "?model=" + document.getElementById("createModel").value + "&nofeed=true&nologo=true";
37}
38
39function newImage() {
40addImage(create(prompt("Creation Prompt")))
41}
42
43function addImage(url) {
44let img = new Image();
45img.src = url;