@c4a/core 0.6.8 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,23 +1,38 @@
1
- # @c4a/core
1
+ # Context Core Contracts
2
2
 
3
- `@c4a/core` is the shared foundation package for Context. It provides reusable types, schemas, error definitions, and utility helpers used across multiple packages.
3
+ [简体中文](./README.zh-CN.md)
4
4
 
5
- ## Installation
5
+ `@c4a/core` is the shared contract package used by Context's project SDK,
6
+ extraction framework, and local workflow runtime. It keeps identities, schemas,
7
+ errors, and reference helpers consistent across package boundaries.
6
8
 
7
- ```bash
8
- bun add @c4a/core
9
- # or
10
- npm install @c4a/core
9
+ This package is infrastructure for Context maintainers and extension authors.
10
+ Knowledge-workspace users normally work through the Context Agent entry and do
11
+ not install it directly.
12
+
13
+ ## Place in the knowledge workflow
14
+
15
+ ```text
16
+ project SDK ─┐
17
+ extractors ──┼─→ shared types / schemas / errors / references
18
+ runtime ─────┘
11
19
  ```
12
20
 
13
- ## What It Includes
21
+ Core contracts prevent the same source, entity, relation, or diagnostic from
22
+ acquiring different shapes as it moves from capture to extraction, review,
23
+ verification, and package build.
14
24
 
15
- - **Domain types**: common TypeScript types for entities, relations, contents, and sources
16
- - **Schema definitions**: Zod-based input/output validation models
17
- - **Error system**: unified error codes and `C4AError`
18
- - **Ref utilities**: helpers for parsing and building `ref:*` pointers
19
- - **Shared constants and helpers**: reusable utilities for Context extraction
20
- and CLI packages
25
+ ## What it provides
26
+
27
+ - domain types for entities, relations, content, sources, and extraction data;
28
+ - Zod schemas for validating shared inputs and outputs;
29
+ - stable error codes and the exported `C4AError` API;
30
+ - helpers for parsing and constructing `ref:*` pointers;
31
+ - constants and utilities shared by extraction and workflow packages.
32
+
33
+ The `C4AError` symbol and `@c4a/core` package name are published API
34
+ identifiers. They are not a separate user-facing product model and should not
35
+ be copied into generated knowledge content.
21
36
 
22
37
  ## Example
23
38
 
@@ -30,12 +45,28 @@ if (!parsed) {
30
45
  }
31
46
  ```
32
47
 
33
- ## Common Use Cases
48
+ ## Use this package when
49
+
50
+ - adding a shared protocol consumed by more than one Context package;
51
+ - validating external or serialized data at a package boundary;
52
+ - working with cross-resource identities and references;
53
+ - implementing an extractor that must return Context-compatible structures.
54
+
55
+ Do not place workflow routing, source-specific business meaning, Agent prompts,
56
+ or filesystem lifecycle behavior here. Those belong to the workflow Provider,
57
+ project SDK, extraction plugins, or runtime respectively.
58
+
59
+ ## Development
60
+
61
+ ```bash
62
+ bun run --filter @c4a/core build
63
+ bun run --filter @c4a/core typecheck
64
+ bun run --filter @c4a/core test
65
+ bun run --filter @c4a/core lint
66
+ ```
34
67
 
35
- - Reuse a single contract across a monorepo to avoid type drift
36
- - Validate external inputs with consistent schemas and error handling
37
- - Parse and build cross-resource reference pointers
68
+ Runtime code remains Node.js compatible.
38
69
 
39
70
  ## License
40
71
 
41
- MIT
72
+ MIT.
@@ -0,0 +1,67 @@
1
+ # Context Core 契约
2
+
3
+ [English](./README.md)
4
+
5
+ `@c4a/core` 是 Context 项目 SDK、提取框架和本地工作流运行时共同使用的契约包。
6
+ 它让身份、Schema、错误和引用工具在不同 package 之间保持一致。
7
+
8
+ 这个包面向 Context 维护者和扩展作者。知识工作区用户通常从 Context Agent 入口
9
+ 工作,不需要单独安装它。
10
+
11
+ ## 在知识生产工作流中的位置
12
+
13
+ ```text
14
+ 项目 SDK ─┐
15
+ 提取器 ───┼─→ 共享类型 / Schema / 错误 / 引用
16
+ 运行时 ───┘
17
+ ```
18
+
19
+ Core 契约避免同一个来源、实体、关系或诊断在采集、提取、审核、验证和知识包构建
20
+ 之间流转时出现不同数据形态。
21
+
22
+ ## 提供内容
23
+
24
+ - 实体、关系、内容、来源和提取数据的领域类型;
25
+ - 用于校验共享输入输出的 Zod Schema;
26
+ - 稳定错误码和导出的 `C4AError` API;
27
+ - 解析和构造 `ref:*` 指针的工具;
28
+ - 提取与工作流 package 共用的常量和辅助函数。
29
+
30
+ `C4AError` 符号和 `@c4a/core` 包名是已经发布的 API 标识,不是另一套面向用户的
31
+ 产品模型,也不应该进入生成的知识内容。
32
+
33
+ ## 示例
34
+
35
+ ```ts
36
+ import { C4AError, ErrorCode, parseRef } from "@c4a/core";
37
+
38
+ const parsed = parseRef("ref:entity:ent_123");
39
+ if (!parsed) {
40
+ throw new C4AError(ErrorCode.VALIDATION_FAILED, "Invalid ref");
41
+ }
42
+ ```
43
+
44
+ ## 适用场景
45
+
46
+ - 增加会被多个 Context package 使用的共享协议;
47
+ - 在 package 边界校验外部数据或序列化数据;
48
+ - 处理跨资源身份和引用;
49
+ - 实现需要返回 Context-compatible 结构的提取器。
50
+
51
+ 不要把工作流路由、来源专属业务含义、Agent Prompt 或文件系统生命周期行为放在
52
+ 本包。它们分别属于 Workflow Provider、项目 SDK、提取插件或运行时。
53
+
54
+ ## 开发
55
+
56
+ ```bash
57
+ bun run --filter @c4a/core build
58
+ bun run --filter @c4a/core typecheck
59
+ bun run --filter @c4a/core test
60
+ bun run --filter @c4a/core lint
61
+ ```
62
+
63
+ 运行时代码保持兼容 Node.js。
64
+
65
+ ## License
66
+
67
+ MIT.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/core",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "type": "module",
5
5
  "description": "Shared extraction types, schemas, and utilities for Context",
6
6
  "license": "MIT",