@mo7yw4ng/openape 1.0.0

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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -0
  3. package/esm/_dnt.polyfills.d.ts +24 -0
  4. package/esm/_dnt.polyfills.js +1 -0
  5. package/esm/_dnt.shims.d.ts +5 -0
  6. package/esm/_dnt.shims.js +61 -0
  7. package/esm/deno.d.ts +23 -0
  8. package/esm/deno.js +22 -0
  9. package/esm/package.json +3 -0
  10. package/package.json +34 -0
  11. package/script/_dnt.polyfills.d.ts +24 -0
  12. package/script/_dnt.polyfills.js +2 -0
  13. package/script/_dnt.shims.d.ts +5 -0
  14. package/script/_dnt.shims.js +65 -0
  15. package/script/deno.d.ts +23 -0
  16. package/script/deno.js +24 -0
  17. package/script/package.json +3 -0
  18. package/script/src/commands/announcements.d.ts +2 -0
  19. package/script/src/commands/announcements.js +288 -0
  20. package/script/src/commands/auth.d.ts +2 -0
  21. package/script/src/commands/auth.js +238 -0
  22. package/script/src/commands/calendar.d.ts +2 -0
  23. package/script/src/commands/calendar.js +375 -0
  24. package/script/src/commands/courses.d.ts +2 -0
  25. package/script/src/commands/courses.js +484 -0
  26. package/script/src/commands/forums.d.ts +2 -0
  27. package/script/src/commands/forums.js +403 -0
  28. package/script/src/commands/grades.d.ts +2 -0
  29. package/script/src/commands/grades.js +259 -0
  30. package/script/src/commands/materials.d.ts +2 -0
  31. package/script/src/commands/materials.js +423 -0
  32. package/script/src/commands/quizzes.d.ts +2 -0
  33. package/script/src/commands/quizzes.js +228 -0
  34. package/script/src/commands/skills.d.ts +2 -0
  35. package/script/src/commands/skills.js +117 -0
  36. package/script/src/commands/videos.d.ts +2 -0
  37. package/script/src/commands/videos.js +334 -0
  38. package/script/src/index.d.ts +26 -0
  39. package/script/src/index.js +156 -0
  40. package/script/src/lib/auth.d.ts +24 -0
  41. package/script/src/lib/auth.js +203 -0
  42. package/script/src/lib/config.d.ts +5 -0
  43. package/script/src/lib/config.js +43 -0
  44. package/script/src/lib/logger.d.ts +2 -0
  45. package/script/src/lib/logger.js +28 -0
  46. package/script/src/lib/moodle.d.ts +234 -0
  47. package/script/src/lib/moodle.js +966 -0
  48. package/script/src/lib/session.d.ts +7 -0
  49. package/script/src/lib/session.js +71 -0
  50. package/script/src/lib/token.d.ts +27 -0
  51. package/script/src/lib/token.js +154 -0
  52. package/script/src/lib/types.d.ts +261 -0
  53. package/script/src/lib/types.js +2 -0
  54. package/script/src/lib/utils.d.ts +5 -0
  55. package/script/src/lib/utils.js +43 -0
  56. package/skills/openape/SKILL.md +328 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MO7YW4NG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # OpenApe CLI (Unofficial)
