@techdivision/opencode-time-tracking 0.1.4 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +32 -0
- package/README.md +9 -7
- package/package.json +6 -13
- package/src/Plugin.ts +2 -8
- package/src/services/ConfigLoader.ts +12 -5
- package/src/types/TimeTrackingConfig.ts +12 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
id-token: write
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Setup Node.js
|
|
21
|
+
uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: '20'
|
|
24
|
+
registry-url: 'https://registry.npmjs.org'
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
- name: Publish to npm
|
|
30
|
+
run: npm publish --provenance --access public
|
|
31
|
+
env:
|
|
32
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# opencode-time-tracking
|
|
1
|
+
# @techdivision/opencode-time-tracking
|
|
2
2
|
|
|
3
3
|
Automatic time tracking plugin for OpenCode. Tracks session duration and tool usage, writing entries to a CSV file compatible with Jira worklog sync.
|
|
4
4
|
|
|
@@ -8,19 +8,22 @@ Add to your `opencode.json`:
|
|
|
8
8
|
|
|
9
9
|
```json
|
|
10
10
|
{
|
|
11
|
-
"plugin": ["opencode-time-tracking"]
|
|
11
|
+
"plugin": ["@techdivision/opencode-time-tracking"]
|
|
12
12
|
}
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Configuration
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Add the `time_tracking` section to your `.opencode/opencode-project.json`:
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
20
|
{
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
21
|
+
"$schema": "https://raw.githubusercontent.com/techdivision/opencode-plugins/main/schemas/opencode-project.json",
|
|
22
|
+
"time_tracking": {
|
|
23
|
+
"csv_file": "~/time_tracking/time-tracking.csv",
|
|
24
|
+
"user_email": "your@email.com",
|
|
25
|
+
"default_account_key": "YOUR_ACCOUNT_KEY"
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
```
|
|
26
29
|
|
|
@@ -42,4 +45,3 @@ id,start_date,end_date,user,ticket_name,issue_key,account_key,start_time,end_tim
|
|
|
42
45
|
| Event | When triggered |
|
|
43
46
|
|-------|----------------|
|
|
44
47
|
| `session.idle` | After each complete AI response (including all tool calls) |
|
|
45
|
-
| `session.deleted` | When a session is explicitly deleted |
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techdivision/opencode-time-tracking",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Automatic time tracking plugin for OpenCode - tracks session duration and tool usage to CSV",
|
|
5
5
|
"main": "src/Plugin.ts",
|
|
6
6
|
"types": "src/Plugin.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/techdivision/opencode-time-tracking"
|
|
10
|
+
},
|
|
7
11
|
"keywords": [
|
|
8
12
|
"opencode",
|
|
9
13
|
"plugin",
|
|
@@ -22,16 +26,5 @@
|
|
|
22
26
|
},
|
|
23
27
|
"peerDependencies": {
|
|
24
28
|
"bun": ">=1.0.0"
|
|
25
|
-
}
|
|
26
|
-
"scripts": {
|
|
27
|
-
"test": "npm test"
|
|
28
|
-
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/techdivision/opencode-time-tracking.git"
|
|
32
|
-
},
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/techdivision/opencode-time-tracking/issues"
|
|
35
|
-
},
|
|
36
|
-
"homepage": "https://github.com/techdivision/opencode-time-tracking#readme"
|
|
29
|
+
}
|
|
37
30
|
}
|
package/src/Plugin.ts
CHANGED
|
@@ -47,14 +47,8 @@ export const plugin: Plugin = async ({
|
|
|
47
47
|
const config = await ConfigLoader.load(directory)
|
|
48
48
|
|
|
49
49
|
if (!config) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
message:
|
|
53
|
-
"Time Tracking: No config found. Run /init-time-tracking to create one.",
|
|
54
|
-
variant: "warning",
|
|
55
|
-
},
|
|
56
|
-
})
|
|
57
|
-
|
|
50
|
+
// Silently return empty hooks if no config found
|
|
51
|
+
// Toast notifications don't work during plugin initialization
|
|
58
52
|
return {}
|
|
59
53
|
}
|
|
60
54
|
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* @fileoverview Configuration loader for the time tracking plugin.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
OpencodeProjectConfig,
|
|
7
|
+
TimeTrackingConfig,
|
|
8
|
+
} from "../types/TimeTrackingConfig"
|
|
6
9
|
|
|
7
10
|
import "../types/Bun"
|
|
8
11
|
|
|
@@ -10,8 +13,8 @@ import "../types/Bun"
|
|
|
10
13
|
* Loads the plugin configuration from the project directory.
|
|
11
14
|
*
|
|
12
15
|
* @remarks
|
|
13
|
-
* The configuration file is expected at `.opencode/
|
|
14
|
-
* within the project directory.
|
|
16
|
+
* The configuration file is expected at `.opencode/opencode-project.json`
|
|
17
|
+
* within the project directory, with a `time_tracking` section.
|
|
15
18
|
*/
|
|
16
19
|
export class ConfigLoader {
|
|
17
20
|
/**
|
|
@@ -29,13 +32,17 @@ export class ConfigLoader {
|
|
|
29
32
|
* ```
|
|
30
33
|
*/
|
|
31
34
|
static async load(directory: string): Promise<TimeTrackingConfig | null> {
|
|
32
|
-
const configPath = `${directory}/.opencode/
|
|
35
|
+
const configPath = `${directory}/.opencode/opencode-project.json`
|
|
33
36
|
|
|
34
37
|
try {
|
|
35
38
|
const file = Bun.file(configPath)
|
|
36
39
|
|
|
37
40
|
if (await file.exists()) {
|
|
38
|
-
|
|
41
|
+
const projectConfig = (await file.json()) as OpencodeProjectConfig
|
|
42
|
+
|
|
43
|
+
if (projectConfig.time_tracking) {
|
|
44
|
+
return projectConfig.time_tracking
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
return null
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Time tracking configuration from `.opencode/opencode-project.json`.
|
|
7
7
|
*/
|
|
8
8
|
export interface TimeTrackingConfig {
|
|
9
9
|
/**
|
|
@@ -23,3 +23,14 @@ export interface TimeTrackingConfig {
|
|
|
23
23
|
/** Default Jira account key for time entries */
|
|
24
24
|
default_account_key: string
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* OpenCode project configuration structure.
|
|
29
|
+
*/
|
|
30
|
+
export interface OpencodeProjectConfig {
|
|
31
|
+
/** JSON Schema reference */
|
|
32
|
+
$schema?: string
|
|
33
|
+
|
|
34
|
+
/** Time tracking configuration */
|
|
35
|
+
time_tracking?: TimeTrackingConfig
|
|
36
|
+
}
|