Skip to content

Open source file-system and knowledge based agent template. Build AI agents that stay up to date with your knowledge base

overall improvements

Hugo Richard962d7f815e79
diff --git a/README.md b/README.md
index 3a1f83b..ba76c0c 100644
--- a/README.md
+++ b/README.md
@@ -143,15 +143,10 @@ GITHUB_CLIENT_SECRET=... # GitHub OAuth app client secret
# AI
AI_GATEWAY_API_KEY=... # Vercel AI Gateway API key
-# Admin
-NUXT_ADMIN_USERS=user1,user2 # Comma-separated admin emails/usernames
-
# Sandbox
# NUXT_GITHUB_SNAPSHOT_REPO=org/repo # Optional default (can be set from admin sandbox UI)
# NUXT_GITHUB_TOKEN=ghp_... # Optional fallback override (GitHub App is the default path)
-# Site
-NUXT_PUBLIC_SITE_URL=https://... # Public URL of your instance
```
See [ENVIRONMENT.md](./docs/ENVIRONMENT.md) for the full list of environment variables.
@@ -219,6 +214,7 @@ bun run lint:fix
## Built With
- [Nuxt](https://nuxt.com) - Full-stack Vue framework
+- [Nuxt UI](https://ui.nuxt.com) - UI component library
- [NuxtHub](https://hub.nuxt.com) - Database, KV, and blob storage
- [Vercel AI SDK](https://ai-sdk.dev) - AI model integration and tool system
- [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox) - Isolated execution environment
diff --git a/apps/app/.env.example b/apps/app/.env.example
index 062f151..b547455 100644
--- a/apps/app/.env.example
+++ b/apps/app/.env.example
@@ -4,11 +4,6 @@
# Copy this file to .env and fill in the values.
# See docs/ENVIRONMENT.md for detailed descriptions.
-# --- Core -------------------------------------------------------------------
-
-NUXT_PUBLIC_SITE_URL=http://localhost:3000
[email protected],your-github-username
-
# --- Authentication ----------------------------------------------------------
BETTER_AUTH_SECRET= # Random secret for signing sessions (generate with: openssl rand -hex 32)
diff --git a/apps/app/app/app.vue b/apps/app/app/app.vue
index c4e9503..1cbfa9e 100644
--- a/apps/app/app/app.vue
+++ b/apps/app/app/app.vue
@@ -24,9 +24,7 @@ useHead({
titleTemplate: `%s - ${appConfig.app.name}`
})
-const config = useRuntimeConfig()
-const siteUrl = config.public.siteUrl as string
-const ogImage = siteUrl ? `${siteUrl.replace(/\/$/, '')}/og.jpg` : '/og.jpg'
+const ogImage = `${useRequestURL().origin}/og.jpg`
useSeoMeta({
title: appConfig.app.name,
diff --git a/apps/app/app/content/docs/admin-mode.md b/apps/app/app/content/docs/admin-mode.md
index 52fea06..2d36db1 100644
--- a/apps/app/app/content/docs/admin-mode.md
+++ b/apps/app/app/content/docs/admin-mode.md
@@ -4,7 +4,7 @@ Admin mode lets you **talk directly to your application**. Instead of searching
## How to Access
-Admin mode is available to users listed in `NUXT_ADMIN_USERS`. When you're an admin, a mode toggle appears on the homepage letting you switch between **Chat** (documentation search) and **Admin** (application monitoring).
+Admin mode is automatically granted to the first user who signs up. Additional admins can be promoted from the admin users page. When you're an admin, a mode toggle appears on the homepage letting you switch between **Chat** (documentation search) and **Admin** (application monitoring).
Admin chats are marked with a shield icon in the sidebar.
diff --git a/apps/app/app/content/docs/getting-started.md b/apps/app/app/content/docs/getting-started.md
index 147d92e..925830c 100644
--- a/apps/app/app/content/docs/getting-started.md
+++ b/apps/app/app/content/docs/getting-started.md
@@ -15,8 +15,6 @@ cp apps/app/.env.example apps/app/.env
| `BETTER_AUTH_SECRET` | Secret used to sign sessions and tokens. See [Better Auth docs](https://www.better-auth.com/docs/installation#set-environment-variables). |
| `GITHUB_CLIENT_ID` | GitHub App client ID (used for OAuth login). See [GitHub App Setup](#github-app-setup) below. |
| `GITHUB_CLIENT_SECRET` | GitHub App client secret |
-| `NUXT_ADMIN_USERS` | Comma-separated list of admin emails or GitHub usernames |
-| `NUXT_PUBLIC_SITE_URL` | Public URL of your instance |
| `AI_GATEWAY_API_KEY` | [Vercel AI Gateway](https://ai-sdk.dev) API key |
`NUXT_GITHUB_SNAPSHOT_REPO` and `NUXT_GITHUB_TOKEN` are optional. You can configure the snapshot repository in the admin sandbox UI after startup, and the app uses a GitHub App installation access token automatically when app credentials are configured.
@@ -133,7 +131,7 @@ npm run dev
```
::
-The app will be available at `http://localhost:3000`. Sign in with GitHub using one of the admin emails or usernames defined in `NUXT_ADMIN_USERS` to access the admin panel.
+The app will be available at `http://localhost:3000`. The first user to sign up is automatically granted admin access.
## Adding Sources
diff --git a/apps/app/app/pages/login.vue b/apps/app/app/pages/login.vue
index 2e04aaa..5093f78 100644
--- a/apps/app/app/pages/login.vue
+++ b/apps/app/app/pages/login.vue
@@ -6,9 +6,7 @@ const appConfig = useAppConfig()
definePageMeta({ layout: false, auth: 'guest' })
-const config = useRuntimeConfig()
-const siteUrl = config.public.siteUrl as string
-const ogImage = siteUrl ? `${siteUrl.replace(/\/$/, '')}/og.jpg` : '/og.jpg'
+const ogImage = `${useRequestURL().origin}/og.jpg`
useSeoMeta({
title: 'Sign in',
@@ -90,7 +88,18 @@ function onGitHub() {
<template>
<div class="flex min-h-dvh bg-default">
<div class="w-full lg:w-1/2 flex items-center justify-center p-8 relative">
- <UColorModeButton class="absolute top-4 right-4" />
+ <div class="absolute top-4 right-4 flex items-center gap-1">
+ <UButton
+ to="https://github.com/vercel-labs/knowledge-agent-template"
+ target="_blank"
+ icon="i-simple-icons-github"
+ color="neutral"
+ variant="ghost"
+ size="md"
+ square
+ />
+ <UColorModeButton />
+ </div>
<div class="w-full max-w-sm">
<div class="text-center mb-8">
@@ -176,9 +185,14 @@ function onGitHub() {
</template>
</p>
- <p class="mt-4 text-center text-xs text-muted/60">
- By continuing, you agree to our terms of service.
- </p>
+ <UAlert
+ class="mt-8"
+ color="neutral"
+ variant="subtle"
+ icon="i-lucide-info"
+ :title="appConfig.app.description"
+ :ui="{ root: 'p-3', title: 'text-xs font-normal', icon: 'size-4' }"
+ />
</div>
</div>
diff --git a/apps/app/nuxt.config.ts b/apps/app/nuxt.config.ts
index 390cb4d..207b5b9 100644
--- a/apps/app/nuxt.config.ts
+++ b/apps/app/nuxt.config.ts
@@ -132,8 +132,6 @@ export default defineNuxtConfig({
},
runtimeConfig: {
- // Admin users (comma-separated GitHub emails or usernames)
- adminUsers: '',
github: {
token: '',
snapshotRepo: '',
@@ -153,7 +151,6 @@ export default defineNuxtConfig({
apiKey: '',
},
public: {
- siteUrl: '',
github: {
appName: '',
botTrigger: '',
diff --git a/apps/app/server/auth.config.ts b/apps/app/server/auth.config.ts
index 4ba21f3..0870df3 100644
--- a/apps/app/server/auth.config.ts
+++ b/apps/app/server/auth.config.ts
@@ -1,11 +1,9 @@
import { admin, apiKey } from 'better-auth/plugins'
import { schema } from '@nuxthub/db'
-import { eq } from 'drizzle-orm'
+import { count, eq } from 'drizzle-orm'
import { defineServerAuth } from '@onmax/nuxt-better-auth/config'
-export default defineServerAuth(({ runtimeConfig, db }) => {
- const adminUsers = runtimeConfig.adminUsers?.split(',').map((s: string) => s.trim().toLowerCase()).filter(Boolean) || []
-
+export default defineServerAuth(({ db }) => {
return {
emailAndPassword: {
enabled: true,
@@ -43,8 +41,9 @@ export default defineServerAuth(({ runtimeConfig, db }) => {
databaseHooks: {
user: {
create: {
- after: async (user: { id: string, email?: string, username?: string }) => {
- if ((user.email && adminUsers.includes(user.email.toLowerCase())) || (user.username && adminUsers.includes(user.username.toLowerCase()))) {
+ after: async (user: { id: string }) => {
+ const result = await db.select({ total: count() }).from(schema.user)
+ if (result[0]!.total === 1) {
await db.update(schema.user).set({ role: 'admin' }).where(eq(schema.user.id, user.id))
}
},
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 45f2d9a..0aee980 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -262,7 +262,7 @@ Both bots use the same AI agent pipeline (router + tools) as the chat interface
Authentication uses [Better Auth](https://www.better-auth.com) with the [`@onmax/nuxt-better-auth`](https://github.com/onmax/nuxt-better-auth) module:
- **Email/password** and **GitHub OAuth** sign-in (via a [GitHub App](https://docs.github.com/en/apps), scope `user:email`)
- **API keys** via Better Auth's [`apiKey` plugin](https://www.better-auth.com/docs/plugins/api-key) (supports `Authorization: Bearer <key>` and `x-api-key` headers)
-- **Admin role** granted to users whose email or username matches `NUXT_ADMIN_USERS`
+- **Admin role** automatically granted to the first registered user; additional admins promoted via the admin panel
### Sandbox
@@ -389,7 +389,7 @@ See [ENVIRONMENT.md](./ENVIRONMENT.md) for the complete list.
- Better Auth handles user sessions, OAuth, and API keys
- API keys support both `Authorization: Bearer <key>` and `x-api-key` headers
-- Admin role is automatically assigned based on `NUXT_ADMIN_USERS`
+- Admin role is automatically assigned to the first registered user
### Sandbox Isolation
diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md
index 4c23de7..9a76b39 100644
--- a/docs/ENVIRONMENT.md
+++ b/docs/ENVIRONMENT.md
@@ -4,13 +4,6 @@
All environment variables for the Knowledge Agent Template project, organized by category.
-## Core
-
-| Variable | Required | Description |
-|----------|----------|-------------|
-| `NUXT_PUBLIC_SITE_URL` | Yes | Public URL of your instance |
-| `NUXT_ADMIN_USERS` | Yes | Comma-separated list of admin emails or GitHub usernames |
-
## Authentication
| Variable | Required | Description |
diff --git a/turbo.json b/turbo.json
index 6700140..75fa9a3 100644
--- a/turbo.json
+++ b/turbo.json
@@ -9,9 +9,7 @@
"inputs": ["$TURBO_DEFAULT$", ".env", ".env.*"],
"outputs": [".vercel/output/**", ".nuxt/**", ".output/**", "dist/**"],
"env": [
- "NUXT_PUBLIC_SITE_URL",
"NUXT_PUBLIC_GITHUB_BOT_TRIGGER",
- "NUXT_ADMIN_USERS",
"NUXT_GITHUB_TOKEN",
"NUXT_GITHUB_SNAPSHOT_REPO",
"NUXT_GITHUB_SNAPSHOT_BRANCH",