cognitive-modules 0.2.0__tar.gz → 0.4.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.
Files changed (29) hide show
  1. {cognitive_modules-0.2.0/src/cognitive_modules.egg-info → cognitive_modules-0.4.0}/PKG-INFO +43 -33
  2. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/README.md +42 -32
  3. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/pyproject.toml +2 -2
  4. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive/cli.py +203 -1
  5. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive/loader.py +16 -5
  6. cognitive_modules-0.4.0/src/cognitive/registry.py +590 -0
  7. cognitive_modules-0.4.0/src/cognitive/runner.py +276 -0
  8. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0/src/cognitive_modules.egg-info}/PKG-INFO +43 -33
  9. cognitive_modules-0.4.0/src/cognitive_modules.egg-info/entry_points.txt +2 -0
  10. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/tests/test_loader.py +16 -12
  11. cognitive_modules-0.2.0/src/cognitive/registry.py +0 -276
  12. cognitive_modules-0.2.0/src/cognitive/runner.py +0 -140
  13. cognitive_modules-0.2.0/src/cognitive_modules.egg-info/entry_points.txt +0 -2
  14. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/LICENSE +0 -0
  15. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/setup.cfg +0 -0
  16. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive/__init__.py +0 -0
  17. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive/providers/__init__.py +0 -0
  18. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive/subagent.py +0 -0
  19. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive/templates.py +0 -0
  20. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive/validator.py +0 -0
  21. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive_modules.egg-info/SOURCES.txt +0 -0
  22. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive_modules.egg-info/dependency_links.txt +0 -0
  23. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive_modules.egg-info/requires.txt +0 -0
  24. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/src/cognitive_modules.egg-info/top_level.txt +0 -0
  25. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/tests/test_cli.py +0 -0
  26. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/tests/test_registry.py +0 -0
  27. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/tests/test_runner.py +0 -0
  28. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/tests/test_subagent.py +0 -0
  29. {cognitive_modules-0.2.0 → cognitive_modules-0.4.0}/tests/test_validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognitive-modules
3
- Version: 0.2.0
3
+ Version: 0.4.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
@@ -68,7 +68,7 @@ Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、
68
68
  - **子代理编排** - `@call:module` 支持模块间调用
69
69
  - **参数传递** - `$ARGUMENTS` 运行时替换
70
70
  - **多 LLM 支持** - OpenAI / Anthropic / MiniMax / Ollama
71
- - **公共注册表** - `cog install registry:module-name`
71
+ - **公共注册表** - `cogn install registry:module-name`
72
72
 
73
73
  ## 安装
74
74
 
@@ -94,13 +94,13 @@ export LLM_PROVIDER=minimax
94
94
  export MINIMAX_API_KEY=sk-xxx
95
95
 
96
96
  # 运行代码审查
97
- cog run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
97
+ cogn run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
98
98
 
99
99
  # 运行任务排序
100
- cog run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --pretty
100
+ cogn run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --pretty
101
101
 
102
102
  # 运行 API 设计
103
- cog run api-designer --args "用户系统 CRUD API" --pretty
103
+ cogn run api-designer --args "用户系统 CRUD API" --pretty
104
104
  ```
105
105
 
106
106
  ## 与 Skills 对比
@@ -114,48 +114,58 @@ cog run api-designer --args "用户系统 CRUD API" --pretty
114
114
  | 推理过程 | ❌ | ✅ 必须 rationale |
115
115
  | 参数传递 | ✅ $ARGUMENTS | ✅ $ARGUMENTS |
116
116
  | 子代理 | ✅ context: fork | ✅ @call + context |
117
- | 验证工具 | ❌ | ✅ cog validate |
118
- | 注册表 | ❌ | ✅ cog install |
117
+ | 验证工具 | ❌ | ✅ cogn validate |
118
+ | 注册表 | ❌ | ✅ cogn install |
119
119
 
120
120
  ## CLI 命令
121
121
 
122
122
  ```bash
123
123
  # 模块管理
