ccstatusline 2.1.3 → 2.1.4

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
@@ -46,12 +46,14 @@
46
46
 
47
47
  ## 🆕 Recent Updates
48
48
 
49
- ### v2.1.0 - v2.1.3 - Usage widgets, links, and reliability fixes
49
+ ### v2.1.0 - v2.1.4 - Usage widgets, links, new git insertions / deletions widgets, and reliability fixes
50
50
 
51
51
  - **🧩 New Usage widgets (v2.1.0)** - Added **Session Usage**, **Weekly Usage**, **Reset Timer**, and **Context Bar** widgets.
52
52
  - **📊 More accurate counts (v2.1.0)** - Usage/context widgets now use new statusline JSON metrics when available for more accurate token and context counts.
53
53
  - **🪟 Windows empty file bug fix (v2.1.1)** - Fixed a Windows issue that could create an empty `c:\dev\null` file.
54
54
  - **🔗 New Link widget (v2.1.3)** - Added a new **Link** widget with clickable OSC8 rendering, preview parity, and raw mode support.
55
+ - **➕ New Git Insertions widget (v2.1.4)** - Added a dedicated Git widget that shows only uncommitted insertions (e.g., `+42`).
56
+ - **➖ New Git Deletions widget (v2.1.4)** - Added a dedicated Git widget that shows only uncommitted deletions (e.g., `-10`).
55
57
 
56
58
  ### v2.0.26 - v2.0.29 - Performance, git internals, and workflow improvements
57
59
 
@@ -412,6 +414,8 @@ bun run example
412
414
  - **Model Name** - Shows the current Claude model (e.g., "Claude 3.5 Sonnet")
413
415
  - **Git Branch** - Displays current git branch name
414
416
  - **Git Changes** - Shows uncommitted insertions/deletions (e.g., "+42,-10")
417
+ - **Git Insertions** - Shows uncommitted insertions only (e.g., "+42")
418
+ - **Git Deletions** - Shows uncommitted deletions only (e.g., "-10")
415
419
  - **Git Root Dir** - Shows the git repository root directory name
416
420
  - **Git Worktree** - Shows the name of the current git worktree
417
421
  - **Session Clock** - Shows elapsed time since session start (e.g., "2hr 15m")
@@ -51469,7 +51469,7 @@ import { execSync as execSync3 } from "child_process";
51469
51469
  import * as fs5 from "fs";
51470
51470
  import * as path4 from "path";
51471
51471
  var __dirname = "/Users/sirmalloc/Projects/Personal/ccstatusline/src/utils";
