@ghl-ai/aw 0.1.56-beta.0 → 0.1.56-beta.1
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.
- package/hooks/aw-usage/hooks/aw-usage-commit-created.js +27 -14
- package/hooks.mjs +10 -5
- package/package.json +1 -1
|
@@ -6,27 +6,40 @@
|
|
|
6
6
|
* Co-Authored-By trailer. Works for all harnesses (Claude, Cursor, Codex)
|
|
7
7
|
* since it fires from a git-level hook, not a harness-specific one.
|
|
8
8
|
*
|
|
9
|
-
* Usage: node aw-usage-commit-created.js <commit_hash> <branch>
|
|
9
|
+
* Usage: node aw-usage-commit-created.js <commit_hash> <branch> [cwd]
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
const { buildEvent, sendAsync, isDisabled } = require('../lib/aw-usage-telemetry');
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function buildCommitCreatedEvent({ commitHash = 'unknown', branch = 'unknown', cwd = process.cwd() } = {}) {
|
|
17
|
+
// Git hooks have no harness session context, but cwd lets buildEvent derive
|
|
18
|
+
// project_hash so the dashboard can correlate commits back to /aw:* sessions.
|
|
19
|
+
const event = buildEvent({ cwd }, 'commit_created', {
|
|
20
|
+
commit_hash: commitHash,
|
|
21
|
+
branch,
|
|
22
|
+
});
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
// Override harness to 'git' since this fires from a git hook, not a harness.
|
|
25
|
+
event.harness = 'git';
|
|
26
|
+
return event;
|
|
27
|
+
}
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// payload makes it clear this is harness-agnostic.
|
|
24
|
-
const event = buildEvent({}, 'commit_created', {
|
|
25
|
-
commit_hash: commitHash,
|
|
26
|
-
branch,
|
|
27
|
-
});
|
|
29
|
+
function main() {
|
|
30
|
+
if (isDisabled()) process.exit(0);
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
const commitHash = process.argv[2] || 'unknown';
|
|
33
|
+
const branch = process.argv[3] || 'unknown';
|
|
34
|
+
const cwd = process.argv[4] || process.cwd();
|
|
31
35
|
|
|
32
|
-
sendAsync(
|
|
36
|
+
sendAsync(buildCommitCreatedEvent({ commitHash, branch, cwd }));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (require.main === module) {
|
|
40
|
+
main();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
buildCommitCreatedEvent,
|
|
45
|
+
};
|
package/hooks.mjs
CHANGED
|
@@ -97,11 +97,14 @@ fi
|
|
|
97
97
|
|
|
98
98
|
# Fire commit_created telemetry if commit has AW co-author trailer
|
|
99
99
|
if git log -1 --format='%b' HEAD 2>/dev/null | grep -qF "Co-Authored-By: AW"; then
|
|
100
|
-
TELEMETRY_HOOK="$HOME/.
|
|
100
|
+
TELEMETRY_HOOK="$HOME/.claude/scripts/hooks/aw-usage-commit-created.js"
|
|
101
|
+
if [ ! -f "$TELEMETRY_HOOK" ]; then
|
|
102
|
+
TELEMETRY_HOOK="$HOME/.aw-ecc/scripts/hooks/aw-usage-commit-created.js"
|
|
103
|
+
fi
|
|
101
104
|
if command -v node >/dev/null 2>&1 && [ -f "$TELEMETRY_HOOK" ]; then
|
|
102
105
|
COMMIT_HASH="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)"
|
|
103
106
|
BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
|
|
104
|
-
node "$TELEMETRY_HOOK" "$COMMIT_HASH" "$BRANCH" >/dev/null 2>&1
|
|
107
|
+
node "$TELEMETRY_HOOK" "$COMMIT_HASH" "$BRANCH" "$(pwd)" >/dev/null 2>&1
|
|
105
108
|
fi
|
|
106
109
|
fi
|
|
107
110
|
|
|
@@ -278,11 +281,14 @@ case "$(pwd)" in /tmp/aw-*|/var/folders/*/aw-*|*/.aw|*/.aw/*) exit 0 ;; esac
|
|
|
278
281
|
|
|
279
282
|
# Fire commit_created telemetry if commit has AW co-author trailer
|
|
280
283
|
if git log -1 --format='%b' HEAD 2>/dev/null | grep -qF "Co-Authored-By: AW"; then
|
|
281
|
-
TELEMETRY_HOOK="$HOME/.
|
|
284
|
+
TELEMETRY_HOOK="$HOME/.claude/scripts/hooks/aw-usage-commit-created.js"
|
|
285
|
+
if [ ! -f "$TELEMETRY_HOOK" ]; then
|
|
286
|
+
TELEMETRY_HOOK="$HOME/.aw-ecc/scripts/hooks/aw-usage-commit-created.js"
|
|
287
|
+
fi
|
|
282
288
|
if command -v node >/dev/null 2>&1 && [ -f "$TELEMETRY_HOOK" ]; then
|
|
283
289
|
COMMIT_HASH="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)"
|
|
284
290
|
BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
|
|
285
|
-
node "$TELEMETRY_HOOK" "$COMMIT_HASH" "$BRANCH" >/dev/null 2>&1
|
|
291
|
+
node "$TELEMETRY_HOOK" "$COMMIT_HASH" "$BRANCH" "$(pwd)" >/dev/null 2>&1
|
|
286
292
|
fi
|
|
287
293
|
fi
|
|
288
294
|
|
|
@@ -339,4 +345,3 @@ export function installLocalCommitHook(projectDir) {
|
|
|
339
345
|
}
|
|
340
346
|
} catch { /* best effort */ }
|
|
341
347
|
}
|
|
342
|
-
|