meter-ai 0.1.2 → 0.3.0
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/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +74 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/wrap.d.ts.map +1 -1
- package/dist/commands/wrap.js +23 -2
- package/dist/commands/wrap.js.map +1 -1
- package/dist/pty/wrapper.d.ts +9 -8
- package/dist/pty/wrapper.d.ts.map +1 -1
- package/dist/pty/wrapper.js +39 -14
- package/dist/pty/wrapper.js.map +1 -1
- package/package.json +1 -1
- package/src/auth/credentials.ts +44 -0
- package/src/auth/detect.ts +24 -0
- package/src/commands/config.ts +19 -0
- package/src/commands/history.ts +16 -0
- package/src/commands/init.ts +149 -0
- package/src/commands/report.ts +27 -0
- package/src/commands/status.ts +16 -0
- package/src/commands/uninstall.ts +20 -0
- package/src/commands/wrap.ts +235 -0
- package/src/constants.ts +52 -0
- package/src/estimation/heuristics.ts +36 -0
- package/src/estimation/history-matcher.ts +43 -0
- package/src/estimation/llm-precheck.ts +27 -0
- package/src/estimation/pipeline.ts +67 -0
- package/src/hooks/on-prompt.js +92 -0
- package/src/hooks/statusline.js +36 -0
- package/src/index.ts +50 -0
- package/src/pty/resize.ts +15 -0
- package/src/pty/screen.ts +15 -0
- package/src/pty/wrapper.ts +143 -0
- package/src/shell/binary-resolver.ts +21 -0
- package/src/shell/detect.ts +33 -0
- package/src/shell/path-inject.ts +31 -0
- package/src/shell/shim-writer.ts +28 -0
- package/src/storage/config-store.ts +46 -0
- package/src/storage/db.ts +63 -0
- package/src/tracking/cost.ts +7 -0
- package/src/tracking/plan-usage.ts +57 -0
- package/src/tracking/tokens.ts +16 -0
- package/src/types.ts +73 -0
- package/src/ui/keypress.ts +27 -0
- package/src/ui/notification.ts +31 -0
- package/src/ui/statusbar.ts +74 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import ansiEscapes from 'ansi-escapes'
|
|
2
|
+
import type { Complexity, UserMode } from '../types.js'
|
|
3
|
+
|
|
4
|
+
export interface StatusBarState {
|
|
5
|
+
model: string
|
|
6
|
+
estimatedCost: number | null
|
|
7
|
+
complexity: Complexity | null
|
|
8
|
+
mode: UserMode
|
|
9
|
+
elapsedCost: number | null
|
|
10
|
+
budgetUsd: number | null
|
|
11
|
+
windowPct: number | null
|
|
12
|
+
windowResetIn: string | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const RESET = '\x1b[0m'
|
|
16
|
+
const DIM = '\x1b[2m'
|
|
17
|
+
const BOLD = '\x1b[1m'
|
|
18
|
+
const YELLOW = '\x1b[33m'
|
|
19
|
+
const RED = '\x1b[31m'
|
|
20
|
+
const GREEN = '\x1b[32m'
|
|
21
|
+
const CYAN = '\x1b[36m'
|
|
22
|
+
|
|
23
|
+
function progressBar(pct: number, width = 12): string {
|
|
24
|
+
const filled = Math.round((pct / 100) * width)
|
|
25
|
+
const empty = width - filled
|
|
26
|
+
const color = pct >= 80 ? RED : pct >= 60 ? YELLOW : GREEN
|
|
27
|
+
return `${color}${'█'.repeat(filled)}${DIM}${'░'.repeat(empty)}${RESET}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function renderStatusBar(state: StatusBarState): string {
|
|
31
|
+
const parts: string[] = [`${CYAN}◆ meter${RESET}`, `${BOLD}${state.model}${RESET}`]
|
|
32
|
+
|
|
33
|
+
if (state.estimatedCost !== null) {
|
|
34
|
+
parts.push(`${DIM}~$${state.estimatedCost.toFixed(2)}${RESET}`)
|
|
35
|
+
}
|
|
36
|
+
if (state.complexity) {
|
|
37
|
+
parts.push(`${DIM}${state.complexity}${RESET}`)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
parts.push('│')
|
|
41
|
+
|
|
42
|
+
if (state.mode === 'api' && state.elapsedCost !== null && state.budgetUsd !== null) {
|
|
43
|
+
const pct = (state.elapsedCost / state.budgetUsd) * 100
|
|
44
|
+
parts.push(progressBar(pct))
|
|
45
|
+
parts.push(`$${state.elapsedCost.toFixed(2)} / $${state.budgetUsd.toFixed(2)}`)
|
|
46
|
+
} else if (state.mode === 'plan' && state.windowPct !== null) {
|
|
47
|
+
parts.push(progressBar(state.windowPct))
|
|
48
|
+
parts.push(`${state.windowPct}% 5hr window`)
|
|
49
|
+
if (state.windowResetIn) parts.push(`${DIM}reset in ${state.windowResetIn}${RESET}`)
|
|
50
|
+
} else {
|
|
51
|
+
parts.push(`${DIM}usage unavailable${RESET}`)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return parts.join(' ')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function injectStatusBar(content: string, linesAbove: number): void {
|
|
58
|
+
process.stdout.write(
|
|
59
|
+
ansiEscapes.cursorSavePosition +
|
|
60
|
+
ansiEscapes.cursorUp(linesAbove) +
|
|
61
|
+
ansiEscapes.eraseLine +
|
|
62
|
+
content +
|
|
63
|
+
ansiEscapes.cursorRestorePosition
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function clearStatusBar(linesAbove: number): void {
|
|
68
|
+
process.stdout.write(
|
|
69
|
+
ansiEscapes.cursorSavePosition +
|
|
70
|
+
ansiEscapes.cursorUp(linesAbove) +
|
|
71
|
+
ansiEscapes.eraseLine +
|
|
72
|
+
ansiEscapes.cursorRestorePosition
|
|
73
|
+
)
|
|
74
|
+
}
|