Skip to content

Commit 6746ff9

Browse files
authored
Merge pull request #14 from techdivision/develop
Release v0.6.0
2 parents faa1ff7 + 5711255 commit 6746ff9

7 files changed

Lines changed: 177 additions & 32 deletions

File tree

AGENTS.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ src/
3333
│ ├── ConfigLoader.ts # Load plugin configuration
3434
│ ├── CsvWriter.ts # CSV file output
3535
│ ├── SessionManager.ts # Session state management
36-
│ └── TicketExtractor.ts # Extract tickets from messages/todos
36+
│ ├── TicketExtractor.ts # Extract tickets from messages/todos
37+
│ └── TicketResolver.ts # Resolve tickets with fallback hierarchy
3738
├── types/ # TypeScript interfaces (one per file)
3839
│ ├── ActivityData.ts
3940
│ ├── SessionData.ts
@@ -196,16 +197,22 @@ export default plugin
196197

197198
## Configuration
198199

199-
Plugin config file: `.opencode/time-tracking.json`
200+
Plugin config file: `.opencode/opencode-project.json`
200201

201202
```json
202203
{
203-
"csv_file": "~/worklogs/time.csv",
204-
"user_email": "user@example.com",
205-
"default_account_key": "ACCOUNT-1"
204+
"time_tracking": {
205+
"csv_file": "~/worklogs/time.csv",
206+
"global_default": {
207+
"issue_key": "PROJ-MISC",
208+
"account_key": "ACCOUNT-1"
209+
}
210+
}
206211
}
207212
```
208213

214+
User email is resolved from `OPENCODE_USER_EMAIL` environment variable or system username.
215+
209216
## Git Workflow (Gitflow)
210217

211218
This project follows **Gitflow**:

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.6.0] - 2025-01-31
6+
7+
### Breaking Changes
8+
9+
- **Config:** `default_account_key` removed from top-level config
10+
- **Config:** `global_default` is now required (was optional)
11+
- **Config:** `global_default.account_key` is now required (was optional)
12+
13+
### Migration
14+
15+
Update your `.opencode/opencode-project.json`:
16+
17+
**Before (0.5.x):**
18+
```json
19+
{
20+
"time_tracking": {
21+
"csv_file": "...",
22+
"default_account_key": "TD_KS_1100",
23+
"global_default": {
24+
"issue_key": "PROJ-123"
25+
}
26+
}
27+
}
28+
```
29+
30+
**After (0.6.0):**
31+
```json
32+
{
33+
"time_tracking": {
34+
"csv_file": "...",
35+
"global_default": {
36+
"issue_key": "PROJ-123",
37+
"account_key": "TD_KS_1100"
38+
}
39+
}
40+
}
41+
```
42+
43+
Run `/time-tracking.init` to automatically migrate your configuration.
44+
45+
## [0.5.0] - 2025-01-28
46+
47+
### Added
48+
49+
- Initial release
50+
- Automatic session tracking with ticket extraction
51+
- CSV export for time entries
52+
- Agent-specific default tickets
53+
- Global fallback configuration
54+
- Ignored agents support

