@task-mcp/cli 1.0.12 → 1.0.13
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/package.json +1 -1
- package/src/commands/dashboard.ts +33 -292
- package/src/storage.ts +2 -2
package/package.json
CHANGED
|
@@ -1,261 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dashboard command - displays project overview with unified widgets
|
|
3
|
-
*
|
|
3
|
+
* Uses shared dashboard renderer from @task-mcp/shared
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { VERSION } from "../index.js";
|
|
7
|
+
import { c } from "../ansi.js";
|
|
7
8
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
banner,
|
|
14
|
-
pad,
|
|
15
|
-
truncate,
|
|
16
|
-
stripAnsi,
|
|
17
|
-
sideBySide,
|
|
18
|
-
displayWidth,
|
|
19
|
-
type TableColumn,
|
|
20
|
-
} from "../ansi.js";
|
|
9
|
+
renderGlobalDashboard,
|
|
10
|
+
renderProjectDashboard,
|
|
11
|
+
type Task as SharedTask,
|
|
12
|
+
type Project as SharedProject,
|
|
13
|
+
} from "@task-mcp/shared";
|
|
21
14
|
import {
|
|
22
15
|
listProjects,
|
|
23
16
|
listTasks,
|
|
24
17
|
listAllTasks,
|
|
25
|
-
calculateStats,
|
|
26
|
-
calculateDependencyMetrics,
|
|
27
|
-
suggestNextTask,
|
|
28
|
-
getTodayTasks,
|
|
29
|
-
getOverdueTasks,
|
|
30
18
|
listInboxItems,
|
|
31
19
|
type Task,
|
|
32
20
|
type Project,
|
|
33
21
|
} from "../storage.js";
|
|
34
22
|
|
|
35
|
-
// =============================================================================
|
|
36
|
-
// Formatters
|
|
37
|
-
// =============================================================================
|
|
38
|
-
|
|
39
|
-
function formatPriority(priority: Task["priority"]): string {
|
|
40
|
-
const colors: Record<string, (s: string) => string> = {
|
|
41
|
-
critical: c.red,
|
|
42
|
-
high: c.yellow,
|
|
43
|
-
medium: c.blue,
|
|
44
|
-
low: c.gray,
|
|
45
|
-
};
|
|
46
|
-
return (colors[priority] ?? c.gray)(priority);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// =============================================================================
|
|
50
|
-
// Widget: Unified Status (combines Overview + Schedule + Dependencies)
|
|
51
|
-
// =============================================================================
|
|
52
|
-
|
|
53
|
-
function renderStatusWidget(tasks: Task[], projects: Project[]): string {
|
|
54
|
-
const stats = calculateStats(tasks);
|
|
55
|
-
const depMetrics = calculateDependencyMetrics(tasks);
|
|
56
|
-
const today = getTodayTasks(tasks);
|
|
57
|
-
const overdue = getOverdueTasks(tasks);
|
|
58
|
-
const activeTasks = stats.total - stats.cancelled;
|
|
59
|
-
const percent = activeTasks > 0 ? Math.round((stats.completed / activeTasks) * 100) : 0;
|
|
60
|
-
|
|
61
|
-
const lines: string[] = [];
|
|
62
|
-
|
|
63
|
-
// Progress bar with fraction
|
|
64
|
-
const bar = progressBar(stats.completed, activeTasks, { width: 24 });
|
|
65
|
-
lines.push(`${bar} ${c.bold(`${percent}%`)} ${stats.completed}/${activeTasks} tasks`);
|
|
66
|
-
lines.push("");
|
|
67
|
-
|
|
68
|
-
// Status counts (2 rows)
|
|
69
|
-
lines.push(
|
|
70
|
-
`${c.green("Done")}: ${stats.completed} ` +
|
|
71
|
-
`${c.blue("Progress")}: ${stats.inProgress} ` +
|
|
72
|
-
`${c.yellow("Pending")}: ${stats.pending} ` +
|
|
73
|
-
`${c.red("Blocked")}: ${stats.blocked}`
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// Schedule info
|
|
77
|
-
const scheduleInfo = [];
|
|
78
|
-
if (overdue.length > 0) scheduleInfo.push(c.red(`Overdue: ${overdue.length}`));
|
|
79
|
-
if (today.length > 0) scheduleInfo.push(c.yellow(`Today: ${today.length}`));
|
|
80
|
-
if (scheduleInfo.length > 0) {
|
|
81
|
-
lines.push(scheduleInfo.join(" "));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
lines.push("");
|
|
85
|
-
|
|
86
|
-
// Priority breakdown
|
|
87
|
-
lines.push(
|
|
88
|
-
`${c.red("Critical")}: ${stats.byPriority.critical} ` +
|
|
89
|
-
`${c.yellow("High")}: ${stats.byPriority.high} ` +
|
|
90
|
-
`${c.blue("Medium")}: ${stats.byPriority.medium} ` +
|
|
91
|
-
`${c.gray("Low")}: ${stats.byPriority.low}`
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
// Dependencies summary
|
|
95
|
-
lines.push(
|
|
96
|
-
`${c.green("Ready")}: ${depMetrics.readyToWork} ` +
|
|
97
|
-
`${c.red("Blocked")}: ${depMetrics.blockedByDependencies}` +
|
|
98
|
-
(depMetrics.mostDependedOn
|
|
99
|
-
? ` ${c.dim("Bottleneck:")} ${truncate(depMetrics.mostDependedOn.title, 15)}`
|
|
100
|
-
: "")
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
return box(lines.join("\n"), {
|
|
104
|
-
title: "Status",
|
|
105
|
-
borderColor: "cyan",
|
|
106
|
-
padding: 1,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// =============================================================================
|
|
111
|
-
// Widget: Next Actions (combines Next Task + Inbox)
|
|
112
|
-
// =============================================================================
|
|
113
|
-
|
|
114
|
-
async function renderActionsWidget(tasks: Task[]): Promise<string> {
|
|
115
|
-
const nextTask = suggestNextTask(tasks);
|
|
116
|
-
|
|
117
|
-
const lines: string[] = [];
|
|
118
|
-
|
|
119
|
-
// Next tasks (top 3 suggestions)
|
|
120
|
-
const readyTasks = tasks
|
|
121
|
-
.filter(t => t.status === "pending" && (!t.dependencies || t.dependencies.length === 0))
|
|
122
|
-
.sort((a, b) => {
|
|
123
|
-
const priorityOrder = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
124
|
-
return (priorityOrder[a.priority] ?? 2) - (priorityOrder[b.priority] ?? 2);
|
|
125
|
-
})
|
|
126
|
-
.slice(0, 4);
|
|
127
|
-
|
|
128
|
-
if (readyTasks.length > 0) {
|
|
129
|
-
for (const task of readyTasks) {
|
|
130
|
-
const deps = task.dependencies?.length ?? 0;
|
|
131
|
-
const depsInfo = deps > 0 ? `${deps} deps` : c.green("ready");
|
|
132
|
-
lines.push(`${c.cyan("→")} ${truncate(task.title, 24)}`);
|
|
133
|
-
lines.push(` ${formatPriority(task.priority)}, ${depsInfo}`);
|
|
134
|
-
}
|
|
135
|
-
} else if (nextTask) {
|
|
136
|
-
const deps = nextTask.dependencies?.length ?? 0;
|
|
137
|
-
const depsInfo = deps > 0 ? `${deps} deps` : c.green("ready");
|
|
138
|
-
lines.push(`${c.cyan("→")} ${truncate(nextTask.title, 24)}`);
|
|
139
|
-
lines.push(` ${formatPriority(nextTask.priority)}, ${depsInfo}`);
|
|
140
|
-
} else {
|
|
141
|
-
lines.push(c.dim("No tasks ready"));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return box(lines.join("\n"), {
|
|
145
|
-
title: "Next Actions",
|
|
146
|
-
borderColor: "green",
|
|
147
|
-
padding: 1,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// =============================================================================
|
|
152
|
-
// Widget: Inbox
|
|
153
|
-
// =============================================================================
|
|
154
|
-
|
|
155
|
-
async function renderInboxWidget(): Promise<string | null> {
|
|
156
|
-
const pendingItems = await listInboxItems("pending");
|
|
157
|
-
|
|
158
|
-
if (pendingItems.length === 0) {
|
|
159
|
-
return null; // Don't show if empty
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const lines: string[] = [];
|
|
163
|
-
lines.push(`${c.yellow("Pending")}: ${pendingItems.length} items`);
|
|
164
|
-
lines.push("");
|
|
165
|
-
|
|
166
|
-
// Show up to 3 items
|
|
167
|
-
for (const item of pendingItems.slice(0, 3)) {
|
|
168
|
-
const date = new Date(item.capturedAt);
|
|
169
|
-
const ago = getTimeAgo(date);
|
|
170
|
-
const tags = item.tags?.length ? c.dim(` #${item.tags[0]}`) : "";
|
|
171
|
-
lines.push(`${c.yellow("○")} ${truncate(item.content, 40)}${tags}`);
|
|
172
|
-
lines.push(` ${c.dim(ago)}`);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (pendingItems.length > 3) {
|
|
176
|
-
lines.push(c.gray(`+${pendingItems.length - 3} more`));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return box(lines.join("\n"), {
|
|
180
|
-
title: "Inbox",
|
|
181
|
-
borderColor: "yellow",
|
|
182
|
-
padding: 1,
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function getTimeAgo(date: Date): string {
|
|
187
|
-
const now = new Date();
|
|
188
|
-
const diffMs = now.getTime() - date.getTime();
|
|
189
|
-
const diffMins = Math.floor(diffMs / 60000);
|
|
190
|
-
const diffHours = Math.floor(diffMins / 60);
|
|
191
|
-
const diffDays = Math.floor(diffHours / 24);
|
|
192
|
-
|
|
193
|
-
if (diffMins < 60) return `${diffMins}m ago`;
|
|
194
|
-
if (diffHours < 24) return `${diffHours}h ago`;
|
|
195
|
-
if (diffDays < 7) return `${diffDays}d ago`;
|
|
196
|
-
return date.toLocaleDateString();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// =============================================================================
|
|
200
|
-
// Projects Table
|
|
201
|
-
// =============================================================================
|
|
202
|
-
|
|
203
|
-
async function renderProjectsTable(projects: Project[]): Promise<string> {
|
|
204
|
-
if (projects.length === 0) {
|
|
205
|
-
return c.gray("No projects found.");
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const rows: {
|
|
209
|
-
name: string;
|
|
210
|
-
progress: string;
|
|
211
|
-
ready: number;
|
|
212
|
-
blocked: number;
|
|
213
|
-
total: number;
|
|
214
|
-
}[] = [];
|
|
215
|
-
|
|
216
|
-
for (const project of projects.slice(0, 10)) {
|
|
217
|
-
const tasks = await listTasks(project.id);
|
|
218
|
-
const stats = calculateStats(tasks);
|
|
219
|
-
const depMetrics = calculateDependencyMetrics(tasks);
|
|
220
|
-
const activeTasks = stats.total - stats.cancelled;
|
|
221
|
-
const percent = activeTasks > 0 ? Math.round((stats.completed / activeTasks) * 100) : 0;
|
|
222
|
-
|
|
223
|
-
// Create mini progress bar
|
|
224
|
-
const barWidth = 8;
|
|
225
|
-
const filled = Math.round((percent / 100) * barWidth);
|
|
226
|
-
const empty = barWidth - filled;
|
|
227
|
-
const miniBar = c.green("█".repeat(filled)) + c.gray("░".repeat(empty));
|
|
228
|
-
|
|
229
|
-
rows.push({
|
|
230
|
-
name: truncate(project.name, 20),
|
|
231
|
-
progress: `${miniBar} ${pad(String(percent) + "%", 4, "right")}`,
|
|
232
|
-
ready: depMetrics.readyToWork,
|
|
233
|
-
blocked: depMetrics.blockedByDependencies,
|
|
234
|
-
total: activeTasks,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const columns: TableColumn[] = [
|
|
239
|
-
{ header: "Project", key: "name", width: 22 },
|
|
240
|
-
{ header: "Progress", key: "progress", width: 16 },
|
|
241
|
-
{ header: "Tasks", key: "total", width: 6, align: "right" },
|
|
242
|
-
{ header: "Ready", key: "ready", width: 6, align: "right", format: (v) => c.green(String(v)) },
|
|
243
|
-
{ header: "Blocked", key: "blocked", width: 8, align: "right", format: (v) => Number(v) > 0 ? c.red(String(v)) : c.gray(String(v)) },
|
|
244
|
-
];
|
|
245
|
-
|
|
246
|
-
return table(rows as unknown as Record<string, unknown>[], columns);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
23
|
// =============================================================================
|
|
250
24
|
// Main Dashboard
|
|
251
25
|
// =============================================================================
|
|
252
26
|
|
|
253
27
|
export async function dashboard(projectId?: string): Promise<void> {
|
|
254
|
-
// Print banner
|
|
255
|
-
console.log();
|
|
256
|
-
console.log(banner("TASK MCP"));
|
|
257
|
-
console.log();
|
|
258
|
-
|
|
259
28
|
// Get projects and tasks
|
|
260
29
|
const projects = await listProjects();
|
|
261
30
|
|
|
@@ -283,62 +52,34 @@ export async function dashboard(projectId?: string): Promise<void> {
|
|
|
283
52
|
tasks = await listAllTasks();
|
|
284
53
|
}
|
|
285
54
|
|
|
286
|
-
//
|
|
287
|
-
const
|
|
288
|
-
? `${c.bold("Project:")} ${project.name}`
|
|
289
|
-
: `${c.bold("All Projects")} (${projects.length} projects)`;
|
|
290
|
-
|
|
291
|
-
console.log(c.dim(`v${VERSION} ${projectInfo}`));
|
|
292
|
-
console.log();
|
|
293
|
-
|
|
294
|
-
// Render widgets
|
|
295
|
-
const statusWidget = renderStatusWidget(tasks, projects);
|
|
296
|
-
const actionsWidget = await renderActionsWidget(tasks);
|
|
297
|
-
|
|
298
|
-
// Print widgets side by side
|
|
299
|
-
console.log(sideBySide([statusWidget, actionsWidget], 2));
|
|
300
|
-
console.log();
|
|
55
|
+
// Get inbox items
|
|
56
|
+
const inboxItems = await listInboxItems("pending");
|
|
301
57
|
|
|
302
|
-
//
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
console.log();
|
|
58
|
+
// Create task lookup for projects table
|
|
59
|
+
const tasksByProject = new Map<string, Task[]>();
|
|
60
|
+
for (const p of projects) {
|
|
61
|
+
tasksByProject.set(p.id, await listTasks(p.id));
|
|
307
62
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
{ header: "Title", key: "title", width: 40 },
|
|
328
|
-
{ header: "Status", key: "status", width: 12, format: (v) => {
|
|
329
|
-
const icon = icons[v as Task["status"]] ?? icons.pending;
|
|
330
|
-
return `${icon} ${v}`;
|
|
331
|
-
}},
|
|
332
|
-
{ header: "Priority", key: "priority", width: 10, format: (v) => formatPriority(v as Task["priority"]) },
|
|
333
|
-
];
|
|
334
|
-
|
|
335
|
-
console.log(table(displayTasks as unknown as Record<string, unknown>[], columns));
|
|
336
|
-
|
|
337
|
-
if (activeTasks.length > 10) {
|
|
338
|
-
console.log(c.gray(`\n(+${activeTasks.length - 10} more tasks)`));
|
|
339
|
-
}
|
|
340
|
-
}
|
|
63
|
+
const getProjectTasks = (pid: string) => tasksByProject.get(pid) ?? [];
|
|
64
|
+
|
|
65
|
+
// Render dashboard using shared renderer
|
|
66
|
+
// Cast types - CLI types are compatible subset of shared types
|
|
67
|
+
let output: string;
|
|
68
|
+
if (project) {
|
|
69
|
+
output = renderProjectDashboard(
|
|
70
|
+
project as SharedProject,
|
|
71
|
+
tasks as SharedTask[],
|
|
72
|
+
{ version: VERSION }
|
|
73
|
+
);
|
|
74
|
+
} else {
|
|
75
|
+
output = renderGlobalDashboard(
|
|
76
|
+
projects as SharedProject[],
|
|
77
|
+
tasks as SharedTask[],
|
|
78
|
+
inboxItems,
|
|
79
|
+
(pid) => (getProjectTasks(pid) as SharedTask[]),
|
|
80
|
+
{ version: VERSION }
|
|
81
|
+
);
|
|
341
82
|
}
|
|
342
83
|
|
|
343
|
-
console.log();
|
|
84
|
+
console.log(output);
|
|
344
85
|
}
|
package/src/storage.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface Task {
|
|
|
27
27
|
priority: "critical" | "high" | "medium" | "low";
|
|
28
28
|
projectId: string;
|
|
29
29
|
parentId?: string;
|
|
30
|
-
dependencies?: { taskId: string; type:
|
|
30
|
+
dependencies?: { taskId: string; type: "blocks" | "blocked_by" | "related"; reason?: string }[];
|
|
31
31
|
dueDate?: string;
|
|
32
32
|
createdAt: string;
|
|
33
33
|
updatedAt: string;
|
|
@@ -43,7 +43,7 @@ export interface Project {
|
|
|
43
43
|
name: string;
|
|
44
44
|
description?: string;
|
|
45
45
|
status: "active" | "on_hold" | "completed" | "archived";
|
|
46
|
-
defaultPriority?:
|
|
46
|
+
defaultPriority?: "critical" | "high" | "medium" | "low";
|
|
47
47
|
createdAt: string;
|
|
48
48
|
updatedAt: string;
|
|
49
49
|
targetDate?: string;
|