cognitive-modules-cli 2.2.15 → 2.2.16

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this package are documented in this file.
4
4
 
5
+ ## 2.2.16 - 2026-03-09
6
+
7
+ - Fix: preserve module-local `$defs` / `definitions` when loading `schema.json`, so runtime validation can resolve internal references inside `data`, `meta`, and `error` sub-schemas.
8
+ - Hardening: restore the official `pr-risk-gate` smoke path; schema validation now succeeds for contracts that include local schema references such as `extensions`.
9
+
5
10
  ## 2.2.15 - 2026-03-09
6
11
 
7
12
  - Runtime: add schema-guided output canonicalization so enum labels and unordered arrays can be normalized before validation/repair.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/cognitive-modules-cli.svg)](https://www.npmjs.com/package/cognitive-modules-cli)
4
4
 
5
- Node.js/TypeScript 版本的 Cognitive Modules CLI。文档统一使用明确入口 `npx cogn@2.2.15 ...`,避免 PATH/命令冲突。
5
+ Node.js/TypeScript 版本的 Cognitive Modules CLI。文档统一使用明确入口 `npx cogn@2.2.16 ...`,避免 PATH/命令冲突。
6
6
 
7
7
  > 这是 [cognitive-modules](../../README.md) monorepo 的一部分。
8
8
 
@@ -10,11 +10,11 @@ Node.js/TypeScript 版本的 Cognitive Modules CLI。文档统一使用明确入
10
10
 
11
11
  ```bash
12
12
  # 零安装(推荐)
13
- npx cogn@2.2.15 --help
13
+ npx cogn@2.2.16 --help
14
14
 
15
15
  # 全局安装(可选)
16
- npm install -g cogn@2.2.15
17
- # 或:npm install -g cognitive-modules-cli@2.2.15
16
+ npm install -g cogn@2.2.16
17
+ # 或:npm install -g cognitive-modules-cli@2.2.16
18
18
  ```
19
19
 
20
20
  ## 快速开始
@@ -24,16 +24,16 @@ npm install -g cogn@2.2.15
24
24
  export OPENAI_API_KEY=sk-xxx
25
25
 
26
26
  # 查看 providers 能力矩阵(结构化输出/流式)
27
- npx cogn@2.2.15 providers --pretty
27
+ npx cogn@2.2.16 providers --pretty
28
28
 
29
29
  # 运行模块
30
- npx cogn@2.2.15 run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
30
+ npx cogn@2.2.16 run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
31
31
 
32
32
  # 列出模块
33
- npx cogn@2.2.15 list
33
+ npx cogn@2.2.16 list
34
34
 
35
35
  # 管道模式
36
- echo "review this code" | npx cogn@2.2.15 pipe --module code-reviewer
36
+ echo "review this code" | npx cogn@2.2.16 pipe --module code-reviewer
37
37
  ```
38
38
 
39
39
  ## 支持的 Provider
@@ -59,21 +59,21 @@ echo "review this code" | npx cogn@2.2.15 pipe --module code-reviewer
59
59
  查看全部 provider(含实验/社区):
60
60
 
61
61
  ```bash
62
- npx cogn@2.2.15 providers --pretty --all
62
+ npx cogn@2.2.16 providers --pretty --all
63
63
  ```
64
64
 
65
65
  ## 命令
66
66
 
67
67
  ```bash
68
68
  # Core(单文件极简路径)
69
- npx cogn@2.2.15 core new # 生成 demo.md
70
- npx cogn@2.2.15 core run demo.md --args "..." # 运行单文件模块
71
- npx cogn@2.2.15 core promote demo.md # 升级为 v2 模块目录
69
+ npx cogn@2.2.16 core new # 生成 demo.md
70
+ npx cogn@2.2.16 core run demo.md --args "..." # 运行单文件模块
71
+ npx cogn@2.2.16 core promote demo.md # 升级为 v2 模块目录
72
72
 
73
73
  # 渐进复杂度(Profiles)
74
- npx cogn@2.2.15 run code-reviewer --args "..." --profile core # 极简:跳过校验
75
- npx cogn@2.2.15 run code-reviewer --args "..." --profile standard # 推荐:日常默认
76
- npx cogn@2.2.15 run code-reviewer --args "..." --profile certified # 最严格:v2.2 + 审计 + registry provenance/完整性门禁
74
+ npx cogn@2.2.16 run code-reviewer --args "..." --profile core # 极简:跳过校验
75
+ npx cogn@2.2.16 run code-reviewer --args "..." --profile standard # 推荐:日常默认
76
+ npx cogn@2.2.16 run code-reviewer --args "..." --profile certified # 最严格:v2.2 + 审计 + registry provenance/完整性门禁
77
77
  # 兼容别名(不推荐写进新文档):
78
78
  # - default -> standard
79
79
  # - strict -> standard(deprecated preset)
@@ -83,41 +83,41 @@ npx cogn@2.2.15 run code-reviewer --args "..." --profile certified # 最严格
83
83
  # - --audit(写入 ~/.cognitive/audit/)
84
84
 
85
85
  # 模块操作
86
- npx cogn@2.2.15 list # 列出模块
87
- npx cogn@2.2.15 run <module> --args "..." # 运行模块
88
- npx cogn@2.2.15 add <url> -m <module> # 从 GitHub 添加模块
89
- npx cogn@2.2.15 update <module> # 更新模块
90
- npx cogn@2.2.15 remove <module> # 删除模块
91
- npx cogn@2.2.15 versions <url> # 查看可用版本
92
- npx cogn@2.2.15 init <name> # 创建新模块
93
- npx cogn@2.2.15 pipe --module <name> # 管道模式
86
+ npx cogn@2.2.16 list # 列出模块
87
+ npx cogn@2.2.16 run <module> --args "..." # 运行模块
88
+ npx cogn@2.2.16 add <url> -m <module> # 从 GitHub 添加模块
89
+ npx cogn@2.2.16 update <module> # 更新模块
90
+ npx cogn@2.2.16 remove <module> # 删除模块
91
+ npx cogn@2.2.16 versions <url> # 查看可用版本
92
+ npx cogn@2.2.16 init <name> # 创建新模块
93
+ npx cogn@2.2.16 pipe --module <name> # 管道模式
94
94
 
95
95
  # 组合执行
96
- npx cogn@2.2.15 compose <module> --args "..."
97
- npx cogn@2.2.15 compose-info <module>
96
+ npx cogn@2.2.16 compose <module> --args "..."
97
+ npx cogn@2.2.16 compose-info <module>
98
98
 
99
99
  # 校验与迁移
100
- npx cogn@2.2.15 validate <module> --v22
101
- npx cogn@2.2.15 validate --all
102
- npx cogn@2.2.15 migrate <module> --dry-run
103
- npx cogn@2.2.15 migrate --all --no-backup
100
+ npx cogn@2.2.16 validate <module> --v22
101
+ npx cogn@2.2.16 validate --all
102
+ npx cogn@2.2.16 migrate <module> --dry-run
103
+ npx cogn@2.2.16 migrate --all --no-backup
104
104
 
105
105
  # 服务器
106
- npx cogn@2.2.15 serve --port 8000 # 启动 HTTP API 服务
107
- npx cogn@2.2.15 mcp # 启动 MCP 服务(Claude Code / Cursor)
106
+ npx cogn@2.2.16 serve --port 8000 # 启动 HTTP API 服务
107
+ npx cogn@2.2.16 mcp # 启动 MCP 服务(Claude Code / Cursor)
108
108
 
109
109
  # 环境检查
110
- npx cogn@2.2.15 doctor
110
+ npx cogn@2.2.16 doctor
111
111
 
112
112
  # Registry(索引与分发)
113
113
  # 默认 registry index(latest):
114
114
  # https://github.com/Cognary/cognitive/releases/latest/download/cognitive-registry.v2.json
115
115
  # 可通过环境变量或全局参数覆盖:
116
- COGNITIVE_REGISTRY_URL=... npx cogn@2.2.15 search
117
- COGNITIVE_REGISTRY_TIMEOUT_MS=15000 COGNITIVE_REGISTRY_MAX_BYTES=2097152 npx cogn@2.2.15 search
118
- npx cogn@2.2.15 search --registry https://github.com/Cognary/cognitive/releases/download/vX.Y.Z/cognitive-registry.v2.json
119
- npx cogn@2.2.15 registry verify --remote --index https://github.com/Cognary/cognitive/releases/latest/download/cognitive-registry.v2.json
120
- npx cogn@2.2.15 registry verify --remote --concurrency 2
116
+ COGNITIVE_REGISTRY_URL=... npx cogn@2.2.16 search
117
+ COGNITIVE_REGISTRY_TIMEOUT_MS=15000 COGNITIVE_REGISTRY_MAX_BYTES=2097152 npx cogn@2.2.16 search
118
+ npx cogn@2.2.16 search --registry https://github.com/Cognary/cognitive/releases/download/vX.Y.Z/cognitive-registry.v2.json
119
+ npx cogn@2.2.16 registry verify --remote --index https://github.com/Cognary/cognitive/releases/latest/download/cognitive-registry.v2.json
120
+ npx cogn@2.2.16 registry verify --remote --concurrency 2
121
121
  ```
122
122
 
123
123
  ## 开发
@@ -47,6 +47,23 @@ function detectV2Version(manifest) {
47
47
  }
48
48
  return 'v2.0';
49
49
  }
50
+ function withLocalSchemaDefinitions(subSchema, rootSchema) {
51
+ if (!subSchema || typeof subSchema !== 'object')
52
+ return subSchema;
53
+ const defs = rootSchema.$defs;
54
+ const definitions = rootSchema.definitions;
55
+ if (defs === undefined && definitions === undefined) {
56
+ return subSchema;
57
+ }
58
+ const normalized = { ...subSchema };
59
+ if (normalized.$defs === undefined && defs !== undefined) {
60
+ normalized.$defs = defs;
61
+ }
62
+ if (normalized.definitions === undefined && definitions !== undefined) {
63
+ normalized.definitions = definitions;
64
+ }
65
+ return normalized;
66
+ }
50
67
  /**
51
68
  * Load v2 format module (module.yaml + prompt.md)
52
69
  */
@@ -77,12 +94,12 @@ async function loadModuleV2(modulePath) {
77
94
  try {
78
95
  const schemaContent = await fs.readFile(schemaFile, 'utf-8');
79
96
  const schema = JSON.parse(schemaContent);
80
- inputSchema = schema.input;
97
+ inputSchema = withLocalSchemaDefinitions(schema.input, schema);
81
98
  // Support both "data" (v2.2) and "output" (v2.1) aliases
82
- dataSchema = schema.data || schema.output;
99
+ dataSchema = withLocalSchemaDefinitions((schema.data || schema.output), schema);
83
100
  outputSchema = dataSchema; // Backward compat
84
- metaSchema = schema.meta;
85
- errorSchema = schema.error;
101
+ metaSchema = withLocalSchemaDefinitions(schema.meta, schema);
102
+ errorSchema = withLocalSchemaDefinitions(schema.error, schema);
86
103
  }
87
104
  catch {
88
105
  // Schema file is optional but recommended
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognitive-modules-cli",
3
- "version": "2.2.15",
3
+ "version": "2.2.16",
4
4
  "description": "Cognitive Modules - Structured AI Task Execution with version management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",