@ethlete/agent-rules 0.1.0-next.37 → 0.1.0-next.39
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 +51 -0
- package/README.md +43 -5
- package/content/hooks/away-mode.py +287 -0
- package/content/hooks/background-design-commands.py +42 -7
- package/content/hooks/context-warning.py +2 -44
- package/content/hooks/subagent-model-policy.py +90 -23
- package/content/mods/.claude-plugin/marketplace.json +5 -0
- package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +1 -1
- package/content/mods/plugins/status-line/.claude-plugin/plugin.json +6 -0
- package/content/mods/plugins/status-line/hooks/hooks.json +1 -0
- package/content/mods/plugins/status-line/hooks/line.ts +73 -0
- package/content/mods/plugins/status-line/hooks/register.tsx +141 -0
- package/content/mods/plugins/status-line/types/index.d.ts +5 -0
- package/content/rules/subagent-models.md +9 -6
- package/content/skills/agent-sessions/SKILL.md +2 -2
- package/content/skills/agent-sessions/agent-sessions.mjs +30 -14
- package/content/skills/angular-patterns/SKILL.md +1 -1
- package/content/skills/codex-subagent/SKILL.md +1 -1
- package/content/skills/design-exploration/SKILL.md +5 -2
- package/content/skills/figma-export/SKILL.md +1 -1
- package/content/skills/handoff/SKILL.md +4 -187
- package/content/skills/handoff/save.md +187 -0
- package/content/skills/query/SKILL.md +1 -1
- package/content/skills/report/SKILL.md +26 -0
- package/content/skills/rxjs-signals/SKILL.md +1 -1
- package/content/skills/styleguide/SKILL.md +1 -1
- package/content/skills/styleguide/lint-rule-lookup.md +42 -41
- package/content/skills/theming/SKILL.md +1 -1
- package/content/skills/timetrack/SKILL.md +37 -1
- package/content/skills/verify-in-storybook/SKILL.md +1 -1
- package/package.json +1 -1
- package/src/index.js +13 -2
- package/src/index.js.map +1 -1
- package/src/lib/config.d.ts +13 -0
- package/src/lib/config.js +13 -3
- package/src/lib/config.js.map +1 -1
- package/src/lib/peer-path.d.ts +12 -0
- package/src/lib/peer-path.js +39 -0
- package/src/lib/peer-path.js.map +1 -0
- package/src/lib/plan.js +10 -2
- package/src/lib/plan.js.map +1 -1
- package/src/lib/render.d.ts +1 -0
- package/src/lib/render.js +3 -1
- package/src/lib/render.js.map +1 -1
- package/src/lib/report-command.d.ts +33 -0
- package/src/lib/report-command.js +312 -0
- package/src/lib/report-command.js.map +1 -0
- package/src/lib/targets/claude-mods.js +1 -1
- package/src/lib/targets/claude-mods.js.map +1 -1
- package/src/lib/targets/hooks-shared.js +6 -0
- package/src/lib/targets/hooks-shared.js.map +1 -1
- package/src/lib/targets/mcp.d.ts +6 -6
- package/src/lib/targets/mcp.js +9 -5
- package/src/lib/targets/mcp.js.map +1 -1
- package/src/lib/timetrack-command.js +240 -41
- package/src/lib/timetrack-command.js.map +1 -1
- package/src/lib/timetrack-snapshot.d.ts +11 -0
- package/src/lib/timetrack-snapshot.js +27 -1
- package/src/lib/timetrack-snapshot.js.map +1 -1
- package/src/lib/timetrack.d.ts +48 -2
- package/src/lib/timetrack.js +8 -2
- package/src/lib/timetrack.js.map +1 -1
|
@@ -30,6 +30,7 @@ const FLAGS_WITH_VALUE = [
|
|
|
30
30
|
'--at',
|
|
31
31
|
'--out',
|
|
32
32
|
'--day',
|
|
33
|
+
'--edits',
|
|
33
34
|
'--from',
|
|
34
35
|
'--to',
|
|
35
36
|
'--state',
|
|
@@ -124,16 +125,24 @@ const countByKind = (events) => {
|
|
|
124
125
|
}
|
|
125
126
|
return [...counts].sort((left, right) => right[1] - left[1]);
|
|
126
127
|
};
|
|
128
|
+
const receivedByMachine = (received) => {
|
|
129
|
+
var _a;
|
|
130
|
+
const byMachine = new Map();
|
|
131
|
+
for (const { machineName, event } of received)
|
|
132
|
+
byMachine.set(machineName, [...((_a = byMachine.get(machineName)) !== null && _a !== void 0 ? _a : []), event]);
|
|
133
|
+
return byMachine;
|
|
134
|
+
};
|
|
127
135
|
const describeRule = (rule) => {
|
|
128
136
|
var _a, _b;
|
|
129
137
|
const where = rule.appId
|
|
130
138
|
? `app ${rule.appId}`
|
|
131
139
|
: `${(_a = rule.repoPath) !== null && _a !== void 0 ? _a : 'nowhere'}${rule.branch ? ` @ ${rule.branch}` : ''}`;
|
|
140
|
+
const scoped = rule.day ? `${where} on ${rule.day}` : where;
|
|
132
141
|
if (rule.donates)
|
|
133
|
-
return `${
|
|
142
|
+
return `${scoped} → donate`;
|
|
134
143
|
if (rule.standInId)
|
|
135
|
-
return `${
|
|
136
|
-
return `${
|
|
144
|
+
return `${scoped} → stand-in ${rule.standInId}`;
|
|
145
|
+
return `${scoped} → ${(_b = rule.issueKey) !== null && _b !== void 0 ? _b : 'no issue'}`;
|
|
137
146
|
};
|
|
138
147
|
const DAY_MS = 24 * 60 * 60000;
|
|
139
148
|
/**
|
|
@@ -195,6 +204,14 @@ const describeStandIn = (options) => {
|
|
|
195
204
|
];
|
|
196
205
|
return `${standIn.name}${project} ${days}d old, ${standIn.days.length} day(s) of work${lines.join('')}`;
|
|
197
206
|
};
|
|
207
|
+
const DEFAULT_STALE_DAYS = 30;
|
|
208
|
+
const staleDaysOf = (argv) => {
|
|
209
|
+
const at = argv.indexOf('--stale');
|
|
210
|
+
if (at === -1)
|
|
211
|
+
return undefined;
|
|
212
|
+
const next = Number(argv[at + 1]);
|
|
213
|
+
return Number.isFinite(next) && next >= 0 && argv[at + 1] !== '' ? next : DEFAULT_STALE_DAYS;
|
|
214
|
+
};
|
|
198
215
|
const HOUR_MS = 60 * 60000;
|
|
199
216
|
const hours = (ms) => `${(ms / HOUR_MS).toFixed(1)}h`;
|
|
200
217
|
const DECLINE_LINES = {
|
|
@@ -225,7 +242,9 @@ const rowLine = (row) => {
|
|
|
225
242
|
row.state,
|
|
226
243
|
...(row.edited ? ['edited'] : []),
|
|
227
244
|
...(row.hidden ? ['hidden'] : []),
|
|
245
|
+
...(row.unattended ? ['unattended'] : []),
|
|
228
246
|
(_c = row.laneKey) !== null && _c !== void 0 ? _c : 'no lane',
|
|
247
|
+
...(row.presence ? [`desk ${row.presence.deskEvents}`, `prompts ${row.presence.humanPrompts}`] : []),
|
|
229
248
|
...(((_d = row.autoModeSubject) === null || _d === void 0 ? void 0 : _d.kind) === 'context' ? [`context ${row.autoModeSubject.contextId}`] : []),
|
|
230
249
|
].join(' ');
|
|
231
250
|
};
|
|
@@ -343,42 +362,109 @@ const namedEdits = (argv) => {
|
|
|
343
362
|
];
|
|
344
363
|
};
|
|
345
364
|
/**
|
|
346
|
-
* The one edit
|
|
365
|
+
* The one edit a change record states, or a refusal naming what it said instead. `prefix` is how the
|
|
366
|
+
* caller spells a name: `--` for flags, empty for a key of an edits file.
|
|
347
367
|
*
|
|
348
|
-
* One
|
|
349
|
-
*
|
|
368
|
+
* One change per row edit, deliberately. A caller that means two changes to one row says so twice, and
|
|
369
|
+
* a combination nobody meant can then never be read as a third thing.
|
|
350
370
|
*/
|
|
351
|
-
const
|
|
352
|
-
const {
|
|
353
|
-
const from
|
|
354
|
-
const to = flagValue(argv, '--to');
|
|
355
|
-
const issueKey = flagValue(argv, '--issue');
|
|
356
|
-
const description = flagValue(argv, '--description');
|
|
357
|
-
const state = flagValue(argv, '--state');
|
|
358
|
-
const named = namedEdits(argv);
|
|
359
|
-
if (named.length > 1) {
|
|
360
|
-
throw new Error(`One edit per call, and these name ${named.length}: ${named.join(', ')}. Run the command once for each.`);
|
|
361
|
-
}
|
|
371
|
+
const rowEditOf = (options) => {
|
|
372
|
+
const { change, rowId, prefix } = options;
|
|
373
|
+
const { from, to, issue, description, state } = change;
|
|
362
374
|
if (from && to)
|
|
363
|
-
return {
|
|
375
|
+
return {
|
|
376
|
+
kind: 'range',
|
|
377
|
+
rowId,
|
|
378
|
+
fromMs: instantOf(`${prefix}from`, from),
|
|
379
|
+
toMs: instantOf(`${prefix}to`, to),
|
|
380
|
+
};
|
|
364
381
|
if (from || to)
|
|
365
|
-
throw new Error(
|
|
366
|
-
if (
|
|
367
|
-
return { kind: 'issue', rowId, issueKey:
|
|
382
|
+
throw new Error(`Moving a row takes both ${prefix}from and ${prefix}to.`);
|
|
383
|
+
if (issue)
|
|
384
|
+
return { kind: 'issue', rowId, issueKey: issue.toUpperCase() };
|
|
368
385
|
if (description !== undefined)
|
|
369
386
|
return { kind: 'description', rowId, description };
|
|
370
387
|
if (state) {
|
|
371
388
|
if (state !== 'accepted' && state !== 'rejected')
|
|
372
|
-
throw new Error(
|
|
389
|
+
throw new Error(`${prefix}state takes accepted or rejected, not ${state}.`);
|
|
373
390
|
return { kind: 'state', rowId, state };
|
|
374
391
|
}
|
|
375
|
-
if (
|
|
392
|
+
if (change.hide)
|
|
376
393
|
return { kind: 'hidden', rowId, hidden: true };
|
|
377
|
-
if (
|
|
394
|
+
if (change.show)
|
|
378
395
|
return { kind: 'hidden', rowId, hidden: false };
|
|
379
|
-
if (
|
|
396
|
+
if (change.reset)
|
|
380
397
|
return { kind: 'reset', rowId };
|
|
381
|
-
throw new Error(
|
|
398
|
+
throw new Error(`Pass one of ${prefix}from with ${prefix}to, ${prefix}issue, ${prefix}description, ${prefix}state, ${prefix}hide, ${prefix}show or ${prefix}reset.`);
|
|
399
|
+
};
|
|
400
|
+
/** The one edit the flags state, or a refusal naming what they said instead. */
|
|
401
|
+
const editOf = (options) => {
|
|
402
|
+
const { argv, rowId } = options;
|
|
403
|
+
const named = namedEdits(argv);
|
|
404
|
+
if (named.length > 1) {
|
|
405
|
+
throw new Error(`One edit per call, and these name ${named.length}: ${named.join(', ')}. Run the command once for each.`);
|
|
406
|
+
}
|
|
407
|
+
return rowEditOf({
|
|
408
|
+
rowId,
|
|
409
|
+
prefix: '--',
|
|
410
|
+
change: {
|
|
411
|
+
from: flagValue(argv, '--from'),
|
|
412
|
+
to: flagValue(argv, '--to'),
|
|
413
|
+
issue: flagValue(argv, '--issue'),
|
|
414
|
+
description: flagValue(argv, '--description'),
|
|
415
|
+
state: flagValue(argv, '--state'),
|
|
416
|
+
hide: argv.includes('--hide'),
|
|
417
|
+
show: argv.includes('--show'),
|
|
418
|
+
reset: argv.includes('--reset'),
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
const CHANGE_KEYS = ['from', 'to', 'issue', 'description', 'state', 'hide', 'show', 'reset'];
|
|
423
|
+
const FLAG_ONLY_VALUE_KEYS = ['hide', 'show', 'reset'];
|
|
424
|
+
/** The row edits of an `--edits` file, or a refusal naming the first entry that is not one. Nothing is queued on a refusal. */
|
|
425
|
+
const editsOfFile = (options) => {
|
|
426
|
+
const { root, path } = options;
|
|
427
|
+
let parsed;
|
|
428
|
+
try {
|
|
429
|
+
parsed = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(root, path), 'utf8'));
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
throw Object.assign(new Error(`--edits ${path} is not a readable JSON file: ${error instanceof Error ? error.message : error}`), { cause: error });
|
|
433
|
+
}
|
|
434
|
+
if (!Array.isArray(parsed))
|
|
435
|
+
throw new Error(`--edits ${path} holds a JSON array of edits.`);
|
|
436
|
+
if (parsed.length === 0)
|
|
437
|
+
throw new Error(`--edits ${path} holds no edits.`);
|
|
438
|
+
return parsed.map((entry, index) => {
|
|
439
|
+
const fail = (problem) => {
|
|
440
|
+
throw new Error(`Edit ${index} in ${path}: ${problem}`);
|
|
441
|
+
};
|
|
442
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry))
|
|
443
|
+
return fail('not an object.');
|
|
444
|
+
const record = entry;
|
|
445
|
+
const { row } = record;
|
|
446
|
+
const unknown = Object.keys(record).filter((key) => key !== 'row' && !CHANGE_KEYS.includes(key));
|
|
447
|
+
if (typeof row !== 'string' || !row)
|
|
448
|
+
return fail('"row" must be the row id as `timetrack rows` prints it.');
|
|
449
|
+
if (unknown.length)
|
|
450
|
+
return fail(`unknown key ${unknown.join(', ')}.`);
|
|
451
|
+
const present = Object.keys(record).filter((key) => key !== 'row');
|
|
452
|
+
const named = present.includes('from') || present.includes('to') ? ['from/to'] : [];
|
|
453
|
+
const all = [...named, ...present.filter((key) => key !== 'from' && key !== 'to')];
|
|
454
|
+
if (all.length > 1)
|
|
455
|
+
return fail(`one change per edit, and this names ${all.length}: ${all.join(', ')}.`);
|
|
456
|
+
for (const key of present) {
|
|
457
|
+
const value = record[key];
|
|
458
|
+
if (FLAG_ONLY_VALUE_KEYS.includes(key) ? value !== true : typeof value !== 'string')
|
|
459
|
+
return fail(`${key} takes ${FLAG_ONLY_VALUE_KEYS.includes(key) ? 'true' : 'a string'}.`);
|
|
460
|
+
}
|
|
461
|
+
try {
|
|
462
|
+
return rowEditOf({ rowId: row, prefix: '', change: record });
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
return fail(error instanceof Error ? error.message : String(error));
|
|
466
|
+
}
|
|
467
|
+
});
|
|
382
468
|
};
|
|
383
469
|
/**
|
|
384
470
|
* Writes an export nobody but its owner can read.
|
|
@@ -429,7 +515,19 @@ const UNDECIDED = {
|
|
|
429
515
|
rejected: 'the user rejected it. Nothing was written.',
|
|
430
516
|
expired: 'expired at the end of the day it was asked on. Nothing was written. Ask again.',
|
|
431
517
|
};
|
|
518
|
+
const waitingDetailLines = (item) => {
|
|
519
|
+
var _a;
|
|
520
|
+
return [
|
|
521
|
+
` ${item.op} ${item.summary}`,
|
|
522
|
+
...(item.day ? [` day: ${item.day}`] : []),
|
|
523
|
+
...(((_a = item.rowIds) === null || _a === void 0 ? void 0 : _a.length) ? [` rows: ${item.rowIds.join(', ')}`] : []),
|
|
524
|
+
...(item.issueKey ? [` issue: ${item.issueKey}`] : []),
|
|
525
|
+
];
|
|
526
|
+
};
|
|
432
527
|
const approvalLines = (found) => {
|
|
528
|
+
if (found.status === 'queued' && found.request) {
|
|
529
|
+
return [`${found.approvalId} ${UNDECIDED.queued}`, ...waitingDetailLines(found.request)];
|
|
530
|
+
}
|
|
433
531
|
if (found.status !== 'approved')
|
|
434
532
|
return [`${found.approvalId} ${UNDECIDED[found.status]}`];
|
|
435
533
|
if (found.error !== undefined)
|
|
@@ -453,8 +551,8 @@ const waitingLines = (waiting) => {
|
|
|
453
551
|
return [
|
|
454
552
|
`${waiting.length} wait(s) for the user's approval in Timetrack. Only the user approves one, in the app.`,
|
|
455
553
|
...waiting.map((item) => {
|
|
456
|
-
var _a;
|
|
457
|
-
return ` ${item.approvalId} ${(_a = item.client) !== null && _a !== void 0 ? _a : 'CLI'} ${item.op} asked ${askedAtOf(item.askedAtMs)} ${item.summary}${item.state === 'running' ? ' (approved, carrying it out)' : ''}`;
|
|
554
|
+
var _a, _b;
|
|
555
|
+
return ` ${item.approvalId} ${(_a = item.client) !== null && _a !== void 0 ? _a : 'CLI'} ${item.op} asked ${askedAtOf(item.askedAtMs)}${item.day ? ` day ${item.day}` : ''}${((_b = item.rowIds) === null || _b === void 0 ? void 0 : _b.length) ? ` rows ${item.rowIds.join(',')}` : ''} ${item.summary}${item.state === 'running' ? ' (approved, carrying it out)' : ''}`;
|
|
458
556
|
}),
|
|
459
557
|
];
|
|
460
558
|
};
|
|
@@ -471,6 +569,41 @@ const approvalExitCode = (found) => {
|
|
|
471
569
|
return 1;
|
|
472
570
|
return isSyncWithRun(found.result) && (found.result.run.retryCount || found.result.run.unrecorded) ? 1 : 0;
|
|
473
571
|
};
|
|
572
|
+
/**
|
|
573
|
+
* Lists the attribution rules that name `--from`, and with `--force` queues pointing them at `--to`.
|
|
574
|
+
* The plan reads the rules the app holds now, so it works against an app that predates the write.
|
|
575
|
+
*/
|
|
576
|
+
const repointRules = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
577
|
+
var _a, _b;
|
|
578
|
+
const { root, argv, json } = options;
|
|
579
|
+
const from = (_a = flagValue(argv, '--from')) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
580
|
+
const to = (_b = flagValue(argv, '--to')) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
581
|
+
const repo = flagValue(argv, '--repo');
|
|
582
|
+
const repoPath = repo === undefined ? undefined : (0, path_1.resolve)(root, repo);
|
|
583
|
+
if (!from || !to) {
|
|
584
|
+
say('Pass --from <KEY> and --to <KEY>.');
|
|
585
|
+
return 1;
|
|
586
|
+
}
|
|
587
|
+
if (from === to) {
|
|
588
|
+
say(`--from and --to both name ${from}.`);
|
|
589
|
+
return 1;
|
|
590
|
+
}
|
|
591
|
+
const matching = (yield (0, timetrack_1.timetrackRules)()).attributionRules.filter((rule) => rule.issueKey === from && (repoPath === undefined || rule.repoPath === repoPath));
|
|
592
|
+
if (!matching.length) {
|
|
593
|
+
say(`No attribution rule names ${from}${repoPath ? ` in ${repoPath}` : ''}.`);
|
|
594
|
+
return 1;
|
|
595
|
+
}
|
|
596
|
+
if (!argv.includes('--force')) {
|
|
597
|
+
if (!json) {
|
|
598
|
+
say(`${matching.length} rule(s) name ${from}${repoPath ? ` in ${repoPath}` : ''}`);
|
|
599
|
+
matching.forEach((rule) => say(` ${describeRule(rule)}`));
|
|
600
|
+
say(`Would point them at ${to}. Pass --force to queue it.`);
|
|
601
|
+
}
|
|
602
|
+
return printed(Object.assign(Object.assign({ from, to }, (repoPath ? { repoPath } : {})), { rules: matching }), json);
|
|
603
|
+
}
|
|
604
|
+
const queued = yield (0, timetrack_1.timetrackRepointRules)(Object.assign({ from, to }, (repoPath ? { repoPath } : {})));
|
|
605
|
+
return printedQueued({ queued, what: `pointing ${matching.length} rule(s) from ${from} at ${to}`, json });
|
|
606
|
+
});
|
|
474
607
|
/**
|
|
475
608
|
* Cuts a placeholder that covered a whole checkout into one per directory its commits worked in.
|
|
476
609
|
*
|
|
@@ -573,16 +706,25 @@ A waiting write can be rejected from here; only the user approves one, in the ap
|
|
|
573
706
|
timetrack log --issue <KEY> --minutes <n>
|
|
574
707
|
Add a row nothing observed to the day it belongs to
|
|
575
708
|
timetrack day [YYYY-MM-DD] The evidence a day holds, which the encrypted store hides otherwise
|
|
709
|
+
(only this machine's; --received adds what paired machines sent)
|
|
576
710
|
timetrack transcript [YYYY-MM-DD]
|
|
577
711
|
What the app transcribed of your own microphone during the day's calls
|
|
578
712
|
timetrack rows [YYYY-MM-DD] The rows the day drew, with the ids an edit names them by
|
|
713
|
+
timetrack rows <D> --json > f Export a day; on another machine, rows <D> --compare f prints each
|
|
714
|
+
differing row (paths and order normalised) and exits 1 on any
|
|
579
715
|
timetrack snapshot [from] [to] [--out <file>]
|
|
580
716
|
Record the rows of the last 7 days (default) before a change
|
|
581
717
|
timetrack snapshot --compare <file>
|
|
582
718
|
Print every row the change altered since; exit 1 when any did
|
|
583
719
|
timetrack edit <row-id> … Change one row of a day: its times, its name, its note or its state
|
|
720
|
+
timetrack edit --day <D> --edits <file.json>
|
|
721
|
+
Many row edits of one day as one approval
|
|
584
722
|
timetrack rules The rules that name a day's work: attribution, project links, apps
|
|
723
|
+
timetrack rules --repoint --from <KEY> --to <KEY> [--repo <dir>] [--force]
|
|
724
|
+
List the attribution rules naming one issue; --force queues pointing
|
|
725
|
+
them at another
|
|
585
726
|
timetrack standins The names the user gave work Jira does not hold yet, and their age
|
|
727
|
+
timetrack standins --stale [days] Only open ones with no days of work, older than days (default 30)
|
|
586
728
|
timetrack standins --remove <id>
|
|
587
729
|
Delete one placeholder, and the rule that named it
|
|
588
730
|
timetrack standins --rename <id> --name <text>
|
|
@@ -645,8 +787,10 @@ Options for sync
|
|
|
645
787
|
approval when the plan changed since
|
|
646
788
|
--plan <hash> The plan hash the read printed, for the rows the user confirmed
|
|
647
789
|
|
|
648
|
-
Options for edit — pass exactly one change
|
|
790
|
+
Options for edit — pass exactly one change, or --edits
|
|
649
791
|
--day <YYYY-MM-DD> The day the row is on (default: today)
|
|
792
|
+
--edits <file.json> A JSON array of { "row": <id>, <one change> }, the changes named as below
|
|
793
|
+
without the dashes ("hide": true). Takes no row id and no change flag
|
|
650
794
|
--from <date> --to <date>
|
|
651
795
|
Move the row, or drag one of its ends
|
|
652
796
|
--issue <KEY> Name the row
|
|
@@ -667,7 +811,7 @@ Options everywhere
|
|
|
667
811
|
* one per checkout.
|
|
668
812
|
*/
|
|
669
813
|
const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
670
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
814
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
671
815
|
const { root, argv } = options;
|
|
672
816
|
const [subcommand, value] = positionalArgs(argv);
|
|
673
817
|
const json = argv.includes('--json');
|
|
@@ -766,7 +910,7 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
766
910
|
const day = value !== null && value !== void 0 ? value : today();
|
|
767
911
|
if (!DAY.test(day))
|
|
768
912
|
throw new Error(`Pass a day as YYYY-MM-DD, not ${day}.`);
|
|
769
|
-
const found = yield (0, timetrack_1.timetrackDayEvents)(day);
|
|
913
|
+
const found = yield (0, timetrack_1.timetrackDayEvents)(day, { received: argv.includes('--received') });
|
|
770
914
|
const outFlag = flagValue(argv, '--out');
|
|
771
915
|
if (outFlag) {
|
|
772
916
|
const out = (0, path_1.resolve)(root, outFlag);
|
|
@@ -780,6 +924,10 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
780
924
|
if (!json) {
|
|
781
925
|
say(`${found.day} ${found.events.length} events`);
|
|
782
926
|
countByKind(found.events).forEach(([kind, count]) => say(` ${kind} ${count}`));
|
|
927
|
+
for (const [machine, events] of receivedByMachine((_a = found.received) !== null && _a !== void 0 ? _a : [])) {
|
|
928
|
+
say(`received from ${machine} ${events.length} events`);
|
|
929
|
+
countByKind(events).forEach(([kind, count]) => say(` ${kind} ${count}`));
|
|
930
|
+
}
|
|
783
931
|
say('Pass --out <path> to write the events themselves, which are far too many to read.');
|
|
784
932
|
}
|
|
785
933
|
return printed(found, json);
|
|
@@ -799,7 +947,30 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
799
947
|
const day = value !== null && value !== void 0 ? value : today();
|
|
800
948
|
if (!DAY.test(day))
|
|
801
949
|
throw new Error(`Pass a day as YYYY-MM-DD, not ${day}.`);
|
|
950
|
+
const compare = flagValue(argv, '--compare');
|
|
802
951
|
const found = yield (0, timetrack_1.timetrackDayRows)(day);
|
|
952
|
+
if (compare) {
|
|
953
|
+
const recorded = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(root, compare), 'utf8'));
|
|
954
|
+
if (!Array.isArray(recorded.rows) || typeof recorded.day !== 'string')
|
|
955
|
+
throw new Error(`${compare} is not the output of timetrack rows <day> --json.`);
|
|
956
|
+
if (value && recorded.day !== day)
|
|
957
|
+
throw new Error(`${compare} holds ${recorded.day}, not ${day}.`);
|
|
958
|
+
const theirs = (0, timetrack_snapshot_1.snapshotDayOf)(Object.assign(Object.assign({ loggedMs: 0, proposedMs: 0, hidden: [] }, recorded), { rows: recorded.rows, day: recorded.day }));
|
|
959
|
+
const diff = (0, timetrack_snapshot_1.diffDayRows)(recorded.checkoutKeys
|
|
960
|
+
? (0, timetrack_snapshot_1.translateSnapshotDay)({
|
|
961
|
+
day: theirs,
|
|
962
|
+
peerKeys: recorded.checkoutKeys,
|
|
963
|
+
localKeys: (_b = found.checkoutKeys) !== null && _b !== void 0 ? _b : {},
|
|
964
|
+
})
|
|
965
|
+
: theirs, (0, timetrack_snapshot_1.snapshotDayOf)(found));
|
|
966
|
+
if (json)
|
|
967
|
+
console.log(JSON.stringify(diff, null, 2));
|
|
968
|
+
else if (diff.changedRows || diff.days.length)
|
|
969
|
+
(0, timetrack_snapshot_1.diffLines)(diff).forEach((line) => say(line));
|
|
970
|
+
else
|
|
971
|
+
say(`${found.day} the same ${found.rows.length + found.hidden.length} row(s) as ${compare}`);
|
|
972
|
+
return diff.changedRows || diff.days.length ? 1 : 0;
|
|
973
|
+
}
|
|
803
974
|
if (!json) {
|
|
804
975
|
say(`${found.day} ${hours(found.loggedMs)} logged of a ${hours(found.targetMs)} target`);
|
|
805
976
|
found.rows.forEach((row) => say(` ${rowLine(row)}`));
|
|
@@ -809,6 +980,10 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
809
980
|
return printed(found, json);
|
|
810
981
|
}
|
|
811
982
|
if (subcommand === 'snapshot') {
|
|
983
|
+
if (argv.includes('--help')) {
|
|
984
|
+
say(USAGE);
|
|
985
|
+
return 0;
|
|
986
|
+
}
|
|
812
987
|
const compare = flagValue(argv, '--compare');
|
|
813
988
|
if (compare) {
|
|
814
989
|
const recorded = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(root, compare), 'utf8'));
|
|
@@ -821,13 +996,13 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
821
996
|
return diff.changedRows || diff.days.length ? 1 : 0;
|
|
822
997
|
}
|
|
823
998
|
const named = positionalArgs(argv).slice(1);
|
|
824
|
-
const to = (
|
|
825
|
-
const from = (
|
|
999
|
+
const to = (_c = named[1]) !== null && _c !== void 0 ? _c : today();
|
|
1000
|
+
const from = (_d = named[0]) !== null && _d !== void 0 ? _d : shiftDay(to, -6);
|
|
826
1001
|
if (!DAY.test(from))
|
|
827
1002
|
throw new Error(`Pass a day as YYYY-MM-DD, not ${from}.`);
|
|
828
1003
|
if (!DAY.test(to))
|
|
829
1004
|
throw new Error(`Pass a day as YYYY-MM-DD, not ${to}.`);
|
|
830
|
-
const path = (0, path_1.resolve)(root, (
|
|
1005
|
+
const path = (0, path_1.resolve)(root, (_e = flagValue(argv, '--out')) !== null && _e !== void 0 ? _e : defaultSnapshotPath());
|
|
831
1006
|
const recorded = yield takeSnapshot({ days: daysBetween(from, to), root });
|
|
832
1007
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(path), { recursive: true });
|
|
833
1008
|
(0, fs_1.writeFileSync)(path, JSON.stringify(recorded, null, 2), { mode: 0o600 });
|
|
@@ -838,15 +1013,28 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
838
1013
|
return 0;
|
|
839
1014
|
}
|
|
840
1015
|
if (subcommand === 'edit') {
|
|
841
|
-
const day = (
|
|
842
|
-
|
|
843
|
-
throw new Error('Pass the row id to edit, as `timetrack rows` prints it.');
|
|
1016
|
+
const day = (_f = flagValue(argv, '--day')) !== null && _f !== void 0 ? _f : today();
|
|
1017
|
+
const editsPath = flagValue(argv, '--edits');
|
|
844
1018
|
if (!DAY.test(day))
|
|
845
1019
|
throw new Error(`Pass a day as YYYY-MM-DD, not ${day}.`);
|
|
1020
|
+
if (editsPath !== undefined) {
|
|
1021
|
+
if (value)
|
|
1022
|
+
throw new Error('--edits names the rows itself: pass no row id with it.');
|
|
1023
|
+
const named = namedEdits(argv);
|
|
1024
|
+
if (named.length)
|
|
1025
|
+
throw new Error(`--edits takes the changes from its file, not from ${named.join(', ')}.`);
|
|
1026
|
+
const edits = editsOfFile({ root, path: editsPath });
|
|
1027
|
+
const queued = yield (0, timetrack_1.timetrackEditDay)({ day, edits });
|
|
1028
|
+
return printedQueued({ queued, what: `${edits.length} edits of rows on ${day}`, json });
|
|
1029
|
+
}
|
|
1030
|
+
if (!value)
|
|
1031
|
+
throw new Error('Pass the row id to edit, as `timetrack rows` prints it, or --edits <file.json>.');
|
|
846
1032
|
const queued = yield (0, timetrack_1.timetrackEditDay)({ day, edits: [editOf({ argv, rowId: value })] });
|
|
847
1033
|
return printedQueued({ queued, what: `an edit of row ${value} on ${day}`, json });
|
|
848
1034
|
}
|
|
849
1035
|
if (subcommand === 'rules') {
|
|
1036
|
+
if (argv.includes('--repoint'))
|
|
1037
|
+
return yield repointRules({ root, argv, json });
|
|
850
1038
|
const rules = yield (0, timetrack_1.timetrackRules)();
|
|
851
1039
|
if (!json) {
|
|
852
1040
|
say(`target ${Math.round(rules.dayTargetMs / 60000)}m day starts at ${rules.dayStartHour}:00`);
|
|
@@ -866,7 +1054,7 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
866
1054
|
return printedQueued({ queued, what: `read the agent sessions of ${paths.join(', ')} again${how}`, json });
|
|
867
1055
|
}
|
|
868
1056
|
if (subcommand === 'worklogs') {
|
|
869
|
-
const to = (
|
|
1057
|
+
const to = (_g = positionalArgs(argv)[2]) !== null && _g !== void 0 ? _g : today();
|
|
870
1058
|
const from = value !== null && value !== void 0 ? value : shiftDay(to, -6);
|
|
871
1059
|
if (!DAY.test(from))
|
|
872
1060
|
throw new Error(`Pass a day as YYYY-MM-DD, not ${from}.`);
|
|
@@ -924,7 +1112,7 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
924
1112
|
return printed(found, json);
|
|
925
1113
|
}
|
|
926
1114
|
if (subcommand === 'calendar') {
|
|
927
|
-
const to = (
|
|
1115
|
+
const to = (_h = positionalArgs(argv)[2]) !== null && _h !== void 0 ? _h : today();
|
|
928
1116
|
const from = value !== null && value !== void 0 ? value : shiftDay(to, -6);
|
|
929
1117
|
if (!DAY.test(from))
|
|
930
1118
|
throw new Error(`Pass a day as YYYY-MM-DD, not ${from}.`);
|
|
@@ -951,13 +1139,19 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
951
1139
|
naming.offers.forEach((offer) => say(` ${offer.repoPath} → ${offer.issueKey} ${hours(offer.loggedMs)}, ${Math.round(offer.share * 100)}%, ${offer.days}d`));
|
|
952
1140
|
say(`Not offered (${naming.declines.length})`);
|
|
953
1141
|
naming.declines.forEach((decline) => say(` ${describeDecline(decline)}`));
|
|
1142
|
+
const verdicts = (_j = naming.standInVerdicts) !== null && _j !== void 0 ? _j : [];
|
|
1143
|
+
say(`Stand-in verdicts (${verdicts.length})`);
|
|
1144
|
+
verdicts.forEach((entry) => {
|
|
1145
|
+
var _a;
|
|
1146
|
+
return say(` ${[(_a = entry.repoPath) !== null && _a !== void 0 ? _a : entry.appId, entry.branch, entry.verdict].join(' ')} ${hours(entry.observedMs)}${entry.drawnMs === undefined ? '' : `, drawn ${hours(entry.drawnMs)}`}`);
|
|
1147
|
+
});
|
|
954
1148
|
}
|
|
955
1149
|
return printed(naming, json);
|
|
956
1150
|
}
|
|
957
1151
|
if (subcommand === 'ask') {
|
|
958
1152
|
const standInId = flagValue(argv, '--stand-in');
|
|
959
1153
|
const contextId = flagValue(argv, '--context');
|
|
960
|
-
const day = (
|
|
1154
|
+
const day = (_k = flagValue(argv, '--day')) !== null && _k !== void 0 ? _k : today();
|
|
961
1155
|
const subject = standInId
|
|
962
1156
|
? { kind: 'stand-in', standInId }
|
|
963
1157
|
: contextId
|
|
@@ -1045,11 +1239,16 @@ const timetrackCommand = (options) => __awaiter(void 0, void 0, void 0, function
|
|
|
1045
1239
|
}
|
|
1046
1240
|
const standIns = yield (0, timetrack_1.timetrackStandIns)();
|
|
1047
1241
|
const rules = json ? [] : (yield (0, timetrack_1.timetrackRules)()).attributionRules;
|
|
1242
|
+
const staleDays = staleDaysOf(argv);
|
|
1048
1243
|
const open = standIns
|
|
1049
1244
|
.filter((standIn) => standIn.state === 'open')
|
|
1245
|
+
.filter((standIn) => staleDays === undefined ||
|
|
1246
|
+
(standIn.days.length === 0 && Date.now() - standIn.createdAtMs > staleDays * DAY_MS))
|
|
1050
1247
|
.sort((left, right) => left.createdAtMs - right.createdAtMs);
|
|
1051
1248
|
if (!json) {
|
|
1052
|
-
say(
|
|
1249
|
+
say(staleDays === undefined
|
|
1250
|
+
? `${open.length} open, ${standIns.length - open.length} resolved`
|
|
1251
|
+
: `${open.length} stale (no days of work, older than ${staleDays} days)`);
|
|
1053
1252
|
open.forEach((standIn) => say(` ${describeStandIn({ standIn, rules })}`));
|
|
1054
1253
|
if (open.length)
|
|
1055
1254
|
say('Only the app opens or resolves one — you may delete one, not write one.');
|