@giftsofprometheus/cli 0.2.1 → 0.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.
- package/README.md +9 -0
- package/dist/index.js +225 -15
- package/dist/skill-files.js +36 -0
- package/package.json +2 -1
- package/skills/giftsofprometheus/SKILL.md +13 -0
- package/skills/history.json +42 -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
|
}
|
|
@@ -219,9 +375,16 @@ async function resolveTalk(value) {
|
|
|
219
375
|
.loose()
|
|
220
376
|
.parse(await request(`/api/knowledge/talks/${encodeURIComponent(value)}`, 'GET', undefined, false));
|
|
221
377
|
}
|
|
222
|
-
|
|
378
|
+
// The service checks the recId against its own deliveries; the CLI only refuses what cannot be one
|
|
379
|
+
const recIdOption = z.uuid();
|
|
380
|
+
function recIdQuery(recId) {
|
|
381
|
+
return recId === undefined ? '' : `?recId=${encodeURIComponent(recIdOption.parse(recId))}`;
|
|
382
|
+
}
|
|
383
|
+
async function event(talk, type, recId) {
|
|
223
384
|
const item = await resolveTalk(talk);
|
|
224
|
-
|
|
385
|
+
// With a recId the service takes the context from that list; `similar` only passes its check
|
|
386
|
+
const source = recId === undefined ? { context: 'talk_page' } : { context: 'similar', recId: recIdOption.parse(recId) };
|
|
387
|
+
return request('/api/knowledge/events', 'POST', [{ id: randomUUID(), type, talkId: item.id, ...source }]);
|
|
225
388
|
}
|
|
226
389
|
program.exitOverride();
|
|
227
390
|
program.configureOutput({
|
|
@@ -279,12 +442,17 @@ program
|
|
|
279
442
|
}
|
|
280
443
|
}
|
|
281
444
|
catch { }
|
|
445
|
+
const latest = installed && !updateCheckDisabled() ? (await latestVersion(true)).latest : null;
|
|
446
|
+
const skills = await installedSkills().catch(() => []);
|
|
282
447
|
return {
|
|
283
448
|
base,
|
|
284
449
|
reachable,
|
|
285
450
|
authenticated,
|
|
286
451
|
authSource: credential ? 'config' : 'missing',
|
|
287
452
|
configPath: credentials,
|
|
453
|
+
// `installed: false` for npx and source runs: they already use the version they asked for
|
|
454
|
+
update: { installed, current: version, latest, available: Boolean(installed && latest && newerVersion(latest, version)), command: updateCommand },
|
|
455
|
+
skills: skills.map(skill => ({ path: skill.path, status: skill.status, version: skill.version })),
|
|
288
456
|
nextStep: !reachable ? 'Check GIFTSOFPROMETHEUS_URL and server availability' : !authenticated ? 'Run giftsofprometheus login' : null,
|
|
289
457
|
};
|
|
290
458
|
}));
|
|
@@ -298,13 +466,42 @@ talks
|
|
|
298
466
|
.argument('<query>')
|
|
299
467
|
.option('--page <page>', 'page number', '1')
|
|
300
468
|
.action(run((query, options) => request(`/api/knowledge/talks?q=${encodeURIComponent(query)}&page=${encodeURIComponent(options.page)}`, 'GET', undefined, false)));
|
|
301
|
-
|
|
469
|
+
// The command a person typed, so a hint can be pasted back as is
|
|
470
|
+
const launcher = /[\\/]_npx[\\/]/.test(packageRoot) ? 'npx @giftsofprometheus/cli' : 'giftsofprometheus';
|
|
471
|
+
talks
|
|
472
|
+
.command('get')
|
|
473
|
+
.argument('<slug-or-id>')
|
|
474
|
+
.action(run(async (id) => {
|
|
475
|
+
const talk = await resolveTalk(id);
|
|
476
|
+
// The next step after the summary is the transcript; stdout stays the talk's JSON
|
|
477
|
+
const signedIn = Boolean(await stored());
|
|
478
|
+
console.error(`Next: the full transcript — ${launcher} talks content ${talk.slug}${signedIn ? '' : ' (asks you to sign in in the browser first)'}`);
|
|
479
|
+
return talk;
|
|
480
|
+
}));
|
|
302
481
|
talks
|
|
303
482
|
.command('content')
|
|
304
483
|
.argument('<slug-or-id>')
|
|
484
|
+
.option('--rec-id <recId>', 'recId of the list the talk came from (feed, search or similar)')
|
|
485
|
+
.action(run(async (id, options) => {
|
|
486
|
+
const talk = await resolveTalk(id);
|
|
487
|
+
const result = await request(`/api/knowledge/talks/${encodeURIComponent(String(talk.slug))}/content${recIdQuery(options.recId)}`, 'POST');
|
|
488
|
+
// After the transcript: talks like this one, or saving it if the user found it useful
|
|
489
|
+
console.error(`Next: similar talks — ${launcher} talks similar ${talk.slug}; save it if the user asks — ${launcher} favorites add ${talk.slug}`);
|
|
490
|
+
return result;
|
|
491
|
+
}));
|
|
492
|
+
talks
|
|
493
|
+
.command('similar')
|
|
494
|
+
.argument('<slug-or-id>')
|
|
305
495
|
.action(run(async (id) => {
|
|
306
496
|
const talk = await resolveTalk(id);
|
|
307
|
-
|
|
497
|
+
// Public; with a session the list gets a recId, and each item's contentUrl carries it
|
|
498
|
+
const result = z
|
|
499
|
+
.object({ recId: z.string().optional() })
|
|
500
|
+
.loose()
|
|
501
|
+
.parse(await request(`/api/knowledge/talks/${encodeURIComponent(String(talk.slug))}/similar`));
|
|
502
|
+
if (result.recId)
|
|
503
|
+
console.error(`Next: open one with ${launcher} talks content <slug> --rec-id ${result.recId}`);
|
|
504
|
+
return result;
|
|
308
505
|
}));
|
|
309
506
|
const favorites = program.command('favorites').description('Manage bookmarks');
|
|
310
507
|
favorites
|
|
@@ -315,7 +512,8 @@ favorites
|
|
|
315
512
|
favorites
|
|
316
513
|
.command('add')
|
|
317
514
|
.argument('<slug-or-id>')
|
|
318
|
-
.
|
|
515
|
+
.option('--rec-id <recId>', 'recId of the list the talk came from')
|
|
516
|
+
.action(run((id, options) => event(id, 'bookmark', options.recId)));
|
|
319
517
|
favorites
|
|
320
518
|
.command('remove')
|
|
321
519
|
.argument('<slug-or-id>')
|
|
@@ -430,7 +628,7 @@ async function onboardingReact(answers) {
|
|
|
430
628
|
async function onboardingFinish(o) {
|
|
431
629
|
const draft = await currentDraft();
|
|
432
630
|
if (!(await stored()))
|
|
433
|
-
throw new ApiError('Not signed in
|
|
631
|
+
throw new ApiError('Not signed in. The onboarding draft is kept until it is saved', 401);
|
|
434
632
|
const queryText = o.queryText?.trim() || draft.queryText;
|
|
435
633
|
z.object({ saved: z.literal(true) }).parse(await request('/api/knowledge/onboarding', 'POST', {
|
|
436
634
|
draftId: draft.draftId,
|
|
@@ -473,15 +671,27 @@ program
|
|
|
473
671
|
.description('Make an authenticated GET request to a Knowledge API path, e.g. /api/knowledge/profile')
|
|
474
672
|
.argument('<path>')
|
|
475
673
|
.action(run((path) => request(path)));
|
|
476
|
-
program
|
|
674
|
+
const skill = program
|
|
477
675
|
.command('skill')
|
|
478
676
|
.description('Print the agent skill that matches this CLI version')
|
|
479
677
|
.option('--path', 'print the skill directory instead, for linking into an agent')
|
|
480
678
|
.action(async (options) => {
|
|
481
|
-
|
|
482
|
-
process.stdout.write(options.path ? `${skill}\n` : await readFile(join(skill, 'SKILL.md'), 'utf8'));
|
|
679
|
+
process.stdout.write(options.path ? `${bundledSkill}/\n` : await readFile(join(bundledSkill, 'SKILL.md'), 'utf8'));
|
|
483
680
|
});
|
|
484
|
-
|
|
681
|
+
skill
|
|
682
|
+
.command('update')
|
|
683
|
+
.description('Replace installed copies of the skill that are older than this CLI; a custom description is kept')
|
|
684
|
+
.option('--force', 'also replace copies that were edited by hand')
|
|
685
|
+
.action(run((options) => updateSkills(Boolean(options.force))));
|
|
686
|
+
// The daily check runs after the command, so it never delays or breaks its output; doctor and skill report the same state themselves
|
|
687
|
+
let skipNotice = false;
|
|
688
|
+
program.hook('preAction', (_, action) => {
|
|
689
|
+
skipNotice = action.name() === 'doctor' || action.name() === 'skill' || action.parent?.name() === 'skill';
|
|
690
|
+
});
|
|
691
|
+
program
|
|
692
|
+
.parseAsync()
|
|
693
|
+
.then(() => (skipNotice ? undefined : updateNotice()))
|
|
694
|
+
.catch(e => {
|
|
485
695
|
if (e.code === 'commander.helpDisplayed' || e.code === 'commander.version')
|
|
486
696
|
return;
|
|
487
697
|
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.
|
|
3
|
+
"version": "0.3.0",
|
|
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
|
},
|
|
@@ -14,6 +14,7 @@ Run `command -v giftsofprometheus`. If it is missing, run every command below as
|
|
|
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
|
|
|
@@ -33,6 +34,7 @@ giftsofprometheus --json talks search 'agent evaluation' # published talks by
|
|
|
33
34
|
giftsofprometheus --json talks list --page 2 # the whole catalog, page by page
|
|
34
35
|
giftsofprometheus --json talks get <slug-or-id> # one talk: summary, speakers, topics, publication
|
|
35
36
|
giftsofprometheus --json talks content <slug-or-id> # full transcript, requires login
|
|
37
|
+
giftsofprometheus --json talks similar <slug-or-id> # up to four similar talks with a reason each
|
|
36
38
|
giftsofprometheus --json feed # personal recommendations, requires login
|
|
37
39
|
giftsofprometheus --json favorites list # saved talks, requires login
|
|
38
40
|
giftsofprometheus --json profile get # interests and current task, requires login
|
|
@@ -43,6 +45,17 @@ giftsofprometheus --json profile get # interests and curre
|
|
|
43
45
|
- A transcript is in the talk's original language. Segment timecodes are in milliseconds from the start of the talk. When a talk is a part of a longer recording, `sourceRange` gives its bounds in that recording. A talk without a transcript returns an empty array.
|
|
44
46
|
- `request <path>` makes a read-only GET to a path under `/api/knowledge/` or `/api/account/` that no command covers.
|
|
45
47
|
- Reading never needs the user's confirmation: search, open talks and transcripts as the task requires.
|
|
48
|
+
- A list with a `recId` (feed, search, similar) puts it into each item's `contentUrl`. When you open a talk from that list, pass it on: `talks content <slug> --rec-id <recId>`, and `favorites add <slug> --rec-id <recId>` when the user saves it.
|
|
49
|
+
|
|
50
|
+
## Next steps
|
|
51
|
+
|
|
52
|
+
After answering, offer one next step in a short line, matched to where the user is. Offer each kind at most once per talk, and skip it when the user is busy with something else:
|
|
53
|
+
|
|
54
|
+
- After a summary (`talks get`): the full transcript.
|
|
55
|
+
- After the transcript or a discussion of it: talks like this one (`talks similar`); show titles with their `reason`.
|
|
56
|
+
- When the user says a talk was useful: saving it to favorites. Save only after they agree.
|
|
57
|
+
|
|
58
|
+
Commands print the suggested next command on stderr. It is a hint for you; do not run a change without the user.
|
|
46
59
|
|
|
47
60
|
## Onboarding
|
|
48
61
|
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
{
|
|
38
|
+
"version": "0.3.0",
|
|
39
|
+
"hash": "dd211af3576fc485",
|
|
40
|
+
"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."
|
|
41
|
+
}
|
|
42
|
+
]
|