@phnx-labs/agents-cli 1.23.27 → 1.23.29
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/CHANGELOG.md +8 -0
- package/README.md +33 -82
- package/dist/bootstrap.js +0 -17
- package/dist/cli/command-registry.js +0 -2
- package/dist/commands/cloud.js +0 -58
- package/dist/commands/config.js +0 -4
- package/dist/commands/daemon-index.js +1 -1
- package/dist/commands/daemon.js +14 -63
- package/dist/commands/doctor.js +0 -12
- package/dist/commands/events.js +1 -1
- package/dist/commands/feed.d.ts +1 -3
- package/dist/commands/feed.js +1 -6
- package/dist/commands/fleet-capture.js +2 -4
- package/dist/commands/focus.d.ts +0 -1
- package/dist/commands/focus.js +2 -4
- package/dist/commands/inspect.d.ts +1 -19
- package/dist/commands/inspect.js +8 -474
- package/dist/commands/mine.js +1 -1
- package/dist/commands/prune.js +2 -64
- package/dist/commands/ps-roster.d.ts +0 -4
- package/dist/commands/ps-roster.js +2 -30
- package/dist/commands/ps.js +1 -4
- package/dist/commands/repo.d.ts +1 -1
- package/dist/commands/repo.js +4 -4
- package/dist/commands/sessions-browser.d.ts +0 -2
- package/dist/commands/sessions-browser.js +2 -32
- package/dist/commands/sessions-optimize.js +3 -4
- package/dist/commands/setup-mine.js +0 -1
- package/dist/commands/ssh.js +8 -9
- package/dist/commands/sync.js +1 -1
- package/dist/commands/update.js +2 -2
- package/dist/commands/watchdog.js +3 -4
- package/dist/lib/accounting/rotate.d.ts +0 -2
- package/dist/lib/accounting/rotate.js +1 -4
- package/dist/lib/agent-spec/agents.d.ts +0 -1
- package/dist/lib/agent-spec/agents.js +0 -8
- package/dist/lib/auth-health.d.ts +0 -1
- package/dist/lib/auth-health.js +0 -3
- package/dist/lib/cli-entry.d.ts +0 -1
- package/dist/lib/cli-entry.js +0 -36
- package/dist/lib/cloud/types.d.ts +0 -2
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +1 -4
- package/dist/lib/daemon/daemon.d.ts +0 -4
- package/dist/lib/daemon/daemon.js +6 -202
- package/dist/lib/daemon/heartbeat-service.d.ts +1 -1
- package/dist/lib/daemon/heartbeat-service.js +1 -8
- package/dist/lib/daemon-services.d.ts +1 -1
- package/dist/lib/daemon-services.js +1 -11
- package/dist/lib/device-config.d.ts +0 -2
- package/dist/lib/device-config.js +4 -22
- package/dist/lib/devices/config-migration.js +1 -3
- package/dist/lib/exec.d.ts +2 -5
- package/dist/lib/exec.js +18 -18
- package/dist/lib/factory/snapshot.d.ts +0 -5
- package/dist/lib/factory/snapshot.js +1 -28
- package/dist/lib/feed/events.d.ts +1 -11
- package/dist/lib/feed/events.js +0 -20
- package/dist/lib/feed/feed.d.ts +0 -2
- package/dist/lib/feed-outcome.d.ts +0 -2
- package/dist/lib/feed-outcome.js +0 -5
- package/dist/lib/fleet/capture.d.ts +0 -1
- package/dist/lib/fleet/capture.js +0 -3
- package/dist/lib/fleet/manifest.js +0 -6
- package/dist/lib/fleet/types.d.ts +0 -1
- package/dist/lib/harness/adapter.d.ts +0 -7
- package/dist/lib/harness/adapters/claude.js +0 -18
- package/dist/lib/harness/adapters/codex.js +0 -10
- package/dist/lib/harness/adapters/cursor.js +0 -11
- package/dist/lib/harness/adapters/kimi.js +0 -3
- package/dist/lib/harness/adapters/muse.js +0 -11
- package/dist/lib/harness/index.d.ts +1 -1
- package/dist/lib/harness/index.js +0 -2
- package/dist/lib/hosts/passthrough.js +2 -10
- package/dist/lib/hosts/ready.d.ts +0 -4
- package/dist/lib/hosts/ready.js +0 -9
- package/dist/lib/hosts/reconcile.d.ts +0 -1
- package/dist/lib/hosts/reconcile.js +0 -8
- package/dist/lib/installations/migrate.d.ts +0 -2
- package/dist/lib/installations/migrate.js +0 -145
- package/dist/lib/loop.js +1 -2
- package/dist/lib/menubar/snapshot.d.ts +0 -1
- package/dist/lib/menubar/snapshot.js +1 -4
- package/dist/lib/placement.d.ts +1 -2
- package/dist/lib/placement.js +4 -24
- package/dist/lib/profiles.d.ts +0 -1
- package/dist/lib/profiles.js +0 -6
- package/dist/lib/projects.js +15 -17
- package/dist/lib/session/active.d.ts +1 -3
- package/dist/lib/session/active.js +0 -4
- package/dist/lib/session/db.d.ts +0 -1
- package/dist/lib/session/db.js +4 -8
- package/dist/lib/session/discover.d.ts +0 -1
- package/dist/lib/session/discover.js +3 -128
- package/dist/lib/session/live-metadata.js +0 -2
- package/dist/lib/session/presentation.d.ts +0 -1
- package/dist/lib/session/presentation.js +3 -8
- package/dist/lib/session/selection.d.ts +0 -2
- package/dist/lib/session/selection.js +2 -12
- package/dist/lib/staleness/detectors/commands.d.ts +1 -1
- package/dist/lib/staleness/detectors/hooks.d.ts +1 -1
- package/dist/lib/staleness/detectors/mcp.d.ts +1 -1
- package/dist/lib/staleness/detectors/permissions.d.ts +1 -1
- package/dist/lib/staleness/detectors/plugins.d.ts +1 -1
- package/dist/lib/staleness/detectors/rules.d.ts +1 -1
- package/dist/lib/staleness/detectors/skills.d.ts +1 -1
- package/dist/lib/staleness/detectors/subagents.d.ts +1 -1
- package/dist/lib/staleness/detectors/workflows.d.ts +1 -1
- package/dist/lib/staleness/writers/commands.d.ts +1 -1
- package/dist/lib/staleness/writers/hooks.d.ts +1 -1
- package/dist/lib/staleness/writers/mcp.d.ts +1 -1
- package/dist/lib/staleness/writers/permissions.d.ts +1 -1
- package/dist/lib/staleness/writers/plugins.d.ts +1 -1
- package/dist/lib/staleness/writers/rules.d.ts +1 -1
- package/dist/lib/staleness/writers/skills.d.ts +1 -1
- package/dist/lib/staleness/writers/subagents.d.ts +1 -1
- package/dist/lib/staleness/writers/workflows.d.ts +1 -1
- package/dist/lib/startup/command-registry.js +5 -2
- package/dist/lib/state.d.ts +0 -3
- package/dist/lib/state.js +2 -25
- package/dist/lib/types.d.ts +0 -1
- package/dist/lib/watchdog/runner.d.ts +0 -2
- package/dist/lib/watchdog/runner.js +0 -2
- package/package.json +1 -1
- package/scripts/postinstall.js +2 -2
- package/dist/commands/routines.d.ts +0 -14
- package/dist/commands/routines.js +0 -2149
- package/dist/commands/routines.test-fixture.d.ts +0 -52
- package/dist/commands/routines.test-fixture.js +0 -254
- package/dist/lib/catchup.d.ts +0 -19
- package/dist/lib/catchup.js +0 -83
- package/dist/lib/daemon/catchup-service.d.ts +0 -18
- package/dist/lib/daemon/catchup-service.js +0 -21
- package/dist/lib/daemon/runner.d.ts +0 -91
- package/dist/lib/daemon/runner.js +0 -1927
- package/dist/lib/harness/adapters/droid.d.ts +0 -2
- package/dist/lib/harness/adapters/droid.js +0 -14
- package/dist/lib/overdue.d.ts +0 -9
- package/dist/lib/overdue.js +0 -74
- package/dist/lib/routine-activation.d.ts +0 -13
- package/dist/lib/routine-activation.js +0 -117
- package/dist/lib/routine-context.d.ts +0 -59
- package/dist/lib/routine-context.js +0 -181
- package/dist/lib/routine-notify-owner.d.ts +0 -4
- package/dist/lib/routine-notify-owner.js +0 -49
- package/dist/lib/routine-notify.d.ts +0 -17
- package/dist/lib/routine-notify.js +0 -138
- package/dist/lib/routine-process-cleanup.d.ts +0 -9
- package/dist/lib/routine-process-cleanup.js +0 -81
- package/dist/lib/routine-readiness.d.ts +0 -31
- package/dist/lib/routine-readiness.js +0 -256
- package/dist/lib/routines-format.d.ts +0 -7
- package/dist/lib/routines-format.js +0 -127
- package/dist/lib/routines-placement.d.ts +0 -16
- package/dist/lib/routines-placement.js +0 -60
- package/dist/lib/routines-project.d.ts +0 -49
- package/dist/lib/routines-project.js +0 -306
- package/dist/lib/sandbox.d.ts +0 -15
- package/dist/lib/sandbox.js +0 -309
- package/dist/lib/scheduler.d.ts +0 -23
- package/dist/lib/scheduler.js +0 -106
- package/dist/lib/scheduling/routines.d.ts +0 -264
- package/dist/lib/scheduling/routines.js +0 -1292
- package/dist/lib/triggers/webhook.d.ts +0 -26
- package/dist/lib/triggers/webhook.js +0 -181
package/dist/commands/inspect.js
CHANGED
|
@@ -26,9 +26,6 @@ import { countSessionsInScope } from '../lib/session/discover.js';
|
|
|
26
26
|
import { isSessionTrackedAgent } from '@phnx-labs/sessions-cli/reader';
|
|
27
27
|
import { damerauLevenshtein } from '../lib/fuzzy.js';
|
|
28
28
|
import { terminalWidth, truncateToWidth, stringWidth, stripAnsi } from '../lib/session/width.js';
|
|
29
|
-
import { readJobFileResult, getJobRunsDir, readRunMeta, isOneShotRoutine, isPastOneShotRoutine, listJobs, } from '../lib/scheduling/routines.js';
|
|
30
|
-
import { routineDeviceIndex, currentRoutineDevice, routineEnabledOnThisDevice, } from '../lib/routine-activation.js';
|
|
31
|
-
import { humanizeCron } from '../lib/routines-format.js';
|
|
32
29
|
const DRILLABLE_KINDS = [
|
|
33
30
|
'commands',
|
|
34
31
|
'skills',
|
|
@@ -38,10 +35,9 @@ const DRILLABLE_KINDS = [
|
|
|
38
35
|
'plugins',
|
|
39
36
|
'workflows',
|
|
40
37
|
'subagents',
|
|
41
|
-
'routines',
|
|
42
38
|
];
|
|
43
39
|
const SIMPLE_KINDS = ['commands', 'skills', 'rules', 'subagents', 'workflows'];
|
|
44
|
-
const RICH_KINDS = ['hooks', 'plugins', 'mcp'
|
|
40
|
+
const RICH_KINDS = ['hooks', 'plugins', 'mcp'];
|
|
45
41
|
const _kindsPartitioned = true;
|
|
46
42
|
void _kindsPartitioned;
|
|
47
43
|
const SINGULAR_DRILL_ALIASES = {
|
|
@@ -52,7 +48,6 @@ const SINGULAR_DRILL_ALIASES = {
|
|
|
52
48
|
plugin: 'plugins',
|
|
53
49
|
workflow: 'workflows',
|
|
54
50
|
subagent: 'subagents',
|
|
55
|
-
routine: 'routines',
|
|
56
51
|
};
|
|
57
52
|
const CAPABILITY_NAMES = [
|
|
58
53
|
'hooks', 'mcp', 'skills', 'commands', 'subagents', 'plugins', 'workflows', 'rules', 'allowlist',
|
|
@@ -221,8 +216,6 @@ function isDotAgentsRoot(dir) {
|
|
|
221
216
|
return true;
|
|
222
217
|
}
|
|
223
218
|
for (const kind of DRILLABLE_KINDS) {
|
|
224
|
-
if (kind === 'routines')
|
|
225
|
-
continue;
|
|
226
219
|
if (safeStat(path.join(dir, kind))?.isDirectory())
|
|
227
220
|
return true;
|
|
228
221
|
}
|
|
@@ -232,19 +225,7 @@ export async function inspectRepo(repo, options) {
|
|
|
232
225
|
const drill = pickDrillKind(options);
|
|
233
226
|
const jsonHead = { repo: repo.label, root: repo.root };
|
|
234
227
|
if (drill) {
|
|
235
|
-
|
|
236
|
-
if (drill.kind === 'routines') {
|
|
237
|
-
const provider = defaultRoutineLive();
|
|
238
|
-
items = collectRepoRoutines(repo, provider.live);
|
|
239
|
-
if (!options.json) {
|
|
240
|
-
for (const err of provider.errors) {
|
|
241
|
-
console.error(chalk.yellow(`device config unreadable — ${err}`));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
items = collectRepoKind(repo, drill.kind);
|
|
247
|
-
}
|
|
228
|
+
const items = collectRepoKind(repo, drill.kind);
|
|
248
229
|
if (drill.query === true || drill.query === undefined) {
|
|
249
230
|
await renderItemList(repo.label, jsonHead, drill.kind, items, options, drill.kind === 'hooks'
|
|
250
231
|
? hookManifestByScript(hookManifestFromFile(path.join(repo.root, 'agents.yaml')))
|
|
@@ -270,262 +251,8 @@ export function collectRepoKind(repo, kind) {
|
|
|
270
251
|
if (fs.existsSync(subrulesDir))
|
|
271
252
|
return readResourceDir(subrulesDir, kind, repo.label);
|
|
272
253
|
}
|
|
273
|
-
if (kind === 'routines')
|
|
274
|
-
return collectRepoRoutines(repo);
|
|
275
254
|
return readResourceDir(path.join(repo.root, kind), kind, repo.label);
|
|
276
255
|
}
|
|
277
|
-
const NO_LIVE_STATE = {
|
|
278
|
-
devices: [], materialized: false, thisDevice: '', enabledHere: null, lastStatus: null, lastAt: null,
|
|
279
|
-
};
|
|
280
|
-
function routineEnabledHere(config, live) {
|
|
281
|
-
return live.enabledHere === null ? config.enabled : live.enabledHere;
|
|
282
|
-
}
|
|
283
|
-
function latestRunOf(name, maxProbes = 20) {
|
|
284
|
-
let runIds;
|
|
285
|
-
try {
|
|
286
|
-
runIds = fs.readdirSync(getJobRunsDir(name), { withFileTypes: true })
|
|
287
|
-
.filter(e => e.isDirectory())
|
|
288
|
-
.map(e => e.name)
|
|
289
|
-
.sort()
|
|
290
|
-
.reverse();
|
|
291
|
-
}
|
|
292
|
-
catch {
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
for (const runId of runIds.slice(0, maxProbes)) {
|
|
296
|
-
const meta = readRunMeta(name, runId);
|
|
297
|
-
if (meta)
|
|
298
|
-
return meta;
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
function defaultRoutineLive() {
|
|
303
|
-
let index;
|
|
304
|
-
try {
|
|
305
|
-
index = routineDeviceIndex();
|
|
306
|
-
}
|
|
307
|
-
catch (err) {
|
|
308
|
-
return { live: () => NO_LIVE_STATE, errors: [err.message] };
|
|
309
|
-
}
|
|
310
|
-
const thisDevice = (() => { try {
|
|
311
|
-
return currentRoutineDevice();
|
|
312
|
-
}
|
|
313
|
-
catch {
|
|
314
|
-
return '';
|
|
315
|
-
} })();
|
|
316
|
-
const errors = [...index.errors];
|
|
317
|
-
let ownDocError = null;
|
|
318
|
-
const enabledOnThisDevice = (name) => {
|
|
319
|
-
try {
|
|
320
|
-
return routineEnabledOnThisDevice(name);
|
|
321
|
-
}
|
|
322
|
-
catch (err) {
|
|
323
|
-
if (!ownDocError) {
|
|
324
|
-
ownDocError = `this device's own config is unreadable — ${err.message}`;
|
|
325
|
-
errors.push(ownDocError);
|
|
326
|
-
}
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
const live = (name) => {
|
|
331
|
-
const run = latestRunOf(name);
|
|
332
|
-
return {
|
|
333
|
-
devices: index.byRoutine.get(name) ?? [],
|
|
334
|
-
materialized: index.materialized,
|
|
335
|
-
thisDevice,
|
|
336
|
-
enabledHere: enabledOnThisDevice(name),
|
|
337
|
-
lastStatus: run?.status ?? null,
|
|
338
|
-
lastAt: run?.startedAt ?? null,
|
|
339
|
-
};
|
|
340
|
-
};
|
|
341
|
-
return { live, errors };
|
|
342
|
-
}
|
|
343
|
-
export function compactAge(iso, now = new Date()) {
|
|
344
|
-
if (!iso)
|
|
345
|
-
return '';
|
|
346
|
-
const then = Date.parse(iso);
|
|
347
|
-
if (!Number.isFinite(then))
|
|
348
|
-
return '';
|
|
349
|
-
const mins = Math.floor((now.getTime() - then) / 60000);
|
|
350
|
-
if (mins < 1)
|
|
351
|
-
return 'now';
|
|
352
|
-
if (mins < 60)
|
|
353
|
-
return `${mins}m`;
|
|
354
|
-
const hours = Math.floor(mins / 60);
|
|
355
|
-
if (hours < 24)
|
|
356
|
-
return `${hours}h`;
|
|
357
|
-
const days = Math.floor(hours / 24);
|
|
358
|
-
if (days < 365)
|
|
359
|
-
return `${days}d`;
|
|
360
|
-
return `${Math.floor(days / 365)}y`;
|
|
361
|
-
}
|
|
362
|
-
export function routineFireLabel(job, now = new Date()) {
|
|
363
|
-
const parts = [];
|
|
364
|
-
if (job.schedule)
|
|
365
|
-
parts.push(humanizeCron(job.schedule, job.timezone));
|
|
366
|
-
if (job.trigger) {
|
|
367
|
-
const t = job.trigger;
|
|
368
|
-
const event = manifestText(t.event) || manifestText(t.type) || 'event';
|
|
369
|
-
const qualifier = [manifestText(t.action), manifestText(t.label)].filter(Boolean).join(' ');
|
|
370
|
-
parts.push(qualifier ? `on ${event} (${qualifier})` : `on ${event}`);
|
|
371
|
-
}
|
|
372
|
-
if (parts.length === 0)
|
|
373
|
-
return 'no schedule or trigger';
|
|
374
|
-
if (isOneShotRoutine(job)) {
|
|
375
|
-
parts.push(isPastOneShotRoutine(job, now) ? '(one-shot, expired)' : '(one-shot)');
|
|
376
|
-
}
|
|
377
|
-
return parts.join(' · ');
|
|
378
|
-
}
|
|
379
|
-
export function routineTargetLabel(job) {
|
|
380
|
-
const agent = manifestText(job.agent);
|
|
381
|
-
if (agent)
|
|
382
|
-
return `agent ${agent}`;
|
|
383
|
-
const workflow = manifestText(job.workflow);
|
|
384
|
-
if (workflow)
|
|
385
|
-
return `workflow ${workflow}`;
|
|
386
|
-
if (manifestText(job.command))
|
|
387
|
-
return 'command (shell)';
|
|
388
|
-
return 'nothing configured';
|
|
389
|
-
}
|
|
390
|
-
export function routineDescription(job, raw) {
|
|
391
|
-
const prompt = job ? manifestText(job.prompt).trim() : '';
|
|
392
|
-
if (prompt)
|
|
393
|
-
return summaryLine(truncate(prompt.replace(/\s+/g, ' '), 400));
|
|
394
|
-
const lines = raw.split('\n');
|
|
395
|
-
for (const line of lines) {
|
|
396
|
-
const comment = line.match(/^\s*#\s?(.+)$/);
|
|
397
|
-
if (!comment) {
|
|
398
|
-
if (line.trim())
|
|
399
|
-
break;
|
|
400
|
-
else
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
const text = comment[1].trim().replace(/^Routine:\s*/i, '');
|
|
404
|
-
if (!text || /^(yaml-language-server|Install:|Usage:)/i.test(text))
|
|
405
|
-
continue;
|
|
406
|
-
return summaryLine(text);
|
|
407
|
-
}
|
|
408
|
-
const command = job ? manifestText(job.command) : '';
|
|
409
|
-
for (const line of command.split('\n')) {
|
|
410
|
-
const text = line.trim();
|
|
411
|
-
if (!text || text.startsWith('#') || /^set\s+-/.test(text))
|
|
412
|
-
continue;
|
|
413
|
-
return truncate(text, 120);
|
|
414
|
-
}
|
|
415
|
-
return '';
|
|
416
|
-
}
|
|
417
|
-
export function collectRepoRoutines(repo, live = defaultRoutineLive().live, now = new Date()) {
|
|
418
|
-
const dir = path.join(repo.root, 'routines');
|
|
419
|
-
let entries;
|
|
420
|
-
try {
|
|
421
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
422
|
-
}
|
|
423
|
-
catch {
|
|
424
|
-
return [];
|
|
425
|
-
}
|
|
426
|
-
const items = [];
|
|
427
|
-
const seen = new Map();
|
|
428
|
-
const files = entries
|
|
429
|
-
.filter(e => e.isFile() && /\.ya?ml$/.test(e.name) && !e.name.startsWith('.'))
|
|
430
|
-
.map(e => e.name)
|
|
431
|
-
.sort((a, b) => {
|
|
432
|
-
const an = a.replace(/\.ya?ml$/, ''), bn = b.replace(/\.ya?ml$/, '');
|
|
433
|
-
if (an !== bn)
|
|
434
|
-
return an.localeCompare(bn);
|
|
435
|
-
return (a.endsWith('.yml') ? 0 : 1) - (b.endsWith('.yml') ? 0 : 1);
|
|
436
|
-
});
|
|
437
|
-
for (const file of files) {
|
|
438
|
-
const filePath = path.join(dir, file);
|
|
439
|
-
const { config, problem } = readJobFileResult(filePath);
|
|
440
|
-
const basename = file.replace(/\.ya?ml$/, '');
|
|
441
|
-
const name = config?.name || basename;
|
|
442
|
-
const existing = seen.get(name);
|
|
443
|
-
if (existing) {
|
|
444
|
-
const collision = `both .yml and .yaml exist — ${file} is ignored; resolve before editing`;
|
|
445
|
-
existing.extra = [...(existing.extra ?? []), ['problem', collision]];
|
|
446
|
-
if (existing.json)
|
|
447
|
-
existing.json.problem = collision;
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
const raw = (() => { try {
|
|
451
|
-
return fs.readFileSync(filePath, 'utf-8');
|
|
452
|
-
}
|
|
453
|
-
catch {
|
|
454
|
-
return '';
|
|
455
|
-
} })();
|
|
456
|
-
const state = config ? live(name) : NO_LIVE_STATE;
|
|
457
|
-
const extra = [];
|
|
458
|
-
if (config) {
|
|
459
|
-
extra.push(['fires', routineFireLabel(config, now)]);
|
|
460
|
-
extra.push(['runs', routineTargetLabel(config)]);
|
|
461
|
-
extra.push(['devices', state.devices.length > 0
|
|
462
|
-
? state.devices.join(', ')
|
|
463
|
-
: state.materialized ? 'no device — will not fire' : 'no device allowlist yet']);
|
|
464
|
-
extra.push(['last', state.lastStatus
|
|
465
|
-
? `${state.lastStatus}${state.lastAt ? ` · ${compactAge(state.lastAt, now)} ago` : ''}`
|
|
466
|
-
: 'never run']);
|
|
467
|
-
extra.push(['enabled', routineEnabledHere(config, state)
|
|
468
|
-
? `yes${state.thisDevice ? ` (on ${state.thisDevice})` : ''}`
|
|
469
|
-
: `no${state.thisDevice ? ` (on ${state.thisDevice})` : ''}`]);
|
|
470
|
-
const repoRef = manifestText(config.repo);
|
|
471
|
-
if (repoRef)
|
|
472
|
-
extra.push(['repo', repoRef]);
|
|
473
|
-
const tz = manifestText(config.timezone);
|
|
474
|
-
if (tz)
|
|
475
|
-
extra.push(['timezone', tz]);
|
|
476
|
-
if (config.catchup === false)
|
|
477
|
-
extra.push(['catchup', 'off — a missed fire is lost']);
|
|
478
|
-
const host = manifestText(config.host);
|
|
479
|
-
if (host)
|
|
480
|
-
extra.push(['host', host]);
|
|
481
|
-
const pinned = manifestList(config.devices);
|
|
482
|
-
if (pinned.length > 0)
|
|
483
|
-
extra.push(['pinned', pinned.join(', ')]);
|
|
484
|
-
if (name !== basename)
|
|
485
|
-
extra.push(['file', file]);
|
|
486
|
-
}
|
|
487
|
-
else if (problem) {
|
|
488
|
-
extra.push(['problem', problem]);
|
|
489
|
-
}
|
|
490
|
-
const item = {
|
|
491
|
-
name,
|
|
492
|
-
source: repo.label,
|
|
493
|
-
path: filePath,
|
|
494
|
-
linkTarget: filePath,
|
|
495
|
-
description: routineDescription(config, raw),
|
|
496
|
-
extra,
|
|
497
|
-
json: {
|
|
498
|
-
path: filePath,
|
|
499
|
-
schedule: config?.schedule ?? null,
|
|
500
|
-
scheduleHuman: config ? routineFireLabel(config, now) : null,
|
|
501
|
-
trigger: config?.trigger ?? null,
|
|
502
|
-
runs: config ? routineTargetLabel(config) : null,
|
|
503
|
-
agent: config?.agent ?? null,
|
|
504
|
-
workflow: config?.workflow ?? null,
|
|
505
|
-
command: config?.command ?? null,
|
|
506
|
-
timezone: config?.timezone ?? null,
|
|
507
|
-
repo: config?.repo ?? null,
|
|
508
|
-
enabled: config ? routineEnabledHere(config, state) : false,
|
|
509
|
-
enabledInFile: config?.enabled ?? false,
|
|
510
|
-
catchup: config ? config.catchup !== false : null,
|
|
511
|
-
devices: config ? manifestList(config.devices) : [],
|
|
512
|
-
enabledDevices: state.devices,
|
|
513
|
-
activationMaterialized: state.materialized,
|
|
514
|
-
oneShot: config ? isOneShotRoutine(config) : false,
|
|
515
|
-
expired: config ? isPastOneShotRoutine(config, now) : false,
|
|
516
|
-
lastStatus: state.lastStatus,
|
|
517
|
-
lastRunAt: state.lastAt,
|
|
518
|
-
problem,
|
|
519
|
-
},
|
|
520
|
-
};
|
|
521
|
-
seen.set(name, item);
|
|
522
|
-
items.push(item);
|
|
523
|
-
}
|
|
524
|
-
return items.sort((a, b) => a.name.localeCompare(b.name));
|
|
525
|
-
}
|
|
526
|
-
function extraOf(item, key) {
|
|
527
|
-
return item.extra?.find(([k]) => k === key)?.[1] ?? '';
|
|
528
|
-
}
|
|
529
256
|
function readResourceDir(dir, kind, source) {
|
|
530
257
|
let entries;
|
|
531
258
|
try {
|
|
@@ -590,15 +317,6 @@ export function pathSize(p) {
|
|
|
590
317
|
}
|
|
591
318
|
return { bytes, files };
|
|
592
319
|
}
|
|
593
|
-
function itemsSize(items) {
|
|
594
|
-
let bytes = 0, files = 0;
|
|
595
|
-
for (const item of items) {
|
|
596
|
-
const sub = pathSize(item.path);
|
|
597
|
-
bytes += sub.bytes;
|
|
598
|
-
files += sub.files;
|
|
599
|
-
}
|
|
600
|
-
return { bytes, files };
|
|
601
|
-
}
|
|
602
320
|
export function repoManifestSummary(root) {
|
|
603
321
|
let parsed;
|
|
604
322
|
try {
|
|
@@ -637,19 +355,10 @@ function renderRepoSummary(repo, options) {
|
|
|
637
355
|
let totalBytes = 0, totalFiles = 0;
|
|
638
356
|
let repoHookByScript = new Map();
|
|
639
357
|
let repoMcpConfigs = new Map();
|
|
640
|
-
let routineActivationErrors = [];
|
|
641
358
|
if (!options.brief) {
|
|
642
359
|
for (const kind of DRILLABLE_KINDS) {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
const provider = defaultRoutineLive();
|
|
646
|
-
routineActivationErrors = provider.errors;
|
|
647
|
-
items = collectRepoRoutines(repo, provider.live);
|
|
648
|
-
}
|
|
649
|
-
else {
|
|
650
|
-
items = collectRepoKind(repo, kind);
|
|
651
|
-
}
|
|
652
|
-
const size = kind === 'routines' ? itemsSize(items) : pathSize(path.join(repo.root, kind));
|
|
360
|
+
const items = collectRepoKind(repo, kind);
|
|
361
|
+
const size = pathSize(path.join(repo.root, kind));
|
|
653
362
|
kindData[kind] = { items, size };
|
|
654
363
|
totalBytes += size.bytes;
|
|
655
364
|
totalFiles += size.files;
|
|
@@ -690,12 +399,6 @@ function renderRepoSummary(repo, options) {
|
|
|
690
399
|
version: i.extra?.find(([k]) => k === 'version')?.[1],
|
|
691
400
|
groups: Object.fromEntries((i.groups ?? []).map(g => [g.label, g.items.length])),
|
|
692
401
|
})) }];
|
|
693
|
-
if (kind === 'routines')
|
|
694
|
-
return [kind, { ...base, items: items.map(i => ({
|
|
695
|
-
name: i.name,
|
|
696
|
-
description: i.description,
|
|
697
|
-
...(i.json ?? {}),
|
|
698
|
-
})) }];
|
|
699
402
|
return [kind, base];
|
|
700
403
|
})),
|
|
701
404
|
}, null, 2));
|
|
@@ -753,16 +456,6 @@ function renderRepoSummary(repo, options) {
|
|
|
753
456
|
printExpandedSection('Hooks', hookRows(kindData.hooks.items, repoHookByScript));
|
|
754
457
|
printExpandedSection('Plugins', pluginRows(kindData.plugins.items));
|
|
755
458
|
printExpandedSection('MCP', mcpRows(kindData.mcp.items, repoMcpConfigs));
|
|
756
|
-
printExpandedSection('Routines', routineRows(kindData.routines.items));
|
|
757
|
-
const dark = routineDarkWarning(kindData.routines.items);
|
|
758
|
-
if (dark) {
|
|
759
|
-
console.log('');
|
|
760
|
-
console.log(` ${chalk.yellow('⚠')} ${dark}`);
|
|
761
|
-
console.log(chalk.gray(` Fix: agents routines devices <name> --set <device>`));
|
|
762
|
-
}
|
|
763
|
-
for (const err of routineActivationErrors) {
|
|
764
|
-
console.log(chalk.gray(` device config unreadable — ${err}`));
|
|
765
|
-
}
|
|
766
459
|
}
|
|
767
460
|
console.log('');
|
|
768
461
|
console.log(chalk.gray(`Drill in: agents inspect ${repo.label} --skills <query>`));
|
|
@@ -893,7 +586,6 @@ async function renderSummary(agent, version, versionHome, options) {
|
|
|
893
586
|
printExpandedSection('Hook files', hookRows(itemsByKind.hooks, hookByScript));
|
|
894
587
|
printExpandedSection('Plugins', pluginRows(itemsByKind.plugins));
|
|
895
588
|
printExpandedSection('MCP', mcpRows(itemsByKind.mcp, mcpConfigs));
|
|
896
|
-
printExpandedSection('Routines', agentRoutineRows(itemsByKind.routines));
|
|
897
589
|
}
|
|
898
590
|
if (sessions) {
|
|
899
591
|
console.log('\n' + chalk.bold('Sessions'));
|
|
@@ -933,13 +625,11 @@ async function renderItemList(header, jsonHead, kind, items, options, hookManife
|
|
|
933
625
|
}
|
|
934
626
|
const sources = new Set(items.map(i => i.source));
|
|
935
627
|
const hookEvents = kind !== 'hooks' ? null : (hookManifest ?? hookManifestByScript(loadCentralHookManifest()));
|
|
936
|
-
const isRoutines = kind === 'routines';
|
|
937
|
-
const routineDevicesColumn = isRoutines && terminalWidth() >= 100;
|
|
938
628
|
await showResourceList({
|
|
939
629
|
resourcePlural: kind,
|
|
940
630
|
resourceSingular: kind.replace(/s$/, ''),
|
|
941
|
-
extraLabel:
|
|
942
|
-
extra2Label:
|
|
631
|
+
extraLabel: 'Size',
|
|
632
|
+
extra2Label: sources.size > 1 ? 'Source' : undefined,
|
|
943
633
|
showSync: false,
|
|
944
634
|
nameCap: terminalWidth() >= 120 ? 40 : undefined,
|
|
945
635
|
linkFor: row => items.find(i => i.name === row.name)?.linkTarget,
|
|
@@ -950,22 +640,10 @@ async function renderItemList(header, jsonHead, kind, items, options, hookManife
|
|
|
950
640
|
const hook = hookEvents?.get(item.name);
|
|
951
641
|
if (hook)
|
|
952
642
|
return summarizeHook(hook);
|
|
953
|
-
if (isRoutines) {
|
|
954
|
-
const problem = extraOf(item, 'problem');
|
|
955
|
-
if (problem)
|
|
956
|
-
return problem;
|
|
957
|
-
return [
|
|
958
|
-
extraOf(item, 'fires'),
|
|
959
|
-
routineDevicesColumn ? '' : compactDeviceCell(extraOf(item, 'devices')),
|
|
960
|
-
summaryLine(item.description),
|
|
961
|
-
].filter(Boolean).join(' · ');
|
|
962
|
-
}
|
|
963
643
|
return summaryLine(item.description);
|
|
964
644
|
})(),
|
|
965
|
-
extra:
|
|
966
|
-
extra2:
|
|
967
|
-
? compactDeviceCell(extraOf(item, 'devices')) || 'none'
|
|
968
|
-
: (isRoutines ? undefined : (sources.size > 1 ? item.source : undefined)),
|
|
645
|
+
extra: itemSizeLabel(item.path),
|
|
646
|
+
extra2: sources.size > 1 ? item.source : undefined,
|
|
969
647
|
targets: [],
|
|
970
648
|
buildDetail: () => previewFor(kind, item, hookEvents ?? new Map()),
|
|
971
649
|
})),
|
|
@@ -1113,13 +791,6 @@ function summaryResourcesJson(itemsByKind, hookByScript, mcpConfigs, hookInvento
|
|
|
1113
791
|
groups: Object.fromEntries((i.groups ?? []).map(g => [g.label, g.items.length])),
|
|
1114
792
|
})) };
|
|
1115
793
|
}
|
|
1116
|
-
else if (kind === 'routines') {
|
|
1117
|
-
out[kind] = { ...base, items: items.map(i => ({
|
|
1118
|
-
name: i.name,
|
|
1119
|
-
source: i.source,
|
|
1120
|
-
...Object.fromEntries(i.extra ?? []),
|
|
1121
|
-
})) };
|
|
1122
|
-
}
|
|
1123
794
|
else {
|
|
1124
795
|
out[kind] = { ...base, names: items.map(i => i.name) };
|
|
1125
796
|
}
|
|
@@ -1152,43 +823,7 @@ function collectKind(agent, versionHome, kind) {
|
|
|
1152
823
|
}));
|
|
1153
824
|
case 'plugins':
|
|
1154
825
|
return pluginItems();
|
|
1155
|
-
case 'routines':
|
|
1156
|
-
return agentRoutineItems(agent);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
function agentRoutineItems(agent) {
|
|
1160
|
-
const { live } = defaultRoutineLive();
|
|
1161
|
-
const now = new Date();
|
|
1162
|
-
let jobs;
|
|
1163
|
-
try {
|
|
1164
|
-
jobs = listJobs();
|
|
1165
|
-
}
|
|
1166
|
-
catch {
|
|
1167
|
-
return [];
|
|
1168
826
|
}
|
|
1169
|
-
return jobs
|
|
1170
|
-
.filter(job => job.agent === agent)
|
|
1171
|
-
.map(job => {
|
|
1172
|
-
const state = live(job.name);
|
|
1173
|
-
return {
|
|
1174
|
-
name: job.name,
|
|
1175
|
-
source: 'user',
|
|
1176
|
-
path: '',
|
|
1177
|
-
linkTarget: '',
|
|
1178
|
-
description: routineDescription(job, ''),
|
|
1179
|
-
extra: [
|
|
1180
|
-
['fires', routineFireLabel(job, now)],
|
|
1181
|
-
['enabled', job.enabled ? 'yes' : 'no'],
|
|
1182
|
-
['devices', state.devices.length > 0
|
|
1183
|
-
? state.devices.join(', ')
|
|
1184
|
-
: state.materialized ? 'no device — will not fire' : 'no device allowlist yet'],
|
|
1185
|
-
['last', state.lastStatus
|
|
1186
|
-
? `${state.lastStatus}${state.lastAt ? ` · ${compactAge(state.lastAt, now)} ago` : ''}`
|
|
1187
|
-
: 'never run'],
|
|
1188
|
-
],
|
|
1189
|
-
};
|
|
1190
|
-
})
|
|
1191
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
1192
827
|
}
|
|
1193
828
|
function pluginItems() {
|
|
1194
829
|
return discoverPlugins().map(p => pluginToItem(p, 'user'));
|
|
@@ -1505,107 +1140,6 @@ function pluginRows(items) {
|
|
|
1505
1140
|
return { source: item.source, name: item.name, detail, linkTarget: item.linkTarget };
|
|
1506
1141
|
});
|
|
1507
1142
|
}
|
|
1508
|
-
const UNHEALTHY_RUN = new Set(['failed', 'timeout', 'missed', 'blocked']);
|
|
1509
|
-
export function routineHealthTier(item) {
|
|
1510
|
-
if (extraOf(item, 'problem'))
|
|
1511
|
-
return 0;
|
|
1512
|
-
const fires = extraOf(item, 'fires');
|
|
1513
|
-
if (fires.includes('expired'))
|
|
1514
|
-
return 5;
|
|
1515
|
-
const devices = extraOf(item, 'devices');
|
|
1516
|
-
if (devices.startsWith('no device —'))
|
|
1517
|
-
return 1;
|
|
1518
|
-
if (extraOf(item, 'enabled').startsWith('no'))
|
|
1519
|
-
return 2;
|
|
1520
|
-
const last = extraOf(item, 'last').split(' ')[0];
|
|
1521
|
-
if (UNHEALTHY_RUN.has(last))
|
|
1522
|
-
return 3;
|
|
1523
|
-
return 4;
|
|
1524
|
-
}
|
|
1525
|
-
function routineRows(items) {
|
|
1526
|
-
const ordered = [...items].sort((a, b) => {
|
|
1527
|
-
const at = routineHealthTier(a), bt = routineHealthTier(b);
|
|
1528
|
-
return at !== bt ? at - bt : a.name.localeCompare(b.name);
|
|
1529
|
-
});
|
|
1530
|
-
const nameW = ordered.length > 0 ? Math.max(...ordered.slice(0, 6).map(r => r.name.length)) : 0;
|
|
1531
|
-
const budget = Math.max(30, terminalWidth() - nameW - 14);
|
|
1532
|
-
const firesW = Math.min(21, Math.max(12, Math.floor(budget * 0.42)));
|
|
1533
|
-
const devicesW = Math.min(14, Math.max(7, Math.floor(budget * 0.22)));
|
|
1534
|
-
return ordered.map(item => {
|
|
1535
|
-
const problem = extraOf(item, 'problem');
|
|
1536
|
-
const fires = extraOf(item, 'fires');
|
|
1537
|
-
if (problem && !fires) {
|
|
1538
|
-
return { source: item.source, name: item.name, linkTarget: item.linkTarget, detail: chalk.red(problem) };
|
|
1539
|
-
}
|
|
1540
|
-
const devices = compactDeviceCell(extraOf(item, 'devices'));
|
|
1541
|
-
const last = extraOf(item, 'last');
|
|
1542
|
-
const problemW = Math.max(12, budget - firesW - devicesW - stringWidth(last) - 8);
|
|
1543
|
-
const detail = [
|
|
1544
|
-
chalk.gray(truncateToWidth(fires, firesW).padEnd(firesW)),
|
|
1545
|
-
(devices === 'none ⚠' ? chalk.yellow : chalk.gray)(truncateToWidth(devices, devicesW).padEnd(devicesW)),
|
|
1546
|
-
colorLast(last),
|
|
1547
|
-
problem ? chalk.red(truncateToWidth(` ⚠ ${problem}`, problemW)) : '',
|
|
1548
|
-
].join(' ').trimEnd();
|
|
1549
|
-
return {
|
|
1550
|
-
source: item.source,
|
|
1551
|
-
name: item.name,
|
|
1552
|
-
linkTarget: item.linkTarget,
|
|
1553
|
-
detail,
|
|
1554
|
-
};
|
|
1555
|
-
});
|
|
1556
|
-
}
|
|
1557
|
-
function agentRoutineRows(items) {
|
|
1558
|
-
const ordered = [...items].sort((a, b) => {
|
|
1559
|
-
const at = routineHealthTier(a), bt = routineHealthTier(b);
|
|
1560
|
-
return at !== bt ? at - bt : a.name.localeCompare(b.name);
|
|
1561
|
-
});
|
|
1562
|
-
return ordered.map(item => ({
|
|
1563
|
-
source: item.source,
|
|
1564
|
-
name: item.name,
|
|
1565
|
-
detail: `${extraOf(item, 'fires').padEnd(20)} ${colorLast(extraOf(item, 'last'))}`,
|
|
1566
|
-
}));
|
|
1567
|
-
}
|
|
1568
|
-
function routineLastCell(item, width = 10) {
|
|
1569
|
-
const last = extraOf(item, 'last');
|
|
1570
|
-
if (!last || last === 'never run')
|
|
1571
|
-
return 'never';
|
|
1572
|
-
const [status, , age] = last.split(' ');
|
|
1573
|
-
const word = status === 'completed' ? 'ok' : status === 'failed' ? 'fail' : status;
|
|
1574
|
-
return truncateToWidth(age ? `${word} ${age}` : word, width);
|
|
1575
|
-
}
|
|
1576
|
-
function compactDeviceCell(devices) {
|
|
1577
|
-
if (devices.startsWith('no device —'))
|
|
1578
|
-
return 'none ⚠';
|
|
1579
|
-
if (devices.startsWith('no device allowlist yet'))
|
|
1580
|
-
return 'unset';
|
|
1581
|
-
const list = devices.split(', ').filter(Boolean);
|
|
1582
|
-
return list.length > 1 ? `${list[0]} +${list.length - 1}` : (list[0] ?? '');
|
|
1583
|
-
}
|
|
1584
|
-
function colorLast(last) {
|
|
1585
|
-
if (!last || last === 'never run')
|
|
1586
|
-
return chalk.gray('never run');
|
|
1587
|
-
const word = last.split(' ')[0];
|
|
1588
|
-
if (word === 'completed')
|
|
1589
|
-
return chalk.green(last);
|
|
1590
|
-
if (UNHEALTHY_RUN.has(word))
|
|
1591
|
-
return chalk.red(last);
|
|
1592
|
-
return chalk.gray(last);
|
|
1593
|
-
}
|
|
1594
|
-
export function routineDarkWarning(items) {
|
|
1595
|
-
const materialized = items.some(i => {
|
|
1596
|
-
const d = extraOf(i, 'devices');
|
|
1597
|
-
return d !== '' && !d.startsWith('no device allowlist yet');
|
|
1598
|
-
});
|
|
1599
|
-
if (!materialized)
|
|
1600
|
-
return null;
|
|
1601
|
-
const dark = items.filter(i => extraOf(i, 'devices').startsWith('no device —')).length;
|
|
1602
|
-
if (dark === 0)
|
|
1603
|
-
return null;
|
|
1604
|
-
const noun = items.length === 1 ? 'routine' : 'routines';
|
|
1605
|
-
const verb = dark === 1 ? 'is' : 'are';
|
|
1606
|
-
const pronoun = dark === 1 ? 'it' : 'they';
|
|
1607
|
-
return `${dark} of ${items.length} ${noun} ${verb} on no device's allowlist — ${pronoun} will not fire.`;
|
|
1608
|
-
}
|
|
1609
1143
|
function mcpRows(items, configs) {
|
|
1610
1144
|
return items.map(item => {
|
|
1611
1145
|
const cfg = configs.get(item.name);
|
package/dist/commands/mine.js
CHANGED
|
@@ -5,7 +5,7 @@ import { updateMeta } from '../lib/state.js';
|
|
|
5
5
|
import { KNOWN_TOP_LEVEL_COMMANDS } from '../lib/startup/command-registry.js';
|
|
6
6
|
function knownCommandNames() {
|
|
7
7
|
const names = new Set(KNOWN_TOP_LEVEL_COMMANDS);
|
|
8
|
-
for (const n of ['perms', 'exec', '
|
|
8
|
+
for (const n of ['perms', 'exec', 'upgrade'])
|
|
9
9
|
names.add(n);
|
|
10
10
|
return names;
|
|
11
11
|
}
|