Files
wehub-resource-sync 26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:30 +08:00

60 lines
1.2 KiB
Lua

local M = {}
local stats_path = vim.fn.expand("~/.lean-ctx/stats.json")
local timer = nil
local current_text = "⚡ lean-ctx"
local function format_tokens(n)
if n >= 1000000 then
return string.format("%.1fM", n / 1000000)
elseif n >= 1000 then
return string.format("%.1fK", n / 1000)
else
return tostring(n)
end
end
local function read_stats()
local f = io.open(stats_path, "r")
if not f then
return nil
end
local content = f:read("*a")
f:close()
local tokens = content:match('"total_input_tokens"%s*:%s*(%d+)')
local commands = content:match('"total_commands"%s*:%s*(%d+)')
if tokens then
return {
tokens_saved = tonumber(tokens) or 0,
commands = tonumber(commands) or 0,
}
end
return nil
end
local function update()
local s = read_stats()
if s and s.tokens_saved > 0 then
current_text = "⚡ " .. format_tokens(s.tokens_saved) .. " saved"
else
current_text = "⚡ lean-ctx"
end
end
function M.start_refresh(interval_ms)
update()
if timer then
timer:stop()
end
timer = vim.uv.new_timer()
timer:start(interval_ms, interval_ms, vim.schedule_wrap(update))
end
function M.statusline_text()
return current_text
end
return M