[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-107935":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":14,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":24,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":15,"starSnapshotCount":15,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},107935,"examples","MEGA-DOT-DEV\u002Fexamples","MEGA-DOT-DEV","Examples for the MEGA developer course. New examples arrive with each lesson.",null,"TypeScript",70,23,6,1,0,3,13,5,45.94,false,"main",true,[],"2026-11-19 11:34:14","2026-11-22 14:13:37","# MEGA examples\n\nCode examples for the [MEGA](https:\u002F\u002Fmega.dev\u002F) developer course.\n\nEach example is a small script that shows one mechanic of large language models: tokens, requests, tool calls, agent loops. The repo also holds small tools that you can keep using after a lesson. Each lesson adds its examples here on the day it opens.\n\nYou run everything through one CLI, `mex` (\"MEGA examples\").\n\n## Setup\n\nOpen **[AGENTS.md](AGENTS.md)**. It has a prompt that you paste into your coding agent (Claude Code, Codex, Cursor or another agent). The agent then sets up everything together with you, step by step: Node.js, Git, this repo, an API key, the panel and a first example. It asks you before it installs anything. AGENTS.md also explains each step for macOS, Windows and Linux, if you prefer to do the setup yourself.\n\nAlready have Node.js 22.18 or newer, and Git?\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FMEGA-DOT-DEV\u002Fexamples.git mega-examples\ncd mega-examples\nnpm install\nnpx mex setup   # add API keys; skip it to start with the examples that need none\nnpm start\n```\n\n## Get new examples\n\nA new lesson brings new examples. Stop the panel with Ctrl+C, then run in the repo folder:\n\n```bash\ngit pull\nnpm install\nnpm start\n```\n\nIf `git pull` stops because you changed a file that the update also changes, run `git stash`, then `git pull`, then `git stash pop` to put your change back.\n\n## Open the examples in your browser\n\n```bash\nnpm start\n```\n\n`npm start` runs `npx mex open`. It starts a small local server at `http:\u002F\u002Flocalhost:4820\u002F` and opens the examples in your browser. Pick one in the sidebar, or move with `[` and `]`. Each example has a **Guide** (its README) and its **Code**. Some also have a **Try it** page, where you change the input and see the result.\n\nTry it pages keep their inputs and results when you switch tabs or examples. A run can finish while you view another page. Refreshing or closing the browser tab clears this state.\n\nYour keys stay in the local server. The browser never receives them. A key you add with `npx mex setup` works without a restart. Press Ctrl+C in the terminal to stop the server.\n\nTo open one example: `npx mex open next-token-probabilities`.\n\n## Paid APIs\n\nExamples that call a model use **your own API key**, and the provider bills **your account**. They all use the Responses API, on OpenRouter (recommended: one key for every lab) or OpenAI. One key is enough; when both are set, examples use OpenRouter. The default model is GPT-6 Luna, which is small and cheap: one run usually costs less than a cent. Set a spending limit in your provider console.\n\n`mex` never prints a key. Request output shows auth headers as `\u003Credacted>`.\n\n## Commands\n\n| Command | What it does |\n|---|---|\n| `npx mex open [name]` | Opens the examples in your browser. Same as `npm start`. |\n| `npx mex setup` | Asks for provider keys with hidden input and writes `.env`. |\n| `npx mex doctor` | Shows the Node version, which keys are set, and what you can run. |\n| `npx mex doctor --check` | Also tests each set key with one free authenticated call. |\n| `npx mex doctor --models` | Also lists the models each key can use. |\n| `npx mex list` | Lists examples, skills and tools, with a summary and key status. |\n| `npx mex run \u003Cname> [args]` | Runs an example or a tool. Stops first if a key is missing. |\n| `npx mex show \u003Cname>` | Prints the README of an example, skill or tool. |\n| `npx mex new \u003Ckind> \u003Cname> [--ui]` | Creates a folder for your own example, skill or tool. `--ui` adds a browser page. |\n| `npx mex check` | Validates folder names and metadata. |\n\nnpm scripts do the same: `npm start`, `npm run setup`, `npm run doctor`, `npm run list`, `npm test`.\n\nRun `npx mex` only inside this repo, after `npm install`. Outside the repo, npx looks for a different package on the npm registry.\n\n## Folders\n\n```\nexamples\u002F\u003Cname>\u002F   A script that shows one mechanic. README.md + index.ts.\n                   Optional: ui\u002F (a browser page) and api.ts (what the page calls).\nskills\u002F\u003Cname>\u002F     An Agent Skill: SKILL.md, plus optional scripts\u002F and references\u002F.\ntools\u002F\u003Cname>\u002F      A CLI or MCP tool that you can keep using. README.md + entry file.\nshared\u002F            Env loading, provider config, output helpers.\ncli\u002F               The mex CLI, and the browser viewer (cli\u002Fviewer).\nlessons.json       Which lesson each example comes from. The viewer groups its sidebar by it.\n```\n\nA name describes the idea, not the lesson: `tokenization-round-trip`, `next-token-probabilities`, `agent-loop`.\n\n## How lessons link here\n\nA lesson links to an example by its name. The name opens the example in your panel, at `http:\u002F\u002Flocalhost:4820\u002F#\u002F\u003Cname>`: it works while `npm start` runs. The small GitHub link next to it opens the folder on GitHub:\n\n```\nhttps:\u002F\u002Fgithub.com\u002FMEGA-DOT-DEV\u002Fexamples\u002Ftree\u002Fmain\u002Fexamples\u002Ftokenization-round-trip\n```\n\nRun it locally with `npx mex run tokenization-round-trip`.\n\n## Skills\n\nA skill folder uses the standard Agent Skills format. Install one for your agent:\n\n```bash\nnpx skills add MEGA-DOT-DEV\u002Fexamples --skill \u003Cname>\n```\n\n## Models\n\n`shared\u002Fproviders.ts` holds the default models. Most pages have a model field, and every script takes `--provider` and `--model`. To change a default, set a variable in `.env`:\n\n```\nMEGA_OPENROUTER_MODEL=openai\u002Fgpt-6-luna\nMEGA_OPENROUTER_SMALL_MODEL=openai\u002Fgpt-5-nano\nMEGA_OPENROUTER_LOGPROBS_MODEL=meta-llama\u002Fllama-3.1-8b-instruct\nMEGA_OPENAI_MODEL=gpt-6-luna\nMEGA_OPENAI_SMALL_MODEL=gpt-5-nano\nMEGA_OPENAI_LOGPROBS_MODEL=gpt-6-luna\n```\n\nSome examples use a `small` model next to the default model. Set its own override to try another small model without changing the default model.\n\n`npx mex doctor --models` shows the models your key can use, and tells you if a default is not available.\n\n`MEGA_\u003CPROVIDER>_BASE_URL` (for example `MEGA_OPENAI_BASE_URL`) sends requests to another address, such as a proxy. The tests use it to point examples at a local mock.\n\n## Fonts\n\nThe browser pages use Geist Sans, Geist Mono and Geist Pixel, under the SIL Open Font License (`cli\u002Fviewer\u002Fkit\u002Ffonts\u002FLICENSE-Geist.txt`).\n","这是一个面向大语言模型（LLM）开发者的教学示例仓库，配套MEGA开发者课程，提供按课时渐进的实操代码范例。核心功能包括：覆盖LLM基础机制（如token处理、API请求、工具调用、智能体循环）的小型可运行脚本；统一CLI工具`mex`管理启动、配置与示例浏览；本地Web面板（http:\u002F\u002Flocalhost:4820\u002F）支持交互式查看指南、源码和实时试运行；支持OpenRouter\u002FOpenAI等主流API，密钥本地存储、不上传浏览器。适用于LLM初学者系统学习API集成、智能体构建与提示工程实践场景。",2,"2026-11-24 04:33:01","CREATED_QUERY"]