@gajae-code/stats 0.18.0 → 0.18.1

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.
Files changed (2) hide show
  1. package/README.md +63 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -85,6 +85,69 @@ The web dashboard provides:
85
85
  - Per-folder breakdown table
86
86
  - Auto-refresh every 30 seconds
87
87
 
88
+ ## Tips & Common Patterns
89
+
90
+ ### Sync and print a summary
91
+
92
+ Every `gjc stats` invocation syncs session files before it does anything else, so there is no separate sync flag.
93
+
94
+ ```bash
95
+ gjc stats --summary
96
+ ```
97
+
98
+ ### JSON output for scripting
99
+
100
+ `gjc stats --json` prints a `Synced N new entries ...` status line and a blank line on stdout before the JSON object (sync progress goes to stderr). Skip to the first line that opens the object before piping into `jq`:
101
+
102
+ ```bash
103
+ gjc stats --json | sed -n '/^{/,$p' | jq '.overall.totalCost'
104
+ ```
105
+
106
+ ### Dashboard on a custom port
107
+
108
+ ```bash
109
+ gjc stats --port 3000
110
+ ```
111
+
112
+ `--summary` and `--json` print and exit without starting the server, so `--port` has no effect when combined with them.
113
+
114
+ ### Programmatic: highest-cost folder
115
+
116
+ ```typescript
117
+ import { getDashboardStats, syncAllSessions } from "@gajae-code/stats";
118
+
119
+ await syncAllSessions();
120
+ const stats = await getDashboardStats();
121
+
122
+ const [first, ...rest] = stats.byFolder;
123
+ if (first) {
124
+ const topFolder = rest.reduce((a, b) => (b.totalCost > a.totalCost ? b : a), first);
125
+ console.log(`Highest cost folder: ${topFolder.folder} ($${topFolder.totalCost.toFixed(2)})`);
126
+ } else {
127
+ console.log("No folder data available");
128
+ }
129
+ ```
130
+
131
+ ### Programmatic: most-requested model
132
+
133
+ ```typescript
134
+ import { getDashboardStats, syncAllSessions } from "@gajae-code/stats";
135
+
136
+ await syncAllSessions();
137
+ const stats = await getDashboardStats();
138
+
139
+ // byModel is ordered by request count, highest first.
140
+ const topModel = stats.byModel[0];
141
+ if (topModel) {
142
+ console.log(`Most requested model: ${topModel.model} (${topModel.totalRequests} requests)`);
143
+ }
144
+ ```
145
+
146
+ ### Troubleshooting
147
+
148
+ - **No data shown?** Check that session logs exist under `~/.gjc/agent/sessions/`.
149
+ - **Dashboard not starting?** Check that port 3847 (or the port passed to `--port`) is free.
150
+
88
151
  ## License
89
152
 
90
153
  MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/stats",
4
- "version": "0.18.0",
4
+ "version": "0.18.1",
5
5
  "description": "Local observability dashboard for pi AI usage statistics",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo",
@@ -38,8 +38,8 @@
38
38
  "fmt": "biome format --write ."
39
39
  },
40
40
  "dependencies": {
41
- "@gajae-code/ai": "0.18.0",
42
- "@gajae-code/utils": "0.18.0",
41
+ "@gajae-code/ai": "0.18.1",
42
+ "@gajae-code/utils": "0.18.1",
43
43
  "@tailwindcss/node": "^4.2.4",
44
44
  "chart.js": "^4.5.1",
45
45
  "date-fns": "^4.1.0",