canary-framework 0.1.0__tar.gz

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 (79) hide show
  1. canary_framework-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +43 -0
  2. canary_framework-0.1.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
  3. canary_framework-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +24 -0
  4. canary_framework-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +20 -0
  5. canary_framework-0.1.0/.github/workflows/ci.yml +46 -0
  6. canary_framework-0.1.0/.github/workflows/publish.yml +45 -0
  7. canary_framework-0.1.0/.github/workflows/sync-wiki.yml +79 -0
  8. canary_framework-0.1.0/.gitignore +218 -0
  9. canary_framework-0.1.0/.python-version +1 -0
  10. canary_framework-0.1.0/CHANGELOG.md +16 -0
  11. canary_framework-0.1.0/CODE_OF_CONDUCT.md +34 -0
  12. canary_framework-0.1.0/CONTRIBUTING.md +45 -0
  13. canary_framework-0.1.0/LICENSE +201 -0
  14. canary_framework-0.1.0/PKG-INFO +167 -0
  15. canary_framework-0.1.0/README.md +139 -0
  16. canary_framework-0.1.0/README_EN.md +129 -0
  17. canary_framework-0.1.0/SECURITY.md +20 -0
  18. canary_framework-0.1.0/docs/en/api-reference.md +127 -0
  19. canary_framework-0.1.0/docs/en/configuration.md +51 -0
  20. canary_framework-0.1.0/docs/en/core-concepts.md +30 -0
  21. canary_framework-0.1.0/docs/en/dependency-injection.md +32 -0
  22. canary_framework-0.1.0/docs/en/index.md +15 -0
  23. canary_framework-0.1.0/docs/en/lifecycle.md +37 -0
  24. canary_framework-0.1.0/docs/en/modules.md +41 -0
  25. canary_framework-0.1.0/docs/en/quickstart.md +85 -0
  26. canary_framework-0.1.0/docs/en/services.md +41 -0
  27. canary_framework-0.1.0/docs/en/web-integration.md +81 -0
  28. canary_framework-0.1.0/docs/zh/api-reference.md +127 -0
  29. canary_framework-0.1.0/docs/zh/configuration.md +51 -0
  30. canary_framework-0.1.0/docs/zh/core-concepts.md +30 -0
  31. canary_framework-0.1.0/docs/zh/dependency-injection.md +32 -0
  32. canary_framework-0.1.0/docs/zh/index.md +19 -0
  33. canary_framework-0.1.0/docs/zh/lifecycle.md +37 -0
  34. canary_framework-0.1.0/docs/zh/modules.md +41 -0
  35. canary_framework-0.1.0/docs/zh/quickstart.md +89 -0
  36. canary_framework-0.1.0/docs/zh/services.md +41 -0
  37. canary_framework-0.1.0/docs/zh/web-integration.md +83 -0
  38. canary_framework-0.1.0/example/.python-version +1 -0
  39. canary_framework-0.1.0/example/main.py +64 -0
  40. canary_framework-0.1.0/example/minimal.py +30 -0
  41. canary_framework-0.1.0/example/pyproject.toml +11 -0
  42. canary_framework-0.1.0/example/service/__init__.py +0 -0
  43. canary_framework-0.1.0/example/service/dataset/__init__.py +0 -0
  44. canary_framework-0.1.0/example/service/dataset/dataset_admin_service.py +30 -0
  45. canary_framework-0.1.0/example/service/dataset/dataset_config.py +6 -0
  46. canary_framework-0.1.0/example/service/dataset/dataset_router.py +13 -0
  47. canary_framework-0.1.0/example/service/dataset/dataset_service.py +31 -0
  48. canary_framework-0.1.0/example/service/db/__init__.py +0 -0
  49. canary_framework-0.1.0/example/service/db/db_config.py +7 -0
  50. canary_framework-0.1.0/example/service/db/db_service.py +24 -0
  51. canary_framework-0.1.0/example/service/user/__init__.py +0 -0
  52. canary_framework-0.1.0/example/service/user/user_config.py +6 -0
  53. canary_framework-0.1.0/example/service/user/user_router.py +17 -0
  54. canary_framework-0.1.0/example/service/user/user_service.py +28 -0
  55. canary_framework-0.1.0/pyproject.toml +98 -0
  56. canary_framework-0.1.0/src/canary_framework/__init__.py +31 -0
  57. canary_framework-0.1.0/src/canary_framework/core/__init__.py +24 -0
  58. canary_framework-0.1.0/src/canary_framework/core/decorators/__init__.py +1 -0
  59. canary_framework-0.1.0/src/canary_framework/core/decorators/config.py +58 -0
  60. canary_framework-0.1.0/src/canary_framework/core/decorators/lifecycle.py +86 -0
  61. canary_framework-0.1.0/src/canary_framework/core/decorators/module.py +66 -0
  62. canary_framework-0.1.0/src/canary_framework/core/decorators/service.py +54 -0
  63. canary_framework-0.1.0/src/canary_framework/core/engine/canary.py +287 -0
  64. canary_framework-0.1.0/src/canary_framework/core/engine/context.py +89 -0
  65. canary_framework-0.1.0/src/canary_framework/core/engine/injector.py +37 -0
  66. canary_framework-0.1.0/src/canary_framework/core/engine/sorter.py +67 -0
  67. canary_framework-0.1.0/src/canary_framework/core/registry/__init__.py +0 -0
  68. canary_framework-0.1.0/src/canary_framework/core/registry/registry.py +138 -0
  69. canary_framework-0.1.0/src/canary_framework/core/utils/__init__.py +0 -0
  70. canary_framework-0.1.0/src/canary_framework/core/utils/naming.py +34 -0
  71. canary_framework-0.1.0/src/canary_framework/web/fastapi/__init__.py +21 -0
  72. canary_framework-0.1.0/src/canary_framework/web/fastapi/decorators/__init__.py +0 -0
  73. canary_framework-0.1.0/src/canary_framework/web/fastapi/decorators/router.py +105 -0
  74. canary_framework-0.1.0/src/canary_framework/web/fastapi/decorators/web.py +45 -0
  75. canary_framework-0.1.0/src/canary_framework/web/fastapi/web_canary.py +150 -0
  76. canary_framework-0.1.0/tests/conftest.py +0 -0
  77. canary_framework-0.1.0/tests/test_canary.py +65 -0
  78. canary_framework-0.1.0/tests/test_injector.py +19 -0
  79. canary_framework-0.1.0/tests/test_naming.py +13 -0
