cognitive-modules-cli 2.2.8 → 2.2.10

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,16 @@
2
2
 
3
3
  All notable changes to this package are documented in this file.
4
4
 
5
+ ## 2.2.10 - 2026-02-07
6
+
7
+ - Fix: Gemini `responseSchema` compatibility by converting JSON-Schema `const` to `enum`.
8
+
9
+ ## 2.2.9 - 2026-02-07
10
+
11
+ - Fix: `cog core run` now prints the error envelope (instead of `Error: undefined`) when execution fails.
12
+ - Packaging: add stable `bin.js` entrypoint so publish/install doesn't depend on prebuilt `dist/` existing at publish-time.
13
+ - Core: align core template placeholders with runtime substitution (`${query}` / `${code}`); missing fields are treated as empty for single-file modules.
14
+
5
15
  ## 2.2.8 - 2026-02-07
6
16
 
7
17
  - Fix: `npx cogn` alias compatibility on newer Node (exports + ESM). (Alias fix ships in `cogn@2.2.8`.)
package/README.md CHANGED
@@ -10,12 +10,12 @@ Node.js/TypeScript 版本的 Cognitive Modules CLI,提供 `cog` 命令。
10
10
 
11
11
  ```bash
12
12
  # 全局安装(推荐)
13
- npm install -g cogn@2.2.8
13
+ npm install -g cogn@2.2.10
14
14
  # 或使用完整包名(同样提供 `cog` 命令)
15
- # npm install -g cognitive-modules-cli@2.2.8
15
+ # npm install -g cognitive-modules-cli@2.2.10
16
16
 
17
17
  # 或使用 npx 零安装
18
- npx cogn@2.2.8 --help
18
+ npx cogn@2.2.10 --help
19
19
  ```
20
20
 
21
21
  ## 快速开始
@@ -95,7 +95,7 @@ cog doctor
95
95
  # 可通过环境变量或全局参数覆盖:
96
96
  COGNITIVE_REGISTRY_URL=... cog search
97
97
  COGNITIVE_REGISTRY_TIMEOUT_MS=15000 COGNITIVE_REGISTRY_MAX_BYTES=2097152 cog search
98
- cog search --registry https://github.com/Cognary/cognitive/releases/download/v2.2.8/cognitive-registry.v2.json
98
+ cog search --registry https://github.com/Cognary/cognitive/releases/download/v2.2.10/cognitive-registry.v2.json
99
99
  cog registry verify --remote --index https://github.com/Cognary/cognitive/releases/latest/download/cognitive-registry.v2.json
100
100
  cog registry verify --remote --concurrency 2
101
101
  ```
package/bin.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Stable CLI entrypoint.
4
+ *
5
+ * Motivation:
6
+ * - Avoid `npm publish` warnings when `bin` points into `dist/` before build runs.
7
+ * - Keep runtime entrypoint stable even if build output paths change.
8
+ *
9
+ * This file is shipped in the published package and forwards to the compiled CLI.
10
+ */
11
+
12
+ import { spawnSync } from 'node:child_process';
13
+ import { fileURLToPath } from 'node:url';
14
+ import path from 'node:path';
15
+
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ const __dirname = path.dirname(__filename);
18
+
19
+ const cliPath = path.join(__dirname, 'dist', 'cli.js');
20
+ const args = process.argv.slice(2);
21
+
22
+ const res = spawnSync(process.execPath, [cliPath, ...args], { stdio: 'inherit' });
23
+
24
+ if (res.error) {
25
+ console.error(res.error);
26
+ process.exit(1);
27
+ }
28
+
29
+ process.exit(res.status ?? 1);
30
+
package/dist/cli.js CHANGED
@@ -182,7 +182,15 @@ async function main() {
182
182
  force: values.force,
183
183
  }, rest);
184
184
  if (!result.success) {
185
- console.error(`Error: ${result.error}`);
185
+ // Keep parity with `cog run`: if an error envelope exists, print it.
186
+ // This avoids confusing "Error: undefined" when the command returns a valid envelope
187
+ // but `error` string is not set.
188
+ if (result.data) {
189
+ console.log(JSON.stringify(result.data, null, values.pretty ? 2 : 0));
190
+ }
191
+ else {
192
+ console.error(`Error: ${result.error ?? 'Unknown error'}`);
193
+ }
186
194
  process.exit(1);
187
195
  }
188
196
  // Stream mode prints events as NDJSON already (via `cog run`).
@@ -48,10 +48,10 @@ function coreTemplate(name) {
48
48
  '',
49
49
  'INPUT VALUES:',
50
50
  'query:',
51
- '{{QUERY}}',
51
+ '${query}',
52
52
  '',
53
53
  'code:',
54
- '{{CODE}}',
54
+ '${code}',
55
55
  '',
56
56
  'Output (requirements):',
57
57
  '- ok: true',
@@ -1175,6 +1175,14 @@ export async function runModule(module, provider, options = {}) {
1175
1175
  inputData.query = args;
1176
1176
  }
1177
1177
  }
1178
+ // Single-file core modules promise "missing fields are empty".
1179
+ // Ensure common placeholders like `${query}` / `${code}` don't leak into prompts.
1180
+ if (typeof module.location === 'string' && /\.(md|markdown)$/i.test(module.location)) {
1181
+ if (inputData.query === undefined)
1182
+ inputData.query = '';
1183
+ if (inputData.code === undefined)
1184
+ inputData.code = '';
1185
+ }
1178
1186
  // Invoke before hooks
1179
1187
  _invokeBeforeHooks(module.name, inputData, module);
1180
1188
  // Validate input against schema
@@ -36,6 +36,12 @@ export class GeminiProvider extends BaseProvider {
36
36
  if (obj && typeof obj === 'object') {
37
37
  const result = {};
38
38
  for (const [key, value] of Object.entries(obj)) {
39
+ // Gemini's responseSchema does not accept JSON-Schema `const`.
40
+ // Convert `{ const: X }` into `{ enum: [X] }` for compatibility.
41
+ if (key === 'const') {
42
+ result.enum = [clean(value)];
43
+ continue;
44
+ }
39
45
  if (!unsupportedFields.includes(key)) {
40
46
  result[key] = clean(value);
41
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognitive-modules-cli",
3
- "version": "2.2.8",
3
+ "version": "2.2.10",
4
4
  "description": "Cognitive Modules - Structured AI Task Execution with version management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,8 +13,8 @@
13
13
  "./package.json": "./package.json"
14
14
  },
15
15
  "bin": {
16
- "cognitive-modules-cli": "dist/cli.js",
17
- "cog": "dist/cli.js"
16
+ "cognitive-modules-cli": "bin.js",
17
+ "cog": "bin.js"
18
18
  },
19
19
  "scripts": {
20
20
  "clean": "node -e \"import('node:fs').then(fs=>fs.rmSync('dist',{recursive:true,force:true}))\"",
@@ -40,6 +40,7 @@
40
40
  "license": "MIT",
41
41
  "author": "ziel-io",
42
42
  "files": [
43
+ "bin.js",
43
44
  "dist",
44
45
  "README.md",
45
46
  "LICENSE",