fix(ROUTING-0001): repair repo routing and isolate MCP filtering
This commit is contained in:
@@ -39,6 +39,7 @@ import { GET as getJobs } from './jobs/+server.js';
|
||||
import { GET as getJob } from './jobs/[id]/+server.js';
|
||||
import { GET as getVersions, POST as postVersions } from './libs/[id]/versions/+server.js';
|
||||
import { GET as getContext } from './context/+server.js';
|
||||
import { DEFAULT_TOKEN_BUDGET } from '$lib/server/api/token-budget.js';
|
||||
|
||||
const NOW_S = Math.floor(Date.now() / 1000);
|
||||
|
||||
@@ -325,6 +326,40 @@ describe('API contract integration', () => {
|
||||
expect(body).toContain('Result count: 0');
|
||||
});
|
||||
|
||||
it('GET /api/v1/context does not token-filter default JSON responses for the UI', async () => {
|
||||
const repositoryId = seedRepo(db);
|
||||
const documentId = seedDocument(db, repositoryId);
|
||||
|
||||
seedSnippet(db, {
|
||||
documentId,
|
||||
repositoryId,
|
||||
type: 'info',
|
||||
title: 'Large result',
|
||||
content: 'Large result body',
|
||||
tokenCount: DEFAULT_TOKEN_BUDGET + 1
|
||||
});
|
||||
seedSnippet(db, {
|
||||
documentId,
|
||||
repositoryId,
|
||||
type: 'info',
|
||||
title: 'Small result',
|
||||
content: 'Small result body',
|
||||
tokenCount: 5
|
||||
});
|
||||
|
||||
const response = await getContext({
|
||||
url: new URL(
|
||||
`http://test/api/v1/context?libraryId=${encodeURIComponent(repositoryId)}&query=${encodeURIComponent('result')}`
|
||||
)
|
||||
} as never);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
const body = await response.json();
|
||||
|
||||
expect(body.snippets).toHaveLength(2);
|
||||
expect(body.resultCount).toBe(2);
|
||||
});
|
||||
|
||||
it('GET /api/v1/context returns additive repository and version metadata for versioned results', async () => {
|
||||
const repositoryId = seedRepo(db);
|
||||
const versionId = seedVersion(db, repositoryId, 'v18.3.0');
|
||||
|
||||
Reference in New Issue
Block a user