feat: demote context startup priority

- cap contexts to 10 per account
- align MCP and onboarding context guidance
- keep contexts optional unless obviously relevant
This commit is contained in:
“BeeRad”
2026-04-13 12:18:47 +10:00
parent 96c72fc908
commit 5dcb2b7df6
15 changed files with 150 additions and 41 deletions
+10
View File
@@ -3,6 +3,7 @@ import type { Context, ContextSummary, Node } from '@/types/database';
import { nodeService } from './nodes';
type ContextRow = Context;
export const MAX_CONTEXTS_PER_ACCOUNT = 10;
function normalizeContextName(name: string): string {
return name.trim().replace(/\s+/g, ' ');
@@ -107,6 +108,15 @@ export class ContextService {
throw new Error(`Context "${name}" already exists.`);
}
const contextCountRow = sqlite.query<{ count: number }>(`
SELECT COUNT(*) AS count
FROM contexts
`).rows[0];
const existingCount = Number(contextCountRow?.count ?? 0);
if (existingCount >= MAX_CONTEXTS_PER_ACCOUNT) {
throw new Error(`Context limit reached. Maximum ${MAX_CONTEXTS_PER_ACCOUNT} contexts are allowed per account.`);
}
const result = sqlite.prepare(`
INSERT INTO contexts (name, description, icon, created_at, updated_at)
VALUES (?, ?, ?, ?, ?)