g1t/apps/web/app/routes/repo/memory.tsx
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 1 | import { Brain } from "lucide-react"; |
| 2 | import { Link, data } from "react-router"; | |
| 3 | ||
| 4 | import type { Route } from "./+types/memory"; | |
| 5 | import { page } from "../../lib/meta"; | |
| 6 | import { AddMemory, MemoryList, memoryAction } from "../../components/memory"; | |
| 7 | import { agents } from "../../lib/services.server"; | |
| 8 | import { assertSameOrigin, getViewer, requireUser, roleIn, unwrap } from "../../lib/session.server"; | |
| 9 | ||
| 10 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 11 | return page(args, { title: `Memory · ${params.owner}/${params.repo} · g1t` }); | |
| 12 | } | |
| 13 | ||
| 14 | export async function loader({ params, context }: Route.LoaderArgs) { | |
| 15 | const viewer = getViewer(context); | |
| 16 | // Memory can hold what a workspace keeps to itself: members only. | |
| 17 | if (!roleIn(viewer, params.owner)) throw data(null, { status: 404 }); | |
| 18 | const memories = await agents.listMemories(viewer, params.owner, { namespace: params.owner, name: params.repo }); | |
| 19 | return unwrap(memories); | |
| 20 | } | |
| 21 | ||
| 22 | export async function action({ params, context, request }: Route.ActionArgs) { | |
| 23 | assertSameOrigin(request); | |
| 24 | const user = requireUser(context, request); | |
| 25 | return memoryAction(agents, user, params.owner, { namespace: params.owner, name: params.repo }, await request.formData()); | |
| 26 | } | |
| 27 | ||
| 28 | export default function ProjectMemory({ loaderData, params }: Route.ComponentProps) { | |
| 29 | const { project, workspace } = loaderData; | |
| 30 | const action = `/${params.owner}/${params.repo}/memory`; | |
| 31 | return ( | |
| 32 | <div className="max-w-4xl"> | |
| 33 | <h2 className="flex items-center gap-2 text-xl font-semibold tracking-tight"> | |
| 34 | <Brain size={19} className="text-merged" /> | |
| 35 | Memory | |
| 36 | </h2> | |
| 37 | <p className="mt-1.5 max-w-2xl text-sm text-muted"> | |
| 38 | What agents and people have learned about this project that the next agent should know: how | |
| 39 | to build and test it, its conventions, decisions and why, and its traps. Every g1t agent run | |
| 40 | here is given it, pinned first, together with the workspace's memory. Agents add to it with | |
| 41 | the remember tool as they work; keep it true by editing or forgetting what no longer holds. | |
| 42 | </p> | |
| 43 | ||
| 44 | <div className="mt-6"> | |
| 45 | <AddMemory scope="project" action={action} placeholder="The tests need TZ=UTC or the date tests fail." /> | |
| 46 | </div> | |
| 47 | ||
| 48 | <section className="mt-8"> | |
| 49 | <div className="flex items-baseline justify-between"> | |
| 50 | <h3 className="text-sm font-medium">This project</h3> | |
| 51 | <span className="text-xs text-muted">{project.length} kept</span> | |
| 52 | </div> | |
| 53 | <div className="mt-3"> | |
| 54 | <MemoryList | |
| 55 | memories={project} | |
| 56 | action={action} | |
| 57 | editable | |
| 58 | empty="Nothing yet. Agents add what they learn here as they work, and so can you." | |
| 59 | /> | |
| 60 | </div> | |
| 61 | </section> | |
| 62 | ||
| 63 | <section className="mt-10"> | |
| 64 | <div className="flex items-baseline justify-between"> | |
| 65 | <h3 className="text-sm font-medium">From the workspace</h3> | |
| 66 | <Link to={`/${params.owner}/-/memory`} className="text-xs text-muted hover:text-fg"> | |
| 67 | Manage workspace memory | |
| 68 | </Link> | |
| 69 | </div> | |
| 70 | <p className="mt-1 text-xs text-muted"> | |
| 71 | True across all of {params.owner}'s projects, and given to agents here too. | |
| 72 | </p> | |
| 73 | <div className="mt-3"> | |
| 74 | <MemoryList | |
| 75 | memories={workspace} | |
| 76 | action={`/${params.owner}/-/memory`} | |
| 77 | editable={false} | |
| 78 | empty="The workspace remembers nothing yet." | |
| 79 | /> | |
| 80 | </div> | |
| 81 | </section> | |
| 82 | </div> | |
| 83 | ); | |
| 84 | } |