1Shelley is an agentic loop with tool use. See
2https://sketch.dev/blog/agent-loop for an example of the idea.
3
4When Shelley is started with "go run ./cmd/shelley" it starts a web server and
5opens a sqlite database, and users interact with the ui built in ui/. (The
6server itself is implemented in server/; cmd/shelley is a very thing shim.)
7
8## Components
9
10### ui/
11
12TODO: A mobile-first UI.
13Infrastructure:
14 * pnpm
15 * Typescript
16 * esbuild
17 * ESLint and eslint-typescript
18 * VueJS
19 * Jest
20
21### db/
22
23conversation(conversation_id, slug, user_initiated):
24
25 Represents a single conversation.
26
27message(conversation_id, message_id, type (agent/user/tool), llm_data (json), user_data (json), usage (json))
28
29 Messages are visible in the UI and sent to the LLM as part of the
30 conversation. There may be both user-visible and llm-visible representations
31 of messages.
32
33The database is sqlite. We use sqlc to define queries and schema.
34
35TODOX: Subagent/tool conversations are done with user_initiated=false.
36
37### server/
38
39The server serves the agent HTTP API and maintains active
40conversations. The HTTP API is:
41
42/conversations?limit=5000&offset=0
43/conversations?q=search_term
44
45 Returns conversations, either matching a query, or matching
46 the paging requirements.
47
48/conversation/<id>
49
50 Returns all the messages within a conversation.
51
52/conversation/<id>/stream
53
54 Returns all the messages within a conversation and
55 uses SSE to wait for updates.
56
57/conversation/<id>/chat (POST)
58
59 Injects a user message into the conversation
60
61
62When a conversation is active (because it's had a message sent to it, or there
63are stream subscribers), a Conversation struct is instantiated from the data,
64and the server keeps a map of these. Each of these has a Loop struct to keep
65track of the interaction with the llm.
66
67## loop/
68
69The core agentic loop.
70
71## claudetool/
72
73Various tools for the LLM.
74
75
76## Other
77
78Shelley talks to the LLMs using the llm/ library.
79
80Logging happens with slog and the tint library.