ccstatusline 2.0.17 → 2.0.19

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.
@@ -51374,7 +51374,7 @@ import { execSync as execSync3 } from "child_process";
51374
51374
  import * as fs5 from "fs";
51375
51375
  import * as path4 from "path";
51376
51376
  var __dirname = "/Users/sirmalloc/Projects/Personal/ccstatusline/src/utils";
51377
- var PACKAGE_VERSION = "2.0.17";
51377
+ var PACKAGE_VERSION = "2.0.19";
51378
51378
  function getPackageVersion() {
51379
51379
  if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
51380
51380
  return PACKAGE_VERSION;
@@ -58977,15 +58977,31 @@ function getBlockMetrics(transcriptPath) {
58977
58977
  if (!transcriptPath || typeof transcriptPath !== "string") {
58978
58978
  return null;
58979
58979
  }
58980
- let currentPath = path6.dirname(transcriptPath);
58981
58980
  let claudePath = null;
58982
- while (currentPath && currentPath !== path6.dirname(currentPath)) {
58983
- const baseName = path6.basename(currentPath);
58984
- if (baseName === ".claude") {
58985
- claudePath = currentPath;
58986
- break;
58981
+ if (process.platform === "win32") {
58982
+ const homeDir = process.env.USERPROFILE ?? process.env.HOME;
58983
+ if (homeDir) {
58984
+ claudePath = path6.join(homeDir, ".claude");
58985
+ if (!fs6.existsSync(claudePath)) {
58986
+ return null;
58987
+ }
58988
+ }
58989
+ } else {
58990
+ let currentPath = path6.dirname(transcriptPath);
58991
+ const visitedPaths = new Set;
58992
+ while (currentPath && !visitedPaths.has(currentPath)) {
58993
+ visitedPaths.add(currentPath);
58994
+ const baseName = path6.basename(currentPath);
58995
+ if (baseName === ".claude") {
58996
+ claudePath = currentPath;
58997
+ break;
58998
+ }
58999
+ const parentPath = path6.dirname(currentPath);
59000
+ if (parentPath === currentPath) {
59001
+ break;
59002
+ }
59003
+ currentPath = parentPath;
58987
59004
  }
58988
- currentPath = path6.dirname(currentPath);
58989
59005
  }
58990
59006
  if (!claudePath)
58991
59007
  return null;
@@ -58997,10 +59013,12 @@ function getBlockMetrics(transcriptPath) {
58997
59013
  }
58998
59014
  function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
58999
59015
  const sessionDurationMs = sessionDurationHours * 60 * 60 * 1000;
59000
- const sessionGapThresholdMs = Math.min(sessionDurationMs, 60 * 60 * 1000);
59001
59016
  const now = new Date;
59002
- const pattern = path6.join(rootDir, "projects", "**", "*.jsonl").replace(/\\/g, "/");
59003
- const files = globSync([pattern]);
59017
+ const pattern = path6.posix.join(rootDir.replace(/\\/g, "/"), "projects", "**", "*.jsonl");
59018
+ const files = globSync([pattern], {
59019
+ absolute: true,
59020
+ cwd: rootDir
59021
+ });
59004
59022
  if (files.length === 0)
59005
59023
  return null;
59006
59024
  const filesWithStats = files.map((file2) => {
@@ -59045,7 +59063,7 @@ function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
59045
59063
  if (!currentTimestamp || !previousTimestamp)
59046
59064
  continue;
59047
59065
  const gap = previousTimestamp.getTime() - currentTimestamp.getTime();
59048
- if (gap >= sessionGapThresholdMs) {
59066
+ if (gap >= sessionDurationMs) {
59049
59067
  foundSessionGap = true;
59050
59068
  break;
59051
59069
  }
@@ -59061,23 +59079,31 @@ function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
59061
59079
  if (!mostRecentTimestamp || !continuousWorkStart) {
59062
59080
  return null;
59063
59081
  }
59064
- const flooredWorkStart = floorToHour(continuousWorkStart);
59065
- const totalWorkTime = now.getTime() - flooredWorkStart.getTime();
59066
- let blockStart = flooredWorkStart;
59067
- if (totalWorkTime > sessionDurationMs) {
59068
- const completedBlocks = Math.floor(totalWorkTime / sessionDurationMs);
59069
- blockStart = new Date(flooredWorkStart.getTime() + completedBlocks * sessionDurationMs);
59070
- }
59071
- const blockEnd = new Date(blockStart.getTime() + sessionDurationMs);
59072
- const inBlockWindow = now.getTime() >= blockStart.getTime() && now.getTime() <= blockEnd.getTime();
59073
- const activityInThisBlock = mostRecentTimestamp.getTime() >= blockStart.getTime() && mostRecentTimestamp.getTime() <= now.getTime();
59074
- const isActive = inBlockWindow && activityInThisBlock;
59075
- if (!isActive)
59076
- return null;
59077
- return {
59078
- startTime: blockStart,
59079
- lastActivity: mostRecentTimestamp
59080
- };
59082
+ const blocks = [];
59083
+ const sortedTimestamps = timestamps.slice().sort((a, b) => a.getTime() - b.getTime());
59084
+ let currentBlockStart = null;
59085
+ let currentBlockEnd = null;
59086
+ for (const timestamp of sortedTimestamps) {
59087
+ if (timestamp.getTime() < continuousWorkStart.getTime())
59088
+ continue;
59089
+ if (!currentBlockStart || currentBlockEnd && timestamp.getTime() > currentBlockEnd.getTime()) {
59090
+ currentBlockStart = floorToHour(timestamp);
59091
+ currentBlockEnd = new Date(currentBlockStart.getTime() + sessionDurationMs);
59092
+ blocks.push({ start: currentBlockStart, end: currentBlockEnd });
59093
+ }
59094
+ }
59095
+ for (const block of blocks) {
59096
+ if (now.getTime() >= block.start.getTime() && now.getTime() <= block.end.getTime()) {
59097
+ const hasActivity = timestamps.some((t) => t.getTime() >= block.start.getTime() && t.getTime() <= block.end.getTime());
59098
+ if (hasActivity) {
59099
+ return {
59100
+ startTime: block.start,
59101
+ lastActivity: mostRecentTimestamp
59102
+ };
59103
+ }
59104
+ }
59105
+ }
59106
+ return null;
59081
59107
  }
59082
59108
  function getAllTimestampsFromFile(filePath) {
59083
59109
  const timestamps = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccstatusline",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "description": "A customizable status line formatter for Claude Code CLI",
5
5
  "module": "src/ccstatusline.ts",
6
6
  "type": "module",