@rachel_rotenberg/ai-contribution-tracker 1.0.23 → 1.0.25

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 +29 -0
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -73,6 +73,10 @@ function appendOrCreateHook(hooksDir) {
73
73
  }
74
74
  return;
75
75
  }
76
+ if (existing.includes("AI_IMPACT_PENDING")) {
77
+ skip(`commit-msg hook already handles AI tracking (installed by VS Code extension): ${hookPath}`);
78
+ return;
79
+ }
76
80
  fs.appendFileSync(hookPath, "\n" + HOOK_BODY + "\n");
77
81
  ok(`Appended AI tracker snippet to existing hook: ${hookPath}`);
78
82
  } else {
@@ -85,6 +89,29 @@ function appendOrCreateHook(hooksDir) {
85
89
  try { fs.chmodSync(hookPath, "755"); } catch { /* Windows */ }
86
90
  }
87
91
 
92
+ const PASSTHROUGH_HOOKS = [
93
+ "pre-commit", "pre-push", "prepare-commit-msg",
94
+ "post-commit", "post-merge", "pre-rebase",
95
+ ];
96
+
97
+ function ensurePassthroughHooks(hooksDir) {
98
+ for (const hookName of PASSTHROUGH_HOOKS) {
99
+ const hookPath = path.join(hooksDir, hookName);
100
+ if (fs.existsSync(hookPath)) continue;
101
+ const content = [
102
+ "#!/bin/sh",
103
+ `LOCAL_HOOK="$(git rev-parse --git-dir)/hooks/${hookName}"`,
104
+ 'if [ -f "$LOCAL_HOOK" ] && [ -x "$LOCAL_HOOK" ]; then',
105
+ ' "$LOCAL_HOOK" "$@" || exit $?',
106
+ 'fi',
107
+ "",
108
+ ].join("\n");
109
+ fs.writeFileSync(hookPath, content);
110
+ try { fs.chmodSync(hookPath, "755"); } catch { }
111
+ ok(`Created passthrough hook: ${hookName}`);
112
+ }
113
+ }
114
+
88
115
  /** Install the global git commit-msg hook. */
89
116
  function installGitHook() {
90
117
  console.log("\nGit commit-msg hook:");
@@ -104,10 +131,12 @@ function installGitHook() {
104
131
  // Use existing hooksPath directory
105
132
  fs.mkdirSync(existingPath, { recursive: true });
106
133
  appendOrCreateHook(existingPath);
134
+ ensurePassthroughHooks(existingPath);
107
135
  } else {
108
136
  const hooksDir = path.join(os.homedir(), ".config", "ai-contribution-tracker", "git-hooks");
109
137
  fs.mkdirSync(hooksDir, { recursive: true });
110
138
  appendOrCreateHook(hooksDir);
139
+ ensurePassthroughHooks(hooksDir);
111
140
 
112
141
  try {
113
142
  const gitPath = hooksDir.replace(/\\/g, "/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rachel_rotenberg/ai-contribution-tracker",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
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",