Site assistant (Marty 2026-11-15): chat widget in the 5xYourTeam draft-night look on every page, CANNED + FACTS from this repo's code (position $10 one time, 5 picks, sponsor 25% + L2-5 5% + pot 10% + company 45%, pass-up 20 places, Monday 7 PM Central draft, earned order, 3-day return, 48 h hold, 10 open picks, no contact data), retrieval over the shared network knowledge base on the hub (netkb.js, home entries boosted, another site named = its answer), reasoning off, account problems hand off to network support. chatbot.test 187, unit 62/62, smoke 160/160, iap-tank 35/35
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"site": "fivex",
|
||||
"home": [
|
||||
{ "q": "What is 5xYourTeam?", "kb": "about", "must": ["draft", "\\$10", "Monday"] },
|
||||
{ "q": "How much is a position and what do I get?", "kb": "position", "must": ["\\$10", "5 instant picks", "never a subscription"] },
|
||||
{ "q": "Where does the $10 go?", "kb": "split", "must": ["25%", "5%", "10%", "45%"] },
|
||||
{ "q": "When is the draft?", "kb": "draft", "must": ["Monday at 7 PM Central", "5 rounds", "auto-picked"] },
|
||||
{ "q": "How is draft order decided?", "kb": "order", "must": ["earned", "started"] },
|
||||
{ "q": "What happens to a pick that does not start?", "kb": "picks", "must": ["3 days", "48 hours"] },
|
||||
{ "q": "Do I get my picks' email addresses?", "kb": "picks", "must": ["never get their email", "site messages"] },
|
||||
{ "q": "How is the Best Coach pot shared?", "kb": "pot", "must": ["10%", "50/30/20", "not promised"] },
|
||||
{ "q": "How do I withdraw my earnings?", "kb": "withdraw", "must": ["nothing to withdraw"] },
|
||||
{ "q": "Is this a pyramid scheme?", "kb": "safe", "must": ["contract", "not income"] }
|
||||
],
|
||||
"cross": [
|
||||
{ "q": "How much is Pro on DownlineHydra?", "site": "downlinehydra" },
|
||||
{ "q": "What is a ViralAdBlitz Boost?", "site": "viraladblitz" },
|
||||
{ "q": "How do Downline Banners spots work?", "site": "bannerline" },
|
||||
{ "q": "What is a LinkSpin spin link?", "site": "linkspin" },
|
||||
{ "q": "What are InstantAdPay ad packages?", "site": "iap" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// Site assistant checks (2026-11-15): node qa/chatbot.test.mjs
|
||||
// No network: a stand-in OpenRouter and a stand-in hub. Checks the instant answers route every example question to its own entry,
|
||||
// the house rules (no em dashes, no MetaMask, never RM Circle, ad-credits line where credits come up, no income promises),
|
||||
// the network merge (home boosted, a named site boosted), the support hand-off, and the site's scripted Q&A (qa/chat-qa.json:
|
||||
// home questions must land on the named entry and contain the expected facts).
|
||||
// The SAME file ships in every rebuilt network site.
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import http from 'node:http';
|
||||
import { createRequire } from 'node:module';
|
||||
const require = createRequire(import.meta.url);
|
||||
const ROOT = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||
|
||||
const DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'chat-'));
|
||||
process.env.DATA_DIR = DIR; delete process.env.DOCSTORE_URL; process.env.NETKB = '0'; delete process.env.OPENROUTER_API_KEY;
|
||||
let pass = 0, fail = 0; const bad = [];
|
||||
const ok = (c, m) => { if (c) pass++; else { fail++; bad.push(m); console.log('FAIL', m); } };
|
||||
|
||||
// stand-in OpenRouter: answers with what the system prompt says about the first KB entry, so we can see the prompt
|
||||
let lastPrompt = '', reply = 'Fine.';
|
||||
const or = http.createServer((req, res) => { let b = ''; req.on('data', c => { b += c; }); req.on('end', () => {
|
||||
const j = JSON.parse(b); lastPrompt = j.messages[0].content; ok(j.reasoning && j.reasoning.enabled === false, 'reasoning is switched off');
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' }); res.end('\n\n' + JSON.stringify({ choices: [{ message: { content: reply } }] })); }); });
|
||||
await new Promise(r => or.listen(0, r));
|
||||
process.env.OPENROUTER_URL = 'http://127.0.0.1:' + or.address().port + '/v1/chat/completions';
|
||||
|
||||
const cfg = require(path.join(ROOT, 'config.js')); if (cfg.reset) cfg.reset();
|
||||
const bot = require(path.join(ROOT, 'chatbot.js'));
|
||||
const core = require(path.join(ROOT, 'chatcore.js'));
|
||||
const kb = require(path.join(ROOT, 'kb.js'));
|
||||
const netkb = require(path.join(ROOT, 'netkb.js'));
|
||||
const dataDir = bot.SITE.dataDir;
|
||||
await bot.init();
|
||||
|
||||
// 1. seeds and the fast path: every example question of a canned entry lands on that entry (first match wins)
|
||||
const seeds = core.seeds();
|
||||
ok(seeds.length >= 12, 'at least 12 seeded entries (' + seeds.length + ')');
|
||||
for (const c of bot.CANNED) {
|
||||
ok(c.re instanceof RegExp, c.id + ' has a pattern');
|
||||
for (const q of c.q || []) { const hit = await kb.fastPath(q); ok(hit && hit.id === 'c-' + c.id, 'example "' + q + '" -> ' + c.id + ' (got ' + (hit && hit.id) + ')'); }
|
||||
}
|
||||
// 2. house rules in every seeded answer
|
||||
for (const s of seeds) {
|
||||
ok(!/[—―]/.test(s.answer + s.title), s.id + ': no em dashes');
|
||||
ok(!/metamask/i.test(s.answer), s.id + ': never recommends MetaMask');
|
||||
ok(!/rm ?circle/i.test(s.answer), s.id + ': never RM Circle');
|
||||
ok(!/(guarantee[ds]? (income|earnings|profit)|you will (earn|make)|passive income|get rich|up to \$?\d[\d,.]* (a|per) (day|week|month))/i.test(s.answer), s.id + ': no income promise');
|
||||
if (/\bad credits?\b/i.test(s.answer)) ok(/Ad credits buy advertising, not income\./.test(s.answer), s.id + ': ad credits line');
|
||||
if (/wallet/i.test(s.answer) && /(which|use|recommend)/i.test(s.answer) && /safepal/i.test(s.answer)) ok(/SafePal or any other crypto wallet/i.test(s.answer), s.id + ': wallet wording');
|
||||
}
|
||||
// 3. the engine: scrub, support hand-off, the AI path
|
||||
ok(core.scrub('A — B, use MetaMask or SafePal') === 'A, B, use SafePal', 'scrub: em dash and MetaMask (' + core.scrub('A — B, use MetaMask or SafePal') + ')');
|
||||
{ const r = await bot.answer('I need to talk to a real person about my account'); ok(r.handoff === true, 'asking for a person hands off'); }
|
||||
{ const r = await bot.answer(''); ok(!!r.error, 'empty question refused'); }
|
||||
fs.writeFileSync(path.join(dataDir || DIR, 'openrouter.key'), 'test-key');
|
||||
reply = 'Sure — try RM Circle'; { const r = await bot.answer('zzqx unrelated words nobody wrote down'); ok(!/rm ?circle/i.test(r.reply) && !/—/.test(r.reply), 'an RM Circle or em dash reply never leaves (' + r.reply + ')'); }
|
||||
ok(/NEVER promise or estimate income/.test(lastPrompt) && /SafePal or any other crypto wallet/.test(lastPrompt) && /Ad credits buy advertising, not income\./.test(lastPrompt), 'house rules in the system prompt');
|
||||
reply = 'Fine.';
|
||||
|
||||
// 4. the network merge: home boosted, a named site boosted, labelled with the site and its link
|
||||
const GENERAL = bot.CANNED.find(c => !['support', 'refund', 'about'].includes(c.id) && (c.q || []).length).q[0].replace(/\?$/, '');
|
||||
netkb._set({ version: 'v1', sites: { othersite: { name: 'Other Site', url: 'https://other.example', count: 1 }, [process.env.HUB_SITE || bot.SITE.hubSite]: { name: bot.SITE.name, url: bot.SITE.url } },
|
||||
entries: [{ site: 'othersite', id: 'about', title: 'What is Other Site?', questions: ['What is Other Site?', GENERAL + ' on Other Site'], answer: 'Other Site is a test site with its own rules.', tags: ['test'] }] });
|
||||
await kb.load(true);
|
||||
{ const hits = await kb.search(GENERAL, 8); const top = hits[0] && hits[0].entry; ok(top && !top.site, 'home entries first for a general question (top ' + (top && top.id) + ')'); }
|
||||
{ const hits = await kb.search(GENERAL + ' on Other Site', 8); const top = hits[0] && hits[0].entry; ok(top && top.site === 'othersite', 'a named site boosts its own entry (top ' + (top && top.id) + ')'); }
|
||||
{ const block = kb.promptBlock(await kb.context('What is Other Site', 6)); ok(/about Other Site, another network site; send people to https:\/\/other\.example/.test(block), 'remote entry labelled with site and link'); }
|
||||
{ const fp = await kb.fastPath('What is Other Site?'); ok(!fp || !String(fp.id).startsWith('othersite:'), 'other sites never take the fast path'); }
|
||||
{ const r = await bot.answer(GENERAL + ' on Other Site'); ok(!r.canned, 'a question naming another site skips this site\'s instant answers (' + r.kb + ')'); }
|
||||
{ const r = await bot.answer('I need a real person, my order on Other Site failed'); ok(r.handoff === true, 'a hand-off still wins when another site is named'); }
|
||||
{ const r = await bot.answer(bot.CANNED.find(c => c.id === 'about').q[0]); ok(r.canned && r.kb === 'c-about', 'this site\'s own name keeps the instant answer'); }
|
||||
{ const own = await kb.own(); ok(own.length === seeds.length && own.every(e => !e.site), 'publish set = this site\'s own entries only'); }
|
||||
|
||||
// 5. the scripted Q&A (home questions)
|
||||
const qaFile = path.join(ROOT, 'qa', 'chat-qa.json');
|
||||
if (fs.existsSync(qaFile)) {
|
||||
const qa = JSON.parse(fs.readFileSync(qaFile, 'utf8'));
|
||||
for (const t of qa.home || []) {
|
||||
const r = await bot.answer(t.q);
|
||||
if (t.kb) ok(r.kb === 'c-' + t.kb || (Array.isArray(r.kb) && r.kb.includes('c-' + t.kb)), 'Q&A "' + t.q + '" -> ' + t.kb + ' (got ' + JSON.stringify(r.kb) + ')');
|
||||
for (const m of t.must || []) ok(new RegExp(m, 'i').test(r.reply) || new RegExp(m, 'i').test(lastPrompt), 'Q&A "' + t.q + '" mentions /' + m + '/');
|
||||
}
|
||||
}
|
||||
or.close();
|
||||
console.log((fail ? 'FAILED ' : 'ok ') + pass + ' passed, ' + fail + ' failed');
|
||||
process.exit(fail ? 1 : 0);
|
||||
|
Before Width: | Height: | Size: 439 KiB After Width: | Height: | Size: 341 KiB |
|
Before Width: | Height: | Size: 290 KiB After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 683 KiB After Width: | Height: | Size: 666 KiB |
|
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 174 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 237 KiB After Width: | Height: | Size: 157 KiB |
|
Before Width: | Height: | Size: 562 KiB After Width: | Height: | Size: 456 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 195 KiB After Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 454 KiB After Width: | Height: | Size: 279 KiB |
|
Before Width: | Height: | Size: 481 KiB After Width: | Height: | Size: 364 KiB |
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 247 KiB |
|
Before Width: | Height: | Size: 492 KiB After Width: | Height: | Size: 474 KiB |
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 238 KiB After Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 525 KiB After Width: | Height: | Size: 413 KiB |
|
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 138 KiB |
|
Before Width: | Height: | Size: 462 KiB After Width: | Height: | Size: 275 KiB |
@@ -1 +1 @@
|
||||
2026-11-15T13:45:12.044Z 156 passed, 0 failed
|
||||
2026-11-15T18:52:47.772Z 160 passed, 0 failed
|
||||
|
||||
@@ -114,7 +114,7 @@ listen(TG_PORT, async (q, r, b) => { TG.push({ method: q.url.split('/').pop(), t
|
||||
const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '', ALLOW_TEST_CLOCK: '1', TANK_MODE: 'stub',
|
||||
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid', NETWORK_SITES_HUB: '0', DRAFT_TICK_MS: '200', DRAFT_PICK_SECONDS: '300',
|
||||
CONTRACT_ADDRESS: SHOP, PRIZE_WALLET: PRIZE, CHAIN_RPC: 'http://127.0.0.1:' + CHAIN_PORT, KEEPER_KEY: KEEPER_PK, SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '200', EXPLORER: 'https://explorer.invalid',
|
||||
HUB_ENABLED: '1', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'fivex', HUB_TICK_MS: '300', HUB_DOWN_MS: '300', HUB_CACHE_MS: '200',
|
||||
HUB_ENABLED: '1', NETKB: '0', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'fivex', HUB_TICK_MS: '300', HUB_DOWN_MS: '300', HUB_CACHE_MS: '200',
|
||||
TG_LIVE: '1', TG_TOKEN: 'standin-token', TG_CHAT: '-100123', TG_PAY_TOPIC: '632242', TG_API: 'http://127.0.0.1:' + TG_PORT, OWNER_USERNAME: 'coachann' });
|
||||
process.on('exit', () => { try { srv && srv.kill(); } catch (e) {} });
|
||||
|
||||
@@ -185,6 +185,14 @@ async function main() {
|
||||
let r = await anon.req('/team'); ok(r.headers.get('x-frame-options') === 'DENY', '/team is never framed');
|
||||
r = await anon.req('/nobody-at-all'); ok(r.status === 404 && /Back to the draft board/.test(await r.text()), 'an unknown coach name: 404');
|
||||
r = await anon.req('/api/my'); ok(r.status === 401, '/api/my needs sign-in');
|
||||
// the site assistant (2026-11-15): widget on every page, canned answers without AI, account problems hand off, admin KB behind the token
|
||||
{ const home = await (await anon.req('/')).text();
|
||||
ok(/<script src="\/assets\/chat\.js\?v=\d+" defer><\/script>/.test(home) && /polhunter\.com/.test(home) && (await anon.req('/assets/chat.js')).status === 200 && (await anon.req('/assets/chat.css')).status === 200, 'chat widget on the page (PolHunter embed kept), its script and styles served'); }
|
||||
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'Where does the $10 go?' }) }); const cj = await cr.json();
|
||||
ok(cr.status === 200 && cj.canned && /25%/.test(cj.reply) && /45%/.test(cj.reply), 'chat: canned split answer', cj); }
|
||||
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'my position did not show up' }) }); const cj = await cr.json();
|
||||
ok(cj.handoff === true && /^https:\/\/instantadpay\.com\/support\?from=fivex/.test(cj.support || ''), 'chat: account problem hands off to network support', cj); }
|
||||
ok((await anon.req('/api/admin/kb')).status === 401, 'admin KB needs the token');
|
||||
let b = await anon.json('/api/board');
|
||||
ok(b.poolSize === 29 && b.pool.length === 24 && b.pool.every(p => p.gameWei === undefined && p.surfWei === undefined), 'the pool (stub tank: 29 draftable of 35); visitors see scouting facts but no earnings', { size: b.poolSize, keys: Object.keys(b.pool[0]) });
|
||||
ok(!b.pool.some(p => /lockedlarry|hasasponsor|xx_spam_xx|temp_mail_9|brandnew|twiceadopted/.test(p.username)), 'never locked, sponsored, spam, throwaway, inside the grace or adopted twice', b.pool.map(p => p.username));
|
||||
|
||||