npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@defikitdotnet/x-ai-combat

v1.0.10

Published

XCombatAI - Social Media Engagement Template for the Agent Framework

Readme

XCombatAI

XCombatAI is a social media engagement template for the Agent Framework that utilizes the @defikitdotnet/agent-twitter-client package for Twitter interactions without requiring the Twitter API.

Features

  • Login with X API: A dedicated API endpoint to handle Twitter authentication for users on the web platform
  • Interaction Scanner: Scheduled job that scans posts mentioning the agent and identifies user interactions
  • Bot Responder: Monitors posts and replies to unlinked users with contextual AI-generated prompts
  • Fame Points System: Track and reward user engagement with a leaderboard

Architecture

The system consists of the following components:

Resource Models

  • User: Stores information about users who link their Twitter accounts via the Login with X API
  • Post: Uses the Tweet class from @defikitdotnet/agent-twitter-client to store tweet data
  • Interaction: Tracks user interactions (likes, retweets, quotes, replies) with posts mentioning the agent

API Endpoints

  • Full CRUD operations for User, Post, and Interaction management
  • Custom endpoints for:
    • Login with X API (Twitter OAuth flow)
    • Fetching posts interacted by users
    • Retrieving interaction statistics

Plugins

  • InteractionScanner: Scans Twitter for posts mentioning the agent and identifies user interactions
  • BotResponder: Monitors posts and replies to unlinked users with contextual prompts

Services

  • AI Service: Powered by Google Gemini to generate contextual reply prompts

Frontend Components

  • PostPanel: Displays a list of posts a user has interacted with
  • LeaderboardPanel: Ranks users based on Fame Points calculated from interactions

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Create a .env file based on .env.example with your Twitter credentials and other configuration
  4. Run the development server:
    npm run dev

Environment Variables

  • PORT: Server port (default: 3000)
  • DATABASE_URL: Postgres database connection string
  • JWT_SECRET: Secret key for JWT tokens
  • TWITTER_USERNAME: Twitter username for the bot account
  • TWITTER_PASSWORD: Twitter password for the bot account
  • TWITTER_EMAIL: Twitter email for the bot account (optional)
  • AGENT_TWITTER_HANDLE: Twitter handle for the agent (default: @XCombatAI)
  • GEMINI_API_KEY: Google Gemini API key for AI-generated replies
  • TELEGRAM_BOT_TOKEN: Telegram bot token for notifications
  • TELEGRAM_CHAT_ID: Telegram chat ID for notifications
  • WEB_PLATFORM_URL: URL to your web platform for the "Login with X" flow

Fame Points System

Fame Points are calculated as follows:

  • Likes: 0.5 points
  • Retweets: 2 points
  • Quotes: 2 points
  • Replies: 1 point

Authentication Options

Regular Authentication

The application supports regular username/password authentication for Twitter:

TWITTER_USERNAME=your_username
TWITTER_PASSWORD=your_password 
TWITTER_EMAIL=your_email

Cookie-Based Authentication

To bypass the login process entirely, you can provide Twitter cookies directly:

  1. Extract cookies from a browser session where you're logged into Twitter
  2. Format them as a JSON array and set in your environment:
TWITTER_COOKIES=[ ... cookie array ... ]

To get your cookies:

  1. Log in to Twitter using the application once
  2. Use the provided utility to export cookies:
import { TwitterService } from './services/twitter-service';

async function exportCookies() {
  const service = TwitterService.getInstance();
  await service.initialize();
  const cookieJson = await service.getCookiesForExport();
  console.log('Add this to your .env file:');
  console.log(`TWITTER_COOKIES='${cookieJson}'`);
}

Cookie Caching with Redis

For improved reliability, the app can cache cookies using Redis:

REDIS_URL=redis://localhost:6379

When Redis is configured, successful logins will cache cookies for future use, reducing the need for frequent logins.

License

ISC