Skip to content

Commit e57802c

Browse files
committed
Merge develop into main for v1.2.0 release
2 parents f3715af + 831a63a commit e57802c

6 files changed

Lines changed: 72 additions & 3 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules/
22
.opencode/
3-
*.js
43
.DS_Store
54
bun.lock

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.2.0] - 2026-03-01
9+
10+
### Added
11+
12+
- Postlink hook (`scripts/postlink.js`) that automatically creates `~/time_tracking/` with subdirectories (`bookings/`, `charts/`, `reports/`) and symlinks `.opencode/time_tracking``~/time_tracking` when the plugin is linked
13+
- `scripts/` directory included in npm package for hook distribution
14+
15+
### Changed
16+
17+
- Removed `*.js` from `.gitignore` (no build step, Bun loads `.ts` directly)
18+
- `plugin.json` now declares `hooks.postlink` for the linker
19+
820
## [1.1.0] - 2026-03-01
921

1022
### Added

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ npx opencode-link shell-env
5252
npx opencode-link time-tracking
5353
```
5454

55+
When linking `time-tracking`, a postlink hook automatically:
56+
57+
1. Creates `~/time_tracking/` with subdirectories (`bookings/`, `charts/`, `reports/`)
58+
2. Symlinks `.opencode/time_tracking``~/time_tracking`
59+
60+
This ensures time tracking data is stored globally in your home directory and shared across projects. If `~/time_tracking/` already exists, the hook only creates missing subdirectories. If `.opencode/time_tracking` is a real directory (not a symlink), it is left untouched.
61+
5562
## Configuration
5663

5764
### 1. Project Configuration

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@techdivision/opencode-plugin-time-tracking",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Automatic time tracking plugin for OpenCode. Tracks session duration and tool usage, writing entries to a CSV file compatible with Jira worklog sync incl. commands, skills and agents.",
55
"type": "module",
66
"main": "src/Plugin.ts",
@@ -11,6 +11,7 @@
1111
"agents/",
1212
"commands/",
1313
"tools/",
14+
"scripts/",
1415
"plugin.json"
1516
],
1617
"keywords": ["opencode", "plugin", "time-tracking", "jira", "tempo"],

plugin.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"name": "time-tracking",
33
"description": "Automatic time tracking plugin for OpenCode. Tracks session duration and tool usage, writing entries to a CSV file compatible with Jira worklog sync incl. commands, skills and agents.",
44
"category": "standard",
5-
"version": "1.0.0"
5+
"version": "1.2.0",
6+
"hooks": {
7+
"postlink": "scripts/postlink.js"
8+
}
69
}

scripts/postlink.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
/**
5+
* Postlink hook for time-tracking plugin.
6+
*
7+
* Creates ~/time_tracking directory with required subdirectories
8+
* and symlinks .opencode/time_tracking -> ~/time_tracking so that
9+
* time tracking data is stored globally and shared across projects.
10+
*/
11+
export default function postlink({ targetDir, homeDir, log }) {
12+
const timeTrackingDir = path.join(homeDir, 'time_tracking');
13+
const symlinkPath = path.join(targetDir, 'time_tracking');
14+
15+
// 1. Create ~/time_tracking + subdirs if missing
16+
for (const subdir of ['', 'bookings', 'charts', 'reports']) {
17+
const dirPath = path.join(timeTrackingDir, subdir);
18+
if (!fs.existsSync(dirPath)) {
19+
fs.mkdirSync(dirPath, { recursive: true });
20+
log.success(`Created ${dirPath.replace(homeDir, '~')}`);
21+
}
22+
}
23+
24+
// 2. Symlink .opencode/time_tracking -> ~/time_tracking
25+
let targetExists = false;
26+
let targetIsSymlink = false;
27+
try {
28+
const stat = fs.lstatSync(symlinkPath);
29+
targetExists = true;
30+
targetIsSymlink = stat.isSymbolicLink();
31+
} catch {
32+
targetExists = false;
33+
}
34+
35+
if (targetExists && targetIsSymlink) {
36+
const existing = fs.readlinkSync(symlinkPath);
37+
if (existing === timeTrackingDir) return; // already correct
38+
fs.unlinkSync(symlinkPath);
39+
fs.symlinkSync(timeTrackingDir, symlinkPath);
40+
log.warning(`time_tracking -> ~/time_tracking (overridden)`);
41+
} else if (targetExists) {
42+
log.warning(`time_tracking (real directory, not overriding)`);
43+
} else {
44+
fs.symlinkSync(timeTrackingDir, symlinkPath);
45+
log.success(`time_tracking -> ~/time_tracking`);
46+
}
47+
}

0 commit comments

Comments
 (0)