burnboard-cli 0.3.0 → 0.3.2

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/cli.mjs CHANGED
@@ -26,7 +26,7 @@ function run(executable, runArgs) {
26
26
  return result.status ?? 1;
27
27
  }
28
28
 
29
- function setup(nameOverride) {
29
+ function setup(nameOverride, mode = "setup") {
30
30
  const name = nameOverride || option("--name", args.find((value) => !value.startsWith("-")));
31
31
  const server = option("--server", "https://burnboard-public.vercel.app");
32
32
  if (!name || name.startsWith("--")) throw new Error('A name is required. Example: npx burnboard-cli setup --name "Harsh Sawant"');
@@ -34,7 +34,7 @@ function setup(nameOverride) {
34
34
  if (process.platform === "win32") {
35
35
  status = run("powershell.exe", ["-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", path.join(installRoot, "burnboard-setup.ps1"), "-Name", name, "-ServerUrl", server]);
36
36
  } else {
37
- status = run("bash", [path.join(installRoot, "burnboard-setup.sh"), name, server]);
37
+ status = run("bash", [path.join(installRoot, "burnboard-setup.sh"), name, server, mode]);
38
38
  }
39
39
  if (status === 0) {
40
40
  fs.writeFileSync(installedVersionPath, `${cliVersion}\n`);
@@ -53,7 +53,7 @@ async function connect() {
53
53
  if (!response.ok) throw new Error(body.error || "The connection code could not be used.");
54
54
  fs.mkdirSync(burnboardRoot, { recursive:true });
55
55
  fs.writeFileSync(path.join(burnboardRoot, "config.json"), `${JSON.stringify({ serverUrl:server, token:body.token, profileUrl:body.profileUrl }, null, 2)}\n`);
56
- if (setup("Connected BurnBoard User") !== 0) throw new Error("Connected, but the local tracker could not be installed. Run the same command again to repair it.");
56
+ if (setup("Connected BurnBoard User", "connect") !== 0) throw new Error("Connected, but the local tracker could not be installed. Run `npx --yes burnboard-cli@latest update --force` to repair it.");
57
57
  }
58
58
 
59
59
  function update() {
@@ -73,7 +73,7 @@ function update() {
73
73
  return;
74
74
  }
75
75
  console.log(`Updating BurnBoard from ${installedVersion || "a legacy installation"} to ${cliVersion}...`);
76
- if (setup("Existing BurnBoard User") !== 0) throw new Error("The update did not complete successfully; the existing tracker is unchanged.");
76
+ if (setup("Existing BurnBoard User", "update") !== 0) throw new Error("The update did not complete successfully; the existing tracker is unchanged.");
77
77
  }
78
78
 
79
79
  function sync() {
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- NAME="${1:?Usage: burnboard-setup.sh NAME [SERVER_URL]}"; SERVER_URL="${2:-https://burnboard-public.vercel.app}"
3
+ NAME="${1:?Usage: burnboard-setup.sh NAME [SERVER_URL]}"; SERVER_URL="${2:-https://burnboard-public.vercel.app}"; MODE="${3:-setup}"
4
4
  command -v node >/dev/null || { echo "Node.js is required." >&2; exit 1; }
5
5
  INSTALL_DIR="$HOME/.burnboard"; CONFIG="$INSTALL_DIR/config.json"; mkdir -p "$INSTALL_DIR" "$HOME/.claude"
6
6
  printf '[1/5] Preparing BurnBoard profile...\n'
@@ -16,10 +16,91 @@ node -e 'require("fs").writeFileSync(process.argv[1],JSON.stringify({serverUrl:p
16
16
  node - "$HOME/.claude/settings.json" <<'NODE'
17
17
  const fs=require('fs'),file=process.argv[2],current=fs.existsSync(file)?JSON.parse(fs.readFileSync(file,'utf8')):{};current.env=current.env||{};for(const key of ['CLAUDE_CODE_ENABLE_TELEMETRY','OTEL_METRICS_EXPORTER','OTEL_LOGS_EXPORTER','OTEL_EXPORTER_OTLP_METRICS_PROTOCOL','OTEL_EXPORTER_OTLP_METRICS_ENDPOINT','OTEL_EXPORTER_OTLP_METRICS_HEADERS','OTEL_METRIC_EXPORT_INTERVAL','OTEL_METRICS_INCLUDE_SESSION_ID'])delete current.env[key];fs.writeFileSync(file,JSON.stringify(current,null,2)+"\n");
18
18
  NODE
19
- printf '[3/5] Scheduling automatic sync...\n'; (crontab -l 2>/dev/null|grep -Ev 'burnboard/agent.mjs|burnboard-cli@latest update'||true;echo "*/5 * * * * $(command -v node) $INSTALL_DIR/agent.mjs >/dev/null 2>&1";echo "0 4 * * * $(command -v npx) --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1";echo "@reboot sleep 180 && $(command -v npx) --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1")|crontab -
20
- if [[ "$(uname -s)" == "Darwin" ]] && ! pgrep -x Antigravity >/dev/null 2>&1 && [[ -d "/Applications/Antigravity.app" ]]; then open -a Antigravity; sleep 8; fi
19
+ printf '[3/5] Scheduling automatic sync...\n'
20
+ NODE_BIN="$(command -v node)"; NPX_BIN="$(command -v npx)"
21
+ if command -v crontab >/dev/null 2>&1; then
22
+ (crontab -l 2>/dev/null|grep -Ev 'burnboard/agent.mjs|burnboard-cli@latest update'||true;echo "*/5 * * * * $NODE_BIN $INSTALL_DIR/agent.mjs >/dev/null 2>&1";echo "0 4 * * * $NPX_BIN --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1";echo "@reboot sleep 180 && $NPX_BIN --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1")|crontab -
23
+ SCHEDULER="cron"
24
+ elif command -v systemctl >/dev/null 2>&1 && systemctl --user show-environment >/dev/null 2>&1; then
25
+ UNIT_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"; mkdir -p "$UNIT_DIR"
26
+ cat >"$UNIT_DIR/burnboard-sync.service" <<EOF
27
+ [Unit]
28
+ Description=BurnBoard token sync
29
+ [Service]
30
+ Type=oneshot
31
+ ExecStart=$NODE_BIN %h/.burnboard/agent.mjs
32
+ EOF
33
+ cat >"$UNIT_DIR/burnboard-sync.timer" <<'EOF'
34
+ [Unit]
35
+ Description=Sync BurnBoard usage every five minutes
36
+ [Timer]
37
+ OnBootSec=2min
38
+ OnUnitActiveSec=5min
39
+ AccuracySec=30s
40
+ Persistent=true
41
+ [Install]
42
+ WantedBy=timers.target
43
+ EOF
44
+ cat >"$UNIT_DIR/burnboard-update.service" <<EOF
45
+ [Unit]
46
+ Description=Update BurnBoard tracker
47
+ [Service]
48
+ Type=oneshot
49
+ ExecStart=$NPX_BIN --yes --prefer-online burnboard-cli@latest update
50
+ EOF
51
+ cat >"$UNIT_DIR/burnboard-update.timer" <<'EOF'
52
+ [Unit]
53
+ Description=Check for BurnBoard updates daily
54
+ [Timer]
55
+ OnBootSec=3min
56
+ OnUnitActiveSec=1d
57
+ AccuracySec=10min
58
+ Persistent=true
59
+ [Install]
60
+ WantedBy=timers.target
61
+ EOF
62
+ systemctl --user daemon-reload
63
+ systemctl --user enable --now burnboard-sync.timer burnboard-update.timer >/dev/null
64
+ SCHEDULER="systemd user timers"
65
+ else
66
+ LOOP="$INSTALL_DIR/run-loop.sh"
67
+ cat >"$LOOP" <<EOF
68
+ #!/usr/bin/env sh
69
+ while :; do
70
+ "$NODE_BIN" "$INSTALL_DIR/agent.mjs" >/dev/null 2>&1
71
+ now=\$(date +%s); last=0; [ -f "$INSTALL_DIR/last-loop-update" ] && last=\$(cat "$INSTALL_DIR/last-loop-update" 2>/dev/null || echo 0)
72
+ if [ \$((now-last)) -ge 86400 ]; then "$NPX_BIN" --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1 && printf '%s' "\$now" >"$INSTALL_DIR/last-loop-update"; fi
73
+ sleep 300
74
+ done
75
+ EOF
76
+ chmod 700 "$LOOP"
77
+ if [[ -f "$INSTALL_DIR/loop.pid" ]]; then OLD_PID="$(cat "$INSTALL_DIR/loop.pid" 2>/dev/null || true)"; if [[ -n "$OLD_PID" && -r "/proc/$OLD_PID/cmdline" ]] && tr '\0' ' ' <"/proc/$OLD_PID/cmdline" | grep -q 'run-loop.sh'; then kill "$OLD_PID" 2>/dev/null || true; fi; fi
78
+ nohup "$LOOP" </dev/null >"$INSTALL_DIR/loop.log" 2>&1 & echo $! >"$INSTALL_DIR/loop.pid"
79
+ AUTOSTART_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/autostart"; mkdir -p "$AUTOSTART_DIR"
80
+ cat >"$AUTOSTART_DIR/burnboard.desktop" <<EOF
81
+ [Desktop Entry]
82
+ Type=Application
83
+ Name=BurnBoard Sync
84
+ Exec=$LOOP
85
+ Terminal=false
86
+ X-GNOME-Autostart-enabled=true
87
+ EOF
88
+ SCHEDULER="portable background service"
89
+ fi
90
+ if [[ "$MODE" != "update" ]] && [[ "$(uname -s)" == "Darwin" ]] && ! pgrep -x Antigravity >/dev/null 2>&1 && [[ -d "/Applications/Antigravity.app" ]]; then open -a Antigravity; sleep 8; fi
91
+ if [[ "$MODE" != "update" ]] && [[ "$(uname -s)" == "Linux" ]] && ! pgrep -if 'antigravity' >/dev/null 2>&1; then
92
+ ANTIGRAVITY_BIN=""
93
+ for candidate in antigravity antigravity-ide Antigravity; do if command -v "$candidate" >/dev/null 2>&1; then ANTIGRAVITY_BIN="$(command -v "$candidate")"; break; fi; done
94
+ if [[ -n "$ANTIGRAVITY_BIN" ]]; then
95
+ printf 'Starting Antigravity so its local usage service is available...\n'
96
+ nohup "$ANTIGRAVITY_BIN" >/dev/null 2>&1 </dev/null &
97
+ sleep 10
98
+ else
99
+ printf 'Antigravity launcher was not found on PATH. Open Antigravity once, then run: npx --yes burnboard-cli sync\n'
100
+ fi
101
+ fi
21
102
  printf '[4/5] Counting and uploading local history'; OUT="$INSTALL_DIR/setup-sync.out"; ERR="$INSTALL_DIR/setup-sync.err"; node "$INSTALL_DIR/agent.mjs" >"$OUT" 2>"$ERR" & PID=$!
22
103
  while kill -0 "$PID" 2>/dev/null; do printf '.'; sleep 1; done
23
104
  if ! wait "$PID"; then printf '\n'; cat "$ERR" >&2; rm -f "$OUT" "$ERR"; exit 1; fi
24
105
  printf '\n[5/5] Complete\n'; cat "$OUT"; rm -f "$OUT" "$ERR"
25
- echo "Burnboard is connected: $SERVER_URL$PROFILE"; echo "Codex, Claude Code, Cursor, and both supported Antigravity installations sync every 5 minutes. Burnboard checks for updates daily."
106
+ echo "Burnboard is connected: $SERVER_URL$PROFILE"; echo "Codex, Claude Code, Cursor, and both supported Antigravity installations sync every 5 minutes using $SCHEDULER. Burnboard checks for updates daily."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "burnboard-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Connect local AI coding token usage to BurnBoard",
5
5
  "type": "module",
6
6
  "bin": {