Towniesystem_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
Towniestyles.css2 matches
160transition-property: background-color;
161transition-duration: 400ms;
162transition-timing-function: linear;
163}
164769transition-property: color, background-color, border-color, opacity;
770transition-duration: 200ms;
771transition-timing-function: ease-in-out;
772}
773
TowniesoundEffects.ts3 matches
1/**
2* Sound effects utility functions for the application
3*/
47* @returns A Promise that resolves when the sound has started playing
8*/
9export function playBellSound(): Promise<void> {
10return new Promise((resolve) => {
11try {
69* @returns A Promise that resolves when the sound has started playing
70*/
71export function playSimpleNotification(): Promise<void> {
72return new Promise((resolve) => {
73try {
TownieRequireAuthRoute.tsx1 match
7import { useAuth } from "../hooks/useAuth.tsx";
89export function RequireAuthRoute () {
10const location = useLocation();
11const { isAuthenticated } = useAuth();
TownieProjectsRoute.tsx3 matches
4import { Loading } from "./Loading.tsx";
56export function ProjectsRoute () {
7const projects = useProjects();
842}
4344function ProjectCard ({
45user,
46project,
81}
8283function Privacy ({ privacy }: {
84privacy: "public"|"unlisted"|"private";
85}) {
TowniePreview.tsx1 match
10}
1112export function Preview({ projectFiles, messages, running }: PreviewProps) {
13const [selectedEndpointIndex, setSelectedEndpointIndex] = useState<number>(0);
14const [customPath, setCustomPath] = useState<string>("/");
TowniePreviewFrame.tsx4 matches
9}
1011export function PreviewFrame (props: PreviewProps) {
12const previewKey = useRef<string>("new-chat");
13const [count, setCount] = useState<number>(0);
77const TSRE = /\/$/;
7879function URLInput ({ url, pathname, setPathname }) {
80const prefix = url.replace(TSRE, "");
81return (
94}
9596function PreviewSelect ({ index, setIndex, files }) {
97return (
98<div>
120}
121122function usePreviewURL ({ files }) {
123const [index, setIndex] = useState<number>(0);
124const htmlVals = files?.filter(file => file.links?.endpoint !== undefined);
TownieNotFoundRoute.tsx1 match
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
23export function NotFoundRoute () {
4return (
5<div className="container">Page not found</div>
TownieNewProjectRoute.tsx2 matches
4import { useCreateProject } from "../hooks/useCreateProject.tsx";
56export function NewProjectRoute () {
7const [name, setName] = useState("");
8const [privacy, setPrivacy] = useState("public");
65]
6667function PrivacyRadios ({
68value,
69onChange,
TownieMessages.tsx8 matches
14};
1516export function Messages ({
17messages,
18messageEndTimes,
40}
4142function Message ({
43message,
44messageEndTimes,
60}
6162function AssistantMessage ({ message, messageEndTimes, running }: {
63message: Message;
64messageEndTimes: Record<string, number>;
85}
8687function Part ({ part }) {
88switch (part.type) {
89case "text":
100}
101102function TextPart ({ part }) {
103return (
104<ReactMarkdown>
108}
109110function ToolPart ({ part }) {
111const {
112toolName,
154}
155156function EditorToolPart ({ part }) {
157const {
158toolName,
220}
221222function UserMessage ({ message }: {
223message: Message;
224}) {