{ "id": "05-modules", "title": "Modules & packages", "icon": "🧩", "level": "intermediate", "lessons": [ { "id": "5.1", "title": "Browse and install modules", "objective": "See what is loaded and install from the WebX11 package index.", "minutes": 8, "commands": [ "modules", "wpm", "load-local" ], "blocks": [ { "type": "text", "text": "`wpm` is the package manager for terminal modules: list the index, install a module from `packages.json` or a URL." }, { "type": "cmd", "text": "wpm list" }, { "type": "cmd", "text": "modules" }, { "type": "text", "text": "Every ext module in the default build auto-loads. There is no separate “needs loadmod” tier." }, { "type": "cmd", "text": "load-local modules/ext/calc.js" } ], "exercise": { "instruction": "List available packages.", "accept": [ "wpm list" ], "check": { "type": "command" }, "hint": "Type: wpm list" }, "quiz": { "q": "What does wpm install?", "options": [ "terminal modules", "system packages", "browser extensions" ], "answer": 0 }, "sources": [ "modules/ext/wpm.js", "packages.json", "modules/core/module-loader.js" ] }, { "id": "5.2", "title": "Module anatomy (a complete mini module)", "objective": "Read the contract every module follows: class, commands map, help info, registration.", "minutes": 12, "commands": [ "load-local" ], "blocks": [ { "type": "text", "text": "A module is a class with `commands`, `registerCommands()`, `getHelpInfo()` and optionally `init(terminal)`. The module manager injects `terminal` before calling `registerCommands()`." }, { "type": "code", "text": "class HelloModule {\n constructor(){ this.commands = {}; }\n getHelpInfo(){ return { hello: 'hello — print a greeting' }; }\n registerCommands(){ this.commands['hello'] = () => this.terminal.print('hello newOS4'); }\n}" }, { "type": "tip", "text": "Tier-3 modules register at the end with `webx11.moduleManager.registerModule(new HelloModule(), url)`." }, { "type": "cmd", "text": "modules" } ], "exercise": { "instruction": "Open the module list and find a module you have not used.", "accept": [ "modules" ], "check": { "type": "command" }, "hint": "Type: modules" }, "quiz": { "q": "What does the module manager inject before registerCommands()?", "options": [ "the terminal", "the database", "nothing" ], "answer": 0 }, "sources": [ "modules/core/module-manager.js", "modules/ext/kanban.js" ] } ] }