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

cortico-world-affinity-alont1

v0.1.2

Published

好感度 World:按账号记住关系分数与档位,模型回话前查一下该用什么态度;分数可涨可跌,还会随疏远衰减

Readme

cortico-world-affinity-alont1

好感度 World:按账号记住关系分数与档位,模型回话前查一下该用什么态度。

Cortico 的 World 收不到消息事件(WorldHost 只有 pushEvent,没有订阅),所以这套不让 框架自动计分,而是让模型自己在对话里记账:回话前查一次对方多少分,发生了值得涨跌的 事就记一笔。这样绕开了那个限制,也让模型对"什么算加分"保有判断权。

分数、档位与情绪余波落盘在 <dataDir>/affinity.json。

装

控制台「扩展」页搜 cortico-world,或者:

cd extensions
corepack pnpm add --ignore-workspace cortico-world-affinity-alont1

--ignore-workspace 不能省:少了它 pnpm 会把 extensions/ 当成仓库工作区的一员。 装完重启进程,World 定义在启动时读取。

它给模型什么

三个工具:

| 工具 | 干什么 | |---|---| | affinity_get | 查某个账号的交情:多少分、什么档位、该用什么态度 | | affinity_adjust | 记一笔涨跌,并写一句为什么 | | affinity_list | 看排在前面的几个人 |

外加一段进系统前缀的环境提示词,告诉它回话前先查、什么时候该记一笔, 以及"有些事还没过去"该怎么影响语气。

分数怎么算

默认五个档位,分数落在哪一档就按哪一档的态度说话:

| 分数 | 档位 | |---|---| | 80+ | 好朋友 | | 55+ | 朋友 | | 35+ | 熟人 | | 15+ | 眼熟 | | 0+ | 陌生群友 |

涨跌规则默认是一句话 +0.4(每日上限 12),夸它 +0.6,跟你分享自己的事 +0.8; 骂它 -1.5,命令式使唤 -0.3,最狠的那种冒犯 -3(指什么由你配)。 超过一周不互动,每天掉 0.8;到过 55 分就保底,疏远也掉不破。

这些都是配置,不是写死的。

情绪余波

分数之外还有一层:好感度是长期的关系分,余波是「刚才那事我还没过去」。 被夸或挨骂之后会留一股劲,按半衰期(默认 90 分钟)衰减,低于阈值就不再进提示词。 真人吵完架不会立刻恢复,这一层就是为了那个。

配置

控制台「好感度」页,或者直接改部署的 config.json:

{
  "worlds": {
    "affinity": {
      "enabled": true,
      "startScore": 0,
      "gainPerMessage": 0.4,
      "friendFloor": 55
    }
  }
}

那个"待遇特殊的人"

默认没有这个人——所有人一视同仁,按分数说话。

想让某个账号分数固定、永不掉分(比如你自己),设 favoredId:

{
  "worlds": {
    "affinity": {
      "favoredId": 10001,          // 这个账号分数固定
      "favoredScore": 100,
      "favoredSay": "满分的意思是不用收着——想说什么就说,想找他就找。"
    }
  }
}

favoredSay 用第一人称写,直接进提示词。它决定这个角色怎么对待那个人—— 关系设定(朋友?恋人?家人?)由你在这里定,扩展本身不带这个假设。

最狠的那种冒犯

lossHarsh 是掉分最狠的一档,但"哪种话算"随角色定:

{
  "worlds": {
    "affinity": {
      "lossHarsh": 3,
      "lossHarshNote": "拿体重开玩笑"
    }
  }
}

lossHarshNote 会写进工具描述,模型据此判断哪种话该重罚。

换掉档位文案

档位表和它的态度文案是配置项,空数组就用内置的:

{
  "worlds": {
    "affinity": {
      "tiers": [
        { "min": 80, "name": "自己人", "say": "在他面前不用装,有什么说什么" },
        { "min": 40, "name": "熟人",   "say": "能聊,但不主动" },
        { "min": 0,  "name": "路人",   "say": "客气,话短" }
      ]
    }
  }
}

分数段、档位名、态度文案都是你的。内置那份是中性的通用曲线,不含任何具体角色。

开发

corepack pnpm install
corepack pnpm typecheck

框架以 cortico/<src 下的路径> import(cortico/world.ts、cortico/core/types.ts), 运行时由框架的模块钩子解析到框架源码本身。开发期编辑器与 tsc 需要装 cortico 这个开发依赖:

corepack pnpm add -D cortico

"type": "module" 是硬要求。契约版本 cortico.api 是 4。

许可

MIT