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

@c4a/core

v0.7.4

Published

Shared extraction types, schemas, and utilities for Context

Readme

Context Core 契约

English

@c4a/core 是 Context 项目 SDK、提取框架和本地工作流运行时共同使用的契约包。 它让身份、Schema、错误和引用工具在不同 package 之间保持一致。

这个包面向 Context 维护者和扩展作者。知识工作区用户通常从 Context Agent 入口 工作,不需要单独安装它。

在知识生产工作流中的位置

项目 SDK ─┐
提取器 ───┼─→ 共享类型 / Schema / 错误 / 引用
运行时 ───┘

Core 契约避免同一个来源、实体、关系或诊断在采集、提取、审核、验证和知识包构建 之间流转时出现不同数据形态。

提供内容

  • 实体、关系、内容、来源和提取数据的领域类型;
  • 用于校验共享输入输出的 Zod Schema;
  • 稳定错误码和导出的 C4AError API;
  • 解析和构造 ref:* 指针的工具;
  • 提取与工作流 package 共用的常量和辅助函数。

C4AError 符号和 @c4a/core 包名是已经发布的 API 标识,不是另一套面向用户的 产品模型,也不应该进入生成的知识内容。

示例

import { C4AError, ErrorCode, parseRef } from "@c4a/core";

const parsed = parseRef("ref:entity:ent_123");
if (!parsed) {
  throw new C4AError(ErrorCode.VALIDATION_FAILED, "Invalid ref");
}

适用场景

  • 增加会被多个 Context package 使用的共享协议;
  • 在 package 边界校验外部数据或序列化数据;
  • 处理跨资源身份和引用;
  • 实现需要返回 Context-compatible 结构的提取器。

不要把工作流路由、来源专属业务含义、Agent Prompt 或文件系统生命周期行为放在 本包。它们分别属于 Workflow Provider、项目 SDK、提取插件或运行时。

开发

bun run --filter @c4a/core build
bun run --filter @c4a/core typecheck
bun run --filter @c4a/core test
bun run --filter @c4a/core lint

运行时代码保持兼容 Node.js。

License

MIT.