cognitive-modules-cli 2.2.10 → 2.2.12
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 +9 -0
- package/README.md +47 -40
- package/dist/cli-args.d.ts +34 -0
- package/dist/cli-args.js +149 -0
- package/dist/cli.js +86 -75
- package/dist/commands/add.js +2 -2
- package/dist/commands/compose.js +1 -24
- package/dist/commands/conformance.d.ts +39 -0
- package/dist/commands/conformance.js +517 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/pipe.js +1 -16
- package/dist/commands/run.js +1 -22
- package/dist/modules/composition.d.ts +3 -3
- package/dist/modules/composition.js +4 -3
- package/dist/modules/json-extract.d.ts +7 -0
- package/dist/modules/json-extract.js +132 -0
- package/dist/modules/runner.d.ts +11 -1
- package/dist/modules/runner.js +614 -47
- package/dist/policy-summary.d.ts +16 -0
- package/dist/policy-summary.js +33 -0
- package/dist/profile.d.ts +1 -0
- package/dist/profile.js +38 -17
- package/dist/providers/base.d.ts +2 -1
- package/dist/providers/base.js +6 -0
- package/dist/providers/gemini.d.ts +5 -0
- package/dist/providers/gemini.js +57 -7
- package/dist/providers/index.d.ts +10 -1
- package/dist/providers/index.js +34 -8
- package/dist/providers/moonshot.d.ts +3 -0
- package/dist/providers/moonshot.js +58 -13
- package/dist/registry/assets.d.ts +8 -0
- package/dist/registry/assets.js +48 -13
- package/dist/types.d.ts +43 -3
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 2.2.12 - 2026-02-08
|
|
6
|
+
|
|
7
|
+
- Conformance: add `runtime` suite (offline, deterministic vectors) to validate publish-grade JSON parsing and profile gates.
|
|
8
|
+
- UX: conformance help/usage now documents `--suite runtime` explicitly.
|
|
9
|
+
|
|
10
|
+
## 2.2.11 - 2026-02-07
|
|
11
|
+
|
|
12
|
+
- Fix: Gemini `responseSchema` compatibility by dropping non-string `enum`/`const` constraints (Gemini rejects boolean enums).
|
|
13
|
+
|
|
5
14
|
## 2.2.10 - 2026-02-07
|
|
6
15
|
|
|
7
16
|
- Fix: Gemini `responseSchema` compatibility by converting JSON-Schema `const` to `enum`.
|
package/README.md
CHANGED
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/cognitive-modules-cli)
|
|
4
4
|
|
|
5
|
-
Node.js/TypeScript 版本的 Cognitive Modules CLI
|
|
5
|
+
Node.js/TypeScript 版本的 Cognitive Modules CLI。文档统一使用明确入口 `npx cogn@2.2.12 ...`,避免 PATH/命令冲突。
|
|
6
6
|
|
|
7
7
|
> 这是 [cognitive-modules](../../README.md) monorepo 的一部分。
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
# 或使用完整包名(同样提供 `cog` 命令)
|
|
15
|
-
# npm install -g cognitive-modules-cli@2.2.10
|
|
12
|
+
# 零安装(推荐)
|
|
13
|
+
npx cogn@2.2.12 --help
|
|
16
14
|
|
|
17
|
-
#
|
|
18
|
-
|
|
15
|
+
# 全局安装(可选)
|
|
16
|
+
npm install -g cogn@2.2.12
|
|
17
|
+
# 或:npm install -g cognitive-modules-cli@2.2.12
|
|
19
18
|
```
|
|
20
19
|
|
|
21
20
|
## 快速开始
|
|
@@ -24,14 +23,17 @@ npx cogn@2.2.10 --help
|
|
|
24
23
|
# 配置 LLM
|
|
25
24
|
export OPENAI_API_KEY=sk-xxx
|
|
26
25
|
|
|
26
|
+
# 查看 providers 能力矩阵(结构化输出/流式)
|
|
27
|
+
npx cogn@2.2.12 providers --pretty
|
|
28
|
+
|
|
27
29
|
# 运行模块
|
|
28
|
-
|
|
30
|
+
npx cogn@2.2.12 run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
|
|
29
31
|
|
|
30
32
|
# 列出模块
|
|
31
|
-
|
|
33
|
+
npx cogn@2.2.12 list
|
|
32
34
|
|
|
33
35
|
# 管道模式
|
|
34
|
-
echo "review this code" |
|
|
36
|
+
echo "review this code" | npx cogn@2.2.12 pipe --module code-reviewer
|
|
35
37
|
```
|
|
36
38
|
|
|
37
39
|
## 支持的 Provider
|
|
@@ -51,53 +53,58 @@ echo "review this code" | cog pipe --module code-reviewer
|
|
|
51
53
|
|
|
52
54
|
```bash
|
|
53
55
|
# Core(单文件极简路径)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
npx cogn@2.2.12 core new # 生成 demo.md
|
|
57
|
+
npx cogn@2.2.12 core run demo.md --args "..." # 运行单文件模块
|
|
58
|
+
npx cogn@2.2.12 core promote demo.md # 升级为 v2 模块目录
|
|
57
59
|
|
|
58
60
|
# 渐进复杂度(Profiles)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
#
|
|
61
|
+
npx cogn@2.2.12 run code-reviewer --args "..." --profile core # 极简:跳过校验
|
|
62
|
+
npx cogn@2.2.12 run code-reviewer --args "..." --profile standard # 推荐:日常默认
|
|
63
|
+
npx cogn@2.2.12 run code-reviewer --args "..." --profile certified # 最严格:v2.2 + 审计 + registry provenance/完整性门禁
|
|
64
|
+
# 兼容别名(不推荐写进新文档):
|
|
65
|
+
# - default -> standard
|
|
66
|
+
# - strict -> standard(deprecated preset)
|
|
67
|
+
# 覆盖开关:
|
|
68
|
+
# - --validate auto|on|off
|
|
69
|
+
# - --structured auto|off|prompt|native(provider 层结构化输出策略)
|
|
70
|
+
# - --audit(写入 ~/.cognitive/audit/)
|
|
64
71
|
|
|
65
72
|
# 模块操作
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
npx cogn@2.2.12 list # 列出模块
|
|
74
|
+
npx cogn@2.2.12 run <module> --args "..." # 运行模块
|
|
75
|
+
npx cogn@2.2.12 add <url> -m <module> # 从 GitHub 添加模块
|
|
76
|
+
npx cogn@2.2.12 update <module> # 更新模块
|
|
77
|
+
npx cogn@2.2.12 remove <module> # 删除模块
|
|
78
|
+
npx cogn@2.2.12 versions <url> # 查看可用版本
|
|
79
|
+
npx cogn@2.2.12 init <name> # 创建新模块
|
|
80
|
+
npx cogn@2.2.12 pipe --module <name> # 管道模式
|
|
74
81
|
|
|
75
82
|
# 组合执行
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
npx cogn@2.2.12 compose <module> --args "..."
|
|
84
|
+
npx cogn@2.2.12 compose-info <module>
|
|
78
85
|
|
|
79
86
|
# 校验与迁移
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
npx cogn@2.2.12 validate <module> --v22
|
|
88
|
+
npx cogn@2.2.12 validate --all
|
|
89
|
+
npx cogn@2.2.12 migrate <module> --dry-run
|
|
90
|
+
npx cogn@2.2.12 migrate --all --no-backup
|
|
84
91
|
|
|
85
92
|
# 服务器
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
npx cogn@2.2.12 serve --port 8000 # 启动 HTTP API 服务
|
|
94
|
+
npx cogn@2.2.12 mcp # 启动 MCP 服务(Claude Code / Cursor)
|
|
88
95
|
|
|
89
96
|
# 环境检查
|
|
90
|
-
|
|
97
|
+
npx cogn@2.2.12 doctor
|
|
91
98
|
|
|
92
99
|
# Registry(索引与分发)
|
|
93
100
|
# 默认 registry index(latest):
|
|
94
101
|
# https://github.com/Cognary/cognitive/releases/latest/download/cognitive-registry.v2.json
|
|
95
102
|
# 可通过环境变量或全局参数覆盖:
|
|
96
|
-
COGNITIVE_REGISTRY_URL=...
|
|
97
|
-
COGNITIVE_REGISTRY_TIMEOUT_MS=15000 COGNITIVE_REGISTRY_MAX_BYTES=2097152
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
COGNITIVE_REGISTRY_URL=... npx cogn@2.2.12 search
|
|
104
|
+
COGNITIVE_REGISTRY_TIMEOUT_MS=15000 COGNITIVE_REGISTRY_MAX_BYTES=2097152 npx cogn@2.2.12 search
|
|
105
|
+
npx cogn@2.2.12 search --registry https://github.com/Cognary/cognitive/releases/download/vX.Y.Z/cognitive-registry.v2.json
|
|
106
|
+
npx cogn@2.2.12 registry verify --remote --index https://github.com/Cognary/cognitive/releases/latest/download/cognitive-registry.v2.json
|
|
107
|
+
npx cogn@2.2.12 registry verify --remote --concurrency 2
|
|
101
108
|
```
|
|
102
109
|
|
|
103
110
|
## 开发
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type CliParseResult = {
|
|
2
|
+
command?: string;
|
|
3
|
+
/**
|
|
4
|
+
* Positionals after the command (subcommand/module name/query words).
|
|
5
|
+
* This intentionally matches the historical meaning of `positionals` in `cli.ts`
|
|
6
|
+
* (i.e., it does NOT include the command itself).
|
|
7
|
+
*/
|
|
8
|
+
positionals: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Convenience array shaped like `process.argv.slice(2)` used to be:
|
|
11
|
+
* args[0] = command, args[1] = first positional after command.
|
|
12
|
+
*/
|
|
13
|
+
args: string[];
|
|
14
|
+
values: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Recover from `npx`/`npm exec` swallowing unknown flags.
|
|
18
|
+
*
|
|
19
|
+
* Example user intent:
|
|
20
|
+
* npx cogn@X --provider minimax --model MiniMax-M2.1 core run --stdin ...
|
|
21
|
+
*
|
|
22
|
+
* Some `npx` flows interpret `--provider/--model` as `npx` flags and strip them,
|
|
23
|
+
* leaving the values as positionals:
|
|
24
|
+
* minimax MiniMax-M2.1 core run --stdin ...
|
|
25
|
+
*
|
|
26
|
+
* This normalization attempts to restore:
|
|
27
|
+
* - command = core
|
|
28
|
+
* - values.provider/model = prelude tokens
|
|
29
|
+
* - positionals = remaining args after core
|
|
30
|
+
*
|
|
31
|
+
* We intentionally scope the recovery to the "core" entrypoint to avoid masking real typos.
|
|
32
|
+
*/
|
|
33
|
+
export declare function normalizeCliParseResult(parsed: CliParseResult): CliParseResult;
|
|
34
|
+
export declare function parseCliArgs(argv: string[]): CliParseResult;
|
package/dist/cli-args.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
const KNOWN_COMMANDS = new Set([
|
|
3
|
+
'run',
|
|
4
|
+
'list',
|
|
5
|
+
'pipe',
|
|
6
|
+
'init',
|
|
7
|
+
'add',
|
|
8
|
+
'update',
|
|
9
|
+
'remove',
|
|
10
|
+
'versions',
|
|
11
|
+
'compose',
|
|
12
|
+
'compose-info',
|
|
13
|
+
'validate',
|
|
14
|
+
'migrate',
|
|
15
|
+
'test',
|
|
16
|
+
'conformance',
|
|
17
|
+
'search',
|
|
18
|
+
'categories',
|
|
19
|
+
'info',
|
|
20
|
+
'providers',
|
|
21
|
+
'registry',
|
|
22
|
+
'serve',
|
|
23
|
+
'doctor',
|
|
24
|
+
'mcp',
|
|
25
|
+
'core',
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* Recover from `npx`/`npm exec` swallowing unknown flags.
|
|
29
|
+
*
|
|
30
|
+
* Example user intent:
|
|
31
|
+
* npx cogn@X --provider minimax --model MiniMax-M2.1 core run --stdin ...
|
|
32
|
+
*
|
|
33
|
+
* Some `npx` flows interpret `--provider/--model` as `npx` flags and strip them,
|
|
34
|
+
* leaving the values as positionals:
|
|
35
|
+
* minimax MiniMax-M2.1 core run --stdin ...
|
|
36
|
+
*
|
|
37
|
+
* This normalization attempts to restore:
|
|
38
|
+
* - command = core
|
|
39
|
+
* - values.provider/model = prelude tokens
|
|
40
|
+
* - positionals = remaining args after core
|
|
41
|
+
*
|
|
42
|
+
* We intentionally scope the recovery to the "core" entrypoint to avoid masking real typos.
|
|
43
|
+
*/
|
|
44
|
+
export function normalizeCliParseResult(parsed) {
|
|
45
|
+
const command = parsed.command;
|
|
46
|
+
if (!command)
|
|
47
|
+
return parsed;
|
|
48
|
+
if (KNOWN_COMMANDS.has(command))
|
|
49
|
+
return parsed;
|
|
50
|
+
const allPositionals = [command, ...parsed.positionals];
|
|
51
|
+
const coreIdx = allPositionals.indexOf('core');
|
|
52
|
+
if (coreIdx <= 0)
|
|
53
|
+
return parsed;
|
|
54
|
+
const prelude = allPositionals.slice(0, coreIdx);
|
|
55
|
+
const rest = allPositionals.slice(coreIdx + 1);
|
|
56
|
+
const values = { ...parsed.values };
|
|
57
|
+
if (values.provider === undefined && prelude[0])
|
|
58
|
+
values.provider = prelude[0];
|
|
59
|
+
if (values.model === undefined && prelude[1])
|
|
60
|
+
values.model = prelude[1];
|
|
61
|
+
return {
|
|
62
|
+
command: 'core',
|
|
63
|
+
positionals: rest,
|
|
64
|
+
args: ['core', ...rest],
|
|
65
|
+
values,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function parseCliArgs(argv) {
|
|
69
|
+
const { values, positionals } = parseArgs({
|
|
70
|
+
args: argv,
|
|
71
|
+
options: {
|
|
72
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
73
|
+
version: { type: 'boolean', short: 'v', default: false },
|
|
74
|
+
stdin: { type: 'boolean', default: false }, // core: read module prompt from stdin
|
|
75
|
+
force: { type: 'boolean', default: false }, // core promote: overwrite existing target dir
|
|
76
|
+
profile: { type: 'string' }, // progressive complexity profile
|
|
77
|
+
validate: { type: 'string' }, // auto|on|off (overrides --no-validate)
|
|
78
|
+
audit: { type: 'boolean', default: false }, // write audit record to ~/.cognitive/audit/
|
|
79
|
+
structured: { type: 'string' }, // auto|off|prompt|native (provider structured output strategy)
|
|
80
|
+
args: { type: 'string', short: 'a' },
|
|
81
|
+
input: { type: 'string', short: 'i' },
|
|
82
|
+
module: { type: 'string', short: 'm' },
|
|
83
|
+
model: { type: 'string', short: 'M' },
|
|
84
|
+
provider: { type: 'string', short: 'p' },
|
|
85
|
+
pretty: { type: 'boolean', default: false },
|
|
86
|
+
verbose: { type: 'boolean', short: 'V', default: false },
|
|
87
|
+
'no-validate': { type: 'boolean', default: false },
|
|
88
|
+
stream: { type: 'boolean', default: false },
|
|
89
|
+
// Add/update options
|
|
90
|
+
name: { type: 'string', short: 'n' },
|
|
91
|
+
tag: { type: 'string', short: 't' },
|
|
92
|
+
branch: { type: 'string', short: 'b' },
|
|
93
|
+
limit: { type: 'string', short: 'l' },
|
|
94
|
+
// Server options
|
|
95
|
+
host: { type: 'string', short: 'H' },
|
|
96
|
+
port: { type: 'string', short: 'P' },
|
|
97
|
+
// Compose options
|
|
98
|
+
'max-depth': { type: 'string', short: 'd' },
|
|
99
|
+
timeout: { type: 'string', short: 'T' },
|
|
100
|
+
trace: { type: 'boolean', default: false },
|
|
101
|
+
// Conformance (spec vectors)
|
|
102
|
+
conformance: { type: 'boolean', default: false }, // test: run official spec vectors
|
|
103
|
+
suite: { type: 'string' }, // envelope|stream|registry|all
|
|
104
|
+
level: { type: 'string' }, // 1|2|3
|
|
105
|
+
'spec-dir': { type: 'string' }, // repo root or <root>/spec
|
|
106
|
+
json: { type: 'boolean', default: false }, // conformance: machine-readable output
|
|
107
|
+
// Validate/migrate options
|
|
108
|
+
v22: { type: 'boolean', default: false },
|
|
109
|
+
'dry-run': { type: 'boolean', default: false },
|
|
110
|
+
'no-backup': { type: 'boolean', default: false },
|
|
111
|
+
all: { type: 'boolean', default: false },
|
|
112
|
+
format: { type: 'string', short: 'f' },
|
|
113
|
+
// Search options
|
|
114
|
+
category: { type: 'string', short: 'c' },
|
|
115
|
+
registry: { type: 'string' }, // override registry index URL (or use env COGNITIVE_REGISTRY_URL)
|
|
116
|
+
'registry-timeout-ms': { type: 'string' },
|
|
117
|
+
'registry-max-bytes': { type: 'string' },
|
|
118
|
+
// Registry build/verify options
|
|
119
|
+
'modules-dir': { type: 'string' },
|
|
120
|
+
'v1-registry': { type: 'string' },
|
|
121
|
+
'out-dir': { type: 'string' },
|
|
122
|
+
'registry-out': { type: 'string' },
|
|
123
|
+
namespace: { type: 'string' },
|
|
124
|
+
'runtime-min': { type: 'string' },
|
|
125
|
+
repository: { type: 'string' },
|
|
126
|
+
homepage: { type: 'string' },
|
|
127
|
+
license: { type: 'string' },
|
|
128
|
+
timestamp: { type: 'string' },
|
|
129
|
+
only: { type: 'string', multiple: true },
|
|
130
|
+
index: { type: 'string' },
|
|
131
|
+
'assets-dir': { type: 'string' },
|
|
132
|
+
'tarball-base-url': { type: 'string' },
|
|
133
|
+
remote: { type: 'boolean', default: false }, // registry verify: fetch index + tarballs over network
|
|
134
|
+
'fetch-timeout-ms': { type: 'string' },
|
|
135
|
+
'max-index-bytes': { type: 'string' },
|
|
136
|
+
'max-tarball-bytes': { type: 'string' },
|
|
137
|
+
concurrency: { type: 'string' },
|
|
138
|
+
},
|
|
139
|
+
allowPositionals: true,
|
|
140
|
+
});
|
|
141
|
+
const command = positionals[0];
|
|
142
|
+
const rest = positionals.slice(1);
|
|
143
|
+
return {
|
|
144
|
+
command,
|
|
145
|
+
positionals: rest,
|
|
146
|
+
args: command ? [command, ...rest] : [],
|
|
147
|
+
values: values,
|
|
148
|
+
};
|
|
149
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -13,90 +13,28 @@
|
|
|
13
13
|
*
|
|
14
14
|
* npx cognitive-modules add ziel-io/cognitive-modules -m code-simplifier
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { normalizeCliParseResult, parseCliArgs } from './cli-args.js';
|
|
17
17
|
import { getProvider, listProviders } from './providers/index.js';
|
|
18
|
-
import { run, list, pipe, init, add, update, remove, versions, compose, composeInfo, validate, validateAll, migrate, migrateAll, test, testAll, search, listCategories, info, core } from './commands/index.js';
|
|
18
|
+
import { run, list, pipe, init, add, update, remove, versions, compose, composeInfo, validate, validateAll, migrate, migrateAll, test, testAll, conformance, search, listCategories, info, core } from './commands/index.js';
|
|
19
19
|
import { listModules, getDefaultSearchPaths } from './modules/loader.js';
|
|
20
20
|
import { VERSION } from './version.js';
|
|
21
21
|
import { resolveExecutionPolicy } from './profile.js';
|
|
22
22
|
import { buildRegistryAssets, verifyRegistryAssets } from './registry/assets.js';
|
|
23
23
|
import { DEFAULT_REGISTRY_URL } from './registry/client.js';
|
|
24
24
|
async function main() {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const parsed = normalizeCliParseResult(parseCliArgs(process.argv.slice(2)));
|
|
26
|
+
const values = parsed.values;
|
|
27
|
+
const positionals = parsed.positionals;
|
|
28
|
+
const args = parsed.args;
|
|
29
|
+
const command = parsed.command;
|
|
30
|
+
if (values.version) {
|
|
31
|
+
console.log(`Cognitive Runtime v${VERSION}`);
|
|
29
32
|
process.exit(0);
|
|
30
33
|
}
|
|
31
|
-
if (command
|
|
32
|
-
|
|
34
|
+
if (!command) {
|
|
35
|
+
printHelp();
|
|
33
36
|
process.exit(0);
|
|
34
37
|
}
|
|
35
|
-
// Parse common options
|
|
36
|
-
const { values, positionals } = parseArgs({
|
|
37
|
-
args: args.slice(1),
|
|
38
|
-
options: {
|
|
39
|
-
help: { type: 'boolean', short: 'h', default: false },
|
|
40
|
-
stdin: { type: 'boolean', default: false }, // core: read module prompt from stdin
|
|
41
|
-
force: { type: 'boolean', default: false }, // core promote: overwrite existing target dir
|
|
42
|
-
profile: { type: 'string' }, // progressive complexity profile
|
|
43
|
-
validate: { type: 'string' }, // auto|on|off (overrides --no-validate)
|
|
44
|
-
audit: { type: 'boolean', default: false }, // write audit record to ~/.cognitive/audit/
|
|
45
|
-
args: { type: 'string', short: 'a' },
|
|
46
|
-
input: { type: 'string', short: 'i' },
|
|
47
|
-
module: { type: 'string', short: 'm' },
|
|
48
|
-
model: { type: 'string', short: 'M' },
|
|
49
|
-
provider: { type: 'string', short: 'p' },
|
|
50
|
-
pretty: { type: 'boolean', default: false },
|
|
51
|
-
verbose: { type: 'boolean', short: 'V', default: false },
|
|
52
|
-
'no-validate': { type: 'boolean', default: false },
|
|
53
|
-
stream: { type: 'boolean', default: false },
|
|
54
|
-
// Add/update options
|
|
55
|
-
name: { type: 'string', short: 'n' },
|
|
56
|
-
tag: { type: 'string', short: 't' },
|
|
57
|
-
branch: { type: 'string', short: 'b' },
|
|
58
|
-
limit: { type: 'string', short: 'l' },
|
|
59
|
-
// Server options
|
|
60
|
-
host: { type: 'string', short: 'H' },
|
|
61
|
-
port: { type: 'string', short: 'P' },
|
|
62
|
-
// Compose options
|
|
63
|
-
'max-depth': { type: 'string', short: 'd' },
|
|
64
|
-
timeout: { type: 'string', short: 'T' },
|
|
65
|
-
trace: { type: 'boolean', default: false },
|
|
66
|
-
// Validate/migrate options
|
|
67
|
-
v22: { type: 'boolean', default: false },
|
|
68
|
-
'dry-run': { type: 'boolean', default: false },
|
|
69
|
-
'no-backup': { type: 'boolean', default: false },
|
|
70
|
-
all: { type: 'boolean', default: false },
|
|
71
|
-
format: { type: 'string', short: 'f' },
|
|
72
|
-
// Search options
|
|
73
|
-
category: { type: 'string', short: 'c' },
|
|
74
|
-
registry: { type: 'string' }, // override registry index URL (or use env COGNITIVE_REGISTRY_URL)
|
|
75
|
-
'registry-timeout-ms': { type: 'string' },
|
|
76
|
-
'registry-max-bytes': { type: 'string' },
|
|
77
|
-
// Registry build/verify options
|
|
78
|
-
'modules-dir': { type: 'string' },
|
|
79
|
-
'v1-registry': { type: 'string' },
|
|
80
|
-
'out-dir': { type: 'string' },
|
|
81
|
-
'registry-out': { type: 'string' },
|
|
82
|
-
namespace: { type: 'string' },
|
|
83
|
-
'runtime-min': { type: 'string' },
|
|
84
|
-
repository: { type: 'string' },
|
|
85
|
-
homepage: { type: 'string' },
|
|
86
|
-
license: { type: 'string' },
|
|
87
|
-
timestamp: { type: 'string' },
|
|
88
|
-
only: { type: 'string', multiple: true },
|
|
89
|
-
index: { type: 'string' },
|
|
90
|
-
'assets-dir': { type: 'string' },
|
|
91
|
-
'tarball-base-url': { type: 'string' },
|
|
92
|
-
remote: { type: 'boolean', default: false }, // registry verify: fetch index + tarballs over network
|
|
93
|
-
'fetch-timeout-ms': { type: 'string' },
|
|
94
|
-
'max-index-bytes': { type: 'string' },
|
|
95
|
-
'max-tarball-bytes': { type: 'string' },
|
|
96
|
-
concurrency: { type: 'string' },
|
|
97
|
-
},
|
|
98
|
-
allowPositionals: true,
|
|
99
|
-
});
|
|
100
38
|
if (values.help) {
|
|
101
39
|
if (command === 'core') {
|
|
102
40
|
console.log(JSON.stringify({
|
|
@@ -140,12 +78,30 @@ async function main() {
|
|
|
140
78
|
validate: values.validate,
|
|
141
79
|
noValidate: values['no-validate'],
|
|
142
80
|
audit: values.audit,
|
|
81
|
+
structured: values.structured,
|
|
143
82
|
});
|
|
144
83
|
}
|
|
145
84
|
catch (e) {
|
|
146
85
|
console.error(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
147
86
|
process.exit(1);
|
|
148
87
|
}
|
|
88
|
+
// Progressive Complexity: `cog core ...` defaults to the `core` profile unless explicitly overridden.
|
|
89
|
+
// This keeps the "5-minute path" minimal by default (no schema enforcement unless requested).
|
|
90
|
+
if (command === 'core' && (values.profile === undefined || values.profile === null || String(values.profile).trim() === '')) {
|
|
91
|
+
try {
|
|
92
|
+
policy = resolveExecutionPolicy({
|
|
93
|
+
profile: 'core',
|
|
94
|
+
validate: values.validate,
|
|
95
|
+
noValidate: values['no-validate'],
|
|
96
|
+
audit: values.audit,
|
|
97
|
+
structured: values.structured,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
149
105
|
const parsePositive = (key, raw) => {
|
|
150
106
|
if (raw === undefined || raw === null || raw === '')
|
|
151
107
|
return undefined;
|
|
@@ -299,6 +255,8 @@ async function main() {
|
|
|
299
255
|
const apiKeyStatus = p.configured ? 'API key set' : 'not configured';
|
|
300
256
|
console.log(` ${status} ${p.name}`);
|
|
301
257
|
console.log(` Model: ${p.model}`);
|
|
258
|
+
console.log(` Structured output: ${p.structuredOutput}`);
|
|
259
|
+
console.log(` Streaming: ${p.streaming ? 'yes' : 'no'}`);
|
|
302
260
|
console.log(` Status: ${apiKeyStatus}`);
|
|
303
261
|
if (p.configured)
|
|
304
262
|
hasConfiguredProvider = true;
|
|
@@ -396,6 +354,11 @@ async function main() {
|
|
|
396
354
|
console.log('For more help: cog --help');
|
|
397
355
|
break;
|
|
398
356
|
}
|
|
357
|
+
case 'providers': {
|
|
358
|
+
const providers = listProviders();
|
|
359
|
+
console.log(JSON.stringify({ providers }, null, values.pretty ? 2 : 0));
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
399
362
|
case 'add': {
|
|
400
363
|
const url = args[1];
|
|
401
364
|
if (!url || url.startsWith('-')) {
|
|
@@ -689,6 +652,43 @@ async function main() {
|
|
|
689
652
|
}
|
|
690
653
|
case 'test': {
|
|
691
654
|
const target = args[1];
|
|
655
|
+
if (values.conformance) {
|
|
656
|
+
const result = await conformance(ctx, {
|
|
657
|
+
specDir: values['spec-dir'],
|
|
658
|
+
suite: values.suite,
|
|
659
|
+
level: values.level ? parseInt(values.level, 10) : undefined,
|
|
660
|
+
verbose: values.verbose,
|
|
661
|
+
json: values.json,
|
|
662
|
+
});
|
|
663
|
+
if (!result.success && !result.data) {
|
|
664
|
+
console.error(`Error: ${result.error ?? 'Unknown error'}`);
|
|
665
|
+
process.exit(1);
|
|
666
|
+
}
|
|
667
|
+
if (values.json || values.pretty) {
|
|
668
|
+
console.log(JSON.stringify(result.data, null, values.pretty ? 2 : 0));
|
|
669
|
+
process.exit(result.success ? 0 : 1);
|
|
670
|
+
}
|
|
671
|
+
const data = result.data;
|
|
672
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
673
|
+
console.log('Conformance Vectors');
|
|
674
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
675
|
+
console.log(`Suite: ${data.suite} Level: ${data.level}`);
|
|
676
|
+
console.log(`Spec: ${data.spec_dir}`);
|
|
677
|
+
console.log(`Total: ${data.total}, Passed: ${data.passed}, Failed: ${data.failed}`);
|
|
678
|
+
if (data.failed > 0) {
|
|
679
|
+
console.log('');
|
|
680
|
+
console.log('Failures:');
|
|
681
|
+
for (const r of data.results) {
|
|
682
|
+
if (r.passed)
|
|
683
|
+
continue;
|
|
684
|
+
const phase = r.phase ? ` (${r.phase})` : '';
|
|
685
|
+
console.log(` ✗ ${r.file}${phase}`);
|
|
686
|
+
if (r.error)
|
|
687
|
+
console.log(` ${r.error}`);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
process.exit(result.success ? 0 : 1);
|
|
691
|
+
}
|
|
692
692
|
if (values.all) {
|
|
693
693
|
// Test all modules
|
|
694
694
|
console.log('→ Running tests for all modules...\n');
|
|
@@ -720,7 +720,8 @@ async function main() {
|
|
|
720
720
|
process.exit(result.success ? 0 : 1);
|
|
721
721
|
}
|
|
722
722
|
if (!target || target.startsWith('-')) {
|
|
723
|
-
console.error('Usage: cog test <module> [--all] [--verbose] [--timeout <ms>]'
|
|
723
|
+
console.error('Usage: cog test <module> [--all] [--verbose] [--timeout <ms>]\n' +
|
|
724
|
+
' cog test --conformance [--suite envelope|runtime|stream|registry|all] [--level 1|2|3] [--spec-dir <path>] [--json]');
|
|
724
725
|
process.exit(1);
|
|
725
726
|
}
|
|
726
727
|
console.log(`→ Running tests for module: ${target}\n`);
|
|
@@ -975,6 +976,7 @@ USAGE:
|
|
|
975
976
|
|
|
976
977
|
COMMANDS:
|
|
977
978
|
core <cmd> Minimal "one-file" workflow (new, schema, run)
|
|
979
|
+
providers List providers (capabilities + configuration)
|
|
978
980
|
run <module> Run a Cognitive Module
|
|
979
981
|
test <module> Run golden tests for a module
|
|
980
982
|
compose <module> Execute a composed module workflow
|
|
@@ -995,8 +997,9 @@ COMMANDS:
|
|
|
995
997
|
doctor Check environment and configuration
|
|
996
998
|
|
|
997
999
|
OPTIONS:
|
|
998
|
-
--profile <name> Progressive complexity profile: core|default
|
|
1000
|
+
--profile <name> Progressive complexity profile: core|standard|certified (aliases: default, strict)
|
|
999
1001
|
--validate <mode> Validation mode: auto|on|off (overrides --no-validate)
|
|
1002
|
+
--structured <mode> Structured output strategy: auto|off|prompt|native
|
|
1000
1003
|
--audit Write an audit record to ~/.cognitive/audit/ (stderr prints path)
|
|
1001
1004
|
-a, --args <str> Arguments to pass to module
|
|
1002
1005
|
-i, --input <json> JSON input for module
|
|
@@ -1020,6 +1023,11 @@ OPTIONS:
|
|
|
1020
1023
|
--dry-run Show what would be done without changes (for migrate)
|
|
1021
1024
|
--no-backup Skip backup before migration (for migrate)
|
|
1022
1025
|
--all Process all modules (for validate/migrate)
|
|
1026
|
+
--conformance Run official spec vectors (for test)
|
|
1027
|
+
--suite <name> Conformance suite: envelope|runtime|stream|registry|all
|
|
1028
|
+
--level <n> Conformance level: 1|2|3
|
|
1029
|
+
--spec-dir <path> Repo root or spec dir (defaults: auto-detect)
|
|
1030
|
+
--json Machine-readable JSON output (for conformance)
|
|
1023
1031
|
-f, --format <fmt> Output format: text or json (for validate)
|
|
1024
1032
|
-c, --category <cat> Filter by category (for search)
|
|
1025
1033
|
--registry <url> Override registry index URL (or set env COGNITIVE_REGISTRY_URL)
|
|
@@ -1062,6 +1070,9 @@ EXAMPLES:
|
|
|
1062
1070
|
cog test code-simplifier # Run golden tests
|
|
1063
1071
|
cog test code-simplifier --verbose # With detailed output
|
|
1064
1072
|
cog test --all # Test all modules
|
|
1073
|
+
cog test --conformance --suite envelope --level 1 # Minimal conformance (envelope only)
|
|
1074
|
+
cog test --conformance --suite all --level 2 # Level 2 contract (envelope+runtime)
|
|
1075
|
+
cog test --conformance --suite all --level 3 # Full conformance (envelope+runtime+stream+registry)
|
|
1065
1076
|
cog migrate code-reviewer --dry-run
|
|
1066
1077
|
cog migrate code-reviewer
|
|
1067
1078
|
cog migrate --all --no-backup
|
package/dist/commands/add.js
CHANGED
|
@@ -367,7 +367,7 @@ export async function addFromRegistry(moduleSpec, ctx, options = {}) {
|
|
|
367
367
|
success: false,
|
|
368
368
|
error: `Certified profile requires registry tarball provenance.\n` +
|
|
369
369
|
`Registry entry for '${moduleName}' resolves to a GitHub source, which is not allowed in --profile certified.\n` +
|
|
370
|
-
`Use a tarball-based registry entry (distribution.tarball + checksum), or
|
|
370
|
+
`Use a tarball-based registry entry (distribution.tarball + checksum), or rerun with --profile standard.`,
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
373
|
const { org, repo, path, ref } = downloadInfo.githubInfo;
|
|
@@ -549,7 +549,7 @@ export async function addFromGitHub(url, ctx, options = {}) {
|
|
|
549
549
|
return {
|
|
550
550
|
success: false,
|
|
551
551
|
error: `Certified profile requires registry tarball provenance; GitHub installs are not allowed.\n` +
|
|
552
|
-
`Use 'cog add <module>' against a tarball-based registry entry, or
|
|
552
|
+
`Use 'cog add <module>' against a tarball-based registry entry, or rerun with --profile standard.`,
|
|
553
553
|
};
|
|
554
554
|
}
|
|
555
555
|
// Determine ref (tag takes priority)
|
package/dist/commands/compose.js
CHANGED
|
@@ -40,7 +40,7 @@ export async function compose(moduleName, ctx, options = {}) {
|
|
|
40
40
|
const errorEnvelope = attachContext(makeErrorEnvelope({
|
|
41
41
|
code: ErrorCodes.INVALID_INPUT,
|
|
42
42
|
message: `Certified profile requires v2.2 modules; got: ${module.formatVersion ?? 'unknown'} (${module.format})`,
|
|
43
|
-
suggestion: "Migrate the module to v2.2, or
|
|
43
|
+
suggestion: "Migrate the module to v2.2, or rerun with `--profile standard`",
|
|
44
44
|
}), { module: moduleName, provider: ctx.provider.name });
|
|
45
45
|
return { success: false, error: errorEnvelope.error.message, data: errorEnvelope };
|
|
46
46
|
}
|
|
@@ -82,29 +82,6 @@ export async function compose(moduleName, ctx, options = {}) {
|
|
|
82
82
|
maxDepth: options.maxDepth,
|
|
83
83
|
timeoutMs: options.timeout,
|
|
84
84
|
policy,
|
|
85
|
-
validateInput: (() => {
|
|
86
|
-
if (options.noValidate)
|
|
87
|
-
return false;
|
|
88
|
-
if (!policy)
|
|
89
|
-
return true;
|
|
90
|
-
if (policy.validate === 'off')
|
|
91
|
-
return false;
|
|
92
|
-
if (policy.validate === 'on')
|
|
93
|
-
return true;
|
|
94
|
-
return policy.profile !== 'core';
|
|
95
|
-
})(),
|
|
96
|
-
validateOutput: (() => {
|
|
97
|
-
if (options.noValidate)
|
|
98
|
-
return false;
|
|
99
|
-
if (!policy)
|
|
100
|
-
return true;
|
|
101
|
-
if (policy.validate === 'off')
|
|
102
|
-
return false;
|
|
103
|
-
if (policy.validate === 'on')
|
|
104
|
-
return true;
|
|
105
|
-
return policy.profile !== 'core';
|
|
106
|
-
})(),
|
|
107
|
-
enableRepair: policy?.enableRepair ?? true,
|
|
108
85
|
});
|
|
109
86
|
if (options.verbose) {
|
|
110
87
|
console.error('--- Composition Trace ---');
|