promptPreprocessor.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.promptPreprocessor = promptPreprocessor;
const donations_1 = require("./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`;
async function promptPreprocessor(ctl, userMessage) {
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 (donations_1.donationManager.shouldShowDonationPrompt()) {
prompt += `\n\n${donations_1.donationManager.getDonationPrompt()}`;
}
return prompt;
}
return userMessage;
}
promptPreprocessor.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.promptPreprocessor = promptPreprocessor;
const donations_1 = require("./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`;
async function promptPreprocessor(ctl, userMessage) {
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 (donations_1.donationManager.shouldShowDonationPrompt()) {
prompt += `\n\n${donations_1.donationManager.getDonationPrompt()}`;
}
return prompt;
}
return userMessage;
}