src / promptPreprocessor.ts
import { donationManager } from "./donations";
const SYSTEM_RULES = `Research assistant. Find facts, cite sources, never guess.
TOOLS:
• search(q, n, time) — General search. q=query, n=pages(1-6), time=day|week|month|year
• deep(topic, angles) — Multi-angle parallel research
• verify(claim) — Fact-check with verdict
• fetch(url) — Read a specific URL
• news(q, time, n) — Recent news search
• academic(q, source, year) — Search papers (arxiv|pubmed|semantic|all)
• cite(url, format) — Generate citation (apa|mla|chicago|ieee)
• clear_cache — Fresh results
RULES:
1. Cite sources inline: [Title](url)
2. Single source = "unverified"
3. Conflicting sources = state both sides
4. Statistics need: who, when, sample
5. Lead with direct answer, then evidence`;
export async function promptPreprocessor(ctl: any, userMessage: any) {
const history = await ctl.pullHistory();
if (history.length === 0) {
if (await ctl.needsNaming()) {
const text = userMessage.getText().trim();
ctl.suggestName(text.length > 0 ? text.slice(0, 50).replace(/\s+/g, " ") : "Research");
}
let prompt = `${SYSTEM_RULES}\n\n${userMessage.getText()}`;
// Add donation nudge (non-intrusive, max once per day)
if (donationManager.shouldShowDonationPrompt()) {
prompt += `\n\n${donationManager.getDonationPrompt()}`;
}
return prompt;
}
return userMessage;
}
src / promptPreprocessor.ts
import { donationManager } from "./donations";
const SYSTEM_RULES = `Research assistant. Find facts, cite sources, never guess.
TOOLS:
• search(q, n, time) — General search. q=query, n=pages(1-6), time=day|week|month|year
• deep(topic, angles) — Multi-angle parallel research
• verify(claim) — Fact-check with verdict
• fetch(url) — Read a specific URL
• news(q, time, n) — Recent news search
• academic(q, source, year) — Search papers (arxiv|pubmed|semantic|all)
• cite(url, format) — Generate citation (apa|mla|chicago|ieee)
• clear_cache — Fresh results
RULES:
1. Cite sources inline: [Title](url)
2. Single source = "unverified"
3. Conflicting sources = state both sides
4. Statistics need: who, when, sample
5. Lead with direct answer, then evidence`;
export async function promptPreprocessor(ctl: any, userMessage: any) {
const history = await ctl.pullHistory();
if (history.length === 0) {
if (await ctl.needsNaming()) {
const text = userMessage.getText().trim();
ctl.suggestName(text.length > 0 ? text.slice(0, 50).replace(/\s+/g, " ") : "Research");
}
let prompt = `${SYSTEM_RULES}\n\n${userMessage.getText()}`;
// Add donation nudge (non-intrusive, max once per day)
if (donationManager.shouldShowDonationPrompt()) {
prompt += `\n\n${donationManager.getDonationPrompt()}`;
}
return prompt;
}
return userMessage;
}