2.4 KiB
2.4 KiB
id, title, status, wave, depends_on, plan, spec, adr
| id | title | status | wave | depends_on | plan | spec | adr | ||
|---|---|---|---|---|---|---|---|---|---|
| 05-rewrite-agent-stats-plugin | Rewrite kandev-plugin-agent-stats to use the SDK data API | done | 4 |
|
plan.md | ../../../specs/plugins/requirements/plugins.md | ../../../decisions/0043-plugin-host-data-api.md |
Task 05: Rewrite kandev-plugin-agent-stats to use the SDK data API
The proof the carrot is sufficient: replace the agent-stats plugin's direct SQLite
access with the Host data API. This is a separate repository at
/home/jcfs/.kandev/tasks/tokens-per-task-loc_9tk/kandev-plugin-agent-stats/ — do
not vendor it into the kandev repo; reference it.
Scope
- Delete
readSessions+sessionsQueryand themodernc.org/sqlitedependency fromserver/stats.go. Stop opening~/.kandev/data/kandev.db. - Fetch sessions via
host.Sessions().List(...)and per-session LOC viahost.Sessions().CodeStats(...). Map the returnedSession+SessionCodeStatsinto the existingsessionRowshape (agent display, model,acp_session_id, committed + peak-pending lines). - Keep
effectiveLinessemantics (max of committed and peak-pending) on the DTO fields; keep the tokscale join onacp_session_idunchanged (external tool, unaffected). - Declare
capabilities.api_read: ["sessions"]in the pluginmanifest.yaml. - Remove the
KANDEV_AGENT_STATS_DBconfig path (no DB path needed); keep the tokscale override.
Acceptance
- The plugin no longer imports a SQLite driver or opens any kandev DB file.
- Stats report still renders sessions + LOC + tokscale ratios using data obtained solely through the Host data API.
manifest.yamldeclaresapi_read: ["sessions"].
Verification
- In the plugin repo:
go build ./...and its existinggo test ./....
Files likely touched (separate repo)
.../kandev-plugin-agent-stats/server/stats.go.../kandev-plugin-agent-stats/server/plugin.go.../kandev-plugin-agent-stats/manifest.yaml.../kandev-plugin-agent-stats/go.mod(drop sqlite dep)
Inputs
- SDK data accessors from task-03; live host impl from task-04.
- Current plugin:
server/stats.go(sessionRow,aggregate,effectiveLines),server/plugin.go(loadConfig,collect).
Dependencies
Tasks 03, 04.
Output contract
Summary, confirmation the SQLite import is gone, mapping notes (DTO →
sessionRow), build/test result, and status update here + in plan.md.