@hasna/statusline 0.0.1 → 0.0.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 +266 -22
- package/dist/accounts.d.ts +50 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1303 -0
- package/dist/config.d.ts +11 -0
- package/dist/context-window.d.ts +14 -0
- package/dist/format.d.ts +4 -0
- package/dist/git.d.ts +6 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +920 -0
- package/dist/install.d.ts +16 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.js +20591 -0
- package/dist/providers/claude.d.ts +7 -0
- package/dist/providers/types.d.ts +47 -0
- package/dist/render.d.ts +4 -0
- package/dist/segments/index.d.ts +3 -0
- package/package.json +34 -4
- package/src/config.ts +0 -53
- package/src/context-window.ts +0 -51
- package/src/format.ts +0 -36
- package/src/git.ts +0 -55
- package/src/index.ts +0 -143
- package/src/install.ts +0 -20
- package/src/providers/claude.ts +0 -35
- package/src/providers/types.ts +0 -23
- package/src/render.ts +0 -19
- package/src/segments/index.ts +0 -187
package/src/segments/index.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { hostname } from "node:os";
|
|
2
|
-
import type { Segment, StatusContext } from "../providers/types";
|
|
3
|
-
import { compactAge, compactDuration, compactNum, money } from "../format";
|
|
4
|
-
import { gitBranch, gitProjectName, lastCommitEpoch, trackedLineCount } from "../git";
|
|
5
|
-
import { contextUsage } from "../context-window";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Format a model id like "claude-fable-5[1m]" or "claude-3-5-sonnet-20241022"
|
|
9
|
-
* into a friendly name ("fable 5", "sonnet 3.5") plus an optional context tag.
|
|
10
|
-
*/
|
|
11
|
-
function friendlyModel(id: string): { name: string; tag: string | null } {
|
|
12
|
-
let tag: string | null = null;
|
|
13
|
-
let mid = id;
|
|
14
|
-
const tagMatch = mid.match(/\[([^\]]+)\]$/);
|
|
15
|
-
if (tagMatch) {
|
|
16
|
-
tag = `[${tagMatch[1]}]`;
|
|
17
|
-
mid = mid.slice(0, mid.length - tagMatch[0].length);
|
|
18
|
-
}
|
|
19
|
-
mid = mid.replace(/^claude-/, "").replace(/-\d{8}$/, "");
|
|
20
|
-
const tokens = mid.split("-").filter(Boolean);
|
|
21
|
-
const words = tokens.filter((t) => !/^\d+$/.test(t));
|
|
22
|
-
const nums = tokens.filter((t) => /^\d+$/.test(t));
|
|
23
|
-
const name = [words.join(" "), nums.join(".")].filter(Boolean).join(" ");
|
|
24
|
-
return { name: name || mid, tag };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const dir = (ctx: StatusContext) => ctx.cwd || process.cwd();
|
|
28
|
-
|
|
29
|
-
export const segments: Segment[] = [
|
|
30
|
-
{
|
|
31
|
-
id: "machine",
|
|
32
|
-
description: "Machine hostname (short)",
|
|
33
|
-
defaultEnabled: true,
|
|
34
|
-
render: () => hostname().split(".")[0] || null,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: "project",
|
|
38
|
-
description: "Project name with current Git branch",
|
|
39
|
-
defaultEnabled: true,
|
|
40
|
-
render(ctx) {
|
|
41
|
-
const name = gitProjectName(dir(ctx)) || dir(ctx).split("/").pop() || null;
|
|
42
|
-
if (!name) return null;
|
|
43
|
-
const branch = gitBranch(dir(ctx));
|
|
44
|
-
return branch ? `${name} (${branch})` : name;
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: "project-name",
|
|
49
|
-
description: "Project name (omitted when unavailable)",
|
|
50
|
-
defaultEnabled: false,
|
|
51
|
-
render: (ctx) => gitProjectName(dir(ctx)) || dir(ctx).split("/").pop() || null,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: "git-branch",
|
|
55
|
-
description: "Current Git branch (omitted when unavailable)",
|
|
56
|
-
defaultEnabled: false,
|
|
57
|
-
render: (ctx) => gitBranch(dir(ctx)),
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: "commit-age",
|
|
61
|
-
description: "Time since last commit (compact)",
|
|
62
|
-
defaultEnabled: true,
|
|
63
|
-
render(ctx) {
|
|
64
|
-
const ts = lastCommitEpoch(dir(ctx));
|
|
65
|
-
if (!ts) return null;
|
|
66
|
-
return compactAge(Date.now() / 1000 - ts);
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: "loc",
|
|
71
|
-
description: "Lines of code tracked by Git (compact)",
|
|
72
|
-
defaultEnabled: true,
|
|
73
|
-
render(ctx) {
|
|
74
|
-
const n = trackedLineCount(dir(ctx));
|
|
75
|
-
return n ? compactNum(n) : null;
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: "current-dir",
|
|
80
|
-
description: "Current working directory (basename)",
|
|
81
|
-
defaultEnabled: false,
|
|
82
|
-
render: (ctx) => dir(ctx).split("/").pop() || null,
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: "model",
|
|
86
|
-
description: "Current model name",
|
|
87
|
-
defaultEnabled: false,
|
|
88
|
-
render(ctx) {
|
|
89
|
-
if (!ctx.model?.id) return null;
|
|
90
|
-
return friendlyModel(ctx.model.id).name;
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: "model-context",
|
|
95
|
-
description: "Model name with context-size tag (e.g. [1m])",
|
|
96
|
-
defaultEnabled: true,
|
|
97
|
-
render(ctx) {
|
|
98
|
-
if (!ctx.model?.id) return null;
|
|
99
|
-
const { name, tag } = friendlyModel(ctx.model.id);
|
|
100
|
-
return tag ? `${name} ${tag}` : name;
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: "context-used",
|
|
105
|
-
description: "Percentage of context window used (omitted when unknown)",
|
|
106
|
-
defaultEnabled: false,
|
|
107
|
-
render(ctx) {
|
|
108
|
-
const u = contextUsage(ctx);
|
|
109
|
-
if (!u) return null;
|
|
110
|
-
return `${Math.min(100, Math.round((u.used / u.window) * 100))}%`;
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: "context-remaining",
|
|
115
|
-
description: "Percentage of context window remaining (omitted when unknown)",
|
|
116
|
-
defaultEnabled: true,
|
|
117
|
-
render(ctx) {
|
|
118
|
-
const u = contextUsage(ctx);
|
|
119
|
-
if (!u) return null;
|
|
120
|
-
return `${Math.max(0, 100 - Math.round((u.used / u.window) * 100))}% left`;
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
id: "used-tokens",
|
|
125
|
-
description: "Total tokens in the context window (omitted when unknown)",
|
|
126
|
-
defaultEnabled: false,
|
|
127
|
-
render(ctx) {
|
|
128
|
-
const u = contextUsage(ctx);
|
|
129
|
-
if (!u) return null;
|
|
130
|
-
return `${compactNum(u.used + u.output)} tok`;
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
id: "cost",
|
|
135
|
-
description: "Session cost in USD (omitted when zero)",
|
|
136
|
-
defaultEnabled: true,
|
|
137
|
-
render(ctx) {
|
|
138
|
-
const c = ctx.cost?.totalCostUsd;
|
|
139
|
-
return c ? money(c) : null;
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
id: "duration",
|
|
144
|
-
description: "Session wall-clock duration",
|
|
145
|
-
defaultEnabled: false,
|
|
146
|
-
render(ctx) {
|
|
147
|
-
const ms = ctx.cost?.totalDurationMs;
|
|
148
|
-
return ms ? compactDuration(ms) : null;
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
id: "lines-changed",
|
|
153
|
-
description: "Lines added/removed this session (omitted when zero)",
|
|
154
|
-
defaultEnabled: false,
|
|
155
|
-
render(ctx) {
|
|
156
|
-
const a = ctx.cost?.totalLinesAdded || 0;
|
|
157
|
-
const r = ctx.cost?.totalLinesRemoved || 0;
|
|
158
|
-
if (!a && !r) return null;
|
|
159
|
-
return `+${a}/-${r}`;
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
id: "output-style",
|
|
164
|
-
description: "Active output style (omitted when default)",
|
|
165
|
-
defaultEnabled: false,
|
|
166
|
-
render(ctx) {
|
|
167
|
-
const s = ctx.outputStyle;
|
|
168
|
-
return s && s !== "default" ? s : null;
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
id: "agent-version",
|
|
173
|
-
description: "Host agent version (e.g. Claude Code version)",
|
|
174
|
-
defaultEnabled: false,
|
|
175
|
-
render: (ctx) => (ctx.version ? `v${ctx.version}` : null),
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
id: "session-id",
|
|
179
|
-
description: "Session identifier (short)",
|
|
180
|
-
defaultEnabled: false,
|
|
181
|
-
render: (ctx) => (ctx.sessionId ? ctx.sessionId.split("-")[0] : null),
|
|
182
|
-
},
|
|
183
|
-
];
|
|
184
|
-
|
|
185
|
-
export function getSegment(id: string): Segment | undefined {
|
|
186
|
-
return segments.find((s) => s.id === id);
|
|
187
|
-
}
|