124
- cog list # 列出已安装模块
125
- cog info <module> # 查看模块详情
126
- cog validate <module> # 验证模块结构
124
+ cogn list # 列出已安装模块
125
+ cogn info <module> # 查看模块详情
126
+ cogn validate <module> # 验证模块结构
127
127
 
128
128
  # 运行模块
129
- cog run <module> input.json -o output.json --pretty
130
- cog run <module> --args "需求描述" --pretty
131
- cog run <module> --args "需求" --subagent # 启用子代理
129
+ cogn run <module> input.json -o output.json --pretty
130
+ cogn run <module> --args "需求描述" --pretty
131
+ cogn run <module> --args "需求" --subagent # 启用子代理
132
132
 
133
133
  # 创建模块
134
- cog init <name> -d "描述"
134
+ cogn init <name> -d "描述"
135
135
 
136
- # 安装/卸载
137
- cog install github:user/repo/path
138
- cog install registry:module-name
139
- cog uninstall <module>
136
+ # 从 GitHub 安装(推荐)
137
+ cogn add ziel-io/cognitive-modules -m code-simplifier
138
+ cogn add org/repo -m module-name --tag v1.0.0 # 安装指定版本
139
+ cogn remove <module> # 删除模块
140
+
141
+ # 版本管理
142
+ cogn update <module> # 更新到最新版本
143
+ cogn update <module> --tag v2.0.0 # 更新到指定版本
144
+ cogn versions <url> # 查看可用版本
145
+
146
+ # 其他安装方式
147
+ cogn install github:user/repo/path
148
+ cogn install registry:module-name
149
+ cogn uninstall <module>
140
150
 
141
151
  # 注册表
142
- cog registry # 查看公共模块
143
- cog search <query> # 搜索模块
152
+ cogn registry # 查看公共模块
153
+ cogn search <query> # 搜索模块
144
154
 
145
155
  # 环境检查
146
- cog doctor
156
+ cogn doctor
147
157
  ```
148
158
 
149
159
  ## 内置模块
150
160
 
151
161
  | 模块 | 功能 | 示例 |
152
162
  |------|------|------|
153
- | `code-reviewer` | 代码审查 | `cog run code-reviewer --args "你的代码"` |
154
- | `code-simplifier` | 代码简化 | `cog run code-simplifier --args "复杂代码"` |
155
- | `task-prioritizer` | 任务优先级排序 | `cog run task-prioritizer --args "任务1,任务2"` |
156
- | `api-designer` | REST API 设计 | `cog run api-designer --args "订单系统"` |
157
- | `ui-spec-generator` | UI 规范生成 | `cog run ui-spec-generator --args "电商首页"` |
158
- | `product-analyzer` | 产品分析(子代理示例) | `cog run product-analyzer --args "健康产品" -s` |
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` | 产品分析(子代理示例) | `cogn run product-analyzer --args "健康产品" -s` |
159
169
 
160
170
  ## 模块格式
161
171
 
@@ -239,7 +249,7 @@ export MINIMAX_API_KEY=sk-xxx
239
249
  export LLM_PROVIDER=ollama
240
250
 
241
251
  # 检查配置
242
- cog doctor
252
+ cogn doctor
243
253
  ```
244
254
 
245
255
  ## 创建新模块(完整流程)
@@ -340,14 +350,14 @@ EOF
340
350
  ### Step 4: 验证模块
341
351
 
342
352
  ```bash
343
- cog validate code-simplifier
344
- cog list # 确认模块出现在列表中
353
+ cogn validate code-simplifier
354
+ cogn list # 确认模块出现在列表中
345
355
  ```
346
356
 
347
357
  ### Step 5: 测试运行
348
358
 
349
359
  ```bash
