@rachel_rotenberg/ai-contribution-tracker 1.0.22 → 1.0.24

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/cli.js +20 -11
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -21,6 +21,12 @@ const { execSync, execFileSync } = require("child_process");
21
21
  const PLUGIN_NAME = "@rachel_rotenberg/ai-contribution-tracker";
22
22
  const HOOK_BEGIN = "# BEGIN ai-contribution-tracker-cli";
23
23
  const HOOK_END = "# END ai-contribution-tracker-cli";
24
+ const HOOK_DELEGATION = [
25
+ 'LOCAL_HOOK="$(git rev-parse --git-dir)/hooks/commit-msg"',
26
+ 'if [ -f "$LOCAL_HOOK" ] && [ -x "$LOCAL_HOOK" ]; then',
27
+ ' "$LOCAL_HOOK" "$@" || exit $?',
28
+ 'fi',
29
+ ].join("\n");
24
30
 
25
31
  // ─── Logging helpers ────────────────────────────────────────
26
32
  function ok(msg) { console.log(` \u2713 ${msg}`); }
@@ -55,23 +61,26 @@ function appendOrCreateHook(hooksDir) {
55
61
  const hookPath = path.join(hooksDir, "commit-msg");
56
62
 
57
63
  if (fs.existsSync(hookPath)) {
58
- const existing = fs.readFileSync(hookPath, "utf8");
64
+ let existing = fs.readFileSync(hookPath, "utf8");
59
65
  if (existing.includes(HOOK_BEGIN)) {
60
- skip(`commit-msg hook already has AI tracker snippet: ${hookPath}`);
66
+ if (!existing.includes(HOOK_DELEGATION.split("\n")[0])) {
67
+ const firstLine = existing.split("\n")[0];
68
+ existing = firstLine + "\n" + HOOK_DELEGATION + "\n" + existing.split("\n").slice(1).join("\n");
69
+ fs.writeFileSync(hookPath, existing.replace(/\r\n/g, "\n"));
70
+ ok(`Added local hook delegation to: ${hookPath}`);
71
+ } else {
72
+ skip(`commit-msg hook already up to date: ${hookPath}`);
73
+ }
74
+ return;
75
+ }
76
+ if (existing.includes("AI_IMPACT_PENDING")) {
77
+ skip(`commit-msg hook already handles AI tracking (installed by VS Code extension): ${hookPath}`);
61
78
  return;
62
79
  }
63
80
  fs.appendFileSync(hookPath, "\n" + HOOK_BODY + "\n");
64
81
  ok(`Appended AI tracker snippet to existing hook: ${hookPath}`);
65
82
  } else {
66
- const delegation = [
67
- "#!/bin/sh",
68
- 'LOCAL_HOOK="$(git rev-parse --git-dir)/hooks/commit-msg"',
69
- 'if [ -f "$LOCAL_HOOK" ] && [ -x "$LOCAL_HOOK" ]; then',
70
- ' "$LOCAL_HOOK" "$@" || exit $?',
71
- 'fi',
72
- "",
73
- ].join("\n");
74
- const content = (delegation + HOOK_BODY + "\n").replace(/\r\n/g, "\n");
83
+ const content = ("#!/bin/sh\n" + HOOK_DELEGATION + "\n\n" + HOOK_BODY + "\n").replace(/\r\n/g, "\n");
75
84
  fs.writeFileSync(hookPath, content);
76
85
  ok(`Created commit-msg hook: ${hookPath}`);
77
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rachel_rotenberg/ai-contribution-tracker",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "OpenCode plugin — tracks AI coding sessions and tags git commits with Impacted by AI markers",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",