insightfulpipe 0.3.0 → 0.4.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.
@@ -7,26 +7,16 @@ import { fail } from '../errors.js';
7
7
  import { confirm } from '../input.js';
8
8
  import { parseIntegerOption } from '../options.js';
9
9
  import { AGENT_NAMES, AGENTS, DEFAULT_AGENT, resolveSkillsDir } from '../../skills/agents.js';
10
- import {
11
- fetchCatalog,
12
- fetchSkillFiles,
13
- fetchSkillZip,
14
- getCatalogUrl,
15
- pageUrl,
16
- resolveSkill,
17
- skillKey,
18
- } from '../../skills/catalog.js';
19
- import {
20
- installSkill,
21
- lexists,
22
- listInstalled,
23
- localChanges,
24
- removeInstalled,
25
- validateBundle,
26
- } from '../../skills/installer.js';
10
+ import { fetchSkillZip, skillKey } from '../../skills/catalog.js';
11
+ import { installSkill, lexists, listInstalled, localChanges, removeInstalled } from '../../skills/installer.js';
12
+ import { isPrivateKey } from '../../skills/private.js';
13
+ import { forgetInstall, isRecordedInstall, realFolderPath, recordInstall } from '../../skills/records.js';
14
+ import { markerLabel, markerOrigin, openSource, sourcesForMarkers } from '../../skills/sources.js';
27
15
 
28
16
  const MCP_TIP =
29
17
  'Skills read live data through the InsightfulPipe MCP. Connect it once: https://insightfulpipe.com/mcp-servers';
18
+ const PRIVATE_IN_PROJECT =
19
+ 'This private workspace skill is in a project folder. Keep it out of shared or public repositories (add the folder to .gitignore).';
30
20
 
