cognis-digital/templates
GitHub: cognis-digital/templates
一套固执己见、开箱即用的 Python 项目启动模板,涵盖 CLI、MCP 服务器、Docker、CI 和开发容器等常见项目骨架。
Stars: 0 | Forks: 0
# cognis-templates
Cognis Digital 项目的启动模板。复制一个模板,重命名,然后发布。
每个模板都是独立的、固执己见的,并且开箱即用、可用于生产环境:现代化的工具,合理的默认设置,无需删除任何样板代码。
## 用法 — 分步指南
1. **获取模板** — 克隆此 repo;每个模板目录都是独立的:
git clone https://github.com/cognis-digital/templates.git && cd templates
2. **复制模板** 将你想要的模板复制到你的新项目中(上表列出了所有路径,例如 `python-cli/`, `mcp-server-python/`):
cp -r python-cli/ ~/projects/my-tool && cd ~/projects/my-tool
3. **重命名占位符** — 通过查找和替换,将 `cognis_tool` / `cognis-tool` 替换为你的包名/项目名,然后阅读模板自带的 `README.md` 了解后续步骤。
4. **安装并运行** 复制后的项目(模板使用 `pyproject.toml`;首选 `uv`,普通的 `pip` 也始终适用):
pip install -e . # 或者:uv pip install -e .
5. **使用内置的 CI 进行交付** — `.github/workflows/ci.yml` 模板会在 push 时运行 ruff、mypy 和 pytest,因此项目从第一次提交起就受到质量门控。
## 索引
| 模板 | 路径 | 提供的内容 |
| --- | --- | --- |
| **Python CLI 工具** | [`python-cli/`](python-cli/) | 一个基于 `pyproject.toml` 的 CLI,带有 `argparse` 子命令、打包的入口点和 pytest。 |
| **MCP server (Python)** | [`mcp-server-python/`](mcp-server-python/) | 一个使用官方 `mcp` SDK 的 Model Context Protocol 服务器,通过 stdio 暴露工具。 |
| **Dockerfile** | [`docker/Dockerfile`](docker/Dockerfile) | 一个多阶段、非 root 用户、带有健康检查的精简 Python 镜像模板。 |
| **CI 工作流** | [`.github/workflows/ci.yml`](.github/workflows/ci.yml) | GitHub Actions:跨矩阵进行 lint (ruff)、类型检查 (mypy) 和测试 (pytest)。 |
| **Dev container** | [`.devcontainer/`](.devcontainer/) | VS Code / Codespaces 的 devcontainer,预装了 Python、uv 和预配置的扩展。 |
| **项目 README** | [`templates/README.template.md`](templates/README.template.md) | 一个适用于新项目的填空式 README。 |
| **Issue / PR 模板** | [`.github/`](.github/) | Bug 报告、功能请求、配置和 PR 检查清单。 |
## 如何使用
1. 选择你想要的模板目录。
2. 将其复制到你的新 repo 中(例如 `cp -r python-cli/ ~/projects/my-tool`)。
3. 查找并替换占位符名称:
- `cognis_tool` / `cognis-tool` -> 你的包 / 项目名称
- `Cognis Digital` -> 对于第一方 repo 保持原样
4. 阅读模板自带的 `README.md` 了解后续步骤。
## 模板中使用的约定
- 以 **Python 3.11+** 为最低版本。
- **`pyproject.toml`** 是项目配置的唯一来源(没有 `setup.py`,没有 `setup.cfg`)。
- **[uv](https://github.com/astral-sh/uv)** 是首选的安装器/运行器,普通的 `pip` 始终可作为备选方案。
- **[ruff](https://github.com/astral-sh/ruff)** 用于 lint 和格式化。
- **[mypy](https://mypy-lang.org/)** 用于类型检查,在可行的情况下采用严格模式。
- **[pytest](https://pytest.org/)** 用于测试。
- 容器以**非 root 用户**运行,并且是**多阶段**构建的,以保持镜像小巧。
## 契合方式
```
flowchart LR
U[You / CI / Agent] --> R[templates]
R --> O[Outputs & artifacts]
R --> M[MCP / JSON]
M --> AI[AI agents]
R --> S[Cognis Neural Suite]
```
**探索套件 →** [🗂️ 所有工具](https://github.com/cognis-digital/cognis-neural-suite) · [⭐ awesome-cognis](https://github.com/cognis-digital/awesome-cognis) · [🔗 cognis-sources](https://github.com/cognis-digital/cognis-sources)
## 互操作性
`templates` 可与包含 300 多个工具的 Cognis 套件组合使用 — JSON 输入/输出以及共享的
OpenAI 兼容的 `/v1` 主干。请参阅 **[INTEROP.md](INTEROP.md)** 了解
套件图谱、组合模式和参考技术栈。
## 集成
通过
[`cognis-connect`](https://github.com/cognis-digital/cognis-connect) 将 `templates` 的发现结果转发至 STIX/MISP/Sigma/Splunk/Elastic/Slack/webhooks。请参阅 **[INTEGRATIONS.md](INTEGRATIONS.md)**。
## 许可证
MIT。请参阅 [LICENSE](LICENSE)。
标签:DevContainer, Docker, MCP, Python, SOC Prime, 安全规则引擎, 安全防御评估, 开发工具, 无后门, 请求拦截, 逆向工具, 项目模板