@hasna/statusline 0.0.7 → 0.0.9
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 +98 -31
- package/dist/cli.js +429 -62
- package/dist/context-window.d.ts +22 -0
- package/dist/disk.d.ts +51 -0
- package/dist/format.d.ts +7 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +435 -63
- package/dist/mcp/index.js +19939 -6483
- package/dist/providers/codex.d.ts +19 -0
- package/dist/providers/opencode.d.ts +16 -0
- package/dist/providers/types.d.ts +10 -3
- package/package.json +10 -8
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The cumulative token usage Codex reports on its `token_count` events. */
|
|
2
|
+
export interface TotalTokenUsage {
|
|
3
|
+
input_tokens?: number;
|
|
4
|
+
cached_input_tokens?: number;
|
|
5
|
+
cache_write_input_tokens?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Newest `rollout-*.jsonl` under `~/.codex/sessions/YYYY/MM/DD/` — the
|
|
9
|
+
* session with the latest activity, by file mtime. Null when nothing exists
|
|
10
|
+
* or the tree cannot be read (statusline degrade rule: never throw).
|
|
11
|
+
*/
|
|
12
|
+
export declare function latestCodexSessionPath(home?: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Cache-hit fraction of the newest Codex session: the LAST `event_msg` whose
|
|
15
|
+
* payload is a `token_count`, whose `payload.info.total_token_usage` holds
|
|
16
|
+
* cumulative session totals. Clamped to [0, 1]; null when the file is
|
|
17
|
+
* missing or unreadable, no token_count event exists, or the divisor is 0.
|
|
18
|
+
*/
|
|
19
|
+
export declare function codexCacheRate(sessionPath?: string): number | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface OpenCodeCacheRateOptions {
|
|
2
|
+
/** Path to the OpenCode sessions DB (default `~/.local/share/opencode/opencode.db`). */
|
|
3
|
+
dbPath?: string;
|
|
4
|
+
/** A specific session id; omitted = the newest session with usage. */
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Cache-hit fraction from the OpenCode sessions DB: the newest session row's
|
|
9
|
+
* `tokens_cache_read` over the input side (input + cache read + cache write).
|
|
10
|
+
* Read-only `Bun.sqlite` (runtime-available in the bun-target CLI build; no
|
|
11
|
+
* new dependency). Never throws — any open/query failure, a missing file, or
|
|
12
|
+
* a zero divisor degrades to null. When the `session` table has no row with
|
|
13
|
+
* token data (older layouts, or an in-flight session whose usage is not
|
|
14
|
+
* written yet), `session_v2` is tried — both schemas carry the columns.
|
|
15
|
+
*/
|
|
16
|
+
export declare function opencodeCacheRate(opts?: OpenCodeCacheRateOptions): number | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface StatusContext {
|
|
2
|
-
provider: "claude";
|
|
2
|
+
provider: "claude" | "codex" | "opencode";
|
|
3
3
|
cwd: string;
|
|
4
4
|
projectDir?: string;
|
|
5
5
|
model?: {
|
|
@@ -34,6 +34,13 @@ export interface StatusContext {
|
|
|
34
34
|
}
|
|
35
35
|
/** ANSI hints a segment can ask the renderer for. */
|
|
36
36
|
export type SegmentColor = "cyan" | "magenta" | "blue" | "green" | "yellow" | "red" | "bold" | "dim";
|
|
37
|
+
/**
|
|
38
|
+
* Scratch belonging to one `renderLine` call. It is passed to a segment's
|
|
39
|
+
* `render` and to its `color`, so a value read once can colour the text it
|
|
40
|
+
* produced without a second read. It dies with that render: there is no
|
|
41
|
+
* cross-render cache and no stale figure to show.
|
|
42
|
+
*/
|
|
43
|
+
export type RenderMemo = Map<symbol, unknown>;
|
|
37
44
|
export interface Segment {
|
|
38
45
|
id: string;
|
|
39
46
|
description: string;
|
|
@@ -42,6 +49,6 @@ export interface Segment {
|
|
|
42
49
|
* Colour applied by the renderer when colours are on. A function lets a
|
|
43
50
|
* segment escalate with its value (e.g. a limit gauge turning red).
|
|
44
51
|
*/
|
|
45
|
-
color?: SegmentColor | ((ctx: StatusContext) => SegmentColor | null);
|
|
46
|
-
render(ctx: StatusContext): Promise<string | null> | string | null;
|
|
52
|
+
color?: SegmentColor | ((ctx: StatusContext, memo?: RenderMemo) => SegmentColor | null);
|
|
53
|
+
render(ctx: StatusContext, memo?: RenderMemo): Promise<string | null> | string | null;
|
|
47
54
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/statusline",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Tiny composable statusline CLI for AI coding agents
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"description": "Tiny composable statusline CLI for AI coding agents — pre-built toggleable segments for Claude Code, with a provider model for others",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -39,11 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
|
-
"url": "
|
|
42
|
+
"url": "https://github.com/hasna/apps.git",
|
|
43
|
+
"directory": "apps/statusline"
|
|
43
44
|
},
|
|
44
|
-
"homepage": "https://github.com/hasna/statusline#readme",
|
|
45
|
+
"homepage": "https://github.com/hasna/apps/tree/main/apps/statusline#readme",
|
|
45
46
|
"bugs": {
|
|
46
|
-
"url": "https://github.com/hasna/
|
|
47
|
+
"url": "https://github.com/hasna/apps/issues"
|
|
47
48
|
},
|
|
48
49
|
"keywords": [
|
|
49
50
|
"statusline",
|
|
@@ -60,11 +61,12 @@
|
|
|
60
61
|
"bun": ">=1.0.0"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
|
-
"@modelcontextprotocol/sdk": "1.
|
|
64
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
64
65
|
"zod": "3.25.76"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"@types/bun": "
|
|
68
|
-
"typescript": "5.9.3"
|
|
68
|
+
"@types/bun": "1.3.14",
|
|
69
|
+
"typescript": "5.9.3",
|
|
70
|
+
"bun-types": "1.3.14"
|
|
69
71
|
}
|
|
70
72
|
}
|