limitcast 0.17.1 → 0.17.3

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/README.md CHANGED
@@ -111,7 +111,7 @@ Created by **Sam Stull**. The project and its history remain available as a port
111
111
 
112
112
  Protection events retain the tier at decision time. Host operation IDs deduplicate retries when supplied; older/unidentified events remain labeled attempts. Forecast history is replayed from readings and does not prove that a notification was delivered. Controls cannot establish how many interruptions were prevented.
113
113
 
114
- For a small consenting pilot, see [the pilot protocol](docs/pilot.md) and [dated market assessment](docs/market-positioning.md). From a repository checkout, `node scripts/pilot-metrics.mjs participants.json` aggregates operator-recorded activation, eligible day-7/day-30 retention and verified renewals locally; it does not recruit people or collect telemetry.
114
+ Operational automation, contact lists and internal research are maintained outside this public repository. Reports remain local, and sharing totals is voluntary.
115
115
 
116
116
  ## License
117
117
 
package/bin/limitcast.mjs CHANGED
@@ -229,7 +229,12 @@ if (cmd === 'status') {
229
229
  // Grok spend/forecast stays on the Grok status line. Claude's feed has rate_limits; mixing the two
230
230
  // would print grok $ on Claude Code and break "waiting for data" when there are no Claude readings.
231
231
  const grokExtra = grokOwn ? grokSamples(now) : [];
232
- line = statusBits(forecastAll(oneClaudeAccount([...load(now - KEEP_MS), ...grokExtra], sid), now), grokOwn ? grokSpendLine(now) : '', hints);
232
+ line = statusLines(
233
+ forecastAll(oneClaudeAccount([...load(now - KEEP_MS), ...grokExtra], sid), now),
234
+ grokOwn ? grokSpendLine(now) : '',
235
+ hints,
236
+ grokOwn ? 'grok' : 'claude',
237
+ ).join('\n');
233
238
  } catch {
234
239
  /* never break the status line */
235
240
  }
@@ -238,11 +243,11 @@ if (cmd === 'status') {
238
243
  // Your status line stays as it was; limitcast adds its own line under it (status scripts often printf without a newline).
239
244
  const yours = r.stdout?.toString() ?? '';
240
245
  process.stdout.write(yours && !yours.endsWith('\n') ? `${yours}\n` : yours);
241
- console.log(`limitcast: ${line}`);
246
+ emitStatus(line);
242
247
  process.exit(r.status ?? 1);
243
248
  }
244
249
  if (grokOwn) console.log(grokOwn);
245
- console.log(`limitcast: ${line}`);
250
+ emitStatus(line);
246
251
  } else if (cmd === 'guard') {
247
252
  // The installed guard protects all users; LIMITCAST_ALLOW=1 remains the explicit override.
248
253
  if (process.env.LIMITCAST_ALLOW === '1') process.exit(0);
@@ -1056,29 +1061,52 @@ function table(rows) {
1056
1061
  .join('\n');
1057
1062
  }
1058
1063
 
1059
- /** @param {ReturnType<typeof forecastAll>} rows */
1060
- function oneLine(rows) {
1061
- const bits = rows.map(
1062
- (f) =>
1063
- `${f.src === 'claude' ? '' : `${f.src} `}${f.win} ${Math.round(f.pct)}%${f.verdict === 'AT_RISK' ? ` ⚠ out ${clock(f.wall)}` : f.verdict === 'NEAR' ? ' ⚠ near limit' : f.verdict === 'HIT' ? ' ⛔' : ''}` +
1064
- (f.today && f.verdict !== 'HIT' ? ` · today ${todayLabel(f.today)}` : ''),
1064
+ /**
1065
+ * One window on a status-line row. Host Grok/Codex windows keep their src prefix;
1066
+ * a labeled `limitcast claude:` / `limitcast grok:` row does not repeat it.
1067
+ * @param {NonNullable<ReturnType<typeof forecastAll>>[number]} f
1068
+ * @param {boolean} labeled
1069
+ */
1070
+ function windowBit(f, labeled = false) {
1071
+ const name = labeled || f.src === 'claude' ? '' : `${f.src} `;
1072
+ return (
1073
+ `${name}${f.win} ${Math.round(f.pct)}%` +
1074
+ (f.verdict === 'AT_RISK' ? ` ⚠ out ${clock(f.wall)}` : f.verdict === 'NEAR' ? ' ⚠ near limit' : f.verdict === 'HIT' ? ' ⛔' : '') +
1075
+ (f.today && f.verdict !== 'HIT' ? ` · today ${todayLabel(f.today)}` : '')
1065
1076
  );
1066
- return bits.join(' · ') || 'limitcast: waiting for data';
1067
1077
  }
1068
1078
 
1069
1079
  /**
1070
- * Status-line body: forecasts, Grok spend when there is no cap, then hints. No "waiting for data" when spend is known.
1080
+ * Status-line rows: one provider per line, Grok spend on the Grok row, then hints on the host row.
1071
1081
  * @param {ReturnType<typeof forecastAll>} rows
1072
1082
  * @param {string} spend
1073
1083
  * @param {string[]} hints
1084
+ * @param {string} host
1074
1085
  */
1075
- function statusBits(rows, spend, hints) {
1076
- const core = oneLine(rows);
1077
- const parts = [];
1078
- if (core !== 'limitcast: waiting for data') parts.push(core.replace(/^limitcast: /, ''));
1079
- if (spend) parts.push(spend);
1080
- parts.push(...hints);
1081
- return parts.join(' · ') || 'waiting for data';
1086
+ function statusLines(rows, spend, hints, host = 'claude') {
1087
+ const order = host === 'grok' ? ['grok', 'claude', 'codex'] : ['claude', 'codex', 'grok'];
1088
+ /** @type {string[]} */
1089
+ const lines = [];
1090
+ for (const src of order) {
1091
+ const group = rows.filter((f) => f.src === src);
1092
+ if (!group.length && !(src === 'grok' && spend)) continue;
1093
+ const labeled = src !== host;
1094
+ const bits = group.map((f) => windowBit(f, labeled));
1095
+ if (src === 'grok' && spend) bits.push(spend);
1096
+ if (!bits.length) continue;
1097
+ const tag = src === host ? 'limitcast' : `limitcast ${src}`;
1098
+ lines.push(`${tag}: ${bits.join(' · ')}`);
1099
+ }
1100
+ if (hints.length) {
1101
+ if (lines.length) lines[0] += ` · ${hints.join(' · ')}`;
1102
+ else lines.push(`limitcast: ${hints.join(' · ')}`);
1103
+ }
1104
+ return lines.length ? lines : ['limitcast: waiting for data'];
1105
+ }
1106
+
1107
+ /** Print limitcast rows. `limitcast claude:` already has the prefix; `waiting for data` does not. */
1108
+ function emitStatus(line) {
1109
+ console.log(line.startsWith('limitcast') ? line : `limitcast: ${line}`);
1082
1110
  }
1083
1111
 
1084
1112
  /** Grok spend line when no dollar cap is set (a cap becomes a forecast row instead). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limitcast",
3
- "version": "0.17.1",
3
+ "version": "0.17.3",
4
4
  "description": "Stretch your Claude Code plan: measure what every session loads before you type, cut what you never use, and stop runaway subagents before they burn your window.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/formats.mjs CHANGED
@@ -16,16 +16,25 @@ export async function formatChecks() {
16
16
 
17
17
  const feedPath = join(stateDir(), 'last-feed.json');
18
18
  if (existsSync(feedPath)) {
19
- let rl = null;
19
+ let feed;
20
20
  try {
21
- rl = JSON.parse(readFileSync(feedPath, 'utf8')).rate_limits;
21
+ feed = JSON.parse(readFileSync(feedPath, 'utf8'));
22
22
  } catch {
23
23
  /* unreadable: reported below */
24
24
  }
25
+ const rl = feed?.rate_limits;
26
+ // Claude omits subscription windows before a response, after reset, or without a supported subscription.
27
+ const noWindows = rl == null || (typeof rl === 'object' && !Array.isArray(rl) && !('five_hour' in rl) && !('seven_day' in rl));
28
+ const validFeed = feed && typeof feed === 'object' && !Array.isArray(feed);
25
29
  out.push(
26
30
  Number.isFinite(rl?.five_hour?.used_percentage ?? rl?.seven_day?.used_percentage)
27
31
  ? { ok: true, line: 'Claude Code status-line feed: limit readings present' }
28
- : { ok: false, line: 'Claude Code status-line feed has no rate_limits: the format may have changed, update limitcast' },
32
+ : validFeed && noWindows
33
+ ? {
34
+ ok: true,
35
+ line: 'Claude Code status-line feed: no subscription limit readings available yet (normal before a response or without a supported subscription)',
36
+ }
37
+ : { ok: false, line: 'Claude Code status-line feed has unreadable rate_limits: the format may have changed, update limitcast' },
29
38
  );
30
39
  }
31
40
 
@@ -35,7 +44,9 @@ export async function formatChecks() {
35
44
  out.push(
36
45
  found
37
46
  ? { ok: true, line: 'Claude Code transcripts: usage records readable' }
38
- : { ok: false, line: `Claude Code transcript has no readable usage records (${claude}): the format may have changed, update limitcast` },
47
+ : !(await findLine(claude, '"assistant"', (ev) => ev?.type === 'assistant'))
48
+ ? { ok: true, line: 'Claude Code: latest session has no assistant usage yet (normal before its first response)' }
49
+ : { ok: false, line: `Claude Code transcript has no readable usage records (${claude}): the format may have changed, update limitcast` },
39
50
  );
40
51
  }
41
52
 
package/src/memory.mjs CHANGED
@@ -28,7 +28,7 @@ const slug = (s) => s.toLowerCase().replace(/\.md$/, '').replace(/[_\s]/g, '-');
28
28
  export function scanMemory(dir) {
29
29
  const indexPath = join(dir, 'MEMORY.md');
30
30
  if (!existsSync(indexPath)) return null;
31
- const names = readdirSync(dir).filter((f) => f.endsWith('.md'));
31
+ const names = readdirSync(dir).filter((f) => f.endsWith('.md') && !['CLAUDE.md', 'AGENTS.md', 'CODEX.md'].includes(f));
32
32
  /** @type {Map<string, string>} */
33
33
  const text = new Map(names.map((f) => [f, readFileSync(join(dir, f), 'utf8')]));
34
34
  const index = /** @type {string} */ (text.get('MEMORY.md'));
@@ -49,6 +49,8 @@ export function scanMemory(dir) {
49
49
  }),
50
50
  // [[name]] links; one with no file yet is allowed (a note worth writing later), so never "broken".
51
51
  ...[...body.matchAll(/\[\[([^\]|#]+)/g)].map((m) => bySlug.get(slug(m[1].trim())) ?? ''),
52
+ // Catalogs also route to local notes by plain or backticked filename.
53
+ ...[...body.matchAll(/(?<![\w/.-])([A-Za-z0-9_-]+\.md)\b/g)].map((m) => (text.has(m[1]) ? m[1] : '')),
52
54
  ];
53
55
  for (const t of targets) {
54
56
  if (!text.has(t) || reached.has(t)) continue;
@@ -94,7 +96,7 @@ export function memoryCheck(s) {
94
96
  };
95
97
  const parts = [
96
98
  s.index.lines >= INDEX_LINES * 0.8 || s.index.bytes >= INDEX_BYTES * 0.8 ? 'index close to the cap' : '',
97
- s.orphans.length ? `${s.orphans.length} not linked from the index` : '',
99
+ s.orphans.length ? `${s.orphans.length} not linked from the local index (may be externally indexed)` : '',
98
100
  s.broken.length ? `${s.broken.length} broken link${s.broken.length === 1 ? '' : 's'}` : '',
99
101
  s.big.length ? `${s.big.length} file${s.big.length === 1 ? '' : 's'} over ${BIG_LINES} lines` : '',
100
102
  ].filter(Boolean);
@@ -112,7 +114,10 @@ export function memoryReport(s, dir = '') {
112
114
  `Index: MEMORY.md ${s.index.lines} / ${INDEX_LINES} lines, ${(s.index.bytes / 1000).toFixed(1)} / 25 KB${overCap(s) ? ' (OVER: what is past the cap is never loaded)' : ''}`,
113
115
  `Topic files: ${s.files}`,
114
116
  ];
115
- if (s.orphans.length) out.push(`Not linked from the index (${s.orphans.length}): ${s.orphans.join(', ')}`);
117
+ if (s.orphans.length)
118
+ out.push(
119
+ `Not linked from the local index (${s.orphans.length}; check external catalogs before treating these as orphans): ${s.orphans.join(', ')}`,
120
+ );
116
121
  if (s.broken.length) out.push(`Broken links (${s.broken.length}): ${s.broken.map((b) => `${b.from} -> ${b.target}`).join(', ')}`);
117
122
  if (s.big.length)
118
123
  out.push(