fix: correct semantic endpoint doc comment GET→POST, clamp limit 1-20
Follow-up to PR #1568: fix stale doc comment that still said GET, and add limit parameter validation (default 5, clamped to 1-20 range). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -249,7 +249,7 @@ export class SearchRoutes extends BaseRouteHandler {
|
||||
|
||||
/**
|
||||
* Semantic context search for per-prompt injection
|
||||
* GET /api/context/semantic?q=<prompt>&project=<project>&limit=5
|
||||
* POST /api/context/semantic { q, project?, limit? }
|
||||
*
|
||||
* Queries Chroma for observations semantically similar to the user's prompt.
|
||||
* Returns compact markdown for injection as additionalContext.
|
||||
@@ -257,7 +257,7 @@ export class SearchRoutes extends BaseRouteHandler {
|
||||
private handleSemanticContext = this.wrapHandler(async (req: Request, res: Response): Promise<void> => {
|
||||
const query = (req.body?.q || req.query.q) as string;
|
||||
const project = (req.body?.project || req.query.project) as string;
|
||||
const limit = parseInt(String(req.body?.limit || req.query.limit || '5'), 10);
|
||||
const limit = Math.min(Math.max(parseInt(String(req.body?.limit || req.query.limit || '5'), 10) || 5, 1), 20);
|
||||
|
||||
if (!query || query.length < 20) {
|
||||
res.json({ context: '', count: 0 });
|
||||
|
||||
Reference in New Issue
Block a user