@edumova/cli 0.0.0-stage → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Edumova contributors
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 CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # @edumova/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Search Edumova — 1,049 MIT education icons — and copy them into your project as files you own. Also runs an MCP server so AI coding agents can find and insert icons. Needs Node 20+. Works offline.
4
+
5
+ ```bash
6
+ npx @edumova/cli search late assignment
7
+ npx @edumova/cli list --category assessment-grading
8
+ npx @edumova/cli categories
9
+ npx @edumova/cli add rubric gradebook --format tsx --out src/components/icons
10
+ ```
11
+
12
+ `add` formats: `svg` (default), `jsx`, `tsx`, `vue` (Vue 3.3+), `svelte` (Svelte 5). Generated components take `size`, `color` and `strokeWidth`, are hidden from screen readers unless labelled, and have no runtime dependency. Existing files are kept unless you pass `--force`.
13
+
14
+ ## MCP server
15
+
16
+ ```bash
17
+ claude mcp add edumova -- npx -y @edumova/cli mcp
18
+ ```
19
+
20
+ Other clients: run `npx -y @edumova/cli mcp` as a stdio server.
21
+
22
+ | Tool | What it does |
23
+ |---|---|
24
+ | `search_icons` | `query`, optional `category` and `limit` → matching icon names and labels |
25
+ | `get_icon` | `name`, `format` (`svg`, `jsx`, `tsx`, `vue`, `svelte`) → file name and source |
26
+ | `list_categories` | categories with icon counts |
27
+
28
+ MIT licence.
package/bin/edumova.js ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ // edumova — search Edumova and copy icons into your project, or run the MCP server for agents.
3
+ import { parseArgs } from 'node:util';
4
+ import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
5
+ import { join, relative } from 'node:path';
6
+ import { icons, find, svgOf, categories } from '../src/data.js';
7
+ import { searchIcons } from '../src/search.js';
8
+ import { render, fileName, FORMATS } from '../src/render.js';
9
+
10
+ const HELP = `edumova — education icons (MIT)
11
+
12
+ edumova search <words...> [--category <id>] [--limit 20]
13
+ edumova list [--category <id>]
14
+ edumova categories
15
+ edumova add <name...> [--format ${FORMATS.join('|')}] [--out icons] [--force]
16
+ edumova mcp start the MCP server (stdio) for AI agents
17
+
18
+ --format svelte writes Svelte 5 components ($props); --format vue needs Vue 3.3+.
19
+
20
+ Examples:
21
+ npx @edumova/cli search late assignment
22
+ npx @edumova/cli add rubric gradebook --format tsx --out src/components/icons
23
+ claude mcp add edumova -- npx -y @edumova/cli mcp
24
+ `;
25
+
26
+ const line = i => `${i.name.padEnd(32)} ${i.label}`;
27
+ const fail = msg => { console.error(msg); process.exit(1); };
28
+
29
+ let parsed;
30
+ try {
31
+ parsed = parseArgs({
32
+ allowPositionals: true,
33
+ options: {
34
+ category: { type: 'string' }, limit: { type: 'string', default: '20' }, format: { type: 'string', default: 'svg' },
35
+ out: { type: 'string', default: 'icons' }, force: { type: 'boolean', default: false }, help: { type: 'boolean', short: 'h' },
36
+ },
37
+ });
38
+ } catch (e) { fail(`${e.message}\n\n${HELP}`); }
39
+ const { values: o, positionals: [cmd, ...args] } = parsed;
40
+ const limit = Number(o.limit);
41
+ if (!Number.isInteger(limit) || limit < 1) fail('--limit must be a whole number of 1 or more');
42
+
43
+ if (!cmd || o.help) console.log(HELP);
44
+ else if (cmd === 'search') {
45
+ const hits = searchIcons(icons(), args.join(' '), o.category).slice(0, limit);
46
+ console.log(hits.map(line).join('\n') || `No icons match "${args.join(' ')}".`);
47
+ } else if (cmd === 'list') {
48
+ console.log(searchIcons(icons(), '', o.category).map(line).join('\n'));
49
+ } else if (cmd === 'categories') {
50
+ console.log(categories().map(c => `${c.name.padEnd(32)} ${c.count}`).join('\n'));
51
+ } else if (cmd === 'add') {
52
+ if (!args.length) fail('Name at least one icon: edumova add rubric');
53
+ if (!FORMATS.includes(o.format)) fail(`--format must be one of: ${FORMATS.join(', ')}`);
54
+ let bad = 0;
55
+ for (const name of args) {
56
+ if (!find(name)) {
57
+ const near = searchIcons(icons(), name.replace(/-/g, ' ')).slice(0, 3).map(i => i.name);
58
+ console.error(`✗ ${name}: no such icon${near.length ? ` (did you mean ${near.join(', ')}?)` : ''}`);
59
+ bad++; continue;
60
+ }
61
+ const file = join(o.out, fileName(name, o.format));
62
+ if (existsSync(file) && !o.force) { console.error(`✗ ${relative('.', file)} exists (use --force to overwrite)`); bad++; continue; }
63
+ mkdirSync(o.out, { recursive: true });
64
+ writeFileSync(file, render(name, svgOf(name), o.format));
65
+ console.log(`✓ ${relative('.', file)}`);
66
+ }
67
+ process.exit(bad ? 1 : 0);
68
+ } else if (cmd === 'mcp') {
69
+ const { startStdio } = await import('../src/mcp.js');
70
+ await startStdio();
71
+ } else fail(`Unknown command "${cmd}".\n\n${HELP}`);
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@edumova/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Search Edumova and copy education icons into your project as SVG, React, Vue or Svelte files. Includes an MCP server for AI agents.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "edumova": "bin/edumova.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "src",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "exports": {
17
+ "./mcp": "./src/mcp.js",
18
+ "./search": "./src/search.js"
19
+ },
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
23
+ "dependencies": {
24
+ "@edumova/static": "^0.1.0",
25
+ "@modelcontextprotocol/sdk": "^1.32.2",
26
+ "zod": "^3.25.76"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }
package/src/data.js ADDED
@@ -0,0 +1,25 @@
1
+ // Icon data comes from @edumova/static, so the CLI and MCP server work offline.
2
+ import { readFileSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
4
+
5
+ const require = createRequire(import.meta.url);
6
+ let index;
7
+
8
+ // [{ name, label, tags, categories, rtlFlip }]
9
+ export function icons() {
10
+ index ??= Object.entries(JSON.parse(readFileSync(require.resolve('@edumova/static/icons.json'), 'utf8'))).map(([name, m]) => ({ name, ...m }));
11
+ return index;
12
+ }
13
+
14
+ export const find = name => icons().find(i => i.name === name);
15
+
16
+ export function svgOf(name) {
17
+ if (!find(name)) throw new Error(`unknown icon "${name}"`);
18
+ return readFileSync(require.resolve(`@edumova/static/icons/${name}.svg`), 'utf8');
19
+ }
20
+
21
+ export function categories() {
22
+ const count = {};
23
+ for (const i of icons()) for (const c of i.categories) count[c] = (count[c] ?? 0) + 1;
24
+ return Object.entries(count).sort().map(([name, n]) => ({ name, count: n }));
25
+ }
package/src/mcp.js ADDED
@@ -0,0 +1,54 @@
1
+ // MCP server: lets an agent search Edumova and get an icon as SVG or a component file.
2
+ // Run: npx @edumova/cli mcp (stdio transport)
3
+ import { createRequire } from 'node:module';
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import { z } from 'zod';
6
+ import { icons, find, svgOf, categories } from './data.js';
7
+ import { searchIcons } from './search.js';
8
+ import { render, fileName, FORMATS } from './render.js';
9
+
10
+ const text = t => ({ content: [{ type: 'text', text: t }] });
11
+
12
+ const { version: VERSION } = createRequire(import.meta.url)('../package.json');
13
+
14
+ export function createServer(version = VERSION) {
15
+ const server = new McpServer({ name: 'edumova', version });
16
+
17
+ server.registerTool('search_icons', {
18
+ title: 'Search education icons',
19
+ description: 'Search Edumova (1,000+ education icons: coursework, grading, attendance, subjects, roles, learning support). Returns icon names to pass to get_icon.',
20
+ inputSchema: { query: z.string().describe('Words to match, e.g. "late assignment" or "microscope"'), category: z.string().optional().describe('Category id from list_categories'), limit: z.number().int().min(1).max(100).default(20) },
21
+ annotations: { readOnlyHint: true },
22
+ }, async ({ query, category, limit }) => {
23
+ const hits = searchIcons(icons(), query, category).slice(0, limit);
24
+ if (!hits.length) return text(`No icons match "${query}". Try fewer or broader words.`);
25
+ return text(hits.map(i => `${i.name} — ${i.label} [${i.categories.join(', ')}]`).join('\n'));
26
+ });
27
+
28
+ server.registerTool('get_icon', {
29
+ title: 'Get an icon',
30
+ description: `Get one icon's source as svg (default) or as a standalone component: ${FORMATS.join(', ')}. Write the result into the user's project under the suggested file name.`,
31
+ inputSchema: { name: z.string().describe('Icon name from search_icons, e.g. "rubric"'), format: z.enum(FORMATS).default('svg') },
32
+ annotations: { readOnlyHint: true },
33
+ }, async ({ name, format }) => {
34
+ if (!find(name)) {
35
+ const near = searchIcons(icons(), name.replace(/-/g, ' ')).slice(0, 5).map(i => i.name);
36
+ return { ...text(`Unknown icon "${name}".${near.length ? ` Did you mean: ${near.join(', ')}?` : ''}`), isError: true };
37
+ }
38
+ return text(`File: ${fileName(name, format)}\n\n${render(name, svgOf(name), format)}`);
39
+ });
40
+
41
+ server.registerTool('list_categories', {
42
+ title: 'List icon categories',
43
+ description: 'List Edumova categories with icon counts. Use a category id to narrow search_icons.',
44
+ inputSchema: {},
45
+ annotations: { readOnlyHint: true },
46
+ }, async () => text(categories().map(c => `${c.name} (${c.count})`).join('\n')));
47
+
48
+ return server;
49
+ }
50
+
51
+ export async function startStdio() {
52
+ const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
53
+ await createServer().connect(new StdioServerTransport());
54
+ }
package/src/render.js ADDED
@@ -0,0 +1,59 @@
1
+ // Turns an icon SVG into a standalone source file. Generated files have no runtime dependency on Edumova.
2
+ export const FORMATS = ['svg', 'jsx', 'tsx', 'vue', 'svelte'];
3
+
4
+ export const pascal = name => {
5
+ const p = name.split('-').map(s => s[0].toUpperCase() + s.slice(1)).join('');
6
+ return /^\d/.test(p) ? `Icon${p}` : p;
7
+ };
8
+
9
+ const children = svg => svg.replace(/ data-part="[^"]*"/g, '').trim().split('\n').slice(1, -1).map(l => l.trim());
10
+ const indent = (lines, pad) => lines.map(l => pad + l).join('\n');
11
+
12
+ export function fileName(name, format) {
13
+ return format === 'svg' ? `${name}.svg` : `${pascal(name)}.${format}`;
14
+ }
15
+
16
+ export function render(name, svg, format = 'svg') {
17
+ const kids = children(svg);
18
+ const label = name.replace(/-/g, ' ');
19
+ if (format === 'svg') return `${svg.replace(/ data-part="[^"]*"/g, '').trim()}\n`;
20
+ if (format === 'jsx' || format === 'tsx') {
21
+ const props = format === 'tsx'
22
+ ? `{ size = 24, color = 'currentColor', strokeWidth = 2, ...props }: React.SVGProps<SVGSVGElement> & { size?: number | string; color?: string; strokeWidth?: number | string }`
23
+ : `{ size = 24, color = 'currentColor', strokeWidth = 2, ...props }`;
24
+ const head = format === 'tsx' ? `import type * as React from 'react';\n\n` : '';
25
+ return `${head}// Edumova "${name}" (MIT). Decorative by default; pass aria-label to announce it.
26
+ export default function ${pascal(name)}(${props}) {
27
+ return (
28
+ <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color}
29
+ strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round" aria-hidden={props['aria-label'] ? undefined : true} {...props}>
30
+ ${indent(kids, ' ')}
31
+ </svg>
32
+ );
33
+ }
34
+ `;
35
+ }
36
+ if (format === 'vue') return `<!-- Edumova "${name}" (MIT). Decorative unless a label is passed. -->
37
+ <script setup>
38
+ defineProps({ size: { type: [Number, String], default: 24 }, color: { type: String, default: 'currentColor' }, strokeWidth: { type: [Number, String], default: 2 }, label: String });
39
+ </script>
40
+
41
+ <template>
42
+ <svg xmlns="http://www.w3.org/2000/svg" :width="size" :height="size" viewBox="0 0 24 24" fill="none" :stroke="color"
43
+ :stroke-width="strokeWidth" stroke-linecap="round" stroke-linejoin="round" :aria-hidden="label ? undefined : 'true'" :aria-label="label" :role="label ? 'img' : undefined">
44
+ ${indent(kids, ' ')}
45
+ </svg>
46
+ </template>
47
+ `;
48
+ if (format === 'svelte') return `<!-- Edumova "${name}" (MIT). Decorative unless a label is passed. -->
49
+ <script>
50
+ let { size = 24, color = 'currentColor', strokeWidth = 2, label, ...rest } = $props();
51
+ </script>
52
+
53
+ <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color}
54
+ stroke-width={strokeWidth} stroke-linecap="round" stroke-linejoin="round" aria-hidden={label ? undefined : 'true'} aria-label={label} role={label ? 'img' : undefined} {...rest}>
55
+ ${indent(kids, ' ')}
56
+ </svg>
57
+ `;
58
+ throw new Error(`unknown format "${format}" (use ${FORMATS.join(', ')}) for ${label}`);
59
+ }
package/src/search.js ADDED
@@ -0,0 +1,25 @@
1
+ // Same ranking as the website search (apps/site/lib/search.mjs), over { name, label, tags, categories }.
2
+ // Every query word must match the name, a tag or the label; better matches rank first.
3
+ function wordScore(ic, w) {
4
+ let s = 0;
5
+ if (ic.name === w) s = 100;
6
+ else if (ic.name.startsWith(w)) s = 60;
7
+ else if (ic.name.split('-').includes(w)) s = 50;
8
+ else if (ic.name.includes(w)) s = 30;
9
+ if (ic.tags.includes(w)) s = Math.max(s, 40);
10
+ else if (ic.tags.some(t => t.includes(w))) s = Math.max(s, 20);
11
+ if (ic.label.toLowerCase().includes(w)) s = Math.max(s, 25);
12
+ return s;
13
+ }
14
+
15
+ export function searchIcons(icons, query = '', category = '') {
16
+ const words = query.toLowerCase().split(/\s+/).filter(Boolean);
17
+ const out = [];
18
+ for (const ic of icons) {
19
+ if (category && !ic.categories.includes(category)) continue;
20
+ let total = 0;
21
+ for (const w of words) { const s = wordScore(ic, w); if (!s) { total = -1; break; } total += s; }
22
+ if (total >= 0) out.push([ic, total]);
23
+ }
24
+ return out.sort((a, b) => b[1] - a[1] || a[0].name.localeCompare(b[0].name)).map(x => x[0]);
25
+ }