@quadient/skillshare 1.17.1 → 1.19.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/README.md +14 -8
- package/dist/agents-claude.js +135 -10
- package/dist/agents-codex.js +185 -14
- package/dist/agents-detect.js +96 -13
- package/dist/agents-form-worker.js +33 -0
- package/dist/agents-forms.js +79 -0
- package/dist/agents-process.js +12 -1
- package/dist/agents-request-upload.js +55 -0
- package/dist/agents-response-hash.js +31 -0
- package/dist/agents-service.js +17 -1
- package/dist/agents-session.js +160 -5
- package/dist/agents-settings.js +133 -0
- package/dist/agents.js +117 -23
- package/dist/cli-args.js +3 -0
- package/dist/help.js +43 -6
- package/dist/index.js +9 -0
- package/dist/news.js +409 -0
- package/dist/teams.js +2 -2
- package/package.json +4 -2
package/dist/news.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { formatDateTime, formatTable } from './output.js';
|
|
3
|
+
const ACTIONS = ['list', 'show', 'read', 'unread', 'post', 'edit', 'delete', 'tags', 'tag', 'subscribe', 'unsubscribe', 'subscriptions', 'feeds', 'feed',
|
|
4
|
+
'review', 'publish', 'repos', 'branches', 'notify'];
|
|
5
|
+
const IMPORTANCE = ['cosmetic', 'normal', 'important'];
|
|
6
|
+
const LOCALES = ['en_us', 'fr_fr', 'cs_cz', 'uk_ua'];
|
|
7
|
+
const LEVEL = { important: 'important only', normal: 'normal and up', cosmetic: 'everything' };
|
|
8
|
+
const TRANSLATION = {
|
|
9
|
+
translated: 'translated from', stale: 'translation updating, from', pending: 'translating from', waiting: 'waiting for a translator agent, in',
|
|
10
|
+
failed: 'translation failed, in', original: 'original in',
|
|
11
|
+
};
|
|
12
|
+
export function newsLink(baseUrl, id) {
|
|
13
|
+
return baseUrl ? `${baseUrl.replace(/\/+$/, '')}/news/${id}` : `/news/${id}`;
|
|
14
|
+
}
|
|
15
|
+
export function renderNewsList(page, baseUrl) {
|
|
16
|
+
if (page.items.length === 0)
|
|
17
|
+
return page.unreadCount === 0 ? 'No news. You are all caught up.' : 'No news matches these filters.';
|
|
18
|
+
const rows = page.items.map((item) => [
|
|
19
|
+
item.unread ? '●' : ' ',
|
|
20
|
+
String(item.id),
|
|
21
|
+
item.importance === 'normal' ? '' : item.importance,
|
|
22
|
+
formatDateTime(item.publishedAt) + (item.scheduled ? ' (scheduled)' : ''),
|
|
23
|
+
item.tags.map((tag) => `#${tag.slug}`).join(' '),
|
|
24
|
+
item.title,
|
|
25
|
+
]);
|
|
26
|
+
const lines = [formatTable(['', 'ID', 'IMPORTANCE', 'DATE', 'TAGS', 'TITLE'], rows)];
|
|
27
|
+
lines.push('', `${page.unreadCount} unread. Open one with: skillshare news show <id>${baseUrl ? ` or ${baseUrl.replace(/\/+$/, '')}/news/<id>` : ''}`);
|
|
28
|
+
if (page.nextCursor)
|
|
29
|
+
lines.push(`More: add --before ${page.nextCursor}`);
|
|
30
|
+
return lines.join('\n');
|
|
31
|
+
}
|
|
32
|
+
export function renderNewsItem(item, baseUrl) {
|
|
33
|
+
const meta = [
|
|
34
|
+
item.importance === 'normal' ? null : item.importance.toUpperCase(),
|
|
35
|
+
item.tags.map((tag) => `#${tag.slug}`).join(' '),
|
|
36
|
+
item.author ? `by ${item.author.name}` : null,
|
|
37
|
+
formatDateTime(item.publishedAt) + (item.scheduled ? ' (scheduled)' : ''),
|
|
38
|
+
item.editedAt ? `edited ${formatDateTime(item.editedAt)}` : null,
|
|
39
|
+
item.feed ? `AI summary from ${item.feed.repository}` : null,
|
|
40
|
+
item.translation ? `${TRANSLATION[item.translation.status] ?? item.translation.status} ${item.translation.sourceLocale}` : `written in ${item.sourceLocale}`,
|
|
41
|
+
].filter(Boolean);
|
|
42
|
+
const sources = (item.sources ?? []).map((source) => ` ${source.label} ${source.url}`);
|
|
43
|
+
return [`#${item.id}${item.draft ? ' [draft]' : ''} ${item.title}`, meta.join(' · '), '', (item.body ?? item.excerpt).trim(),
|
|
44
|
+
...(sources.length ? ['', 'Changes:', ...sources] : []), '', newsLink(baseUrl, item.id)].join('\n');
|
|
45
|
+
}
|
|
46
|
+
export function renderNewsTags(tags) {
|
|
47
|
+
if (tags.length === 0)
|
|
48
|
+
return 'No tags yet. Create one with: skillshare news tag create <slug> --name <name>';
|
|
49
|
+
return formatTable(['TAG', 'NAME', 'NEWS', 'FOLLOWERS', 'YOU FOLLOW', 'UNREAD', 'POSTING'], tags.map((tag) => [
|
|
50
|
+
`#${tag.slug}`, tag.name, String(tag.itemCount), String(tag.subscriberCount),
|
|
51
|
+
tag.subscription ? LEVEL[tag.subscription] : '—', tag.subscription ? String(tag.unreadCount) : '',
|
|
52
|
+
tag.ownersOnly ? 'owners only' : 'everyone',
|
|
53
|
+
]));
|
|
54
|
+
}
|
|
55
|
+
export function renderNewsTag(tag) {
|
|
56
|
+
return [
|
|
57
|
+
`#${tag.slug} ${tag.name !== tag.slug ? tag.name : ''}`.trimEnd(),
|
|
58
|
+
tag.description || '(no description)',
|
|
59
|
+
'',
|
|
60
|
+
`Owners: ${tag.owners.map((owner) => `${owner.name} (${owner.id})`).join(', ')}`,
|
|
61
|
+
`Posting: ${tag.ownersOnly ? 'owners only' : 'everyone'}${tag.canPost ? '' : ' (you cannot post here)'}`,
|
|
62
|
+
`News: ${tag.itemCount} · Followers: ${tag.subscriberCount}${tag.lastPublishedAt ? ` · Last news ${formatDateTime(tag.lastPublishedAt)}` : ''}`,
|
|
63
|
+
`You follow: ${tag.subscription ? `${LEVEL[tag.subscription]} (${tag.unreadCount} unread)` : `no — skillshare news subscribe ${tag.slug}`}`,
|
|
64
|
+
].join('\n');
|
|
65
|
+
}
|
|
66
|
+
export function renderNewsFeeds(feeds) {
|
|
67
|
+
if (feeds.length === 0)
|
|
68
|
+
return 'No repo feeds. Add one with: skillshare news feed create <tag> --repo <alias> --branches <regex>';
|
|
69
|
+
return feeds.map((feed) => [
|
|
70
|
+
`Feed ${feed.id}: ${feed.repository} ${feed.branchPattern} [${feed.enabled ? feed.status : 'paused'}]`,
|
|
71
|
+
` ${feed.grouping === 'daily' ? 'daily digest' : 'news per change'}, ${feed.publishing === 'review' ? 'review first' : 'published automatically'}` +
|
|
72
|
+
`${feed.owner ? `, agent of ${feed.owner.name}` : ''}${feed.agentTarget ? ` on ${feed.agentTarget.listenerId} (${feed.agentTarget.configurationId})` : ''}`,
|
|
73
|
+
feed.branches.length ? ` following ${feed.branches.join(', ')}` : '',
|
|
74
|
+
feed.lastPolledAt ? ` checked ${formatDateTime(feed.lastPolledAt)}` : '',
|
|
75
|
+
feed.lastError ? ` problem: ${feed.lastError}` : '',
|
|
76
|
+
...feed.jobs.slice(0, 5).map((job) => ` job ${job.id}: ${job.status}${job.dryRun ? ' (preview)' : ''}, ${job.changes.length} changes, ${formatDateTime(job.createdAt)}` +
|
|
77
|
+
`${job.itemIds.length ? `, news ${job.itemIds.map((id) => '#' + id).join(' ')}` : ''}${job.error && job.status !== 'done' ? ` — ${job.error}` : ''}` +
|
|
78
|
+
(job.preview ? '\n' + job.preview.map((item) => ` [${item.importance}] ${item.title.en_us}`).join('\n') : '')),
|
|
79
|
+
].filter(Boolean).join('\n')).join('\n\n');
|
|
80
|
+
}
|
|
81
|
+
export function renderNewsSubscriptions(subscriptions) {
|
|
82
|
+
if (subscriptions.length === 0)
|
|
83
|
+
return 'You follow no tags. List them with: skillshare news tags';
|
|
84
|
+
return formatTable(['TAG', 'SHOWS', 'UNREAD', 'SINCE'], subscriptions.map((subscription) => [
|
|
85
|
+
`#${subscription.tag.slug}`, LEVEL[subscription.minImportance], String(subscription.unreadCount), formatDateTime(subscription.created),
|
|
86
|
+
]));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reads, writes and follows news. Showing an item marks it read, as opening it in the browser does,
|
|
90
|
+
* unless --keep-unread is passed.
|
|
91
|
+
*/
|
|
92
|
+
export async function runNewsCommand(client, positionals, flags, print, readText = readStdin) {
|
|
93
|
+
const [action = 'list', ...rest] = positionals;
|
|
94
|
+
if (!ACTIONS.includes(action))
|
|
95
|
+
throw new Error(`Unknown news command '${action}'. Use ${ACTIONS.join(', ')}.`);
|
|
96
|
+
const call = (path, method = 'GET', body) => send(client, path, method, body);
|
|
97
|
+
if (action === 'list') {
|
|
98
|
+
const query = new URLSearchParams();
|
|
99
|
+
if (flags.tag)
|
|
100
|
+
query.set('tag', flags.tag.replace(/^#/, ''));
|
|
101
|
+
if (flags.importance)
|
|
102
|
+
query.set('importance', importance(flags.importance));
|
|
103
|
+
if (flags.unread === 'true')
|
|
104
|
+
query.set('unread', 'true');
|
|
105
|
+
if (flags.search)
|
|
106
|
+
query.set('q', flags.search);
|
|
107
|
+
if (flags.before)
|
|
108
|
+
query.set('before', flags.before);
|
|
109
|
+
if (flags.limit)
|
|
110
|
+
query.set('limit', String(positiveInteger(flags.limit, '--limit')));
|
|
111
|
+
if (flags.lang)
|
|
112
|
+
query.set('lang', locale(flags.lang));
|
|
113
|
+
const page = await call(`${flags.all === 'true' ? '/items' : '/feed'}${query.size ? `?${query}` : ''}`);
|
|
114
|
+
print(page, () => renderNewsList(page, client.baseUrl));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (action === 'show') {
|
|
118
|
+
const id = itemId(rest[0], 'show');
|
|
119
|
+
const query = new URLSearchParams();
|
|
120
|
+
if (flags.lang)
|
|
121
|
+
query.set('lang', locale(flags.lang));
|
|
122
|
+
if (flags.original === 'true')
|
|
123
|
+
query.set('original', 'true');
|
|
124
|
+
const item = await call(`/items/${id}${query.size ? `?${query}` : ''}`);
|
|
125
|
+
if (item.unread && flags['keep-unread'] !== 'true')
|
|
126
|
+
await call('/read', 'POST', { itemIds: [id], read: true });
|
|
127
|
+
print({ ...item, link: newsLink(client.baseUrl, id) }, () => renderNewsItem(item, client.baseUrl));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (action === 'read' || action === 'unread') {
|
|
131
|
+
if (action === 'read' && flags.all === 'true') {
|
|
132
|
+
const result = await call('/read-all', 'POST', {
|
|
133
|
+
tag: flags.tag?.replace(/^#/, '') || null, importance: flags.importance ? importance(flags.importance) : null,
|
|
134
|
+
});
|
|
135
|
+
const count = result.itemIds?.length ?? 0;
|
|
136
|
+
print(result, () => count === 0 ? 'Everything was already read.'
|
|
137
|
+
: `Marked ${count} as read. Undo with: skillshare news unread ${result.itemIds.join(' ')}`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (rest.length === 0)
|
|
141
|
+
throw new Error(`news ${action} requires one or more item ids${action === 'read' ? ', or --all' : ''}`);
|
|
142
|
+
const ids = rest.map((value) => itemId(value, action));
|
|
143
|
+
const result = await call('/read', 'POST', { itemIds: ids, read: action === 'read' });
|
|
144
|
+
print(result, () => `Marked ${result.itemIds?.length ?? ids.length} as ${action}.`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (action === 'post' || action === 'edit') {
|
|
148
|
+
const id = action === 'edit' ? itemId(rest[0], 'edit') : 0;
|
|
149
|
+
const words = action === 'edit' ? rest.slice(1) : rest;
|
|
150
|
+
const existing = id ? await call(`/items/${id}?original=true`) : null;
|
|
151
|
+
const bodyText = flags.file ? await readFile(flags.file, 'utf8') : words.length > 0 && words.join(' ') !== '-' ? words.join(' ') : await readText();
|
|
152
|
+
const body = bodyText.trim() || existing?.body || '';
|
|
153
|
+
const title = flags.title ?? existing?.title;
|
|
154
|
+
const tags = flags.tags !== undefined ? tagList(flags.tags) : existing?.tags.map((tag) => tag.slug) ?? [];
|
|
155
|
+
if (!title)
|
|
156
|
+
throw new Error('news post requires --title "…"');
|
|
157
|
+
if (!body)
|
|
158
|
+
throw new Error('The text is empty. Pass it as arguments, with --file <path>, or pipe it to stdin.');
|
|
159
|
+
if (tags.length === 0)
|
|
160
|
+
throw new Error('news post requires --tags <slug>[,<slug>…]');
|
|
161
|
+
if (flags.lang && !LOCALES.includes(flags.lang))
|
|
162
|
+
throw new Error(`--lang must be one of ${LOCALES.join(', ')}`);
|
|
163
|
+
const input = {
|
|
164
|
+
title, body, tags,
|
|
165
|
+
importance: flags.importance ? importance(flags.importance) : existing?.importance ?? 'normal',
|
|
166
|
+
publishedAt: flags.date ? date(flags.date) : existing?.publishedAt ?? null,
|
|
167
|
+
// Without --lang the server uses the language you last chose in the web app, then English.
|
|
168
|
+
locale: flags.lang ?? existing?.sourceLocale ?? null,
|
|
169
|
+
notifyAgain: flags['notify-again'] === 'true',
|
|
170
|
+
};
|
|
171
|
+
const result = await call(id ? `/items/${id}` : '/items', id ? 'PUT' : 'POST', input);
|
|
172
|
+
const scheduled = input.publishedAt !== null && new Date(input.publishedAt).getTime() > Date.now();
|
|
173
|
+
print({ ...result, link: newsLink(client.baseUrl, result.id) }, () => `${id ? 'Updated' : scheduled ? 'Scheduled' : 'Published'} #${result.id}: ${newsLink(client.baseUrl, result.id)}`);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (action === 'delete') {
|
|
177
|
+
const id = itemId(rest[0], 'delete');
|
|
178
|
+
await call(`/items/${id}`, 'DELETE');
|
|
179
|
+
print({ deleted: id }, () => `Deleted #${id}.`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (action === 'tags') {
|
|
183
|
+
const search = flags.search ?? rest.join(' ');
|
|
184
|
+
const tags = await call(`/tags${search ? `?q=${encodeURIComponent(search)}` : ''}`);
|
|
185
|
+
print(tags, () => renderNewsTags(tags));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (action === 'tag') {
|
|
189
|
+
const [sub, rawSlug] = rest;
|
|
190
|
+
const slug = rawSlug?.replace(/^#/, '');
|
|
191
|
+
if (!sub || !['show', 'create', 'edit'].includes(sub) || !slug)
|
|
192
|
+
throw new Error('Use news tag show|create|edit <slug>.');
|
|
193
|
+
if (sub === 'show') {
|
|
194
|
+
const tag = await call(`/tags/${encodeURIComponent(slug)}`);
|
|
195
|
+
print(tag, () => renderNewsTag(tag));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (flags.lang && !LOCALES.includes(flags.lang))
|
|
199
|
+
throw new Error(`--lang must be one of ${LOCALES.join(', ')}`);
|
|
200
|
+
const existing = sub === 'edit' ? await call(`/tags/${encodeURIComponent(slug)}`) : null;
|
|
201
|
+
const input = {
|
|
202
|
+
slug,
|
|
203
|
+
name: flags.name ?? existing?.name ?? slug,
|
|
204
|
+
description: flags.description ?? existing?.description ?? '',
|
|
205
|
+
ownersOnly: flags['owners-only'] !== undefined ? flags['owners-only'] === 'true' : existing?.ownersOnly ?? false,
|
|
206
|
+
ownerUserIds: flags.owners !== undefined ? flags.owners.split(',').map((value) => positiveInteger(value.trim(), '--owners')) : undefined,
|
|
207
|
+
locale: flags.lang ?? null,
|
|
208
|
+
};
|
|
209
|
+
if (sub === 'create') {
|
|
210
|
+
await call('/tags', 'POST', input);
|
|
211
|
+
print({ created: slug }, () => `Created #${slug}. You follow everything in it.`);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
await call(`/tags/${encodeURIComponent(slug)}`, 'PUT', input);
|
|
215
|
+
print({ updated: slug }, () => `Updated #${slug}.`);
|
|
216
|
+
}
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (action === 'subscribe' || action === 'unsubscribe') {
|
|
220
|
+
const slug = rest[0]?.replace(/^#/, '');
|
|
221
|
+
if (!slug)
|
|
222
|
+
throw new Error(`news ${action} requires <tag>`);
|
|
223
|
+
const path = `/subscriptions/${encodeURIComponent(slug)}`;
|
|
224
|
+
if (action === 'unsubscribe') {
|
|
225
|
+
await call(path, 'DELETE');
|
|
226
|
+
print({ unsubscribed: slug }, () => `You no longer follow #${slug}.`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const level = flags.importance ? importance(flags.importance) : 'normal';
|
|
230
|
+
await call(path, 'PUT', { minImportance: level });
|
|
231
|
+
print({ subscribed: slug, minImportance: level }, () => `Following #${slug}: ${LEVEL[level]}.`);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (action === 'subscriptions') {
|
|
235
|
+
const subscriptions = await call('/subscriptions');
|
|
236
|
+
print(subscriptions, () => renderNewsSubscriptions(subscriptions));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (action === 'review') {
|
|
240
|
+
const slug = tagSlug(rest[0], 'review');
|
|
241
|
+
const page = await call(`/items?tag=${encodeURIComponent(slug)}&drafts=true&limit=100`);
|
|
242
|
+
print(page, () => page.items.length === 0 ? `No drafts wait for review in #${slug}.`
|
|
243
|
+
: renderNewsList(page, client.baseUrl).split('\n\n')[0] + `\n\nPublish one with: skillshare news publish <id>`);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (action === 'publish') {
|
|
247
|
+
const id = itemId(rest[0], 'publish');
|
|
248
|
+
await call(`/items/${id}/publish`, 'POST');
|
|
249
|
+
print({ published: id }, () => `Published #${id}: ${newsLink(client.baseUrl, id)}`);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (action === 'repos') {
|
|
253
|
+
const repositories = await call('/repositories');
|
|
254
|
+
print(repositories, () => repositories.length ? repositories.join('\n') : 'You have no repositories in Git Sources.');
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (action === 'branches') {
|
|
258
|
+
const repository = rest[0];
|
|
259
|
+
if (!repository)
|
|
260
|
+
throw new Error('news branches requires <repository alias>');
|
|
261
|
+
const result = await call(`/repositories/branches?repository=${encodeURIComponent(repository)}&pattern=${encodeURIComponent(flags.branches ?? '')}`);
|
|
262
|
+
print(result, () => {
|
|
263
|
+
if (result.error)
|
|
264
|
+
return result.error;
|
|
265
|
+
const matching = result.branches.filter((branch) => branch.matches);
|
|
266
|
+
return flags.branches
|
|
267
|
+
? [`${matching.length} of ${result.branches.length} branches match ${flags.branches}:`, ...matching.map((branch) => ` ${branch.name}`)].join('\n')
|
|
268
|
+
: result.branches.map((branch) => branch.name).join('\n');
|
|
269
|
+
});
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (action === 'notify') {
|
|
273
|
+
const state = rest[0];
|
|
274
|
+
if (state !== 'on' && state !== 'off')
|
|
275
|
+
throw new Error('Use news notify on|off.');
|
|
276
|
+
await call('/me', 'PUT', { notifyImportant: state === 'on' });
|
|
277
|
+
print({ notifyImportant: state === 'on' }, () => state === 'on'
|
|
278
|
+
? 'Important news in your feed now notifies the browsers you registered for notifications in Skillshare.'
|
|
279
|
+
: 'News notifications are off.');
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (action === 'feeds') {
|
|
283
|
+
const slug = tagSlug(rest[0], 'feeds');
|
|
284
|
+
const feeds = await call(`/tags/${encodeURIComponent(slug)}/feeds`);
|
|
285
|
+
print(feeds, () => renderNewsFeeds(feeds));
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const [sub, target] = rest;
|
|
289
|
+
if (!sub || !['create', 'edit', 'run', 'preview', 'delete'].includes(sub) || !target)
|
|
290
|
+
throw new Error('Use news feed create <tag> | edit|run|preview|delete <feed id>.');
|
|
291
|
+
if (sub === 'run' || sub === 'preview') {
|
|
292
|
+
const id = itemId(target, `feed ${sub}`);
|
|
293
|
+
await call(`/feeds/${id}/run`, 'POST', { dryRun: sub === 'preview' });
|
|
294
|
+
print({ feed: id, dryRun: sub === 'preview' }, () => sub === 'preview'
|
|
295
|
+
? `The agent writes a preview from recent changes; nothing is published. See it with: skillshare news feeds <tag>`
|
|
296
|
+
: `Checking feed ${id} for new changes now.`);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (sub === 'delete') {
|
|
300
|
+
const id = itemId(target, 'feed delete');
|
|
301
|
+
await call(`/feeds/${id}`, 'DELETE');
|
|
302
|
+
print({ deleted: id }, () => `Deleted feed ${id}. Its news stays.`);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const agent = flags.agent ? agentTarget(flags.agent) : undefined;
|
|
306
|
+
const body = (existing) => ({
|
|
307
|
+
repository: flags.repo ?? existing?.repository,
|
|
308
|
+
branchPattern: flags.branches ?? existing?.branchPattern,
|
|
309
|
+
grouping: flags.digest !== undefined ? (flags.digest === 'true' ? 'daily' : 'pullRequest') : existing?.grouping ?? 'pullRequest',
|
|
310
|
+
publishing: flags.review !== undefined ? (flags.review === 'true' ? 'review' : 'auto') : existing?.publishing ?? 'auto',
|
|
311
|
+
agentTarget: agent !== undefined ? agent : existing?.agentTarget ?? null,
|
|
312
|
+
enabled: flags.disabled !== undefined ? flags.disabled !== 'true' : existing?.enabled ?? true,
|
|
313
|
+
backfillDays: flags.backfill ? Number(flags.backfill) : 0,
|
|
314
|
+
});
|
|
315
|
+
if (sub === 'create') {
|
|
316
|
+
const slug = tagSlug(target, 'feed create');
|
|
317
|
+
const input = body();
|
|
318
|
+
if (!input.repository || !input.branchPattern)
|
|
319
|
+
throw new Error('news feed create requires --repo <alias> and --branches <regex>');
|
|
320
|
+
const result = await call(`/tags/${encodeURIComponent(slug)}/feeds`, 'POST', input);
|
|
321
|
+
print(result, () => `Feed ${result.id} follows ${input.repository} ${input.branchPattern} for #${slug}. Try it with: skillshare news feed preview ${result.id}`);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const id = itemId(target, 'feed edit');
|
|
325
|
+
if (!flags.tag)
|
|
326
|
+
throw new Error('news feed edit needs --tag <slug> to find the feed.');
|
|
327
|
+
const feeds = await call(`/tags/${encodeURIComponent(flags.tag.replace(/^#/, ''))}/feeds`);
|
|
328
|
+
const existing = feeds.find((feed) => feed.id === id);
|
|
329
|
+
if (!existing)
|
|
330
|
+
throw new Error(`Feed ${id} is not on #${flags.tag}.`);
|
|
331
|
+
await call(`/feeds/${id}`, 'PUT', body(existing));
|
|
332
|
+
print({ updated: id }, () => `Updated feed ${id}.`);
|
|
333
|
+
}
|
|
334
|
+
function tagSlug(value, action) {
|
|
335
|
+
const slug = value?.replace(/^#/, '');
|
|
336
|
+
if (!slug)
|
|
337
|
+
throw new Error(`news ${action} requires <tag>`);
|
|
338
|
+
return slug;
|
|
339
|
+
}
|
|
340
|
+
function locale(value) {
|
|
341
|
+
if (!LOCALES.includes(value))
|
|
342
|
+
throw new Error(`--lang must be one of ${LOCALES.join(', ')}`);
|
|
343
|
+
return value;
|
|
344
|
+
}
|
|
345
|
+
/** --agent <listener id>[:<agent>[/<model>]], for example laptop:claude/haiku; "auto" clears it. */
|
|
346
|
+
function agentTarget(value) {
|
|
347
|
+
if (value === 'auto')
|
|
348
|
+
return null;
|
|
349
|
+
const [listenerId, configuration = 'claude'] = value.split(':');
|
|
350
|
+
const [agent, model = 'default'] = configuration.split('/');
|
|
351
|
+
if (!listenerId || !['claude', 'codex'].includes(agent))
|
|
352
|
+
throw new Error('--agent must be <listener id>[:claude|codex[/<model>]] or auto');
|
|
353
|
+
return { listenerId, configurationId: `${agent}/${model}/default` };
|
|
354
|
+
}
|
|
355
|
+
function importance(value) {
|
|
356
|
+
const normalized = value.trim().toLowerCase();
|
|
357
|
+
const level = normalized === 'all' || normalized === 'everything' ? 'cosmetic' : normalized;
|
|
358
|
+
if (!IMPORTANCE.includes(level))
|
|
359
|
+
throw new Error('--importance must be important, normal or cosmetic (everything).');
|
|
360
|
+
return level;
|
|
361
|
+
}
|
|
362
|
+
function tagList(value) {
|
|
363
|
+
return value.split(',').map((tag) => tag.trim().replace(/^#/, '')).filter(Boolean);
|
|
364
|
+
}
|
|
365
|
+
function itemId(value, action) {
|
|
366
|
+
const id = Number(value);
|
|
367
|
+
if (!value || !Number.isSafeInteger(id) || id <= 0)
|
|
368
|
+
throw new Error(`news ${action} requires a news item id`);
|
|
369
|
+
return id;
|
|
370
|
+
}
|
|
371
|
+
function positiveInteger(value, name) {
|
|
372
|
+
const number = Number(value);
|
|
373
|
+
if (!Number.isSafeInteger(number) || number <= 0)
|
|
374
|
+
throw new Error(`${name} must be a positive whole number`);
|
|
375
|
+
return number;
|
|
376
|
+
}
|
|
377
|
+
function date(value) {
|
|
378
|
+
const parsed = new Date(value);
|
|
379
|
+
if (Number.isNaN(parsed.getTime()))
|
|
380
|
+
throw new Error('--date must be a date such as 2026-11-01 or 2026-11-01T09:00');
|
|
381
|
+
return parsed.toISOString();
|
|
382
|
+
}
|
|
383
|
+
async function send(client, path, method, body) {
|
|
384
|
+
const response = await client.request(`/api/news${path}`, body === undefined
|
|
385
|
+
? { method }
|
|
386
|
+
: { method, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
387
|
+
if (response.ok)
|
|
388
|
+
return (response.status === 204 ? undefined : await response.json());
|
|
389
|
+
let error = {};
|
|
390
|
+
try {
|
|
391
|
+
error = await response.json();
|
|
392
|
+
}
|
|
393
|
+
catch { }
|
|
394
|
+
if (error.error)
|
|
395
|
+
throw new Error(error.error);
|
|
396
|
+
if (response.status === 404)
|
|
397
|
+
throw new Error('Not found. Check the news id or tag.');
|
|
398
|
+
if (response.status === 403)
|
|
399
|
+
throw new Error('You are not allowed to do that.');
|
|
400
|
+
throw new Error(`Skillshare returned HTTP ${response.status} for news.`);
|
|
401
|
+
}
|
|
402
|
+
async function readStdin() {
|
|
403
|
+
if (process.stdin.isTTY)
|
|
404
|
+
return '';
|
|
405
|
+
const chunks = [];
|
|
406
|
+
for await (const chunk of process.stdin)
|
|
407
|
+
chunks.push(Buffer.from(chunk));
|
|
408
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
409
|
+
}
|
package/dist/teams.js
CHANGED
|
@@ -118,8 +118,8 @@ export async function runTeamsCommand(client, args, flags, appDirectory) {
|
|
|
118
118
|
}
|
|
119
119
|
if (action === 'access') {
|
|
120
120
|
const mode = args[1];
|
|
121
|
-
if (mode !== 'readOnly' && mode !== 'fullAccess')
|
|
122
|
-
throw new Error('Use teams access readOnly or teams access fullAccess.');
|
|
121
|
+
if (mode !== 'readOnly' && mode !== 'limitedAccess' && mode !== 'fullAccess')
|
|
122
|
+
throw new Error('Use teams access readOnly, teams access limitedAccess or teams access fullAccess.');
|
|
123
123
|
const response = await client.request(`${root}/access-mode`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ accessMode: mode }) });
|
|
124
124
|
await expectOk(response);
|
|
125
125
|
console.log(`Teams access mode: ${mode}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadient/skillshare",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "Skillshare CLI for installing and publishing Quadient skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && node -e \"require('node:fs').copyFileSync('page-browser-client.js', 'dist/page-browser-client.js')\"",
|
|
17
17
|
"start": "node ./dist/index.js",
|
|
18
18
|
"prepublishOnly": "npm run build",
|
|
19
|
-
"test": "tsx --test session-auth.test.ts cli-args.test.ts install-files.test.ts removed-skills.test.ts output.test.ts pages.test.ts page-links.test.ts pages-secrets.test.ts pages-comments.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts salesforce.test.ts agents.test.ts agents-update.test.ts login-callback.test.ts"
|
|
19
|
+
"test": "tsx --test session-auth.test.ts cli-args.test.ts install-files.test.ts removed-skills.test.ts output.test.ts pages.test.ts page-links.test.ts pages-secrets.test.ts pages-comments.test.ts news.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts salesforce.test.ts agents.test.ts agents-detection.test.ts agents-lockdown.test.ts agents-approvals.test.ts agents-native-forms.test.ts agents-delivery.test.ts agents-request-upload.test.ts agents-update.test.ts login-callback.test.ts"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@clack/prompts": "^1.7.0",
|
|
35
|
+
"ajv": "8.17.1",
|
|
36
|
+
"ajv-formats": "3.0.1",
|
|
35
37
|
"chokidar": "4.0.3",
|
|
36
38
|
"cross-spawn": "7.0.6",
|
|
37
39
|
"esbuild": "0.28.2",
|