cnb-agentic-memory 0.1.0__tar.gz

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.
@@ -0,0 +1,27 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+
9
+ # Virtual environments
10
+ .venv/
11
+ venv/
12
+
13
+ # Test / tooling caches
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+ .coverage
18
+ htmlcov/
19
+
20
+ # Editors
21
+ .vscode/
22
+ .idea/
23
+ *.swp
24
+
25
+ # OS
26
+ .DS_Store
27
+ node_modules/
@@ -0,0 +1,80 @@
1
+ # 贡献指南
2
+
3
+ 感谢你对 cnb-agentic-memory (cam) 的关注!欢迎提交 Issue 和 Pull Request。
4
+
5
+ ## 开发环境
6
+
7
+ - Python 3.11+
8
+ - [uv](https://docs.astral.sh/uv/) 包管理(推荐)
9
+ - 仓库:`cnb.cool/cnpc/cam`
10
+
11
+ ## 开发流程
12
+
13
+ ### 1. 安装依赖
14
+
15
+ ```bash
16
+ uv sync --extra dev
17
+ ```
18
+
19
+ ### 2. 提交代码前
20
+
21
+ 运行全部质量检查:
22
+
23
+ ```bash
24
+ # 代码风格
25
+ uv run ruff check src/ tests/
26
+ uv run ruff format --check src/ tests/
27
+
28
+ # 类型检查
29
+ uv run mypy src tests
30
+
31
+ # 单元测试
32
+ uv run pytest tests/ -v
33
+
34
+ # Markdown 文档校验(需 node 环境)
35
+ npx markdownlint-cli2 '**/*.md'
36
+ ```
37
+
38
+ 目标:新增代码的测试覆盖率不低于 90%,所有检查必须通过。
39
+
40
+ ### 3. 提交规范
41
+
42
+ - 提交信息使用中文,遵循 [Conventional Commits](https://www.conventionalcommits.org/) 风格:
43
+ - `feat:` 新功能
44
+ - `fix:` 缺陷修复
45
+ - `refactor:` 重构
46
+ - `docs:` 文档
47
+ - `ci:` 流水线 / CI 配置
48
+ - `test:` 测试
49
+ - `chore:` 杂项
50
+ - 示例:`feat: 支持 memory_append 追加更新记录`
51
+
52
+ ## 代码规范
53
+
54
+ ### 约定
55
+
56
+ - 代码注释与文档使用中文
57
+ - 遵循现有文件命名与函数风格,不做风格重构
58
+ - 新增参数必须有默认值或兼容旧行为
59
+ - 可复用的逻辑必须抽离为独立函数,禁止在多处重复实现
60
+
61
+ ### 架构约束
62
+
63
+ - **零 git 依赖**:存储操作全部走 CNB Open API,禁止引入 git 协议封装
64
+ - **写路径显式校验**:写操作完成后 GET 回读确认,防范 CNB API 静默失败
65
+ - 完整架构约束见 [AGENTS.md](./AGENTS.md),设计方案见 [Issue #1](https://cnb.cool/cnpc/cam/-/issues/1)
66
+
67
+ ### 目录约定
68
+
69
+ - `src/cam/` — 核心(API 客户端 / 工具语义层 / MCP Server / CLI)
70
+
71
+ ## 分支与发布
72
+
73
+ - 开发在短生命周期分支进行,main 分支通过 PR 合并(保护分支)
74
+ - 打 tag(`v*`)触发 CI:测试 → 发布 PyPI → code-wiki → git release
75
+
76
+ ## 测试注意事项
77
+
78
+ - 单元测试使用 `respx` mock CNB API 请求,不依赖真实网络
79
+ - 集成测试(真实 CNB API)不进入 CI,本地手动验证
80
+ - 集成测试需要 `MEMORY_REPO` / `CNB_TOKEN` 环境变量
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cnb-agentic-memory Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.5
2
+ Name: cnb-agentic-memory
3
+ Version: 0.1.0
4
+ Summary: cnb-agentic-memory (cam) — 通用智能体记忆工具:以 CNB Issue 为存储、知识库为检索的 MCP Server
5
+ Project-URL: Homepage, https://cnb.cool/cnpc/cam
6
+ Project-URL: Repository, https://cnb.cool/cnpc/cam
7
+ Project-URL: Issues, https://cnb.cool/cnpc/cam/-/issues
8
+ Author: cnb-agentic-memory Contributors
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,cnb,knowledge-base,llm,mcp,memory
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: httpx>=0.27
22
+ Provides-Extra: dev
23
+ Requires-Dist: mcp<2,>=1.2.0; extra == 'dev'
24
+ Requires-Dist: mypy>=1.10; extra == 'dev'
25
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
26
+ Requires-Dist: pytest>=8.0; extra == 'dev'
27
+ Requires-Dist: respx>=0.21; extra == 'dev'
28
+ Requires-Dist: ruff>=0.4; extra == 'dev'
29
+ Provides-Extra: mcp
30
+ Requires-Dist: mcp<2,>=1.2.0; extra == 'mcp'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # cnb-agentic-memory (cam)
34
+
35
+ [![Latest Release](https://cnb.cool/cnpc/cam/-/badge/release)](https://cnb.cool/cnpc/cam/-/badge/release.link)
36
+ [![PyPI](https://img.shields.io/pypi/v/cnb-agentic-memory.svg)](https://pypi.org/project/cnb-agentic-memory/)
37
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
38
+ [![Python](https://img.shields.io/badge/Python-3.11%2B-3776AB.svg)](https://www.python.org)
39
+
40
+ 基于 CNB 平台构建的通用智能体记忆工具 —— 以 CNB Issue 为存储、CNB 知识库为语义检索,以 MCP Server 形式让任何智能体"记住"跨会话、跨任务的信息。
41
+
42
+ > **核心思路**:完全依托 CNB 现成能力,不写一行存储/检索代码。存储、向量化、检索全部由 CNB 平台承担,cam 只是一个轻量适配层。设计文档见 [Issue #1](https://cnb.cool/cnpc/cam/-/issues/1)。
43
+
44
+ ## 工作原理
45
+
46
+ ```text
47
+ 智能体 ←MCP→ cam MCP Server ←纯 API→ CNB Issue 存储 + 知识库检索
48
+
49
+ issue.open/update/comment/close 事件自动触发 knowledge:update 向量化
50
+ ```
51
+
52
+ - **一条记忆 = 一个 Issue**:`number` 即记忆 id,天然唯一,并发写零冲突
53
+ - **写入即入库**:Issue 变更事件自动触发知识库同步(约 1~2 分钟可检索)
54
+ - **语义检索**:知识库向量召回,从 `metadata.path` 直接定位记忆原文
55
+ - **软删除**:`state=closed` 归档可恢复,`activities` 免费审计日志
56
+
57
+ ## 安装
58
+
59
+ ```bash
60
+ uvx cam-mcp # 免安装直接运行 MCP Server
61
+ pip install "cnb-agentic-memory[mcp]" # 含 MCP 支持
62
+ uv tool install cnb-agentic-memory[mcp]
63
+ ```
64
+
65
+ ## MCP 接入
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "cam": {
71
+ "command": "cam-mcp",
72
+ "env": {
73
+ "MEMORY_REPO": "group/memory-repo",
74
+ "CNB_TOKEN": "<你的 CNB 访问令牌>"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ 环境变量:
82
+
83
+ | 变量 | 说明 |
84
+ | --- | --- |
85
+ | `MEMORY_REPO` | 记忆仓库 slug,如 `group/memory-repo` |
86
+ | `CNB_TOKEN` | 访问令牌,需 `repo-issue:rw`(Issue 读写)+ `repo-code:r`(知识库检索) |
87
+
88
+ ## 工具清单
89
+
90
+ | 工具 | 说明 |
91
+ | --- | --- |
92
+ | `memory_write` | 新增记忆(自动生成关键词标题,两步写入标签) |
93
+ | `memory_update` | 修改记忆内容/标签 |
94
+ | `memory_append` | 追加更新记录(评论,可被语义检索) |
95
+ | `memory_delete` | 软删除(归档,可恢复) |
96
+ | `memory_get` | 按编号精确读取 |
97
+ | `memory_list` | 按分类/标签列出 |
98
+ | `memory_list_recent` | 最近 N 条记忆 |
99
+ | `memory_search` | 语义检索(知识库向量召回为主通道) |
100
+
101
+ ## 记忆仓库初始化
102
+
103
+ 记忆仓库需配置 `.cnb.yml` 启用 Issue → 知识库同步(模板见 [Issue #1 §8](https://cnb.cool/cnpc/cam/-/issues/1))。后续版本将提供 `cam init --repo <slug>` 一键初始化。
104
+
105
+ ## 文档
106
+
107
+ - [设计方案与实测依据](https://cnb.cool/cnpc/cam/-/issues/1) — 完整设计 + 全量 PoC 实测结论
108
+ - [贡献指南](CONTRIBUTING.md)
109
+ - [安全策略](SECURITY.md)
110
+
111
+ ## 贡献指南
112
+
113
+ 欢迎参与贡献!请参考 [CONTRIBUTING.md](./CONTRIBUTING.md)。
114
+
115
+ ## 许可证
116
+
117
+ [MIT](./LICENSE)
@@ -0,0 +1,85 @@
1
+ # cnb-agentic-memory (cam)
2
+
3
+ [![Latest Release](https://cnb.cool/cnpc/cam/-/badge/release)](https://cnb.cool/cnpc/cam/-/badge/release.link)
4
+ [![PyPI](https://img.shields.io/pypi/v/cnb-agentic-memory.svg)](https://pypi.org/project/cnb-agentic-memory/)
5
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
6
+ [![Python](https://img.shields.io/badge/Python-3.11%2B-3776AB.svg)](https://www.python.org)
7
+
8
+ 基于 CNB 平台构建的通用智能体记忆工具 —— 以 CNB Issue 为存储、CNB 知识库为语义检索,以 MCP Server 形式让任何智能体"记住"跨会话、跨任务的信息。
9
+
10
+ > **核心思路**:完全依托 CNB 现成能力,不写一行存储/检索代码。存储、向量化、检索全部由 CNB 平台承担,cam 只是一个轻量适配层。设计文档见 [Issue #1](https://cnb.cool/cnpc/cam/-/issues/1)。
11
+
12
+ ## 工作原理
13
+
14
+ ```text
15
+ 智能体 ←MCP→ cam MCP Server ←纯 API→ CNB Issue 存储 + 知识库检索
16
+
17
+ issue.open/update/comment/close 事件自动触发 knowledge:update 向量化
18
+ ```
19
+
20
+ - **一条记忆 = 一个 Issue**:`number` 即记忆 id,天然唯一,并发写零冲突
21
+ - **写入即入库**:Issue 变更事件自动触发知识库同步(约 1~2 分钟可检索)
22
+ - **语义检索**:知识库向量召回,从 `metadata.path` 直接定位记忆原文
23
+ - **软删除**:`state=closed` 归档可恢复,`activities` 免费审计日志
24
+
25
+ ## 安装
26
+
27
+ ```bash
28
+ uvx cam-mcp # 免安装直接运行 MCP Server
29
+ pip install "cnb-agentic-memory[mcp]" # 含 MCP 支持
30
+ uv tool install cnb-agentic-memory[mcp]
31
+ ```
32
+
33
+ ## MCP 接入
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "cam": {
39
+ "command": "cam-mcp",
40
+ "env": {
41
+ "MEMORY_REPO": "group/memory-repo",
42
+ "CNB_TOKEN": "<你的 CNB 访问令牌>"
43
+ }
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ 环境变量:
50
+
51
+ | 变量 | 说明 |
52
+ | --- | --- |
53
+ | `MEMORY_REPO` | 记忆仓库 slug,如 `group/memory-repo` |
54
+ | `CNB_TOKEN` | 访问令牌,需 `repo-issue:rw`(Issue 读写)+ `repo-code:r`(知识库检索) |
55
+
56
+ ## 工具清单
57
+
58
+ | 工具 | 说明 |
59
+ | --- | --- |
60
+ | `memory_write` | 新增记忆(自动生成关键词标题,两步写入标签) |
61
+ | `memory_update` | 修改记忆内容/标签 |
62
+ | `memory_append` | 追加更新记录(评论,可被语义检索) |
63
+ | `memory_delete` | 软删除(归档,可恢复) |
64
+ | `memory_get` | 按编号精确读取 |
65
+ | `memory_list` | 按分类/标签列出 |
66
+ | `memory_list_recent` | 最近 N 条记忆 |
67
+ | `memory_search` | 语义检索(知识库向量召回为主通道) |
68
+
69
+ ## 记忆仓库初始化
70
+
71
+ 记忆仓库需配置 `.cnb.yml` 启用 Issue → 知识库同步(模板见 [Issue #1 §8](https://cnb.cool/cnpc/cam/-/issues/1))。后续版本将提供 `cam init --repo <slug>` 一键初始化。
72
+
73
+ ## 文档
74
+
75
+ - [设计方案与实测依据](https://cnb.cool/cnpc/cam/-/issues/1) — 完整设计 + 全量 PoC 实测结论
76
+ - [贡献指南](CONTRIBUTING.md)
77
+ - [安全策略](SECURITY.md)
78
+
79
+ ## 贡献指南
80
+
81
+ 欢迎参与贡献!请参考 [CONTRIBUTING.md](./CONTRIBUTING.md)。
82
+
83
+ ## 许可证
84
+
85
+ [MIT](./LICENSE)
@@ -0,0 +1,47 @@
1
+ # 安全策略
2
+
3
+ cnb-agentic-memory (cam) 是基于 CNB 平台的智能体记忆工具,涉及 CNB API 凭据管理与智能体记忆读写。我们高度重视安全问题。
4
+
5
+ ## 支持版本
6
+
7
+ 仅最新稳定版本接收安全补丁,不对旧版本进行回溯修复。
8
+
9
+ | 版本 | 支持状态 |
10
+ | --- | --- |
11
+ | 最新稳定版 | ✅ |
12
+ | < 最新 | ❌ |
13
+
14
+ 请查看 [Releases](https://cnb.cool/cnpc/cam/-/releases) 获取当前版本信息。
15
+
16
+ ## 报告漏洞
17
+
18
+ **请勿通过公开 Issue 报告安全漏洞。**
19
+
20
+ 请通过以下方式私下报告:
21
+
22
+ - **CNB 私信**:在仓库页面发起私密讨论,标题注明 `[SECURITY]`
23
+ - **邮件**:发送至项目维护者,主题行包含 `[SECURITY]`
24
+
25
+ 报告中请包含:
26
+
27
+ - 漏洞描述及被利用后的影响
28
+ - 复现步骤或概念验证代码
29
+ - 受影响的版本和配置信息
30
+ - 建议的缓解方案(可选)
31
+
32
+ ## 响应时间线
33
+
34
+ | 阶段 | 目标时间 |
35
+ | --- | --- |
36
+ | 确认接收 | 收到报告后 48 小时内 |
37
+ | 评估分类 | 5 个工作日内 — 评估严重程度、影响范围和修复方案 |
38
+ | 补丁发布(严重) | 评估完成后 14 天内 |
39
+ | 补丁发布(中等/低危) | 下一个功能版本发布或与维护者协商的时间线 |
40
+ | 公开披露 | 补丁发布且用户有充分时间更新后 |
41
+
42
+ ## 安全设计原则
43
+
44
+ - **凭据安全**:CNB 访问令牌通过环境变量(`CNB_TOKEN`)传入,绝不写入代码、日志或文档;工具对用户请求中的令牌类内容应拒绝存储(见 MCP 客户端交互规范)
45
+ - **最小权限**:令牌仅需 `repo-issue:rw`(Issue 读写)+ `repo-code:r`(知识库检索),文档明确告知用户所需最小权限集
46
+ - **软删除优先**:记忆删除为 Issue 归档(state=closed),保留完整审计链(activities),无物理删除
47
+ - **输入校验**:记忆编号、标签命名严格校验,非法输入返回清晰错误
File without changes
@@ -0,0 +1,75 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "cnb-agentic-memory"
7
+ version = "0.1.0"
8
+ description = "cnb-agentic-memory (cam) — 通用智能体记忆工具:以 CNB Issue 为存储、知识库为检索的 MCP Server"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "cnb-agentic-memory Contributors" },
14
+ ]
15
+ keywords = ["mcp", "memory", "agent", "cnb", "knowledge-base", "llm"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+
27
+ dependencies = [
28
+ "httpx>=0.27",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ # MCP server(upper bound 强制:mcp v2 移除 fastmcp 兼容路径)
33
+ mcp = [
34
+ "mcp>=1.2.0,<2",
35
+ ]
36
+ dev = [
37
+ "pytest>=8.0",
38
+ "pytest-asyncio>=0.23",
39
+ "respx>=0.21",
40
+ "ruff>=0.4",
41
+ "mypy>=1.10",
42
+ "mcp>=1.2.0,<2",
43
+ ]
44
+
45
+ [project.scripts]
46
+ cam-mcp = "cam.mcp_server:main"
47
+ cam = "cam.cli:main"
48
+
49
+ [project.urls]
50
+ Homepage = "https://cnb.cool/cnpc/cam"
51
+ Repository = "https://cnb.cool/cnpc/cam"
52
+ Issues = "https://cnb.cool/cnpc/cam/-/issues"
53
+
54
+ [tool.hatch.build.targets.wheel]
55
+ packages = ["src/cam"]
56
+
57
+ [tool.hatch.build.targets.sdist]
58
+ include = ["src", "tests", "docs", "README.md", "LICENSE", "CONTRIBUTING.md", "SECURITY.md", "pyproject.toml"]
59
+
60
+ [tool.pytest.ini_options]
61
+ testpaths = ["tests"]
62
+ asyncio_mode = "auto"
63
+
64
+ [tool.ruff]
65
+ line-length = 110
66
+ target-version = "py311"
67
+
68
+ [tool.ruff.lint]
69
+ select = ["E", "F", "I", "W", "UP", "B"]
70
+ ignore = ["E501"]
71
+
72
+ [tool.mypy]
73
+ python_version = "3.11"
74
+ packages = ["src/cam"]
75
+ ignore_missing_imports = true
@@ -0,0 +1,9 @@
1
+ """cnb-agentic-memory (cam) — 基于 CNB 平台的通用智能体记忆工具。
2
+
3
+ 以 CNB Issue 为存储、CNB 知识库为语义检索,以 MCP Server 形式
4
+ 让任何智能体"记住"跨会话、跨任务的信息。
5
+ """
6
+
7
+ __version__ = "0.1.0"
8
+
9
+ __all__ = ["__version__"]
@@ -0,0 +1,6 @@
1
+ """cam CLI 入口(骨架)。"""
2
+
3
+
4
+ def main() -> None:
5
+ """CLI 入口(子命令实现中)。"""
6
+ raise SystemExit("cam CLI 尚在开发中,设计方案见 https://cnb.cool/cnpc/cam/-/issues/1")
@@ -0,0 +1,6 @@
1
+ """cam-mcp 入口:MCP Server 启动(骨架,工具注册见设计文档 cnpc/cam#1 §3)。"""
2
+
3
+
4
+ def main() -> None:
5
+ """启动 MCP Server(工具面实现中)。"""
6
+ raise SystemExit("cam MCP Server 尚在开发中,工具面设计见 https://cnb.cool/cnpc/cam/-/issues/1")
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ """包基础自检。"""
2
+
3
+ from cam import __version__
4
+
5
+
6
+ def test_version() -> None:
7
+ assert __version__ == "0.1.0"