algorithm-cultivation · diff
v1.0 to v2.0
210 added, 30 removed. Audit A to A.
What this update changes in the checks
No check changed: every fixed check gives the same answer before and after this update.
A tripped check is a label, not a verdict: read the matched text and the lines below. This week's updates that newly trip a check.
---
name: algorithm-cultivation
- description: Trains an X/Twitter account's algorithmic feed to surface niche-relevant content and positions the account as a thought leader. Includes browser scripts for manual operation and architecture for 24/7 LLM-powered autonomous agents. Use when a user wants to build up their algorithm, cultivate their feed for a niche, grow a fresh account, become a thought leader, or run automated engagement with AI-generated content.
+ description: Trains an X/Twitter account's algorithmic feed to surface niche-relevant content and positions the account as a thought leader. Includes browser scripts for manual operation, a full Persona Engine for identity management, and a 24/7 Algorithm Builder with LLM-powered engagement via Puppeteer. Use when a user wants to build up their algorithm, cultivate their feed for a niche, grow a fresh account, become a thought leader, or run automated engagement with AI-generated content.
license: MIT
metadata:
author: nichxbt
- version: "1.0"
+ version: "2.0"
---
# Algorithm Cultivation & Thought Leadership
- Train your X/Twitter algorithm for a specific niche. Two approaches: browser script (manual) or headless agent (24/7 autonomous with LLM).
+ Train your X/Twitter algorithm for a specific niche. Three approaches:
+ 1. **Browser script** — paste into DevTools console for manual sessions
+ 2. **CLI + Persona Engine** — create personas and run from the command line
+ 3. **24/7 Algorithm Builder** — headless Puppeteer + LLM running continuously
+
## Quick reference
| Goal | Solution |
|------|----------|
- | Train algorithm via browser console (standalone) | `scripts/thoughtLeaderCultivator.js` |
- | Train algorithm via browser console (with core.js) | `src/automation/algorithmTrainer.js` |
- | Understand how algorithm training works | `docs/research/algorithm-cultivation.md` |
- | Run 24/7 with LLM intelligence | `docs/research/llm-powered-thought-leader.md` |
- | Build prompts for the full agent system | `prompts/09-algorithm-cultivation-system.md` |
+ | Create a persona (CLI) | `xactions persona create` |
+ | Run 24/7 with LLM (CLI) | `xactions persona run <id>` |
+ | Check persona status | `xactions persona status <id>` |
+ | Browser console (with core.js) | `src/automation/algorithmBuilder.js` |
+ | Browser console (standalone) | `scripts/thoughtLeaderCultivator.js` |
+ | Browser console (algorithm trainer) | `src/automation/algorithmTrainer.js` |
+ | Persona Engine (Node.js module) | `src/personaEngine.js` |
+ | Algorithm Builder (Node.js module) | `src/algorithmBuilder.js` |
+ | Research: algorithm internals | `docs/research/algorithm-cultivation.md` |
+ | Research: LLM architecture | `docs/research/llm-powered-thought-leader.md` |
+ ## Persona Engine — `src/personaEngine.js`
+
+ The Persona Engine defines a complete identity for algorithm building:
+
+ **Niche presets** (quick-start templates):
+ - `crypto-degen` — crypto, DeFi, web3, memecoins
+ - `tech-builder` — building in public, SaaS, indie hacking
+ - `ai-researcher` — AI/ML, LLMs, papers, agents
+ - `growth-marketer` — content strategy, copywriting, audience building
+ - `finance-investor` — stocks, markets, portfolio management
+ - `creative-writer` — writing craft, storytelling, books
+ - `custom` — define your own
+
+ **Activity patterns** (human-like schedules):
+ - `night-owl` — active late night, sleeps mornings
+ - `early-bird` — active from 5am, winds down by 10pm
+ - `nine-to-five` — checks before/after work, active evenings
+ - `always-on` — creator schedule, active throughout the day
+ - `weekend-warrior` — light weekdays, heavy weekends
+
+ **Engagement strategies**:
+ - `aggressive` — maximum growth (80 follows, 150 likes, 40 comments/day)
+ - `moderate` — balanced (40 follows, 80 likes, 20 comments/day)
+ - `conservative` — slow and safe (15 follows, 40 likes, 8 comments/day)
+ - `thoughtleader` — quality over quantity (20 follows, 60 likes, 30 deep comments/day)
+
+ **Key exports:**
+ ```js
+ import {
+ createPersona, savePersona, loadPersona, listPersonas, deletePersona,
+ buildPersonaSystemPrompt, buildCommentPrompt, buildPostPrompt,
+ shouldBeActive, planSession, getSessionDuration,
+ NICHE_PRESETS, ACTIVITY_PATTERNS, ENGAGEMENT_STRATEGIES,
+ } from './personaEngine.js';
+ ```
+
+ ## Algorithm Builder — `src/algorithmBuilder.js`
+
+ 24/7 headless automation powered by Puppeteer + OpenRouter LLM.
+
+ **How it works:**
+ 1. Loads a persona config from `~/.xactions/personas/`
+ 2. Launches headless Chrome via Puppeteer (stealth mode)
+ 3. Plans sessions with shuffled activities based on strategy
+ 4. Executes: search → scroll → like → comment (LLM) → follow → post (LLM) → browse
+ 5. Takes breaks between sessions following human-like timing
+ 6. Respects sleep hours from the activity pattern
+ 7. Persists all state and stats to disk after each session
+
+ **LLM features:**
+ - Comments generated by LLM in persona's voice (via OpenRouter)
+ - Original posts created by LLM matching persona's niche and tone
+ - System prompt auto-built from persona config
+ - Supports any OpenRouter model (default: `google/gemini-flash-2.0`)
+
+ **Key exports:**
+ ```js
+ import { startAlgorithmBuilder, runSingleSession } from './algorithmBuilder.js';
+
+ await startAlgorithmBuilder({
+ personaId: 'persona_1234',
+ authToken: 'your_auth_token',
+ headless: true, // false to see the browser
+ dryRun: false, // true to preview without executing
+ maxSessions: 0, // 0 = infinite
+ });
+ ```
+
+ ## CLI commands
+
+ ```bash
+ # Create a persona interactively
+ xactions persona create
+
+ # Create with options
+ xactions persona create --preset crypto-degen --strategy aggressive --activity night-owl
+
+ # List all personas
+ xactions persona list
+
+ # Run the algorithm builder (24/7)
+ xactions persona run <personaId>
+ xactions persona run <personaId> --no-headless # visible browser
+ xactions persona run <personaId> --dry-run # preview mode
+ xactions persona run <personaId> --sessions 5 # stop after 5 sessions
+
+ # Check detailed stats
+ xactions persona status <personaId>
+
+ # Edit persona config
+ xactions persona edit <personaId> --topics "ai,llm,agents" --strategy thoughtleader
+
+ # Delete a persona
+ xactions persona delete <personaId>
+ ```
+
+ ## Environment variables
+
+ | Variable | Purpose |
+ |----------|---------|
+ | `OPENROUTER_API_KEY` | Required for LLM-generated comments and posts |
+ | `XACTIONS_SESSION_COOKIE` | X auth token (alternative to `--token` flag) |
+
## Browser scripts
- ### Standalone: `scripts/thoughtLeaderCultivator.js`
+ ### Full-featured: `src/automation/algorithmBuilder.js`
- Zero dependencies. Paste directly into DevTools console on x.com.
+ Requires pasting `src/automation/core.js` first. 969-line comprehensive browser automation with:
+ - LLM-powered comment generation (OpenRouter or any OpenAI-compatible endpoint)
+ - 6 activity cycles: Search & Engage, Browse Home, Target Account, Explore, Search People, Own Profile
+ - Weighted cycle selection with natural activity rotation
+ - Session/break cycling for 24/7 operation
+ - Peak/off-peak hour awareness
+ - Per-session and per-day rate limits
+ - Full state persistence via localStorage
**Configure:**
- - `YOUR_NICHE.searchTerms` — keywords for your target niche
- - `YOUR_NICHE.comments` — reply templates (picked randomly)
- - `YOUR_NICHE.influencers` — handles to prioritize engaging with
- - `YOUR_PERSONA.mode` — `gentle` | `normal` | `active` | `grind`
- - `TARGETS` — per-session and daily limits
+ - `NICHE_CONFIG.KEYWORDS` — search terms for your niche
+ - `NICHE_CONFIG.PERSONA` — your niche identity (used for LLM persona)
+ - `NICHE_CONFIG.TARGET_ACCOUNTS` — accounts to engage with
+ - `NICHE_CONFIG.BIO_KEYWORDS` — only follow users matching these
+ - `LLM_CONFIG.ENABLED` — enable AI-generated comments
+ - `LLM_CONFIG.API_KEY` — your OpenRouter API key
+ - `LLM_CONFIG.MODEL` — LLM model to use
+ - `BEHAVIOR` — all timing, limits, and probability settings
**Controls:**
+ - `window.stopAlgoBuilder()` — stop after current action
+ - `window.algoStats()` — print all-time stats
+ - `window.algoReset()` — clear state and start fresh
+ - `window.algoConfig()` — show current configuration
+
+ ### Standalone: `scripts/thoughtLeaderCultivator.js`
+
+ Zero dependencies. Paste directly into DevTools console on x.com.
+
+ **Controls:**
- `stopCultivator()` — stop after current action
- `cultivatorStatus()` — print current stats
- `cultivatorReset()` — clear all tracking data
- ### With core.js: `src/automation/algorithmTrainer.js`
-
- Requires pasting `src/automation/core.js` first. More features: multi-niche rotation, intensity presets, cycle-based architecture, richer state tracking.
+ ### Algorithm Trainer: `src/automation/algorithmTrainer.js`
- **Configure:**
- - `NICHES.topics[]` — array of niches with search terms, comments, influencers
- - `PERSONA.INTENSITY` — `chill` | `normal` | `active`
- - `BEHAVIOR` — cycle duration, limits, timing, engagement probabilities
+ Requires `core.js`. Multi-niche rotation, intensity presets, cycle-based architecture.
**Controls:**
- `stopTrainer()` — stop
- `trainerStatus()` — status report
- `trainerReset()` — clear data
## Training phases
Both scripts cycle through these phases with randomized order:
1. **Search Top** — search a niche term, scroll top results, engage
2. **Search Latest** — same term, latest tab (catch fresh content)
3. **Search People** — follow qualifying accounts in the niche
4. **Home Feed** — scroll and engage to reinforce algorithm learning
5. **Influencer Visit** — visit niche leaders' profiles with boosted engagement
6. **Own Profile** — visit own profile (active user signal)
7. **Explore** — browse trending topics (normalization behavior)
8. **Idle** — dwell period simulating human rest
## Algorithm signals (by weight)
| Signal | Weight | Generated by |
|--------|--------|-------------|
| Extended dwell (>2 min on thread) | 11.0x | Scroll + read pause |
| Profile click | 4.0x | Influencer / own profile visits |
| Reply / comment | 1.0-27.0x | Comment on posts |
| Bookmark | ~1.0x | Bookmark quality content |
| Like | 0.5x | Like niche posts |
| Follow | High (graph) | Follow niche accounts |
| Search | High (intent) | Search niche keywords |
## Phase model (fresh account → thought leader)
| Phase | Days | Focus |
|-------|------|-------|
| Seeding | 1-7 | Pure consumption. Search + scroll + like + follow. |
| Engagement | 8-30 | Replies, quote tweets, early engagement on viral posts. |
| Authority | 31-90 | Original threads, community building, Spaces. |
| Maintenance | 90+ | Consistency, content creation, community stewardship. |
## 24/7 LLM-powered operation
- For autonomous 24/7 operation, see `docs/research/llm-powered-thought-leader.md`. Architecture:
+ Now fully implemented via `src/algorithmBuilder.js` + `src/personaEngine.js`.
- - **Headless browser** (Puppeteer + stealth) for X.com interaction
- - **LLM Brain** (tiered models) for content scoring, reply generation, original content creation
- - **Circadian scheduler** with human-like variance (sleep hours, activity fluctuation)
- - **Persistent database** for action logging, metrics, deduplication
- - **Persona manager** ensuring consistent voice across all generated content
+ ### Architecture
- Estimated cost: $8-15/month (VPS + LLM API).
+ ```
+ ┌─────────────────────────────────────────────────┐
+ │ CLI: xactions persona run │
+ ├─────────────────────────────────────────────────┤
+ │ Persona Engine (personaEngine.js) │
+ │ ├─ Niche presets (6 built-in + custom) │
+ │ ├─ Activity patterns (sleep/wake schedules) │
+ │ ├─ Engagement strategies (limits & ratios) │
+ │ ├─ Session planner (shuffled activity queues) │
+ │ └─ State persistence (~/.xactions/personas/) │
+ ├─────────────────────────────────────────────────┤
+ │ Algorithm Builder (algorithmBuilder.js) │
+ │ ├─ Puppeteer + stealth (headless Chrome) │
+ │ ├─ Human-like behavior simulation │
+ │ │ ├─ Variable scroll speeds │
+ │ │ ├─ Reading pauses (2-8s) │
+ │ │ ├─ Mouse movement with jitter │
+ │ │ ├─ Typing with per-char delay (30-100ms) │
+ │ │ ├─ Coffee breaks (30s-2min) │
+ │ │ └─ Session gaps (10-120min) │
+ │ ├─ Activity executor │
+ │ │ ├─ search (top + latest tabs) │
+ │ │ ├─ browse_home (For You timeline) │
+ │ │ ├─ like (on-topic tweets) │
+ │ │ ├─ follow (from search & target accounts) │
+ │ │ ├─ comment (LLM-generated in persona voice)│
+ │ │ ├─ create_post (LLM original content) │
+ │ │ ├─ profile_visit (targets & discovered) │
+ │ │ ├─ check_own_profile │
+ │ │ └─ check_notifications │
+ │ └─ Graceful shutdown (SIGINT/SIGTERM/abort) │
+ ├─────────────────────────────────────────────────┤
+ │ LLM Brain (OpenRouter) │
+ │ ├─ Comment generation (persona-voiced) │
+ │ ├─ Post creation (niche-relevant) │
+ │ ├─ Reply threading │
+ │ └─ Any model: Gemini, GPT-4o, Claude, Llama │
+ └─────────────────────────────────────────────────┘
+ ```
- Build prompts: `prompts/09-algorithm-cultivation-system.md` — 14 detailed prompts covering all components.
+ ### Cost estimate
+ - **VPS**: $5-10/month (any VPS with Chrome support)
+ - **LLM API**: $3-10/month (depends on model and comment volume)
+ - **Total**: ~$8-20/month for 24/7 operation
+
+ ### Getting started (5 minutes)
+
+ ```bash
+ # 1. Set your OpenRouter key
+ export OPENROUTER_API_KEY=sk-or-v1-...
+
+ # 2. Login to X
+ xactions login
+
+ # 3. Create a persona
+ xactions persona create --preset crypto-degen --strategy thoughtleader --activity always-on
+
+ # 4. Start building (runs forever)
+ xactions persona run persona_1234567890
+ ```
## Research paper
Full technical deep dive: `docs/research/algorithm-cultivation.md`
Covers:
- X's recommendation algorithm internals (SimClusters, TwHIN, scoring formula)
- Signal taxonomy (4 tiers of trainable signals)
- Human behavior simulation techniques
- Detection avoidance strategies
- Metrics and measurement framework
- Ethical considerations