Skip to content

feat(kun): add Kun CLI usage provider - #251

Open
Legiani wants to merge 1 commit into
chattymin:mainfrom
Legiani:feat/kun-usage-provider
Open

Legiani wants to merge 1 commit into
chattymin:mainfrom
Legiani:feat/kun-usage-provider

Conversation

@Legiani

@Legiani Legiani commented Aug 31, 2026 •

Copy link
Copy Markdown

Summary

Adds Kun CLI (kun) as a 13th local usage source. Kun persists session usage in an SQLite database under ~/.kun/data/index.sqlite3 in the usage_events table with (thread_id, seq, timestamp, model, usage_json).

Key details:

  • Per-turn delta computation: Kun records cumulative session stats in usage_json (promptTokens, completionTokens, cachedTokens, totalTokens, costUsd); the reader calculates per-turn token and cost deltas across sequential events in each thread.
  • Durable roots & environment: Default root is ~/.kun/data/index.sqlite3 with KUN_DATA_DIR override support registered in UsageEnvironment, CustomScanRoots, and tests.
  • Extension contract compliance: Implements UsageProvider and registers in UsageStore.init providers: array without provider-specific logic in generic paths.

Type of change

  • New feature

UI changes

No UI structure changes. Users with a Kun database get a Kun capsule in the provider tab bar and an entry in Settings → Additional scan folders; Kun token usage and cost join today's aggregate totals.

Checklist

  • swift build and swift test pass locally (907 tests, 0 failures)
  • PR title and description are written in English
  • Tests added in KunUsageTests.swift and registry tests updated

@Legiani
Legiani force-pushed the feat/kun-usage-provider branch from 3288410 to 45829f5 Compare August 31, 2026 20:21
@Legiani Legiani changed the title feat(kun): add Kun CLI usage provider and update pricing table feat(kun): add Kun CLI usage provider Aug 31, 2026

@chattymin chattymin left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please preserve already observed usage when Kun threads disappear. Merge cache entries by a stable entry ID, keep the larger cumulative value for an existing thread, and retain previously observed entries that are absent from a later scan instead of replacing the cache wholesale. Please add a regression test proving that deleting a thread cannot reduce historical totals, update the data-source documentation, and rebase onto current main.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants