agy-statusblocks 0.1.1 → 0.1.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/dist/cache.js CHANGED
@@ -3,9 +3,9 @@ import { join } from 'path';
3
3
  import { tmpdir } from 'os';
4
4
  import { createHash } from 'crypto';
5
5
  function cacheDir(create) {
6
- const override = process.env['AGY_STATUSBLOCKS_CACHE_DIR'] || process.env['CLAUDE_STATUSBLOCKS_CACHE_DIR'];
6
+ const override = process.env['AGY_STATUSBLOCKS_CACHE_DIR'];
7
7
  const uid = typeof process.getuid === 'function' ? `-${process.getuid()}` : '';
8
- const dir = override || join(tmpdir(), `claude-statusblocks${uid}`);
8
+ const dir = override || join(tmpdir(), `agy-statusblocks${uid}`);
9
9
  if (create)
10
10
  mkdirSync(dir, { recursive: true });
11
11
  return dir;
package/dist/index.js CHANGED
@@ -129,6 +129,10 @@ function normalizeInput(raw) {
129
129
  };
130
130
  }
131
131
  let input = '';
132
+ if (process.stdin.isTTY) {
133
+ process.stdout.write('\n');
134
+ process.exit(0);
135
+ }
132
136
  process.stdin.setEncoding('utf8');
133
137
  process.stdin.on('data', (chunk) => { input += chunk; });
134
138
  process.stdin.on('end', () => {
package/dist/layout.js CHANGED
@@ -77,10 +77,34 @@ function computeRowWidths(blockRow, blockCount, targetRows, blockWidths, rowWidt
77
77
  }
78
78
  }
79
79
  }
80
+ function solveGreedy(blocks, maxWidth) {
81
+ const rows = [];
82
+ for (const b of blocks) {
83
+ const boxW = b.width + BOX_CHROME;
84
+ let placed = false;
85
+ for (const r of rows) {
86
+ const addedW = r.blocks.length > 0 ? boxW + GAP : boxW;
87
+ if (r.currentW + addedW <= maxWidth) {
88
+ r.blocks.push(b);
89
+ r.widths.push(b.width);
90
+ r.currentW += addedW;
91
+ placed = true;
92
+ break;
93
+ }
94
+ }
95
+ if (!placed) {
96
+ rows.push({ blocks: [b], widths: [b.width], currentW: boxW });
97
+ }
98
+ }
99
+ rows.sort((a, b) => a.currentW - b.currentW);
100
+ return rows.map(r => ({ blocks: r.blocks, widths: r.widths }));
101
+ }
80
102
  function solveLayout(blocks, maxWidth) {
81
103
  if (blocks.length === 0)
82
104
  return [];
83
105
  const blockCount = blocks.length;
106
+ if (blockCount > 6)
107
+ return solveGreedy(blocks, maxWidth);
84
108
  const blockWidths = blocks.map(b => b.width);
85
109
  for (let targetRows = 1; targetRows <= blockCount; targetRows++) {
86
110
  const totalCombos = Math.pow(targetRows, blockCount);
@@ -1,10 +1,11 @@
1
1
  import { color, c, visibleLength, pctColor, renderBar } from '../colors.js';
2
2
  function formatTokens(n) {
3
- if (n >= 1000000)
4
- return `${(n / 1000000).toFixed(1)}M`;
5
- if (n >= 1000)
6
- return `${Math.round(n / 1000)}K`;
7
- return String(n);
3
+ const safe = Math.max(0, Math.round(n || 0));
4
+ if (safe >= 1000000)
5
+ return `${(safe / 1000000).toFixed(1)}M`;
6
+ if (safe >= 1000)
7
+ return `${Math.round(safe / 1000)}K`;
8
+ return String(safe);
8
9
  }
9
10
  export const contextSegment = {
10
11
  id: 'context',
@@ -31,12 +31,13 @@ function getGitInfo(cwd) {
31
31
  }
32
32
  let info = null;
33
33
  try {
34
- let branch = execSync('git branch --show-current', { cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
34
+ const execOpts = { cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'], timeout: 1500 };
35
+ let branch = execSync('git branch --show-current', execOpts).trim();
35
36
  if (!branch) {
36
- branch = '@' + execSync('git rev-parse --short HEAD', { cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
37
+ branch = '@' + execSync('git rev-parse --short HEAD', execOpts).trim();
37
38
  }
38
- const stagedOut = execSync('git diff --cached --numstat', { cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
39
- const modifiedOut = execSync('git diff --numstat', { cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
39
+ const stagedOut = execSync('git diff --cached --numstat', execOpts).trim();
40
+ const modifiedOut = execSync('git diff --numstat', execOpts).trim();
40
41
  const staged = stagedOut ? stagedOut.split('\n').length : 0;
41
42
  const modified = modifiedOut ? modifiedOut.split('\n').length : 0;
42
43
  let added = 0, removed = 0;
@@ -16,7 +16,7 @@ function formatResetTime(epochSec) {
16
16
  return `${d}d${h > 0 ? `${h}h` : ''}${m > 0 ? `${m}m` : ''}`;
17
17
  if (h > 0)
18
18
  return `${h}h${m > 0 ? `${m}m` : ''}`;
19
- return `${m}m`;
19
+ return m > 0 ? `${m}m` : '<1m';
20
20
  }
21
21
  function clampPercent(v) {
22
22
  return Math.min(999, Math.max(0, Math.round(v ?? 0)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agy-statusblocks",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Opinionated, adaptive block-based status line for Antigravity CLI (agy) with bin-packing layout, rate limit tracking, and live agent telemetry",
5
5
  "type": "module",
6
6
  "bin": {