cognitive-modules-cli 2.2.0 → 2.2.5
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 +11 -0
- package/LICENSE +21 -0
- package/README.md +35 -29
- package/dist/cli.js +572 -28
- package/dist/commands/add.d.ts +33 -14
- package/dist/commands/add.js +222 -13
- package/dist/commands/compose.d.ts +31 -0
- package/dist/commands/compose.js +185 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/init.js +23 -1
- package/dist/commands/migrate.d.ts +30 -0
- package/dist/commands/migrate.js +650 -0
- package/dist/commands/pipe.d.ts +1 -0
- package/dist/commands/pipe.js +31 -11
- package/dist/commands/remove.js +33 -2
- package/dist/commands/run.d.ts +1 -0
- package/dist/commands/run.js +37 -27
- package/dist/commands/search.d.ts +28 -0
- package/dist/commands/search.js +143 -0
- package/dist/commands/test.d.ts +65 -0
- package/dist/commands/test.js +454 -0
- package/dist/commands/update.d.ts +1 -0
- package/dist/commands/update.js +106 -14
- package/dist/commands/validate.d.ts +36 -0
- package/dist/commands/validate.js +97 -0
- package/dist/errors/index.d.ts +218 -0
- package/dist/errors/index.js +412 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -1
- package/dist/mcp/server.js +84 -79
- package/dist/modules/composition.d.ts +251 -0
- package/dist/modules/composition.js +1330 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +2 -0
- package/dist/modules/loader.d.ts +22 -2
- package/dist/modules/loader.js +171 -6
- package/dist/modules/runner.d.ts +422 -1
- package/dist/modules/runner.js +1472 -71
- package/dist/modules/subagent.d.ts +6 -1
- package/dist/modules/subagent.js +20 -13
- package/dist/modules/validator.d.ts +28 -0
- package/dist/modules/validator.js +637 -0
- package/dist/providers/anthropic.d.ts +15 -0
- package/dist/providers/anthropic.js +147 -5
- package/dist/providers/base.d.ts +11 -0
- package/dist/providers/base.js +18 -0
- package/dist/providers/gemini.d.ts +15 -0
- package/dist/providers/gemini.js +122 -5
- package/dist/providers/ollama.d.ts +15 -0
- package/dist/providers/ollama.js +111 -3
- package/dist/providers/openai.d.ts +11 -0
- package/dist/providers/openai.js +133 -0
- package/dist/registry/client.d.ts +204 -0
- package/dist/registry/client.js +356 -0
- package/dist/registry/index.d.ts +4 -0
- package/dist/registry/index.js +4 -0
- package/dist/server/http.js +173 -42
- package/dist/types.d.ts +123 -8
- package/dist/types.js +4 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/package.json +32 -7
- package/src/cli.ts +0 -410
- package/src/commands/add.ts +0 -315
- package/src/commands/index.ts +0 -12
- package/src/commands/init.ts +0 -94
- package/src/commands/list.ts +0 -33
- package/src/commands/pipe.ts +0 -76
- package/src/commands/remove.ts +0 -57
- package/src/commands/run.ts +0 -80
- package/src/commands/update.ts +0 -130
- package/src/commands/versions.ts +0 -79
- package/src/index.ts +0 -55
- package/src/mcp/index.ts +0 -5
- package/src/mcp/server.ts +0 -403
- package/src/modules/index.ts +0 -7
- package/src/modules/loader.ts +0 -318
- package/src/modules/runner.ts +0 -495
- package/src/modules/subagent.ts +0 -275
- package/src/providers/anthropic.ts +0 -89
- package/src/providers/base.ts +0 -29
- package/src/providers/deepseek.ts +0 -83
- package/src/providers/gemini.ts +0 -117
- package/src/providers/index.ts +0 -78
- package/src/providers/minimax.ts +0 -81
- package/src/providers/moonshot.ts +0 -82
- package/src/providers/ollama.ts +0 -83
- package/src/providers/openai.ts +0 -84
- package/src/providers/qwen.ts +0 -82
- package/src/server/http.ts +0 -316
- package/src/server/index.ts +0 -6
- package/src/types.ts +0 -495
- package/tsconfig.json +0 -17
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are documented in this file.
|
|
4
|
+
|
|
5
|
+
## 2.2.5 - 2026-02-06
|
|
6
|
+
|
|
7
|
+
- Standardized v2.2 runtime behavior and cross-surface error envelope consistency (CLI/HTTP/MCP).
|
|
8
|
+
- Clarified `compose` output contract: default/pretty output returns full v2.2 envelope, while `compose --trace` returns a debug wrapper object (`result/moduleResults/trace/totalTimeMs`) for diagnostics.
|
|
9
|
+
- Hardened module add/update/remove and registry path handling against traversal risks.
|
|
10
|
+
- Improved composition/subagent/streaming reliability and fallback handling.
|
|
11
|
+
- Added stricter package publish checks and metadata alignment for npm release.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ziel-io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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,提供 `cog` 命令。
|
|
6
6
|
|
|
7
7
|
> 这是 [cognitive-modules](../../README.md) monorepo 的一部分。
|
|
8
8
|
|
|
@@ -10,21 +10,22 @@ Node.js/TypeScript 版本的 Cognitive Modules CLI。
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
# 全局安装(推荐)
|
|
13
|
-
npm install -g cogn
|
|
13
|
+
npm install -g cogn@2.2.5
|
|
14
|
+
# 或使用完整包名(同样提供 `cog` 命令)
|
|
15
|
+
# npm install -g cognitive-modules-cli@2.2.5
|
|
14
16
|
|
|
15
17
|
# 或使用 npx 零安装
|
|
16
|
-
npx cogn --help
|
|
18
|
+
npx cogn@2.2.5 --help
|
|
17
19
|
```
|
|
18
20
|
|
|
19
21
|
## 快速开始
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
# 配置 LLM
|
|
23
|
-
export LLM_PROVIDER=openai
|
|
24
25
|
export OPENAI_API_KEY=sk-xxx
|
|
25
26
|
|
|
26
27
|
# 运行模块
|
|
27
|
-
cog run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')"
|
|
28
|
+
cog run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
|
|
28
29
|
|
|
29
30
|
# 列出模块
|
|
30
31
|
cog list
|
|
@@ -33,33 +34,18 @@ cog list
|
|
|
33
34
|
echo "review this code" | cog pipe --module code-reviewer
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
## 与 Python 版的功能对比
|
|
37
|
-
|
|
38
|
-
| 功能 | Python (`cogn`) | Node.js (`cog`) |
|
|
39
|
-
|------|----------------|-----------------|
|
|
40
|
-
| 包名 | `cognitive-modules` | `cogn` / `cognitive-modules-cli` |
|
|
41
|
-
| 安装 | `pip install` | `npm install -g` |
|
|
42
|
-
| 子代理 | ✅ `@call:module` | ✅ `@call:module` |
|
|
43
|
-
| MCP Server | ✅ | ✅ |
|
|
44
|
-
| HTTP Server | ✅ | ✅ |
|
|
45
|
-
| v2.2 Envelope | ✅ | ✅ |
|
|
46
|
-
|
|
47
|
-
两个版本功能完全一致,共享相同的模块格式和 v2.2 规范。
|
|
48
|
-
|
|
49
|
-
**推荐使用 Node.js 版**:零安装快速体验 `npx cogn run ...`
|
|
50
|
-
|
|
51
37
|
## 支持的 Provider
|
|
52
38
|
|
|
53
|
-
| Provider | 环境变量 |
|
|
39
|
+
| Provider | 环境变量 | 说明 |
|
|
54
40
|
|----------|----------|------|
|
|
55
|
-
| OpenAI | `OPENAI_API_KEY` |
|
|
56
|
-
| Anthropic | `ANTHROPIC_API_KEY` |
|
|
57
|
-
| Gemini | `GEMINI_API_KEY` |
|
|
58
|
-
| DeepSeek | `DEEPSEEK_API_KEY` |
|
|
59
|
-
| MiniMax | `MINIMAX_API_KEY` |
|
|
60
|
-
| Moonshot | `MOONSHOT_API_KEY` |
|
|
61
|
-
| Qwen | `DASHSCOPE_API_KEY`
|
|
62
|
-
| Ollama | `OLLAMA_HOST` |
|
|
41
|
+
| OpenAI | `OPENAI_API_KEY` | OpenAI API |
|
|
42
|
+
| Anthropic | `ANTHROPIC_API_KEY` | Claude |
|
|
43
|
+
| Gemini | `GEMINI_API_KEY` | Google Gemini |
|
|
44
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | DeepSeek |
|
|
45
|
+
| MiniMax | `MINIMAX_API_KEY` | MiniMax |
|
|
46
|
+
| Moonshot | `MOONSHOT_API_KEY` | Kimi |
|
|
47
|
+
| Qwen | `DASHSCOPE_API_KEY` / `QWEN_API_KEY` | 通义千问 |
|
|
48
|
+
| Ollama | `OLLAMA_HOST` | 本地模型 |
|
|
63
49
|
|
|
64
50
|
## 命令
|
|
65
51
|
|
|
@@ -74,9 +60,22 @@ cog versions <url> # 查看可用版本
|
|
|
74
60
|
cog init <name> # 创建新模块
|
|
75
61
|
cog pipe --module <name> # 管道模式
|
|
76
62
|
|
|
63
|
+
# 组合执行
|
|
64
|
+
cog compose <module> --args "..."
|
|
65
|
+
cog compose-info <module>
|
|
66
|
+
|
|
67
|
+
# 校验与迁移
|
|
68
|
+
cog validate <module> --v22
|
|
69
|
+
cog validate --all
|
|
70
|
+
cog migrate <module> --dry-run
|
|
71
|
+
cog migrate --all --no-backup
|
|
72
|
+
|
|
77
73
|
# 服务器
|
|
78
74
|
cog serve --port 8000 # 启动 HTTP API 服务
|
|
79
75
|
cog mcp # 启动 MCP 服务(Claude Code / Cursor)
|
|
76
|
+
|
|
77
|
+
# 环境检查
|
|
78
|
+
cog doctor
|
|
80
79
|
```
|
|
81
80
|
|
|
82
81
|
## 开发
|
|
@@ -92,6 +91,13 @@ npm run build
|
|
|
92
91
|
npm run dev -- run code-reviewer --args "..."
|
|
93
92
|
```
|
|
94
93
|
|
|
94
|
+
## 发布前检查
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 完整发布检查(构建 + 测试 + npm 打包清单)
|
|
98
|
+
npm run release:check
|
|
99
|
+
```
|
|
100
|
+
|
|
95
101
|
## License
|
|
96
102
|
|
|
97
103
|
MIT
|