Skip to content

nanocoai/nanoclaw / .claude/skills/add-clidash

add-clidash

Unverified

Add clidash — a zero-dependency, read-only web dashboard that derives its tabs and tables at runtime from any CLI that lists resources as JSON. Ships pre-wired for NanoClaw's ncl CLI (agent groups, sessions, channels, users, roles), plus message-activity charts, a log tail, and a read-only file viewer for group skills/CLAUDE.md/profiles.

FileKindSize
REMOVE.mdmarkdown544 B
SKILL.mdskill md6.3 KB
add/tools/clidash/README.mdmarkdown4.0 KB
add/tools/clidash/activity.jsscript3.5 KB
add/tools/clidash/clidash.config.example.jsonconfig3.3 KB
add/tools/clidash/docs.jsscript3.7 KB
add/tools/clidash/logs.jsscript667 B
add/tools/clidash/package.jsonmanifest347 B
add/tools/clidash/parsers.jsscript3.3 KB
add/tools/clidash/public/app.jsscript32.6 KB
add/tools/clidash/public/apple-touch-icon.pngbinary5.3 KB
add/tools/clidash/public/favicon.icobinary547 B
add/tools/clidash/public/favicon.svgother570 B
add/tools/clidash/public/icon-192.pngbinary6.5 KB
add/tools/clidash/public/icon-512.pngbinary18.5 KB
add/tools/clidash/public/index.htmlother1.9 KB
add/tools/clidash/public/md.jsscript2.7 KB
add/tools/clidash/public/site.webmanifestother298 B
add/tools/clidash/public/style.cssother18.0 KB
add/tools/clidash/server.jsscript17.2 KB
add/tools/clidash/test/activity-server.test.jsscript2.3 KB
add/tools/clidash/test/activity.test.jsscript3.8 KB
add/tools/clidash/test/cmd.test.jsscript3.4 KB
add/tools/clidash/test/css.test.jsscript991 B
add/tools/clidash/test/docs-server.test.jsscript4.0 KB
add/tools/clidash/test/docs.test.jsscript4.4 KB
add/tools/clidash/test/fixtures/ncl-help.txtmarkdown4.1 KB
add/tools/clidash/test/fixtures/stub-cli.jsscript1.8 KB
add/tools/clidash/test/help.test.jsscript2.2 KB
add/tools/clidash/test/logs.test.jsscript2.9 KB
add/tools/clidash/test/md.test.jsscript2.9 KB
add/tools/clidash/test/ncl-overview.test.jsscript3.5 KB
add/tools/clidash/test/parsers.test.jsscript4.0 KB
add/tools/clidash/test/server.test.jsscript8.9 KB
add/tools/clidash/test/smoke.shexecutablescript747 B
add/tools/clidash/views/ncl-overview.jsscript1.9 KB

add/tools/clidash/activity.js

View on GitHub
// Message-activity reader for clidash.
//
// ncl has no `messages` resource — message data lives in the per-session SQLite
// DBs (`data/v2-sessions/<group>/<session>/{inbound,outbound}.db`). We read them
// read-only with Node's built-in `node:sqlite` (no new dependency) and aggregate
// per-session in/out totals + a daily time-series for charting.

import { readdirSync, existsSync } from 'node:fs';
import { join } from 'node:path';
import { DatabaseSync } from 'node:sqlite';

// Timestamps come in two shapes across tables: SQLite "YYYY-MM-DD HH:MM:SS" (UTC)
// and already-ISO "YYYY-MM-DDTHH:MM:SS.sssZ". Normalize to a comparable ISO form
// so date-bucketing and max("last") work regardless of which a row used.
function normTs(ts) {
  if (typeof ts !== 'string' || ts.length < 10) return null;
  if (ts.includes('T')) return ts; // already ISO
  return `${ts.replace(' ', 'T')}Z`;
}

// Local calendar day "YYYY-MM-DD" — chart labels are read by a human, so
// bucket by the server's local day, not the UTC date prefix.
function localDay(date) {
  return date.toLocaleDateString('sv-SE');
}

function readTable(dbPath, table) {
  let db;
  try {
    db = new DatabaseSync(dbPath, { readOnly: true });
    const rows = db.prepare(`SELECT timestamp FROM ${table}`).all();
    const byDay = new Map();
    let last = null;
    for (const r of rows) {
      const ts = normTs(r.timestamp);
      if (!ts) continue;
      const day = localDay(new Date(ts));
      byDay.set(day, (byDay.get(day) ?? 0) + 1);
      if (last === null || ts > last) last = ts;
    }
    return { total: rows.length, byDay, last };
  } catch {
    return { total: 0, byDay: new Map(), last: null }; // missing/locked/corrupt → skip
  } finally {
    try { db?.close(); } catch { /* already closed */ }
  }
}

function listDirs(path) {
  try {
    return readdirSync(path, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
  } catch {
    return [];
  }
}

/**
 * Aggregate message activity across all session DBs under `sessionsRoot`.
 * @returns {{ sessions: Array, series: Array<{date,in,out}> }}
 *   sessions — per session: { agent_group_id, session_id, in, out, lastActivity }
 *   series   — one bucket per day for the last `days` days (local time, newest last)
 */
export function collectActivity(sessionsRoot, days, now) {
  const dates = [];
  for (let i = days - 1; i >= 0; i--) {
    dates.push(localDay(new Date(now.getTime() - i * 86_400_000)));
  }
  const series = new Map(dates.map((d) => [d, { date: d, in: 0, out: 0 }]));
  const sessions = [];

  for (const group of listDirs(sessionsRoot)) {
    for (const session of listDirs(join(sessionsRoot, group))) {
      const base = join(sessionsRoot, group, session);
      // a real session dir has at least one of the two message DBs; skip shared
      // scaffolding dirs like `.claude-shared` that don't.
      if (!existsSync(join(base, 'inbound.db')) && !existsSync(join(base, 'outbound.db'))) continue;
      const inb = readTable(join(base, 'inbound.db'), 'messages_in');
      const out = readTable(join(base, 'outbound.db'), 'messages_out');
      const lastActivity = [inb.last, out.last].filter(Boolean).sort().at(-1) ?? null;
      sessions.push({ agent_group_id: group, session_id: session, in: inb.total, out: out.total, lastActivity });
      for (const [day, n] of inb.byDay) series.get(day)?.in !== undefined && (series.get(day).in += n);
      for (const [day, n] of out.byDay) series.get(day)?.out !== undefined && (series.get(day).out += n);
    }
  }
  return { sessions, series: dates.map((d) => series.get(d)) };
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall