cognitive-modules 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

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.
cognitive/registry.py CHANGED
@@ -31,7 +31,7 @@ SEARCH_PATHS = [
31
31
  USER_MODULES_DIR = Path.home() / ".cognitive" / "modules"
32
32
 
33
33
  # Default registry URL
34
- DEFAULT_REGISTRY_URL = "https://raw.githubusercontent.com/leizii/cognitive-modules/main/cognitive-registry.json"
34
+ DEFAULT_REGISTRY_URL = "https://raw.githubusercontent.com/ziel-io/cognitive-modules/main/cognitive-registry.json"
35
35
 
36
36
  # Local registry cache
37
37
  REGISTRY_CACHE = Path.home() / ".cognitive" / "registry-cache.json"
@@ -0,0 +1,289 @@
1
+ Metadata-Version: 2.4
2
+ Name: cognitive-modules
3
+ Version: 0.1.1
4
+ Summary: Structured LLM task runner with schema validation, confidence scoring, and subagent orchestration
5
+ Author: ziel-io
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ziel-io/cognitive-modules
8
+ Project-URL: Documentation, https://github.com/ziel-io/cognitive-modules#readme
9
+ Project-URL: Repository, https://github.com/ziel-io/cognitive-modules
10
+ Project-URL: Issues, https://github.com/ziel-io/cognitive-modules/issues
11
+ Keywords: llm,cognitive,modules,ai,cli,schema,validation,prompt,agent,subagent
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: jsonschema>=4.17.0
27
+ Requires-Dist: pyyaml>=6.0
28
+ Requires-Dist: typer>=0.9.0
29
+ Requires-Dist: rich>=13.0.0
30
+ Provides-Extra: openai
31
+ Requires-Dist: openai>=1.0.0; extra == "openai"
32
+ Provides-Extra: anthropic
33
+ Requires-Dist: anthropic>=0.18.0; extra == "anthropic"
34
+ Provides-Extra: ollama
35
+ Requires-Dist: requests>=2.28.0; extra == "ollama"
36
+ Provides-Extra: minimax
37
+ Requires-Dist: openai>=1.0.0; extra == "minimax"
38
+ Provides-Extra: all
39
+ Requires-Dist: openai>=1.0.0; extra == "all"
40
+ Requires-Dist: anthropic>=0.18.0; extra == "all"
41
+ Requires-Dist: requests>=2.28.0; extra == "all"
42
+ Provides-Extra: dev
43
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
44
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
45
+ Requires-Dist: build>=1.0.0; extra == "dev"
46
+ Requires-Dist: twine>=4.0.0; extra == "dev"
47
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
48
+ Provides-Extra: docs
49
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
50
+ Requires-Dist: pymdown-extensions>=10.0.0; extra == "docs"
51
+ Dynamic: license-file
52
+
53
+ # Cognitive Modules
54
+
55
+ [![CI](https://github.com/ziel-io/cognitive-modules/actions/workflows/ci.yml/badge.svg)](https://github.com/ziel-io/cognitive-modules/actions/workflows/ci.yml)
56
+ [![PyPI version](https://badge.fury.io/py/cognitive-modules.svg)](https://pypi.org/project/cognitive-modules/)
57
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
58
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
59
+
60
+ > 可验证的结构化 AI 任务规范
61
+
62
+ Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、可验证、可审计**的生成任务设计。
63
+
64
+ ## 特性
65
+
66
+ - **强类型契约** - JSON Schema 双向验证输入输出
67
+ - **可解释输出** - 强制输出 `confidence` + `rationale`
68
+ - **子代理编排** - `@call:module` 支持模块间调用
69
+ - **参数传递** - `$ARGUMENTS` 运行时替换
70
+ - **多 LLM 支持** - OpenAI / Anthropic / MiniMax / Ollama
71
+ - **公共注册表** - `cog install registry:module-name`
72
+
73
+ ## 安装
74
+
75
+ ```bash
76
+ # 基础安装
77
+ pip install cognitive-modules
78
+
79
+ # 带 LLM 支持
80
+ pip install cognitive-modules[openai] # OpenAI
81
+ pip install cognitive-modules[anthropic] # Claude
82
+ pip install cognitive-modules[all] # 全部
83
+ ```
84
+
85
+ ## 快速开始
86
+
87
+ ```bash
88
+ # 配置 LLM
89
+ export LLM_PROVIDER=openai
90
+ export OPENAI_API_KEY=sk-xxx
91
+
92
+ # 或使用 MiniMax
93
+ export LLM_PROVIDER=minimax
94
+ export MINIMAX_API_KEY=sk-xxx
95
+
96
+ # 运行代码审查
97
+ cog run code-reviewer --args "def login(u,p): return db.query(f'SELECT * FROM users WHERE name={u}')" --pretty
98
+
99
+ # 运行任务排序
100
+ cog run task-prioritizer --args "修复bug(紧急), 写文档, 优化性能" --pretty
101
+
102
+ # 运行 API 设计
103
+ cog run api-designer --args "用户系统 CRUD API" --pretty
104
+ ```
105
+
106
+ ## 与 Skills 对比
107
+
108
+ | | Skills | Cognitive Modules |
109
+ |---|--------|------------------|
110
+ | 定位 | 轻量指令扩展 | 可验证的结构化任务 |
111
+ | 输入校验 | ❌ | ✅ JSON Schema |
112
+ | 输出校验 | ❌ | ✅ JSON Schema |
113
+ | 置信度 | ❌ | ✅ 必须 0-1 |
114
+ | 推理过程 | ❌ | ✅ 必须 rationale |
115
+ | 参数传递 | ✅ $ARGUMENTS | ✅ $ARGUMENTS |
116
+ | 子代理 | ✅ context: fork | ✅ @call + context |
117
+ | 验证工具 | ❌ | ✅ cog validate |
118
+ | 注册表 | ❌ | ✅ cog install |
119
+
120
+ ## CLI 命令
121
+
122
+ ```bash
123
+ # 模块管理
124
+ cog list # 列出已安装模块
125
+ cog info <module> # 查看模块详情
126
+ cog validate <module> # 验证模块结构
127
+
128
+ # 运行模块
129
+ cog run <module> input.json -o output.json --pretty
130
+ cog run <module> --args "需求描述" --pretty
131
+ cog run <module> --args "需求" --subagent # 启用子代理
132
+
133
+ # 创建模块
134
+ cog init <name> -d "描述"
135
+
136
+ # 安装/卸载
137
+ cog install github:user/repo/path
138
+ cog install registry:module-name
139
+ cog uninstall <module>
140
+
141
+ # 注册表
142
+ cog registry # 查看公共模块
143
+ cog search <query> # 搜索模块
144
+
145
+ # 环境检查
146
+ cog doctor
147
+ ```
148
+
149
+ ## 内置模块
150
+
151
+ | 模块 | 功能 | 示例 |
152
+ |------|------|------|
153
+ | `code-reviewer` | 代码审查 | `cog run code-reviewer --args "你的代码"` |
154
+ | `task-prioritizer` | 任务优先级排序 | `cog run task-prioritizer --args "任务1,任务2"` |
155
+ | `api-designer` | REST API 设计 | `cog run api-designer --args "订单系统"` |
156
+ | `ui-spec-generator` | UI 规范生成 | `cog run ui-spec-generator --args "电商首页"` |
157
+ | `product-analyzer` | 产品分析(子代理示例) | `cog run product-analyzer --args "健康产品" -s` |
158
+
159
+ ## 模块格式
160
+
161
+ ### 新格式(推荐)
162
+
163
+ ```
164
+ my-module/
165
+ ├── MODULE.md # 元数据 + 指令
166
+ ├── schema.json # 输入输出 Schema
167
+ └── examples/
168
+ ├── input.json
169
+ └── output.json
170
+ ```
171
+
172
+ ### MODULE.md
173
+
174
+ ```yaml
175
+ ---
176
+ name: my-module
177
+ version: 1.0.0
178
+ responsibility: 一句话描述
179
+
180
+ excludes:
181
+ - 不做的事情
182
+
183
+ constraints:
184
+ no_network: true
185
+ no_inventing_data: true
186
+ require_confidence: true
187
+ require_rationale: true
188
+
189
+ context: fork # 可选:隔离执行
190
+ ---
191
+
192
+ # 指令
193
+
194
+ 根据用户需求 $ARGUMENTS 执行任务。
195
+
196
+ 可以调用其他模块:
197
+ @call:other-module($ARGUMENTS)
198
+ ```
199
+
200
+ ## 在 AI 工具中使用
201
+
202
+ ### Cursor / Codex CLI
203
+
204
+ 在项目根目录创建 `AGENTS.md`:
205
+
206
+ ```markdown
207
+ ## 代码审查
208
+
209
+ 当需要审查代码时:
210
+ 1. 读取 `~/.cognitive/modules/code-reviewer/MODULE.md`
211
+ 2. 按 schema.json 格式输出
212
+ 3. 包含 issues、summary、rationale、confidence
213
+ ```
214
+
215
+ ### 直接对话
216
+
217
+ ```
218
+ 读取 ~/.cognitive/modules/code-reviewer/MODULE.md,
219
+ 审查这段代码:def login(u,p): ...
220
+ ```
221
+
222
+ ## 配置 LLM
223
+
224
+ ```bash
225
+ # OpenAI
226
+ export LLM_PROVIDER=openai
227
+ export OPENAI_API_KEY=sk-xxx
228
+
229
+ # Anthropic Claude
230
+ export LLM_PROVIDER=anthropic
231
+ export ANTHROPIC_API_KEY=sk-ant-xxx
232
+
233
+ # MiniMax
234
+ export LLM_PROVIDER=minimax
235
+ export MINIMAX_API_KEY=sk-xxx
236
+
237
+ # Ollama(本地)
238
+ export LLM_PROVIDER=ollama
239
+
240
+ # 检查配置
241
+ cog doctor
242
+ ```
243
+
244
+ ## 开发
245
+
246
+ ```bash
247
+ # 克隆
248
+ git clone https://github.com/ziel-io/cognitive-modules.git
249
+ cd cognitive-modules
250
+
251
+ # 安装开发依赖
252
+ pip install -e ".[dev]"
253
+
254
+ # 运行测试
255
+ pytest tests/ -v
256
+
257
+ # 创建新模块
258
+ cog init my-module -d "模块描述"
259
+ cog validate my-module
260
+ ```
261
+
262
+ ## 项目结构
263
+
264
+ ```
265
+ cognitive-modules/
266
+ ├── src/cognitive/ # CLI 源码
267
+ │ ├── cli.py # 命令入口
268
+ │ ├── loader.py # 模块加载
269
+ │ ├── runner.py # 模块执行
270
+ │ ├── subagent.py # 子代理编排
271
+ │ ├── validator.py # 模块验证
272
+ │ ├── registry.py # 模块安装
273
+ │ ├── templates.py # 模块模板
274
+ │ └── providers/ # LLM 后端
275
+ ├── cognitive/modules/ # 内置模块
276
+ ├── tests/ # 单元测试
277
+ ├── SPEC.md # 规范文档
278
+ ├── INTEGRATION.md # 集成指南
279
+ └── cognitive-registry.json # 公共注册表
280
+ ```
281
+
282
+ ## 文档
283
+
284
+ - [SPEC.md](SPEC.md) - 完整规范(含上下文哲学)
285
+ - [INTEGRATION.md](INTEGRATION.md) - Agent 工具集成指南
286
+
287
+ ## License
288
+
289
+ MIT
@@ -1,15 +1,15 @@
1
1
  cognitive/__init__.py,sha256=uSX5NuOWyW0qtq1bnxbzabZ0OQakAtsjF0MWbjQBvwE,401
2
2
  cognitive/cli.py,sha256=q0vHCHFmig9gQ85KRyIrX6vrJZFm5nXF_bW5qQRGEPU,14608
3
3
  cognitive/loader.py,sha256=E_lSuy2ERBWfziOHr3f13nLq-wEYvBqIKrGlPk4PQyA,4031
4
- cognitive/registry.py,sha256=Adb9246LH5mj6aObpZs-QkqdB3iC7f9-3C0kItgfvrI,8850
4
+ cognitive/registry.py,sha256=aBkkpg5PtL_tKDIOXpv6vblB7x_Ax0eVaWgejuQTfCE,8851
5
5
  cognitive/runner.py,sha256=9uxBAGd3gtXnwUm5x2CjhXi_S1gd2nfjRfM3Q_1f30Q,4362
6
6
  cognitive/subagent.py,sha256=fb7LWwNF6YcJtC_T1dK0EvzqWMBnav-kiCIpvVohEBw,8142
7
7
  cognitive/templates.py,sha256=fEd1Tj5A12PUE256dC7-cnsulWzm6MTrcQ0yLPWrtx0,4692
8
8
  cognitive/validator.py,sha256=1v1HUHYOlAc2sYCkIq_gnUMMnca0fdtQwr7UMBFpp04,12200
9
9
  cognitive/providers/__init__.py,sha256=hqhVA1IEXpVtyCAteXhO5yD8a8ikQpVIPEKJVHLtRFY,7492
10
- cognitive_modules-0.1.0.dist-info/licenses/LICENSE,sha256=f7MIeafHCzp_CW2Oq1aAjmZjFUa3hBILmBEMl7AsK7k,1063
11
- cognitive_modules-0.1.0.dist-info/METADATA,sha256=wS_z7RLTFaawk0XDoqiRNoibRrfM6UH9hxRliNcUm28,7530
12
- cognitive_modules-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
- cognitive_modules-0.1.0.dist-info/entry_points.txt,sha256=PKHlfrFmve5K2349ryipySKbOOsKxo_vIq1NNT-iBV0,42
14
- cognitive_modules-0.1.0.dist-info/top_level.txt,sha256=kGIfDucCKylo8cRBtxER_v3DHIea-Sol9x9YSJo1u3Y,10
15
- cognitive_modules-0.1.0.dist-info/RECORD,,
10
+ cognitive_modules-0.1.1.dist-info/licenses/LICENSE,sha256=NXFYUy2hPJdh3NHRxMChTnMiQD9k8zFxkmR7gWefexc,1064
11
+ cognitive_modules-0.1.1.dist-info/METADATA,sha256=oonLUUD0fO3t7bo8DVZKlqC1vM5ZyHFUw7KXP46SLdI,8242
12
+ cognitive_modules-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
+ cognitive_modules-0.1.1.dist-info/entry_points.txt,sha256=PKHlfrFmve5K2349ryipySKbOOsKxo_vIq1NNT-iBV0,42
14
+ cognitive_modules-0.1.1.dist-info/top_level.txt,sha256=kGIfDucCKylo8cRBtxER_v3DHIea-Sol9x9YSJo1u3Y,10
15
+ cognitive_modules-0.1.1.dist-info/RECORD,,
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 leizii
3
+ Copyright (c) 2026 ziel-io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,295 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cognitive-modules
3
- Version: 0.1.0
4
- Summary: Structured LLM task runner with schema validation, confidence scoring, and subagent orchestration
5
- Author: leizii
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/leizii/cognitive-modules
8
- Project-URL: Documentation, https://github.com/leizii/cognitive-modules#readme
9
- Project-URL: Repository, https://github.com/leizii/cognitive-modules
10
- Project-URL: Issues, https://github.com/leizii/cognitive-modules/issues
11
- Keywords: llm,cognitive,modules,ai,cli,schema,validation,prompt,agent,subagent
12
- Classifier: Development Status :: 4 - Beta
13
- Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.9
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
- Requires-Python: >=3.9
24
- Description-Content-Type: text/markdown
25
- License-File: LICENSE
26
- Requires-Dist: jsonschema>=4.17.0
27
- Requires-Dist: pyyaml>=6.0
28
- Requires-Dist: typer>=0.9.0
29
- Requires-Dist: rich>=13.0.0
30
- Provides-Extra: openai
31
- Requires-Dist: openai>=1.0.0; extra == "openai"
32
- Provides-Extra: anthropic
33
- Requires-Dist: anthropic>=0.18.0; extra == "anthropic"
34
- Provides-Extra: ollama
35
- Requires-Dist: requests>=2.28.0; extra == "ollama"
36
- Provides-Extra: minimax
37
- Requires-Dist: openai>=1.0.0; extra == "minimax"
38
- Provides-Extra: all
39
- Requires-Dist: openai>=1.0.0; extra == "all"
40
- Requires-Dist: anthropic>=0.18.0; extra == "all"
41
- Requires-Dist: requests>=2.28.0; extra == "all"
42
- Provides-Extra: dev
43
- Requires-Dist: pytest>=7.0.0; extra == "dev"
44
- Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
45
- Requires-Dist: build>=1.0.0; extra == "dev"
46
- Requires-Dist: twine>=4.0.0; extra == "dev"
47
- Dynamic: license-file
48
-
49
- # Cognitive Modules
50
-
51
- > 可验证的结构化 AI 任务规范
52
-
53
- Cognitive Modules 是一种 AI 任务定义规范,专为需要**强约束、可验证、可审计**的生成任务设计。
54
-
55
- ## 与 Skills 的区别
56
-
57
- | | Skills | Cognitive Modules |
58
- |---|--------|------------------|
59
- | 定位 | 轻量指令扩展 | 可验证的结构化任务 |
60
- | 输入校验 | 无 | JSON Schema |
61
- | 输出校验 | 无 | JSON Schema |
62
- | 置信度 | 无 | 必须 0-1 |
63
- | 推理过程 | 无 | 必须 rationale |
64
- | 适用场景 | 快捷命令 | 规范生成、设计文档 |
65
-
66
- ## 快速开始
67
-
68
- ```bash
69
- # 克隆
70
- git clone https://github.com/leizii/cognitive-modules.git
71
- cd cognitive-modules
72
-
73
- # 安装依赖
74
- pip install typer rich jsonschema pyyaml
75
-
76
- # 运行
77
- ./cog --help
78
- ```
79
-
80
- ## CLI 命令
81
-
82
- ```bash
83
- # 模块管理
84
- cog list # 列出已安装模块
85
- cog info <module> # 查看模块详情
86
- cog validate <module> # 验证模块结构
87
-
88
- # 创建模块
89
- cog init <name> -d "描述" # 从模板创建新模块
90
-
91
- # 运行模块
92
- cog run <module> input.json -o output.json --pretty
93
-
94
- # 直接传参数(无需 JSON 文件)
95
- cog run <module> --args "你的需求描述" -o output.json
96
-
97
- # 启用子代理模式(支持 @call 调用其他模块)
98
- cog run <module> --args "需求" --subagent
99
-
100
- # 安装/卸载
101
- cog install <source> # 从 git/本地/注册表安装
102
- cog uninstall <module> # 卸载模块
103
-
104
- # 注册表
105
- cog registry # 查看公共模块
106
- cog search <query> # 搜索模块
107
-
108
- # 环境检查
109
- cog doctor # 检查 LLM 配置
110
- ```
111
-
112
- ## 安装来源
113
-
114
- ```bash
115
- # 从本地安装
116
- cog install ./path/to/module
117
-
118
- # 从 GitHub 安装
119
- cog install github:leizii/cognitive-modules/cognitive/modules/ui-spec-generator
120
-
121
- # 从注册表安装
122
- cog install registry:ui-spec-generator
123
- ```
124
-
125
- ## 模块格式
126
-
127
- ### 新格式(推荐,2 文件)
128
-
129
- ```
130
- my-module/
131
- ├── MODULE.md # 元数据 + 指令
132
- ├── schema.json # 输入输出 Schema
133
- └── examples/ # 可选
134
- ├── input.json
135
- └── output.json
136
- ```
137
-
138
- ### 旧格式(兼容,6 文件)
139
-
140
- ```
141
- my-module/
142
- ├── module.md
143
- ├── input.schema.json
144
- ├── output.schema.json
145
- ├── constraints.yaml
146
- ├── prompt.txt
147
- └── examples/
148
- ```
149
-
150
- ## MODULE.md 格式
151
-
152
- ```yaml
153
- ---
154
- name: my-module
155
- version: 1.0.0
156
- responsibility: 一句话描述
157
-
158
- excludes:
159
- - 不做的事情
160
-
161
- constraints:
162
- no_network: true
163
- no_inventing_data: true
164
- require_confidence: true
165
- require_rationale: true
166
- ---
167
-
168
- # 指令内容
169
-
170
- (这里写 prompt)
171
- ```
172
-
173
- ## 在 Codex / Cursor 中使用
174
-
175
- ### 方式 1:直接对话(零配置)
176
-
177
- ```
178
- 读取 ~/.cognitive/modules/ui-spec-generator/MODULE.md,
179
- 为电商首页生成 UI 规范,保存到 ui-spec.json
180
- ```
181
-
182
- ### 方式 2:AGENTS.md(项目约定)
183
-
184
- 在项目根目录创建 `AGENTS.md`:
185
-
186
- ```markdown
187
- ## UI 规范生成
188
-
189
- 当需要生成 UI 规范时:
190
- 1. 读取 `~/.cognitive/modules/ui-spec-generator/MODULE.md`
191
- 2. 按 schema.json 格式输出
192
- 3. 保存到 ui-spec.json
193
- ```
194
-
195
- ### 方式 3:包装成 Skill
196
-
197
- ```yaml
198
- # ~/.claude/skills/ui-spec/SKILL.md
199
- ---
200
- name: ui-spec
201
- description: 生成 UI 规范
202
- ---
203
- 执行 ~/.cognitive/modules/ui-spec-generator/MODULE.md
204
- ```
205
-
206
- ## 配置 LLM(仅 CLI 需要)
207
-
208
- ```bash
209
- # OpenAI
210
- export LLM_PROVIDER=openai
211
- export OPENAI_API_KEY=sk-xxx
212
-
213
- # Anthropic Claude
214
- export LLM_PROVIDER=anthropic
215
- export ANTHROPIC_API_KEY=sk-ant-xxx
216
-
217
- # Ollama(本地免费)
218
- export LLM_PROVIDER=ollama
219
-
220
- # 不配置则使用 stub(返回示例输出)
221
- ```
222
-
223
- ## 模块搜索路径
224
-
225
- 模块按以下顺序查找:
226
-
227
- 1. `./cognitive/modules/` - 项目本地
228
- 2. `~/.cognitive/modules/` - 用户全局
229
- 3. `$COGNITIVE_MODULES_PATH` - 自定义路径
230
-
231
- ## 创建新模块
232
-
233
- ```bash
234
- # 1. 创建骨架
235
- cog init my-module -d "模块职责描述"
236
-
237
- # 2. 编辑 MODULE.md 添加指令
238
- # 3. 编辑 schema.json 定义输入输出
239
- # 4. 验证
240
- cog validate my-module
241
-
242
- # 5. 全局安装(可选)
243
- cog install ./cognitive/modules/my-module
244
- ```
245
-
246
- ## 内置模块
247
-
248
- ### ui-spec-generator
249
-
250
- 将产品需求转换为前端可实现的 UI 规范。
251
-
252
- **输出包含**:
253
- - 信息架构(sections + hierarchy)
254
- - 组件定义(type, props, states)
255
- - 交互设计(events, transitions)
256
- - 响应式规则(breakpoints, layout)
257
- - 可访问性(WCAG 要求)
258
- - 验收标准(可测试条件)
259
- - 置信度 + 推理过程
260
-
261
- ```bash
262
- cog run ui-spec-generator examples/input.json -o ui-spec.json --pretty
263
- ```
264
-
265
- ## 项目结构
266
-
267
- ```
268
- cognitive-modules/
269
- ├── README.md # 本文件
270
- ├── SPEC.md # 规范文档
271
- ├── INTEGRATION.md # Agent 集成指南
272
- ├── AGENTS.md # Agent 约定示例
273
- ├── cognitive-registry.json # 公共模块注册表
274
- ├── src/cognitive/ # CLI 源码
275
- │ ├── cli.py # 命令入口
276
- │ ├── loader.py # 模块加载(支持新旧格式)
277
- │ ├── runner.py # 模块执行
278
- │ ├── validator.py # 模块验证
279
- │ ├── registry.py # 模块发现与安装
280
- │ ├── templates.py # 模块模板
281
- │ └── providers/ # LLM 后端
282
- ├── cognitive/modules/ # 内置模块
283
- │ └── ui-spec-generator/
284
- └── pyproject.toml
285
- ```
286
-
287
- ## 文档
288
-
289
- - [SPEC.md](SPEC.md) - 完整规范文档
290
- - [INTEGRATION.md](INTEGRATION.md) - Agent 工具集成指南
291
- - [AGENTS.md](AGENTS.md) - Agent 约定示例
292
-
293
- ## License
294
-
295
- MIT