31
21
  function withTargetOptions(command) {
32
22
  return command
@@ -35,6 +25,33 @@ function withTargetOptions(command) {
35
25
  .option('--dir <path>', 'Use this skills directory instead');
36
26
  }
37
27
 
28
+ const NOT_YOURS =
29
+ 'Not installed by you here, so it is never checked or updated. To use it, install it again with --private --force.';
30
+
31
+ /** The HTTP status of a failed app request, for the JSON, when the error carries one. */
32
+ function httpStatus(error) {
33
+ return error?.httpStatus ? { http_status: error.httpStatus } : {};
34
+ }
35
+
36
+ /** The options that point a command at the same skills folder, for commands the CLI suggests. */
37
+ function folderArgs(where) {
38
+ if (where.scope === 'custom') return ` --dir ${JSON.stringify(where.dir)}`;
39
+ const agent = where.agent && where.agent !== DEFAULT_AGENT ? ` --agent ${where.agent}` : '';
40
+ return `${agent}${where.scope === 'project' ? ' --project' : ''}`;
41
+ }
42
+
43
+ /** A private marker is the user's only when the install record names its folder: any other may have come
44
+ * with a cloned repository, so nothing is fetched, written or sent for it. */
45
+ function trusted(dir, marker) {
46
+ return markerOrigin(marker) === 'public' || isRecordedInstall(dir, marker);
47
+ }
48
+
49
+ function withPrivateOptions(command) {
50
+ return command
51
+ .option('--private', "Use your workspace's private skills (app API, needs your API key) instead of the public library")
52
+ .option('-w, --workspace <id>', 'Workspace for --private (defaults to the one saved with "insightfulpipe use")');
53
+ }
54
+
38
55
  function target(opts) {
39
56
  try {
40
57
  return resolveSkillsDir({ agent: opts.agent, project: Boolean(opts.project), dir: opts.dir });
@@ -43,29 +60,20 @@ function target(opts) {
43
60
  }
44
61
  }
45
62
 
46
- async function loadCatalog() {
63
+ async function loadSource(opts) {
64
+ if (opts.workspace !== undefined && !opts.private) {
65
+ fail('--workspace applies to private skills only.', 'Add --private to use your workspace\'s private skills.');
66
+ }
47
67
  try {
48
- return await fetchCatalog();
68
+ return await openSource(opts);
49
69
  } catch (error) {
50
- fail(error.message);
70
+ fail(error.message, undefined, httpStatus(error));
51
71
  }
52
72
  }
53
73
 
54
- function installHint(skill, skills) {
55
- const sameSlug = skills.filter((other) => other.slug === skill.slug).length > 1;
56
- return `insightfulpipe skills install ${sameSlug ? skillKey(skill) : skill.slug}`;
57
- }
58
-
59
- function summarize(skill, skills) {
60
- return {
61
- skill: skill.slug,
62
- category: skill.category,
63
- name: skill.displayName,
64
- description: skill.description,
65
- version: skill.version ?? null,
66
- install: installHint(skill, skills),
67
- page: pageUrl(skill),
68
- };
74
+ /** What the JSON says about the source: public, or private with its workspace. */
75
+ function sourceFields(source) {
76
+ return source.origin === 'private' ? { source: 'private', workspace_id: source.workspaceId } : { source: 'public' };
69
77
  }
70
78
 
71
79
  function short(text, max) {
@@ -77,37 +85,67 @@ function agentLabel(where) {
77
85
  return where.agent ? AGENTS[where.agent].label : 'the chosen folder';
78
86
  }
79
87
 
80
- /** Download, verify and write one skill. Returns a result row; never exits. */
81
88
  /** Downloads one skill and checks it; `row` describes the failure when there is no `validated`. */
82
- async function fetchChecked(skill) {
89
+ async function fetchChecked(source, skill) {
83
90
  let bundle;
84
91
  try {
85
- bundle = await fetchSkillFiles(skill.category, skill.slug);
92
+ bundle = await source.files(skill);
86
93
  } catch (error) {
87
- return { row: { skill: skillKey(skill), error: error.message } };
94
+ return { row: { skill: skillKey(skill), error: error.message, ...httpStatus(error) } };
88
95
  }
89
96
  if (!bundle) {
90
- return { row: { skill: skillKey(skill), error: 'The catalogue has no files for this skill.' } };
97
+ return { row: { skill: skillKey(skill), error: `The ${source.origin} source has no files for this skill.` } };
91
98
  }
92
99
  try {
93
- return { validated: validateBundle(bundle, skill) };
100
+ return { validated: source.validate(bundle, skill) };
94
101
  } catch (error) {
95
102
  return { row: { skill: skillKey(skill), error: error.message } };
96
103
  }
97
104
  }
98
105
 
99
- function installChecked(skill, where, validated, force) {
106
+ /** Keeps the install record in step with the folder: a private install is recorded, anything else that
107
+ * now holds the folder is not. */
108
+ function recordOutcome(source, skill, path) {
109
+ try {
110
+ if (source.origin === 'private') recordInstall(path, { key: skill.key, workspaceId: source.workspaceId, slug: skill.slug });
111
+ else forgetInstall(realFolderPath(path));
112
+ return '';
113
+ } catch (error) {
114
+ return `The install could not be recorded (${error.message}), so list and update will not trust this private skill.`;
115
+ }
116
+ }
117
+
118
+ function installChecked(source, skill, where, validated, force) {
100
119
  try {
101
- const { path, warning } = installSkill(where.dir, skill, validated, { force, source: getCatalogUrl() });
102
- return { ok: true, row: { skill: skillKey(skill), version: validated.version, path, ...(warning ? { warning } : {}) } };
120
+ const { path, warning } = installSkill(where.dir, skill, validated, { force, ...source.installOptions(skill) });
121
+ const notes = [
122
+ warning,
123
+ recordOutcome(source, skill, path),
124
+ source.origin === 'private' && where.scope !== 'global' ? PRIVATE_IN_PROJECT : '',
125
+ ].filter(Boolean);
126
+ return {
127
+ ok: true,
128
+ row: { skill: skillKey(skill), version: validated.version, path, ...(notes.length ? { warning: notes.join(' ') } : {}) },
129
+ };
103
130
  } catch (error) {
104
131
  return { ok: false, row: { skill: skillKey(skill), error: error.message } };
105
132
  }
106
133
  }
107
134
 
108
- async function installOne(skill, where, force) {
109
- const fetched = await fetchChecked(skill);
110
- return fetched.validated ? installChecked(skill, where, fetched.validated, force) : { ok: false, row: fetched.row };
135
+ async function installOne(source, skill, where, force) {
136
+ const fetched = await fetchChecked(source, skill);
137
+ return fetched.validated ? installChecked(source, skill, where, fetched.validated, force) : { ok: false, row: fetched.row };
138
+ }
139
+
140
+ /** Installed skills a name points at: the folder name, `category/name`, or a private skill's key. */
141
+ function findInstalled(installed, name) {
142
+ const wanted = String(name).toLowerCase().replace(/^@insightfulpipe\//, '');
143
+ return installed.filter(
144
+ ({ marker }) =>
145
+ marker.slug === wanted ||
146
+ markerLabel(marker) === wanted ||
147
+ (markerOrigin(marker) === 'private' && isPrivateKey(wanted) && marker.key === wanted),
148
+ );
111
149
  }
112
150
 
113
151
  export function registerSkillsCommand(program) {
@@ -115,99 +153,118 @@ export function registerSkillsCommand(program) {
115
153
  .command('skills')
116
154
  .description('Find and install InsightfulPipe skills for Claude Code, OpenClaw, Codex, Cursor and Gemini CLI');
117
155
 
118
- skills
119
- .command('search')
120
- .argument('[query...]', 'Words to look for in the skill name, category or description')
121
- .option('-c, --category <category>', 'Only skills in this category (e.g., google-ads, seo)')
122
- .option('--limit <n>', 'Show at most this many skills')
123
- .description('Browse or search the skills catalogue')
124
- .action(async (words, opts, command) => {
125
- const catalog = await loadCatalog();
126
- const terms = (words || []).join(' ').toLowerCase().split(/\s+/).filter(Boolean);
127
- let found = catalog.skills.filter((skill) => {
128
- if (opts.category && skill.category !== opts.category) return false;
129
- const haystack = `${skill.slug} ${skill.displayName} ${skill.description} ${skill.category}`.toLowerCase();
130
- return terms.every((term) => haystack.includes(term));
131
- });
132
- if (opts.limit) found = found.slice(0, parseIntegerOption('limit', opts.limit));
133
-
134
- if (wantsJson(command)) {
135
- printJson({ status: 'success', count: found.length, skills: found.map((skill) => summarize(skill, catalog.skills)) });
136
- return;
137
- }
138
- printTable(
139
- found.map((skill) => ({ skill: skill.slug, category: skill.category, description: short(skill.description, 70) })),
140
- [
141
- { key: 'skill', label: 'Skill' },
142
- { key: 'category', label: 'Category' },
143
- { key: 'description', label: 'Description' },
144
- ],
145
- );
156
+ withPrivateOptions(
157
+ skills
158
+ .command('search')
159
+ .argument('[query...]', 'Words to look for in the skill name, category or description')
160
+ .option('-c, --category <category>', 'Only skills in this category (e.g., google-ads, seo)')
161
+ .option('--limit <n>', 'Show at most this many skills')
162
+ .description('Browse or search the public library, or your private skills with --private'),
163
+ ).action(async (words, opts, command) => {
164
+ if (opts.private && opts.category) fail('--category applies to the public library, not to private skills.');
165
+ const source = await loadSource(opts);
166
+ const terms = (words || []).join(' ').toLowerCase().split(/\s+/).filter(Boolean);
167
+ let found = source.skills.filter((skill) => {
168
+ if (opts.category && skill.category !== opts.category) return false;
169
+ const haystack = [skill.slug, skill.key, skill.displayName, skill.name, skill.description, skill.category, skill.data_source]
170
+ .filter(Boolean)
171
+ .join(' ')
172
+ .toLowerCase();
173
+ return terms.every((term) => haystack.includes(term));
146
174
  });
175
+ if (opts.limit) found = found.slice(0, parseIntegerOption('limit', opts.limit));
147
176
 
148
- skills
149
- .command('info')
150
- .argument('<skill>', 'Skill name, category/name, or @insightfulpipe/name')
151
- .description('Show what a skill does, its files and how to install it')
152
- .action(async (name, opts, command) => {
153
- const catalog = await loadCatalog();
154
- const found = resolveSkill(name, catalog.skills);
155
- if (found.error) fail(found.error);
156
- const skill = found.skill;
157
- const info = {
158
- ...summarize(skill, catalog.skills),
159
- files: (skill.files || []).map((file) => ({ path: file.path, size: file.size })),
160
- };
161
-
162
- if (wantsJson(command)) {
163
- printJson({ status: 'success', skill: info });
164
- return;
165
- }
166
- console.log(`${info.name} (${skillKey(skill)})`);
167
- console.log(`Version: ${info.version ?? 'unknown'}`);
168
- console.log(`Page: ${info.page}`);
169
- console.log(`Install: ${info.install}`);
170
- console.log(`Files: ${info.files.map((file) => file.path).join(', ') || 'unknown'}`);
171
- console.log('');
172
- console.log(info.description);
173
- });
177
+ if (wantsJson(command)) {
178
+ printJson({ status: 'success', ...sourceFields(source), count: found.length, skills: found.map(source.summarize) });
179
+ return;
180
+ }
181
+ printTable(
182
+ found.map((skill) => ({ skill: skill.slug, category: skill.category, description: short(skill.description, 70) })),
183
+ [
184
+ { key: 'skill', label: 'Skill' },
185
+ { key: 'category', label: 'Category' },
186
+ { key: 'description', label: 'Description' },
187
+ ],
188
+ );
189
+ });
174
190
 
175
- withTargetOptions(
191
+ withPrivateOptions(
176
192
  skills
177
- .command('install')
178
- .argument('[skills...]', 'One or more skills: name, category/name, or @insightfulpipe/name')
179
- .option('-c, --category <category>', 'Install every skill in this category')
180
- .option('-f, --force', 'Replace a skill folder that already exists')
181
- .description('Download skills into your agent\'s skills folder (Claude Code by default)'),
193
+ .command('info')
194
+ .argument('<skill>', 'Skill name, category/name, or @insightfulpipe/name (with --private: name or key)')
195
+ .description('Show what a skill does, its files and how to install it'),
196
+ ).action(async (name, opts, command) => {
197
+ const source = await loadSource(opts);
198
+ const found = source.resolve(name);
199
+ if (found.error) fail(found.error);
200
+ const skill = found.skill;
201
+ const info = {
202
+ ...source.summarize(skill),
203
+ files: (skill.files || []).map((file) => ({ path: file.path, size: file.size })),
204
+ };
205
+
206
+ if (wantsJson(command)) {
207
+ printJson({ status: 'success', ...sourceFields(source), skill: info });
208
+ return;
209
+ }
210
+ console.log(`${info.name} (${skillKey(skill)}${info.key ? `, ${info.key}, workspace ${source.workspaceId}` : ''})`);
211
+ console.log(`Version: ${info.version ?? 'unknown'}`);
212
+ if (info.page) console.log(`Page: ${info.page}`);
213
+ console.log(`Install: ${info.install}`);
214
+ console.log(`Files: ${info.files.map((file) => file.path).join(', ') || 'unknown'}`);
215
+ console.log('');
216
+ console.log(info.description);
217
+ });
218
+
219
+ withPrivateOptions(
220
+ withTargetOptions(
221
+ skills
222
+ .command('install')
223
+ .argument('[skills...]', 'One or more skills: name, category/name, or @insightfulpipe/name (with --private: name or key)')
224
+ .option('-c, --category <category>', 'Install every skill in this category')
225
+ .option('-f, --force', 'Replace a skill folder that already exists')
226
+ .description('Download skills into your agent\'s skills folder (Claude Code by default)'),
227
+ ),
182
228
  ).action(async (names, opts, command) => {
229
+ if (opts.private && opts.category) fail('--category applies to the public library, not to private skills.');
183
230
  if (!names?.length && !opts.category) {
184
231
  fail('Name at least one skill, or use --category.', 'Run: insightfulpipe skills search');
185
232
  }
186
233
  const where = target(opts);
187
- const catalog = await loadCatalog();
234
+ const source = await loadSource(opts);
188
235
 
189
236
  const chosen = [];
190
237
  for (const name of names || []) {
191
- const found = resolveSkill(name, catalog.skills);
238
+ const found = source.resolve(name);
192
239
  if (found.error) fail(found.error);
193
240
  chosen.push(found.skill);
194
241
  }
195
242
  if (opts.category) {
196
- const inCategory = catalog.skills.filter((skill) => skill.category === opts.category);
243
+ const inCategory = source.skills.filter((skill) => skill.category === opts.category);
197
244
  if (!inCategory.length) fail(`No skills in category "${opts.category}".`, 'Run: insightfulpipe skills search');
198
245
  chosen.push(...inCategory);
199
246
  }
200
- const unique = [...new Map(chosen.map((skill) => [skillKey(skill), skill])).values()];
247
+ const unique = [...new Map(chosen.map((skill) => [skill.key ?? skillKey(skill), skill])).values()];
201
248
 
202
249
  const installed = [];
203
250
  const failed = [];
251
+ const folders = new Map();
204
252
  for (const skill of unique) {
205
- const result = await installOne(skill, where, Boolean(opts.force));
253
+ const label = skill.key ? `${skillKey(skill)} (${skill.key})` : skillKey(skill);
254
+ if (folders.has(skill.slug)) {
255
+ failed.push({
256
+ skill: skillKey(skill),
257
+ error: `${folders.get(skill.slug)} goes into the same folder, ${skill.slug}. Install one of them, or the other into another folder with --dir.`,
258
+ });
259
+ continue;
260
+ }
261
+ folders.set(skill.slug, label);
262
+ const result = await installOne(source, skill, where, Boolean(opts.force));
206
263
  (result.ok ? installed : failed).push(result.row);
207
264
  }
208
265
 
209
266
  if (wantsJson(command)) {
210
- const report = { agent: where.agent, scope: where.scope, skills_dir: where.dir, installed, failed };
267
+ const report = { ...sourceFields(source), agent: where.agent, scope: where.scope, skills_dir: where.dir, installed, failed };
211
268
  if (!installed.length) fail('No skill was installed.', undefined, report);
212
269
  printJson({
213
270
  status: failed.length ? 'partial' : 'success',
@@ -228,48 +285,64 @@ export function registerSkillsCommand(program) {
228
285
  ).action(async (opts, command) => {
229
286
  const where = target(opts);
230
287
  const installed = listInstalled(where.dir);
231
-
232
- let catalog = null;
233
- if (installed.length) {
234
- try {
235
- catalog = await fetchCatalog();
236
- } catch {
237
- catalog = null; // Offline still lists what is installed; it just can't say what is newer.
288
+ const sourceFor = sourcesForMarkers();
289
+ let publicReached = null;
290
+
291
+ const rows = [];
292
+ for (const { dir, marker } of installed) {
293
+ const origin = markerOrigin(marker);
294
+ const ours = trusted(dir, marker);
295
+ let latest = null;
296
+ let checked = false;
297
+ let status = {};
298
+ const problems = [];
299
+ if (ours) {
300
+ try {
301
+ latest = (await sourceFor(marker)).find(marker)?.version ?? null;
302
+ checked = true;
303
+ if (origin === 'public') publicReached = true;
304
+ } catch (error) {
305
+ // Offline, the public library still lists what is installed; a private source that refuses is an error.
306
+ if (origin === 'public') publicReached = false;
307
+ else {
308
+ problems.push(`Could not check for updates: ${error.message}`);
309
+ status = httpStatus(error);
310
+ }
311
+ }
238
312
  }
239
- }
240
- const latestFor = (marker) =>
241
- catalog?.skills.find((skill) => skill.category === marker.category && skill.slug === marker.slug)?.version ?? null;
242
-
243
- const rows = installed.map(({ dir, marker }) => {
244
- const latest = latestFor(marker);
245
313
  let edited = null;
246
- let problem;
247
314
  try {
248
315
  edited = localChanges(dir, marker).edited;
249
316
  } catch (error) {
250
- problem = `Could not check for local edits: ${error.message}`;
317
+ problems.push(`Could not check for local edits: ${error.message}`);
251
318
  }
252
- return {
253
- skill: `${marker.category}/${marker.slug}`,
319
+ rows.push({
320
+ skill: markerLabel(marker),
321
+ origin,
322
+ ...(origin === 'private' ? { trusted: ours } : {}),
323
+ ...(origin === 'private' && ours ? { key: marker.key, workspace_id: marker.workspace_id } : {}),
254
324
  version: marker.version,
255
325
  latest,
326
+ latest_checked: checked,
327
+ ...(ours ? {} : { note: NOT_YOURS }),
256
328
  update_available: Boolean(latest && latest !== marker.version),
257
329
  locally_edited: edited,
258
330
  path: dir,
259
- ...(problem ? { error: problem } : {}),
260
- };
261
- });
331
+ ...(problems.length ? { error: problems.join(' '), ...status } : {}),
332
+ });
333
+ }
262
334
 
335
+ const unchecked = rows.some((row) => row.error);
263
336
  if (wantsJson(command)) {
264
337
  printJson({
265
- status: 'success',
338
+ status: unchecked ? 'partial' : 'success',
266
339
  agent: where.agent,
267
340
  scope: where.scope,
268
341
  skills_dir: where.dir,
269
- catalog: installed.length ? (catalog ? 'checked' : 'unreachable') : 'not needed',
342
+ catalog: publicReached === null ? 'not needed' : publicReached ? 'checked' : 'unreachable',
270
343
  skills: rows,
271
344
  });
272
- if (rows.some((row) => row.error)) process.exitCode = 1;
345
+ if (unchecked) process.exitCode = 1;
273
346
  return;
274
347
  }
275
348
  printTable(
@@ -277,7 +350,7 @@ export function registerSkillsCommand(program) {
277
350
  skill: row.skill,
278
351
  version: row.version,
279
352
  status: row.update_available ? `update: ${row.latest}` : row.latest ? 'up to date' : 'unknown',
280
- edited: row.error ? 'unknown' : row.locally_edited ? 'yes' : '',
353
+ edited: row.locally_edited === null ? 'unknown' : row.locally_edited ? 'yes' : '',
281
354
  })),
282
355
  [
283
356
  { key: 'skill', label: 'Skill' },
@@ -287,6 +360,7 @@ export function registerSkillsCommand(program) {
287
360
  ],
288
361
  );
289
362
  for (const row of rows) {
363
+ if (row.note) console.error(`${row.skill}: ${row.note}`);
290
364
  if (row.error) {
291
365
  console.error(`${row.skill}: ${row.error}`);
292
366
  process.exitCode = 1;
@@ -313,10 +387,7 @@ export function registerSkillsCommand(program) {
313
387
  targets.push(...installed);
314
388
  } else {
315
389
  for (const name of names) {
316
- const wanted = String(name).toLowerCase().replace(/^@insightfulpipe\//, '');
317
- const matches = installed.filter(
318
- ({ marker }) => marker.slug === wanted || `${marker.category}/${marker.slug}` === wanted,
319
- );
390
+ const matches = findInstalled(installed, name);
320
391
  if (matches.length !== 1) {
321
392
  fail(matches.length ? `"${name}" matches more than one installed skill.` : `"${name}" is not installed in ${where.dir}.`);
322
393
  }
@@ -324,20 +395,38 @@ export function registerSkillsCommand(program) {
324
395
  }
325
396
  }
326
397
 
327
- const catalog = targets.length ? await loadCatalog() : { skills: [] };
398
+ const sourceFor = sourcesForMarkers();
328
399
  const result = { updated: [], up_to_date: [], skipped: [], failed: [] };
329
400
  for (const { dir, marker } of targets) {
330
- const key = `${marker.category}/${marker.slug}`;
331
- const latest = catalog.skills.find((skill) => skill.category === marker.category && skill.slug === marker.slug);
401
+ const key = markerLabel(marker);
402
+ if (!trusted(dir, marker)) {
403
+ result.skipped.push({ skill: key, reason: NOT_YOURS });
404
+ continue;
405
+ }
406
+ let source;
407
+ try {
408
+ source = await sourceFor(marker);
409
+ } catch (error) {
410
+ result.failed.push({ skill: key, error: `Could not check for updates: ${error.message}`, ...httpStatus(error) });
411
+ continue;
412
+ }
413
+ const latest = source.find(marker);
332
414
  if (!latest) {
333
- result.skipped.push({ skill: key, reason: 'It is no longer in the catalogue; left as it is.' });
415
+ result.skipped.push({ skill: key, reason: `It is no longer in the ${source.origin === 'private' ? "workspace's private skills" : 'catalogue'}; left as it is.` });
416
+ continue;
417
+ }
418
+ if (source.origin === 'private' && latest.slug !== marker.slug) {
419
+ result.skipped.push({
420
+ skill: key,
421
+ reason: `It was renamed to ${latest.slug}. Install it again with "insightfulpipe skills install ${latest.key} --private --workspace ${marker.workspace_id}${folderArgs(where)}", then remove ${marker.slug}${folderArgs(where)}.`,
422
+ });
334
423
  continue;
335
424
  }
336
425
  if (latest.version && latest.version === marker.version) {
337
426
  result.up_to_date.push({ skill: key, version: marker.version });
338
427
  continue;
339
428
  }
340
- const fetched = await fetchChecked(latest);
429
+ const fetched = await fetchChecked(source, latest);
341
430
  if (!fetched.validated) {
342
431
  result.failed.push(fetched.row);
343
432
  continue;
@@ -359,7 +448,7 @@ export function registerSkillsCommand(program) {
359
448
  });
360
449
  continue;
361
450
  }
362
- const outcome = installChecked(latest, where, fetched.validated, true);
451
+ const outcome = installChecked(source, latest, where, fetched.validated, true);
363
452
  if (outcome.ok) result.updated.push({ ...outcome.row, from: marker.version });
364
453
  else result.failed.push(outcome.row);
365
454
  }
@@ -388,10 +477,7 @@ export function registerSkillsCommand(program) {
388
477
  const where = target(opts);
389
478
  const installed = listInstalled(where.dir);
390
479
  const targets = names.map((name) => {
391
- const wanted = String(name).toLowerCase().replace(/^@insightfulpipe\//, '');
392
- const matches = installed.filter(
393
- ({ marker }) => marker.slug === wanted || `${marker.category}/${marker.slug}` === wanted,
394
- );
480
+ const matches = findInstalled(installed, name);
395
481
  if (matches.length !== 1) {
396
482
  fail(matches.length ? `"${name}" matches more than one installed skill.` : `"${name}" is not an InsightfulPipe skill installed in ${where.dir}.`);
397
483
  }
@@ -406,12 +492,19 @@ export function registerSkillsCommand(program) {
406
492
 
407
493
  const removed = [];
408
494
  for (const { dir, marker } of targets) {
495
+ const realPath = realFolderPath(dir);
409
496
  try {
410
497
  removeInstalled(dir);
411
- removed.push({ skill: `${marker.category}/${marker.slug}`, path: dir });
412
498
  } catch (error) {
413
499
  fail(error.message);
414
500
  }
501
+ let warning;
502
+ try {
503
+ forgetInstall(realPath);
504
+ } catch (error) {
505
+ warning = `The install record could not be updated (${error.message}).`;
506
+ }
507
+ removed.push({ skill: markerLabel(marker), path: dir, ...(warning ? { warning } : {}) });
415
508
  }
416
509
  if (wantsJson(command)) printJson({ status: 'success', removed });
417
510
  else for (const row of removed) console.log(`Removed ${row.skill} (${row.path})`);
@@ -422,10 +515,17 @@ export function registerSkillsCommand(program) {
422
515
  .argument('<skill>', 'Skill name, category/name, or @insightfulpipe/name')
423
516
  .option('-o, --output <file>', 'Where to save the ZIP (default: <skill>.zip in this folder)')
424
517
  .option('-f, --force', 'Overwrite the file if it exists')
425
- .description('Save a skill as a ZIP, for uploading in Claude.ai or Claude Desktop')
518
+ .option('--private', 'Not available yet for private skills')
519
+ .description('Save a public skill as a ZIP, for uploading in Claude.ai or Claude Desktop')
426
520
  .action(async (name, opts, command) => {
427
- const catalog = await loadCatalog();
428
- const found = resolveSkill(name, catalog.skills);
521
+ if (opts.private) {
522
+ fail(
523
+ 'Private skills cannot be downloaded as a ZIP from the CLI yet.',
524
+ "Use Download on the skill in the app's Skills Library, or install it with: insightfulpipe skills install <skill> --private",
525
+ );
526
+ }
527
+ const source = await loadSource({});
528
+ const found = source.resolve(name);
429
529
  if (found.error) fail(found.error);
430
530
  const skill = found.skill;
431
531
  const output = resolve(opts.output || `${skill.slug}.zip`);
package/src/config.js CHANGED
@@ -18,7 +18,7 @@ const DEFAULT_CONFIG = {
18
18
  brand_id: null,
19
19
  };
20
20
 
21
- function getConfigDir() {
21
+ export function getConfigDir() {
22
22
  return join(homedir(), '.insightfulpipe');
23
23
  }
24
24
 
@@ -200,9 +200,22 @@ export function getConfigSnapshot() {
200
200
  return buildConfigSnapshot();
201
201
  }
202
202
 
203
+ // What an Authorization header can carry. Real keys are ip_sk_ plus hex; other bearer tokens can come in through the env var.
204
+ const TOKEN_RE = /^[\x21-\x7e]+$/;
205
+
206
+ /** The token without the whitespace a pasted or file-read value often carries at its ends: the same
207
+ * characters the app's header parser (Python's str.split) drops, so 0.3.0 sent such a token as if clean. */
208
+ export function cleanToken(value) {
209
+ return typeof value === 'string' ? value.replace(/^[\s\x85]+|[\s\x85]+$/g, '') || null : null;
210
+ }
211
+
212
+ /** Why a token cannot be sent, or null when it can. */
213
+ export function tokenProblem(token) {
214
+ return TOKEN_RE.test(token) ? null : 'The API token contains spaces, line breaks or other characters an API token never has.';
215
+ }
216
+
203
217
  export function getToken() {
204
- const config = loadConfig();
205
- return config.token;
218
+ return cleanToken(loadConfig().token);
206
219
  }
207
220
 
208
221
  export function getApiUrl() {
package/src/http.js CHANGED
@@ -6,7 +6,7 @@ export const PACKAGE_VERSION = JSON.parse(
6
6
  readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8'),
7
7
  ).version;
8
8
 
9
- /** Sent on every request, so the app's logs and the catalogue can tell CLI calls from MCP ones. */
9
+ /** Sent on every request. The app's Activity log labels key-authenticated calls carrying it as CLI. */
10
10
  export const USER_AGENT = `insightfulpipe-cli/${PACKAGE_VERSION}`;
11
11
 
12
12
  /** The whole body as a Buffer. Past `maxBytes` it returns null (leaving the loop cancels the rest of