monash-study-kit 1.8.0__tar.gz → 1.10.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.
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/CHANGELOG.md +19 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/PKG-INFO +65 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/README.md +64 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/README.zh-CN.md +64 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/pyproject.toml +1 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/scripts/check_dist.py +1 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/__init__.py +1 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/__main__.py +1 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/browser_login.py +3 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/cli.py +61 -11
- monash_study_kit-1.10.0/src/monash_study_kit/cli_google.py +32 -0
- monash_study_kit-1.10.0/src/monash_study_kit/cli_profile.py +118 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/doctor.py +3 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/doctor_deep.py +2 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/edexport.py +11 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/edsync.py +34 -8
- monash_study_kit-1.10.0/src/monash_study_kit/entry.py +89 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/export.py +63 -6
- monash_study_kit-1.10.0/src/monash_study_kit/google_export.py +365 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/help_menu.py +10 -0
- monash_study_kit-1.10.0/src/monash_study_kit/home.py +41 -0
- monash_study_kit-1.10.0/src/monash_study_kit/htmlmd.py +181 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/jobs.py +33 -8
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/lessons.py +67 -2
- monash_study_kit-1.10.0/src/monash_study_kit/materials_policy.py +57 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/mcp_server.py +25 -8
- monash_study_kit-1.10.0/src/monash_study_kit/moodle_content.py +108 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/moodlelib.py +6 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/paths.py +16 -27
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/student_tools.py +2 -0
- monash_study_kit-1.10.0/src/monash_study_kit/syncer.py +718 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_course_export.py +121 -1
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_ed_export.py +86 -0
- monash_study_kit-1.10.0/tests/test_ed_tracking.py +35 -0
- monash_study_kit-1.10.0/tests/test_google_export.py +259 -0
- monash_study_kit-1.10.0/tests/test_moodle_content.py +178 -0
- monash_study_kit-1.10.0/tests/test_profiles.py +448 -0
- monash_study_kit-1.8.0/src/monash_study_kit/syncer.py +0 -393
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/.github/pull_request_template.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/.github/workflows/release.yml +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/.github/workflows/test.yml +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/.gitignore +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/CODE_OF_CONDUCT.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/CONTRIBUTING.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/LICENSE +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/PRIVACY.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/SECURITY.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/SECURITY-REVIEW-1.5-SCOPE.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/adr/0001-one-shared-core.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/adr/0002-read-only-public-package.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/adr/0003-release-from-a-tag.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/adr/0004-confirmed-mail-and-attendance-actions.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/adr/README.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/gmail-foundation.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/google-and-attendance-setup.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/panels-library-remote.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/releasing.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/screenshots/todo.png +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/docs/security.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/glama.json +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/scripts/measure_tokens.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/scripts/smoke_test.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/skills/monash-study-kit/SKILL.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/attendance.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/attendance_assets/PROVENANCE.md +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/attendance_assets/extract-rows.js +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/attendance_assets/shared.js +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/attendance_auto.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/attendance_evidence.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/attendance_http.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/cdp.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/claude_setup.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/cli_attendance.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/cli_ed.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/cli_gmail.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/clients.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/content_index.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/edlib.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/edquery.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/features.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/gmail.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/gmail_tools.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/google_client.json +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/htmldom.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/lesson_reader.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/library.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/location.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/output.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/recordings.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/remote.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/semester.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/service_actions.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/service_jobs.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/service_setup.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/student_services.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/textextract.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/todo.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/transcribe.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/ui/panel.html +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/update_check.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/webnotes.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/src/monash_study_kit/widgets.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/conftest.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_attendance_browser.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_attendance_fast.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_attendance_parity.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_cdp.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_cli.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_clients.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_content_index.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_doctor.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_doctor_deep.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_ed_auth.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_ed_markdown.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_ed_query.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_ed_quiz.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_feature_cli.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_features.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_gmail.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_help_menu.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_layout.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_lesson_reader.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_library.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_location.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_mcp.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_panels.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_recordings.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_remote.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_removed_files.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_security.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_semester.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_service_setup.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_setup.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_shared_core.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_skill.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_student_gmail.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_student_tools.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_sync_robustness.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_todo.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_update_check.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_webnotes.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/tests/test_without_ed.py +0 -0
- {monash_study_kit-1.8.0 → monash_study_kit-1.10.0}/uv.lock +0 -0
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Version numbers follow `__version__` in `src/monash_study_kit/__init__.py`: patch for bug fixes, minor for new features.
|
|
4
4
|
|
|
5
|
+
## 1.10.0
|
|
6
|
+
|
|
7
|
+
- Add an early account-selection entry point: `--profile NAME`, `--profile=NAME`, or `MONASH_KIT_PROFILE` isolates credentials, databases, materials and browser sessions under the default data home's `profiles/NAME`. Names are validated, directories are private, per-directory overrides cannot escape named profiles, and the default account keeps its existing behavior.
|
|
8
|
+
- Add `profile list` and confirmed `profile remove NAME [--all] [--yes]`. Removal revokes the target's Drive and Gmail OAuth authorizations before deleting any local session files; any revocation failure preserves all local files. Materials remain unless `--all` is used. No Moodle logout is requested, and the completion message points to Ed's manual API-token deletion page.
|
|
9
|
+
- Named profiles stay local: refuse remote serving, AI configuration and independent moves; setup only logs in and selects courses. Add `materials_only`, false by default and forced true for named profiles, with centralized CLI and MCP allowlists.
|
|
10
|
+
- Materials mode syncs Ed course lists and Lessons without discussions, preserves Moodle and linked Google material exports, and skips Gmail sync, attendance reads/keepalive, personal-calendar setup and private diagnostic checks. Its MCP surface is limited to file listing/reading/search, Lessons/quizzes and local Ed export; forbidden tools and aliases fail before their handlers run.
|
|
11
|
+
- Document complete command/tool policies, account isolation and cleanup. Add synthetic and subprocess tests for import order, directory isolation, settings enforcement, local-only restrictions, materials sync, background work, diagnostics, safe removal and credential-free listings.
|
|
12
|
+
|
|
13
|
+
## 1.9.0
|
|
14
|
+
|
|
15
|
+
Course exports now contain what used to be left as links, with the reason for anything still missing.
|
|
16
|
+
|
|
17
|
+
- Moodle Page, Book and assignment text, and the rubric or marking guide students can see, are saved as Markdown. Images in them are downloaded to `assets/` (named by content hash, so duplicates are stored once). Links to this unit's pages, files, folders and books are followed instead of listed. Books are read through the print view, which Moodle does not count as a view.
|
|
18
|
+
- Folders are downloaded whole (`download_folder.php`, not counted as a view), keeping subfolders, case and original file names. They are refreshed at most weekly, and if the zip is unavailable the files are fetched one by one. Images that a notebook references but that are missing (or differ only in case) are reported.
|
|
19
|
+
- Images in Ed lesson pages are downloaded and de-duplicated, with links rewritten to relative paths. Failed downloads keep the remote link and are listed in the export index. Ed and whole-unit exports include `assets/`.
|
|
20
|
+
- Google Slides, Docs, Sheets and Drive files linked from a unit are exported read-only through the Drive API: Slides and Docs to PDF (Docs optionally DOCX with `monash config google_docs_format docx`), Sheets to XLSX, Drive files as they are. When a file is too large or an administrator blocks the API, the dedicated login browser's Google session is tried; its cookies stay in memory. Failures keep the link and record the reason. New `monash google login` / `status` / `logout` use a separate token with only `drive.readonly` (`logout` revokes it first); `monash sync --refresh-google` exports again.
|
|
21
|
+
- Ed units whose code matches a tracked Moodle unit are tracked automatically, including archived and combined units. This is why a past unit's Ed Lessons could be missing. A choice made in `monash courses` is kept. `monash export --sync` syncs the unit's Moodle and Ed content first.
|
|
22
|
+
- The export index lists everything not exported with its reason, and gains a statistics section (links files, remote images left, Google links exported or failed by reason), also in `--json`.
|
|
23
|
+
|
|
5
24
|
## 1.8.0
|
|
6
25
|
|
|
7
26
|
One export for a whole unit, and this package is now the only copy of the Moodle, Ed, Google and attendance code (the author's private server deployment depends on it instead of carrying its own copies).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: monash-study-kit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.10.0
|
|
4
4
|
Summary: Connect Monash Moodle and Ed to Claude, Codex, Cursor or any local MCP client via a local MCP server and CLI: deadlines, announcements, grades, full-text search over course materials and Ed posts, all on your own machine.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Waldo0926/monash-study-kit
|
|
6
6
|
Project-URL: Issues, https://github.com/Waldo0926/monash-study-kit/issues
|
|
@@ -71,6 +71,70 @@ The picture is real output of `monash todo` against a database filled with made-
|
|
|
71
71
|
|
|
72
72
|
For the original v1.1 security review and the [1.5 feature review checklist](docs/SECURITY-REVIEW-1.5-SCOPE.md), see [security documentation](docs/security.md). The earlier review does not automatically certify features added later.
|
|
73
73
|
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Multiple accounts / course materials only (1.10.0)
|
|
77
|
+
|
|
78
|
+
Without `--profile`, or with `--profile default`, the existing default account keeps its directory rules and features. Named accounts store separate databases, files, credentials and browser sessions under `<default data home>/profiles/<name>/`. The base still follows `MONASH_KIT_HOME` > `location.json` > the platform default. `default` is reserved; other names must match `[a-z0-9][a-z0-9_-]{0,31}`.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
monash --profile alice setup # login and course selection only
|
|
82
|
+
monash --profile alice google login # optional; drive.readonly only
|
|
83
|
+
monash --profile alice sync
|
|
84
|
+
monash --profile=alice export FIT1045 --sync
|
|
85
|
+
monash --profile alice mcp # local stdio, materials tools only
|
|
86
|
+
monash profile list # manage from the default account
|
|
87
|
+
monash profile remove alice # confirm, clear logins, keep materials
|
|
88
|
+
monash profile remove alice --all --yes # also remove databases and materials
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`MONASH_KIT_PROFILE=alice` also works; the command-line selection wins. Selection happens before importing service modules; an initialized Python process cannot switch accounts. Named profiles ignore individual directory overrides (`MONASH_KIT_DATA`, `MONASH_KIT_SECRETS`, `MONASH_KIT_FILES`, `MONASH_KIT_ED_DATA`, `MONASH_KIT_ED_TOKEN`, `ED_TOKEN`, and `files_dir`) to avoid sharing the default account's paths or credentials. Directories use mode 700 where supported.
|
|
92
|
+
|
|
93
|
+
Named profiles **stay local**: `remote`, `connect`, `setup claude`, and `move` are refused, and `setup` skips AI configuration. Sessions cannot be handed to remote services or AI configuration. Local stdio `mcp` can still be run manually. Profiles move together with the default data home rather than independently.
|
|
94
|
+
|
|
95
|
+
Named profiles force `materials_only=true`, even if settings or environment variables request false. The default account starts with false and can enable it with `monash config materials_only true`. While the mode is active, config can inspect this setting but cannot change it. To exit on the default account, temporarily override `MONASH_KIT_MATERIALS_ONLY=false`, then save false; named profiles cannot use this override.
|
|
96
|
+
|
|
97
|
+
Materials sync keeps Moodle files, Pages, Books, assignment descriptions and visible grading criteria, folders, linked Google files and Ed Lessons. It still reads Ed course lists to match unit codes, but never syncs discussions or replies. Gmail background sync, attendance reads and keepalive are skipped; Moodle login does not obtain a personal calendar link. `doctor --deep` checks materials and the search index only, skipping deadlines, submission status, grades and posts. Existing cached data is not deleted when enabling the mode.
|
|
98
|
+
|
|
99
|
+
Complete command policy in materials mode (refused commands return exit code 1):
|
|
100
|
+
|
|
101
|
+
- Allowed: `setup` (login and course selection), `login moodle/ed`, `google login/status/logout`, `sync`, `export`, `courses`, `status`, `doctor`, `open`, `library`, `config`, `grep`, `help`, `mcp`; `ed export/lessons/read/quiz`; `moodle ls/get`; `profile list/remove` from the default account.
|
|
102
|
+
- Config cannot change active `materials_only`; named profiles cannot change `files_dir`. `moodle get` only accepts course-resource/file entry points, rejecting grade pages and submission files.
|
|
103
|
+
- Refused: all `gmail` and `attendance` commands; `todo`, `due`, `semester`, `media`, `uninstall`, `update`, `connect`, `move`, all `remote`, `setup claude`; `ed courses/threads/search/show/new/following`; `moodle overview/due/calendar/assignments/grades/news/search/find/open/alerts/messages`. New commands require an explicit allowlist entry.
|
|
104
|
+
|
|
105
|
+
The MCP tool list is exactly `list_files`, `read_file`, `search_content`, `get_ed_lessons`, `export_ed_lessons`; `use_ed=false` removes the last two. Other tools and their legacy aliases fail when called. Export writes a local zip without changing upstream course data and retains its local-write MCP annotation. Personal study prompts are unavailable. There is no arbitrary Drive browsing or search command/tool: Google exports only follow course links during sync.
|
|
106
|
+
|
|
107
|
+
`profile list` checks only credential-file presence and disk usage, never reading or printing credential contents. Removal first revokes the target profile's Drive and Gmail Google OAuth authorizations in order. Any revocation failure stops removal and preserves **every local file** for a retry; an earlier successful remote revocation cannot be undone. Once all revocations succeed, `secrets/`, `browser-profile/` and `attendance-browser/` are removed. Only `--all` removes the complete profile, including materials and databases. The default account and other profiles are untouched; Moodle receives no logout or other request. Ed API tokens have no revocation interface here: manually delete them at [Ed API tokens](https://edstem.org/au/settings/api-tokens).
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## 1.9.0: more complete course exports
|
|
111
|
+
|
|
112
|
+
Moodle Pages, Book chapters, assignment descriptions and visible rubrics / marking guides are saved as Markdown. Moodle images are stored in course `assets/` by content hash, and internal links to Page, Resource, Folder and Book activities are followed. Folder downloads preserve original names, subdirectories and case, reuse files for seven days, and fall back to individual downloads. Missing notebook images, case mismatches, empty pages and hidden grading criteria are explained in the index.
|
|
113
|
+
|
|
114
|
+
Ed Lessons document / code images hosted on `edusercontent.com` are cached locally, deduplicated by content and limited to 200 MB each. Failed images keep their original URL and an error record. Both Ed-only and whole-unit exports include `assets/` with working relative references.
|
|
115
|
+
|
|
116
|
+
Google Slides and Docs export as PDF, Sheets as XLSX, and ordinary Drive files retain their format. Only file links found in Moodle and Ed Lessons are processed; Google Forms cannot be exported. Existing exports are reused while the file remains on disk. Successful file links disappear from generated link lists; failures retain their URL and a Chinese reason in the index.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
uv tool install --reinstall 'monash-study-kit[gmail]'
|
|
120
|
+
monash google login # bundled desktop OAuth client
|
|
121
|
+
monash google login --client client.json
|
|
122
|
+
monash google status
|
|
123
|
+
monash config google_docs_format docx # default: pdf; Google Docs only
|
|
124
|
+
monash sync FIT1045 --refresh-google # force Google exports to refresh
|
|
125
|
+
monash export FIT1045 --sync --json # sync this Moodle unit, then matching Ed units
|
|
126
|
+
monash google logout # revoke first, then remove the local token
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The bundled OAuth client is currently in Google's **Testing** state: its maintainer must add your Google account to the test-user list before you can authorize it. Google classifies `drive.readonly` as a **restricted scope**. It permits reading Drive files; this tool only downloads files linked from courses and does not enumerate your Drive. Google authorization shares the optional `[gmail]` dependency, but uses an independent flow and `secrets/google-drive-token.json` under the data home (`MONASH_KIT_SECRETS` can override the directory). Gmail authorization and `gmail-token.json` are unchanged. Credentials stay in the terminal / browser authorization flow; never paste them into chat.
|
|
130
|
+
|
|
131
|
+
Downloads use read-only GET requests. For Drive export-size or administrator restrictions, a fallback tries the existing Google session in the dedicated login browser. Cookies are used only in memory, never logged or separately saved, and redirects outside Google's domains stop. The fallback may still be blocked by policy; failures keep the original link and explain why. Missing authorization points to `monash google login`. Moodle Page, Resource and assignment `view.php` requests still record a view. Normal folder downloads and Book print requests avoid their `view.php`; the individual-file fallback must open the folder page and records a view.
|
|
132
|
+
|
|
133
|
+
Every sync checks newly discovered Ed units against tracked Moodle unit codes, including archived units and combined codes such as `FIT1045/FIT1053`; later user tracking choices are preserved. `monash export <unit> --sync` refreshes Moodle first, then matching Ed discussions and Lessons, before exporting. Ordinary exports use only local data. The README index includes all omission notes and failed Ed images, plus counts of link lists, remote Markdown images, Google links, successful exports and failures grouped by reason; `--json` exposes the same counts in `statistics`.
|
|
134
|
+
|
|
135
|
+
New tests use synthetic HTML / JSON, fake clients and mocked HTTP, with no real account requests. Ed code-challenge workspace downloads still require a real read-only response to establish the interface and are excluded, as are multi-account profiles.
|
|
136
|
+
|
|
137
|
+
|
|
74
138
|
## Two parts, one codebase
|
|
75
139
|
|
|
76
140
|
The same core (login, sync, queries) serves two kinds of "users":
|
|
@@ -35,6 +35,70 @@ The picture is real output of `monash todo` against a database filled with made-
|
|
|
35
35
|
|
|
36
36
|
For the original v1.1 security review and the [1.5 feature review checklist](docs/SECURITY-REVIEW-1.5-SCOPE.md), see [security documentation](docs/security.md). The earlier review does not automatically certify features added later.
|
|
37
37
|
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Multiple accounts / course materials only (1.10.0)
|
|
41
|
+
|
|
42
|
+
Without `--profile`, or with `--profile default`, the existing default account keeps its directory rules and features. Named accounts store separate databases, files, credentials and browser sessions under `<default data home>/profiles/<name>/`. The base still follows `MONASH_KIT_HOME` > `location.json` > the platform default. `default` is reserved; other names must match `[a-z0-9][a-z0-9_-]{0,31}`.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
monash --profile alice setup # login and course selection only
|
|
46
|
+
monash --profile alice google login # optional; drive.readonly only
|
|
47
|
+
monash --profile alice sync
|
|
48
|
+
monash --profile=alice export FIT1045 --sync
|
|
49
|
+
monash --profile alice mcp # local stdio, materials tools only
|
|
50
|
+
monash profile list # manage from the default account
|
|
51
|
+
monash profile remove alice # confirm, clear logins, keep materials
|
|
52
|
+
monash profile remove alice --all --yes # also remove databases and materials
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`MONASH_KIT_PROFILE=alice` also works; the command-line selection wins. Selection happens before importing service modules; an initialized Python process cannot switch accounts. Named profiles ignore individual directory overrides (`MONASH_KIT_DATA`, `MONASH_KIT_SECRETS`, `MONASH_KIT_FILES`, `MONASH_KIT_ED_DATA`, `MONASH_KIT_ED_TOKEN`, `ED_TOKEN`, and `files_dir`) to avoid sharing the default account's paths or credentials. Directories use mode 700 where supported.
|
|
56
|
+
|
|
57
|
+
Named profiles **stay local**: `remote`, `connect`, `setup claude`, and `move` are refused, and `setup` skips AI configuration. Sessions cannot be handed to remote services or AI configuration. Local stdio `mcp` can still be run manually. Profiles move together with the default data home rather than independently.
|
|
58
|
+
|
|
59
|
+
Named profiles force `materials_only=true`, even if settings or environment variables request false. The default account starts with false and can enable it with `monash config materials_only true`. While the mode is active, config can inspect this setting but cannot change it. To exit on the default account, temporarily override `MONASH_KIT_MATERIALS_ONLY=false`, then save false; named profiles cannot use this override.
|
|
60
|
+
|
|
61
|
+
Materials sync keeps Moodle files, Pages, Books, assignment descriptions and visible grading criteria, folders, linked Google files and Ed Lessons. It still reads Ed course lists to match unit codes, but never syncs discussions or replies. Gmail background sync, attendance reads and keepalive are skipped; Moodle login does not obtain a personal calendar link. `doctor --deep` checks materials and the search index only, skipping deadlines, submission status, grades and posts. Existing cached data is not deleted when enabling the mode.
|
|
62
|
+
|
|
63
|
+
Complete command policy in materials mode (refused commands return exit code 1):
|
|
64
|
+
|
|
65
|
+
- Allowed: `setup` (login and course selection), `login moodle/ed`, `google login/status/logout`, `sync`, `export`, `courses`, `status`, `doctor`, `open`, `library`, `config`, `grep`, `help`, `mcp`; `ed export/lessons/read/quiz`; `moodle ls/get`; `profile list/remove` from the default account.
|
|
66
|
+
- Config cannot change active `materials_only`; named profiles cannot change `files_dir`. `moodle get` only accepts course-resource/file entry points, rejecting grade pages and submission files.
|
|
67
|
+
- Refused: all `gmail` and `attendance` commands; `todo`, `due`, `semester`, `media`, `uninstall`, `update`, `connect`, `move`, all `remote`, `setup claude`; `ed courses/threads/search/show/new/following`; `moodle overview/due/calendar/assignments/grades/news/search/find/open/alerts/messages`. New commands require an explicit allowlist entry.
|
|
68
|
+
|
|
69
|
+
The MCP tool list is exactly `list_files`, `read_file`, `search_content`, `get_ed_lessons`, `export_ed_lessons`; `use_ed=false` removes the last two. Other tools and their legacy aliases fail when called. Export writes a local zip without changing upstream course data and retains its local-write MCP annotation. Personal study prompts are unavailable. There is no arbitrary Drive browsing or search command/tool: Google exports only follow course links during sync.
|
|
70
|
+
|
|
71
|
+
`profile list` checks only credential-file presence and disk usage, never reading or printing credential contents. Removal first revokes the target profile's Drive and Gmail Google OAuth authorizations in order. Any revocation failure stops removal and preserves **every local file** for a retry; an earlier successful remote revocation cannot be undone. Once all revocations succeed, `secrets/`, `browser-profile/` and `attendance-browser/` are removed. Only `--all` removes the complete profile, including materials and databases. The default account and other profiles are untouched; Moodle receives no logout or other request. Ed API tokens have no revocation interface here: manually delete them at [Ed API tokens](https://edstem.org/au/settings/api-tokens).
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## 1.9.0: more complete course exports
|
|
75
|
+
|
|
76
|
+
Moodle Pages, Book chapters, assignment descriptions and visible rubrics / marking guides are saved as Markdown. Moodle images are stored in course `assets/` by content hash, and internal links to Page, Resource, Folder and Book activities are followed. Folder downloads preserve original names, subdirectories and case, reuse files for seven days, and fall back to individual downloads. Missing notebook images, case mismatches, empty pages and hidden grading criteria are explained in the index.
|
|
77
|
+
|
|
78
|
+
Ed Lessons document / code images hosted on `edusercontent.com` are cached locally, deduplicated by content and limited to 200 MB each. Failed images keep their original URL and an error record. Both Ed-only and whole-unit exports include `assets/` with working relative references.
|
|
79
|
+
|
|
80
|
+
Google Slides and Docs export as PDF, Sheets as XLSX, and ordinary Drive files retain their format. Only file links found in Moodle and Ed Lessons are processed; Google Forms cannot be exported. Existing exports are reused while the file remains on disk. Successful file links disappear from generated link lists; failures retain their URL and a Chinese reason in the index.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv tool install --reinstall 'monash-study-kit[gmail]'
|
|
84
|
+
monash google login # bundled desktop OAuth client
|
|
85
|
+
monash google login --client client.json
|
|
86
|
+
monash google status
|
|
87
|
+
monash config google_docs_format docx # default: pdf; Google Docs only
|
|
88
|
+
monash sync FIT1045 --refresh-google # force Google exports to refresh
|
|
89
|
+
monash export FIT1045 --sync --json # sync this Moodle unit, then matching Ed units
|
|
90
|
+
monash google logout # revoke first, then remove the local token
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The bundled OAuth client is currently in Google's **Testing** state: its maintainer must add your Google account to the test-user list before you can authorize it. Google classifies `drive.readonly` as a **restricted scope**. It permits reading Drive files; this tool only downloads files linked from courses and does not enumerate your Drive. Google authorization shares the optional `[gmail]` dependency, but uses an independent flow and `secrets/google-drive-token.json` under the data home (`MONASH_KIT_SECRETS` can override the directory). Gmail authorization and `gmail-token.json` are unchanged. Credentials stay in the terminal / browser authorization flow; never paste them into chat.
|
|
94
|
+
|
|
95
|
+
Downloads use read-only GET requests. For Drive export-size or administrator restrictions, a fallback tries the existing Google session in the dedicated login browser. Cookies are used only in memory, never logged or separately saved, and redirects outside Google's domains stop. The fallback may still be blocked by policy; failures keep the original link and explain why. Missing authorization points to `monash google login`. Moodle Page, Resource and assignment `view.php` requests still record a view. Normal folder downloads and Book print requests avoid their `view.php`; the individual-file fallback must open the folder page and records a view.
|
|
96
|
+
|
|
97
|
+
Every sync checks newly discovered Ed units against tracked Moodle unit codes, including archived units and combined codes such as `FIT1045/FIT1053`; later user tracking choices are preserved. `monash export <unit> --sync` refreshes Moodle first, then matching Ed discussions and Lessons, before exporting. Ordinary exports use only local data. The README index includes all omission notes and failed Ed images, plus counts of link lists, remote Markdown images, Google links, successful exports and failures grouped by reason; `--json` exposes the same counts in `statistics`.
|
|
98
|
+
|
|
99
|
+
New tests use synthetic HTML / JSON, fake clients and mocked HTTP, with no real account requests. Ed code-challenge workspace downloads still require a real read-only response to establish the interface and are excluded, as are multi-account profiles.
|
|
100
|
+
|
|
101
|
+
|
|
38
102
|
## Two parts, one codebase
|
|
39
103
|
|
|
40
104
|
The same core (login, sync, queries) serves two kinds of "users":
|
|
@@ -36,6 +36,70 @@ Moodle和Ed始终**只读**:不会交作业、做测验或在Ed发帖。可选
|
|
|
36
36
|
|
|
37
37
|
之前的[1.1安全审计](docs/security.md)只覆盖当时的功能;新增的远程连接、邮箱与考勤另列有[1.5审查清单](docs/SECURITY-REVIEW-1.5-SCOPE.md),不能直接沿用旧版结论。
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## 多账号 / 只导课程资料(1.10.0)
|
|
42
|
+
|
|
43
|
+
不加 `--profile` 或使用 `--profile default`,仍是原来的默认账号,目录规则和功能不变。命名账号在默认数据目录的 `profiles/<名称>/` 中独立保存数据库、课件、凭据和浏览器会话;默认目录仍按 `MONASH_KIT_HOME` > `location.json` > 系统默认位置决定。`default` 是保留名,其他名称只能匹配 `[a-z0-9][a-z0-9_-]{0,31}`。
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
monash --profile alice setup # 只做登录和选课
|
|
47
|
+
monash --profile alice google login # 可选:只申请 drive.readonly
|
|
48
|
+
monash --profile alice sync
|
|
49
|
+
monash --profile=alice export FIT1045 --sync
|
|
50
|
+
monash --profile alice mcp # 本机 stdio,仅课程资料工具
|
|
51
|
+
monash profile list # 必须在默认账号下管理
|
|
52
|
+
monash profile remove alice # 确认后清除登录,保留资料
|
|
53
|
+
monash profile remove alice --all --yes # 同时删除资料和数据库
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
也支持环境变量 `MONASH_KIT_PROFILE=alice`;命令行选择优先。入口在导入服务模块前选定账号,不能在同一个 Python 进程中切换已经初始化的账号。命名账号忽略单项目录覆盖(`MONASH_KIT_DATA`、`MONASH_KIT_SECRETS`、`MONASH_KIT_FILES`、`MONASH_KIT_ED_DATA`、`MONASH_KIT_ED_TOKEN`、`ED_TOKEN` 和 `files_dir`),避免误用默认账号的目录或令牌。目录在支持的系统上设为 700 权限。
|
|
57
|
+
|
|
58
|
+
命名 profile **只留在本机**:拒绝 `remote`、`connect`、`setup claude` 和 `move`,`setup` 跳过 AI 软件配置;不能把会话交给远程服务或 AI 软件配置。`mcp` 仍可在本机手动运行。profile 随默认数据目录整体移动,不单独搬家。
|
|
59
|
+
|
|
60
|
+
命名 profile 强制开启 `materials_only`,设置文件或环境变量也关不掉。默认账号的该设置默认是 false,可以用 `monash config materials_only true` 开启;资料模式运行中只能查看 `materials_only`,不能用 config 修改。默认账号如需退出,可先用 `MONASH_KIT_MATERIALS_ONLY=false` 临时覆盖,再保存 false;命名账号不接受该覆盖。
|
|
61
|
+
|
|
62
|
+
资料模式同步照常获取 Moodle 课件、Page、Book、作业说明和可见评分细则、文件夹、课程链接中的 Google 文件和 Ed Lessons。Ed 仍拉课程列表以匹配课号,但不抓 threads / replies;跳过 Gmail 后台同步、考勤读取和续期,Moodle 登录时也不获取个人日历。`doctor --deep` 只检查课件和全文索引,不读个人截止、提交状态、成绩或帖子。已有缓存不会因此被删除。
|
|
63
|
+
|
|
64
|
+
资料模式的完整命令清单(被拒绝时退出码 1):
|
|
65
|
+
|
|
66
|
+
- 允许:`setup`(仅登录选课)、`login moodle/ed`、`google login/status/logout`、`sync`、`export`、`courses`、`status`、`doctor`、`open`、`library`、`config`、`grep`、`help`、`mcp`;`ed export/lessons/read/quiz`;`moodle ls/get`;默认账号下的 `profile list/remove`。
|
|
67
|
+
- `config` 不能修改当前启用的 `materials_only`;命名账号也不能修改 `files_dir`。`moodle get` 只接受课件资源和文件入口,拒绝成绩页和提交文件。
|
|
68
|
+
- 拒绝:全部 `gmail`、全部 `attendance`;`todo`、`due`、`semester`、`media`、`uninstall`、`update`、`connect`、`move`、全部 `remote`、`setup claude`;`ed courses/threads/search/show/new/following`;`moodle overview/due/calendar/assignments/grades/news/search/find/open/alerts/messages`。未来新增命令也需显式加入白名单。
|
|
69
|
+
|
|
70
|
+
MCP 只注册 `list_files`、`read_file`、`search_content`、`get_ed_lessons`、`export_ed_lessons`;`use_ed=false` 时再去掉后两项。其余工具(包括旧别名)调用均报错。导出只在本机写 zip,不修改上游课程;仍保留其本地写文件的 MCP 标注。个人学习预设提示不在此模式提供。没有任意浏览或搜索 Drive 的命令或工具,Google 文件只在同步时按课程链接导出。
|
|
71
|
+
|
|
72
|
+
`profile list` 只检查 Moodle / Ed / Google 凭据文件是否存在及占用空间,不读取或打印内容。`profile remove` 会先依次吊销目标 profile 的 Drive 和 Gmail Google OAuth 授权;任何一个失败时停止,**本机文件一律保留**,可重试(此前已成功的远端吊销无法撤回)。全部成功后删除目标的 `secrets/`、`browser-profile/`、`attendance-browser/`;只有 `--all` 才删整个 profile,默认账号和其他 profile 不受影响。不向 Moodle 发送注销或任何其他请求。Ed 的 API 令牌没有吊销接口,请到 [Ed API tokens](https://edstem.org/au/settings/api-tokens) 手动删除。
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## 1.9.0:补全课程资料导出
|
|
76
|
+
|
|
77
|
+
- Moodle 的 Page、Book 章节、作业说明和学生能看到的 rubric / marking guide 存成 Markdown;正文里的 Moodle 图片存到课程的 `assets/`,同内容去重。指向本课程 Page、Resource、Folder、Book 的内部链接也会跟进。
|
|
78
|
+
- 文件夹优先整包下载,保留 notebook、图片的原名、子目录和大小写,7 天内跳过重复下载;失败时逐文件下载。索引会说明 notebook 图片缺失、大小写不一致、正文为空或评分细则未显示等情况。
|
|
79
|
+
- Ed Lessons 的 document / code 正文图片只下载 Ed 自己的 `edusercontent.com` 地址,按内容去重并缓存 URL,每张最多 200 MB。下载失败保留原链接并记录原因;独立 Ed 导出和整课导出都包含 `assets/`,图片使用相对路径。
|
|
80
|
+
- Google Slides / Docs 默认导出 PDF,Sheets 导出 XLSX,Drive 普通文件按原格式下载。只处理 Moodle 和 Ed Lessons 里出现过的文件链接;Google 表单不能导出。文件还在时跳过,`monash sync --refresh-google` 强制重新导出。
|
|
81
|
+
- 每次同步检查新出现的 Ed 课程:课号与已跟踪 Moodle 课程相同就自动跟踪,包括归档课程和 `FIT1045/FIT1053` 这样的联合课号;处理过的课程保留用户选择。
|
|
82
|
+
- `monash export FIT1045 --sync` 先同步这门 Moodle 课及对应 Ed 课再导出。普通导出继续只读本机缓存。README 索引列出未导出内容和原因,并统计链接清单数量、Markdown 远程图片数、Google 总数 / 成功 / 按原因分组的失败数;`--json` 的 `statistics` 提供相同数字。
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Google 授权依赖与 Gmail 共用,但授权流程和 token 分开
|
|
86
|
+
uv tool install --reinstall 'monash-study-kit[gmail]'
|
|
87
|
+
monash google login # 默认使用安装包里的桌面 OAuth 客户端
|
|
88
|
+
monash google login --client client.json # 也可以用自己的桌面客户端
|
|
89
|
+
monash google status
|
|
90
|
+
monash config google_docs_format docx # 默认 pdf;只影响 Google Docs
|
|
91
|
+
monash sync FIT1045 --refresh-google
|
|
92
|
+
monash export FIT1045 --sync --json
|
|
93
|
+
monash google logout # 先向 Google 吊销,再删除本机令牌
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
自带 OAuth 客户端目前处于 Google 的“测试”状态,授权账号需要先由客户端维护者加入测试用户名单。`drive.readonly` 在 Google 属于受限 scope,允许读取 Drive 文件;本工具仅下载课程链接里出现的文件,不遍历整个 Drive。令牌单独存在数据目录的 `secrets/google-drive-token.json`(可通过 `MONASH_KIT_SECRETS` 改位置),不修改 Gmail 的授权流程或 `gmail-token.json`。令牌只在终端 / 浏览器授权流程中流转,不要贴进聊天。
|
|
97
|
+
|
|
98
|
+
课程下载走只读 GET。Drive API 报大小限制或管理员限制时,会尝试专用登录浏览器中已有的 Google 会话;cookie 只在内存使用,不写日志或另存文件,跳转离开 Google 域名会停止。后备路径不能保证绕过管理员限制,仍失败时保留原链接并在索引说明原因。未授权时提示 `monash google login`。Moodle Page、Resource、作业仍会打开 `view.php`,Moodle 会记录查看;文件夹正常下载和 Book 打印视图不打开各自的 `view.php`。文件夹整包下载失败后的逐文件回退需要打开文件夹页,也会记录一次查看。
|
|
99
|
+
|
|
100
|
+
本版新增测试均使用合成 HTML / JSON、假客户端或假 HTTP,不访问真实课程、Google 账号或 Ed 工作区。Ed code challenge 工作区下载暂未实现,仍需真实只读响应确认接口;多账号 profile 等不在本版范围内。
|
|
101
|
+
|
|
102
|
+
|
|
39
103
|
## 它由两部分组成
|
|
40
104
|
|
|
41
105
|
同一套底层代码(登录、同步、查询),给两种“用户”用:
|
|
@@ -41,7 +41,7 @@ Issues = "https://github.com/Waldo0926/monash-study-kit/issues"
|
|
|
41
41
|
Changelog = "https://github.com/Waldo0926/monash-study-kit/blob/main/CHANGELOG.md"
|
|
42
42
|
|
|
43
43
|
[project.scripts]
|
|
44
|
-
monash = "monash_study_kit.
|
|
44
|
+
monash = "monash_study_kit.entry:main"
|
|
45
45
|
|
|
46
46
|
[dependency-groups]
|
|
47
47
|
# tzdata:Windows 上跑考勤相关的测试要它
|
|
@@ -65,7 +65,7 @@ def main() -> None:
|
|
|
65
65
|
fail(f"包里不该有 {n}")
|
|
66
66
|
if f"\nVersion: {version}\n" not in meta:
|
|
67
67
|
fail("METADATA 里的版本号不对")
|
|
68
|
-
if "monash = monash_study_kit.
|
|
68
|
+
if "monash = monash_study_kit.entry:main" not in entry:
|
|
69
69
|
fail("没有 monash 命令的入口")
|
|
70
70
|
if "Description-Content-Type: text/markdown" not in meta or "## Installation" not in meta:
|
|
71
71
|
fail("PyPI 页面会没有 README")
|
|
@@ -181,6 +181,9 @@ def login_moodle(interactive: bool = True, timeout: float = 300, log=print) -> d
|
|
|
181
181
|
|
|
182
182
|
def _save_calendar_url(client: MoodleClient, log) -> None:
|
|
183
183
|
"""顺手存下 iCal 订阅链接:以后会话过期了,截止日期还能靠它拿到。"""
|
|
184
|
+
from .paths import load_settings
|
|
185
|
+
if load_settings().get("materials_only"):
|
|
186
|
+
return
|
|
184
187
|
from . import features as F
|
|
185
188
|
if F.load_calendar_url():
|
|
186
189
|
return
|
|
@@ -49,7 +49,7 @@ from .edlib import EdAuthError
|
|
|
49
49
|
from .moodlelib import FILES_DIR, MoodleAuthError, MoodleClient, MoodleError, db_connect
|
|
50
50
|
from .output import emit_json, local_time, relative, table, want_json
|
|
51
51
|
from .paths import HOME, ensure_private_dir, load_settings, save_settings
|
|
52
|
-
from .syncer import course_code, course_folder
|
|
52
|
+
from .syncer import course_code, course_folder, write_links_md
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def _fmt_secs(s: int | None) -> str:
|
|
@@ -128,7 +128,7 @@ def _pick(items: list[str], chosen: set[int], title: str) -> set[int] | None:
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
def choose_courses(interactive: bool = True) -> None:
|
|
131
|
-
"""Moodle 默认跟踪本学期的课,Ed
|
|
131
|
+
"""Moodle 默认跟踪本学期的课,Ed 按已跟踪的 Moodle 课号匹配;interactive 时让人改。"""
|
|
132
132
|
try:
|
|
133
133
|
client, con = MoodleClient(), db_connect()
|
|
134
134
|
courses = sorted(jobs.load_courses(client, con), key=lambda c: -(c.get("startdate") or 0))
|
|
@@ -152,8 +152,7 @@ def choose_courses(interactive: bool = True) -> None:
|
|
|
152
152
|
conn = edlib.db_connect()
|
|
153
153
|
ecs = ed.courses()
|
|
154
154
|
edsync.upsert_courses(conn, ecs)
|
|
155
|
-
|
|
156
|
-
edsync.auto_track(conn, ecs)
|
|
155
|
+
edsync.auto_track(conn, ecs)
|
|
157
156
|
rows = [dict(r) for r in conn.execute("SELECT id, code, name, status, tracked FROM courses "
|
|
158
157
|
"ORDER BY status != 'active', id DESC")]
|
|
159
158
|
if interactive:
|
|
@@ -182,7 +181,9 @@ def cmd_setup(args):
|
|
|
182
181
|
code = claude_setup.install_code()
|
|
183
182
|
return 0 if desktop or code else 1
|
|
184
183
|
from . import location
|
|
185
|
-
|
|
184
|
+
from .paths import is_default_profile
|
|
185
|
+
materials = load_settings().get("materials_only", False)
|
|
186
|
+
if is_default_profile() and location.first_run():
|
|
186
187
|
print(f"Monash 学习助手 {__version__}\n")
|
|
187
188
|
choice = location.ask()
|
|
188
189
|
if choice is not None:
|
|
@@ -209,6 +210,9 @@ def cmd_setup(args):
|
|
|
209
210
|
login_moodle()
|
|
210
211
|
print("\n== 3/4 选课 ==")
|
|
211
212
|
choose_courses(interactive=_yes("默认跟踪本学期的课。要自己挑吗?", default=False))
|
|
213
|
+
if materials:
|
|
214
|
+
print("\n完成!已登录并选课。只导课程资料模式下,请运行 monash sync,再用 monash export <课号> 导出。")
|
|
215
|
+
return 0
|
|
212
216
|
print("\n== 4/4 接进 Claude ==")
|
|
213
217
|
claude_setup.install_code()
|
|
214
218
|
claude_setup.install_desktop()
|
|
@@ -257,6 +261,8 @@ def cmd_status(args):
|
|
|
257
261
|
def _optional_status() -> dict:
|
|
258
262
|
"""开了的可选功能各给一行;坏了也不影响 Moodle 和 Ed 的状态。"""
|
|
259
263
|
settings, out = load_settings(), {}
|
|
264
|
+
if settings.get("materials_only"):
|
|
265
|
+
return out
|
|
260
266
|
try:
|
|
261
267
|
if settings.get("gmail_enabled"):
|
|
262
268
|
from . import gmail
|
|
@@ -291,10 +297,11 @@ def cmd_sync(args):
|
|
|
291
297
|
client, con = MoodleClient(), db_connect()
|
|
292
298
|
courses = jobs.load_courses(client, con)
|
|
293
299
|
only = [F.find_course(courses, r) for r in args.courses] if args.courses else None
|
|
294
|
-
|
|
300
|
+
con.close()
|
|
301
|
+
st = jobs.sync_moodle(only=only, dry_run=args.dry_run, refresh_google=getattr(args, "refresh_google", False))
|
|
295
302
|
print(f"新下载 {st['downloaded']} 个文件,{st['bytes'] / 1e6:.1f} MB")
|
|
296
303
|
return
|
|
297
|
-
st = jobs.sync_all()
|
|
304
|
+
st = jobs.sync_all(refresh_google=True) if getattr(args, "refresh_google", False) else jobs.sync_all()
|
|
298
305
|
m, e, idx = st.get("moodle") or {}, st.get("ed") or {}, st.get("index") or {}
|
|
299
306
|
print("\n同步完成:" + ",".join(x for x in [
|
|
300
307
|
f"Ed 新帖 {e.get('new_threads', 0)}、新回复 {e.get('new_replies', 0)}" if "ed" not in st["errors"] else "",
|
|
@@ -329,6 +336,8 @@ def cmd_open(args):
|
|
|
329
336
|
|
|
330
337
|
def parse_setting(key: str, raw: str, current):
|
|
331
338
|
"""按默认值的类型解析。数字一律先当小数读:阿德莱德是 UTC+9.5,auto_sync_hours 也可以写 0.5。"""
|
|
339
|
+
if key == "google_docs_format" and raw not in {"pdf", "docx"}:
|
|
340
|
+
raise ValueError("google_docs_format 只能是 pdf 或 docx")
|
|
332
341
|
if isinstance(current, bool):
|
|
333
342
|
if raw.lower() in ("true", "yes", "1", "on"):
|
|
334
343
|
return True
|
|
@@ -626,12 +635,40 @@ def cmd_due(args):
|
|
|
626
635
|
return emit_json(items) if want_json(args) else _print_due(items)
|
|
627
636
|
|
|
628
637
|
|
|
638
|
+
def sync_export_course(ref: str, log=print) -> None:
|
|
639
|
+
"""先同步指定 Moodle 课,再同步对应 Ed 课,最后补导 Ed 的 Google 链接。"""
|
|
640
|
+
from . import google_export
|
|
641
|
+
client, con = MoodleClient(), db_connect()
|
|
642
|
+
try:
|
|
643
|
+
courses = jobs.load_courses(client, con)
|
|
644
|
+
course = F.find_course(courses, ref)
|
|
645
|
+
jobs.sync_moodle(only=[course], log=log)
|
|
646
|
+
if jobs.have_ed_token():
|
|
647
|
+
jobs.sync_ed(log=log, course_code=course_code(course))
|
|
648
|
+
econ = edlib.db_connect()
|
|
649
|
+
try:
|
|
650
|
+
google_export.sync_course(con, course, ed_conn=econ, log=log)
|
|
651
|
+
write_links_md(con, course["id"], course_folder(course))
|
|
652
|
+
finally:
|
|
653
|
+
econ.close()
|
|
654
|
+
elif load_settings().get("use_ed", True):
|
|
655
|
+
log("还没设置 Ed 令牌(monash login ed;不用 Ed 就 monash config use_ed false)")
|
|
656
|
+
finally:
|
|
657
|
+
con.close()
|
|
658
|
+
|
|
659
|
+
|
|
629
660
|
def cmd_export(args):
|
|
630
661
|
"""一门课的 Moodle 课件 + Ed Lessons 合成一份课程资料(zip 或文件夹),附索引。只用本机已同步的数据。"""
|
|
631
662
|
from . import export as X, moodlelib
|
|
632
663
|
try:
|
|
633
|
-
|
|
634
|
-
|
|
664
|
+
if getattr(args, "sync", False):
|
|
665
|
+
sync_export_course(args.course, log=(lambda text: print(text, file=sys.stderr)))
|
|
666
|
+
mcon, econ = moodlelib.db_connect(), edlib.db_connect()
|
|
667
|
+
try:
|
|
668
|
+
d = X.export(args.course, args.to, as_dir=args.dir, moodle_con=mcon, ed_conn=econ)
|
|
669
|
+
finally:
|
|
670
|
+
mcon.close()
|
|
671
|
+
econ.close()
|
|
635
672
|
except LookupError as e:
|
|
636
673
|
print(e, file=sys.stderr)
|
|
637
674
|
return 1
|
|
@@ -870,7 +907,7 @@ class _Parser(argparse.ArgumentParser):
|
|
|
870
907
|
|
|
871
908
|
|
|
872
909
|
def build_parser() -> argparse.ArgumentParser:
|
|
873
|
-
from . import cli_attendance, cli_ed, cli_gmail
|
|
910
|
+
from . import cli_attendance, cli_ed, cli_gmail, cli_google, cli_profile
|
|
874
911
|
ap = _Parser(prog="monash", description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
875
912
|
ap.add_argument("--version", action="version", version=f"monash-study-kit {__version__}")
|
|
876
913
|
sub = ap.add_subparsers(dest="cmd")
|
|
@@ -897,6 +934,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
897
934
|
p = cmd(sub, "sync", cmd_sync, help="同步 Ed + Moodle + 全文索引")
|
|
898
935
|
p.add_argument("courses", nargs="*", help="只同步这几门 Moodle 课")
|
|
899
936
|
p.add_argument("--dry-run", action="store_true", help="只列出 Moodle 会下载什么")
|
|
937
|
+
p.add_argument("--refresh-google", action="store_true", help="强制重新导出 Google 文件")
|
|
900
938
|
cmd(sub, "courses", cmd_courses, help="选要跟踪的课")
|
|
901
939
|
p = cmd(sub, "todo", cmd_todo, json_flag=True, help="本周待办")
|
|
902
940
|
p.add_argument("--days", type=int, default=7)
|
|
@@ -912,6 +950,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
912
950
|
p.add_argument("--to", help="保存到哪个文件夹(默认“下载”)")
|
|
913
951
|
p.add_argument("--dir", action="store_true", help="写成文件夹,不打 zip")
|
|
914
952
|
p.add_argument("--open", action="store_true", help="导出后在文件管理器里显示")
|
|
953
|
+
p.add_argument("--sync", action="store_true", help="导出前同步这门 Moodle 和 Ed 课程")
|
|
915
954
|
p = cmd(sub, "media", cmd_media, help="录播:YouTube 字幕、Zoom 录像下载和转写(要装 [media])")
|
|
916
955
|
p.add_argument("--limit", type=int, default=0, help="这次最多转写几个视频")
|
|
917
956
|
p.add_argument("--match", help="只转写路径里含这段文字的视频")
|
|
@@ -973,7 +1012,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
973
1012
|
p.add_argument("conversation", nargs="?", type=int); p.add_argument("--limit", type=int, default=20)
|
|
974
1013
|
p = cmd(m, "ls", cmd_m_ls, help="本地已同步的课件"); p.add_argument("course"); p.add_argument("week", nargs="?")
|
|
975
1014
|
|
|
1015
|
+
cli_profile.add_commands(sub.add_parser("profile", help="管理本机命名账号").add_subparsers(dest="profile_cmd", required=True))
|
|
976
1016
|
cli_ed.add_commands(sub.add_parser("ed", help="Ed 查询").add_subparsers(dest="ecmd", required=True))
|
|
1017
|
+
cli_google.add_commands(sub.add_parser("google", help="Google 课程文件只读授权").add_subparsers(dest="google_cmd", required=True))
|
|
977
1018
|
cli_gmail.add_commands(sub.add_parser("gmail", help="Gmail 同步、离线搜索与可选邮箱操作").add_subparsers(dest="gcmd", required=True))
|
|
978
1019
|
cli_attendance.add_commands(sub.add_parser("attendance", help="考勤门户:登录、状态、读取签到记录(要装 [attendance])")
|
|
979
1020
|
.add_subparsers(dest="acmd", required=True))
|
|
@@ -988,7 +1029,7 @@ def _print_update_notice() -> None:
|
|
|
988
1029
|
print(f"\n↑ {msg}", file=sys.stderr)
|
|
989
1030
|
|
|
990
1031
|
|
|
991
|
-
def
|
|
1032
|
+
def setup_streams() -> None:
|
|
992
1033
|
for stream in (sys.stdout, sys.stderr):
|
|
993
1034
|
try:
|
|
994
1035
|
if stream.isatty():
|
|
@@ -997,8 +1038,17 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
997
1038
|
stream.reconfigure(encoding="utf-8") # 管道/重定向:Windows 默认是本地代码页,中文会丢
|
|
998
1039
|
except (AttributeError, ValueError):
|
|
999
1040
|
pass
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
def main(argv: list[str] | None = None) -> int:
|
|
1044
|
+
setup_streams()
|
|
1000
1045
|
ap = build_parser()
|
|
1001
1046
|
args = ap.parse_args(argv)
|
|
1047
|
+
from .materials_policy import command_error
|
|
1048
|
+
error = command_error(args, load_settings())
|
|
1049
|
+
if error:
|
|
1050
|
+
print(error, file=sys.stderr)
|
|
1051
|
+
return 1
|
|
1002
1052
|
ensure_private_dir(HOME) # 库里有同学的名字和私密帖,只给自己读
|
|
1003
1053
|
quiet = args.cmd in ("mcp", "update", "doctor", "remote", "library")
|
|
1004
1054
|
if not quiet:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Google 课程文件的独立授权命令。"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from . import google_export as G
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def run(args):
|
|
12
|
+
try:
|
|
13
|
+
if args.google_cmd == "login":
|
|
14
|
+
client = Path(args.client).expanduser() if args.client else Path(__file__).with_name("google_client.json")
|
|
15
|
+
result = G.login(client)
|
|
16
|
+
elif args.google_cmd == "logout":
|
|
17
|
+
result = G.logout()
|
|
18
|
+
else:
|
|
19
|
+
result = G.status()
|
|
20
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
21
|
+
return 0
|
|
22
|
+
except (G.GoogleError, OSError, ValueError) as e:
|
|
23
|
+
print(str(e) if isinstance(e, G.GoogleError) else "Google 授权文件无法读取,请检查客户端 JSON", file=sys.stderr)
|
|
24
|
+
return 1
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def add_commands(sub):
|
|
28
|
+
for name, help_text in (("login", "授权 Google Drive 只读导出"), ("status", "查看授权和 scope"), ("logout", "吊销授权并删除令牌")):
|
|
29
|
+
parser = sub.add_parser(name, help=help_text)
|
|
30
|
+
parser.set_defaults(fn=run)
|
|
31
|
+
if name == "login":
|
|
32
|
+
parser.add_argument("--client", metavar="JSON", help="Google 桌面应用客户端 JSON")
|