49 lines
1.4 KiB
Markdown
49 lines
1.4 KiB
Markdown
|
|
# Task ID: 44
|
||
|
|
|
||
|
|
**Title:** Create prompt-index API endpoint
|
||
|
|
|
||
|
|
**Status:** done
|
||
|
|
|
||
|
|
**Dependencies:** 42 ✓
|
||
|
|
|
||
|
|
**Priority:** medium
|
||
|
|
|
||
|
|
**Description:** Create GET /api/v1/projects/:name/prompt-index endpoint that returns a compact index of prompts (name, priority, summary, chapters) for a project.
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
1. Add route in `/src/mcpd/src/routes/prompts.ts`:
|
||
|
|
```typescript
|
||
|
|
fastify.get('/api/v1/projects/:name/prompt-index', async (request, reply) => {
|
||
|
|
const { name } = request.params as { name: string };
|
||
|
|
const project = await projectService.findByName(name);
|
||
|
|
if (!project) {
|
||
|
|
return reply.status(404).send({ error: 'Project not found' });
|
||
|
|
}
|
||
|
|
|
||
|
|
const prompts = await promptService.findByProject(project.id);
|
||
|
|
const index = prompts.map(p => ({
|
||
|
|
name: p.name,
|
||
|
|
priority: p.priority,
|
||
|
|
summary: p.summary,
|
||
|
|
chapters: p.chapters,
|
||
|
|
linkTarget: p.linkTarget,
|
||
|
|
}));
|
||
|
|
|
||
|
|
return reply.send({ prompts: index });
|
||
|
|
});
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Consider adding global prompts to the index (inherited by all projects)
|
||
|
|
|
||
|
|
3. Sort by priority descending in response
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
- Unit test: Returns compact index for valid project
|
||
|
|
- Unit test: Index contains name, priority, summary, chapters, linkTarget
|
||
|
|
- Unit test: 404 for non-existent project
|
||
|
|
- Unit test: Empty array for project with no prompts
|
||
|
|
- Unit test: Results sorted by priority descending
|
||
|
|
- Integration test: End-to-end retrieval matches database state
|