@mo7yw4ng/openape 1.0.5 → 2.0.3

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 (152) hide show
  1. package/bin/openape +29 -0
  2. package/bin/openape.js +29 -0
  3. package/package.json +22 -28
  4. package/LICENSE +0 -21
  5. package/README.md +0 -135
  6. package/esm/_dnt.polyfills.d.ts +0 -101
  7. package/esm/_dnt.polyfills.d.ts.map +0 -1
  8. package/esm/_dnt.polyfills.js +0 -127
  9. package/esm/_dnt.shims.d.ts +0 -6
  10. package/esm/_dnt.shims.d.ts.map +0 -1
  11. package/esm/_dnt.shims.js +0 -61
  12. package/esm/deno.d.ts +0 -25
  13. package/esm/deno.d.ts.map +0 -1
  14. package/esm/deno.js +0 -23
  15. package/esm/package.json +0 -3
  16. package/esm/src/commands/announcements.d.ts +0 -3
  17. package/esm/src/commands/announcements.d.ts.map +0 -1
  18. package/esm/src/commands/announcements.js +0 -134
  19. package/esm/src/commands/assignments.d.ts +0 -3
  20. package/esm/src/commands/assignments.d.ts.map +0 -1
  21. package/esm/src/commands/assignments.js +0 -230
  22. package/esm/src/commands/auth.d.ts +0 -3
  23. package/esm/src/commands/auth.d.ts.map +0 -1
  24. package/esm/src/commands/auth.js +0 -290
  25. package/esm/src/commands/calendar.d.ts +0 -3
  26. package/esm/src/commands/calendar.d.ts.map +0 -1
  27. package/esm/src/commands/calendar.js +0 -179
  28. package/esm/src/commands/courses.d.ts +0 -3
  29. package/esm/src/commands/courses.d.ts.map +0 -1
  30. package/esm/src/commands/courses.js +0 -348
  31. package/esm/src/commands/forums.d.ts +0 -3
  32. package/esm/src/commands/forums.d.ts.map +0 -1
  33. package/esm/src/commands/forums.js +0 -318
  34. package/esm/src/commands/grades.d.ts +0 -3
  35. package/esm/src/commands/grades.d.ts.map +0 -1
  36. package/esm/src/commands/grades.js +0 -121
  37. package/esm/src/commands/materials.d.ts +0 -3
  38. package/esm/src/commands/materials.d.ts.map +0 -1
  39. package/esm/src/commands/materials.js +0 -413
  40. package/esm/src/commands/quizzes.d.ts +0 -3
  41. package/esm/src/commands/quizzes.d.ts.map +0 -1
  42. package/esm/src/commands/quizzes.js +0 -271
  43. package/esm/src/commands/skills.d.ts +0 -3
  44. package/esm/src/commands/skills.d.ts.map +0 -1
  45. package/esm/src/commands/skills.js +0 -106
  46. package/esm/src/commands/upload.d.ts +0 -3
  47. package/esm/src/commands/upload.d.ts.map +0 -1
  48. package/esm/src/commands/upload.js +0 -58
  49. package/esm/src/commands/videos.d.ts +0 -3
  50. package/esm/src/commands/videos.d.ts.map +0 -1
  51. package/esm/src/commands/videos.js +0 -336
  52. package/esm/src/index.d.ts +0 -27
  53. package/esm/src/index.d.ts.map +0 -1
  54. package/esm/src/index.js +0 -160
  55. package/esm/src/lib/auth.d.ts +0 -47
  56. package/esm/src/lib/auth.d.ts.map +0 -1
  57. package/esm/src/lib/auth.js +0 -227
  58. package/esm/src/lib/config.d.ts +0 -6
  59. package/esm/src/lib/config.d.ts.map +0 -1
  60. package/esm/src/lib/config.js +0 -36
  61. package/esm/src/lib/logger.d.ts +0 -3
  62. package/esm/src/lib/logger.d.ts.map +0 -1
  63. package/esm/src/lib/logger.js +0 -27
  64. package/esm/src/lib/moodle.d.ts +0 -433
  65. package/esm/src/lib/moodle.d.ts.map +0 -1
  66. package/esm/src/lib/moodle.js +0 -1318
  67. package/esm/src/lib/session.d.ts +0 -8
  68. package/esm/src/lib/session.d.ts.map +0 -1
  69. package/esm/src/lib/session.js +0 -42
  70. package/esm/src/lib/token.d.ts +0 -38
  71. package/esm/src/lib/token.d.ts.map +0 -1
  72. package/esm/src/lib/token.js +0 -178
  73. package/esm/src/lib/types.d.ts +0 -189
  74. package/esm/src/lib/types.d.ts.map +0 -1
  75. package/esm/src/lib/types.js +0 -2
  76. package/esm/src/lib/utils.d.ts +0 -57
  77. package/esm/src/lib/utils.d.ts.map +0 -1
  78. package/esm/src/lib/utils.js +0 -129
  79. package/script/_dnt.polyfills.d.ts +0 -101
  80. package/script/_dnt.polyfills.d.ts.map +0 -1
  81. package/script/_dnt.polyfills.js +0 -130
  82. package/script/_dnt.shims.d.ts +0 -6
  83. package/script/_dnt.shims.d.ts.map +0 -1
  84. package/script/_dnt.shims.js +0 -65
  85. package/script/deno.d.ts +0 -25
  86. package/script/deno.d.ts.map +0 -1
  87. package/script/deno.js +0 -25
  88. package/script/package.json +0 -3
  89. package/script/src/commands/announcements.d.ts +0 -3
  90. package/script/src/commands/announcements.d.ts.map +0 -1
  91. package/script/src/commands/announcements.js +0 -140
  92. package/script/src/commands/assignments.d.ts +0 -3
  93. package/script/src/commands/assignments.d.ts.map +0 -1
  94. package/script/src/commands/assignments.js +0 -269
  95. package/script/src/commands/auth.d.ts +0 -3
  96. package/script/src/commands/auth.d.ts.map +0 -1
  97. package/script/src/commands/auth.js +0 -296
  98. package/script/src/commands/calendar.d.ts +0 -3
  99. package/script/src/commands/calendar.d.ts.map +0 -1
  100. package/script/src/commands/calendar.js +0 -185
  101. package/script/src/commands/courses.d.ts +0 -3
  102. package/script/src/commands/courses.d.ts.map +0 -1
  103. package/script/src/commands/courses.js +0 -354
  104. package/script/src/commands/forums.d.ts +0 -3
  105. package/script/src/commands/forums.d.ts.map +0 -1
  106. package/script/src/commands/forums.js +0 -324
  107. package/script/src/commands/grades.d.ts +0 -3
  108. package/script/src/commands/grades.d.ts.map +0 -1
  109. package/script/src/commands/grades.js +0 -127
  110. package/script/src/commands/materials.d.ts +0 -3
  111. package/script/src/commands/materials.d.ts.map +0 -1
  112. package/script/src/commands/materials.js +0 -419
  113. package/script/src/commands/quizzes.d.ts +0 -3
  114. package/script/src/commands/quizzes.d.ts.map +0 -1
  115. package/script/src/commands/quizzes.js +0 -277
  116. package/script/src/commands/skills.d.ts +0 -3
  117. package/script/src/commands/skills.d.ts.map +0 -1
  118. package/script/src/commands/skills.js +0 -112
  119. package/script/src/commands/upload.d.ts +0 -3
  120. package/script/src/commands/upload.d.ts.map +0 -1
  121. package/script/src/commands/upload.js +0 -64
  122. package/script/src/commands/videos.d.ts +0 -3
  123. package/script/src/commands/videos.d.ts.map +0 -1
  124. package/script/src/commands/videos.js +0 -342
  125. package/script/src/index.d.ts +0 -27
  126. package/script/src/index.d.ts.map +0 -1
  127. package/script/src/index.js +0 -167
  128. package/script/src/lib/auth.d.ts +0 -47
  129. package/script/src/lib/auth.d.ts.map +0 -1
  130. package/script/src/lib/auth.js +0 -269
  131. package/script/src/lib/config.d.ts +0 -6
  132. package/script/src/lib/config.d.ts.map +0 -1
  133. package/script/src/lib/config.js +0 -42
  134. package/script/src/lib/logger.d.ts +0 -3
  135. package/script/src/lib/logger.d.ts.map +0 -1
  136. package/script/src/lib/logger.js +0 -30
  137. package/script/src/lib/moodle.d.ts +0 -433
  138. package/script/src/lib/moodle.d.ts.map +0 -1
  139. package/script/src/lib/moodle.js +0 -1389
  140. package/script/src/lib/session.d.ts +0 -8
  141. package/script/src/lib/session.d.ts.map +0 -1
  142. package/script/src/lib/session.js +0 -45
  143. package/script/src/lib/token.d.ts +0 -38
  144. package/script/src/lib/token.d.ts.map +0 -1
  145. package/script/src/lib/token.js +0 -189
  146. package/script/src/lib/types.d.ts +0 -189
  147. package/script/src/lib/types.d.ts.map +0 -1
  148. package/script/src/lib/types.js +0 -3
  149. package/script/src/lib/utils.d.ts +0 -57
  150. package/script/src/lib/utils.d.ts.map +0 -1
  151. package/script/src/lib/utils.js +0 -175
  152. package/skills/openape/SKILL.md +0 -115
