4import { convertToCoreMessages, type CoreUserMessage, streamText } from "npm:ai";
5import { Hono } from "npm:hono";
6import { finishTrackingUsage, insertInferenceCall, overLimit, startTrackingUsage } from "../database/queries.tsx";
7import {
8 getTextEditorTool,
7export const thinkTool = tool({
8 description:
9 "Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.",
10 parameters: z.object({
11 thought: z.string().describe("A thought to think about."),
4import { INFERENCE_CALLS_TABLE, USAGE_TABLE } from "./schema.tsx";
5
6// Eventually we'll have a user database,
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
9- [ ] make it one click to branch off like old jp townie demos
10- [ ] opentownie as a pr bot
11- [ ] give it the ability to see its own client-side and server-side logs by building a middleware that shoves them into a SQL light database date and then give it a tool to access them
12- [ ] do a browser use or screenshot thing to give it access to its own visual output
13- [ ] Have it default to creating a new branch off main
116});
117
118// Database functions
119async function initDatabase() {
120 // Create websites table
121 await sqlite.execute(`
202}
203
204// Initialize database on startup
205initDatabase().catch(console.error);
206
207// Export the Hono app
17- Provides error handling
18
19No external APIs or databases are used. All data is stored in the browser's localStorage.
2import { cors } from "https://esm.sh/hono@3.11.7/middleware";
3import { readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
4import { initializeDatabase } from "./database/migrations.ts";
5import {
6 getAllBooks,
10 updateBook,
11 deleteBook
12} from "./database/queries.ts";
13import { BookCreate, BookUpdate, ReadingStatus } from "../shared/types.ts";
14
15// Initialize the database
16await initializeDatabase();
17
18// Create Hono app
3import { BOOKS_TABLE } from "./migrations.ts";
4
5// Transform database row to Book object
6function rowToBook(row: any): Book {
7 return {
19}
20
21// Initialize the database
22export async function initializeDatabase() {
23 await createBooksTable();
24}
14
15## Project Structure
16- `/backend` - Hono API server and SQLite database
17- `/frontend` - React frontend with TailwindCSS
18- `/shared` - Shared types and utilities