2
+
3
+ 中原大學 [i-Learning](https://ilearning.cycu.edu.tw/) (Moodle) 平台自動化命令列工具 (CLI),幫助你快速查詢課程、觀看影片、下載教材。
4
+
5
+ ## 功能特色
6
+ - 📚 **課程資訊**:列出修課清單、成績、課程大綱與進度。
7
+ - 📺 **影片輔助**:列出/下載影片,甚至自動標記為已觀看。
8
+ - 📝 **測驗與教材**:快速查看測驗、下載教材。
9
+ - 💬 **討論區與公告**:在終端機直接閱讀公告與討論區。
10
+ - 📅 **行事曆**:內建行事曆事件查詢與匯出。
11
+ - 🤖 **Agent Skills**:提供 Claude Code 等 Skills 工作流支援。
12
+
13
+ ## 安裝
14
+
15
+ 透過 npm 安裝([Node.js v18+](https://nodejs.org/)):
16
+ ```bash
17
+ npm install -g openape
18
+ ```
19
+
20
+ ## 核心指令
21
+
22
+ ### 登入與驗證 (Authentication)
23
+ 第一次使用需要登入,會開啟瀏覽器讓你手動完成登入,隨後會快取 Session 供未來使用。
24
+ ```bash
25
+ openape login # 登入並儲存 session (開啟瀏覽器)
26
+ openape auth status # 檢查當前登入狀態
27
+ openape auth logout # 登出並清除 session
28
+ ```
29
+
30
+ ### 課程 (Courses)
31
+ ```bash
32
+ openape courses list # 列出所有課程 (支援 --incomplete-only, --level)
33
+ openape courses info <id> # 顯示特定課程的詳細資訊
34
+ openape courses progress <id> # 顯示特定課程的進度
35
+ openape courses syllabus <id> # 顯示課程大綱
36
+ ```
37
+
38
+ ### 影片 (Videos)
39
+ ```bash
40
+ openape videos list <course-id> # 列出課程中的影片
41
+ openape videos complete <id> # 標記特定影片為已觀看
42
+ openape videos complete-all <id> # 影片批次完成
43
+ openape videos download <id> # 下載影片
44
+ ```
45
+
46
+ ### 測驗與教材 (Quizzes & Materials)
47
+ ```bash
48
+ openape quizzes list <course-id> # 列出特定課程測驗
49
+ openape quizzes list-all # 列出所有課程測驗
50
+ openape quizzes open <id> # 開啟特定測驗
51
+ openape materials list-all # 列出所有可下載教材
52
+ openape materials download <id> # 下載指定教材
53
+ openape materials download-all # 批次下載教材
54
+ ```
55
+
56
+ ### 成績與其他查詢 (Grades, Forums, Calendar)
57
+ ```bash
58
+ openape grades summary # 顯示學期成績總覽
59
+ openape grades course <id> # 顯示特定課程成績
60
+ openape forums list <course-id> # 列出課程論壇
61
+ openape announcements list-all # 列出所有公告
62
+ openape announcements read <id> # 閱讀特定公告
63
+ openape calendar events # 查詢行事曆事件
64
+ openape calendar export # 匯出事件
65
+ ```
66
+
67
+ ### Skills
68
+ 讓你的 AI Agent 也可以控制 OpenApe。只需一個指令即可安裝:
69
+ ```bash
70
+ openape skills list # 查看目前提供的所有 skills
71
+ openape skills install claude # 為 Claude Code 安裝技能 (支援 claude, codex, opencode)
72
+ openape skills install --all # 自動偵測環境並安裝給所有支援的 Agent
73
+ ```
74
+ 也可以透過 `npx skills` 安裝:
75
+ ```bash
76
+ npx skills add openape/openape
77
+ ```
78
+
79
+ ## 開發
80
+
81
+ 專案使用 [Deno](https://deno.land/) 開發,歡迎一同貢獻:
82
+
83
+ ```bash
84
+ git clone https://github.com/mo7yw4ng/openape && cd openape
85
+
86
+ # 啟動開發伺服器 (將直接執行 src/index.ts)
87
+ deno task dev
88
+
89
+ # 編譯成各平台執行檔 (預設輸出到 dist/OpenApe.exe)
90
+ deno task compile
91
+ ```
92
+
93
+ ## 版權與授權
94
+
95
+ 此專案之版權規範採用 **MIT License** - 至 [LICENSE](LICENSE) 查看更多相關聲明
96
+
97
+ > **免責聲明**:本工具為非官方開放原始碼專案,與中原大學官方無關。請斟酌使用腳本輔助功能,避免不當操作(如短時間發送大量請求修改系統狀態)而違反學術倫理或導致帳號遭封鎖。
@@ -0,0 +1,24 @@
1
+ declare global {
2
+ interface ImportMeta {
3
+ /** A flag that indicates if the current module is the main module that was
4
+ * called when starting the program under Deno.
5
+ *
6
+ * ```ts
7
+ * if (import.meta.main) {
8
+ * // this was loaded as the main module, maybe do some bootstrapping
9
+ * }
10
+ * ```
11
+ */
12
+ main: boolean;
13
+ /** A function that returns resolved specifier as if it would be imported
14
+ * using `import(specifier)`.
15
+ *
16
+ * ```ts
17
+ * console.log(import.meta.resolve("./foo.js"));
18
+ * // file:///dev/foo.js
19
+ * ```
20
+ */
21
+ resolve(specifier: string): string;
22
+ }
23
+ }
24
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
4
+ Deno: typeof Deno;
5
+ };
@@ -0,0 +1,61 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ const dntGlobals = {
4
+ Deno,
5
+ };
6
+ export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
7
+ function createMergeProxy(baseObj, extObj) {
8
+ return new Proxy(baseObj, {
9
+ get(_target, prop, _receiver) {
10
+ if (prop in extObj) {
11
+ return extObj[prop];
12
+ }
13
+ else {
14
+ return baseObj[prop];
15
+ }
16
+ },
17
+ set(_target, prop, value) {
18
+ if (prop in extObj) {
19
+ delete extObj[prop];
20
+ }
21
+ baseObj[prop] = value;
22
+ return true;
23
+ },
24
+ deleteProperty(_target, prop) {
25
+ let success = false;
26
+ if (prop in extObj) {
27
+ delete extObj[prop];
28
+ success = true;
29
+ }
30
+ if (prop in baseObj) {
31
+ delete baseObj[prop];
32
+ success = true;
33
+ }
34
+ return success;
35
+ },
36
+ ownKeys(_target) {
37
+ const baseKeys = Reflect.ownKeys(baseObj);
38
+ const extKeys = Reflect.ownKeys(extObj);
39
+ const extKeysSet = new Set(extKeys);
40
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
41
+ },
42
+ defineProperty(_target, prop, desc) {
43
+ if (prop in extObj) {
44
+ delete extObj[prop];
45
+ }
46
+ Reflect.defineProperty(baseObj, prop, desc);
47
+ return true;
48
+ },
49
+ getOwnPropertyDescriptor(_target, prop) {
50
+ if (prop in extObj) {
51
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
52
+ }
53
+ else {
54
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
55
+ }
56
+ },
57
+ has(_target, prop) {
58
+ return prop in extObj || prop in baseObj;
59
+ },
60
+ });
61
+ }
package/esm/deno.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ declare namespace _default {
2
+ let name: string;
3
+ let version: string;
4
+ let description: string;
5
+ let license: string;
6
+ let exports: string;
7
+ let tasks: {
8
+ dev: string;
9
+ compile: string;
10
+ "build:npm": string;
11
+ };
12
+ let imports: {
13
+ commander: string;
14
+ "playwright-core": string;
15
+ "node-html-parser": string;
16
+ };
17
+ let nodeModulesDir: string;
18
+ namespace compilerOptions {
19
+ let lib: string[];
20
+ }
21
+ let unstable: string[];
22
+ }
23
+ export default _default;
package/esm/deno.js ADDED
@@ -0,0 +1,22 @@
1
+ export default {
2
+ "name": "@openape/openape",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool for CYCU i-Learning platform",
5
+ "license": "MIT",
6
+ "exports": "./src/index.ts",
7
+ "tasks": {
8
+ "dev": "deno run --allow-all --sloppy-imports --watch src/index.ts",
9
+ "compile": "deno compile --allow-all --no-check --sloppy-imports --output dist/OpenApe.exe src/index.ts",
10
+ "build:npm": "deno run -A src/build_npm.ts"
11
+ },
12
+ "imports": {
13
+ "commander": "npm:commander@^12.1.0",
14
+ "playwright-core": "npm:playwright-core@^1.48.0",
15
+ "node-html-parser": "npm:node-html-parser@^6.1.13"
16
+ },
17
+ "nodeModulesDir": "auto",
18
+ "compilerOptions": {
19
+ "lib": ["ES2022", "DOM", "deno.ns"]
20
+ },
21
+ "unstable": ["sloppy-imports"]
22
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@mo7yw4ng/openape",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool for CYCU i-Learning platform",
5
+ "keywords": [
6
+ "ilearning",
7
+ "cycu",
8
+ "cli",
9
+ "headless",
10
+ "automation",
11
+ "playwright"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/mo7yw4ng/openape.git"
16
+ },
17
+ "license": "MIT",
18
+ "bugs": {
19
+ "url": "https://github.com/mo7yw4ng/openape/issues"
20
+ },
21
+ "bin": {
22
+ "openape": "./script/src/index.js"
23
+ },
24
+ "engines": {
25
+ "node": ">=18.0.0"
26
+ },
27
+ "dependencies": {
28
+ "@deno/shim-deno": "~0.18.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20.9.0"
32
+ },
33
+ "_generatedBy": "dnt@0.40.0"
34
+ }
@@ -0,0 +1,24 @@
1
+ declare global {
2
+ interface ImportMeta {
3
+ /** A flag that indicates if the current module is the main module that was
4
+ * called when starting the program under Deno.
5
+ *
6
+ * ```ts
7
+ * if (import.meta.main) {
8
+ * // this was loaded as the main module, maybe do some bootstrapping
9
+ * }
10
+ * ```
11
+ */
12
+ main: boolean;
13
+ /** A function that returns resolved specifier as if it would be imported
14
+ * using `import(specifier)`.
15
+ *
16
+ * ```ts
17
+ * console.log(import.meta.resolve("./foo.js"));
18
+ * // file:///dev/foo.js
19
+ * ```
20
+ */
21
+ resolve(specifier: string): string;
22
+ }
23
+ }
24
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
4
+ Deno: typeof Deno;
5
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dntGlobalThis = exports.Deno = void 0;
4
+ const shim_deno_1 = require("@deno/shim-deno");
5
+ var shim_deno_2 = require("@deno/shim-deno");
6
+ Object.defineProperty(exports, "Deno", { enumerable: true, get: function () { return shim_deno_2.Deno; } });
7
+ const dntGlobals = {
8
+ Deno: shim_deno_1.Deno,
9
+ };
10
+ exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
11
+ function createMergeProxy(baseObj, extObj) {
12
+ return new Proxy(baseObj, {
13
+ get(_target, prop, _receiver) {
14
+ if (prop in extObj) {
15
+ return extObj[prop];
16
+ }
17
+ else {
18
+ return baseObj[prop];
19
+ }
20
+ },
21
+ set(_target, prop, value) {
22
+ if (prop in extObj) {
23
+ delete extObj[prop];
24
+ }
25
+ baseObj[prop] = value;
26
+ return true;
27
+ },
28
+ deleteProperty(_target, prop) {
29
+ let success = false;
30
+ if (prop in extObj) {
31
+ delete extObj[prop];
32
+ success = true;
33
+ }
34
+ if (prop in baseObj) {
35
+ delete baseObj[prop];
36
+ success = true;
37
+ }
38
+ return success;
39
+ },
40
+ ownKeys(_target) {
41
+ const baseKeys = Reflect.ownKeys(baseObj);
42
+ const extKeys = Reflect.ownKeys(extObj);
43
+ const extKeysSet = new Set(extKeys);
44
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
45
+ },
46
+ defineProperty(_target, prop, desc) {
47
+ if (prop in extObj) {
48
+ delete extObj[prop];
49
+ }
50
+ Reflect.defineProperty(baseObj, prop, desc);
51
+ return true;
52
+ },
53
+ getOwnPropertyDescriptor(_target, prop) {
54
+ if (prop in extObj) {
55
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
56
+ }
57
+ else {
58
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
59
+ }
60
+ },
61
+ has(_target, prop) {
62
+ return prop in extObj || prop in baseObj;
63
+ },
64
+ });
65
+ }
@@ -0,0 +1,23 @@
1
+ declare namespace _default {
2
+ let name: string;
3
+ let version: string;
4
+ let description: string;
5
+ let license: string;
6
+ let exports: string;
7
+ let tasks: {
8
+ dev: string;
9
+ compile: string;
10
+ "build:npm": string;
11
+ };
12
+ let imports: {
13
+ commander: string;
14
+ "playwright-core": string;
15
+ "node-html-parser": string;
16
+ };
17
+ let nodeModulesDir: string;
18
+ namespace compilerOptions {
19
+ let lib: string[];
20
+ }
21
+ let unstable: string[];
22
+ }
23
+ export default _default;
package/script/deno.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "name": "@openape/openape",
5
+ "version": "1.0.0",
6
+ "description": "CLI tool for CYCU i-Learning platform",
7
+ "license": "MIT",
8
+ "exports": "./src/index.ts",
9
+ "tasks": {
10
+ "dev": "deno run --allow-all --sloppy-imports --watch src/index.ts",
11
+ "compile": "deno compile --allow-all --no-check --sloppy-imports --output dist/OpenApe.exe src/index.ts",
12
+ "build:npm": "deno run -A src/build_npm.ts"
13
+ },
14
+ "imports": {
15
+ "commander": "npm:commander@^12.1.0",
16
+ "playwright-core": "npm:playwright-core@^1.48.0",
17
+ "node-html-parser": "npm:node-html-parser@^6.1.13"
18
+ },
19
+ "nodeModulesDir": "auto",
20
+ "compilerOptions": {
21
+ "lib": ["ES2022", "DOM", "deno.ns"]
22
+ },
23
+ "unstable": ["sloppy-imports"]
24
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerAnnouncementsCommand(program: Command): void;