350
- cog run code-simplifier --args "def calc(x): if x > 0: if x < 10: return x * 2 else: return x else: return 0" --pretty
360
+ cogn run code-simplifier --args "def calc(x): if x > 0: if x < 10: return x * 2 else: return x else: return 0" --pretty
351
361
  ```
352
362
 
353
363
  ### Step 6: 添加示例(可选)
@@ -384,8 +394,8 @@ pip install -e ".[dev]"
384
394
  pytest tests/ -v
385
395
 
386
396
  # 创建新模块(使用模板)
387
- cog init my-module -d "模块描述"
388
- cog validate my-module
397
+ cogn init my-module -d "模块描述"
398
+ cogn validate my-module
389
399
  ```
390
400
 
391
401
  ## 项目结构
@@ -16,7 +16,7 @@ Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、
16
16
  - **子代理编排** - `@call:module` 支持模块间调用
17
17
  - **参数传递** - `$ARGUMENTS` 运行时替换
18
18
  - **多 LLM 支持** - OpenAI / Anthropic / MiniMax / Ollama
19
- - **公共注册表** - `cog install registry:module-name`
19
+ - **公共注册表** - `cogn install registry:module-name`
20
20
 
21
21
  ## 安装
22
22
 
@@ -42,13 +42,13 @@ export LLM_PROVIDER=minimax
42
42
  export MINIMAX_API_KEY=sk-xxx
43
43
 
44
44
  # 运行代码审查
45
- cog run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
45
+ cogn run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
46
46
 
47
47
  # 运行任务排序
48
- cog run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --pretty
48
+ cogn run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --pretty
49
49
 
50
50
  # 运行 API 设计
51
- cog run api-designer --args "用户系统 CRUD API" --pretty
51
+ cogn run api-designer --args "用户系统 CRUD API" --pretty
52
52
  ```
53
53
 
54
54
  ## 与 Skills 对比
@@ -62,48 +62,58 @@ cog run api-designer --args "用户系统 CRUD API" --pretty
62
62
  | 推理过程 | ❌ | ✅ 必须 rationale |
63
63
  | 参数传递 | ✅ $ARGUMENTS | ✅ $ARGUMENTS |
64
64
  | 子代理 | ✅ context: fork | ✅ @call + context |
65
- | 验证工具 | ❌ | ✅ cog validate |
66
- | 注册表 | ❌ | ✅ cog install |
65
+ | 验证工具 | ❌ | ✅ cogn validate |
66
+ | 注册表 | ❌ | ✅ cogn install |
67
67
 
68
68
  ## CLI 命令
69
69
 
70
70
  ```bash
71
71
  # 模块管理
72
- cog list # 列出已安装模块
73
- cog info <module> # 查看模块详情
74
- cog validate <module> # 验证模块结构
72
+ cogn list # 列出已安装模块
73
+ cogn info <module> # 查看模块详情
74
+ cogn validate <module> # 验证模块结构
75
75
 
76
76
  # 运行模块
77
- cog run <module> input.json -o output.json --pretty
78
- cog run <module> --args "需求描述" --pretty
79
- cog run <module> --args "需求" --subagent # 启用子代理
77
+ cogn run <module> input.json -o output.json --pretty
78
+ cogn run <module> --args "需求描述" --pretty
79
+ cogn run <module> --args "需求" --subagent # 启用子代理
80
80
 
81
81
  # 创建模块
82
- cog init <name> -d "描述"
82
+ cogn init <name> -d "描述"
83
83
 
84
- # 安装/卸载
85
- cog install github:user/repo/path
86
- cog install registry:module-name
87
- cog uninstall <module>
84
+ # 从 GitHub 安装(推荐)
85
+ cogn add ziel-io/cognitive-modules -m code-simplifier
86
+ cogn add org/repo -m module-name --tag v1.0.0 # 安装指定版本
87
+ cogn remove <module> # 删除模块
88
+
89
+ # 版本管理
90
+ cogn update <module> # 更新到最新版本
91
+ cogn update <module> --tag v2.0.0 # 更新到指定版本
92
+ cogn versions <url> # 查看可用版本
93
+
94
+ # 其他安装方式
95
+ cogn install github:user/repo/path
96
+ cogn install registry:module-name
97
+ cogn uninstall <module>
88
98
 
