Skip to content

Commit aee9399

Browse files
committed
Merge branch 'develop'
2 parents 48b32b7 + 24c51c2 commit aee9399

15 files changed

Lines changed: 321 additions & 84 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
node_modules/
22
bun.lock
33
*.log
4+
5+
# OpenCode local data
6+
.opencode/

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.8.0] - 2025-03-01
6+
7+
### Added
8+
9+
- Add detailed token columns to CSV: `tokens_input`, `tokens_output`, `tokens_reasoning`, `tokens_cache_read`, `tokens_cache_write`
10+
- Add `cost` column to CSV tracking session cost in USD (from OpenCode SDK)
11+
- Add `CsvWriter.ensureHeader()` for automatic CSV header management at plugin startup
12+
13+
### Fixed
14+
15+
- Fix CSV header migration: automatically upgrade old 17-column files to 23-column format
16+
- Fix ticket extraction: skip synthetic text parts (file contents, MCP resources) to avoid false positives from example patterns in docs
17+
- Fix empty CSV files created without headers
18+
19+
### Changed
20+
21+
- CSV header is now validated and repaired at plugin startup, not on each write
22+
523
## [0.7.1] - 2025-03-01
624

725
### Fixed

package-lock.json

Lines changed: 87 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@techdivision/opencode-time-tracking",
3-
"version": "0.7.1",
3+
"version": "0.8.0",
44
"description": "Automatic time tracking plugin for OpenCode - tracks session duration and tool usage to CSV",
55
"main": "src/Plugin.ts",
66
"types": "src/Plugin.ts",

src/Plugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ export const plugin: Plugin = async ({
6464
const ticketExtractor = new TicketExtractor(client, config.valid_projects)
6565
const ticketResolver = new TicketResolver(config, ticketExtractor)
6666

67+
// Ensure CSV file has a valid header at startup
68+
await csvWriter.ensureHeader()
69+
6770
const hooks: Hooks = {
6871
"tool.execute.after": createToolExecuteAfterHook(
6972
sessionManager,

src/hooks/EventHook.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ export function createEventHook(
140140
cacheRead: part.tokens.cache.read,
141141
cacheWrite: part.tokens.cache.write,
142142
})
143+
144+
// Track cost from step-finish events
145+
if (part.cost !== undefined) {
146+
sessionManager.addCost(part.sessionID, part.cost)
147+
}
143148
}
144149

145150
return
@@ -224,6 +229,7 @@ export function createEventHook(
224229
description,
225230
notes: `Auto-tracked: ${toolSummary}`,
226231
tokenUsage: session.tokenUsage,
232+
cost: session.cost,
227233
model: modelString,
228234
agent: agentString,
229235
})

0 commit comments

Comments
 (0)