Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .claude/commands/commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
**步骤 1:获取当前年份**
```bash
# 动态获取当前年份(绝对不要硬编码)
CURRENT_YEAR=$(date +%Y)
echo "当前年份: $CURRENT_YEAR"
date +%Y
# 输出示例:2026
```

**步骤 2:检查修改的文件**
Expand Down Expand Up @@ -112,8 +112,8 @@ Edit(
### 完整示例

```bash
# 1. 获取当前年份
CURRENT_YEAR=$(date +%Y)
# 1. 获取当前年份(AI 执行时只用 date +%Y)
date +%Y
# 输出:2026

# 2. 查看修改的文件
Expand Down
2 changes: 1 addition & 1 deletion .claude/project-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Bash("OWNER_GROUP=$(ls -l README.md | awk '{print $3\":\"$4}') && sudo chown $OW

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
```

**Type 类型(使用英文):**
Expand Down
1 change: 1 addition & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"permissions": {
"allow": [
"Bash(tree:*)",
"Bash(date:*)",
"WebSearch",
"WebFetch",
"Bash(gh:*)",
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
types: [opened, edited, synchronize]

permissions:
pull-requests: read
pull-requests: write
statuses: write

jobs:
validate:
Expand Down Expand Up @@ -34,9 +35,6 @@ jobs:
subjectPattern: '^.{5,100}$'
subjectPatternError: '标题描述长度应在 5-100 字符之间'

# 禁用首字母大写检查(兼容中文)
enforceSingleSentence: false

# 支持 WIP 前缀标记进行中的工作
wip: true

Expand Down
7 changes: 7 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Git mailmap file
# 统一 Claude AI 的贡献者署名,确保 GitHub 能够正确统计所有 Claude 辅助的提交

# 将所有 Claude 模型变体统一为 "Claude"
Claude <noreply@anthropic.com> Claude Sonnet 4.5 <noreply@anthropic.com>
Claude <noreply@anthropic.com> Claude Opus 4.5 <noreply@anthropic.com>
Claude <noreply@anthropic.com> Claude Haiku 4.5 <noreply@anthropic.com>
1 change: 1 addition & 0 deletions framework/fit/python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fit_plugin_cli.egg-info
__pycache__
plugin/*
!plugin/fit_py*/
.venv/

*.tar
*.zip
Expand Down
81 changes: 47 additions & 34 deletions framework/fit/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FIT for Python 是基于 FIT Framework 的 Python 运行时与插件开发套件
- `plugin/`:本地插件工程根目录,使用 CLI 生成与构建。
- `conf/`:框架及插件相关配置。
- `bootstrap/`:运行时启动与配置加载的底层实现。
- `requirements.txt`:运行时依赖列表
- `pyproject.toml`:项目配置与运行时依赖列表
- `fit_common_struct/`:框架通用数据结构与工具。
- `fit_flowable/`:流程/可流式组件相关实现。
- `fit_py_nacos_registry/`:Nacos 注册中心适配。
Expand Down Expand Up @@ -44,56 +44,68 @@ FIT for Python 是基于 FIT Framework 的 Python 运行时与插件开发套件
项目已配置 `.python-version` 文件指定版本。如使用 pyenv,会自动切换到对应版本。

**版本兼容性说明:**
- 依赖包(特别是 numpy==1.25.2)已针对 Python 3.9 进行测试
- 依赖包(特别是 numpy>=1.25.2)已针对 Python 3.9 进行测试
- 更高版本(如 3.14+)可能存在兼容性问题
- 升级 Python 版本时,请同步更新 `requirements.txt` 中的依赖版本
- 升级 Python 版本时,请同步更新 `pyproject.toml` 中的依赖版本

### 安装依赖

需要安装 `requirements.txt` 中的第三方依赖,当前依赖如下
本项目使用 **uv** 作为依赖管理工具,提供更快的依赖解析和安装速度。当前依赖如下(定义在 `pyproject.toml` 中)

```python
numpy==1.25.2
PyYAML==6.0.1
requests==2.32.4
tornado==6.5.0
```toml
numpy>=1.25.2,<2.0.0
pyyaml>=6.0.1,<7.0.0
requests>=2.32.4,<3.0.0
tornado>=6.5.0,<7.0.0
```

推荐在虚拟环境中安装依赖:
#### 安装 uv

如果还没有安装 uv,请先安装:

```bash
# macOS
brew install uv

# Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

# 或使用 pip 安装
pip install uv
```

#### 使用 uv 安装依赖

推荐使用 uv 管理虚拟环境和依赖:

```bash
# 方法 1:使用 python3.9(推荐)
python3.9 -m venv .venv # 创建虚拟环境
source .venv/bin/activate # Windows 可执行 .\.venv\Scripts\activate
pip install -r requirements.txt

# 方法 2:使用 pyenv(自动读取 .python-version)
pyenv install 3.9.25 # 首次使用需安装
eval "$(pyenv init -)"
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# 方法 3:使用系统默认 python3
python3 -m venv .venv # 确保 python3 版本 >= 3.9
source .venv/bin/activate
pip install -r requirements.txt
# 使用 uv sync
# uv 会自动创建虚拟环境并安装所有依赖
uv sync
```

**注意:** 虚拟环境激活后,`python` 命令即可直接使用,无需输入 `python3`。
**注意:**
- uv 会自动管理虚拟环境,默认创建在 `.venv` 目录
- 使用 `uv sync` 时会自动激活虚拟环境并安装依赖
- 虚拟环境激活后,`python` 命令即可直接使用

## 快速开始

1. 进入工程根目录:`cd framework/fit/python`。
2. 创建并激活虚拟环境,安装依赖:同上所示
2. 安装依赖:执行 `uv sync` 自动创建虚拟环境并安装所有依赖
3. 按需修改 `conf/application.yml` 中的 `registry-center` 和端口配置。
4. 启动:`python -m fitframework`,观察终端或 `fit_framework.log` 是否有错误。
4. 启动:`uv run python -m fitframework`,观察终端或 `fit_framework.log` 是否有错误。
5. 健康检查:按下文 curl 示例确认返回 `OK`。

## 启动框架

在项目根目录执行:
```bash
python -m fitframework
# 使用 uv 运行
uv run python -m fitframework
```
默认会启动本地服务并按配置加载插件;进程前台运行,终端保持开启即可。

Expand All @@ -115,12 +127,12 @@ curl --request GET \

1. 初始化插件工程(在项目根目录):
```bash
python -m fit_cli init your_plugin_name
uv run python -m fit_cli init your_plugin_name
```
2. 开发完成后构建与打包:
```bash
python -m fit_cli build your_plugin_name
python -m fit_cli package your_plugin_name
uv run python -m fit_cli build your_plugin_name
uv run python -m fit_cli package your_plugin_name
```
生成的产物位于 `plugin/your_plugin_name/build/`。

Expand All @@ -130,5 +142,6 @@ curl --request GET \

- 启动报端口占用:调整 `conf/fit_startup.yml` 或 `application.yml` 中的端口后重启。
- 注册中心连通性:确认 `registry-center.addresses` 可达,必要时先用 curl/ping 验证。
- 重新安装依赖:在已激活虚拟环境中执行 `pip install -r requirements.txt --force-reinstall`。
- 重新安装依赖:执行 `uv sync --reinstall` 重新安装所有依赖。
- 清理并重建环境:删除 `.venv` 目录后重新执行 `uv sync`。
- 停止服务:直接中断前台进程(Ctrl+C),或关闭终端会话。
4 changes: 4 additions & 0 deletions framework/fit/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ keywords = ["fit", "cli", "plugin"]
requires-python = ">=3.9"

dependencies = [
"numpy>=1.25.2,<2.0.0",
"pyyaml>=6.0.1,<7.0.0",
"requests>=2.32.4,<3.0.0",
"tornado>=6.5.0,<7.0.0",
]

[project.scripts]
Expand Down
4 changes: 0 additions & 4 deletions framework/fit/python/requirements.txt

This file was deleted.

Loading