monash-study-kit 1.9.0__tar.gz → 1.11.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 (148) hide show
  1. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/CHANGELOG.md +18 -0
  2. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/PKG-INFO +39 -2
  3. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/README.md +38 -1
  4. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/README.zh-CN.md +37 -1
  5. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/pyproject.toml +1 -1
  6. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/scripts/check_dist.py +1 -1
  7. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/__init__.py +1 -1
  8. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/__main__.py +1 -1
  9. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/browser_login.py +3 -0
  10. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/cdp.py +17 -6
  11. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/cli.py +29 -6
  12. monash_study_kit-1.11.0/src/monash_study_kit/cli_profile.py +118 -0
  13. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/doctor.py +3 -1
  14. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/doctor_deep.py +2 -0
  15. monash_study_kit-1.11.0/src/monash_study_kit/entry.py +89 -0
  16. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/export.py +85 -11
  17. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/google_export.py +28 -11
  18. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/help_menu.py +10 -0
  19. monash_study_kit-1.11.0/src/monash_study_kit/home.py +41 -0
  20. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/jobs.py +12 -2
  21. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/lessons.py +48 -1
  22. monash_study_kit-1.11.0/src/monash_study_kit/materials_policy.py +57 -0
  23. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/mcp_server.py +25 -8
  24. monash_study_kit-1.11.0/src/monash_study_kit/mdhtml.py +178 -0
  25. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/paths.py +16 -27
  26. monash_study_kit-1.11.0/src/monash_study_kit/pdfrender.py +174 -0
  27. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/student_tools.py +2 -0
  28. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_course_export.py +1 -0
  29. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_ed_export.py +24 -2
  30. monash_study_kit-1.11.0/tests/test_export_pdf.py +443 -0
  31. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_google_export.py +44 -1
  32. monash_study_kit-1.11.0/tests/test_profiles.py +448 -0
  33. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  34. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  35. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  36. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/.github/pull_request_template.md +0 -0
  37. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/.github/workflows/release.yml +0 -0
  38. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/.github/workflows/test.yml +0 -0
  39. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/.gitignore +0 -0
  40. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/CODE_OF_CONDUCT.md +0 -0
  41. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/CONTRIBUTING.md +0 -0
  42. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/LICENSE +0 -0
  43. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/PRIVACY.md +0 -0
  44. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/SECURITY.md +0 -0
  45. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/SECURITY-REVIEW-1.5-SCOPE.md +0 -0
  46. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/adr/0001-one-shared-core.md +0 -0
  47. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/adr/0002-read-only-public-package.md +0 -0
  48. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/adr/0003-release-from-a-tag.md +0 -0
  49. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/adr/0004-confirmed-mail-and-attendance-actions.md +0 -0
  50. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/adr/README.md +0 -0
  51. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/gmail-foundation.md +0 -0
  52. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/google-and-attendance-setup.md +0 -0
  53. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/panels-library-remote.md +0 -0
  54. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/releasing.md +0 -0
  55. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/screenshots/todo.png +0 -0
  56. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/docs/security.md +0 -0
  57. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/glama.json +0 -0
  58. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/scripts/measure_tokens.py +0 -0
  59. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/scripts/smoke_test.py +0 -0
  60. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/skills/monash-study-kit/SKILL.md +0 -0
  61. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/attendance.py +0 -0
  62. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/attendance_assets/PROVENANCE.md +0 -0
  63. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/attendance_assets/extract-rows.js +0 -0
  64. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/attendance_assets/shared.js +0 -0
  65. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/attendance_auto.py +0 -0
  66. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/attendance_evidence.py +0 -0
  67. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/attendance_http.py +0 -0
  68. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/claude_setup.py +0 -0
  69. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/cli_attendance.py +0 -0
  70. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/cli_ed.py +0 -0
  71. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/cli_gmail.py +0 -0
  72. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/cli_google.py +0 -0
  73. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/clients.py +0 -0
  74. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/content_index.py +0 -0
  75. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/edexport.py +0 -0
  76. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/edlib.py +0 -0
  77. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/edquery.py +0 -0
  78. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/edsync.py +0 -0
  79. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/features.py +0 -0
  80. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/gmail.py +0 -0
  81. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/gmail_tools.py +0 -0
  82. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/google_client.json +0 -0
  83. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/htmldom.py +0 -0
  84. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/htmlmd.py +0 -0
  85. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/lesson_reader.py +0 -0
  86. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/library.py +0 -0
  87. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/location.py +0 -0
  88. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/moodle_content.py +0 -0
  89. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/moodlelib.py +0 -0
  90. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/output.py +0 -0
  91. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/recordings.py +0 -0
  92. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/remote.py +0 -0
  93. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/semester.py +0 -0
  94. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/service_actions.py +0 -0
  95. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/service_jobs.py +0 -0
  96. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/service_setup.py +0 -0
  97. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/student_services.py +0 -0
  98. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/syncer.py +0 -0
  99. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/textextract.py +0 -0
  100. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/todo.py +0 -0
  101. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/transcribe.py +0 -0
  102. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/ui/panel.html +0 -0
  103. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/update_check.py +0 -0
  104. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/webnotes.py +0 -0
  105. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/src/monash_study_kit/widgets.py +0 -0
  106. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/conftest.py +0 -0
  107. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_attendance_browser.py +0 -0
  108. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_attendance_fast.py +0 -0
  109. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_attendance_parity.py +0 -0
  110. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_cdp.py +0 -0
  111. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_cli.py +0 -0
  112. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_clients.py +0 -0
  113. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_content_index.py +0 -0
  114. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_doctor.py +0 -0
  115. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_doctor_deep.py +0 -0
  116. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_ed_auth.py +0 -0
  117. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_ed_markdown.py +0 -0
  118. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_ed_query.py +0 -0
  119. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_ed_quiz.py +0 -0
  120. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_ed_tracking.py +0 -0
  121. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_feature_cli.py +0 -0
  122. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_features.py +0 -0
  123. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_gmail.py +0 -0
  124. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_help_menu.py +0 -0
  125. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_layout.py +0 -0
  126. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_lesson_reader.py +0 -0
  127. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_library.py +0 -0
  128. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_location.py +0 -0
  129. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_mcp.py +0 -0
  130. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_moodle_content.py +0 -0
  131. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_panels.py +0 -0
  132. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_recordings.py +0 -0
  133. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_remote.py +0 -0
  134. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_removed_files.py +0 -0
  135. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_security.py +0 -0
  136. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_semester.py +0 -0
  137. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_service_setup.py +0 -0
  138. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_setup.py +0 -0
  139. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_shared_core.py +0 -0
  140. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_skill.py +0 -0
  141. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_student_gmail.py +0 -0
  142. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_student_tools.py +0 -0
  143. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_sync_robustness.py +0 -0
  144. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_todo.py +0 -0
  145. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_update_check.py +0 -0
  146. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_webnotes.py +0 -0
  147. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/tests/test_without_ed.py +0 -0
  148. {monash_study_kit-1.9.0 → monash_study_kit-1.11.0}/uv.lock +0 -0
