codex-wakatime 1.0.1 → 1.1.0

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.
Files changed (2) hide show
  1. package/dist/index.cjs +40 -15
  2. package/package.json +10 -2
package/dist/index.cjs CHANGED
@@ -279,16 +279,17 @@ var path7 = __toESM(require("node:path"), 1);
279
279
 
280
280
  // src/extractor.ts
281
281
  var path = __toESM(require("node:path"), 1);
282
- var PATTERNS = [
282
+ var READ_PATTERNS = [
283
283
  // Code block headers: ```typescript:src/index.ts or ```ts:src/index.ts
284
284
  /```\w*:([^\n`]+)/g,
285
285
  // Backtick paths with extension: `src/foo/bar.ts`
286
286
  /`([^`\s]+\.\w{1,6})`/g,
287
- // Action patterns: Read/List/Created/Modified/Updated/Wrote/Edited/Deleted file.ts
288
- /(?:Read|List|Create|Created|Modify|Modified|Update|Updated|Write|Wrote|Edit|Edited|Delete|Deleted)\s+`?([^\s`\n]+\.\w{1,6})`?/gi,
289
287
  // File path in quotes: "src/file.ts" or 'src/file.ts'
290
- /["']([^"'\s]+\.\w{1,6})["']/g
288
+ /["']([^"'\s]+\.\w{1,6})["']/g,
289
+ // Read action patterns: Read/List file.ts
290
+ /(?:Read|List)\s+`?([^\s`\n]+\.\w{1,6})`?/gi
291
291
  ];
292
+ var WRITE_PATTERN = /(?:Create|Created|Modify|Modified|Update|Updated|Write|Wrote|Edit|Edited|Delete|Deleted)\s+`?([^\s`\n]+\.\w{1,6})`?/gi;
292
293
  function isValidFilePath(p) {
293
294
  if (!p || p.length === 0) return false;
294
295
  if (p.startsWith("http://") || p.startsWith("https://") || p.includes("://"))
@@ -306,22 +307,35 @@ function normalizePath(filePath, cwd) {
306
307
  }
307
308
  return path.normalize(path.join(cwd, cleaned));
308
309
  }
309
- function extractFilePaths(message, cwd) {
310
+ function extractFiles(message, cwd) {
310
311
  if (!message || message.length === 0) {
311
312
  return [];
312
313
  }
313
- const files = /* @__PURE__ */ new Set();
314
- for (const pattern of PATTERNS) {
314
+ const fileMap = /* @__PURE__ */ new Map();
315
+ WRITE_PATTERN.lastIndex = 0;
316
+ for (const match of message.matchAll(WRITE_PATTERN)) {
317
+ const filePath = match[1];
318
+ if (filePath && isValidFilePath(filePath)) {
319
+ const normalized = normalizePath(filePath, cwd);
320
+ fileMap.set(normalized, true);
321
+ }
322
+ }
323
+ for (const pattern of READ_PATTERNS) {
315
324
  pattern.lastIndex = 0;
316
325
  for (const match of message.matchAll(pattern)) {
317
326
  const filePath = match[1];
318
327
  if (filePath && isValidFilePath(filePath)) {
319
328
  const normalized = normalizePath(filePath, cwd);
320
- files.add(normalized);
329
+ if (!fileMap.has(normalized)) {
330
+ fileMap.set(normalized, false);
331
+ }
321
332
  }
322
333
  }
323
334
  }
324
- return Array.from(files);
335
+ return Array.from(fileMap.entries()).map(([filePath, isWrite]) => ({
336
+ path: filePath,
337
+ isWrite
338
+ }));
325
339
  }
326
340
 
327
341
  // src/install.ts
@@ -647,7 +661,7 @@ var os6 = __toESM(require("node:os"), 1);
647
661
  var package_default = {
648
662
  $schema: "https://json.schemastore.org/package.json",
649
663
  name: "codex-wakatime",
650
- version: "1.0.1",
664
+ version: "1.1.0",
651
665
  description: "WakaTime plugin for OpenAI Codex CLI - Track AI coding activity and time spent",
652
666
  repository: {
653
667
  type: "git",
@@ -671,7 +685,8 @@ var package_default = {
671
685
  test: "vitest",
672
686
  "test:run": "vitest run",
673
687
  "test:coverage": "vitest run --coverage",
674
- prepublishOnly: "npm run build"
688
+ prepublishOnly: "npm run build",
689
+ prepare: "husky"
675
690
  },
676
691
  keywords: [
677
692
  "codex",
@@ -692,6 +707,8 @@ var package_default = {
692
707
  "@types/which": "^3.0.0",
693
708
  "@vitest/coverage-v8": "^4.0.16",
694
709
  esbuild: "^0.25.0",
710
+ husky: "^9.1.7",
711
+ "lint-staged": "^16.2.7",
695
712
  "semantic-release": "^25.0.2",
696
713
  typescript: "^5.0.0",
697
714
  vitest: "^4.0.16"
@@ -699,6 +716,11 @@ var package_default = {
699
716
  dependencies: {
700
717
  "@iarna/toml": "^3.0.0",
701
718
  which: "^4.0.0"
719
+ },
720
+ "lint-staged": {
721
+ "*.{ts,js,json}": [
722
+ "biome check --write"
723
+ ]
702
724
  }
703
725
  };
704
726
 
@@ -1099,16 +1121,19 @@ async function main() {
1099
1121
  }
1100
1122
  const assistantMessage = notification["last-assistant-message"] ?? "";
1101
1123
  const cwd = notification.cwd;
1102
- const files = extractFilePaths(assistantMessage, cwd);
1124
+ const files = extractFiles(assistantMessage, cwd);
1103
1125
  logger.debug(`Extracted ${files.length} files from message`);
1104
1126
  if (files.length > 0) {
1105
1127
  for (const file of files) {
1106
- logger.debug(`Sending heartbeat for file: ${file}`);
1128
+ logger.debug(
1129
+ `Sending heartbeat for file: ${file.path} (isWrite: ${file.isWrite})`
1130
+ );
1107
1131
  sendHeartbeat({
1108
- entity: file,
1132
+ entity: file.path,
1109
1133
  entityType: "file",
1110
1134
  category: "ai coding",
1111
- projectFolder: cwd
1135
+ projectFolder: cwd,
1136
+ isWrite: file.isWrite
1112
1137
  });
1113
1138
  }
1114
1139
  } else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "codex-wakatime",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "description": "WakaTime plugin for OpenAI Codex CLI - Track AI coding activity and time spent",
6
6
  "repository": {
7
7
  "type": "git",
@@ -25,7 +25,8 @@
25
25
  "test": "vitest",
26
26
  "test:run": "vitest run",
27
27
  "test:coverage": "vitest run --coverage",
28
- "prepublishOnly": "npm run build"
28
+ "prepublishOnly": "npm run build",
29
+ "prepare": "husky"
29
30
  },
30
31
  "keywords": [
31
32
  "codex",
@@ -46,6 +47,8 @@
46
47
  "@types/which": "^3.0.0",
47
48
  "@vitest/coverage-v8": "^4.0.16",
48
49
  "esbuild": "^0.25.0",
50
+ "husky": "^9.1.7",
51
+ "lint-staged": "^16.2.7",
49
52
  "semantic-release": "^25.0.2",
50
53
  "typescript": "^5.0.0",
51
54
  "vitest": "^4.0.16"
@@ -53,5 +56,10 @@
53
56
  "dependencies": {
54
57
  "@iarna/toml": "^3.0.0",
55
58
  "which": "^4.0.0"
59
+ },
60
+ "lint-staged": {
61
+ "*.{ts,js,json}": [
62
+ "biome check --write"
63
+ ]
56
64
  }
57
65
  }