agenthud 0.8.2 → 0.8.3
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/dist/index.js
CHANGED
|
@@ -68,25 +68,21 @@ function getVersion() {
|
|
|
68
68
|
function clearScreen() {
|
|
69
69
|
console.clear();
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function parseLocalMidnight(dateStr) {
|
|
72
72
|
if (dateStr === "today") {
|
|
73
73
|
const now = /* @__PURE__ */ new Date();
|
|
74
|
-
return new Date(
|
|
75
|
-
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
|
|
76
|
-
);
|
|
74
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
77
75
|
}
|
|
78
76
|
const match = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
79
77
|
if (!match) return null;
|
|
80
78
|
const [, y, m, d] = match.map(Number);
|
|
81
|
-
const date = new Date(
|
|
79
|
+
const date = new Date(y, m - 1, d);
|
|
82
80
|
if (Number.isNaN(date.getTime())) return null;
|
|
83
81
|
return date;
|
|
84
82
|
}
|
|
85
|
-
function
|
|
83
|
+
function todayLocalMidnight() {
|
|
86
84
|
const now = /* @__PURE__ */ new Date();
|
|
87
|
-
return new Date(
|
|
88
|
-
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
|
|
89
|
-
);
|
|
85
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
90
86
|
}
|
|
91
87
|
function parseArgs(args) {
|
|
92
88
|
if (args.includes("--help") || args.includes("-h")) {
|
|
@@ -100,7 +96,7 @@ function parseArgs(args) {
|
|
|
100
96
|
}
|
|
101
97
|
if (args[0] === "report") {
|
|
102
98
|
const rest = args.slice(1);
|
|
103
|
-
let reportDate =
|
|
99
|
+
let reportDate = todayLocalMidnight();
|
|
104
100
|
let reportInclude = DEFAULT_TYPES;
|
|
105
101
|
let reportError;
|
|
106
102
|
for (const arg of rest) {
|
|
@@ -115,7 +111,7 @@ function parseArgs(args) {
|
|
|
115
111
|
if (!dateStr) {
|
|
116
112
|
reportError = "Invalid date: missing value for --date";
|
|
117
113
|
} else {
|
|
118
|
-
const parsed =
|
|
114
|
+
const parsed = parseLocalMidnight(dateStr);
|
|
119
115
|
if (!parsed) {
|
|
120
116
|
reportError = `Invalid date: "${dateStr}". Use YYYY-MM-DD or "today".`;
|
|
121
117
|
} else {
|
|
@@ -430,11 +426,11 @@ function activityMatchesInclude(activity, include) {
|
|
|
430
426
|
return true;
|
|
431
427
|
return false;
|
|
432
428
|
}
|
|
433
|
-
function
|
|
434
|
-
return a.
|
|
429
|
+
function isSameLocalDay(a, b) {
|
|
430
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
435
431
|
}
|
|
436
432
|
function formatTime(date) {
|
|
437
|
-
return `${String(date.
|
|
433
|
+
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
438
434
|
}
|
|
439
435
|
function formatActivity(activity) {
|
|
440
436
|
const time = formatTime(activity.timestamp);
|
|
@@ -443,15 +439,15 @@ function formatActivity(activity) {
|
|
|
443
439
|
return `[${time}] ${activity.icon} ${activity.label}${suffix}`;
|
|
444
440
|
}
|
|
445
441
|
function formatDateString(date) {
|
|
446
|
-
return `${date.
|
|
442
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
447
443
|
}
|
|
448
444
|
function sessionIsOnDate(session, date, activities) {
|
|
449
445
|
try {
|
|
450
446
|
const mtime = new Date(statSync(session.filePath).mtimeMs);
|
|
451
|
-
if (
|
|
447
|
+
if (isSameLocalDay(mtime, date)) return true;
|
|
452
448
|
} catch {
|
|
453
449
|
}
|
|
454
|
-
return activities.some((a) =>
|
|
450
|
+
return activities.some((a) => isSameLocalDay(a.timestamp, date));
|
|
455
451
|
}
|
|
456
452
|
function generateReport(sessions, options2) {
|
|
457
453
|
const { date, include, format = "markdown" } = options2;
|
|
@@ -460,7 +456,7 @@ function generateReport(sessions, options2) {
|
|
|
460
456
|
for (const session of sessions) {
|
|
461
457
|
const allActivities = parseSessionHistory(session.filePath);
|
|
462
458
|
if (!sessionIsOnDate(session, date, allActivities)) continue;
|
|
463
|
-
const dayActivities = allActivities.filter((a) =>
|
|
459
|
+
const dayActivities = allActivities.filter((a) => isSameLocalDay(a.timestamp, date)).filter((a) => activityMatchesInclude(a, include));
|
|
464
460
|
if (dayActivities.length === 0) continue;
|
|
465
461
|
blocks.push({
|
|
466
462
|
session,
|
package/package.json
CHANGED