89
99
  # 注册表
90
- cog registry # 查看公共模块
91
- cog search <query> # 搜索模块
100
+ cogn registry # 查看公共模块
101
+ cogn search <query> # 搜索模块
92
102
 
93
103
  # 环境检查
94
- cog doctor
104
+ cogn doctor
95
105
  ```
96
106
 
97
107
  ## 内置模块
98
108
 
99
109
  | 模块 | 功能 | 示例 |
100
110
  |------|------|------|
101
- | `code-reviewer` | 代码审查 | `cog run code-reviewer --args "你的代码"` |
102
- | `code-simplifier` | 代码简化 | `cog run code-simplifier --args "复杂代码"` |
103
- | `task-prioritizer` | 任务优先级排序 | `cog run task-prioritizer --args "任务1,任务2"` |
104
- | `api-designer` | REST API 设计 | `cog run api-designer --args "订单系统"` |
105
- | `ui-spec-generator` | UI 规范生成 | `cog run ui-spec-generator --args "电商首页"` |
106
- | `product-analyzer` | 产品分析(子代理示例) | `cog run product-analyzer --args "健康产品" -s` |
111
+ | `code-reviewer` | 代码审查 | `cogn run code-reviewer --args "你的代码"` |
112
+ | `code-simplifier` | 代码简化 | `cogn run code-simplifier --args "复杂代码"` |
113
+ | `task-prioritizer` | 任务优先级排序 | `cogn run task-prioritizer --args "任务1,任务2"` |
114
+ | `api-designer` | REST API 设计 | `cogn run api-designer --args "订单系统"` |
115
+ | `ui-spec-generator` | UI 规范生成 | `cogn run ui-spec-generator --args "电商首页"` |
116
+ | `product-analyzer` | 产品分析(子代理示例) | `cogn run product-analyzer --args "健康产品" -s` |
107
117
 
108
118
  ## 模块格式
109
119
 
@@ -187,7 +197,7 @@ export MINIMAX_API_KEY=sk-xxx
187
197
  export LLM_PROVIDER=ollama
188
198
 
189
199
  # 检查配置
190
- cog doctor
200
+ cogn doctor
191
201
  ```
192
202
 
193
203
  ## 创建新模块(完整流程)
@@ -288,14 +298,14 @@ EOF
288
298
  ### Step 4: 验证模块
289
299
 
290
300
  ```bash
291
- cog validate code-simplifier
292
- cog list # 确认模块出现在列表中
301
+ cogn validate code-simplifier
302
+ cogn list # 确认模块出现在列表中
293
303
  ```
294
304
 
295
305
  ### Step 5: 测试运行
296
306
 
297
307
  ```bash
298
- cog run code-simplifier --args "def calc(x): if x > 0: if x < 10: return x * 2 else: return x else: return 0" --pretty
308
+ cogn run code-simplifier --args "def calc(x): if x > 0: if x < 10: return x * 2 else: return x else: return 0" --pretty
299
309
  ```
300
310
 
301
311
  ### Step 6: 添加示例(可选)
@@ -332,8 +342,8 @@ pip install -e ".[dev]"
332
342
  pytest tests/ -v
333
343
 
334
344
  # 创建新模块(使用模板)
