@mo7yw4ng/openape 1.0.6 → 2.0.4

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 +32 -0
  3. package/package.json +24 -28
  4. package/LICENSE +0 -21
  5. package/README.md +0 -138
  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 -71
  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 -229
  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 -127
  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 -312
  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 -190
  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 -84
  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 -402
  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 -236
  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 -55
  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 -266
  52. package/esm/src/index.d.ts +0 -28
  53. package/esm/src/index.d.ts.map +0 -1
  54. package/esm/src/index.js +0 -164
  55. package/esm/src/lib/auth.d.ts +0 -66
  56. package/esm/src/lib/auth.d.ts.map +0 -1
  57. package/esm/src/lib/auth.js +0 -286
  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 -26
  64. package/esm/src/lib/moodle.d.ts +0 -447
  65. package/esm/src/lib/moodle.d.ts.map +0 -1
  66. package/esm/src/lib/moodle.js +0 -1353
  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 -52
  77. package/esm/src/lib/utils.d.ts.map +0 -1
  78. package/esm/src/lib/utils.js +0 -122
  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 -74
  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 -268
  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 -133
  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 -315
  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 -193
  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 -87
  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 -408
  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 -239
  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 -61
  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 -272
  125. package/script/src/index.d.ts +0 -28
  126. package/script/src/index.d.ts.map +0 -1
  127. package/script/src/index.js +0 -171
  128. package/script/src/lib/auth.d.ts +0 -66
  129. package/script/src/lib/auth.d.ts.map +0 -1
  130. package/script/src/lib/auth.js +0 -296
  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 -29
  137. package/script/src/lib/moodle.d.ts +0 -447
  138. package/script/src/lib/moodle.d.ts.map +0 -1
  139. package/script/src/lib/moodle.js +0 -1425
  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 -52
  150. package/script/src/lib/utils.d.ts.map +0 -1
  151. package/script/src/lib/utils.js +0 -167
  152. package/skills/openape/SKILL.md +0 -115
@@ -1,167 +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.sanitizeFilename = sanitizeFilename;
41
- exports.getSessionPath = getSessionPath;
42
- exports.formatFileSize = formatFileSize;
43
- exports.formatMoodleDate = formatMoodleDate;
44
- exports.formatTimestamp = formatTimestamp;
45
- exports.formatRelativeTime = formatRelativeTime;
46
- const dntShim = __importStar(require("../../_dnt.shims.js"));
47
- const node_path_1 = require("node:path");
48
- /**
49
- * Returns the base directory for config/storage resolving.
50
- * Handles both Deno (raw/compiled) and Node.js (npx).
51
- */
52
- function getBaseDir() {
53
- // @ts-ignore - Deno global is available in Deno
54
- if (typeof dntShim.Deno !== "undefined" && typeof dntShim.Deno.execPath === "function") {
55
- try {
56
- // @ts-ignore
57
- const exeDir = (0, node_path_1.dirname)(dntShim.Deno.execPath());
58
- return exeDir.includes("deno") ? process.cwd() : exeDir;
59
- }
60
- catch {
61
- // Deno shim (dnt) or Deno not installed
62
- return process.cwd();
63
- }
64
- }
65
- // Node.js or dnt runtime
66
- return process.cwd();
67
- }
68
- /**
69
- * Strip HTML tags from a string.
70
- * Preserves text content while removing all HTML markup.
71
- */
72
- function stripHtmlTags(html) {
73
- if (!html)
74
- return "";
75
- // Remove HTML tags
76
- return html.replace(/<[^>]*>/g, "")
77
- // Replace HTML entities with their characters
78
- .replace(/&nbsp;/g, " ")
79
- .replace(/&amp;/g, "&")
80
- .replace(/&lt;/g, "<")
81
- .replace(/&gt;/g, ">")
82
- .replace(/&quot;/g, '"')
83
- .replace(/&#39;/g, "'")
84
- .replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(parseInt(dec, 10)))
85
- // Clean up excessive whitespace
86
- .replace(/\s+/g, " ")
87
- .trim();
88
- }
89
- /**
90
- * Extract clean course name from Moodle fullname.
91
- * Removes mlang tags, course codes, and instructor info.
92
- * Example: "{mlang zh-tw}1142Jazz Analysis(Distance)-Instructor..." -> "Jazz Analysis"
93
- */
94
- function extractCourseName(fullname) {
95
- if (!fullname)
96
- return "";
97
- // Remove {mlang ...} tags
98
- let cleaned = fullname.replace(/\{mlang[^}]*\}/g, "");
99
- // Match: 4+ digits + course name (until (, -, or [)
100
- const match = cleaned.match(/\d{4,}([^([-]+)/);
101
- return match ? match[1].trim() : fullname;
102
- }
103
- /**
104
- * Get output format from command options (global or local).
105
- * Defaults to "json" if not specified.
106
- */
107
- function getOutputFormat(command) {
108
- const opts = command.optsWithGlobals();
109
- return opts.output || "json";
110
- }
111
- /**
112
- * Sanitize filename by removing invalid characters and limiting length.
113
- * Replaces invalid characters with underscores and limits to maxLength.
114
- */
115
- function sanitizeFilename(name, maxLength = 200) {
116
- return name
117
- .replace(/[<>:"/\\|?*]/g, "_")
118
- .replace(/\s+/g, "_")
119
- .substring(0, maxLength);
120
- }
121
- /**
122
- * Get the session storage file path.
123
- */
124
- function getSessionPath() {
125
- const baseDir = getBaseDir();
126
- return (0, node_path_1.resolve)(baseDir, ".auth", "storage-state.json");
127
- }
128
- /**
129
- * Format file size to KB with specified decimal places.
130
- */
131
- function formatFileSize(bytes, decimals = 2) {
132
- return (bytes / 1024).toFixed(decimals);
133
- }
134
- /**
135
- * Format Moodle timestamp to localized string.
136
- */
137
- function formatMoodleDate(timestamp) {
138
- if (!timestamp || timestamp === 0)
139
- return "無期限";
140
- return new Date(timestamp * 1000).toLocaleString("zh-TW");
141
- }
142
- /**
143
- * Unified timestamp conversion (default: local time string)
144
- */
145
- function formatTimestamp(timestamp, format = "local") {
146
- if (!timestamp || timestamp === 0)
147
- return "無期限";
148
- const date = new Date(timestamp * 1000);
149
- if (format === "iso")
150
- return date.toISOString();
151
- if (format === "relative")
152
- return formatRelativeTime(timestamp);
153
- return date.toLocaleString("zh-TW");
154
- }
155
- /**
156
- * Relative time format (e.g., "2 hours ago")
157
- */
158
- function formatRelativeTime(timestamp) {
159
- const seconds = Math.floor(Date.now() / 1000) - timestamp;
160
- if (seconds < 60)
161
- return `${seconds} seconds ago`;
162
- if (seconds < 3600)
163
- return `${Math.floor(seconds / 60)} minutes ago`;
164
- if (seconds < 86400)
165
- return `${Math.floor(seconds / 3600)} hours ago`;
166
- return `${Math.floor(seconds / 86400)} days ago`;
167
- }
@@ -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
75
- - `list-all` — List all forums across all courses. Flags: `--level in_progress|all`
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: `--attachment-id <id>`, `--inline-attachment-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>`, `--upcoming`, `--days <n>`
90
- - `export` — Export calendar events to file. Flags: `--output <path>`, `--days <n>`
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
- Most data 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
- ```