cognitive-modules 0.1.0__tar.gz → 0.1.1__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.
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/LICENSE +1 -1
- cognitive_modules-0.1.1/PKG-INFO +289 -0
- cognitive_modules-0.1.1/README.md +237 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/pyproject.toml +12 -7
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/registry.py +1 -1
- cognitive_modules-0.1.1/src/cognitive_modules.egg-info/PKG-INFO +289 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive_modules.egg-info/requires.txt +5 -0
- cognitive_modules-0.1.0/PKG-INFO +0 -295
- cognitive_modules-0.1.0/README.md +0 -247
- cognitive_modules-0.1.0/src/cognitive_modules.egg-info/PKG-INFO +0 -295
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/setup.cfg +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/__init__.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/cli.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/loader.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/providers/__init__.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/runner.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/subagent.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/templates.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive/validator.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive_modules.egg-info/SOURCES.txt +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive_modules.egg-info/dependency_links.txt +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive_modules.egg-info/entry_points.txt +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/src/cognitive_modules.egg-info/top_level.txt +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/tests/test_cli.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/tests/test_loader.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/tests/test_registry.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/tests/test_runner.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/tests/test_subagent.py +0 -0
- {cognitive_modules-0.1.0 → cognitive_modules-0.1.1}/tests/test_validator.py +0 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cognitive-modules
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Structured LLM task runner with schema validation, confidence scoring, and subagent orchestration
|
|
5
|
+
Author: ziel-io
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ziel-io/cognitive-modules
|
|
8
|
+
Project-URL: Documentation, https://github.com/ziel-io/cognitive-modules#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/ziel-io/cognitive-modules
|
|
10
|
+
Project-URL: Issues, https://github.com/ziel-io/cognitive-modules/issues
|
|
11
|
+
Keywords: llm,cognitive,modules,ai,cli,schema,validation,prompt,agent,subagent
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: jsonschema>=4.17.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Requires-Dist: typer>=0.9.0
|
|
29
|
+
Requires-Dist: rich>=13.0.0
|
|
30
|
+
Provides-Extra: openai
|
|
31
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
32
|
+
Provides-Extra: anthropic
|
|
33
|
+
Requires-Dist: anthropic>=0.18.0; extra == "anthropic"
|
|
34
|
+
Provides-Extra: ollama
|
|
35
|
+
Requires-Dist: requests>=2.28.0; extra == "ollama"
|
|
36
|
+
Provides-Extra: minimax
|
|
37
|
+
Requires-Dist: openai>=1.0.0; extra == "minimax"
|
|
38
|
+
Provides-Extra: all
|
|
39
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
40
|
+
Requires-Dist: anthropic>=0.18.0; extra == "all"
|
|
41
|
+
Requires-Dist: requests>=2.28.0; extra == "all"
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
44
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
45
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
46
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
47
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
48
|
+
Provides-Extra: docs
|
|
49
|
+
Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
|
|
50
|
+
Requires-Dist: pymdown-extensions>=10.0.0; extra == "docs"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
# Cognitive Modules
|
|
54
|
+
|
|
55
|
+
[](https://github.com/ziel-io/cognitive-modules/actions/workflows/ci.yml)
|
|
56
|
+
[](https://pypi.org/project/cognitive-modules/)
|
|
57
|
+
[](https://www.python.org/downloads/)
|
|
58
|
+
[](https://opensource.org/licenses/MIT)
|
|
59
|
+
|
|
60
|
+
> 可验证的结构化 AI 任务规范
|
|
61
|
+
|
|
62
|
+
Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、可验证、可审计**的生成任务设计。
|
|
63
|
+
|
|
64
|
+
## 特性
|
|
65
|
+
|
|
66
|
+
- **强类型契约** - JSON Schema 双向验证输入输出
|
|
67
|
+
- **可解释输出** - 强制输出 `confidence` + `rationale`
|
|
68
|
+
- **子代理编排** - `@call:module` 支持模块间调用
|
|
69
|
+
- **参数传递** - `$ARGUMENTS` 运行时替换
|
|
70
|
+
- **多 LLM 支持** - OpenAI / Anthropic / MiniMax / Ollama
|
|
71
|
+
- **公共注册表** - `cog install registry:module-name`
|
|
72
|
+
|
|
73
|
+
## 安装
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 基础安装
|
|
77
|
+
pip install cognitive-modules
|
|
78
|
+
|
|
79
|
+
# 带 LLM 支持
|
|
80
|
+
pip install cognitive-modules[openai] # OpenAI
|
|
81
|
+
pip install cognitive-modules[anthropic] # Claude
|
|
82
|
+
pip install cognitive-modules[all] # 全部
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 快速开始
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# 配置 LLM
|
|
89
|
+
export LLM_PROVIDER=openai
|
|
90
|
+
export OPENAI_API_KEY=sk-xxx
|
|
91
|
+
|
|
92
|
+
# 或使用 MiniMax
|
|
93
|
+
export LLM_PROVIDER=minimax
|
|
94
|
+
export MINIMAX_API_KEY=sk-xxx
|
|
95
|
+
|
|
96
|
+
# 运行代码审查
|
|
97
|
+
cog run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
|
|
98
|
+
|
|
99
|
+
# 运行任务排序
|
|
100
|
+
cog run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --pretty
|
|
101
|
+
|
|
102
|
+
# 运行 API 设计
|
|
103
|
+
cog run api-designer --args "用户系统 CRUD API" --pretty
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 与 Skills 对比
|
|
107
|
+
|
|
108
|
+
| | Skills | Cognitive Modules |
|
|
109
|
+
|---|--------|------------------|
|
|
110
|
+
| 定位 | 轻量指令扩展 | 可验证的结构化任务 |
|
|
111
|
+
| 输入校验 | ❌ | ✅ JSON Schema |
|
|
112
|
+
| 输出校验 | ❌ | ✅ JSON Schema |
|
|
113
|
+
| 置信度 | ❌ | ✅ 必须 0-1 |
|
|
114
|
+
| 推理过程 | ❌ | ✅ 必须 rationale |
|
|
115
|
+
| 参数传递 | ✅ $ARGUMENTS | ✅ $ARGUMENTS |
|
|
116
|
+
| 子代理 | ✅ context: fork | ✅ @call + context |
|
|
117
|
+
| 验证工具 | ❌ | ✅ cog validate |
|
|
118
|
+
| 注册表 | ❌ | ✅ cog install |
|
|
119
|
+
|
|
120
|
+
## CLI 命令
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# 模块管理
|
|
124
|
+
cog list # 列出已安装模块
|
|
125
|
+
cog info <module> # 查看模块详情
|
|
126
|
+
cog validate <module> # 验证模块结构
|
|
127
|
+
|
|
128
|
+
# 运行模块
|
|
129
|
+
cog run <module> input.json -o output.json --pretty
|
|
130
|
+
cog run <module> --args "需求描述" --pretty
|
|
131
|
+
cog run <module> --args "需求" --subagent # 启用子代理
|
|
132
|
+
|
|
133
|
+
# 创建模块
|
|
134
|
+
cog init <name> -d "描述"
|
|
135
|
+
|
|
136
|
+
# 安装/卸载
|
|
137
|
+
cog install github:user/repo/path
|
|
138
|
+
cog install registry:module-name
|
|
139
|
+
cog uninstall <module>
|
|
140
|
+
|
|
141
|
+
# 注册表
|
|
142
|
+
cog registry # 查看公共模块
|
|
143
|
+
cog search <query> # 搜索模块
|
|
144
|
+
|
|
145
|
+
# 环境检查
|
|
146
|
+
cog doctor
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 内置模块
|
|
150
|
+
|
|
151
|
+
| 模块 | 功能 | 示例 |
|
|
152
|
+
|------|------|------|
|
|
153
|
+
| `code-reviewer` | 代码审查 | `cog run code-reviewer --args "你的代码"` |
|
|
154
|
+
| `task-prioritizer` | 任务优先级排序 | `cog run task-prioritizer --args "任务1,任务2"` |
|
|
155
|
+
| `api-designer` | REST API 设计 | `cog run api-designer --args "订单系统"` |
|
|
156
|
+
| `ui-spec-generator` | UI 规范生成 | `cog run ui-spec-generator --args "电商首页"` |
|
|
157
|
+
| `product-analyzer` | 产品分析(子代理示例) | `cog run product-analyzer --args "健康产品" -s` |
|
|
158
|
+
|
|
159
|
+
## 模块格式
|
|
160
|
+
|
|
161
|
+
### 新格式(推荐)
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
my-module/
|
|
165
|
+
├── MODULE.md # 元数据 + 指令
|
|
166
|
+
├── schema.json # 输入输出 Schema
|
|
167
|
+
└── examples/
|
|
168
|
+
├── input.json
|
|
169
|
+
└── output.json
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### MODULE.md
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
---
|
|
176
|
+
name: my-module
|
|
177
|
+
version: 1.0.0
|
|
178
|
+
responsibility: 一句话描述
|
|
179
|
+
|
|
180
|
+
excludes:
|
|
181
|
+
- 不做的事情
|
|
182
|
+
|
|
183
|
+
constraints:
|
|
184
|
+
no_network: true
|
|
185
|
+
no_inventing_data: true
|
|
186
|
+
require_confidence: true
|
|
187
|
+
require_rationale: true
|
|
188
|
+
|
|
189
|
+
context: fork # 可选:隔离执行
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
# 指令
|
|
193
|
+
|
|
194
|
+
根据用户需求 $ARGUMENTS 执行任务。
|
|
195
|
+
|
|
196
|
+
可以调用其他模块:
|
|
197
|
+
@call:other-module($ARGUMENTS)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## 在 AI 工具中使用
|
|
201
|
+
|
|
202
|
+
### Cursor / Codex CLI
|
|
203
|
+
|
|
204
|
+
在项目根目录创建 `AGENTS.md`:
|
|
205
|
+
|
|
206
|
+
```markdown
|
|
207
|
+
## 代码审查
|
|
208
|
+
|
|
209
|
+
当需要审查代码时:
|
|
210
|
+
1. 读取 `~/.cognitive/modules/code-reviewer/MODULE.md`
|
|
211
|
+
2. 按 schema.json 格式输出
|
|
212
|
+
3. 包含 issues、summary、rationale、confidence
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 直接对话
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
读取 ~/.cognitive/modules/code-reviewer/MODULE.md,
|
|
219
|
+
审查这段代码:def login(u,p): ...
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 配置 LLM
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# OpenAI
|
|
226
|
+
export LLM_PROVIDER=openai
|
|
227
|
+
export OPENAI_API_KEY=sk-xxx
|
|
228
|
+
|
|
229
|
+
# Anthropic Claude
|
|
230
|
+
export LLM_PROVIDER=anthropic
|
|
231
|
+
export ANTHROPIC_API_KEY=sk-ant-xxx
|
|
232
|
+
|
|
233
|
+
# MiniMax
|
|
234
|
+
export LLM_PROVIDER=minimax
|
|
235
|
+
export MINIMAX_API_KEY=sk-xxx
|
|
236
|
+
|
|
237
|
+
# Ollama(本地)
|
|
238
|
+
export LLM_PROVIDER=ollama
|
|
239
|
+
|
|
240
|
+
# 检查配置
|
|
241
|
+
cog doctor
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## 开发
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# 克隆
|
|
248
|
+
git clone https://github.com/ziel-io/cognitive-modules.git
|
|
249
|
+
cd cognitive-modules
|
|
250
|
+
|
|
251
|
+
# 安装开发依赖
|
|
252
|
+
pip install -e ".[dev]"
|
|
253
|
+
|
|
254
|
+
# 运行测试
|
|
255
|
+
pytest tests/ -v
|
|
256
|
+
|
|
257
|
+
# 创建新模块
|
|
258
|
+
cog init my-module -d "模块描述"
|
|
259
|
+
cog validate my-module
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## 项目结构
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
cognitive-modules/
|
|
266
|
+
├── src/cognitive/ # CLI 源码
|
|
267
|
+
│ ├── cli.py # 命令入口
|
|
268
|
+
│ ├── loader.py # 模块加载
|
|
269
|
+
│ ├── runner.py # 模块执行
|
|
270
|
+
│ ├── subagent.py # 子代理编排
|
|
271
|
+
│ ├── validator.py # 模块验证
|
|
272
|
+
│ ├── registry.py # 模块安装
|
|
273
|
+
│ ├── templates.py # 模块模板
|
|
274
|
+
│ └── providers/ # LLM 后端
|
|
275
|
+
├── cognitive/modules/ # 内置模块
|
|
276
|
+
├── tests/ # 单元测试
|
|
277
|
+
├── SPEC.md # 规范文档
|
|
278
|
+
├── INTEGRATION.md # 集成指南
|
|
279
|
+
└── cognitive-registry.json # 公共注册表
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## 文档
|
|
283
|
+
|
|
284
|
+
- [SPEC.md](SPEC.md) - 完整规范(含上下文哲学)
|
|
285
|
+
- [INTEGRATION.md](INTEGRATION.md) - Agent 工具集成指南
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Cognitive Modules
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ziel-io/cognitive-modules/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/cognitive-modules/)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
> 可验证的结构化 AI 任务规范
|
|
9
|
+
|
|
10
|
+
Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、可验证、可审计**的生成任务设计。
|
|
11
|
+
|
|
12
|
+
## 特性
|
|
13
|
+
|
|
14
|
+
- **强类型契约** - JSON Schema 双向验证输入输出
|
|
15
|
+
- **可解释输出** - 强制输出 `confidence` + `rationale`
|
|
16
|
+
- **子代理编排** - `@call:module` 支持模块间调用
|
|
17
|
+
- **参数传递** - `$ARGUMENTS` 运行时替换
|
|
18
|
+
- **多 LLM 支持** - OpenAI / Anthropic / MiniMax / Ollama
|
|
19
|
+
- **公共注册表** - `cog install registry:module-name`
|
|
20
|
+
|
|
21
|
+
## 安装
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 基础安装
|
|
25
|
+
pip install cognitive-modules
|
|
26
|
+
|
|
27
|
+
# 带 LLM 支持
|
|
28
|
+
pip install cognitive-modules[openai] # OpenAI
|
|
29
|
+
pip install cognitive-modules[anthropic] # Claude
|
|
30
|
+
pip install cognitive-modules[all] # 全部
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 快速开始
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# 配置 LLM
|
|
37
|
+
export LLM_PROVIDER=openai
|
|
38
|
+
export OPENAI_API_KEY=sk-xxx
|
|
39
|
+
|
|
40
|
+
# 或使用 MiniMax
|
|
41
|
+
export LLM_PROVIDER=minimax
|
|
42
|
+
export MINIMAX_API_KEY=sk-xxx
|
|
43
|
+
|
|
44
|
+
# 运行代码审查
|
|
45
|
+
cog run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
|
|
46
|
+
|
|
47
|
+
# 运行任务排序
|
|
48
|
+
cog run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --pretty
|
|
49
|
+
|
|
50
|
+
# 运行 API 设计
|
|
51
|
+
cog run api-designer --args "用户系统 CRUD API" --pretty
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 与 Skills 对比
|
|
55
|
+
|
|
56
|
+
| | Skills | Cognitive Modules |
|
|
57
|
+
|---|--------|------------------|
|
|
58
|
+
| 定位 | 轻量指令扩展 | 可验证的结构化任务 |
|
|
59
|
+
| 输入校验 | ❌ | ✅ JSON Schema |
|
|
60
|
+
| 输出校验 | ❌ | ✅ JSON Schema |
|
|
61
|
+
| 置信度 | ❌ | ✅ 必须 0-1 |
|
|
62
|
+
| 推理过程 | ❌ | ✅ 必须 rationale |
|
|
63
|
+
| 参数传递 | ✅ $ARGUMENTS | ✅ $ARGUMENTS |
|
|
64
|
+
| 子代理 | ✅ context: fork | ✅ @call + context |
|
|
65
|
+
| 验证工具 | ❌ | ✅ cog validate |
|
|
66
|
+
| 注册表 | ❌ | ✅ cog install |
|
|
67
|
+
|
|
68
|
+
## CLI 命令
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# 模块管理
|
|
72
|
+
cog list # 列出已安装模块
|
|
73
|
+
cog info <module> # 查看模块详情
|
|
74
|
+
cog validate <module> # 验证模块结构
|
|
75
|
+
|
|
76
|
+
# 运行模块
|
|
77
|
+
cog run <module> input.json -o output.json --pretty
|
|
78
|
+
cog run <module> --args "需求描述" --pretty
|
|
79
|
+
cog run <module> --args "需求" --subagent # 启用子代理
|
|
80
|
+
|
|
81
|
+
# 创建模块
|
|
82
|
+
cog init <name> -d "描述"
|
|
83
|
+
|
|
84
|
+
# 安装/卸载
|
|
85
|
+
cog install github:user/repo/path
|
|
86
|
+
cog install registry:module-name
|
|
87
|
+
cog uninstall <module>
|
|
88
|
+
|
|
89
|
+
# 注册表
|
|
90
|
+
cog registry # 查看公共模块
|
|
91
|
+
cog search <query> # 搜索模块
|
|
92
|
+
|
|
93
|
+
# 环境检查
|
|
94
|
+
cog doctor
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 内置模块
|
|
98
|
+
|
|
99
|
+
| 模块 | 功能 | 示例 |
|
|
100
|
+
|------|------|------|
|
|
101
|
+
| `code-reviewer` | 代码审查 | `cog run code-reviewer --args "你的代码"` |
|
|
102
|
+
| `task-prioritizer` | 任务优先级排序 | `cog run task-prioritizer --args "任务1,任务2"` |
|
|
103
|
+
| `api-designer` | REST API 设计 | `cog run api-designer --args "订单系统"` |
|
|
104
|
+
| `ui-spec-generator` | UI 规范生成 | `cog run ui-spec-generator --args "电商首页"` |
|
|
105
|
+
| `product-analyzer` | 产品分析(子代理示例) | `cog run product-analyzer --args "健康产品" -s` |
|
|
106
|
+
|
|
107
|
+
## 模块格式
|
|
108
|
+
|
|
109
|
+
### 新格式(推荐)
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
my-module/
|
|
113
|
+
├── MODULE.md # 元数据 + 指令
|
|
114
|
+
├── schema.json # 输入输出 Schema
|
|
115
|
+
└── examples/
|
|
116
|
+
├── input.json
|
|
117
|
+
└── output.json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### MODULE.md
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
---
|
|
124
|
+
name: my-module
|
|
125
|
+
version: 1.0.0
|
|
126
|
+
responsibility: 一句话描述
|
|
127
|
+
|
|
128
|
+
excludes:
|
|
129
|
+
- 不做的事情
|
|
130
|
+
|
|
131
|
+
constraints:
|
|
132
|
+
no_network: true
|
|
133
|
+
no_inventing_data: true
|
|
134
|
+
require_confidence: true
|
|
135
|
+
require_rationale: true
|
|
136
|
+
|
|
137
|
+
context: fork # 可选:隔离执行
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
# 指令
|
|
141
|
+
|
|
142
|
+
根据用户需求 $ARGUMENTS 执行任务。
|
|
143
|
+
|
|
144
|
+
可以调用其他模块:
|
|
145
|
+
@call:other-module($ARGUMENTS)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## 在 AI 工具中使用
|
|
149
|
+
|
|
150
|
+
### Cursor / Codex CLI
|
|
151
|
+
|
|
152
|
+
在项目根目录创建 `AGENTS.md`:
|
|
153
|
+
|
|
154
|
+
```markdown
|
|
155
|
+
## 代码审查
|
|
156
|
+
|
|
157
|
+
当需要审查代码时:
|
|
158
|
+
1. 读取 `~/.cognitive/modules/code-reviewer/MODULE.md`
|
|
159
|
+
2. 按 schema.json 格式输出
|
|
160
|
+
3. 包含 issues、summary、rationale、confidence
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 直接对话
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
读取 ~/.cognitive/modules/code-reviewer/MODULE.md,
|
|
167
|
+
审查这段代码:def login(u,p): ...
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 配置 LLM
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# OpenAI
|
|
174
|
+
export LLM_PROVIDER=openai
|
|
175
|
+
export OPENAI_API_KEY=sk-xxx
|
|
176
|
+
|
|
177
|
+
# Anthropic Claude
|
|
178
|
+
export LLM_PROVIDER=anthropic
|
|
179
|
+
export ANTHROPIC_API_KEY=sk-ant-xxx
|
|
180
|
+
|
|
181
|
+
# MiniMax
|
|
182
|
+
export LLM_PROVIDER=minimax
|
|
183
|
+
export MINIMAX_API_KEY=sk-xxx
|
|
184
|
+
|
|
185
|
+
# Ollama(本地)
|
|
186
|
+
export LLM_PROVIDER=ollama
|
|
187
|
+
|
|
188
|
+
# 检查配置
|
|
189
|
+
cog doctor
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## 开发
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# 克隆
|
|
196
|
+
git clone https://github.com/ziel-io/cognitive-modules.git
|
|
197
|
+
cd cognitive-modules
|
|
198
|
+
|
|
199
|
+
# 安装开发依赖
|
|
200
|
+
pip install -e ".[dev]"
|
|
201
|
+
|
|
202
|
+
# 运行测试
|
|
203
|
+
pytest tests/ -v
|
|
204
|
+
|
|
205
|
+
# 创建新模块
|
|
206
|
+
cog init my-module -d "模块描述"
|
|
207
|
+
cog validate my-module
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 项目结构
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
cognitive-modules/
|
|
214
|
+
├── src/cognitive/ # CLI 源码
|
|
215
|
+
│ ├── cli.py # 命令入口
|
|
216
|
+
│ ├── loader.py # 模块加载
|
|
217
|
+
│ ├── runner.py # 模块执行
|
|
218
|
+
│ ├── subagent.py # 子代理编排
|
|
219
|
+
│ ├── validator.py # 模块验证
|
|
220
|
+
│ ├── registry.py # 模块安装
|
|
221
|
+
│ ├── templates.py # 模块模板
|
|
222
|
+
│ └── providers/ # LLM 后端
|
|
223
|
+
├── cognitive/modules/ # 内置模块
|
|
224
|
+
├── tests/ # 单元测试
|
|
225
|
+
├── SPEC.md # 规范文档
|
|
226
|
+
├── INTEGRATION.md # 集成指南
|
|
227
|
+
└── cognitive-registry.json # 公共注册表
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## 文档
|
|
231
|
+
|
|
232
|
+
- [SPEC.md](SPEC.md) - 完整规范(含上下文哲学)
|
|
233
|
+
- [INTEGRATION.md](INTEGRATION.md) - Agent 工具集成指南
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT
|
|
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cognitive-modules"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.1"
|
|
8
8
|
description = "Structured LLM task runner with schema validation, confidence scoring, and subagent orchestration"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
11
11
|
requires-python = ">=3.9"
|
|
12
12
|
authors = [
|
|
13
|
-
{name = "
|
|
13
|
+
{name = "ziel-io"}
|
|
14
14
|
]
|
|
15
15
|
keywords = [
|
|
16
16
|
"llm",
|
|
@@ -59,17 +59,22 @@ dev = [
|
|
|
59
59
|
"pytest>=7.0.0",
|
|
60
60
|
"pytest-cov>=4.0.0",
|
|
61
61
|
"build>=1.0.0",
|
|
62
|
-
"twine>=4.0.0"
|
|
62
|
+
"twine>=4.0.0",
|
|
63
|
+
"ruff>=0.1.0"
|
|
64
|
+
]
|
|
65
|
+
docs = [
|
|
66
|
+
"mkdocs-material>=9.0.0",
|
|
67
|
+
"pymdown-extensions>=10.0.0"
|
|
63
68
|
]
|
|
64
69
|
|
|
65
70
|
[project.scripts]
|
|
66
71
|
cog = "cognitive.cli:app"
|
|
67
72
|
|
|
68
73
|
[project.urls]
|
|
69
|
-
Homepage = "https://github.com/
|
|
70
|
-
Documentation = "https://github.com/
|
|
71
|
-
Repository = "https://github.com/
|
|
72
|
-
Issues = "https://github.com/
|
|
74
|
+
Homepage = "https://github.com/ziel-io/cognitive-modules"
|
|
75
|
+
Documentation = "https://github.com/ziel-io/cognitive-modules#readme"
|
|
76
|
+
Repository = "https://github.com/ziel-io/cognitive-modules"
|
|
77
|
+
Issues = "https://github.com/ziel-io/cognitive-modules/issues"
|
|
73
78
|
|
|
74
79
|
[tool.setuptools.packages.find]
|
|
75
80
|
where = ["src"]
|
|
@@ -31,7 +31,7 @@ SEARCH_PATHS = [
|
|
|
31
31
|
USER_MODULES_DIR = Path.home() / ".cognitive" / "modules"
|
|
32
32
|
|
|
33
33
|
# Default registry URL
|
|
34
|
-
DEFAULT_REGISTRY_URL = "https://raw.githubusercontent.com/
|
|
34
|
+
DEFAULT_REGISTRY_URL = "https://raw.githubusercontent.com/ziel-io/cognitive-modules/main/cognitive-registry.json"
|
|
35
35
|
|
|
36
36
|
# Local registry cache
|
|
37
37
|
REGISTRY_CACHE = Path.home() / ".cognitive" / "registry-cache.json"
|