@@ -1,175 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getBaseDir = getBaseDir;
37
- exports.stripHtmlTags = stripHtmlTags;
38
- exports.extractCourseName = extractCourseName;
39
- exports.getOutputFormat = getOutputFormat;
40
- exports.shouldSilenceLogs = shouldSilenceLogs;
41
- exports.sanitizeFilename = sanitizeFilename;
42
- exports.getSessionPath = getSessionPath;
43
- exports.formatFileSize = formatFileSize;
44
- exports.formatMoodleDate = formatMoodleDate;
45
- exports.formatTimestamp = formatTimestamp;
46
- exports.formatRelativeTime = formatRelativeTime;
47
- const dntShim = __importStar(require("../../_dnt.shims.js"));
48
- const node_path_1 = require("node:path");
49
- /**
50
- * Returns the base directory for config/storage resolving.
51
- * Handles both Deno (raw/compiled) and Node.js (npx).
52
- */
53
- function getBaseDir() {
54
- // @ts-ignore - Deno global is available in Deno
55
- if (typeof dntShim.Deno !== "undefined" && typeof dntShim.Deno.execPath === "function") {
56
- try {
57
- // @ts-ignore
58
- const exeDir = (0, node_path_1.dirname)(dntShim.Deno.execPath());
59
- return exeDir.includes("deno") ? process.cwd() : exeDir;
60
- }
61
- catch {
62
- // Deno shim (dnt) or Deno not installed
63
- return process.cwd();
64
- }
65
- }
66
- // Node.js or dnt runtime
67
- return process.cwd();
68
- }
69
- /**
70
- * Strip HTML tags from a string.
71
- * Preserves text content while removing all HTML markup.
72
- */
73
- function stripHtmlTags(html) {
74
- if (!html)
75
- return "";
76
- // Remove HTML tags
77
- return html.replace(/<[^>]*>/g, "")
78
- // Replace HTML entities with their characters
79
- .replace(/&nbsp;/g, " ")
80
- .replace(/&amp;/g, "&")
81
- .replace(/&lt;/g, "<")
82
- .replace(/&gt;/g, ">")
83
- .replace(/&quot;/g, '"')
84
- .replace(/&#39;/g, "'")
85
- .replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(parseInt(dec, 10)))
86
- // Clean up excessive whitespace
87
- .replace(/\s+/g, " ")
88
- .trim();
89
- }
90
- /**
91
- * Extract clean course name from Moodle fullname.
92
- * Removes mlang tags, course codes, and instructor info.
93
- * Example: "{mlang zh-tw}1142爵士樂賞析(遠距)-楊曊恩..." -> "爵士樂賞析"
94
- */
95
- function extractCourseName(fullname) {
96
- if (!fullname)
97
- return "";
98
- // Remove {mlang ...} tags
99
- let cleaned = fullname.replace(/\{mlang[^}]*\}/g, "");
100
- // Match: 4+ digits + course name (until (, -, or [)
101
- const match = cleaned.match(/\d{4,}([^([-]+)/);
102
- return match ? match[1].trim() : fullname;
103
- }
104
- /**
105
- * Get output format from command options (global or local).
106
- * Defaults to "json" if not specified.
107
- */
108
- function getOutputFormat(command) {
109
- const opts = command.optsWithGlobals();
110
- return opts.output || "json";
111
- }
112
- /**
113
- * Determine if logs should be silenced based on output format and verbosity.
114
- * JSON output without verbose flag silences logs.
115
- */
116
- function shouldSilenceLogs(outputFormat, verbose) {
117
- return outputFormat === "json" && !verbose;
118
- }
119
- /**
120
- * Sanitize filename by removing invalid characters and limiting length.
121
- * Replaces invalid characters with underscores and limits to maxLength.
122
- */
123
- function sanitizeFilename(name, maxLength = 200) {
124
- return name
125
- .replace(/[<>:"/\\|?*]/g, "_")
126
- .replace(/\s+/g, "_")
127
- .substring(0, maxLength);
128
- }
129
- /**
130
- * Get the session storage file path.
131
- */
132
- function getSessionPath() {
133
- const baseDir = getBaseDir();
134
- return (0, node_path_1.resolve)(baseDir, ".auth", "storage-state.json");
135
- }
136
- /**
137
- * Format file size to KB with specified decimal places.
138
- */
139
- function formatFileSize(bytes, decimals = 2) {
140
- return (bytes / 1024).toFixed(decimals);
141
- }
142
- /**
143
- * Format Moodle timestamp to localized string.
144
- */
145
- function formatMoodleDate(timestamp) {
146
- if (!timestamp || timestamp === 0)
147
- return "無期限";
148
- return new Date(timestamp * 1000).toLocaleString("zh-TW");
149
- }
150
- /**
151
- * 統一時間戳記轉換 (預設:本地時間字串)
152
- */
153
- function formatTimestamp(timestamp, format = "local") {
154
- if (!timestamp || timestamp === 0)
155
- return "無期限";
156
- const date = new Date(timestamp * 1000);
157
- if (format === "iso")
158
- return date.toISOString();
159
- if (format === "relative")
160
- return formatRelativeTime(timestamp);
161
- return date.toLocaleString("zh-TW");
162
- }
163
- /**
164
- * 相對時間格式 (e.g., "2 hours ago")
165
- */
166
- function formatRelativeTime(timestamp) {
167
- const seconds = Math.floor(Date.now() / 1000) - timestamp;
168
- if (seconds < 60)
169
- return `${seconds} seconds ago`;
170
- if (seconds < 3600)
171
- return `${Math.floor(seconds / 60)} minutes ago`;
172
- if (seconds < 86400)
173
- return `${Math.floor(seconds / 3600)} hours ago`;
174
- return `${Math.floor(seconds / 86400)} days ago`;
175
- }
@@ -1,115 +0,0 @@
1
- ---
2
- name: openape
3
- description: "CYCU iLearning (Moodle): Manage courses, videos, quizzes, materials, grades, forums, announcements, and calendar."
4
- metadata:
5
- openclaw:
6
- category: "education"
7
- requires:
8
- bins:
9
- - openape
10
- cliHelp: "openape --help"
11
- ---
12
-
13
- # openape
14
-
15
- > **PREREQUISITE:** Install and login first:
16
- >
17
- > ```bash
18
- > npm install -g @mo7yw4ng/openape
19
- > openape login
20
- > ```
21
-
22
- ```bash
23
- openape <command> [subcommand] [args] [flags]
24
- ```
25
-
26
- ## Commands
27
-
28
- ### courses — Course operations
29
-
30
- - `list` — List enrolled courses. Flags: `--level in_progress|past|future|all`
31
- - `info <course-id>` — Show detailed course information
32
- - `progress <course-id>` — Show course completion progress
33
- - `syllabus <course-id>` — Show course syllabus (from CMAP)
34
-
35
- ### videos — Video progress operations
36
-
37
- - `list <course-id>` — List videos in a course. Flags: `--incomplete-only`
38
- - `complete <course-id>` — Complete all videos in a course
39
- - `complete-all` — Complete all incomplete videos across all courses. Flags: `--dry-run`
40
- - `download <course-id>` — Download videos from a course. Flags: `--output-dir <path>`
41
-
42
- ### quizzes — Quiz operations
43
-
44
- - `list <course-id>` — List incomplete quizzes in a course. Flags: `--all`
45
- - `list-all` — List all incomplete quizzes across courses. Flags: `--level in_progress|all`
46
- - `start <quiz-id>` — Start a new quiz attempt
47
- - `info <attempt-id>` — Get quiz attempt data and questions. Flags: `--page <number>`
48
- - `save <attempt-id> '<answers-json>'` — Save answers for a quiz attempt. Flags: `--submit`. JSON format: `[{"slot":1,"answer":"0"}]`. Multichoice: number, multichoices: `"0,2"`, shortanswer: text
49
-
50
- > **NEVER SUBMIT WITHOUT USER'S PERMISSION**, you have to make sure answer is saved before submitting.
51
-
52
- ### materials — Material/resource operations
53
-
54
- - `list-all` — List all materials across courses. Flags: `--level in_progress|all`
55
- - `download <course-id>` — Download all materials from a course
56
- - `download-all` — Download all materials from all courses. Flags: `--output-dir <path>`
57
- - `complete <course-id>` — Mark all incomplete resources (non-video) as complete
58
- - `complete-all` — Mark all incomplete resources across all in-progress courses
59
-
60
- ### assignments — Assignment operations
61
-
62
- - `list <course-id>` — List assignments in a course
63
- - `list-all` — List all assignments across courses. Flags: `--level in_progress|all`
64
- - `status <assignment-id>` — Check assignment submission status
65
- - `submit <assignment-id>` — Submit an assignment. Flags: `--text <content>`, `--file-id <id>`
66
-
67
- ### grades — Grade operations
68
-
69
- - `summary` — Show grade summary across all courses
70
- - `course <course-id>` — Show detailed grades for a course
71
-
72
- ### forums — Forum operations
73
-
74
- - `list` — List forums from in-progress courses. Flags: `--level in_progress|all`
75
- - `list-all` — List all forums across all courses
76
- - `discussions <forum-id>` — List discussions in a forum
77
- - `posts <discussion-id>` — Show posts in a discussion
78
- - `post <forum-id> <subject> <message>` — Post a new discussion. Flags: `--subscribe`, `--pin`
79
- - `reply <post-id> <subject> <message>` — Reply to a discussion post. Flags: `--parent-id <id>`
80
- - `delete <post-id>` — Delete a forum post or discussion
81
-
82
- ### announcements — Announcement operations
83
-
84
- - `list-all` — List all announcements across courses. Flags: `--unread-only`
85
- - `read <announcement-id>` — Read a specific announcement (full content)
86
-
87
- ### calendar — Calendar operations
88
-
89
- - `events` — List calendar events. Flags: `--course-id <id>`, `--events-after <date>`, `--events-before <date>`
90
- - `export` — Export calendar events to file. Flags: `--format json|ics`, `--output <file>`
91
-
92
- ### upload — File upload
93
-
94
- - `file <file-path>` — Upload a file to Moodle draft area
95
-
96
- ### skills — Skill management
97
-
98
- - `install [platform]` — Install OpenApe skill to an agent platform (claude, codex, opencode)
99
- - `show` — Print the raw SKILL.md content
100
-
101
- ## Output Formats
102
-
103
- All commands support `--output`: `json` (default), `csv`, `table`, `silent`
104
-
105
- Global flags: `--verbose`, `--headed`, `--session <path>`
106
-
107
- ## Discovering Commands
108
-
109
- ```bash
110
- # Browse all commands
111
- openape --help
112
-
113
- # Inspect a command's subcommands and options
114
- openape <command> --help
115
- ```