YourProgramBuilder, the Seed Bed (Marty 2026-11-17: "keep fleshing it out"): STAGING build

Plant a program free (referral link with {id}, link check green / yellow / red, daily recheck, reports), members save their
referral IDs in its packet, a sponsor-first link (member page / ?r= / the hub sponsor line, then the planter), the sprout meter
to REVIEW_SAVES (DEFAULT 25) -> Marty's review queue -> approved packets exported for the CTB builder / DownlineHydra wild heads
with every saved ID. Dormant old programs confirmed by their owner, old-link redirects (oldrefs), Spotlight on YPBShop (NOT
deployed; DEFAULT $10 / 1,000 views, 20/5/5/5/5, company 60), verified views with Spotlight delivery, trust pack (ledger,
contract, toasts, Telegram card, terms / disclaimer / privacy, TrustClickz only), network footer row, chatbot, promo kit,
Guides, PolHunter slot, LinkSpin tracked-link and zone hooks, AI writer through the hub. Seed-catalog look from the approved
mockup. Tests: qa/unit.test.cjs 33/33, qa/e2e.mjs 121/121 on a local anvil chain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 09:30:59 -06:00
commit a8a1a8eec7
104 changed files with 7632 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
// My packets (the member dashboard): sign in (network account through the hub, or wallet), my packet (status, link check, sprout
// meter, edit / remove), dormant old programs to confirm, the planting form with the AI writer, my saved IDs, Spotlights and earnings.
(async function () {
const $ = YPB.$, esc = YPB.esc;
YPB.wire('other').catch(() => {});
const c = await YPB.getConfig().catch(() => ({}));
const me = await YPB.getJSON('/api/me');
const qs = new URLSearchParams(location.search);
if (!me.signedIn) {
try { const ss = await YPB.getJSON('/api/sso/status'); if (ss && ss.check) { location.replace('/sso/start?mode=check&to=' + encodeURIComponent(location.pathname + location.search)); return; } } catch (e) {}
$('signin').hidden = false; if (c.joinUrl) $('joinLink').href = c.joinUrl;
$('walletBtn').onclick = async () => {
try { YPB.status('Check your wallet for the sign-in message.', '', 'status'); await YPBWallet.signIn(); location.reload(); }
catch (e) { YPB.status(String(e && e.message || e).slice(0, 300), 'err'); }
};
return;
}
$('dash').hidden = false;
$('logout').onclick = async () => { await YPB.post('/api/auth/logout'); location.reload(); };
$('logoutAll').onclick = async () => { $('logoutAll').disabled = true; await YPB.post('/api/auth/logout-everywhere'); location.reload(); };
const tabs = document.querySelectorAll('[data-tab]');
const show = t => { tabs.forEach(b => b.setAttribute('aria-pressed', String(b.dataset.tab === t))); document.querySelectorAll('[data-pane]').forEach(p => { p.hidden = p.dataset.pane !== t; }); };
tabs.forEach(b => { b.onclick = () => show(b.dataset.tab); });
show(['plant', 'saved', 'spot'].includes(qs.get('tab')) ? qs.get('tab') : 'packets');
(c.cats || []).forEach(k => { const o = document.createElement('option'); o.value = k.id; o.textContent = k.name; $('cat').appendChild(o); });
$('cat').value = '0';
const costPicked = () => document.querySelector('input[name=cost]:checked').value;
document.querySelectorAll('input[name=cost]').forEach(r => { r.onchange = () => { $('costRow').hidden = costPicked() !== 'paid'; }; });
let d = null;
const CHECK = { green: '<span class="tag ok">Link check green</span>', yellow: '<span class="tag warn">Link check yellow: waiting for a person</span>', red: '<span class="tag bad">Link check red: not shown</span>' };
const stageTag = x => x.stage === 'review' ? '<span class="tag ok">In review</span>' : x.stage === 'approved' ? '<span class="tag ok">Transplanted</span>' : x.stage === 'rejected' ? '<span class="tag">Not added this time</span>' : '';
function packetBox(x) {
const pctv = Math.min(100, Math.round(100 * x.saves / x.need));
const notes = x.check && x.check.why && x.check.why.length ? '<p class="muted" style="font-size:14px">Check notes: ' + esc(x.check.why.join('; ')) + '</p>' : '';
return '<div class="panel" style="border-width:1.5px;margin-top:10px">'
+ '<div class="row" style="justify-content:space-between"><h3 style="font-size:22px">' + (x.status === 'live' ? '<a href="/p/' + x.id + '">' + esc(x.name) + '</a>' : esc(x.name)) + '</h3><span class="mono" style="font-size:12px">PACKET No. ' + esc(x.no) + '</span></div>'
+ '<p class="meta" style="margin:8px 0">' + (CHECK[x.check && x.check.state] || '') + (x.status === 'held' ? '<span class="tag warn">Held' + (x.heldWhy ? ': ' + esc(x.heldWhy) : '') + '</span>' : '') + stageTag(x) + '</p>'
+ notes + (x.decidedNote ? '<p class="muted" style="font-size:14px">Note: ' + esc(x.decidedNote) + '</p>' : '')
+ '<div class="meter"><div class="lbl"><span>Saved IDs</span><span>' + YPB.n(x.saves) + ' / ' + YPB.n(x.need) + '</span></div><div class="bar"><span style="width:' + pctv + '%"></span></div></div>'
+ '<p class="muted" style="font-size:14px;margin-top:8px">' + YPB.n(x.views) + ' verified views, ' + YPB.n(x.clicks) + ' verified clicks' + (x.spotlight ? ', Spotlight ' + YPB.n(x.spotlight.delivered) + ' / ' + YPB.n(x.spotlight.views) + ' views' : '') + '</p>'
+ '<div class="row"><button class="btn sm" type="button" data-edit="' + x.id + '">Edit</button>' + (x.stage !== 'approved' ? '<button class="btn sm" type="button" data-remove="' + x.id + '">Remove</button>' : '') + (x.status === 'live' ? '<a class="btn sm" href="/spotlight?p=' + x.id + '">Spotlight it</a>' : '') + '</div></div>';
}
async function load() {
d = await YPB.getJSON('/api/my');
if (d.error) return YPB.status(d.error, 'err');
$('who').innerHTML = 'Signed in as ' + (d.username ? '<b>@' + esc(d.username) + '</b>' : esc(YPB.short(d.address))) + (d.netVerified ? ', network member' : ', <a href="' + esc(d.joinUrl) + '">join the network free</a> to plant and save IDs') + (d.test ? ' (staging test member)' : '');
$('myStats').innerHTML = [['Packets planted', d.packets.length], ['IDs saved', d.saved.length], ['Clicks to my links', d.saved.reduce((t, s) => t + (s.clicks || 0), 0)], ['Spotlights bought', d.spotlights.length]].map(s => '<div class="stat"><b>' + YPB.n(s[1]) + '</b><span>' + s[0] + '</span></div>').join('');
if (d.page) { $('pageBox').hidden = false; $('pageUrl').textContent = d.page; $('copyPage').onclick = e => YPB.copy(d.page, e.target); }
$('myPackets').innerHTML = d.packets.length ? d.packets.map(packetBox).join('') : '<p class="muted">Nothing planted yet. <a href="/my?tab=plant" data-go-tab="plant">Plant a program</a>.</p>';
document.querySelectorAll('[data-go-tab]').forEach(a => { a.onclick = e => { e.preventDefault(); show(a.dataset.goTab); }; });
document.querySelectorAll('[data-edit]').forEach(b => { b.onclick = () => edit(d.packets.find(x => x.id === Number(b.dataset.edit))); });
document.querySelectorAll('[data-remove]').forEach(b => { b.onclick = async () => { b.disabled = true; const r = await YPB.post('/api/my/packet/remove', { id: Number(b.dataset.remove) }); if (r.error) { b.disabled = false; return YPB.status(r.error, 'err'); } load(); }; });
if (d.dormant && d.dormant.length) {
$('dormant').hidden = false;
$('dormant').innerHTML = '<b>Your programs from the old YourProgramBuilder</b><br>' + d.dormant.map(x => esc(x.name) + ' <span class="muted">(' + esc(x.url) + ')</span> <button class="btn sm" type="button" data-dorm="' + x.id + '">Confirm it</button>').join('<br>')
+ '<p class="muted" style="font-size:14px;margin:8px 0 0">Confirming opens the planting form with your old link: put {id} where your ID goes, then plant it. It counts as your packet.</p>';
document.querySelectorAll('[data-dorm]').forEach(b => { b.onclick = () => { const x = d.dormant.find(y => y.id === Number(b.dataset.dorm)); reset(); $('dormantId').value = x.id; $('url').value = x.url; $('name').value = x.name; $('plantTitle').textContent = 'Confirm your old program'; show('plant'); }; });
} else $('dormant').hidden = true;
$('savedRows').innerHTML = d.saved.length ? d.saved.map(s => '<tr><td>' + (s.shown ? '<a href="/p/' + s.packetId + '">' + esc(s.name) + '</a>' : esc(s.name) + ' <span class="muted">(not shown now)</span>') + '</td><td class="mono">' + esc(s.refId) + '</td><td class="n">' + YPB.n(s.saves) + '</td><td class="n">' + YPB.n(s.clicks) + '</td><td>' + esc(s.stage) + '</td></tr>').join('')
: '<tr><td colspan="5" class="muted">Open any packet in the <a href="/#bed">Seed Bed</a> and tap Save my ID.</td></tr>';
$('spotRows').innerHTML = d.spotlights.length ? d.spotlights.map(b => '<tr><td>' + esc(YPB.when(b.at)) + '</td><td>Packet ' + esc(b.packetId || '?') + '</td><td class="n">' + YPB.n(b.delivered) + ' / ' + YPB.n(b.views) + '</td><td>' + esc(b.status) + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">No Spotlights bought yet.</td></tr>';
$('earnStats').innerHTML = '<div class="stat"><b>' + YPB.polOf(d.earned.wei) + '</b><span>POL paid to you by Spotlights</span></div>';
$('earnRows').innerHTML = d.earned.items.length ? d.earned.items.map(i => '<tr><td>' + esc(YPB.when(i.at)) + '</td><td>Level ' + i.kind + '</td><td class="n">' + YPB.polOf(i.wei) + ' POL' + (i.failed ? ' (waiting to claim)' : '') + '</td><td>' + (i.buyerName ? '@' + esc(i.buyerName) : '') + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">Nothing yet. Nothing is promised.</td></tr>';
}
function reset() { $('plantForm').reset(); $('editId').value = ''; $('dormantId').value = ''; $('cancelEdit').hidden = true; $('costRow').hidden = true; $('plantTitle').textContent = 'Plant a program'; $('plantBtn').textContent = 'Plant it'; $('cat').value = '0'; }
function edit(x) {
reset(); $('editId').value = x.id; $('url').value = x.url; $('myId').value = x.ownerId || ''; $('name').value = x.name; $('desc').value = x.desc;
document.querySelector('input[name=cost][value=' + (x.cost === 'paid' ? 'paid' : 'free') + ']').checked = true; $('costRow').hidden = x.cost !== 'paid'; $('costText').value = x.costText || '';
$('contract').value = x.contract || ''; $('cat').value = x.cat || '0'; $('plantTitle').textContent = 'Edit packet No. ' + x.no; $('plantBtn').textContent = 'Save the changes'; $('cancelEdit').hidden = false; show('plant');
}
$('cancelEdit').onclick = () => { reset(); show('packets'); };
$('plantForm').onsubmit = async e => {
e.preventDefault(); $('plantBtn').disabled = true; YPB.status('Checking your link...', '');
const body = { id: $('editId').value || undefined, dormant: $('dormantId').value || undefined, url: $('url').value.trim(), myId: $('myId').value.trim(), name: $('name').value, desc: $('desc').value,
cost: costPicked(), costText: $('costText').value, contract: $('contract').value.trim(), cat: $('cat').value };
const r = await YPB.post('/api/my/plant', body); $('plantBtn').disabled = false;
if (r.error) { YPB.status(r.error, 'err'); const f = r.field && $(r.field); if (f && f.focus) f.focus(); return; }
const pk = r.packet; const no = String(pk.id).padStart(3, '0');
YPB.status(pk.check === 'green' ? 'Planted. Packet No. ' + no + ' is in the Seed Bed now.' : 'Planted. Packet No. ' + no + ' waits for a person to look at it first (' + pk.why.join('; ') + ').', pk.check === 'green' ? 'ok' : 'warn');
reset(); await load();
};
// the AI writer (through the hub): a name and a one-sentence description from the program's own page; picking one fills the form
if (c.aiWriter) {
$('aiBox').hidden = false;
$('aiWrite').onclick = async () => {
const box = $('aiList'), url = $('url').value.trim();
if (!/^https?:\/\//i.test(url)) { box.innerHTML = '<p class="note err">Put your referral link in the first box first.</p>'; return; }
$('aiWrite').disabled = true; box.innerHTML = '<p class="muted" style="margin:8px 0 0">Reading the program page...</p>';
const r = await YPB.post('/api/my/adwriter', { url }); $('aiWrite').disabled = false;
if (r.error) { box.innerHTML = '<p class="note err">' + esc(r.error) + '</p>'; return; }
box.innerHTML = r.options.map((o, i) => '<button type="button" class="btn sm" style="margin:8px 8px 0 0;text-align:left" data-ai="' + i + '"><b>' + esc(o.headline) + '</b>' + (o.line ? ': ' + esc(o.line) : '') + '</button>').join('')
+ '<p class="muted" style="font-size:13px;margin:8px 0 0">' + (r.left != null ? r.left + ' writes left today. ' : '') + 'Pick one, then change any words you like.</p>';
box.querySelectorAll('[data-ai]').forEach(b => { b.onclick = () => { const o = r.options[Number(b.dataset.ai)]; $('name').value = String(o.headline || '').slice(0, 40); if (o.line) $('desc').value = String(o.line).slice(0, 200); }; });
};
}
await load();
})();