coherence-cli 0.4.0 → 0.4.1
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/lib/commands/status.mjs +25 -6
- package/package.json +1 -1
package/lib/commands/status.mjs
CHANGED
|
@@ -31,6 +31,19 @@ export async function showStatus() {
|
|
|
31
31
|
const running = taskList(runningData);
|
|
32
32
|
const completed = taskList(completedData);
|
|
33
33
|
|
|
34
|
+
/** Extract a human-readable name from a task */
|
|
35
|
+
function _taskName(t) {
|
|
36
|
+
const ctx = t.context || {};
|
|
37
|
+
if (ctx.idea_name) return ctx.idea_name.slice(0, 45);
|
|
38
|
+
if (t.direction) {
|
|
39
|
+
// Extract the idea name from "Write a spec for: <name>." pattern
|
|
40
|
+
const match = t.direction.match(/for:\s*(.+?)[\.\n]/);
|
|
41
|
+
if (match) return match[1].slice(0, 45);
|
|
42
|
+
return t.direction.slice(0, 45);
|
|
43
|
+
}
|
|
44
|
+
return t.id?.slice(0, 20) || "?";
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
console.log();
|
|
35
48
|
console.log("\x1b[1m COHERENCE NETWORK STATUS\x1b[0m");
|
|
36
49
|
console.log(` ${"─".repeat(50)}`);
|
|
@@ -65,11 +78,18 @@ export async function showStatus() {
|
|
|
65
78
|
if (Array.isArray(nodes) && nodes.length > 0) {
|
|
66
79
|
const now = Date.now();
|
|
67
80
|
const alive = nodes.filter((n) => {
|
|
68
|
-
const last = n.last_heartbeat || n.registered_at || "";
|
|
81
|
+
const last = n.last_seen_at || n.last_heartbeat || n.registered_at || "";
|
|
69
82
|
if (!last) return false;
|
|
70
83
|
return now - new Date(last).getTime() < 600_000; // 10 min
|
|
71
84
|
});
|
|
72
85
|
console.log(` Nodes: ${nodes.length} registered (${alive.length} live)`);
|
|
86
|
+
for (const n of nodes) {
|
|
87
|
+
const last = n.last_seen_at || n.last_heartbeat || n.registered_at || "";
|
|
88
|
+
const ago = last ? Math.round((now - new Date(last).getTime()) / 60000) : 9999;
|
|
89
|
+
const icon = ago < 10 ? "\x1b[32m●\x1b[0m" : ago < 60 ? "\x1b[33m●\x1b[0m" : "\x1b[31m○\x1b[0m";
|
|
90
|
+
const agoStr = ago < 60 ? `${ago}m` : `${Math.round(ago / 60)}h`;
|
|
91
|
+
console.log(` ${icon} ${(n.hostname || n.node_id || "?").slice(0, 20).padEnd(22)} ${(n.os_type || "?").padEnd(8)} ${agoStr} ago`);
|
|
92
|
+
}
|
|
73
93
|
}
|
|
74
94
|
|
|
75
95
|
// Pipeline
|
|
@@ -81,10 +101,10 @@ export async function showStatus() {
|
|
|
81
101
|
|
|
82
102
|
if (running.length > 0) {
|
|
83
103
|
for (const t of running.slice(0, 3)) {
|
|
84
|
-
const
|
|
85
|
-
const name = ctx.idea_name || t.direction?.slice(0, 40) || t.id?.slice(0, 16) || "?";
|
|
104
|
+
const name = _taskName(t);
|
|
86
105
|
const age = t.created_at ? Math.round((Date.now() - new Date(t.created_at).getTime()) / 60000) : 0;
|
|
87
|
-
|
|
106
|
+
const ageColor = age > 15 ? "\x1b[31m" : age > 5 ? "\x1b[33m" : "\x1b[32m";
|
|
107
|
+
console.log(` \x1b[33m▸\x1b[0m ${(t.task_type || "?").padEnd(6)} ${ageColor}${age}m\x1b[0m ${name}`);
|
|
88
108
|
}
|
|
89
109
|
if (running.length > 3) console.log(` ... and ${running.length - 3} more`);
|
|
90
110
|
}
|
|
@@ -93,8 +113,7 @@ export async function showStatus() {
|
|
|
93
113
|
if (completed.length > 0) {
|
|
94
114
|
console.log(` Recent: last ${completed.length} completed`);
|
|
95
115
|
for (const t of completed.slice(0, 3)) {
|
|
96
|
-
const
|
|
97
|
-
const name = ctx.idea_name || t.id?.slice(0, 16) || "?";
|
|
116
|
+
const name = _taskName(t);
|
|
98
117
|
console.log(` \x1b[32m✓\x1b[0m ${t.task_type || "?"} ${name}`);
|
|
99
118
|
}
|
|
100
119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coherence-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Coherence Network CLI — trace ideas from inception to payout, with fair attribution, coherence scoring, and 37 identity providers. No signup needed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|