@@ -2,6 +2,24 @@
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.11.0
6
+
7
+ - Course exports now turn Markdown body pages, link lists, quizzes and the index into PDFs by default, keeping original course files. `monash export --format pdf|both|md` overrides the `export_format` setting; synced Markdown and MCP indexing are unchanged.
8
+ - PDFs are printed offline with one isolated temporary Chrome / Edge / Brave process per export. Local exported images are embedded, raw HTML is escaped, and remote requests are blocked. Without a browser, exports fall back to Markdown with an explanation in the index and terminal.
9
+ - Cache PDFs by the complete printable HTML and embedded image contents under `data/pdf-cache/`, evicting the oldest entries above 500 MB. JSON exports report generated and cached PDF counts and the fallback reason.
10
+
11
+ ## 1.10.1
12
+
13
+ - Ed images whose address has no file extension are saved as `.png`, `.jpg`, `.gif`, `.webp` or `.svg` according to their content, instead of `.img`, which viewers did not show. Images saved as `.img` by earlier versions are renamed on the next sync, and the references in the Markdown pages are updated.
14
+
15
+ ## 1.10.0
16
+
17
+ - 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.
18
+ - 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.
19
+ - 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.
20
+ - 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.
21
+ - 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.
22
+
5
23
  ## 1.9.0
6
24
 
7
25
  Course exports now contain what used to be left as links, with the reason for anything still missing.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: monash-study-kit
3
- Version: 1.9.0
3
+ Version: 1.11.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
@@ -72,6 +72,41 @@ The picture is real output of `monash todo` against a database filled with made-
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
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
+
75
110
  ## 1.9.0: more complete course exports
76
111
 