51472
- var PACKAGE_VERSION = "2.1.3";
51472
+ var PACKAGE_VERSION = "2.1.4";
51473
51473
  function getPackageVersion() {
51474
51474
  if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
51475
51475
  return PACKAGE_VERSION;
@@ -52414,6 +52414,24 @@ function runGit(command, context) {
52414
52414
  function isInsideGitWorkTree(context) {
52415
52415
  return runGit("rev-parse --is-inside-work-tree", context) === "true";
52416
52416
  }
52417
+ function parseDiffShortStat(stat) {
52418
+ const insertMatch = /(\d+)\s+insertions?/.exec(stat);
52419
+ const deleteMatch = /(\d+)\s+deletions?/.exec(stat);
52420
+ return {
52421
+ insertions: insertMatch?.[1] ? parseInt(insertMatch[1], 10) : 0,
52422
+ deletions: deleteMatch?.[1] ? parseInt(deleteMatch[1], 10) : 0
52423
+ };
52424
+ }
52425
+ function getGitChangeCounts(context) {
52426
+ const unstagedStat = runGit("diff --shortstat", context) ?? "";
52427
+ const stagedStat = runGit("diff --cached --shortstat", context) ?? "";
52428
+ const unstagedCounts = parseDiffShortStat(unstagedStat);
52429
+ const stagedCounts = parseDiffShortStat(stagedStat);
52430
+ return {
52431
+ insertions: unstagedCounts.insertions + stagedCounts.insertions,
52432
+ deletions: unstagedCounts.deletions + stagedCounts.deletions
52433
+ };
52434
+ }
52417
52435
 
52418
52436
  // src/widgets/GitBranch.ts
52419
52437
  class GitBranchWidget {
@@ -52519,7 +52537,7 @@ class GitChangesWidget {
52519
52537
  }
52520
52538
  return null;
52521
52539
  }
52522
- render(item, context, settings) {
52540
+ render(item, context, _settings) {
52523
52541
  const hideNoGit = item.metadata?.hideNoGit === "true";
52524
52542
  if (context.isPreview) {
52525
52543
  return "(+42,-10)";
@@ -52527,30 +52545,130 @@ class GitChangesWidget {
52527
52545
  if (!isInsideGitWorkTree(context)) {
52528
52546
  return hideNoGit ? null : "(no git)";
52529
52547
  }
52530
- const changes = this.getGitChanges(context);
52531
- if (changes)
52532
- return `(+${changes.insertions},-${changes.deletions})`;
52533
- else
52548
+ const changes = getGitChangeCounts(context);
52549
+ return `(+${changes.insertions},-${changes.deletions})`;
52550
+ }
52551
+ getCustomKeybinds() {
52552
+ return [
52553
+ { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52554
+ ];
52555
+ }
52556
+ supportsRawValue() {
52557
+ return false;
52558
+ }
52559
+ supportsColors(item) {
52560
+ return true;
52561
+ }
52562
+ }
52563
+ // src/widgets/GitInsertions.ts
52564
+ class GitInsertionsWidget {
52565
+ getDefaultColor() {
52566
+ return "green";
52567
+ }
52568
+ getDescription() {
52569
+ return "Shows git insertions count";
52570
+ }
52571
+ getDisplayName() {
52572
+ return "Git Insertions";
52573
+ }
52574
+ getCategory() {
52575
+ return "Git";
52576
+ }
52577
+ getEditorDisplay(item) {
52578
+ const hideNoGit = item.metadata?.hideNoGit === "true";
52579
+ const modifiers = [];
52580
+ if (hideNoGit) {
52581
+ modifiers.push("hide 'no git'");
52582
+ }
52583
+ return {
52584
+ displayText: this.getDisplayName(),
52585
+ modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52586
+ };
52587
+ }
52588
+ handleEditorAction(action, item) {
52589
+ if (action === "toggle-nogit") {
52590
+ const currentState = item.metadata?.hideNoGit === "true";
52591
+ return {
52592
+ ...item,
52593
+ metadata: {
52594
+ ...item.metadata,
52595
+ hideNoGit: (!currentState).toString()
52596
+ }
52597
+ };
52598
+ }
52599
+ return null;
52600
+ }
52601
+ render(item, context, _settings) {
52602
+ const hideNoGit = item.metadata?.hideNoGit === "true";
52603
+ if (context.isPreview) {
52604
+ return "+42";
52605
+ }
52606
+ if (!isInsideGitWorkTree(context)) {
52534
52607
  return hideNoGit ? null : "(no git)";
52608
+ }
52609
+ const changes = getGitChangeCounts(context);
52610
+ return `+${changes.insertions}`;
52535
52611
  }
52536
- getGitChanges(context) {
52537
- let totalInsertions = 0;
52538
- let totalDeletions = 0;
52539
- const unstagedStat = runGit("diff --shortstat", context) ?? "";
52540
- const stagedStat = runGit("diff --cached --shortstat", context) ?? "";
52541
- if (unstagedStat) {
52542
- const insertMatch = /(\d+) insertion/.exec(unstagedStat);
52543
- const deleteMatch = /(\d+) deletion/.exec(unstagedStat);
52544
- totalInsertions += insertMatch?.[1] ? parseInt(insertMatch[1], 10) : 0;
52545
- totalDeletions += deleteMatch?.[1] ? parseInt(deleteMatch[1], 10) : 0;
52546
- }
52547
- if (stagedStat) {
52548
- const insertMatch = /(\d+) insertion/.exec(stagedStat);
52549
- const deleteMatch = /(\d+) deletion/.exec(stagedStat);
52550
- totalInsertions += insertMatch?.[1] ? parseInt(insertMatch[1], 10) : 0;
52551
- totalDeletions += deleteMatch?.[1] ? parseInt(deleteMatch[1], 10) : 0;
52552
- }
52553
- return { insertions: totalInsertions, deletions: totalDeletions };
52612
+ getCustomKeybinds() {
52613
+ return [
52614
+ { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52615
+ ];
52616
+ }
52617
+ supportsRawValue() {
52618
+ return false;
52619
+ }
52620
+ supportsColors(item) {
52621
+ return true;
52622
+ }
52623
+ }
52624
+ // src/widgets/GitDeletions.ts
52625
+ class GitDeletionsWidget {
52626
+ getDefaultColor() {
52627
+ return "red";
52628
+ }
52629
+ getDescription() {
52630
+ return "Shows git deletions count";
52631
+ }
52632
+ getDisplayName() {
52633
+ return "Git Deletions";
52634
+ }
52635
+ getCategory() {
52636
+ return "Git";
52637
+ }
52638
+ getEditorDisplay(item) {
52639
+ const hideNoGit = item.metadata?.hideNoGit === "true";
52640
+ const modifiers = [];
52641
+ if (hideNoGit) {
52642
+ modifiers.push("hide 'no git'");
52643
+ }
52644
+ return {
52645
+ displayText: this.getDisplayName(),
52646
+ modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52647
+ };
52648
+ }
52649
+ handleEditorAction(action, item) {
52650
+ if (action === "toggle-nogit") {
52651
+ const currentState = item.metadata?.hideNoGit === "true";
52652
+ return {
52653
+ ...item,
52654
+ metadata: {
52655
+ ...item.metadata,
52656
+ hideNoGit: (!currentState).toString()
52657
+ }
52658
+ };
52659
+ }
52660
+ return null;
52661
+ }
52662
+ render(item, context, _settings) {
52663
+ const hideNoGit = item.metadata?.hideNoGit === "true";
52664
+ if (context.isPreview) {
52665
+ return "-10";
52666
+ }
52667
+ if (!isInsideGitWorkTree(context)) {
52668
+ return hideNoGit ? null : "(no git)";
52669
+ }
52670
+ const changes = getGitChangeCounts(context);
52671
+ return `-${changes.deletions}`;
52554
52672
  }
52555
52673
  getCustomKeybinds() {
52556
52674
  return [
@@ -57141,6 +57259,8 @@ var widgetRegistry = new Map([
57141
57259
  ["output-style", new OutputStyleWidget],
57142
57260
  ["git-branch", new GitBranchWidget],
57143
57261
  ["git-changes", new GitChangesWidget],
57262
+ ["git-insertions", new GitInsertionsWidget],
57263
+ ["git-deletions", new GitDeletionsWidget],
57144
57264
  ["git-root-dir", new GitRootDirWidget],
57145
57265
  ["git-worktree", new GitWorktreeWidget],
57146
57266
  ["current-working-dir", new CurrentWorkingDirWidget],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccstatusline",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "A customizable status line formatter for Claude Code CLI",
5
5
  "module": "src/ccstatusline.ts",
6
6
  "type": "module",