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.
Files changed (94) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +21 -0
  3. package/README.md +35 -29
  4. package/dist/cli.js +572 -28
  5. package/dist/commands/add.d.ts +33 -14
  6. package/dist/commands/add.js +222 -13
  7. package/dist/commands/compose.d.ts +31 -0
  8. package/dist/commands/compose.js +185 -0
  9. package/dist/commands/index.d.ts +5 -0
  10. package/dist/commands/index.js +5 -0
  11. package/dist/commands/init.js +23 -1
  12. package/dist/commands/migrate.d.ts +30 -0
  13. package/dist/commands/migrate.js +650 -0
  14. package/dist/commands/pipe.d.ts +1 -0
  15. package/dist/commands/pipe.js +31 -11
  16. package/dist/commands/remove.js +33 -2
  17. package/dist/commands/run.d.ts +1 -0
  18. package/dist/commands/run.js +37 -27
  19. package/dist/commands/search.d.ts +28 -0
  20. package/dist/commands/search.js +143 -0
  21. package/dist/commands/test.d.ts +65 -0
  22. package/dist/commands/test.js +454 -0
  23. package/dist/commands/update.d.ts +1 -0
  24. package/dist/commands/update.js +106 -14
  25. package/dist/commands/validate.d.ts +36 -0
  26. package/dist/commands/validate.js +97 -0
  27. package/dist/errors/index.d.ts +218 -0
  28. package/dist/errors/index.js +412 -0
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +5 -1
  31. package/dist/mcp/server.js +84 -79
  32. package/dist/modules/composition.d.ts +251 -0
  33. package/dist/modules/composition.js +1330 -0
  34. package/dist/modules/index.d.ts +2 -0
  35. package/dist/modules/index.js +2 -0
  36. package/dist/modules/loader.d.ts +22 -2
  37. package/dist/modules/loader.js +171 -6
  38. package/dist/modules/runner.d.ts +422 -1
  39. package/dist/modules/runner.js +1472 -71
  40. package/dist/modules/subagent.d.ts +6 -1
  41. package/dist/modules/subagent.js +20 -13
  42. package/dist/modules/validator.d.ts +28 -0
  43. package/dist/modules/validator.js +637 -0
  44. package/dist/providers/anthropic.d.ts +15 -0
  45. package/dist/providers/anthropic.js +147 -5
  46. package/dist/providers/base.d.ts +11 -0
  47. package/dist/providers/base.js +18 -0
  48. package/dist/providers/gemini.d.ts +15 -0
  49. package/dist/providers/gemini.js +122 -5
  50. package/dist/providers/ollama.d.ts +15 -0
  51. package/dist/providers/ollama.js +111 -3
  52. package/dist/providers/openai.d.ts +11 -0
  53. package/dist/providers/openai.js +133 -0
  54. package/dist/registry/client.d.ts +204 -0
  55. package/dist/registry/client.js +356 -0
  56. package/dist/registry/index.d.ts +4 -0
  57. package/dist/registry/index.js +4 -0
  58. package/dist/server/http.js +173 -42
  59. package/dist/types.d.ts +123 -8
  60. package/dist/types.js +4 -1
  61. package/dist/version.d.ts +1 -0
  62. package/dist/version.js +4 -0
  63. package/package.json +32 -7
  64. package/src/cli.ts +0 -410
  65. package/src/commands/add.ts +0 -315
  66. package/src/commands/index.ts +0 -12
  67. package/src/commands/init.ts +0 -94
  68. package/src/commands/list.ts +0 -33
  69. package/src/commands/pipe.ts +0 -76
  70. package/src/commands/remove.ts +0 -57
  71. package/src/commands/run.ts +0 -80
  72. package/src/commands/update.ts +0 -130
  73. package/src/commands/versions.ts +0 -79
  74. package/src/index.ts +0 -55
  75. package/src/mcp/index.ts +0 -5
  76. package/src/mcp/server.ts +0 -403
  77. package/src/modules/index.ts +0 -7
  78. package/src/modules/loader.ts +0 -318
  79. package/src/modules/runner.ts +0 -495
  80. package/src/modules/subagent.ts +0 -275
  81. package/src/providers/anthropic.ts +0 -89
  82. package/src/providers/base.ts +0 -29
  83. package/src/providers/deepseek.ts +0 -83
  84. package/src/providers/gemini.ts +0 -117
  85. package/src/providers/index.ts +0 -78
  86. package/src/providers/minimax.ts +0 -81
  87. package/src/providers/moonshot.ts +0 -82
  88. package/src/providers/ollama.ts +0 -83
  89. package/src/providers/openai.ts +0 -84
  90. package/src/providers/qwen.ts +0 -82
  91. package/src/server/http.ts +0 -316
  92. package/src/server/index.ts +0 -6
  93. package/src/types.ts +0 -495
  94. 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
  [![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
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` | `kimi` |
61
- | Qwen | `DASHSCOPE_API_KEY` | `tongyi` |
62
- | Ollama | `OLLAMA_HOST` | `local` |
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