335
- cog init my-module -d "模块描述"
336
- cog validate my-module
345
+ cogn init my-module -d "模块描述"
346
+ cogn validate my-module
337
347
  ```
338
348
 
339
349
  ## 项目结构
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cognitive-modules"
7
- version = "0.2.0"
7
+ version = "0.4.0"
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"}
@@ -68,7 +68,7 @@ docs = [
68
68
  ]
69
69
 
70
70
  [project.scripts]
71
- cog = "cognitive.cli:app"
71
+ cogn = "cognitive.cli:app"
72
72
 
73
73
  [project.urls]
74
74
  Homepage = "https://github.com/ziel-io/cognitive-modules"
@@ -5,8 +5,12 @@ Commands:
5
5
  cog list List installed modules
6
6
  cog run <module> <input> Run a module
7
7
  cog validate <module> Validate module structure
8
+ cog add <url> --module <name> Add module from GitHub (recommended)
9
+ cog update <module> Update module to latest version
10
+ cog versions <url> List available versions for a repo
8
11
  cog install <source> Install module from git/local/registry
9
- cog uninstall <module> Remove an installed module
12
+ cog remove <module> Remove an installed module
13
+ cog uninstall <module> Remove an installed module (alias)
10
14
  cog init <name> Create a new module from template
11
15
  cog search <query> Search the public registry
12
16
  cog doctor Check environment setup
@@ -31,6 +35,11 @@ from .registry import (
31
35
  uninstall_module,
32
36
  search_registry,
33
37
  fetch_registry,
38
+ install_from_github_url,
39
+ update_module,
40
+ get_installed_module_info,
41
+ get_module_version,
42
+ list_github_tags,
34
43
  USER_MODULES_DIR,
35
44
  )
36
45
  from .loader import load_module, detect_format
@@ -203,6 +212,185 @@ def install_cmd(
203
212
  raise typer.Exit(1)
204
213
 
205
214
 
215
+ @app.command("add")
216
+ def add_cmd(
217
+ url: str = typer.Argument(..., help="GitHub URL or org/repo shorthand"),
218
+ module: str = typer.Option(None, "--module", "-m", help="Module path within repo"),
219
+ name: Optional[str] = typer.Option(None, "--name", "-n", help="Override module name"),
220
+ branch: str = typer.Option("main", "--branch", "-b", help="Git branch"),
221
+ tag: Optional[str] = typer.Option(None, "--tag", "-t", help="Git tag/version (e.g., v1.0.0)"),
222
+ ):
223
+ """
224
+ Add a cognitive module from GitHub.
225
+
226
+ Examples:
227
+
228
+ cog add https://github.com/ziel-io/cognitive-modules --module code-simplifier
229
+
230
+ cog add ziel-io/cognitive-modules -m code-reviewer
231
+
232
+ cog add org/repo -m my-module --tag v1.0.0
233
+
234
+ cog add org/repo -m path/to/module --name my-module
235
+ """
236
+ rprint(f"[cyan]→[/cyan] Adding module from: {url}")
237
+ if module:
238
+ rprint(f" Module path: {module}")
239
+ if tag:
240
+ rprint(f" Version: {tag}")
241
+
242
+ try:
243
+ target = install_from_github_url(
244
+ url=url,
245
+ module_path=module,
246
+ name=name,
247
+ branch=branch,
248
+ tag=tag,
249
+ )
250
+
251
+ # Validate installed module
252
+ is_valid, errors, warnings = validate_module(str(target))
253
+
254
+ if not is_valid:
255
+ rprint(f"[red]✗ Installed module failed validation:[/red]")
256
+ for e in errors:
257
+ rprint(f" - {e}")
258
+ uninstall_module(target.name)
259
+ raise typer.Exit(1)
260
+
261
+ # Get version info
262
+ version = get_module_version(target)
263
+ version_str = f" v{version}" if version else ""
264
+
265
+ rprint(f"[green]✓ Added: {target.name}{version_str}[/green]")
266
+ rprint(f" Location: {target}")
267
+
268
+ if warnings:
269
+ rprint(f"[yellow] Warnings: {len(warnings)}[/yellow]")
270
+
271
+ rprint(f"\nRun with:")
272
+ rprint(f" [cyan]cog run {target.name} --args \"your input\"[/cyan]")
273
+
274
+ except Exception as e:
275
+ rprint(f"[red]✗ Failed to add module: {e}[/red]")
276
+ raise typer.Exit(1)
277
+
278
+
279
+ @app.command("remove")
280
+ def remove_cmd(
281
+ module: str = typer.Argument(..., help="Module name to remove"),
282
+ ):
283
+ """Remove an installed cognitive module (alias for uninstall)."""
284
+ uninstall_cmd(module)
285
+
286
+
287
+ @app.command("update")
288
+ def update_cmd(
289
+ module: str = typer.Argument(..., help="Module name to update"),
290
+ tag: Optional[str] = typer.Option(None, "--tag", "-t", help="Update to specific tag/version"),
291
+ ):
292
+ """
293
+ Update an installed module to the latest version.
294
+
295
+ Examples:
296
+
297
+ cog update code-simplifier
298
+
299
+ cog update code-simplifier --tag v2.0.0
300
+ """
301
+ rprint(f"[cyan]→[/cyan] Updating module: {module}")
302
+
303
+ # Check if module is installed
304
+ info = get_installed_module_info(module)
305
+ if not info:
306
+ rprint(f"[red]✗ Module not found or not installed from GitHub: {module}[/red]")
307
+ rprint(f" Only modules installed with 'cog add' can be updated.")
308
+ raise typer.Exit(1)
309
+
310
+ github_url = info.get("github_url")
311
+ if not github_url:
312
+ rprint(f"[red]✗ Module was not installed from GitHub: {module}[/red]")
313
+ raise typer.Exit(1)
314
+
315
+ # Get current version
316
+ current_path = USER_MODULES_DIR / module
317
+ old_version = get_module_version(current_path) if current_path.exists() else None
318
+
319
+ if old_version:
320
+ rprint(f" Current version: {old_version}")
321
+
322
+ try:
323
+ # Re-install from source
324
+ module_path = info.get("module_path")
325
+ branch = info.get("branch", "main")
326
+
327
+ # Use specified tag or keep using the same ref type
328
+ use_tag = tag or info.get("tag")
329
+
330
+ target = install_from_github_url(
331
+ url=github_url,
332
+ module_path=module_path,
333
+ name=module,
334
+ branch=branch if not use_tag else "main",
335
+ tag=use_tag,
336
+ )
337
+
338
+ # Get new version
339
+ new_version = get_module_version(target)
340
+
341
+ if old_version and new_version:
342
+ if old_version == new_version:
343
+ rprint(f"[green]✓ Already up to date: {module} v{new_version}[/green]")
344
+ else:
345
+ rprint(f"[green]✓ Updated: {module} v{old_version} → v{new_version}[/green]")
346
+ elif new_version:
347
+ rprint(f"[green]✓ Updated: {module} to v{new_version}[/green]")
348
+ else:
349
+ rprint(f"[green]✓ Updated: {module}[/green]")
350
+
351
+ except Exception as e:
352
+ rprint(f"[red]✗ Failed to update module: {e}[/red]")
353
+ raise typer.Exit(1)
354
+
355
+
356
+ @app.command("versions")
357
+ def versions_cmd(
358
+ url: str = typer.Argument(..., help="GitHub URL or org/repo shorthand"),
359
+ limit: int = typer.Option(10, "--limit", "-l", help="Max versions to show"),
360
+ ):
361
+ """
362
+ List available versions (tags) for a GitHub repository.
363
+
364
+ Examples:
365
+
366
+ cog versions ziel-io/cognitive-modules
367
+
368
+ cog versions https://github.com/org/repo
369
+ """
370
+ rprint(f"[cyan]→[/cyan] Fetching versions from: {url}\n")
371
+
372
+ try:
373
+ tags = list_github_tags(url, limit=limit)
374
+
375
+ if not tags:
376
+ rprint("[yellow]No tags/versions found.[/yellow]")
377
+ return
378
+
379
+ table = Table(title=f"Available Versions ({len(tags)})")
380
+ table.add_column("Version", style="cyan")
381
+ table.add_column("Install Command")
382
+
383
+ for tag in tags:
384
+ cmd = f"cog add {url} --tag {tag}"
385
+ table.add_row(tag, f"[dim]{cmd}[/dim]")
386
+
387
+ console.print(table)
388
+
389
+ except Exception as e:
390
+ rprint(f"[red]✗ Failed to fetch versions: {e}[/red]")
391
+ raise typer.Exit(1)
392
+
393
+
206
394
  @app.command("uninstall")
207
395
  def uninstall_cmd(
208
396
  module: str = typer.Argument(..., help="Module name to uninstall"),
@@ -403,6 +591,20 @@ def info_cmd(
403
591
 
404
592
  rprint(f"\n[bold]Path:[/bold] {m['path']}")
405
593
  rprint(f"[bold]Prompt size:[/bold] {len(m['prompt'])} chars")
594
+
595
+ # Show installation info if available
596
+ install_info = get_installed_module_info(meta.get('name', module))
597
+ if install_info:
598
+ rprint(f"\n[bold]Installation:[/bold]")
599
+ if install_info.get("github_url"):
600
+ rprint(f" Source: {install_info['github_url']}")
601
+ if install_info.get("tag"):
602
+ rprint(f" Tag: {install_info['tag']}")
603
+ elif install_info.get("branch"):
604
+ rprint(f" Branch: {install_info['branch']}")
605
+ if install_info.get("installed_time"):
606
+ rprint(f" Installed: {install_info['installed_time'][:10]}")
607
+ rprint(f"\n Update with: [cyan]cog update {meta.get('name', module)}[/cyan]")
406
608
 
407
609
 
408
610
  @app.callback(invoke_without_command=True)
@@ -79,22 +79,28 @@ def load_v2_format(module_path: Path) -> dict:
79
79
  output_schema = {}
80
80
  error_schema = {}
81
81
 
82
- # Extract constraints
82
+ # Extract constraints (supports both old and new format)
83
83
  constraints_raw = manifest.get("constraints", {})
84
+ policies_raw = manifest.get("policies", {})
85
+
84
86
  constraints = {
85
87
  "operational": {
86
- "no_external_network": constraints_raw.get("no_network", True),
87
- "no_side_effects": constraints_raw.get("no_side_effects", True),
88
- "no_file_write": constraints_raw.get("no_file_write", True),
88
+ "no_external_network": constraints_raw.get("no_network", True) or policies_raw.get("network") == "deny",
89
+ "no_side_effects": constraints_raw.get("no_side_effects", True) or policies_raw.get("side_effects") == "deny",
90
+ "no_file_write": constraints_raw.get("no_file_write", True) or policies_raw.get("filesystem_write") == "deny",
89
91
  "no_inventing_data": constraints_raw.get("no_inventing_data", True),
90
92
  },
91
93
  "output_quality": {
92
94
  "require_confidence": manifest.get("output", {}).get("require_confidence", True),
93
95
  "require_rationale": manifest.get("output", {}).get("require_rationale", True),
94
96
  "require_behavior_equivalence": manifest.get("output", {}).get("require_behavior_equivalence", False),
95
- }
97
+ },
98
+ "behavior_equivalence_false_max_confidence": constraints_raw.get("behavior_equivalence_false_max_confidence", 0.7),
96
99
  }
97
100
 
101
+ # Extract policies (v2.1)
102
+ policies = manifest.get("policies", {})
103
+
98
104
  # Extract tools policy
99
105
  tools = manifest.get("tools", {})
100
106
 
@@ -104,6 +110,9 @@ def load_v2_format(module_path: Path) -> dict:
104
110
  # Extract failure contract
105
111
  failure_contract = manifest.get("failure", {})
106
112
 
113
+ # Extract runtime requirements
114
+ runtime_requirements = manifest.get("runtime_requirements", {})
115
+
107
116
  return {
108
117
  "name": manifest.get("name", module_path.name),
109
118
  "version": manifest.get("version", "1.0.0"),
@@ -116,9 +125,11 @@ def load_v2_format(module_path: Path) -> dict:
116
125
  "output_schema": output_schema,
117
126
  "error_schema": error_schema,
118
127
  "constraints": constraints,
128
+ "policies": policies,
119
129
  "tools": tools,
120
130
  "output_contract": output_contract,
121
131
  "failure_contract": failure_contract,
132
+ "runtime_requirements": runtime_requirements,
122
133
  "prompt": prompt,
123
134
  }
124
135