README.md

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ Add the `time_tracking` section to your `.opencode/opencode-project.json`:
2323
"$schema": "https://raw.githubusercontent.com/techdivision/opencode-plugins/main/schemas/opencode-project.json",
2424
"time_tracking": {
2525
"csv_file": "~/time_tracking/time-tracking.csv",
26-
"default_account_key": "YOUR_ACCOUNT_KEY"
26+
"global_default": {
27+
"issue_key": "PROJ-MISC",
28+
"account_key": "YOUR_ACCOUNT_KEY"
29+
}
2730
}
2831
}
2932
```
@@ -46,11 +49,100 @@ export OPENCODE_USER_EMAIL=your@email.com
4649

4750
If not set, the system username is used as fallback.
4851

52+
## Configuration Options
53+
54+
### Required Fields
55+
56+
| Field | Description |
57+
|-------|-------------|
58+
| `csv_file` | Path to the CSV output file (supports `~/`, absolute, or relative paths) |
59+
| `global_default.issue_key` | Default JIRA issue key when no ticket found in context |
60+
| `global_default.account_key` | Default Tempo account key for time entries |
61+
62+
### Optional Fields
63+
64+
#### Agent-specific Defaults
65+
66+
Override default ticket/account for specific agents:
67+
68+
```json
69+
{
70+
"time_tracking": {
71+
"csv_file": "...",
72+
"global_default": {
73+
"issue_key": "PROJ-MISC",
74+
"account_key": "TD_GENERAL"
75+
},
76+
"agent_defaults": {
77+
"@developer": {
78+
"issue_key": "PROJ-DEV",
79+
"account_key": "TD_DEVELOPMENT"
80+
},
81+
"@reviewer": {
82+
"issue_key": "PROJ-REVIEW"
83+
}
84+
}
85+
}
86+
}
87+
```
88+
89+
#### Ignored Agents
90+
91+
Skip time tracking for specific agents:
92+
93+
```json
94+
{
95+
"time_tracking": {
96+
"csv_file": "...",
97+
"global_default": { ... },
98+
"ignored_agents": ["@internal", "@notrack"]
99+
}
100+
}
101+
```
102+
103+
### Full Example
104+
105+
```json
106+
{
107+
"$schema": "https://raw.githubusercontent.com/techdivision/opencode-plugins/main/schemas/opencode-project.json",
108+
"time_tracking": {
109+
"csv_file": "~/time_tracking/time-tracking.csv",
110+
"global_default": {
111+
"issue_key": "PROJ-MISC",
112+
"account_key": "TD_GENERAL"
113+
},
114+
"agent_defaults": {
115+
"@developer": {
116+
"issue_key": "PROJ-DEV",
117+
"account_key": "TD_DEVELOPMENT"
118+
},
119+
"@reviewer": {
120+
"issue_key": "PROJ-REVIEW"
121+
}
122+
},
123+
"ignored_agents": ["@internal"]
124+
}
125+
}
126+
```
127+
128+
## Fallback Hierarchy
129+
130+
### Ticket Resolution
131+
132+
1. Context ticket (from messages/todos)
133+
2. Agent-specific `issue_key` (if configured)
134+
3. `global_default.issue_key`
135+
136+
### Account Key Resolution
137+
138+
1. Agent-specific `account_key` (if configured)
139+
2. `global_default.account_key`
140+
49141
## How it works
50142

51143
- Tracks tool executions during each session turn
52-
- Extracts JIRA ticket from git branch name (e.g., `feature/PROJ-123-description`)
53-
- Writes CSV entry when session becomes idle (after each complete response)
144+
- Extracts JIRA ticket from user messages or todos
145+
- Writes CSV entry when session becomes idle
54146
- Shows toast notification with tracked time
55147

56148
## CSV Format

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.5.0",
3+
"version": "0.6.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/services/TicketResolver.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import type { TicketExtractor } from "./TicketExtractor"
1818
*
1919
* Account key fallback hierarchy:
2020
* 1. Agent-specific account_key
21-
* 2. Global default account_key
22-
* 3. default_account_key from config
21+
* 2. Global default account_key (required)
2322
*/
2423
export class TicketResolver {
2524
/** Plugin configuration */
@@ -101,12 +100,7 @@ export class TicketResolver {
101100
return this.config.agent_defaults[agentName].account_key!
102101
}
103102

104-
// 2. Global default account_key
105-
if (this.config.global_default?.account_key) {
106-
return this.config.global_default.account_key
107-
}
108-
109-
// 3. Config default
110-
return this.config.default_account_key
103+
// 2. Global default account_key (required)
104+
return this.config.global_default.account_key
111105
}
112106
}

src/types/GlobalDefaultConfig.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ export interface GlobalDefaultConfig {
1919
issue_key: string
2020

2121
/**
22-
* Optional Tempo Account Key.
22+
* Default Tempo Account Key.
2323
*
2424
* @remarks
25-
* If not set, falls back to `default_account_key`.
25+
* Required. Used as the default account for all time entries
26+
* unless overridden by agent-specific configuration.
2627
*/
27-
account_key?: string
28+
account_key: string
2829
}

src/types/TimeTrackingConfig.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,23 @@ export interface TimeTrackingJsonConfig {
2525
*/
2626
csv_file: string
2727

28-
/** Default Jira account key for time entries */
29-
default_account_key: string
30-
3128
/**
32-
* Agent-specific default tickets.
29+
* Global fallback ticket and account configuration.
3330
*
3431
* @remarks
35-
* Map of agent names (e.g., "@developer", "@reviewer") to their
36-
* default ticket configuration. Used when no ticket is found in context.
32+
* Required. Contains the default issue_key and account_key used when
33+
* no ticket is found in context and no agent-specific default is configured.
3734
*/
38-
agent_defaults?: Record<string, AgentDefaultConfig>
35+
global_default: GlobalDefaultConfig
3936

4037
/**
41-
* Global fallback ticket configuration.
38+
* Agent-specific default tickets.
4239
*
4340
* @remarks
44-
* Used when no ticket is found in context and no agent-specific
45-
* default is configured.
41+
* Map of agent names (e.g., "@developer", "@reviewer") to their
42+
* default ticket configuration. Used when no ticket is found in context.
4643
*/
47-
global_default?: GlobalDefaultConfig
44+
agent_defaults?: Record<string, AgentDefaultConfig>
4845

4946
/**
5047
* List of agent names to ignore for time tracking.

0 commit comments

Comments
 (0)