Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(prompts): keep examples within schema bounds (#804)

copacabanaservice01e2a39507df90
diff --git a/server/src/routes/prompts.js b/server/src/routes/prompts.js
index c01134db4..42784ae1a 100644
--- a/server/src/routes/prompts.js
+++ b/server/src/routes/prompts.js
@@ -630,7 +630,7 @@ router.post('/from-topics', async (req, res) => {
RULES:
- Keep prompts SHORT and concise — between 30 and 100 characters. Aim for 40-80 characters.
-- Write them like real quick searches, e.g. "best CRM for small business" or "top email marketing tools ${new Date().getFullYear()}".
+- Write them like real quick searches, e.g. "best CRM software for growing small businesses" or "top email marketing tools for startups in ${new Date().getFullYear()}".
- Do NOT use the brand name "${brandName}" in the prompts.
- Each prompt should be relevant to the specific topic it belongs to.
- Focus on queries where the brand could organically appear in AI-generated answers.
diff --git a/server/src/routes/prompts.test.js b/server/src/routes/prompts.test.js
new file mode 100644
index 000000000..1e4c5d610
--- /dev/null
+++ b/server/src/routes/prompts.test.js
@@ -0,0 +1,27 @@
+import { describe, expect, it } from 'vitest';
+import { readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+
+const source = readFileSync(fileURLToPath(new URL('./prompts.js', import.meta.url)), 'utf8');
+
+describe('topic prompt examples', () => {
+ it('keeps every documented example within the prompt schema bounds', () => {
+ const schema = source.match(
+ /const topicPromptSchema[\s\S]*?prompts: z\.array\(z\.string\(\)\.min\((\d+)\)\.max\((\d+)\)/,
+ );
+ expect(schema).not.toBeNull();
+ const bounds = { min: Number(schema[1]), max: Number(schema[2]) };
+ const rule = source.match(/- Write them like real quick searches, e\.g\. ([^\n]+)$/m);
+ expect(rule).not.toBeNull();
+ const examples = [...rule[1].matchAll(/"([^"]+)"/g)].map(([, example]) => example);
+ const currentYear = String(new Date().getFullYear());
+ const resolvedExamples = examples.map((example) =>
+ example.replace('${new Date().getFullYear()}', currentYear),
+ );
+
+ for (const example of resolvedExamples) {
+ expect(example.length).toBeGreaterThanOrEqual(bounds.min);
+ expect(example.length).toBeLessThanOrEqual(bounds.max);
+ }
+ });
+});