77
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.
@@ -95,6 +130,8 @@ The bundled OAuth client is currently in Google's **Testing** state: its maintai
95
130
 
96
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.
97
132
 
133
+ `monash export <unit>` now exports Markdown body pages, link lists, quizzes and the index as **PDF by default**, alongside the original course files. Install Chrome, Edge or Brave to generate PDFs; if no browser is found, the export falls back to Markdown and explains this in the index and terminal. Use `--format both` to include PDF and Markdown, or `--format md` for Markdown only. For example, `monash config export_format both` saves PDF and Markdown as the default. Synced Markdown stays unchanged on your computer for AI, search and MCP. PDF generation runs offline in a fresh temporary browser profile, embeds only local exported images and omits remote images (keeping their alt text). PDFs are cached under `data/pdf-cache/` (up to 500 MB); `--json` includes `pdf.generated`, `pdf.cached` and `pdf.skipped_reason`. `monash ed export` keeps its existing behavior.
134
+
98
135
  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`.
99
136
 
100
137
  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.
@@ -449,7 +486,7 @@ You can also query directly in the terminal without any AI:
449
486
  | `monash ed lessons FIT2109` / `quiz FIT2109` | Ed lesson progress / quiz questions (for revision) |
450
487
  | `monash ed read FIT2109 "W3 Pre-Class"` | A whole lesson as Markdown: text slides, reading pages and PDFs in order, plus its quiz questions |
451
488
  | `monash ed export FIT2109 [--module "Week 3"] [--open]` | Zip a unit's Ed materials by week into Downloads |
452
- | `monash export FIT1043 [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
489
+ | `monash export FIT1043 [--format pdf\|both\|md] [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
453
490
  | `monash config` | View / change settings (restart your AI app afterwards) |
454
491
  | `monash connect [client]` | Connect to Codex, Cursor, VS Code, Windsurf or Gemini CLI (see [Other AI clients](#other-ai-clients)) |
455
492
  | `monash remote serve` / `pair` / `clients` / `revoke` | Optional remote MCP for ChatGPT and Claude on the web ([Host it yourself](https://docs.secureview.tech/study-kit/remote/)) |
@@ -36,6 +36,41 @@ The picture is real output of `monash todo` against a database filled with made-
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
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
+
39
74
  ## 1.9.0: more complete course exports
40
75
 
41
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.
@@ -59,6 +94,8 @@ The bundled OAuth client is currently in Google's **Testing** state: its maintai
59
94
 
60
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.
61
96
 
97
+ `monash export <unit>` now exports Markdown body pages, link lists, quizzes and the index as **PDF by default**, alongside the original course files. Install Chrome, Edge or Brave to generate PDFs; if no browser is found, the export falls back to Markdown and explains this in the index and terminal. Use `--format both` to include PDF and Markdown, or `--format md` for Markdown only. For example, `monash config export_format both` saves PDF and Markdown as the default. Synced Markdown stays unchanged on your computer for AI, search and MCP. PDF generation runs offline in a fresh temporary browser profile, embeds only local exported images and omits remote images (keeping their alt text). PDFs are cached under `data/pdf-cache/` (up to 500 MB); `--json` includes `pdf.generated`, `pdf.cached` and `pdf.skipped_reason`. `monash ed export` keeps its existing behavior.
98
+
62
99
  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`.
63
100
 
64
101
  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.
@@ -413,7 +450,7 @@ You can also query directly in the terminal without any AI:
413
450
  | `monash ed lessons FIT2109` / `quiz FIT2109` | Ed lesson progress / quiz questions (for revision) |
414
451
  | `monash ed read FIT2109 "W3 Pre-Class"` | A whole lesson as Markdown: text slides, reading pages and PDFs in order, plus its quiz questions |
415
452
  | `monash ed export FIT2109 [--module "Week 3"] [--open]` | Zip a unit's Ed materials by week into Downloads |
416
- | `monash export FIT1043 [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
453
+ | `monash export FIT1043 [--format pdf\|both\|md] [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
417
454
  | `monash config` | View / change settings (restart your AI app afterwards) |
418
455
  | `monash connect [client]` | Connect to Codex, Cursor, VS Code, Windsurf or Gemini CLI (see [Other AI clients](#other-ai-clients)) |
419
456
  | `monash remote serve` / `pair` / `clients` / `revoke` | Optional remote MCP for ChatGPT and Claude on the web ([Host it yourself](https://docs.secureview.tech/study-kit/remote/)) |
@@ -37,6 +37,41 @@ Moodle和Ed始终**只读**:不会交作业、做测验或在Ed发帖。可选
37
37
  之前的[1.1安全审计](docs/security.md)只覆盖当时的功能;新增的远程连接、邮箱与考勤另列有[1.5审查清单](docs/SECURITY-REVIEW-1.5-SCOPE.md),不能直接沿用旧版结论。
38
38
 
39
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
+
40
75
  ## 1.9.0:补全课程资料导出
41
76
 
42
77
  - Moodle 的 Page、Book 章节、作业说明和学生能看到的 rubric / marking guide 存成 Markdown;正文里的 Moodle 图片存到课程的 `assets/`,同内容去重。指向本课程 Page、Resource、Folder、Book 的内部链接也会跟进。
@@ -44,6 +79,7 @@ Moodle和Ed始终**只读**:不会交作业、做测验或在Ed发帖。可选
44
79
  - Ed Lessons 的 document / code 正文图片只下载 Ed 自己的 `edusercontent.com` 地址,按内容去重并缓存 URL,每张最多 200 MB。下载失败保留原链接并记录原因;独立 Ed 导出和整课导出都包含 `assets/`,图片使用相对路径。
45
80
  - Google Slides / Docs 默认导出 PDF,Sheets 导出 XLSX,Drive 普通文件按原格式下载。只处理 Moodle 和 Ed Lessons 里出现过的文件链接;Google 表单不能导出。文件还在时跳过,`monash sync --refresh-google` 强制重新导出。
46
81
  - 每次同步检查新出现的 Ed 课程:课号与已跟踪 Moodle 课程相同就自动跟踪,包括归档课程和 `FIT1045/FIT1053` 这样的联合课号;处理过的课程保留用户选择。
82
+ - `monash export <课号>` 导出包里的正文页、链接清单、测验和索引默认是 **PDF(给人看)**,课件原件照常保留。本机同步的 md 不变,继续供 AI、全文搜索和 MCP 使用。用 `--format both` 同时放 PDF 和 md,`--format md` 只放 md;例如 `monash config export_format both` 可将默认值设为同时导出两种格式。需要安装 Chrome / Edge / Brave 才能生成 PDF;没有浏览器时自动回退 md,并在索引和终端说明。PDF 在全新的临时浏览器配置中离线生成,只内嵌本次导出的本地图片,远程图片仅保留替代文字。缓存放在数据目录的 `pdf-cache/`,最多 500 MB;`--json` 新增 `pdf.generated`、`pdf.cached`、`pdf.skipped_reason`。`monash ed export` 的行为不变。
47
83
  - `monash export FIT1045 --sync` 先同步这门 Moodle 课及对应 Ed 课再导出。普通导出继续只读本机缓存。README 索引列出未导出内容和原因,并统计链接清单数量、Markdown 远程图片数、Google 总数 / 成功 / 按原因分组的失败数;`--json` 的 `statistics` 提供相同数字。
48
84
 
49
85
  ```bash
@@ -397,7 +433,7 @@ npx skills add Waldo0926/monash-study-kit
397
433
  | `monash ed lessons FIT2109` / `quiz FIT2109` | Ed Lessons 进度 / 测验题(复习用) |
398
434
  | `monash ed read FIT2109 "W3 Pre-Class"` | 整节 lesson 的正文:文字页、阅读网页、PDF 按页序拼成 Markdown,附测验题 |
399
435
  | `monash ed export FIT2109 [--module "Week 3"] [--open]` | 整门课的 Ed 课件按周打包成 zip,存到“下载” |
400
- | `monash export FIT1043 [--dir] [--open]` | 导出一门课的课程资料(Moodle + Ed Lessons),附索引,写明没导出的内容和原因 |
436
+ | `monash export FIT1043 [--format pdf\|both\|md] [--dir] [--open]` | 导出一门课的课程资料(Moodle + Ed Lessons),附索引,写明没导出的内容和原因 |
401
437
  | `monash config` | 看/改设置(改完重启 AI 软件) |
402
438
  | `monash connect [客户端]` | 接进 Codex、Cursor、VS Code、Windsurf 或 Gemini CLI(见[接入其他 AI 客户端](#接入其他-ai-客户端)) |
403
439
  | `monash remote serve` / `pair` / `clients` / `revoke` | 可选:给 ChatGPT 和网页版 Claude 用的远程 MCP([自己托管(进阶)](https://docs.secureview.tech/zh-cn/study-kit/remote/)) |
@@ -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.cli:main"
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.cli:main" not in entry:
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")
@@ -1,4 +1,4 @@
1
1
  """Monash 学习助手:把 Moodle 和 Ed 接进 Claude。"""
2
2
  # 发新版就改这里(pyproject 从这里读):朋友那边的更新提示比的就是 main 上的这个号。
3
3
  # 修 bug 加最后一位,加功能加中间一位。CI 会检查改了 src/ 的 PR 有没有改它。
4
- __version__ = "1.9.0"
4
+ __version__ = "1.11.0"
@@ -1,5 +1,5 @@
1
1
  import sys
2
2
 
3
- from .cli import main
3
+ from .entry import main
4
4
 
5
5
  sys.exit(main())
@@ -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
@@ -107,10 +107,13 @@ class CDP:
107
107
  self.ws = WebSocket(ws_url)
108
108
  self._id = 0
109
109
 
110
- def call(self, method: str, params: dict | None = None, timeout: float = 15) -> dict:
110
+ def call(self, method: str, params: dict | None = None, timeout: float = 15, *, session_id: str | None = None) -> dict:
111
111
  self._id += 1
112
112
  mid = self._id
113
- self.ws.send(json.dumps({"id": mid, "method": method, "params": params or {}}))
113
+ message = {"id": mid, "method": method, "params": params or {}}
114
+ if session_id:
115
+ message["sessionId"] = session_id
116
+ self.ws.send(json.dumps(message))
114
117
  deadline = time.monotonic() + timeout
115
118
  while time.monotonic() < deadline:
116
119
  msg = json.loads(self.ws.recv())
@@ -140,19 +143,27 @@ class PipeCDP:
140
143
  os.set_inheritable(3, True)
141
144
  os.set_inheritable(4, True)
142
145
 
143
- self.proc = subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
144
- stderr=subprocess.DEVNULL, preexec_fn=wire, close_fds=False)
146
+ try:
147
+ self.proc = subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
148
+ stderr=subprocess.DEVNULL, preexec_fn=wire, close_fds=False)
149
+ except BaseException:
150
+ for fd in (to_child_r, self._to_child, self._from_child, from_child_w):
151
+ os.close(fd)
152
+ raise
145
153
  os.close(to_child_r)
146
154
  os.close(from_child_w)
147
155
  os.set_blocking(self._from_child, False)
148
156
  self._buf = b""
149
157
  self._id = 0
150
158
 
151
- def call(self, method: str, params: dict | None = None, timeout: float = 15) -> dict:
159
+ def call(self, method: str, params: dict | None = None, timeout: float = 15, *, session_id: str | None = None) -> dict:
152
160
  self._id += 1
153
161
  mid = self._id
162
+ message = {"id": mid, "method": method, "params": params or {}}
163
+ if session_id:
164
+ message["sessionId"] = session_id
154
165
  try:
155
- os.write(self._to_child, json.dumps({"id": mid, "method": method, "params": params or {}}).encode() + b"\0")
166
+ os.write(self._to_child, json.dumps(message).encode() + b"\0")
156
167
  except OSError as e:
157
168
  raise WebSocketClosed("浏览器已经关掉了") from e
158
169
  deadline = time.monotonic() + timeout
@@ -181,7 +181,9 @@ def cmd_setup(args):
181
181
  code = claude_setup.install_code()
182
182
  return 0 if desktop or code else 1
183
183
  from . import location
184
- if location.first_run():
184
+ from .paths import is_default_profile
185
+ materials = load_settings().get("materials_only", False)
186
+ if is_default_profile() and location.first_run():
185
187
  print(f"Monash 学习助手 {__version__}\n")
186
188
  choice = location.ask()
187
189
  if choice is not None:
@@ -208,6 +210,9 @@ def cmd_setup(args):
208
210
  login_moodle()
209
211
  print("\n== 3/4 选课 ==")
210
212
  choose_courses(interactive=_yes("默认跟踪本学期的课。要自己挑吗?", default=False))
213
+ if materials:
214
+ print("\n完成!已登录并选课。只导课程资料模式下,请运行 monash sync,再用 monash export <课号> 导出。")
215
+ return 0
211
216
  print("\n== 4/4 接进 Claude ==")
212
217
  claude_setup.install_code()
213
218
  claude_setup.install_desktop()
@@ -256,6 +261,8 @@ def cmd_status(args):
256
261
  def _optional_status() -> dict:
257
262
  """开了的可选功能各给一行;坏了也不影响 Moodle 和 Ed 的状态。"""
258
263
  settings, out = load_settings(), {}
264
+ if settings.get("materials_only"):
265
+ return out
259
266
  try:
260
267
  if settings.get("gmail_enabled"):
261
268
  from . import gmail
@@ -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 == "export_format" and raw not in {"pdf", "both", "md"}:
340
+ raise ValueError("export_format 只能是 pdf、both 或 md")
332
341
  if key == "google_docs_format" and raw not in {"pdf", "docx"}:
333
342
  raise ValueError("google_docs_format 只能是 pdf 或 docx")
334
343
  if isinstance(current, bool):
@@ -658,14 +667,17 @@ def cmd_export(args):
658
667
  sync_export_course(args.course, log=(lambda text: print(text, file=sys.stderr)))
659
668
  mcon, econ = moodlelib.db_connect(), edlib.db_connect()
660
669
  try:
661
- d = X.export(args.course, args.to, as_dir=args.dir, moodle_con=mcon, ed_conn=econ)
670
+ d = X.export(args.course, args.to, as_dir=args.dir, moodle_con=mcon, ed_conn=econ,
671
+ export_format=getattr(args, "format", None))
662
672
  finally:
663
673
  mcon.close()
664
674
  econ.close()
665
- except LookupError as e:
675
+ except (LookupError, ValueError, OSError, RuntimeError, TimeoutError) as e:
666
676
  print(e, file=sys.stderr)
667
677
  return 1
668
678
  if want_json(args):
679
+ if d.get("pdf", {}).get("skipped_reason"):
680
+ print(d["pdf"]["skipped_reason"], file=sys.stderr)
669
681
  return emit_json(d)
670
682
  print(f"已导出 {d['course']}({d['bytes'] / 1e6:.1f} MB):{d['path']}")
671
683
  if d["moodle"]:
@@ -675,7 +687,7 @@ def cmd_export(args):
675
687
  for n in d["notes"]:
676
688
  print(f" ! {n}")
677
689
  if d["missing"]:
678
- print(f" 有 {d['missing']} 项没导出,原因写在 README.md 的“没导出的内容”里")
690
+ print(f" 有 {d['missing']} 项没导出,原因写在 README 索引的“没导出的内容”里")
679
691
  if args.open:
680
692
  reveal(d["path"])
681
693
  return 0
@@ -900,7 +912,7 @@ class _Parser(argparse.ArgumentParser):
900
912
 
901
913
 
902
914
  def build_parser() -> argparse.ArgumentParser:
903
- from . import cli_attendance, cli_ed, cli_gmail, cli_google
915
+ from . import cli_attendance, cli_ed, cli_gmail, cli_google, cli_profile
904
916
  ap = _Parser(prog="monash", description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
905
917
  ap.add_argument("--version", action="version", version=f"monash-study-kit {__version__}")
906
918
  sub = ap.add_subparsers(dest="cmd")
@@ -944,6 +956,7 @@ def build_parser() -> argparse.ArgumentParser:
944
956
  p.add_argument("--dir", action="store_true", help="写成文件夹,不打 zip")
945
957
  p.add_argument("--open", action="store_true", help="导出后在文件管理器里显示")
946
958
  p.add_argument("--sync", action="store_true", help="导出前同步这门 Moodle 和 Ed 课程")
959
+ p.add_argument("--format", choices=["pdf", "both", "md"], help="正文格式(默认读取 export_format,初始为 pdf)")
947
960
  p = cmd(sub, "media", cmd_media, help="录播:YouTube 字幕、Zoom 录像下载和转写(要装 [media])")
948
961
  p.add_argument("--limit", type=int, default=0, help="这次最多转写几个视频")
949
962
  p.add_argument("--match", help="只转写路径里含这段文字的视频")
@@ -1005,6 +1018,7 @@ def build_parser() -> argparse.ArgumentParser:
1005
1018
  p.add_argument("conversation", nargs="?", type=int); p.add_argument("--limit", type=int, default=20)
1006
1019
  p = cmd(m, "ls", cmd_m_ls, help="本地已同步的课件"); p.add_argument("course"); p.add_argument("week", nargs="?")
1007
1020
 
1021
+ cli_profile.add_commands(sub.add_parser("profile", help="管理本机命名账号").add_subparsers(dest="profile_cmd", required=True))
1008
1022
  cli_ed.add_commands(sub.add_parser("ed", help="Ed 查询").add_subparsers(dest="ecmd", required=True))
1009
1023
  cli_google.add_commands(sub.add_parser("google", help="Google 课程文件只读授权").add_subparsers(dest="google_cmd", required=True))
1010
1024
  cli_gmail.add_commands(sub.add_parser("gmail", help="Gmail 同步、离线搜索与可选邮箱操作").add_subparsers(dest="gcmd", required=True))
@@ -1021,7 +1035,7 @@ def _print_update_notice() -> None:
1021
1035
  print(f"\n↑ {msg}", file=sys.stderr)
1022
1036
 
1023
1037
 
1024
- def main(argv: list[str] | None = None) -> int:
1038
+ def setup_streams() -> None:
1025
1039
  for stream in (sys.stdout, sys.stderr):
1026
1040
  try:
1027
1041
  if stream.isatty():
@@ -1030,8 +1044,17 @@ def main(argv: list[str] | None = None) -> int:
1030
1044
  stream.reconfigure(encoding="utf-8") # 管道/重定向:Windows 默认是本地代码页,中文会丢
1031
1045
  except (AttributeError, ValueError):
1032
1046
  pass
1047
+
1048
+
1049
+ def main(argv: list[str] | None = None) -> int:
1050
+ setup_streams()
1033
1051
  ap = build_parser()
1034
1052
  args = ap.parse_args(argv)
1053
+ from .materials_policy import command_error
1054
+ error = command_error(args, load_settings())
1055
+ if error:
1056
+ print(error, file=sys.stderr)
1057
+ return 1
1035
1058
  ensure_private_dir(HOME) # 库里有同学的名字和私密帖,只给自己读
1036
1059
  quiet = args.cmd in ("mcp", "update", "doctor", "remote", "library")
1037
1060
  if not quiet:
@@ -0,0 +1,118 @@
1
+ """仅在默认账号下管理命名 profile;删除前先吊销全部 Google 授权。"""
2
+ from __future__ import annotations
3
+
4
+ import os
5
+ import shutil
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ from . import google_export, paths
10
+ from .home import validate_profile
11
+
12
+ ED_HINT = "Ed 的 API 令牌没有吊销接口,请到 https://edstem.org/au/settings/api-tokens 手动删除"
13
+ SESSIONS = ("secrets", "browser-profile", "attendance-browser")
14
+ TOKENS = ("google-drive-token.json", "gmail-token.json")
15
+
16
+
17
+ def profile_path(name: str) -> Path:
18
+ validate_profile(name)
19
+ root = paths.HOME / "profiles"
20
+ target = root / name
21
+ if root.is_symlink() or target.is_symlink():
22
+ raise ValueError("profile 目录不能是符号链接")
23
+ return target
24
+
25
+
26
+ def _size(directory: Path, exclude_profiles=False) -> int:
27
+ total = 0
28
+ for base, dirs, files in os.walk(directory, followlinks=False):
29
+ dirs[:] = [d for d in dirs if not (Path(base) / d).is_symlink()
30
+ and not (exclude_profiles and Path(base) == directory and d == "profiles")]
31
+ for name in files:
32
+ file = Path(base) / name
33
+ if not file.is_symlink():
34
+ total += file.stat().st_size
35
+ return total
36
+
37
+
38
+ def list_profiles() -> list[dict]:
39
+ """只查凭据文件是否存在,不读其中内容。"""
40
+ rows = []
41
+ roots = [("default", paths.HOME)]
42
+ root = paths.HOME / "profiles"
43
+ if root.is_dir() and not root.is_symlink():
44
+ for directory in sorted(root.iterdir()):
45
+ try:
46
+ validate_profile(directory.name)
47
+ except ValueError:
48
+ continue
49
+ if directory.is_dir() and not directory.is_symlink():
50
+ roots.append((directory.name, directory))
51
+ for name, directory in roots:
52
+ secrets = paths.SECRETS_DIR if name == "default" else directory / "secrets"
53
+ safe = not secrets.is_symlink()
54
+ exists = lambda filename: safe and (secrets / filename).is_file() and not (secrets / filename).is_symlink()
55
+ rows.append({"name": name, "path": str(directory), "moodle": exists("moodle-cookie"),
56
+ "ed": exists("ed-token"), "google": any(exists(t) for t in TOKENS),
57
+ "bytes": _size(directory, exclude_profiles=name == "default")})
58
+ return rows
59
+
60
+
61
+ def remove_profile(name: str, *, all_data: bool = False, yes: bool = False, ask=None, log=print) -> bool:
62
+ """任何吊销失败都不删本机内容;不调用 Moodle 注销或任何课程接口。"""
63
+ if not paths.is_default_profile():
64
+ raise ValueError("请在默认账号下运行 monash profile,不能在命名 profile 内管理其他账号")
65
+ target = profile_path(name)
66
+ if not target.is_dir():
67
+ raise ValueError(f"没有这个 profile:{name}")
68
+ for part in SESSIONS:
69
+ if (target / part).is_symlink():
70
+ raise ValueError("登录或会话目录不能是符号链接,请先手动检查")
71
+ for token in TOKENS:
72
+ if (target / "secrets" / token).is_symlink():
73
+ raise ValueError("凭据文件不能是符号链接,请先手动检查")
74
+ deleting = [target] if all_data else [target / part for part in SESSIONS]
75
+ if not yes:
76
+ answer = (ask or input)("将删除以下本机目录,并先吊销 Google 授权:\n" + "\n".join(str(d) for d in deleting) + "\n确认删除?[y/N] ")
77
+ if answer.strip().lower() not in {"y", "yes", "是"}:
78
+ log("已取消,未删除任何文件")
79
+ return False
80
+ for token in TOKENS:
81
+ google_export.revoke_token(target / "secrets" / token)
82
+ if all_data:
83
+ shutil.rmtree(target)
84
+ log(f"已删除 profile:{target}")
85
+ else:
86
+ for part in SESSIONS:
87
+ directory = target / part
88
+ if directory.is_dir():
89
+ shutil.rmtree(directory)
90
+ log(f"已清除登录和会话,课程资料与数据库仍保留在:{target}")
91
+ log(ED_HINT)
92
+ return True
93
+
94
+
95
+ def run(args):
96
+ try:
97
+ if not paths.is_default_profile():
98
+ raise ValueError("请在默认账号下运行 monash profile,不能在命名 profile 内管理其他账号")
99
+ if args.profile_cmd == "list":
100
+ for row in list_profiles():
101
+ flag = lambda key: "有" if row[key] else "无"
102
+ print(f"{row['name']} · Moodle {flag('moodle')} · Ed {flag('ed')} · Google {flag('google')} · {row['bytes']} 字节 · {row['path']}")
103
+ else:
104
+ remove_profile(args.name, all_data=args.all, yes=args.yes)
105
+ return 0
106
+ except (ValueError, OSError, google_export.GoogleError) as e:
107
+ print(str(e) if not isinstance(e, OSError) else "本机目录清理失败,请检查权限后重试", file=sys.stderr)
108
+ return 1
109
+
110
+
111
+ def add_commands(sub):
112
+ p = sub.add_parser("list", help="列账号、凭据是否存在和占用空间")
113
+ p.set_defaults(fn=run)
114
+ p = sub.add_parser("remove", help="吊销 Google 授权并清除本机登录会话")
115
+ p.set_defaults(fn=run)
116
+ p.add_argument("name", help="命名 profile,不能是 default")
117
+ p.add_argument("--all", action="store_true", help="同时删除课程资料和数据库")
118
+ p.add_argument("--yes", action="store_true", help="直接确认所列目录的清理")
@@ -257,8 +257,10 @@ CHECKS = [check_install, check_data_dir, check_browser, check_moodle, check_ed,
257
257
 
258
258
  def run(skip: tuple = (), deep: bool = False) -> dict:
259
259
  results = []
260
+ materials = load_settings().get("materials_only")
261
+ private = {"check_gmail", "check_attendance", "check_claude_desktop", "check_claude_code"}
260
262
  for fn in CHECKS:
261
- if fn.__name__ in skip:
263
+ if fn.__name__ in skip or materials and fn.__name__ in private:
262
264
  continue
263
265
  try:
264
266
  result = fn()
@@ -264,6 +264,8 @@ def run() -> list[dict]:
264
264
  out = []
265
265
  try:
266
266
  for fn in DEEP_CHECKS:
267
+ if load_settings().get("materials_only") and fn.__name__ not in {"deep_files", "deep_index"}:
268
+ continue
267
269
  try:
268
270
  out.append(fn(ctx))
269
271
  except MoodleAuthError: