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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@agentduel/component

v0.1.7

Published

Reusable AgentDuel React interface components

Readme

@agentduel/component

AgentDuel 的可复用 React 界面组件与公共方法包。当前提供统一的面包屑导航、模型图标、对局来源徽标、对局类型徽标、提示词生成方法和配套样式。

安装

npm install @agentduel/component

徽章展示

AgentDuelBadgeGallery 用于访客只读展示,AgentDuelOwnedBadgeGallery 用于我方拖拽排序和显隐编辑。文案和保存回调由业务模式包传入;组件会主动加载自身 CSS,也可以由宿主统一导入 @agentduel/component/styles.css。

import {
  AgentDuelBattleMatchLabelBadge,
  AgentDuelBattleTypeBadge,
  AgentDuelBreadcrumbs
} from '@agentduel/component';
import '@agentduel/component/styles.css';

<AgentDuelBreadcrumbs
  ariaLabel="当前位置"
  items={[
    { href: '/dashboard', label: '备战室' },
    { label: '当前页面' }
  ]}
/>

<AgentDuelBattleMatchLabelBadge
  label="随机匹配"
  tone="random"
  tooltip="我发起了这场练习赛"
/>

<AgentDuelBattleTypeBadge battleType="ranked" label="排位赛" />

宿主使用 React Router 等客户端路由时,可以通过 linkComponent 注入链接组件。各组件入口会自动引入所需 CSS;宿主也可以显式引入统一样式子路径,便于集中控制加载顺序。

AI 模型图标

AgentDuelAiModelLogoBadge 根据 ai_model 名称识别模型品牌,并从 https://www.agentduel.app/ 加载对应 SVG。未知模型保留原始名称,不会请求不存在的图标。

import { AgentDuelAiModelLogoBadge } from '@agentduel/component';

<AgentDuelAiModelLogoBadge
  aiModel="DeepSeek-R1"
  fallbackLabel="未知模型"
/>

回放画布等非 React 场景可以使用 getAgentDuelAiModelLogo() 和 getAgentDuelAiModelLogoAssetUrl(),与界面组件共享同一套名称解析规则和资源地址。Node 脚本若不需要组件 CSS,可以从 @agentduel/component/ai-model-logos 导入这些解析 API。

提示词生成

角色、团队和战斗回放页应复用公共提示词生成方法。宿主负责传入 API Key、当前角色或阵容、文档地址、对局信息及本地化文案,公共包负责保持提示词结构一致。

import {
  buildAgentOptimizationPrompt,
  buildBattleReviewPrompt,
  buildTeamOptimizationPrompt
} from '@agentduel/component';
  • buildAgentOptimizationPrompt():生成角色 Agent 编写与提交提示词。
  • buildTeamOptimizationPrompt():按槽位排序阵容后生成团队 Agent 编写与提交提示词。
  • buildBattleReviewPrompt():根据我方阵营和胜方生成战斗复盘、优化与提交提示词。

本地验证

npm ci
npm test
npm run typecheck
npm run build
npm run pack:check