@rachel_rotenberg/ai-contribution-tracker 1.0.19 → 1.0.20

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 (3) hide show
  1. package/cli.js +17 -3
  2. package/index.ts +1 -1
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -15,7 +15,7 @@
15
15
  const fs = require("fs");
16
16
  const path = require("path");
17
17
  const os = require("os");
18
- const { execSync } = require("child_process");
18
+ const { execSync, execFileSync } = require("child_process");
19
19
 
20
20
  // ─── Constants ──────────────────────────────────────────────
21
21
  const PLUGIN_NAME = "@rachel_rotenberg/ai-contribution-tracker";
@@ -36,7 +36,7 @@ const HOOK_BODY = [
36
36
  'if [ -f "$IMPACT_FLAG" ]; then',
37
37
  ' MARKER=$(cat "$IMPACT_FLAG")',
38
38
  ' if [ -z "$MARKER" ]; then MARKER="Impacted by AI"; fi',
39
- ' if ! grep -qF "Impacted by AI" "$1"; then',
39
+ ' if ! grep -qF "$MARKER" "$1"; then',
40
40
  ' echo "" >> "$1"',
41
41
  ' echo "$MARKER" >> "$1"',
42
42
  ' fi',
@@ -95,7 +95,7 @@ function installGitHook() {
95
95
 
96
96
  try {
97
97
  const gitPath = hooksDir.replace(/\\/g, "/");
98
- execSync(`git config --global core.hooksPath "${gitPath}"`, {
98
+ execFileSync("git", ["config", "--global", "core.hooksPath", gitPath], {
99
99
  encoding: "utf8",
100
100
  stdio: ["pipe", "pipe", "pipe"],
101
101
  });
@@ -261,6 +261,19 @@ function removeGitHook() {
261
261
  if (remaining === "#!/bin/sh" || remaining === "") {
262
262
  fs.unlinkSync(hookFile);
263
263
  ok(`Removed commit-msg hook: ${hookFile}`);
264
+
265
+ const ourDefaultDir = path.join(os.homedir(), ".config", "ai-contribution-tracker", "git-hooks");
266
+ const normalizedHooksPath = hooksPath.replace(/\\/g, "/");
267
+ const normalizedOurDir = ourDefaultDir.replace(/\\/g, "/");
268
+ if (normalizedHooksPath === normalizedOurDir) {
269
+ try {
270
+ execFileSync("git", ["config", "--global", "--unset", "core.hooksPath"], {
271
+ encoding: "utf8",
272
+ stdio: ["pipe", "pipe", "pipe"],
273
+ });
274
+ ok("Unset git global core.hooksPath");
275
+ } catch { }
276
+ }
264
277
  } else {
265
278
  fs.writeFileSync(hookFile, remaining + "\n");
266
279
  ok(`Removed AI tracker snippet from: ${hookFile}`);
@@ -358,3 +371,4 @@ switch (command) {
358
371
  printUsage();
359
372
  process.exit(command ? 1 : 0);
360
373
  }
374
+
package/index.ts CHANGED
@@ -278,7 +278,7 @@ const AIContributionTracker: Plugin = async ({ directory, worktree }) => {
278
278
  if (sess.isSubagent) return;
279
279
 
280
280
  // Resolve gitDir from file path — this is the ONLY place we resolve
281
- if (!sess.gitDir) {
281
+ if (!sess.gitDir || !fs.existsSync(sess.gitDir)) {
282
282
  const args = input.args as Record<string, unknown> ?? {};
283
283
  const fp = typeof args.filePath === "string" ? args.filePath : typeof args.path === "string" ? args.path : undefined;
284
284
  if (fp) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rachel_rotenberg/ai-contribution-tracker",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
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",