cognitive-modules 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
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/__init__.py +1 -1
- cognitive/cli.py +173 -18
- cognitive/loader.py +180 -14
- cognitive/mcp_server.py +245 -0
- cognitive/migrate.py +624 -0
- cognitive/runner.py +409 -80
- cognitive/server.py +294 -0
- cognitive/validator.py +380 -122
- {cognitive_modules-0.4.0.dist-info → cognitive_modules-0.5.0.dist-info}/METADATA +179 -176
- cognitive_modules-0.5.0.dist-info/RECORD +18 -0
- cognitive_modules-0.4.0.dist-info/RECORD +0 -15
- {cognitive_modules-0.4.0.dist-info → cognitive_modules-0.5.0.dist-info}/WHEEL +0 -0
- {cognitive_modules-0.4.0.dist-info → cognitive_modules-0.5.0.dist-info}/entry_points.txt +0 -0
- {cognitive_modules-0.4.0.dist-info → cognitive_modules-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {cognitive_modules-0.4.0.dist-info → cognitive_modules-0.5.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognitive-modules
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Structured LLM task runner with schema validation, confidence scoring, and subagent orchestration
|
|
5
5
|
Author: ziel-io
|
|
6
6
|
License: MIT
|
|
@@ -39,6 +39,12 @@ Provides-Extra: all
|
|
|
39
39
|
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
40
40
|
Requires-Dist: anthropic>=0.18.0; extra == "all"
|
|
41
41
|
Requires-Dist: requests>=2.28.0; extra == "all"
|
|
42
|
+
Provides-Extra: server
|
|
43
|
+
Requires-Dist: fastapi>=0.109.0; extra == "server"
|
|
44
|
+
Requires-Dist: uvicorn[standard]>=0.27.0; extra == "server"
|
|
45
|
+
Requires-Dist: pydantic>=2.0.0; extra == "server"
|
|
46
|
+
Provides-Extra: mcp
|
|
47
|
+
Requires-Dist: mcp>=1.0.0; extra == "mcp"
|
|
42
48
|
Provides-Extra: dev
|
|
43
49
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
44
50
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -61,10 +67,22 @@ Dynamic: license-file
|
|
|
61
67
|
|
|
62
68
|
Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、可验证、可审计**的生成任务设计。
|
|
63
69
|
|
|
70
|
+
## v2.2 新特性
|
|
71
|
+
|
|
72
|
+
| 特性 | 说明 |
|
|
73
|
+
|------|------|
|
|
74
|
+
| **Control/Data 分离** | `meta` 控制面 + `data` 数据面,中间件无需解析业务 |
|
|
75
|
+
| **模块分级 (Tier)** | `exec` / `decision` / `exploration` 不同严格度 |
|
|
76
|
+
| **可回收溢出** | `extensions.insights` 保留 LLM 的额外洞察 |
|
|
77
|
+
| **可扩展 Enum** | 允许自定义类型,不牺牲类型安全 |
|
|
78
|
+
| **Repair Pass** | 自动修复格式问题,降低验证失败率 |
|
|
79
|
+
|
|
64
80
|
## 特性
|
|
65
81
|
|
|
66
82
|
- **强类型契约** - JSON Schema 双向验证输入输出
|
|
67
83
|
- **可解释输出** - 强制输出 `confidence` + `rationale`
|
|
84
|
+
- **Control/Data 分离** - `meta.explain` 快速路由 + `data.rationale` 详细审计
|
|
85
|
+
- **模块分级** - exec / decision / exploration 不同约束等级
|
|
68
86
|
- **子代理编排** - `@call:module` 支持模块间调用
|
|
69
87
|
- **参数传递** - `$ARGUMENTS` 运行时替换
|
|
70
88
|
- **多 LLM 支持** - OpenAI / Anthropic / MiniMax / Ollama
|
|
@@ -72,8 +90,9 @@ Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、
|
|
|
72
90
|
|
|
73
91
|
## 安装
|
|
74
92
|
|
|
93
|
+
### Python (pip)
|
|
94
|
+
|
|
75
95
|
```bash
|
|
76
|
-
# 基础安装
|
|
77
96
|
pip install cognitive-modules
|
|
78
97
|
|
|
79
98
|
# 带 LLM 支持
|
|
@@ -82,6 +101,21 @@ pip install cognitive-modules[anthropic] # Claude
|
|
|
82
101
|
pip install cognitive-modules[all] # 全部
|
|
83
102
|
```
|
|
84
103
|
|
|
104
|
+
### Node.js (npm)
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# 全局安装
|
|
108
|
+
npm install -g cognitive-modules-cli
|
|
109
|
+
|
|
110
|
+
# 或 npx 零安装使用
|
|
111
|
+
npx cognitive-modules-cli --help
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
| 平台 | 包名 | 命令 |
|
|
115
|
+
|------|------|------|
|
|
116
|
+
| pip | `cognitive-modules` | `cogn` |
|
|
117
|
+
| npm | `cognitive-modules-cli` | `cog` |
|
|
118
|
+
|
|
85
119
|
## 快速开始
|
|
86
120
|
|
|
87
121
|
```bash
|
|
@@ -89,10 +123,6 @@ pip install cognitive-modules[all] # 全部
|
|
|
89
123
|
export LLM_PROVIDER=openai
|
|
90
124
|
export OPENAI_API_KEY=sk-xxx
|
|
91
125
|
|
|
92
|
-
# 或使用 MiniMax
|
|
93
|
-
export LLM_PROVIDER=minimax
|
|
94
|
-
export MINIMAX_API_KEY=sk-xxx
|
|
95
|
-
|
|
96
126
|
# 运行代码审查
|
|
97
127
|
cogn run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
|
|
98
128
|
|
|
@@ -103,19 +133,63 @@ cogn run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --
|
|
|
103
133
|
cogn run api-designer --args "用户系统 CRUD API" --pretty
|
|
104
134
|
```
|
|
105
135
|
|
|
106
|
-
##
|
|
136
|
+
## v2.2 响应格式
|
|
137
|
+
|
|
138
|
+
所有模块现在返回统一的 v2.2 envelope 格式:
|
|
107
139
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"ok": true,
|
|
143
|
+
"meta": {
|
|
144
|
+
"confidence": 0.92,
|
|
145
|
+
"risk": "low",
|
|
146
|
+
"explain": "简短摘要,用于快速路由决策(≤280字符)"
|
|
147
|
+
},
|
|
148
|
+
"data": {
|
|
149
|
+
"...业务字段...",
|
|
150
|
+
"rationale": "详细推理过程,用于审计和人工审核",
|
|
151
|
+
"extensions": {
|
|
152
|
+
"insights": [
|
|
153
|
+
{
|
|
154
|
+
"text": "额外洞察",
|
|
155
|
+
"suggested_mapping": "建议添加到 schema 的字段"
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Control vs Data Plane
|
|
164
|
+
|
|
165
|
+
| 层 | 字段 | 用途 |
|
|
166
|
+
|---|------|------|
|
|
167
|
+
| **Control Plane** | `meta.confidence` | 路由/降级决策 |
|
|
168
|
+
| **Control Plane** | `meta.risk` | 人工审核触发 |
|
|
169
|
+
| **Control Plane** | `meta.explain` | 日志/卡片 UI |
|
|
170
|
+
| **Data Plane** | `data.rationale` | 详细审计 |
|
|
171
|
+
| **Data Plane** | `data.extensions` | 可回收洞察 |
|
|
172
|
+
|
|
173
|
+
## 核心特性
|
|
174
|
+
|
|
175
|
+
| 特性 | 说明 |
|
|
176
|
+
|------|------|
|
|
177
|
+
| **JSON Schema 验证** | 输入输出双向校验 |
|
|
178
|
+
| **置信度** | 每个输出必须包含 0-1 的 confidence |
|
|
179
|
+
| **推理过程** | `meta.explain` (简短) + `data.rationale` (详细) |
|
|
180
|
+
| **模块分级** | `tier: exec \| decision \| exploration` |
|
|
181
|
+
| **风险聚合** | `meta.risk = max(changes[*].risk)` |
|
|
182
|
+
| **参数传递** | `$ARGUMENTS` 运行时替换 |
|
|
183
|
+
| **子代理** | `@call:module` 支持模块间调用 |
|
|
184
|
+
| **验证工具** | `cogn validate` / `cogn validate --v22` |
|
|
185
|
+
|
|
186
|
+
## 集成方式
|
|
187
|
+
|
|
188
|
+
| 方式 | 命令 | 适用场景 |
|
|
189
|
+
|------|------|----------|
|
|
190
|
+
| CLI | `cogn run` | 命令行 |
|
|
191
|
+
| HTTP API | `cogn serve` | n8n、Coze、Dify |
|
|
192
|
+
| MCP Server | `cogn mcp` | Claude、Cursor |
|
|
119
193
|
|
|
120
194
|
## CLI 命令
|
|
121
195
|
|
|
@@ -124,6 +198,7 @@ cogn run api-designer --args "用户系统 CRUD API" --pretty
|
|
|
124
198
|
cogn list # 列出已安装模块
|
|
125
199
|
cogn info <module> # 查看模块详情
|
|
126
200
|
cogn validate <module> # 验证模块结构
|
|
201
|
+
cogn validate <module> --v22 # 验证 v2.2 格式
|
|
127
202
|
|
|
128
203
|
# 运行模块
|
|
129
204
|
cogn run <module> input.json -o output.json --pretty
|
|
@@ -132,6 +207,10 @@ cogn run <module> --args "需求" --subagent # 启用子代理
|
|
|
132
207
|
|
|
133
208
|
# 创建模块
|
|
134
209
|
cogn init <name> -d "描述"
|
|
210
|
+
cogn init <name> --format v22 # 创建 v2.2 格式模块
|
|
211
|
+
|
|
212
|
+
# 迁移模块
|
|
213
|
+
cogn migrate <module> # 将 v1/v2.1 模块迁移到 v2.2
|
|
135
214
|
|
|
136
215
|
# 从 GitHub 安装(推荐)
|
|
137
216
|
cogn add ziel-io/cognitive-modules -m code-simplifier
|
|
@@ -158,55 +237,83 @@ cogn doctor
|
|
|
158
237
|
|
|
159
238
|
## 内置模块
|
|
160
239
|
|
|
161
|
-
| 模块 | 功能 | 示例 |
|
|
162
|
-
|
|
163
|
-
| `code-reviewer` | 代码审查 | `cogn run code-reviewer --args "你的代码"` |
|
|
164
|
-
| `code-simplifier` | 代码简化 | `cogn run code-simplifier --args "复杂代码"` |
|
|
165
|
-
| `task-prioritizer` | 任务优先级排序 | `cogn run task-prioritizer --args "任务1,任务2"` |
|
|
166
|
-
| `api-designer` | REST API 设计 | `cogn run api-designer --args "订单系统"` |
|
|
167
|
-
| `ui-spec-generator` | UI 规范生成 | `cogn run ui-spec-generator --args "电商首页"` |
|
|
168
|
-
| `product-analyzer` |
|
|
240
|
+
| 模块 | Tier | 功能 | 示例 |
|
|
241
|
+
|------|------|------|------|
|
|
242
|
+
| `code-reviewer` | decision | 代码审查 | `cogn run code-reviewer --args "你的代码"` |
|
|
243
|
+
| `code-simplifier` | decision | 代码简化 | `cogn run code-simplifier --args "复杂代码"` |
|
|
244
|
+
| `task-prioritizer` | decision | 任务优先级排序 | `cogn run task-prioritizer --args "任务1,任务2"` |
|
|
245
|
+
| `api-designer` | decision | REST API 设计 | `cogn run api-designer --args "订单系统"` |
|
|
246
|
+
| `ui-spec-generator` | exploration | UI 规范生成 | `cogn run ui-spec-generator --args "电商首页"` |
|
|
247
|
+
| `product-analyzer` | exploration | 产品分析(子代理) | `cogn run product-analyzer --args "健康产品" -s` |
|
|
169
248
|
|
|
170
249
|
## 模块格式
|
|
171
250
|
|
|
172
|
-
###
|
|
251
|
+
### v2.2 格式(推荐)
|
|
173
252
|
|
|
174
253
|
```
|
|
175
254
|
my-module/
|
|
176
|
-
├──
|
|
177
|
-
├──
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
255
|
+
├── module.yaml # 机器可读 manifest(含 tier/overflow/enums)
|
|
256
|
+
├── prompt.md # 人类可读 prompt
|
|
257
|
+
├── schema.json # meta + input + data + error schemas
|
|
258
|
+
└── tests/ # 黄金测试用例
|
|
259
|
+
├── case1.input.json
|
|
260
|
+
└── case1.expected.json
|
|
181
261
|
```
|
|
182
262
|
|
|
183
|
-
###
|
|
263
|
+
### module.yaml (v2.2)
|
|
184
264
|
|
|
185
265
|
```yaml
|
|
186
|
-
---
|
|
187
266
|
name: my-module
|
|
188
|
-
version:
|
|
267
|
+
version: 2.2.0
|
|
189
268
|
responsibility: 一句话描述
|
|
190
269
|
|
|
270
|
+
tier: decision # exec | decision | exploration
|
|
271
|
+
schema_strictness: medium # high | medium | low
|
|
272
|
+
|
|
191
273
|
excludes:
|
|
192
274
|
- 不做的事情
|
|
193
275
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
276
|
+
policies:
|
|
277
|
+
network: deny
|
|
278
|
+
filesystem_write: deny
|
|
279
|
+
side_effects: deny
|
|
280
|
+
|
|
281
|
+
overflow:
|
|
282
|
+
enabled: true
|
|
283
|
+
recoverable: true
|
|
284
|
+
max_items: 5
|
|
285
|
+
require_suggested_mapping: true
|
|
199
286
|
|
|
200
|
-
|
|
201
|
-
|
|
287
|
+
enums:
|
|
288
|
+
strategy: extensible # strict | extensible
|
|
202
289
|
|
|
203
|
-
|
|
290
|
+
failure:
|
|
291
|
+
contract: error_union
|
|
292
|
+
partial_allowed: true
|
|
204
293
|
|
|
205
|
-
|
|
294
|
+
compat:
|
|
295
|
+
accepts_v21_payload: true
|
|
296
|
+
runtime_auto_wrap: true
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### v1 格式(仍支持)
|
|
206
300
|
|
|
207
|
-
可以调用其他模块:
|
|
208
|
-
@call:other-module($ARGUMENTS)
|
|
209
301
|
```
|
|
302
|
+
my-module/
|
|
303
|
+
├── MODULE.md # 元数据 + 指令
|
|
304
|
+
├── schema.json # 输入输出 Schema
|
|
305
|
+
└── examples/
|
|
306
|
+
├── input.json
|
|
307
|
+
└── output.json
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Tier 说明
|
|
311
|
+
|
|
312
|
+
| Tier | 用途 | Schema 严格度 | Overflow |
|
|
313
|
+
|------|------|---------------|----------|
|
|
314
|
+
| `exec` | 自动执行(patch、指令生成) | high | 关闭 |
|
|
315
|
+
| `decision` | 判断/评估/分类 | medium | 开启 |
|
|
316
|
+
| `exploration` | 探索/调研/灵感 | low | 开启 |
|
|
210
317
|
|
|
211
318
|
## 在 AI 工具中使用
|
|
212
319
|
|
|
@@ -220,7 +327,7 @@ context: fork # 可选:隔离执行
|
|
|
220
327
|
当需要审查代码时:
|
|
221
328
|
1. 读取 `~/.cognitive/modules/code-reviewer/MODULE.md`
|
|
222
329
|
2. 按 schema.json 格式输出
|
|
223
|
-
3. 包含
|
|
330
|
+
3. 包含 meta.explain + data.rationale
|
|
224
331
|
```
|
|
225
332
|
|
|
226
333
|
### 直接对话
|
|
@@ -252,133 +359,26 @@ export LLM_PROVIDER=ollama
|
|
|
252
359
|
cogn doctor
|
|
253
360
|
```
|
|
254
361
|
|
|
255
|
-
##
|
|
256
|
-
|
|
257
|
-
以 `code-simplifier` 为例:
|
|
258
|
-
|
|
259
|
-
### Step 1: 创建目录结构
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
mkdir -p cognitive/modules/code-simplifier
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### Step 2: 编写 MODULE.md
|
|
266
|
-
|
|
267
|
-
```bash
|
|
268
|
-
cat > cognitive/modules/code-simplifier/MODULE.md << 'EOF'
|
|
269
|
-
---
|
|
270
|
-
name: code-simplifier
|
|
271
|
-
version: 1.0.0
|
|
272
|
-
responsibility: Simplify complex code while preserving functionality
|
|
273
|
-
|
|
274
|
-
excludes:
|
|
275
|
-
- Changing the code's behavior
|
|
276
|
-
- Adding new features
|
|
277
|
-
- Removing functionality
|
|
278
|
-
|
|
279
|
-
constraints:
|
|
280
|
-
no_network: true
|
|
281
|
-
no_side_effects: true
|
|
282
|
-
require_confidence: true
|
|
283
|
-
require_rationale: true
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
# Code Simplifier Module
|
|
287
|
-
|
|
288
|
-
You are an expert at refactoring and simplifying code.
|
|
289
|
-
|
|
290
|
-
## Input
|
|
291
|
-
|
|
292
|
-
Code to simplify: $ARGUMENTS
|
|
293
|
-
|
|
294
|
-
## Simplification Strategies
|
|
295
|
-
|
|
296
|
-
1. **Remove redundancy** - Eliminate duplicate code
|
|
297
|
-
2. **Improve naming** - Use clear, descriptive names
|
|
298
|
-
3. **Reduce nesting** - Flatten deep conditionals
|
|
299
|
-
4. **Simplify logic** - Use built-in functions
|
|
300
|
-
|
|
301
|
-
## Output Requirements
|
|
302
|
-
|
|
303
|
-
Return JSON containing:
|
|
304
|
-
- `simplified_code`: The simplified version
|
|
305
|
-
- `changes`: List of changes made
|
|
306
|
-
- `summary`: Brief description
|
|
307
|
-
- `rationale`: Explanation of decisions
|
|
308
|
-
- `confidence`: Confidence score [0-1]
|
|
309
|
-
EOF
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
### Step 3: 编写 schema.json
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
cat > cognitive/modules/code-simplifier/schema.json << 'EOF'
|
|
316
|
-
{
|
|
317
|
-
"$schema": "https://ziel-io.github.io/cognitive-modules/schema/v1.json",
|
|
318
|
-
"input": {
|
|
319
|
-
"type": "object",
|
|
320
|
-
"properties": {
|
|
321
|
-
"code": { "type": "string" },
|
|
322
|
-
"language": { "type": "string" },
|
|
323
|
-
"$ARGUMENTS": { "type": "string" }
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
"output": {
|
|
327
|
-
"type": "object",
|
|
328
|
-
"required": ["simplified_code", "changes", "summary", "rationale", "confidence"],
|
|
329
|
-
"properties": {
|
|
330
|
-
"simplified_code": { "type": "string" },
|
|
331
|
-
"changes": {
|
|
332
|
-
"type": "array",
|
|
333
|
-
"items": {
|
|
334
|
-
"type": "object",
|
|
335
|
-
"properties": {
|
|
336
|
-
"type": { "type": "string" },
|
|
337
|
-
"description": { "type": "string" }
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
"summary": { "type": "string" },
|
|
342
|
-
"rationale": { "type": "string" },
|
|
343
|
-
"confidence": { "type": "number", "minimum": 0, "maximum": 1 }
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
EOF
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
### Step 4: 验证模块
|
|
351
|
-
|
|
352
|
-
```bash
|
|
353
|
-
cogn validate code-simplifier
|
|
354
|
-
cogn list # 确认模块出现在列表中
|
|
355
|
-
```
|
|
362
|
+
## 迁移到 v2.2
|
|
356
363
|
|
|
357
|
-
|
|
364
|
+
从 v1 或 v2.1 模块迁移到 v2.2:
|
|
358
365
|
|
|
359
366
|
```bash
|
|
360
|
-
|
|
361
|
-
|
|
367
|
+
# 自动迁移单个模块
|
|
368
|
+
cogn migrate code-reviewer
|
|
362
369
|
|
|
363
|
-
|
|
370
|
+
# 迁移所有模块
|
|
371
|
+
cogn migrate --all
|
|
364
372
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
# 添加 input.json 和 output.json 作为测试用例
|
|
373
|
+
# 验证迁移结果
|
|
374
|
+
cogn validate code-reviewer --v22
|
|
368
375
|
```
|
|
369
376
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
| `version` | ✅ | 语义化版本 |
|
|
376
|
-
| `responsibility` | ✅ | 一句话描述职责 |
|
|
377
|
-
| `excludes` | ✅ | 明确列出不做的事 |
|
|
378
|
-
| `$ARGUMENTS` | ✅ | 支持命令行参数 |
|
|
379
|
-
| `confidence` | ✅ | 输出必须包含 0-1 置信度 |
|
|
380
|
-
| `rationale` | ✅ | 输出必须包含推理过程 |
|
|
381
|
-
| `schema.json` | ✅ | 定义输入输出契约 |
|
|
377
|
+
手动迁移步骤:
|
|
378
|
+
1. 创建 `module.yaml`(添加 tier/overflow/enums)
|
|
379
|
+
2. 更新 `schema.json`(添加 meta schema)
|
|
380
|
+
3. 创建/更新 `prompt.md`(说明 v2.2 envelope 格式)
|
|
381
|
+
4. 保留 `MODULE.md`(向后兼容)
|
|
382
382
|
|
|
383
383
|
## 开发
|
|
384
384
|
|
|
@@ -393,9 +393,9 @@ pip install -e ".[dev]"
|
|
|
393
393
|
# 运行测试
|
|
394
394
|
pytest tests/ -v
|
|
395
395
|
|
|
396
|
-
#
|
|
397
|
-
cogn init my-module -d "模块描述"
|
|
398
|
-
cogn validate my-module
|
|
396
|
+
# 创建新模块(v2.2 格式)
|
|
397
|
+
cogn init my-module -d "模块描述" --format v22
|
|
398
|
+
cogn validate my-module --v22
|
|
399
399
|
```
|
|
400
400
|
|
|
401
401
|
## 项目结构
|
|
@@ -404,23 +404,26 @@ cogn validate my-module
|
|
|
404
404
|
cognitive-modules/
|
|
405
405
|
├── src/cognitive/ # CLI 源码
|
|
406
406
|
│ ├── cli.py # 命令入口
|
|
407
|
-
│ ├── loader.py #
|
|
408
|
-
│ ├── runner.py #
|
|
407
|
+
│ ├── loader.py # 模块加载(支持 v0/v1/v2.2)
|
|
408
|
+
│ ├── runner.py # 模块执行(v2.2 envelope)
|
|
409
|
+
│ ├── validator.py # 模块验证(含 v2.2 验证)
|
|
410
|
+
│ ├── migrate.py # v2.2 迁移工具
|
|
409
411
|
│ ├── subagent.py # 子代理编排
|
|
410
|
-
│ ├── validator.py # 模块验证
|
|
411
412
|
│ ├── registry.py # 模块安装
|
|
412
413
|
│ ├── templates.py # 模块模板
|
|
413
414
|
│ └── providers/ # LLM 后端
|
|
414
|
-
├── cognitive/modules/ #
|
|
415
|
+
├── cognitive/modules/ # 内置模块(全部 v2.2)
|
|
415
416
|
├── tests/ # 单元测试
|
|
416
|
-
├── SPEC.md #
|
|
417
|
+
├── SPEC.md # v0.1 规范(历史)
|
|
418
|
+
├── SPEC-v2.2.md # v2.2 规范(最新)
|
|
417
419
|
├── INTEGRATION.md # 集成指南
|
|
418
420
|
└── cognitive-registry.json # 公共注册表
|
|
419
421
|
```
|
|
420
422
|
|
|
421
423
|
## 文档
|
|
422
424
|
|
|
423
|
-
- [SPEC.md](SPEC.md) -
|
|
425
|
+
- [SPEC-v2.2.md](SPEC-v2.2.md) - v2.2 完整规范(Control/Data 分离、Tier、Overflow)
|
|
426
|
+
- [SPEC.md](SPEC.md) - v0.1 规范(含上下文哲学)
|
|
424
427
|
- [INTEGRATION.md](INTEGRATION.md) - Agent 工具集成指南
|
|
425
428
|
|
|
426
429
|
## License
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
cognitive/__init__.py,sha256=pFMrHFn6hsXl4Jd5bosCmWcUnJcwYwPrS7qg1Ogxxhk,401
|
|
2
|
+
cognitive/cli.py,sha256=tYYWkFJt-eBtWF3GwokuqIZz6vFIP3ZJj7yls1cru6E,26778
|
|
3
|
+
cognitive/loader.py,sha256=p3uS5LbAhRxWnRhMsSGzlGqohAxHzVZjPm1WKtoeYes,14537
|
|
4
|
+
cognitive/mcp_server.py,sha256=NUQT7IqdYB9tQ-1YYfG5MPJuq6A70FXlcV2x3lBnuvM,6852
|
|
5
|
+
cognitive/migrate.py,sha256=15CXw0qWVFbC-kPau1bzPBirs8kg_b_E_1YANlJ34uI,19679
|
|
6
|
+
cognitive/registry.py,sha256=qLGyvUxSDP4frs46UlPa5jCcKubqiikWT3Y9JrBqfFc,18549
|
|
7
|
+
cognitive/runner.py,sha256=36b9pHa4Jiw01aslK_eFFamqHreLJ-t--nYcukmzuW4,19771
|
|
8
|
+
cognitive/server.py,sha256=cz8zGqhGrZgFY-HM0RSCjPCpB_Mfg1jsybeoo2ALvAc,9041
|
|
9
|
+
cognitive/subagent.py,sha256=fb7LWwNF6YcJtC_T1dK0EvzqWMBnav-kiCIpvVohEBw,8142
|
|
10
|
+
cognitive/templates.py,sha256=lKC197X9aQIA-npUvVCaplSwvhxjsH_KYVCQtrTZrL4,4712
|
|
11
|
+
cognitive/validator.py,sha256=8B02JQQdNcwvH-mtbyP8bVTRQxUrO9Prt4gU0N53fdg,21843
|
|
12
|
+
cognitive/providers/__init__.py,sha256=hqhVA1IEXpVtyCAteXhO5yD8a8ikQpVIPEKJVHLtRFY,7492
|
|
13
|
+
cognitive_modules-0.5.0.dist-info/licenses/LICENSE,sha256=NXFYUy2hPJdh3NHRxMChTnMiQD9k8zFxkmR7gWefexc,1064
|
|
14
|
+
cognitive_modules-0.5.0.dist-info/METADATA,sha256=nHK8DmSqc1tHhwxpzTKg5AUTl2walIHNBv_LP-ErF3s,12842
|
|
15
|
+
cognitive_modules-0.5.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
16
|
+
cognitive_modules-0.5.0.dist-info/entry_points.txt,sha256=1yqKB-MjHrRoe8FcYm-TgZDqGEZxzBPsd0xC4pcfBNU,43
|
|
17
|
+
cognitive_modules-0.5.0.dist-info/top_level.txt,sha256=kGIfDucCKylo8cRBtxER_v3DHIea-Sol9x9YSJo1u3Y,10
|
|
18
|
+
cognitive_modules-0.5.0.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
cognitive/__init__.py,sha256=uSX5NuOWyW0qtq1bnxbzabZ0OQakAtsjF0MWbjQBvwE,401
|
|
2
|
-
cognitive/cli.py,sha256=A8NUW5nvJpk6H3sJIZWC6HHvuSibR7QKDm0PlVGpwcs,21495
|
|
3
|
-
cognitive/loader.py,sha256=3_ShEfefOMP2EJjpQ1VGTGio4K_GUWLZMQHa0RgvBwg,8715
|
|
4
|
-
cognitive/registry.py,sha256=qLGyvUxSDP4frs46UlPa5jCcKubqiikWT3Y9JrBqfFc,18549
|
|
5
|
-
cognitive/runner.py,sha256=KFO_pV7YTluYaL98_5bPp_HTNgwsTvlUjgNYlI8mo-w,8467
|
|
6
|
-
cognitive/subagent.py,sha256=fb7LWwNF6YcJtC_T1dK0EvzqWMBnav-kiCIpvVohEBw,8142
|
|
7
|
-
cognitive/templates.py,sha256=lKC197X9aQIA-npUvVCaplSwvhxjsH_KYVCQtrTZrL4,4712
|
|
8
|
-
cognitive/validator.py,sha256=1v1HUHYOlAc2sYCkIq_gnUMMnca0fdtQwr7UMBFpp04,12200
|
|
9
|
-
cognitive/providers/__init__.py,sha256=hqhVA1IEXpVtyCAteXhO5yD8a8ikQpVIPEKJVHLtRFY,7492
|
|
10
|
-
cognitive_modules-0.4.0.dist-info/licenses/LICENSE,sha256=NXFYUy2hPJdh3NHRxMChTnMiQD9k8zFxkmR7gWefexc,1064
|
|
11
|
-
cognitive_modules-0.4.0.dist-info/METADATA,sha256=iF4YKfLj1CzOZuoYDH0JjuH_S2eh7MbV91KQfm-pdoI,11833
|
|
12
|
-
cognitive_modules-0.4.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
13
|
-
cognitive_modules-0.4.0.dist-info/entry_points.txt,sha256=1yqKB-MjHrRoe8FcYm-TgZDqGEZxzBPsd0xC4pcfBNU,43
|
|
14
|
-
cognitive_modules-0.4.0.dist-info/top_level.txt,sha256=kGIfDucCKylo8cRBtxER_v3DHIea-Sol9x9YSJo1u3Y,10
|
|
15
|
-
cognitive_modules-0.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|