@@ -0,0 +1,43 @@
1
+ name: 🐛 Bug 报告
2
+ description: 报告框架的 bug 或异常行为
3
+ labels: [bug]
4
+ body:
5
+ - type: textarea
6
+ attributes:
7
+ label: 描述问题
8
+ description: 请清晰描述你遇到的问题
9
+ validations:
10
+ required: true
11
+ - type: textarea
12
+ attributes:
13
+ label: 复现步骤
14
+ description: 提供最小复现代码
15
+ render: python
16
+ validations:
17
+ required: true
18
+ - type: textarea
19
+ attributes:
20
+ label: 期望行为
21
+ description: 你期望发生什么?
22
+ validations:
23
+ required: true
24
+ - type: input
25
+ attributes:
26
+ label: CF 版本
27
+ placeholder: "0.1.0"
28
+ validations:
29
+ required: true
30
+ - type: input
31
+ attributes:
32
+ label: Python 版本
33
+ placeholder: "3.12"
34
+ validations:
35
+ required: true
36
+ - type: input
37
+ attributes:
38
+ label: 操作系统
39
+ placeholder: "Ubuntu 22.04 / macOS 14 / Windows 11"
40
+ - type: textarea
41
+ attributes:
42
+ label: 其他上下文
43
+ description: 日志输出、截图等
@@ -0,0 +1,8 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: 💬 讨论 / Discussions
4
+ url: https://github.com/HotcocoaCanary/Canary-Framework/discussions
5
+ about: 使用问题、想法建议请到 Discussions 交流
6
+ - name: 📖 文档 / Wiki
7
+ url: https://github.com/HotcocoaCanary/Canary-Framework/wiki
8
+ about: 查看 Wiki 文档
@@ -0,0 +1,24 @@
1
+ name: ✨ 功能请求
2
+ description: 建议新功能或改进
3
+ labels: [enhancement]
4
+ body:
5
+ - type: textarea
6
+ attributes:
7
+ label: 使用场景
8
+ description: 描述你的使用场景,你想解决什么问题?
9
+ validations:
10
+ required: true
11
+ - type: textarea
12
+ attributes:
13
+ label: 期望方案
14
+ description: 你期望的 API 或行为是什么样的?
15
+ validations:
16
+ required: true
17
+ - type: textarea
18
+ attributes:
19
+ label: 备选方案
20
+ description: 你考虑过哪些替代方案?
21
+ - type: textarea
22
+ attributes:
23
+ label: 补充信息
24
+ description: 其他相关内容
@@ -0,0 +1,20 @@
1
+ ## 变更说明
2
+
3
+ <!-- 请描述这个 PR 做了什么 -->
4
+
5
+ ## 变更类型
6
+
7
+ - [ ] 🐛 Bug 修复
8
+ - [ ] ✨ 新功能
9
+ - [ ] 📝 文档
10
+ - [ ] ♻️ 重构
11
+ - [ ] 🧪 测试
12
+ - [ ] 🔧 配置/工具
13
+
14
+ ## 检查清单
15
+
16
+ - [ ] 代码已通过 `ruff check` 和 `ruff format`
17
+ - [ ] 类型检查已通过 `mypy`
18
+ - [ ] 已添加/更新测试
19
+ - [ ] 所有测试通过 `pytest`
20
+ - [ ] 文档已更新(如需要)
@@ -0,0 +1,46 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ env:
10
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.12", "3.13"]
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+
22
+ - name: Install uv
23
+ uses: astral-sh/setup-uv@v5
24
+
25
+ - name: Set up Python ${{ matrix.python-version }}
26
+ run: uv python install ${{ matrix.python-version }}
27
+
28
+ - name: Install dependencies
29
+ run: uv sync --extra dev --extra web
30
+
31
+ - name: Lint (ruff)
32
+ run: uv run ruff check src/ tests/ example/
33
+
34
+ - name: Format check (ruff)
35
+ run: uv run ruff format --check src/ tests/ example/
36
+
37
+ - name: Type check (mypy)
38
+ run: uv run mypy src/
39
+
40
+ - name: Test
41
+ run: uv run pytest --cov=src/canary_framework --cov-report=term --cov-report=xml
42
+
43
+ - name: Upload coverage
44
+ uses: codecov/codecov-action@v5
45
+ with:
46
+ files: ./coverage.xml
@@ -0,0 +1,45 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ env:
9
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v5
19
+
20
+ - name: Build
21
+ run: uv build
22
+
23
+ - name: Check package
24
+ run: uv run --with twine twine check dist/*
25
+
26
+ - name: Upload artifacts
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: dist
30
+ path: dist/
31
+
32
+ publish:
33
+ needs: build
34
+ runs-on: ubuntu-latest
35
+ permissions:
36
+ id-token: write
37
+ environment: publish
38
+ steps:
39
+ - uses: actions/download-artifact@v4
40
+ with:
41
+ name: dist
42
+ path: dist/
43
+
44
+ - name: Publish to PyPI
45
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,79 @@
1
+ name: Sync Wiki
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - "docs/zh/**"
8
+
9
+ env:
10
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
11
+
12
+ permissions:
13
+ contents: write
14
+
15
+ jobs:
16
+ sync-wiki:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Sync docs to wiki
22
+ env:
23
+ GH_TOKEN: ${{ secrets.GH_PAT }}
24
+ run: |
25
+ git clone "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.wiki.git" /tmp/wiki
26
+
27
+ declare -A TITLES=(
28
+ ["index"]="Home"
29
+ ["quickstart"]="快速开始"
30
+ ["core-concepts"]="核心概念"
31
+ ["services"]="服务"
32
+ ["modules"]="模块"
33
+ ["configuration"]="配置"
34
+ ["lifecycle"]="生命周期"
35
+ ["dependency-injection"]="依赖注入"
36
+ ["web-integration"]="Web-集成"
37
+ ["api-reference"]="API-参考"
38
+ )
39
+
40
+ ORDER=(index quickstart core-concepts services modules configuration lifecycle dependency-injection web-integration api-reference)
41
+
42
+ cd /tmp/wiki
43
+ for key in "${ORDER[@]}"; do
44
+ src="$GITHUB_WORKSPACE/docs/zh/${key}.md"
45
+ title="${TITLES[$key]}"
46
+ dst="${title// /-}.md"
47
+ if [ -f "$src" ]; then
48
+ cp "$src" "$dst"
49
+ fi
50
+ done
51
+
52
+ cat > _Sidebar.md << 'SIDEBAR'
53
+ # 文档
54
+
55
+ - [快速开始](快速开始)
56
+ - [核心概念](核心概念)
57
+ - [服务](服务)
58
+ - [模块](模块)
59
+ - [配置](配置)
60
+ - [生命周期](生命周期)
61
+ - [依赖注入](依赖注入)
62
+ - [Web 集成](Web-集成)
63
+ - [API 参考](API-参考)
64
+
65
+ ---
66
+
67
+ [回到仓库](https://github.com/HotcocoaCanary/Canary-Framework)
68
+ SIDEBAR
69
+
70
+ git add -A
71
+ if git diff --cached --quiet; then
72
+ echo "No wiki changes."
73
+ else
74
+ git -c user.name="github-actions[bot]" \
75
+ -c user.email="github-actions[bot]@users.noreply.github.com" \
76
+ commit -m "Sync docs from main repo"
77
+ git push origin master
78
+ echo "Wiki updated!"
79
+ fi
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,16 @@
1
+ # 变更日志
2
+
3
+ ## [0.1.0] - 2026-05-25
4
+
5
+ ### 新增
6
+ - 核心引擎 `Canary`:服务生命周期编排(init → start → stop)
7
+ - 装饰器 `@service` / `@module`:声明服务和模块
8
+ - 装饰器 `@config`:基于 pydantic-settings 的自动配置加载
9
+ - 装饰器 `@on_init` / `@on_start` / `@on_end`:生命周期钩子
10
+ - 依赖注入:按 snake_case 自动注入依赖实例
11
+ - 拓扑排序启动:基于 Kahn 算法保证依赖顺序
12
+ - Context 上下文系统:parent 链向上委托配置和依赖解析
13
+ - Web 集成 `WebCanary`:自动接入 FastAPI + Uvicorn
14
+ - 装饰器 `@web` / `@router` / `@get` / `@post` / `@put` / `@delete` / `@patch`
15
+ - 配置前缀分发:`uvicorn_*` → uvicorn,`fastapi_*` → FastAPI
16
+ - 框架日志系统:`CF_LOG_LEVEL` 环境变量控制,与 uvicorn 隔离
@@ -0,0 +1,34 @@
1
+ # 行为准则
2
+
3
+ ## 我们的承诺
4
+
5
+ 为了营造一个开放和友好的环境,我们承诺让每个人都能无差别地参与此项目。
6
+
7
+ ## 我们的标准
8
+
9
+ 鼓励的行为:
10
+ - 使用友好和包容的语言
11
+ - 尊重不同的观点和经验
12
+ - 建设性地接受批评
13
+ - 关注对社区最有利的事情
14
+
15
+ 禁止的行为:
16
+ - 使用与性别、性取向、种族、宗教等相关的冒犯性言论
17
+ - 公开或私下骚扰
18
+ - 未经许可发布他人私人信息
19
+
20
+ ## 我们的责任
21
+
22
+ 项目维护者有责任明确可接受行为的标准,并对任何不可接受的行为采取适当和公平的纠正措施。
23
+
24
+ ## 范围
25
+
26
+ 本行为准则适用于所有项目空间和公共场合。
27
+
28
+ ## 执行
29
+
30
+ 如有不可接受的行为,可通过 GitHub Issues 向维护者报告。
31
+
32
+ ## 来源
33
+
34
+ 改编自 [Contributor Covenant](https://www.contributor-covenant.org),版本 2.1。
@@ -0,0 +1,45 @@
1
+ # 贡献指南
2
+
3
+ 感谢你对 CF (Canary Framework) 的关注!欢迎贡献代码、文档或提出问题。
4
+
5
+ ## 环境搭建
6
+
7
+ ```bash
8
+ git clone https://github.com/HotcocoaCanary/Canary-Framework.git
9
+ cd Canary-Framework
10
+ uv sync --extra dev --extra web
11
+ ```
12
+
13
+ ## 开发流程
14
+
15
+ 1. Fork 仓库,从 `main` 创建功能分支
16
+ 2. 编写代码和测试
17
+ 3. 运行检查和测试:
18
+
19
+ ```bash
20
+ uv run ruff check src/ tests/ # 代码检查
21
+ uv run ruff format src/ tests/ # 代码格式化
22
+ uv run mypy src/ # 类型检查
23
+ uv run pytest --cov=src/canary_framework # 运行测试
24
+ ```
25
+
26
+ 4. 提交 PR,描述变更内容
27
+
28
+ ## 代码风格
29
+
30
+ - Python 3.12+ 语法
31
+ - 使用 ruff 进行格式化和 lint
32
+ - 类型注解尽量完整
33
+ - 注释使用中文(docstring 中英文均可)
34
+
35
+ ## 提交信息规范
36
+
37
+ ```
38
+ 类型: 简短描述
39
+
40
+ 类型: feat / fix / docs / refactor / test / chore
41
+ ```
42
+
43
+ ## 许可证
44
+
45
+ 贡献的代码将采用 Apache 2.0 许可证。