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:
@@ -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 (?, ?, ?, ?, ?)
|
||||
|
||||
Reference in New Issue
Block a user