cognitive-modules 0.6.1__tar.gz → 2.2.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.6.1 → cognitive_modules-2.2.1}/PKG-INFO +68 -159
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/README.md +67 -158
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/pyproject.toml +2 -2
- cognitive_modules-2.2.1/src/cognitive/runner.py +654 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive_modules.egg-info/PKG-INFO +68 -159
- cognitive_modules-2.2.1/src/cognitive_modules.egg-info/entry_points.txt +2 -0
- cognitive_modules-0.6.1/src/cognitive/runner.py +0 -1348
- cognitive_modules-0.6.1/src/cognitive_modules.egg-info/entry_points.txt +0 -2
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/LICENSE +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/setup.cfg +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/__init__.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/cli.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/loader.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/mcp_server.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/migrate.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/providers/__init__.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/registry.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/server.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/subagent.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/templates.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive/validator.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive_modules.egg-info/SOURCES.txt +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive_modules.egg-info/dependency_links.txt +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive_modules.egg-info/requires.txt +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/src/cognitive_modules.egg-info/top_level.txt +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/tests/test_cli.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/tests/test_loader.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/tests/test_migrate.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/tests/test_registry.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/tests/test_runner.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/tests/test_subagent.py +0 -0
- {cognitive_modules-0.6.1 → cognitive_modules-2.2.1}/tests/test_validator.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognitive-modules
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Structured LLM task runner with schema validation, confidence scoring, and subagent orchestration
|
|
5
5
|
Author: ziel-io
|
|
6
6
|
License: MIT
|
|
@@ -69,32 +69,6 @@ English | [中文](README_zh.md)
|
|
|
69
69
|
|
|
70
70
|
Cognitive Modules is an AI task definition specification designed for generation tasks that require **strong constraints, verifiability, and auditability**.
|
|
71
71
|
|
|
72
|
-
## What's New in v2.5
|
|
73
|
-
|
|
74
|
-
| Feature | Description |
|
|
75
|
-
|---------|-------------|
|
|
76
|
-
| **Streaming Response** | Real-time chunk-based output for better UX |
|
|
77
|
-
| **Multimodal Support** | Native image, audio, and video input/output |
|
|
78
|
-
| **Backward Compatible** | v2.2 modules run without modification |
|
|
79
|
-
| **Level 4 Conformance** | Extended conformance level for v2.5 features |
|
|
80
|
-
|
|
81
|
-
```yaml
|
|
82
|
-
# module.yaml - v2.5 example
|
|
83
|
-
name: image-analyzer
|
|
84
|
-
version: 2.5.0
|
|
85
|
-
tier: decision
|
|
86
|
-
|
|
87
|
-
# v2.5: Enable streaming
|
|
88
|
-
response:
|
|
89
|
-
mode: streaming
|
|
90
|
-
chunk_type: delta
|
|
91
|
-
|
|
92
|
-
# v2.5: Enable multimodal
|
|
93
|
-
modalities:
|
|
94
|
-
input: [text, image]
|
|
95
|
-
output: [text]
|
|
96
|
-
```
|
|
97
|
-
|
|
98
72
|
## What's New in v2.2
|
|
99
73
|
|
|
100
74
|
| Feature | Description |
|
|
@@ -114,7 +88,24 @@ modalities:
|
|
|
114
88
|
- **Subagent Orchestration** - `@call:module` supports inter-module calls
|
|
115
89
|
- **Parameter Passing** - `$ARGUMENTS` runtime substitution
|
|
116
90
|
- **Multi-LLM Support** - OpenAI / Anthropic / MiniMax / Ollama
|
|
117
|
-
- **Public Registry** - `
|
|
91
|
+
- **Public Registry** - `cog install registry:module-name`
|
|
92
|
+
|
|
93
|
+
## Version Selection
|
|
94
|
+
|
|
95
|
+
| Version | Spec | npm | PyPI | Status |
|
|
96
|
+
|---------|------|-----|------|--------|
|
|
97
|
+
| **v2.2** | v2.2 | `2.2.0` | `2.2.0` | ✅ Stable (recommended) |
|
|
98
|
+
| **v2.5** | v2.5 | `2.5.0-beta.x` | `2.5.0bx` | 🧪 Beta (streaming + multimodal) |
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Install stable v2.2
|
|
102
|
+
npm install cognitive-modules-cli@2.2.0
|
|
103
|
+
pip install cognitive-modules==2.2.0
|
|
104
|
+
|
|
105
|
+
# Install beta v2.5 (streaming + multimodal)
|
|
106
|
+
npm install cognitive-modules-cli@beta
|
|
107
|
+
pip install cognitive-modules==2.5.0b1
|
|
108
|
+
```
|
|
118
109
|
|
|
119
110
|
## Installation
|
|
120
111
|
|
|
@@ -122,30 +113,27 @@ modalities:
|
|
|
122
113
|
|
|
123
114
|
```bash
|
|
124
115
|
# Zero-install quick start (recommended)
|
|
125
|
-
npx
|
|
116
|
+
npx cognitive-modules-cli@2.2.0 run code-reviewer --args "your code"
|
|
126
117
|
|
|
127
118
|
# Global installation
|
|
128
|
-
npm install -g
|
|
129
|
-
|
|
130
|
-
# Or install with full package name
|
|
131
|
-
npm install -g cognitive-modules-cli
|
|
119
|
+
npm install -g cognitive-modules-cli@2.2.0
|
|
132
120
|
```
|
|
133
121
|
|
|
134
122
|
### Python (pip)
|
|
135
123
|
|
|
136
124
|
```bash
|
|
137
|
-
pip install cognitive-modules
|
|
125
|
+
pip install cognitive-modules==2.2.0
|
|
138
126
|
|
|
139
127
|
# With LLM support
|
|
140
|
-
pip install cognitive-modules[openai] # OpenAI
|
|
141
|
-
pip install cognitive-modules[anthropic] # Claude
|
|
142
|
-
pip install cognitive-modules[all] # All providers
|
|
128
|
+
pip install "cognitive-modules[openai]==2.2.0" # OpenAI
|
|
129
|
+
pip install "cognitive-modules[anthropic]==2.2.0" # Claude
|
|
130
|
+
pip install "cognitive-modules[all]==2.2.0" # All providers
|
|
143
131
|
```
|
|
144
132
|
|
|
145
133
|
| Platform | Package | Command | Features |
|
|
146
134
|
|----------|---------|---------|----------|
|
|
147
|
-
| **npm** | `
|
|
148
|
-
| pip | `cognitive-modules` | `
|
|
135
|
+
| **npm** | `cognitive-modules-cli` | `cog` | ✅ Recommended, zero-install, full features |
|
|
136
|
+
| pip | `cognitive-modules` | `cog` | ✅ Full features |
|
|
149
137
|
|
|
150
138
|
## Quick Start
|
|
151
139
|
|
|
@@ -155,7 +143,7 @@ export LLM_PROVIDER=openai
|
|
|
155
143
|
export OPENAI_API_KEY=sk-xxx
|
|
156
144
|
|
|
157
145
|
# Run code review (npm)
|
|
158
|
-
npx
|
|
146
|
+
npx cognitive-modules-cli run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
|
|
159
147
|
|
|
160
148
|
# Or use globally installed cog command
|
|
161
149
|
cog run code-reviewer --args "..." --pretty
|
|
@@ -221,70 +209,70 @@ All modules now return the unified v2.2 envelope format:
|
|
|
221
209
|
| **Risk Aggregation** | `meta.risk = max(changes[*].risk)` |
|
|
222
210
|
| **Parameter Passing** | `$ARGUMENTS` runtime substitution |
|
|
223
211
|
| **Subagents** | `@call:module` for inter-module calls |
|
|
224
|
-
| **Validation Tools** | `
|
|
212
|
+
| **Validation Tools** | `cog validate` / `cog validate --v22` |
|
|
225
213
|
|
|
226
214
|
## Integration Methods
|
|
227
215
|
|
|
228
216
|
| Method | Command | Use Case |
|
|
229
217
|
|--------|---------|----------|
|
|
230
|
-
| CLI | `
|
|
231
|
-
| HTTP API | `
|
|
232
|
-
| MCP Server | `
|
|
218
|
+
| CLI | `cog run` | Command line |
|
|
219
|
+
| HTTP API | `cog serve` | n8n, Coze, Dify |
|
|
220
|
+
| MCP Server | `cog mcp` | Claude, Cursor |
|
|
233
221
|
|
|
234
222
|
## CLI Commands
|
|
235
223
|
|
|
236
224
|
```bash
|
|
237
225
|
# Module management
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
226
|
+
cog list # List installed modules
|
|
227
|
+
cog info <module> # View module details
|
|
228
|
+
cog validate <module> # Validate module structure
|
|
229
|
+
cog validate <module> --v22 # Validate v2.2 format
|
|
242
230
|
|
|
243
231
|
# Run modules
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
232
|
+
cog run <module> input.json -o output.json --pretty
|
|
233
|
+
cog run <module> --args "requirements" --pretty
|
|
234
|
+
cog run <module> --args "requirements" --subagent # Enable subagent
|
|
247
235
|
|
|
248
236
|
# Create modules
|
|
249
|
-
|
|
250
|
-
|
|
237
|
+
cog init <name> -d "description"
|
|
238
|
+
cog init <name> --format v22 # Create v2.2 format module
|
|
251
239
|
|
|
252
240
|
# Migrate modules
|
|
253
|
-
|
|
241
|
+
cog migrate <module> # Migrate v1/v2.1 module to v2.2
|
|
254
242
|
|
|
255
243
|
# Install from GitHub (recommended)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
244
|
+
cog add ziel-io/cognitive-modules -m code-simplifier
|
|
245
|
+
cog add org/repo -m module-name --tag v1.0.0 # Install specific version
|
|
246
|
+
cog remove <module> # Remove module
|
|
259
247
|
|
|
260
248
|
# Version management
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
249
|
+
cog update <module> # Update to latest version
|
|
250
|
+
cog update <module> --tag v2.0.0 # Update to specific version
|
|
251
|
+
cog versions <url> # View available versions
|
|
264
252
|
|
|
265
253
|
# Other installation methods
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
254
|
+
cog install github:user/repo/path
|
|
255
|
+
cog install registry:module-name
|
|
256
|
+
cog uninstall <module>
|
|
269
257
|
|
|
270
258
|
# Registry
|
|
271
|
-
|
|
272
|
-
|
|
259
|
+
cog registry # View public modules
|
|
260
|
+
cog search <query> # Search modules
|
|
273
261
|
|
|
274
262
|
# Environment check
|
|
275
|
-
|
|
263
|
+
cog doctor
|
|
276
264
|
```
|
|
277
265
|
|
|
278
266
|
## Built-in Modules
|
|
279
267
|
|
|
280
268
|
| Module | Tier | Function | Example |
|
|
281
269
|
|--------|------|----------|---------|
|
|
282
|
-
| `code-reviewer` | decision | Code review | `
|
|
283
|
-
| `code-simplifier` | decision | Code simplification | `
|
|
284
|
-
| `task-prioritizer` | decision | Task priority sorting | `
|
|
285
|
-
| `api-designer` | decision | REST API design | `
|
|
286
|
-
| `ui-spec-generator` | exploration | UI spec generation | `
|
|
287
|
-
| `product-analyzer` | exploration | Product analysis (subagent) | `
|
|
270
|
+
| `code-reviewer` | decision | Code review | `cog run code-reviewer --args "your code"` |
|
|
271
|
+
| `code-simplifier` | decision | Code simplification | `cog run code-simplifier --args "complex code"` |
|
|
272
|
+
| `task-prioritizer` | decision | Task priority sorting | `cog run task-prioritizer --args "task1,task2"` |
|
|
273
|
+
| `api-designer` | decision | REST API design | `cog run api-designer --args "order system"` |
|
|
274
|
+
| `ui-spec-generator` | exploration | UI spec generation | `cog run ui-spec-generator --args "e-commerce homepage"` |
|
|
275
|
+
| `product-analyzer` | exploration | Product analysis (subagent) | `cog run product-analyzer --args "health product" -s` |
|
|
288
276
|
|
|
289
277
|
## Module Format
|
|
290
278
|
|
|
@@ -355,83 +343,6 @@ my-module/
|
|
|
355
343
|
| `decision` | Judgment/evaluation/classification | medium | Enabled |
|
|
356
344
|
| `exploration` | Exploration/research/inspiration | low | Enabled |
|
|
357
345
|
|
|
358
|
-
## v2.5 Streaming & Multimodal
|
|
359
|
-
|
|
360
|
-
### Streaming Response
|
|
361
|
-
|
|
362
|
-
Enable real-time streaming for better UX:
|
|
363
|
-
|
|
364
|
-
```yaml
|
|
365
|
-
# module.yaml
|
|
366
|
-
response:
|
|
367
|
-
mode: streaming # sync | streaming | both
|
|
368
|
-
chunk_type: delta # delta | snapshot
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
**JavaScript/TypeScript Usage:**
|
|
372
|
-
|
|
373
|
-
```typescript
|
|
374
|
-
import { runModuleStream } from 'cognitive-modules-cli';
|
|
375
|
-
|
|
376
|
-
// Stream execution
|
|
377
|
-
for await (const chunk of runModuleStream(module, provider, { input })) {
|
|
378
|
-
if ('delta' in chunk.chunk) {
|
|
379
|
-
process.stdout.write(chunk.chunk.delta);
|
|
380
|
-
} else if ('final' in chunk) {
|
|
381
|
-
console.log('\nComplete:', chunk.data);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
**Python Usage:**
|
|
387
|
-
|
|
388
|
-
```python
|
|
389
|
-
from cognitive import StreamingRunner
|
|
390
|
-
|
|
391
|
-
runner = StreamingRunner()
|
|
392
|
-
async for chunk in runner.execute_stream("image-analyzer", input_data):
|
|
393
|
-
if chunk.get("chunk"):
|
|
394
|
-
print(chunk["chunk"]["delta"], end="")
|
|
395
|
-
elif chunk.get("final"):
|
|
396
|
-
print("\nComplete:", chunk["data"])
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
### Multimodal Input
|
|
400
|
-
|
|
401
|
-
Enable image/audio/video processing:
|
|
402
|
-
|
|
403
|
-
```yaml
|
|
404
|
-
# module.yaml
|
|
405
|
-
modalities:
|
|
406
|
-
input: [text, image, audio]
|
|
407
|
-
output: [text, image]
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
**JavaScript/TypeScript Usage:**
|
|
411
|
-
|
|
412
|
-
```typescript
|
|
413
|
-
const result = await runModule(module, provider, {
|
|
414
|
-
input: {
|
|
415
|
-
prompt: "Describe this image",
|
|
416
|
-
images: [
|
|
417
|
-
{ type: "url", url: "https://example.com/image.jpg" },
|
|
418
|
-
{ type: "base64", media_type: "image/png", data: "iVBORw0K..." }
|
|
419
|
-
]
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
**Python Usage:**
|
|
425
|
-
|
|
426
|
-
```python
|
|
427
|
-
result = await runner.execute("image-analyzer", {
|
|
428
|
-
"prompt": "Describe this image",
|
|
429
|
-
"images": [
|
|
430
|
-
{"type": "url", "url": "https://example.com/image.jpg"},
|
|
431
|
-
{"type": "file", "path": "./local-image.png"}
|
|
432
|
-
]
|
|
433
|
-
})
|
|
434
|
-
|
|
435
346
|
## Using with AI Tools
|
|
436
347
|
|
|
437
348
|
### Cursor / Codex CLI
|
|
@@ -473,7 +384,7 @@ export MINIMAX_API_KEY=sk-xxx
|
|
|
473
384
|
export LLM_PROVIDER=ollama
|
|
474
385
|
|
|
475
386
|
# Check configuration
|
|
476
|
-
|
|
387
|
+
cog doctor
|
|
477
388
|
```
|
|
478
389
|
|
|
479
390
|
## Migrating to v2.2
|
|
@@ -482,13 +393,13 @@ Migrate from v1 or v2.1 modules to v2.2:
|
|
|
482
393
|
|
|
483
394
|
```bash
|
|
484
395
|
# Auto-migrate single module
|
|
485
|
-
|
|
396
|
+
cog migrate code-reviewer
|
|
486
397
|
|
|
487
398
|
# Migrate all modules
|
|
488
|
-
|
|
399
|
+
cog migrate --all
|
|
489
400
|
|
|
490
401
|
# Verify migration result
|
|
491
|
-
|
|
402
|
+
cog validate code-reviewer --v22
|
|
492
403
|
```
|
|
493
404
|
|
|
494
405
|
Manual migration steps:
|
|
@@ -511,8 +422,8 @@ pip install -e ".[dev]"
|
|
|
511
422
|
pytest tests/ -v
|
|
512
423
|
|
|
513
424
|
# Create new module (v2.2 format)
|
|
514
|
-
|
|
515
|
-
|
|
425
|
+
cog init my-module -d "module description" --format v22
|
|
426
|
+
cog validate my-module --v22
|
|
516
427
|
```
|
|
517
428
|
|
|
518
429
|
## Project Structure
|
|
@@ -546,8 +457,8 @@ cognitive-modules/
|
|
|
546
457
|
|
|
547
458
|
| Platform | Package | Command | Installation |
|
|
548
459
|
|----------|---------|---------|--------------|
|
|
549
|
-
| Python | `cognitive-modules` | `
|
|
550
|
-
| Node.js | `
|
|
460
|
+
| Python | `cognitive-modules` | `cog` | `pip install cognitive-modules` |
|
|
461
|
+
| Node.js | `cognitive-modules-cli` | `cog` | `npm install -g cognitive-modules-cli` |
|
|
551
462
|
|
|
552
463
|
Both versions share the same module format and v2.2 specification.
|
|
553
464
|
|
|
@@ -557,8 +468,6 @@ Both versions share the same module format and v2.2 specification.
|
|
|
557
468
|
|
|
558
469
|
| Document | Description |
|
|
559
470
|
|----------|-------------|
|
|
560
|
-
| [SPEC-v2.5.md](SPEC-v2.5.md) | v2.5 full specification (Streaming, Multimodal) |
|
|
561
|
-
| [SPEC-v2.5_zh.md](SPEC-v2.5_zh.md) | v2.5 规范中文版 |
|
|
562
471
|
| [SPEC-v2.2.md](SPEC-v2.2.md) | v2.2 full specification (Control/Data separation, Tier, Overflow) |
|
|
563
472
|
| [SPEC-v2.2_zh.md](SPEC-v2.2_zh.md) | v2.2 规范中文版 |
|
|
564
473
|
| [SPEC.md](SPEC.md) | v0.1 specification (context philosophy) |
|