Skip to content
Draft
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: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.venv/
.git/
.github/
__pycache__/
*.pyc
docs/
tests/
*.log
35 changes: 16 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
name: CI
name: Windows package

on:
push:

# Allows you to run this workflow manually from the Actions tab
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
architecture: 'x64'
name: 'win64'

runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.13'
architecture: ${{matrix.architecture}}

- name: Install requirements
run: |
pip install -r requirements.txt
pip install pyinstaller

- name: Build win bin
run: pyinstaller -F main.py -n 'chaoxing' --add-data "resource;resource" --hidden-import=chardet
- name: Build binaries
run: |
pyinstaller -F main.py -n chaoxing --add-data "resource;resource" --hidden-import=chardet
pyinstaller -F setup_wizard.py -n chaoxing-setup --add-data "resource;resource" --add-data "config_template.ini;." --hidden-import main

- name: Smoke test executable
run: ./dist/chaoxing.exe --help

- name: Create release package
run: |
mkdir release
copy dist\chaoxing.exe release\
copy dist\chaoxing-setup.exe release\
copy config_template.ini release\
cd release
7z a -tzip chaoxing.zip *
7z a -tzip chaoxing-win64.zip *

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: 'release/chaoxing.zip'
name: win64
path: release/chaoxing-win64.zip
20 changes: 20 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Installed wheel
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
jobs:
installed-wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- run: pip install build
- run: python -m build
- run: pip install dist/*.whl
- name: Run installed package outside checkout
working-directory: /tmp
run: |
chaoxing --help
python -c "from api.cxsecret_font import FontHashDAO; FontHashDAO()"
30 changes: 30 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: tests

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Public contribution guard
run: python tools/audit/publication_guard.py
- name: Compile check
run: python -m compileall -q api main.py setup_wizard.py tools tests
- name: Unit tests (offline)
run: python -m unittest discover -s tests -t .
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ cookies.txt
.config.ini
config.ini
chaoxing.log
# 多用户模式保存的账号(含明文密码,绝不能提交)
accounts/
config*.ini
.chaoxing.log
./config.ini
Expand All @@ -154,6 +156,27 @@ config*.ini
.idea/
.vscode/
cache.json

# 探针本机配置(含真实账号/课程参数,绝不入库)
tools/probe/local.env

# 抓包文件:*.har 一律不入库;capture_*.txt 脱敏后可以入库(提交前必须自查)
docs/artifacts/*.har
start*.bat
.workbuddy/
myConfig/

# Private development material must never be published.
AGENTS.md
CLAUDE.md
docs/handoff/
docs/artifacts/
private/
*.har
*capture*.txt
SESSION-LOG*
TASKS.yaml
HANDOFF*
AUDIT-REPORT*
.env.*
!.env.example
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ FROM python:3.13-slim

WORKDIR /app

COPY . /app
# 依赖单独一层,改代码不用重装依赖
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
COPY api ./api
COPY resource ./resource
COPY tools ./tools
COPY main.py setup_wizard.py config_template.ini Makefile ./

# 创建配置文件目录并提供默认配置
RUN mkdir -p /config && \
cp config_template.ini /config/config.ini
# 账号 / 配置 / cookie / 日志都落在 /root/.chaoxing,挂载出来才能持久化
VOLUME ["/root/.chaoxing"]

# 定义卷,用户可以挂载自己的配置文件
VOLUME /config

# 使用配置文件启动应用
ENTRYPOINT ["python3", "main.py", "-c", "/config/config.ini"]
# 默认进入交互式向导(docker run -it);也可以覆盖命令跑 main.py
ENTRYPOINT ["python3", "setup_wizard.py"]
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 常用命令:给人和 Agent 共用
PY ?= python3
.PHONY: help test lint compile publication doctor

help: ## 列出所有命令
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'

# 本地默认解释器可能比 CI 新(如 3.14):注解求值时机不同,
# 提交前用 CI 同版本再跑一遍,避免"本地绿、CI 红"。
# make test-313 # 系统 python3.13(没装依赖就跳过)
# make test-313 PY313=/tmp/cx313/bin/python # 自己建好的 3.13 venv
PY313 ?= python3.13

test-313:
@if ! command -v $(PY313) >/dev/null 2>&1 && [ ! -x "$(PY313)" ]; then \
echo "没有 $(PY313),跳过(CI 会跑)"; \
elif ! $(PY313) -c "import loguru, openai, bs4, lxml, requests, httpx, tqdm, tenacity" 2>/dev/null; then \
echo "$(PY313) 缺依赖,跳过(CI 会跑)。本地对齐:python3.13 -m venv /tmp/cx313 && /tmp/cx313/bin/pip install -r requirements.txt"; \
else \
$(PY313) -m compileall -q api main.py setup_wizard.py tools tests && \
$(PY313) -m unittest discover -s tests -t .; \
fi

test: ## 跑全量单测(离线)
$(PY) -m unittest discover -s tests -t .

compile: ## 语法编译检查
$(PY) -m compileall -q api main.py tools tests

publication:
$(PY) tools/audit/publication_guard.py

lint: publication compile test ## 提交前必跑:编译 + 单测

doctor: ## 环境自检
@echo "python : $$($(PY) -V)"
@echo "venv : $$(test -x $(PY) && echo ok || echo missing)"
@echo "data : $$(test -d $$HOME/.chaoxing && echo $$HOME/.chaoxing || echo 'missing (~/.chaoxing)')"
@$(PY) -c "import requests, bs4, loguru, tqdm; print('deps : ok')"
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,49 @@ python main.py -a ask # 使用询问模式
- 本代码遵循 [GPL-3.0 License](https://github.com/Samueli924/chaoxing/blob/main/LICENSE) 协议,允许**开源/免费使用和引用/修改/衍生代码的开源/免费使用**,不允许**修改和衍生的代码作为闭源的商业软件发布和销售**,禁止**使用本代码盈利**,以此代码为基础的程序**必须**同样遵守 [GPL-3.0 License](https://github.com/Samueli924/chaoxing/blob/main/LICENSE) 协议
- 本代码仅用于**学习讨论**,禁止**用于盈利**
- 他人或组织使用本代码进行的任何**违法行为**与本人无关

## 任务中心与交互式入口

新增任务中心教学任务:视频、文档阅读、章节同步、作业、主题讨论和 AI 实践。
任务按分组顺序解锁,完成状态以平台复查为准;失败不会影响章节任务。
思考题暂不支持,文档时长是否有效取决于平台返回的状态。
真实观看时长、请求间隔和顺序解锁不能通过配置绕过。

```sh
python setup_wizard.py
./cx
./cx discuss
./cx review
```

向导支持选择账号、课程和任务范围。讨论区挑帖必须逐条预览和确认,
`--yes` 不绕过这一确认。任务讨论遵循 `task_center_submit_mode`:
`confirm` 逐项确认;`auto` 在检查与留痕后发送。

账号配置、密码、Cookie、缓存和日志保存在 `~/.chaoxing/`。
生成的实质性文字在请求之前持久化到 `~/.chaoxing/reviews/`;
写入失败会阻止该项提交。记录区分取消、失败、未确认和平台接受。
客观题选项显示在运行记录中,不进入正文复核文件。
文本检查不能完整判断真实性,用户仍应复核内容。

可选题库和模型服务会接收问题及相关上下文;写作服务可能接收讨论参考文本,
通知服务会接收配置的通知。日志脱敏不能去除任意正文中的所有私人事实。
不要公开凭据、账号数据或原始抓包;若凭据已公开,应在来源处撤销或更换。
删除当前文件不会清除 Git 历史。公开贡献仅包含可维护的代码、
用户文档和合成测试数据;工作笔记保存在仓库之外。

## 安装包和离线验证

```sh
pip install .
chaoxing --help
chaoxing-setup
python -m unittest discover -s tests -t .
python tools/audit/publication_guard.py
python tools/audit/01_human_likeness_audit.py --selftest
```

安装包包含字体映射和配置模板,支持在仓库目录之外运行。
生成内容、取消和失败状态、顺序解锁与接口解析均有离线回归测试。
开发时还应检查 Python 3.13、安装包和上游自动审查结果。
公开贡献应从最新上游历史建立,按功能拆分并说明依赖,保留许可与作者归属。
Loading