mkt-skills 1.2.1 → 1.3.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.
@@ -37,7 +37,7 @@ if (!command || command === '--help' || command === '-h') {
37
37
  }
38
38
 
39
39
  if (command === '--version' || command === '-v') {
40
- console.log('mkt-skills 1.2.1');
40
+ console.log('mkt-skills 1.3.0');
41
41
  process.exit(0);
42
42
  }
43
43
 
@@ -47,7 +47,8 @@ if (!commandMap[command]) {
47
47
  }
48
48
 
49
49
  try {
50
- await commandMap[command](args);
50
+ // subCommand is argv[3]; reassemble the full positional list (it was dropped before)
51
+ await commandMap[command]([subCommand, ...args].filter(Boolean));
51
52
  } catch (err) {
52
53
  if (err.name === 'AbortError') {
53
54
  console.error('Request timed out. Check your internet connection.');
@@ -69,7 +70,7 @@ Usage:
69
70
  Commands:
70
71
  install <slug> Install a skill to ~/.claude/skills/
71
72
  list List all available skills
72
- search <keyword> Search skills by keyword
73
+ search "<query>" Find skills by what you want to do (ranked)
73
74
  info <slug> Show details about a skill
74
75
  uninstall <slug> Remove an installed skill
75
76
  sets List available skill sets
package/lib/api.mjs CHANGED
@@ -8,7 +8,7 @@ async function request(path) {
8
8
  try {
9
9
  const res = await fetch(`${BASE_URL}${path}`, {
10
10
  signal: controller.signal,
11
- headers: { 'User-Agent': 'mkt-skills-cli/1.1.0' },
11
+ headers: { 'User-Agent': 'mkt-skills-cli/1.3.0' },
12
12
  });
13
13
  return res;
14
14
  } finally {
@@ -40,6 +40,13 @@ export async function fetchSet(slug) {
40
40
  return res.json();
41
41
  }
42
42
 
43
+ export async function fetchSearch(query, limit = 5) {
44
+ const params = new URLSearchParams({ q: query, limit: String(limit) });
45
+ const res = await request(`/search?${params.toString()}`);
46
+ if (!res.ok) throw new Error(`Failed to fetch search results (HTTP ${res.status})`);
47
+ return res.json();
48
+ }
49
+
43
50
  export async function fetchInstall(slug, code) {
44
51
  const path = `/install/${encodeURIComponent(slug)}` + (code ? `?code=${encodeURIComponent(code)}` : '');
45
52
  const res = await request(path);
package/lib/commands.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { mkdir, rm, access, writeFile } from 'fs/promises';
2
2
  import { createInterface } from 'readline';
3
- import { fetchCatalog, fetchInstall, fetchSets, fetchSet } from './api.mjs';
3
+ import { fetchCatalog, fetchInstall, fetchSets, fetchSet, fetchSearch } from './api.mjs';
4
4
  import { skillDir, skillFile, installedSlugs } from './paths.mjs';
5
5
  import { bold, dim, green, red, yellow, cyan } from './ui.mjs';
6
6
 
@@ -112,39 +112,43 @@ export async function list(args) {
112
112
 
113
113
  // ── search ──────────────────────────────────────────────────
114
114
 
115
- export async function search(args) {
116
- const query = args.filter(a => !a.startsWith('-')).join(' ').toLowerCase();
115
+ export function renderSearchResults(payload) {
116
+ const { query, results = [] } = payload;
117
+ const out = [];
117
118
 
118
- if (!query) {
119
- console.error('Usage: mkt-skills search <keyword>\n');
120
- process.exit(1);
121
- }
122
-
123
- const catalog = await fetchCatalog();
124
- const results = catalog.filter(s =>
125
- s.slug.includes(query) ||
126
- s.title.toLowerCase().includes(query) ||
127
- s.description.toLowerCase().includes(query) ||
128
- s.categories.some(c => c.toLowerCase().includes(query))
129
- );
130
-
131
- if (results.length === 0) {
132
- console.log(`\nNo skills found matching "${query}".`);
133
- console.log(`${dim('->')} Browse all: ${cyan('npx mkt-skills list')}\n`);
134
- return;
119
+ if (!results.length) {
120
+ out.push(`\nNo close matches for ${bold(`"${query}"`)}.`);
121
+ out.push(`${dim('->')} Browse all: ${cyan('npx mkt-skills list')}\n`);
122
+ return out.join('\n');
135
123
  }
136
124
 
137
- console.log(`\n${bold(`Search: "${query}"`)} (${results.length} results)\n`);
125
+ out.push(`\n${bold(`Best matches for "${query}"`)}\n`);
126
+ results.forEach((r, i) => {
127
+ const price = r.price === 'paid' ? yellow(' [premium]') : '';
128
+ const cats = r.categories?.length ? dim(` (${r.categories.join(', ')})`) : '';
129
+ out.push(` ${bold(`${i + 1}. ${r.slug}`)}${price}${cats}`);
130
+ out.push(` ${r.description}`);
131
+ if (r.matched && r.matched.length) {
132
+ out.push(` ${dim(`↳ matched: ${r.matched.join(', ')}`)}`);
133
+ }
134
+ out.push(` ${dim('Install:')} ${cyan(`npx mkt-skills install ${r.slug}`)}`);
135
+ out.push('');
136
+ });
137
+ return out.join('\n');
138
+ }
138
139
 
139
- for (const s of results) {
140
- const price = s.price === 'paid' ? yellow(' [premium]') : '';
141
- const cats = s.categories.length ? dim(` (${s.categories.join(', ')})`) : '';
142
- console.log(` ${bold(s.slug)}${price}${cats}`);
143
- console.log(` ${s.description}`);
144
- console.log('');
140
+ export async function search(args) {
141
+ const query = args.filter(a => !a.startsWith('-')).join(' ');
142
+ if (!query) {
143
+ console.error('Usage: mkt-skills search "<what you want to do>"\n');
144
+ process.exit(1);
145
145
  }
146
+ const limitFlag = args.find(a => a.startsWith('--limit='));
147
+ const parsedLimit = limitFlag ? parseInt(limitFlag.split('=')[1], 10) : NaN;
148
+ const limit = Number.isInteger(parsedLimit) && parsedLimit > 0 ? parsedLimit : 5;
146
149
 
147
- console.log(`${dim('Install:')} npx mkt-skills install <slug>\n`);
150
+ const payload = await fetchSearch(query, limit);
151
+ console.log(renderSearchResults(payload));
148
152
  }
149
153
 
150
154
  // ── info ────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "mkt-skills",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Install Claude Code marketing skills from marketingskills.directory",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "mkt-skills": "bin/mkt-skills.mjs"
8
8
  },
9
+ "scripts": {
10
+ "test": "node --test"
11
+ },
9
12
  "engines": {
10
13
  "node": ">=18.0.0"
11
14
  },