@giftsofprometheus/cli 0.2.0 → 0.2.2
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 +9 -0
- package/dist/index.js +217 -14
- package/dist/skill-files.js +36 -0
- package/package.json +2 -1
- package/skills/giftsofprometheus/SKILL.md +8 -6
- package/skills/history.json +37 -0
package/README.md
CHANGED
|
@@ -79,6 +79,15 @@ npx skills add timurkhakhalev/giftsofprometheus-cli
|
|
|
79
79
|
|
|
80
80
|
По инструкции skill агент меняет избранное и интересы только по вашей просьбе. Поиск и чтение ничего не сохраняют, не лайкают и не скрывают.
|
|
81
81
|
|
|
82
|
+
## Обновления
|
|
83
|
+
|
|
84
|
+
Установленный через npm CLI раз в сутки проверяет, не вышла ли новая версия, и после команды пишет в stderr строку `Update: …` с командой обновления. Запуски через `npx` не проверяются: они и так берут последнюю версию. Отключить проверку: `GIFTSOFPROMETHEUS_NO_UPDATE_CHECK=1` (в CI она выключена сама).
|
|
85
|
+
|
|
86
|
+
Так же раз в сутки CLI находит установленные копии skill в `.agents`, `.claude`, `.codex` и `.cursor` (в домашней папке и в текущем проекте) и сравнивает их по хешу с выпущенными версиями. Строка `description` при сравнении не учитывается, поэтому своё описание не мешает.
|
|
87
|
+
|
|
88
|
+
- `giftsofprometheus doctor` показывает версию CLI и статус каждой копии: `current`, `outdated`, `modified` (правили вручную) или `linked` (ссылка на папку из пакета).
|
|
89
|
+
- `giftsofprometheus skill update` заменяет устаревшие копии и сохраняет ваше описание. Копии, которые правили вручную, заменяются только с `--force`.
|
|
90
|
+
|
|
82
91
|
## Что есть в каталоге
|
|
83
92
|
|
|
84
93
|
**Конференции:** [AI Engineer World's Fair 2026](https://giftsofprometheus.com/events/ai-engineer-world-s-fair-2026?utm_source=github&utm_medium=readme&utm_campaign=cli), [AI Engineer World's Fair 2025](https://giftsofprometheus.com/events/ai-engineer-world-s-fair-2025?utm_source=github&utm_medium=readme&utm_campaign=cli), [AI Engineer Europe 2026](https://giftsofprometheus.com/events/ai-engineer-europe-2026?utm_source=github&utm_medium=readme&utm_campaign=cli), [AI Engineer World's Fair 2024](https://giftsofprometheus.com/events/ai-engineer-world-s-fair-2024?utm_source=github&utm_medium=readme&utm_campaign=cli), [AI Engineer Code 2025](https://giftsofprometheus.com/events/ai-engineer-code-2025?utm_source=github&utm_medium=readme&utm_campaign=cli), [AI Engineer Summit 2025](https://giftsofprometheus.com/events/ai-engineer-summit-2025?utm_source=github&utm_medium=readme&utm_campaign=cli), [AI Engineer Summit 2023](https://giftsofprometheus.com/events/ai-engineer-summit-2023?utm_source=github&utm_medium=readme&utm_campaign=cli), [BAAI Conference 2026 · 北京智源大会](https://giftsofprometheus.com/events/baai-conference-2026?utm_source=github&utm_medium=readme&utm_campaign=cli), [Apsara Conference 2026 · 云栖大会](https://giftsofprometheus.com/events/apsara-conference-2026?utm_source=github&utm_medium=readme&utm_campaign=cli).
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import { chmod, lstat, mkdir, readFile, rename, writeFile, unlink } from 'node:fs/promises';
|
|
4
|
+
import { chmod, lstat, mkdir, readFile, realpath, rename, stat, writeFile, unlink } from 'node:fs/promises';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { isAbsolute, join } from 'node:path';
|
|
7
7
|
import { spawn } from 'node:child_process';
|
|
8
8
|
import { randomUUID } from 'node:crypto';
|
|
9
9
|
import { createRequire } from 'node:module';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { mergeSkill, newerVersion, skillHash } from './skill-files.js';
|
|
11
12
|
const { version } = z.object({ version: z.string() }).parse(createRequire(import.meta.url)('../package.json'));
|
|
12
13
|
const program = new Command();
|
|
13
14
|
const base = (process.env.GIFTSOFPROMETHEUS_URL || 'https://giftsofprometheus.com').replace(/\/$/, '');
|
|
@@ -21,6 +22,8 @@ const credentials = join(directory, 'credentials.json');
|
|
|
21
22
|
const pendingLogin = join(directory, 'login.json');
|
|
22
23
|
// The onboarding draft lives outside the project next to the session, so it survives `login` between `deck` and `finish`
|
|
23
24
|
const onboardingDraft = join(directory, 'onboarding.json');
|
|
25
|
+
// When the daily update check last ran and what npm reported then
|
|
26
|
+
const updateState = join(directory, 'update.json');
|
|
24
27
|
const credentialsSchema = z.object({ base: z.string(), token: z.string() });
|
|
25
28
|
/** Only a missing file means "no session"; a file that cannot be read or parsed may still hold a valid session */
|
|
26
29
|
async function storedAny() {
|
|
@@ -111,27 +114,179 @@ async function request(path, method = 'GET', body, authenticated = true) {
|
|
|
111
114
|
function out(value) {
|
|
112
115
|
console.log(JSON.stringify(value, null, program.opts().json ? 0 : 2));
|
|
113
116
|
}
|
|
117
|
+
// What an agent must do on 401. It is in the error itself, so an agent without the skill also knows to sign the user in
|
|
118
|
+
const SIGN_IN_STEPS = 'Sign the user in: run `login --start` with the same launcher and --json, give the user verificationUrl and userCode in one line, run `login --wait` (it waits for the confirmation), then repeat this command.';
|
|
119
|
+
const interactive = () => !program.opts().json && Boolean(process.stdin.isTTY && process.stderr.isTTY);
|
|
114
120
|
function run(fn) {
|
|
115
121
|
return async (...args) => {
|
|
116
122
|
try {
|
|
117
|
-
|
|
123
|
+
try {
|
|
124
|
+
out(await fn(...args));
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
// A person in a terminal is taken through the browser confirmation and gets the answer, instead of an error to act on
|
|
128
|
+
if (!(e instanceof ApiError && e.status === 401 && interactive()))
|
|
129
|
+
throw e;
|
|
130
|
+
const device = await startLogin();
|
|
131
|
+
console.error(`Sign-in needed. Open ${verificationUrl(device.userCode)} and confirm the code ${device.userCode}`);
|
|
132
|
+
await waitLogin(device);
|
|
133
|
+
out(await fn(...args));
|
|
134
|
+
}
|
|
118
135
|
}
|
|
119
136
|
catch (e) {
|
|
120
137
|
const message = e instanceof Error ? e.message : 'Unknown error';
|
|
138
|
+
const status = e instanceof ApiError ? e.status : 1;
|
|
121
139
|
if (program.opts().json)
|
|
122
|
-
console.log(JSON.stringify({ error: { message, status
|
|
140
|
+
console.log(JSON.stringify({ error: { message, status, ...(status === 401 ? { nextStep: SIGN_IN_STEPS } : {}) } }));
|
|
123
141
|
else
|
|
124
142
|
console.error(printable(message));
|
|
125
143
|
process.exitCode = 1;
|
|
126
144
|
}
|
|
127
145
|
};
|
|
128
146
|
}
|
|
147
|
+
const packageRoot = fileURLToPath(new URL('../', import.meta.url));
|
|
148
|
+
const bundledSkill = join(packageRoot, 'skills', 'giftsofprometheus');
|
|
149
|
+
// Installed from npm (global or a project dependency), not a one-off npx, pnpm dlx or bunx run and not a source checkout:
|
|
150
|
+
// only then is there an installed version to update
|
|
151
|
+
const installed = /[\\/]node_modules[\\/]/.test(packageRoot) && !/[\\/](_npx|dlx|bunx-[^\\/]*)[\\/]/.test(packageRoot);
|
|
152
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
153
|
+
const updateStateSchema = z.object({ base: z.string(), checkedAt: z.number(), latest: z.string().nullable() });
|
|
154
|
+
const historySchema = z.array(z.object({ version: z.string(), hash: z.string(), description: z.string().nullable() }));
|
|
155
|
+
const updateCommand = /[\\/]pnpm[\\/]global[\\/]/.test(packageRoot)
|
|
156
|
+
? 'pnpm add -g @giftsofprometheus/cli@latest'
|
|
157
|
+
: /[\\/]\.bun[\\/]install[\\/]global[\\/]/.test(packageRoot)
|
|
158
|
+
? 'bun add -g @giftsofprometheus/cli@latest'
|
|
159
|
+
: 'npm install -g @giftsofprometheus/cli@latest';
|
|
160
|
+
const shortPath = (path) => (path.startsWith(homedir()) ? '~' + path.slice(homedir().length) : path);
|
|
161
|
+
async function fetchLatest() {
|
|
162
|
+
try {
|
|
163
|
+
const response = await fetch('https://registry.npmjs.org/@giftsofprometheus/cli/latest', {
|
|
164
|
+
headers: { Accept: 'application/json', 'User-Agent': `giftsofprometheus/${version}` },
|
|
165
|
+
redirect: 'error',
|
|
166
|
+
signal: AbortSignal.timeout(1500),
|
|
167
|
+
});
|
|
168
|
+
if (!response.ok)
|
|
169
|
+
return null;
|
|
170
|
+
const parsed = z.object({ version: z.string().regex(/^\d+\.\d+\.\d+/) }).safeParse(await response.json());
|
|
171
|
+
return parsed.success ? parsed.data.version : null;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** The latest npm version, asked at most once a day; `fresh` is true when this call asked npm */
|
|
178
|
+
async function latestVersion(force = false) {
|
|
179
|
+
const state = await readState(updateState, updateStateSchema);
|
|
180
|
+
if (!force && state && Date.now() - state.checkedAt < DAY_MS)
|
|
181
|
+
return { latest: state.latest, fresh: false };
|
|
182
|
+
// npx and source runs never ask npm: they already run the version that was asked for
|
|
183
|
+
const latest = installed ? ((await fetchLatest()) ?? state?.latest ?? null) : null;
|
|
184
|
+
// A failed check also counts, so an offline machine does not wait for npm on every run
|
|
185
|
+
await saveJson(updateState, { base, checkedAt: Date.now(), latest }).catch(() => { });
|
|
186
|
+
return { latest, fresh: true };
|
|
187
|
+
}
|
|
188
|
+
// Where agents and `npx skills add` keep personal and project skills
|
|
189
|
+
function skillDirectories() {
|
|
190
|
+
const roots = [homedir(), process.cwd()];
|
|
191
|
+
const homes = [process.env.CLAUDE_CONFIG_DIR, process.env.CODEX_HOME].filter((value) => Boolean(value && isAbsolute(value)));
|
|
192
|
+
return [
|
|
193
|
+
...roots.flatMap(root => ['.agents', '.claude', '.codex', '.cursor'].map(agent => join(root, agent, 'skills', 'giftsofprometheus'))),
|
|
194
|
+
...homes.map(home => join(home, 'skills', 'giftsofprometheus')),
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
async function skillHistory() {
|
|
198
|
+
return historySchema.parse(JSON.parse(await readFile(join(packageRoot, 'skills', 'history.json'), 'utf8')));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Installed copies of the skill, each once even when several agent folders link to it.
|
|
202
|
+
* The description line is not compared: a custom one, or a personal tail, does not make a copy outdated.
|
|
203
|
+
*/
|
|
204
|
+
async function installedSkills() {
|
|
205
|
+
const bundled = await realpath(bundledSkill);
|
|
206
|
+
const current = skillHash(await readFile(join(bundled, 'SKILL.md'), 'utf8'));
|
|
207
|
+
const history = await skillHistory();
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
const found = [];
|
|
210
|
+
for (const folder of skillDirectories()) {
|
|
211
|
+
let real;
|
|
212
|
+
try {
|
|
213
|
+
real = await realpath(folder);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (seen.has(real))
|
|
219
|
+
continue;
|
|
220
|
+
seen.add(real);
|
|
221
|
+
if (real === bundled) {
|
|
222
|
+
found.push({ path: shortPath(folder), file: join(real, 'SKILL.md'), status: 'linked', version });
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
let text;
|
|
226
|
+
try {
|
|
227
|
+
text = await readFile(join(real, 'SKILL.md'), 'utf8');
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const hash = skillHash(text);
|
|
233
|
+
const known = history.findLast(entry => entry.hash === hash);
|
|
234
|
+
const status = hash === current ? 'current' : known ? 'outdated' : 'modified';
|
|
235
|
+
found.push({ path: shortPath(folder), file: join(real, 'SKILL.md'), status, version: known?.version ?? null });
|
|
236
|
+
}
|
|
237
|
+
return found;
|
|
238
|
+
}
|
|
239
|
+
async function updateSkills(force) {
|
|
240
|
+
const bundled = await readFile(join(bundledSkill, 'SKILL.md'), 'utf8');
|
|
241
|
+
const stock = (await skillHistory()).flatMap(entry => (entry.description ? [entry.description] : []));
|
|
242
|
+
const updated = [];
|
|
243
|
+
const unchanged = [];
|
|
244
|
+
for (const skill of await installedSkills()) {
|
|
245
|
+
if (skill.status !== 'outdated' && !(force && skill.status === 'modified')) {
|
|
246
|
+
unchanged.push({ path: skill.path, status: skill.status });
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const text = mergeSkill(bundled, await readFile(skill.file, 'utf8'), stock);
|
|
250
|
+
const temporary = `${skill.file}.${randomUUID()}.tmp`;
|
|
251
|
+
try {
|
|
252
|
+
await writeFile(temporary, text, { mode: (await stat(skill.file)).mode & 0o777, flag: 'wx' });
|
|
253
|
+
await rename(temporary, skill.file);
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
await unlink(temporary).catch(() => { });
|
|
257
|
+
throw e;
|
|
258
|
+
}
|
|
259
|
+
updated.push({ path: skill.path, from: skill.version });
|
|
260
|
+
}
|
|
261
|
+
return { version, updated, unchanged };
|
|
262
|
+
}
|
|
263
|
+
const updateCheckDisabled = () => Boolean(process.env.GIFTSOFPROMETHEUS_NO_UPDATE_CHECK || process.env.CI);
|
|
264
|
+
/** Once a day, after a command: a line on stderr when the CLI or an installed skill is behind. Never fails the command */
|
|
265
|
+
async function updateNotice() {
|
|
266
|
+
if (updateCheckDisabled())
|
|
267
|
+
return;
|
|
268
|
+
try {
|
|
269
|
+
const { latest, fresh } = await latestVersion();
|
|
270
|
+
if (!fresh)
|
|
271
|
+
return;
|
|
272
|
+
const lines = [];
|
|
273
|
+
if (installed && latest && newerVersion(latest, version))
|
|
274
|
+
lines.push(`Update: giftsofprometheus ${latest} is available (installed ${version}). Run: ${updateCommand}`);
|
|
275
|
+
for (const skill of await installedSkills())
|
|
276
|
+
if (skill.status === 'outdated')
|
|
277
|
+
lines.push(`Update: the agent skill in ${skill.path} is older than this CLI. Run: giftsofprometheus skill update`);
|
|
278
|
+
if (lines.length)
|
|
279
|
+
console.error(lines.join('\n'));
|
|
280
|
+
}
|
|
281
|
+
catch { }
|
|
282
|
+
}
|
|
129
283
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
130
284
|
// Windows is skipped: a short program name is looked up in the current directory before PATH, so a checkout could plant cmd.exe,
|
|
131
285
|
// and cmd.exe also interprets & | ^ in the URL. The printed link is enough there
|
|
132
286
|
function openBrowser(url) {
|
|
133
287
|
const opener = process.platform === 'darwin' ? '/usr/bin/open' : process.platform === 'win32' ? null : 'xdg-open';
|
|
134
|
-
|
|
288
|
+
// Set by the tests, and useful on a remote machine where the local browser is the wrong one
|
|
289
|
+
if (!opener || process.env.GIFTSOFPROMETHEUS_NO_BROWSER)
|
|
135
290
|
return;
|
|
136
291
|
const child = spawn(opener, [url.href], { detached: true, stdio: 'ignore', shell: false });
|
|
137
292
|
child.on('error', () => { });
|
|
@@ -201,7 +356,8 @@ async function waitLogin(device) {
|
|
|
201
356
|
}
|
|
202
357
|
catch (e) {
|
|
203
358
|
const message = e instanceof Error ? e.message : '';
|
|
204
|
-
|
|
359
|
+
// 429: a server limit on polling; back off like slow_down instead of failing a login the user may already have confirmed
|
|
360
|
+
if (/slow.down|too frequently/i.test(message) || (e instanceof ApiError && e.status === 429)) {
|
|
205
361
|
interval = Math.min(interval + 5, 60);
|
|
206
362
|
continue;
|
|
207
363
|
}
|
|
@@ -279,12 +435,17 @@ program
|
|
|
279
435
|
}
|
|
280
436
|
}
|
|
281
437
|
catch { }
|
|
438
|
+
const latest = installed && !updateCheckDisabled() ? (await latestVersion(true)).latest : null;
|
|
439
|
+
const skills = await installedSkills().catch(() => []);
|
|
282
440
|
return {
|
|
283
441
|
base,
|
|
284
442
|
reachable,
|
|
285
443
|
authenticated,
|
|
286
444
|
authSource: credential ? 'config' : 'missing',
|
|
287
445
|
configPath: credentials,
|
|
446
|
+
// `installed: false` for npx and source runs: they already use the version they asked for
|
|
447
|
+
update: { installed, current: version, latest, available: Boolean(installed && latest && newerVersion(latest, version)), command: updateCommand },
|
|
448
|
+
skills: skills.map(skill => ({ path: skill.path, status: skill.status, version: skill.version })),
|
|
288
449
|
nextStep: !reachable ? 'Check GIFTSOFPROMETHEUS_URL and server availability' : !authenticated ? 'Run giftsofprometheus login' : null,
|
|
289
450
|
};
|
|
290
451
|
}));
|
|
@@ -298,7 +459,18 @@ talks
|
|
|
298
459
|
.argument('<query>')
|
|
299
460
|
.option('--page <page>', 'page number', '1')
|
|
300
461
|
.action(run((query, options) => request(`/api/knowledge/talks?q=${encodeURIComponent(query)}&page=${encodeURIComponent(options.page)}`, 'GET', undefined, false)));
|
|
301
|
-
|
|
462
|
+
// The command a person typed, so a hint can be pasted back as is
|
|
463
|
+
const launcher = /[\\/]_npx[\\/]/.test(packageRoot) ? 'npx @giftsofprometheus/cli' : 'giftsofprometheus';
|
|
464
|
+
talks
|
|
465
|
+
.command('get')
|
|
466
|
+
.argument('<slug-or-id>')
|
|
467
|
+
.action(run(async (id) => {
|
|
468
|
+
const talk = await resolveTalk(id);
|
|
469
|
+
// The next step after the summary is the transcript; stdout stays the talk's JSON
|
|
470
|
+
const signedIn = Boolean(await stored());
|
|
471
|
+
console.error(`Next: the full transcript — ${launcher} talks content ${talk.slug}${signedIn ? '' : ' (asks you to sign in in the browser first)'}`);
|
|
472
|
+
return talk;
|
|
473
|
+
}));
|
|
302
474
|
talks
|
|
303
475
|
.command('content')
|
|
304
476
|
.argument('<slug-or-id>')
|
|
@@ -361,7 +533,26 @@ const draftSchema = z.object({
|
|
|
361
533
|
reactions: z.array(z.object({ talkId: z.number().int().positive(), reaction: reactions })),
|
|
362
534
|
queryText: z.string().optional(),
|
|
363
535
|
});
|
|
364
|
-
const card = z.object({
|
|
536
|
+
const card = z.object({
|
|
537
|
+
id: z.number().int().positive(),
|
|
538
|
+
slug: z.string(),
|
|
539
|
+
title: z.string(),
|
|
540
|
+
description: z.string().nullish(),
|
|
541
|
+
speakers: z.array(z.object({ name: z.string() })).default([]),
|
|
542
|
+
topics: z.array(z.object({ title: z.string() })).default([]),
|
|
543
|
+
event: z.object({ name: z.string() }).nullish(),
|
|
544
|
+
});
|
|
545
|
+
// A card keeps what an agent shows in a list: the summary's first paragraph, without the bullets, links and media fields
|
|
546
|
+
function brief(t) {
|
|
547
|
+
return {
|
|
548
|
+
slug: t.slug,
|
|
549
|
+
title: t.title,
|
|
550
|
+
summary: t.description?.split(/\n\s*\n/)[0]?.trim() ?? null,
|
|
551
|
+
speakers: t.speakers.map(s => s.name),
|
|
552
|
+
topics: t.topics.map(s => s.title),
|
|
553
|
+
event: t.event?.name ?? null,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
365
556
|
async function currentDraft() {
|
|
366
557
|
const draft = await readState(onboardingDraft, draftSchema);
|
|
367
558
|
if (!draft)
|
|
@@ -380,7 +571,7 @@ async function onboardingDeck(o) {
|
|
|
380
571
|
const draft = { base, draftId: randomUUID(), interests: [...interests].map(([topic, level]) => ({ topic, level })), deck: [], reactions: [] };
|
|
381
572
|
const { deck } = z.object({ deck: z.array(card) }).parse(await request('/api/knowledge/onboarding/deck', 'POST', { interests: draft.interests }, false));
|
|
382
573
|
await saveJson(onboardingDraft, { ...draft, deck: deck.map(t => t.id), ...(o.queryText?.trim() ? { queryText: o.queryText.trim() } : {}) });
|
|
383
|
-
return { draftId: draft.draftId, deck: deck.map((t, i) => ({ n: i + 1, ...t })) };
|
|
574
|
+
return { draftId: draft.draftId, deck: deck.map((t, i) => ({ n: i + 1, ...brief(t) })) };
|
|
384
575
|
}
|
|
385
576
|
// Answers refer to card numbers from `deck`, so an agent can pass the user's reply ("1, 4 yes, 3 no") without looking up IDs
|
|
386
577
|
async function onboardingReact(answers) {
|
|
@@ -403,7 +594,7 @@ async function onboardingReact(answers) {
|
|
|
403
594
|
.parse(await request('/api/knowledge/onboarding/preview', 'POST', { interests: next.interests, reactions: next.reactions, shownTalkIds: next.deck }, false));
|
|
404
595
|
await saveJson(onboardingDraft, next);
|
|
405
596
|
return {
|
|
406
|
-
preview,
|
|
597
|
+
preview: preview.map(t => ({ ...brief(t), reason: t.reason })),
|
|
407
598
|
answered: draft.deck.flatMap((id, i) => (chosen.has(id) ? [{ n: i + 1, reaction: chosen.get(id) }] : [])),
|
|
408
599
|
unanswered: draft.deck.flatMap((id, i) => (chosen.has(id) ? [] : [i + 1])),
|
|
409
600
|
};
|
|
@@ -411,7 +602,7 @@ async function onboardingReact(answers) {
|
|
|
411
602
|
async function onboardingFinish(o) {
|
|
412
603
|
const draft = await currentDraft();
|
|
413
604
|
if (!(await stored()))
|
|
414
|
-
throw new ApiError('Not signed in
|
|
605
|
+
throw new ApiError('Not signed in. The onboarding draft is kept until it is saved', 401);
|
|
415
606
|
const queryText = o.queryText?.trim() || draft.queryText;
|
|
416
607
|
z.object({ saved: z.literal(true) }).parse(await request('/api/knowledge/onboarding', 'POST', {
|
|
417
608
|
draftId: draft.draftId,
|
|
@@ -454,15 +645,27 @@ program
|
|
|
454
645
|
.description('Make an authenticated GET request to a Knowledge API path, e.g. /api/knowledge/profile')
|
|
455
646
|
.argument('<path>')
|
|
456
647
|
.action(run((path) => request(path)));
|
|
457
|
-
program
|
|
648
|
+
const skill = program
|
|
458
649
|
.command('skill')
|
|
459
650
|
.description('Print the agent skill that matches this CLI version')
|
|
460
651
|
.option('--path', 'print the skill directory instead, for linking into an agent')
|
|
461
652
|
.action(async (options) => {
|
|
462
|
-
|
|
463
|
-
process.stdout.write(options.path ? `${skill}\n` : await readFile(join(skill, 'SKILL.md'), 'utf8'));
|
|
653
|
+
process.stdout.write(options.path ? `${bundledSkill}/\n` : await readFile(join(bundledSkill, 'SKILL.md'), 'utf8'));
|
|
464
654
|
});
|
|
465
|
-
|
|
655
|
+
skill
|
|
656
|
+
.command('update')
|
|
657
|
+
.description('Replace installed copies of the skill that are older than this CLI; a custom description is kept')
|
|
658
|
+
.option('--force', 'also replace copies that were edited by hand')
|
|
659
|
+
.action(run((options) => updateSkills(Boolean(options.force))));
|
|
660
|
+
// The daily check runs after the command, so it never delays or breaks its output; doctor and skill report the same state themselves
|
|
661
|
+
let skipNotice = false;
|
|
662
|
+
program.hook('preAction', (_, action) => {
|
|
663
|
+
skipNotice = action.name() === 'doctor' || action.name() === 'skill' || action.parent?.name() === 'skill';
|
|
664
|
+
});
|
|
665
|
+
program
|
|
666
|
+
.parseAsync()
|
|
667
|
+
.then(() => (skipNotice ? undefined : updateNotice()))
|
|
668
|
+
.catch(e => {
|
|
466
669
|
if (e.code === 'commander.helpDisplayed' || e.code === 'commander.version')
|
|
467
670
|
return;
|
|
468
671
|
if (program.opts().json)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
// The `description:` line is the user's to change (a custom wording or a personal tail), so it is left out of the comparison
|
|
3
|
+
const DESCRIPTION = /^description:.*$/m;
|
|
4
|
+
export function skillDescription(text) {
|
|
5
|
+
return text.replace(/\r\n/g, '\n').match(DESCRIPTION)?.[0] ?? null;
|
|
6
|
+
}
|
|
7
|
+
/** Hash of SKILL.md without its description line and without trailing whitespace differences */
|
|
8
|
+
export function skillHash(text) {
|
|
9
|
+
const body = text
|
|
10
|
+
.replace(/\r\n/g, '\n')
|
|
11
|
+
.replace(DESCRIPTION, '')
|
|
12
|
+
.split('\n')
|
|
13
|
+
.map(line => line.trimEnd())
|
|
14
|
+
.join('\n')
|
|
15
|
+
.trim();
|
|
16
|
+
return createHash('sha256').update(body).digest('hex').slice(0, 16);
|
|
17
|
+
}
|
|
18
|
+
/** The bundled skill with the installed description kept, unless that description is one the CLI shipped */
|
|
19
|
+
export function mergeSkill(bundled, installed, stockDescriptions) {
|
|
20
|
+
const own = skillDescription(installed);
|
|
21
|
+
if (!own || stockDescriptions.includes(own))
|
|
22
|
+
return bundled;
|
|
23
|
+
return bundled.replace(/\r\n/g, '\n').replace(DESCRIPTION, () => own);
|
|
24
|
+
}
|
|
25
|
+
export function newerVersion(latest, current) {
|
|
26
|
+
const parse = (value) => value.split('-')[0]?.split('.').map(Number) ?? [];
|
|
27
|
+
const [a, b] = [parse(latest), parse(current)];
|
|
28
|
+
for (let i = 0; i < 3; i++) {
|
|
29
|
+
const [x = 0, y = 0] = [a[i], b[i]];
|
|
30
|
+
if (Number.isNaN(x) || Number.isNaN(y))
|
|
31
|
+
return false;
|
|
32
|
+
if (x !== y)
|
|
33
|
+
return x > y;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giftsofprometheus/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Search AI conference talks, read transcripts, and manage your Gifts of Prometheus favorites from the shell or an AI agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"format:fix": "oxfmt --write .",
|
|
37
37
|
"test": "pnpm build && node --test tests/*.test.mjs",
|
|
38
38
|
"check": "pnpm lint && pnpm format && pnpm typecheck && pnpm test:quality && pnpm test",
|
|
39
|
+
"skill-history": "node tools/skill-history/update.ts",
|
|
39
40
|
"test:quality": "node --test tools/typescript-quality/verify.test.mjs",
|
|
40
41
|
"prepublishOnly": "pnpm check"
|
|
41
42
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: giftsofprometheus
|
|
3
3
|
description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI, and build a starting profile in the chat. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus.
|
|
4
|
-
allowed-tools: Bash(giftsofprometheus:*)
|
|
4
|
+
allowed-tools: Bash(giftsofprometheus:*), Bash(npx -y @giftsofprometheus/cli:*)
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Gifts of Prometheus
|
|
@@ -10,10 +10,11 @@ allowed-tools: Bash(giftsofprometheus:*)
|
|
|
10
10
|
|
|
11
11
|
## Setup
|
|
12
12
|
|
|
13
|
-
Run `command -v giftsofprometheus`. If it is missing,
|
|
13
|
+
Run `command -v giftsofprometheus`. If it is missing, run every command below as `npx -y @giftsofprometheus/cli` with the same arguments instead of `giftsofprometheus`, and mention once that a permanent install is described in https://github.com/timurkhakhalev/giftsofprometheus-cli#install. Then run `giftsofprometheus --json doctor`:
|
|
14
14
|
|
|
15
15
|
- `reachable: false`: the service is unavailable; report it and stop.
|
|
16
16
|
- `authenticated: false`: search, talk metadata and onboarding still work. Sign in only when a command needs it (see Sign in).
|
|
17
|
+
- `update.available: true`, a skill in `skills` with `status: "outdated"`, or a line starting with `Update:` on stderr of any command: tell the user in one line and offer to update. Run `update.command` or `giftsofprometheus skill update` only after they agree, then continue the task. A skill with `status: "modified"` was edited by hand: do not offer to replace it.
|
|
17
18
|
|
|
18
19
|
## Sign in
|
|
19
20
|
|
|
@@ -46,14 +47,15 @@ giftsofprometheus --json profile get # interests and curre
|
|
|
46
47
|
|
|
47
48
|
## Onboarding
|
|
48
49
|
|
|
49
|
-
Offer it when `profile get` returns `needsOnboarding: true`, or when the user is not signed in and asks what to watch. It takes a minute and needs no account until the last step; the user fills in nothing, they answer in the chat.
|
|
50
|
+
Run it when the user asks for onboarding. Offer it when `profile get` returns `needsOnboarding: true`, or when the user is not signed in and asks what to watch. It takes a minute and needs no account until the last step; the user fills in nothing, they answer in the chat.
|
|
50
51
|
|
|
51
52
|
1. Ask two or three short questions in one message: what they are building or working on, their level, what they do not want to see.
|
|
52
53
|
2. Run `giftsofprometheus --json onboarding topics` and match the answers to topic slugs: what they work on → `interested`, what they do not want → `not_interested`. Use only topics their answers support.
|
|
53
54
|
3. Run `giftsofprometheus --json onboarding deck --interest <slug>=interested --interest <slug>=not_interested --query-text '<what they are building, in their words>'`. It starts a new draft and returns up to 8 cards with numbers `n`.
|
|
54
|
-
4. Show the cards as a numbered list: title and one short line each. Ask which are useful and which miss, for example "1, 4 yes, 3 no". Unmentioned cards stay unjudged.
|
|
55
|
-
5. Run `giftsofprometheus --json onboarding react 1=like 4=like 3=dislike` with the numbers from the reply (`skip` takes an answer back). Show the returned `preview`
|
|
56
|
-
6.
|
|
55
|
+
4. Show the cards as a numbered list: the title and the `summary` in one short line each. Ask which are useful and which miss, for example "1, 4 yes, 3 no". Unmentioned cards stay unjudged.
|
|
56
|
+
5. Run `giftsofprometheus --json onboarding react 1=like 4=like 3=dislike` with the numbers from the reply (`skip` takes an answer back). Show the returned `preview` (title and `reason`), so the user sees what changed.
|
|
57
|
+
6. Save the draft: if `doctor` showed `authenticated: false`, sign in first yourself (see Sign in): run `login --start`, give the user the link and code, run `login --wait`. Never ask the user to run the login command. Then run `giftsofprometheus --json onboarding finish`. On status 401, sign in the same way and run it again; the draft is kept locally until it is saved.
|
|
58
|
+
7. Run `giftsofprometheus --json feed` and show the recommendations with their `reason`. Mention that the same feed is on https://giftsofprometheus.com/for-you.
|
|
57
59
|
|
|
58
60
|
Pass only what the user said. The draft holds at most 8 reactions and the levels `interested` and `not_interested`; the user can raise a topic to `high` later with `profile update`.
|
|
59
61
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"hash": "80d68fbd8383084c",
|
|
5
|
+
"description": "description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"version": "0.1.1",
|
|
9
|
+
"hash": "02e931c7faedd75f",
|
|
10
|
+
"description": "description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus."
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"version": "0.1.2",
|
|
14
|
+
"hash": "02e931c7faedd75f",
|
|
15
|
+
"description": "description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus."
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"version": "0.1.3",
|
|
19
|
+
"hash": "593c1ddf1f1e1bd7",
|
|
20
|
+
"description": "description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"version": "0.2.0",
|
|
24
|
+
"hash": "24255e5be5294829",
|
|
25
|
+
"description": "description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI, and build a starting profile in the chat. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"version": "0.2.1",
|
|
29
|
+
"hash": "55a45e822d057329",
|
|
30
|
+
"description": "description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI, and build a starting profile in the chat. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"version": "0.2.2",
|
|
34
|
+
"hash": "dc7123cc1ecddd93",
|
|
35
|
+
"description": "description: Find AI conference talks (AI Engineer, BAAI, Apsara and others) with Russian summaries, read their full transcripts, and manage the signed-in user's favorites, interests and personal feed through the giftsofprometheus CLI, and build a starting profile in the chat. Use when the user asks for talks, speakers or transcripts on an AI engineering topic, or wants to save, list or remove favorites on Gifts of Prometheus."
|
|
36
|
+
}
|
|
37
|
+
]
|