portable-agent-layer 0.15.0 → 0.15.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portable-agent-layer",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "PAL — Portable Agent Layer: persistent personal context for AI coding assistants",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import { existsSync, readdirSync, readFileSync } from "node:fs";
12
+ import { homedir } from "node:os";
12
13
  import { resolve } from "node:path";
13
14
  import { parseArgs } from "node:util";
14
15
  import { MODEL_PRICING } from "../hooks/lib/models";
@@ -104,16 +105,16 @@ function fmtCost(n: number): string {
104
105
  return `$${n.toFixed(4)}`;
105
106
  }
106
107
 
107
- function printRow(label: string, b: Bucket): void {
108
+ function printRow(label: string, b: Bucket, labelWidth = 14): void {
108
109
  const tokens = b.input + b.output + b.cacheWrite + b.cacheRead;
109
110
  console.log(
110
- ` ${label.padEnd(14)} ${fmt(tokens).padStart(8)} tok ${fmt(b.calls).padStart(5)} calls ${fmtCost(b.cost).padStart(8)}`
111
+ ` ${label.padEnd(labelWidth)} ${fmt(tokens).padStart(8)} tok ${fmt(b.calls).padStart(5)} calls ${fmtCost(b.cost).padStart(8)}`
111
112
  );
112
113
  }
113
114
 
114
- function printDetailed(label: string, b: Bucket): void {
115
+ function printDetailed(label: string, b: Bucket, labelWidth = 14): void {
115
116
  console.log(
116
- ` ${label.padEnd(14)} ${fmt(b.input).padStart(8)} in ${fmt(b.output).padStart(8)} out ${fmt(b.cacheWrite).padStart(8)} cw ${fmt(b.cacheRead).padStart(8)} cr ${fmtCost(b.cost).padStart(8)}`
117
+ ` ${label.padEnd(labelWidth)} ${fmt(b.input).padStart(8)} in ${fmt(b.output).padStart(8)} out ${fmt(b.cacheWrite).padStart(8)} cw ${fmt(b.cacheRead).padStart(8)} cr ${fmtCost(b.cost).padStart(8)}`
117
118
  );
118
119
  }
119
120
 
@@ -160,7 +161,7 @@ function readClaudeCode(): {
160
161
  const byModel: Record<string, Bucket> = {};
161
162
  const byProject: Record<string, TimeBuckets> = {};
162
163
 
163
- const claudeDir = resolve(process.env.HOME ?? "~", ".claude", "projects");
164
+ const claudeDir = resolve(homedir(), ".claude", "projects");
164
165
  if (!existsSync(claudeDir)) return { buckets, byModel, byProject };
165
166
 
166
167
  const projectDirs = readdirSync(claudeDir, { withFileTypes: true })
@@ -294,8 +295,10 @@ printRow("Total", cc.buckets.total);
294
295
  if (Object.keys(cc.byModel).length > 0) {
295
296
  console.log("\n By Model (all time)\n");
296
297
  const sorted = Object.entries(cc.byModel).sort((a, b) => b[1].cost - a[1].cost);
297
- for (const [model, bucket] of sorted) {
298
- printDetailed(model.replace("claude-", ""), bucket);
298
+ const modelNames = sorted.map(([m]) => m.replace("claude-", ""));
299
+ const modelWidth = Math.max(14, ...modelNames.map((n) => n.length + 2));
300
+ for (let i = 0; i < sorted.length; i++) {
301
+ printDetailed(modelNames[i], sorted[i][1], modelWidth);
299
302
  }
300
303
  }
301
304