@ascenda-one/claude-code-hooks 0.1.6 → 0.1.7
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/README.md +4 -1
- package/dist/cli.js +115 -18
- package/dist/mapClaudeEvent.js +35 -9
- package/dist/mapClaudeEvent.js.map +1 -1
- package/dist/safeExtract.js +1 -1
- package/dist/safeExtract.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/examples/sample-post-tool-use-bash-test-ok.json +18 -0
- package/examples/sample-post-tool-use-edit.json +17 -4
- package/examples/sample-post-tool-use-failure.json +13 -0
- package/examples/settings.local.json +1 -0
- package/package.json +2 -1
- package/examples/sample-post-tool-use-bash-test-failed.json +0 -6
package/README.md
CHANGED
|
@@ -119,6 +119,7 @@ for machine-wide coverage:
|
|
|
119
119
|
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks UserPromptSubmit" }] }],
|
|
120
120
|
"PreToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreToolUse" }] }],
|
|
121
121
|
"PostToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUse" }] }],
|
|
122
|
+
"PostToolUseFailure": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUseFailure" }] }],
|
|
122
123
|
"PreCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreCompact" }] }],
|
|
123
124
|
"PostCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostCompact" }] }],
|
|
124
125
|
"Stop": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks Stop" }] }],
|
|
@@ -167,6 +168,7 @@ on Claude Code's PATH, use an absolute path such as
|
|
|
167
168
|
UserPromptSubmit
|
|
168
169
|
PreToolUse
|
|
169
170
|
PostToolUse
|
|
171
|
+
PostToolUseFailure
|
|
170
172
|
PreCompact
|
|
171
173
|
PostCompact
|
|
172
174
|
Stop
|
|
@@ -182,7 +184,8 @@ UserPromptSubmit -> ai_prompt_submitted / ai_correction_prompt
|
|
|
182
184
|
PreToolUse -> ai_tool_call_started
|
|
183
185
|
PostToolUse Edit -> ai_file_edit
|
|
184
186
|
PostToolUse Write -> ai_file_write
|
|
185
|
-
PostToolUse Bash -> editor_verification_activity /
|
|
187
|
+
PostToolUse Bash -> editor_verification_activity / ai_tool_call_completed (success only)
|
|
188
|
+
PostToolUseFailure -> compile_error / ai_tool_call_failed
|
|
186
189
|
PreCompact -> context_compression_manual / context_compression_auto
|
|
187
190
|
PostCompact -> context_pressure_high
|
|
188
191
|
Stop (long only) -> agent_loop_long
|
package/dist/cli.js
CHANGED
|
@@ -65,6 +65,75 @@ var require_commandClassifier = __commonJS({
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
// ../packages/tool-kit/out/commandHeads.js
|
|
69
|
+
var require_commandHeads = __commonJS({
|
|
70
|
+
"../packages/tool-kit/out/commandHeads.js"(exports) {
|
|
71
|
+
"use strict";
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.commandHeads = commandHeads;
|
|
74
|
+
function commandHeads(value) {
|
|
75
|
+
const stripped = stripQuoted(stripHeredocBodies(value));
|
|
76
|
+
return stripped.split(/[;&|()\n]+/).map((segment) => {
|
|
77
|
+
let head = segment.trim();
|
|
78
|
+
for (; ; ) {
|
|
79
|
+
const env = /^[a-z_][a-z0-9_]*=\S*\s+/.exec(head);
|
|
80
|
+
if (!env)
|
|
81
|
+
break;
|
|
82
|
+
head = head.slice(env[0].length);
|
|
83
|
+
}
|
|
84
|
+
return head;
|
|
85
|
+
}).filter((head) => head.length > 0);
|
|
86
|
+
}
|
|
87
|
+
function stripHeredocBodies(value) {
|
|
88
|
+
const marker = /<<-?\s*(["']?)(\w+)\1/;
|
|
89
|
+
let kept = "";
|
|
90
|
+
let rest = value;
|
|
91
|
+
for (; ; ) {
|
|
92
|
+
const opened = marker.exec(rest);
|
|
93
|
+
if (!opened)
|
|
94
|
+
return kept + rest;
|
|
95
|
+
const introLineEnd = rest.indexOf("\n", opened.index + opened[0].length);
|
|
96
|
+
if (introLineEnd === -1)
|
|
97
|
+
return kept + rest;
|
|
98
|
+
kept += rest.slice(0, introLineEnd + 1);
|
|
99
|
+
const body = rest.slice(introLineEnd + 1);
|
|
100
|
+
const terminator = new RegExp(`^\\s*${opened[2]}\\s*$`, "m").exec(body);
|
|
101
|
+
if (!terminator)
|
|
102
|
+
return kept;
|
|
103
|
+
rest = body.slice(terminator.index + terminator[0].length);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function stripQuoted(value) {
|
|
107
|
+
let out = "";
|
|
108
|
+
let i = 0;
|
|
109
|
+
while (i < value.length) {
|
|
110
|
+
const ch = value[i];
|
|
111
|
+
if (ch === "'") {
|
|
112
|
+
const close = value.indexOf("'", i + 1);
|
|
113
|
+
if (close === -1)
|
|
114
|
+
return out;
|
|
115
|
+
i = close + 1;
|
|
116
|
+
} else if (ch === '"') {
|
|
117
|
+
let j = i + 1;
|
|
118
|
+
while (j < value.length && value[j] !== '"') {
|
|
119
|
+
j += value[j] === "\\" ? 2 : 1;
|
|
120
|
+
}
|
|
121
|
+
if (j >= value.length)
|
|
122
|
+
return out;
|
|
123
|
+
i = j + 1;
|
|
124
|
+
} else if (ch === "\\") {
|
|
125
|
+
out += value.slice(i, i + 2);
|
|
126
|
+
i += 2;
|
|
127
|
+
} else {
|
|
128
|
+
out += ch;
|
|
129
|
+
i += 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
68
137
|
// ../packages/tool-kit/out/gitActionClassifier.js
|
|
69
138
|
var require_gitActionClassifier = __commonJS({
|
|
70
139
|
"../packages/tool-kit/out/gitActionClassifier.js"(exports) {
|
|
@@ -72,25 +141,27 @@ var require_gitActionClassifier = __commonJS({
|
|
|
72
141
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
142
|
exports.classifyGitAction = classifyGitAction2;
|
|
74
143
|
exports.isReworkGitAction = isReworkGitAction2;
|
|
144
|
+
var commandHeads_1 = require_commandHeads();
|
|
75
145
|
function classifyGitAction2(command) {
|
|
76
146
|
if (!command)
|
|
77
147
|
return void 0;
|
|
78
148
|
const value = command.toLowerCase().trim();
|
|
79
149
|
if (!/\bgit\b/.test(value))
|
|
80
150
|
return void 0;
|
|
81
|
-
|
|
151
|
+
const heads = (0, commandHeads_1.commandHeads)(value);
|
|
152
|
+
if (heads.some((h) => /^git\s+commit\b/.test(h) && /\s--amend\b/.test(h)))
|
|
82
153
|
return "amend";
|
|
83
|
-
if (
|
|
154
|
+
if (heads.some((h) => /^git\s+revert\b/.test(h)))
|
|
84
155
|
return "revert";
|
|
85
|
-
if (
|
|
156
|
+
if (heads.some((h) => /^git\s+reset\b/.test(h) && /\s--hard\b/.test(h)))
|
|
86
157
|
return "reset_hard";
|
|
87
|
-
if (
|
|
158
|
+
if (heads.some((h) => /^git\s+restore\b/.test(h) && !/\s--staged\b/.test(h)))
|
|
88
159
|
return "restore";
|
|
89
|
-
if (
|
|
160
|
+
if (heads.some((h) => /^git\s+checkout\b.*\s--\s/.test(h)))
|
|
90
161
|
return "restore";
|
|
91
|
-
if (
|
|
162
|
+
if (heads.some((h) => /^git\s+push\b/.test(h)))
|
|
92
163
|
return "push";
|
|
93
|
-
if (
|
|
164
|
+
if (heads.some((h) => /^git\s+commit\b/.test(h)))
|
|
94
165
|
return "commit";
|
|
95
166
|
return void 0;
|
|
96
167
|
}
|
|
@@ -107,17 +178,19 @@ var require_workMilestoneClassifier = __commonJS({
|
|
|
107
178
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
108
179
|
exports.classifyWorkMilestone = classifyWorkMilestone2;
|
|
109
180
|
exports.invitesDebrief = invitesDebrief2;
|
|
181
|
+
var commandHeads_1 = require_commandHeads();
|
|
110
182
|
function classifyWorkMilestone2(command) {
|
|
111
183
|
if (!command)
|
|
112
184
|
return void 0;
|
|
113
185
|
const value = command.toLowerCase().trim();
|
|
114
186
|
if (!/\bgh\b/.test(value))
|
|
115
187
|
return void 0;
|
|
116
|
-
|
|
188
|
+
const heads = (0, commandHeads_1.commandHeads)(value);
|
|
189
|
+
if (heads.some((head) => /^gh\s+pr\s+merge\b/.test(head)))
|
|
117
190
|
return "pr_merged";
|
|
118
|
-
if (
|
|
191
|
+
if (heads.some((head) => /^gh\s+issue\s+close\b/.test(head)))
|
|
119
192
|
return "issue_closed";
|
|
120
|
-
if (
|
|
193
|
+
if (heads.some((head) => /^gh\s+pr\s+create\b/.test(head)))
|
|
121
194
|
return "pr_opened";
|
|
122
195
|
return void 0;
|
|
123
196
|
}
|
|
@@ -204,6 +277,7 @@ var require_payload = __commonJS({
|
|
|
204
277
|
exports.getNestedString = getNestedString2;
|
|
205
278
|
exports.getNestedNumber = getNestedNumber2;
|
|
206
279
|
exports.inferOutcome = inferOutcome2;
|
|
280
|
+
exports.outcomeForHook = outcomeForHook2;
|
|
207
281
|
exports.looksLikeCorrection = looksLikeCorrection2;
|
|
208
282
|
function getString2(input, keys) {
|
|
209
283
|
for (const key of keys) {
|
|
@@ -255,6 +329,18 @@ var require_payload = __commonJS({
|
|
|
255
329
|
return "failure";
|
|
256
330
|
return "unknown";
|
|
257
331
|
}
|
|
332
|
+
function outcomeForHook2(hookName, input) {
|
|
333
|
+
if (hookName === "PostToolUseFailure") {
|
|
334
|
+
const interrupted = input["is_interrupt"] === true || getNested2(input, ["tool_response", "interrupted"]) === true;
|
|
335
|
+
return interrupted ? "cancelled" : "failure";
|
|
336
|
+
}
|
|
337
|
+
if (hookName === "PostToolUse") {
|
|
338
|
+
if (getNested2(input, ["tool_response", "interrupted"]) === true)
|
|
339
|
+
return "cancelled";
|
|
340
|
+
return "success";
|
|
341
|
+
}
|
|
342
|
+
return "unknown";
|
|
343
|
+
}
|
|
258
344
|
function looksLikeCorrection2(text) {
|
|
259
345
|
if (!text)
|
|
260
346
|
return false;
|
|
@@ -718,7 +804,7 @@ var require_out2 = __commonJS({
|
|
|
718
804
|
"../packages/tool-kit/out/index.js"(exports) {
|
|
719
805
|
"use strict";
|
|
720
806
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
721
|
-
exports.parseIngestResponse = exports.postToolEventsBatch = exports.postToolEvent = exports.renewToolToken = exports.getPairingStatus = exports.createPairingSession = exports.AscendaApiError = exports.hashWithMachineSalt = exports.readOrCreateMachineSalt = exports.machineSaltFilePath = exports.readTokenFile = exports.persistEventWriteToken = exports.defaultTokenFilePath = exports.AscendaSemanticEventError = exports.AscendaEventSender = exports.looksLikeCorrection = exports.inferOutcome = exports.getNestedNumber = exports.getNestedString = exports.getNested = exports.getNumber = exports.getString = exports.isAfterHours = exports.bucketDurationMs = exports.bucketLinesChanged = exports.invitesDebrief = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
|
|
807
|
+
exports.parseIngestResponse = exports.postToolEventsBatch = exports.postToolEvent = exports.renewToolToken = exports.getPairingStatus = exports.createPairingSession = exports.AscendaApiError = exports.hashWithMachineSalt = exports.readOrCreateMachineSalt = exports.machineSaltFilePath = exports.readTokenFile = exports.persistEventWriteToken = exports.defaultTokenFilePath = exports.AscendaSemanticEventError = exports.AscendaEventSender = exports.looksLikeCorrection = exports.outcomeForHook = exports.inferOutcome = exports.getNestedNumber = exports.getNestedString = exports.getNested = exports.getNumber = exports.getString = exports.isAfterHours = exports.bucketDurationMs = exports.bucketLinesChanged = exports.invitesDebrief = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
|
|
722
808
|
var commandClassifier_1 = require_commandClassifier();
|
|
723
809
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
724
810
|
return commandClassifier_1.classifyCommand;
|
|
@@ -770,6 +856,9 @@ var require_out2 = __commonJS({
|
|
|
770
856
|
Object.defineProperty(exports, "inferOutcome", { enumerable: true, get: function() {
|
|
771
857
|
return payload_1.inferOutcome;
|
|
772
858
|
} });
|
|
859
|
+
Object.defineProperty(exports, "outcomeForHook", { enumerable: true, get: function() {
|
|
860
|
+
return payload_1.outcomeForHook;
|
|
861
|
+
} });
|
|
773
862
|
Object.defineProperty(exports, "looksLikeCorrection", { enumerable: true, get: function() {
|
|
774
863
|
return payload_1.looksLikeCorrection;
|
|
775
864
|
} });
|
|
@@ -902,8 +991,13 @@ function mapClaudeEvent(hookName, input) {
|
|
|
902
991
|
return mapUserPromptSubmit(input);
|
|
903
992
|
case "PreToolUse":
|
|
904
993
|
return mapPreToolUse(input);
|
|
994
|
+
// Success and failure arrive on different hooks with different payloads —
|
|
995
|
+
// PostToolUse carries tool_response and no exit code; PostToolUseFailure
|
|
996
|
+
// carries `error`/`is_interrupt` and no tool_response. One mapper handles
|
|
997
|
+
// both so the event vocabulary cannot drift between the two paths.
|
|
905
998
|
case "PostToolUse":
|
|
906
|
-
|
|
999
|
+
case "PostToolUseFailure":
|
|
1000
|
+
return mapPostToolUse(hookName, input);
|
|
907
1001
|
case "PreCompact":
|
|
908
1002
|
return mapPreCompact(input);
|
|
909
1003
|
case "PostCompact":
|
|
@@ -922,7 +1016,7 @@ function isNewSessionStart(input) {
|
|
|
922
1016
|
return !source || source === "startup" || source === "resume";
|
|
923
1017
|
}
|
|
924
1018
|
function milestoneInviting(input) {
|
|
925
|
-
if ((0, import_tool_kit4.
|
|
1019
|
+
if ((0, import_tool_kit4.outcomeForHook)("PostToolUse", input) !== "success") return false;
|
|
926
1020
|
const command = (0, import_tool_kit4.getString)(input, ["command"]) ?? (0, import_tool_kit4.getNestedString)(input, [["tool_input", "command"], ["input", "command"], ["parameters", "command"]]);
|
|
927
1021
|
return (0, import_tool_kit5.invitesDebrief)((0, import_tool_kit5.classifyWorkMilestone)(command));
|
|
928
1022
|
}
|
|
@@ -941,15 +1035,18 @@ function mapUserPromptSubmit(input) {
|
|
|
941
1035
|
function mapPreToolUse(input) {
|
|
942
1036
|
return [{ eventType: "ai_tool_call_started", severity: "low", metadata: { toolName: sanitiseToolName(getToolName(input)) } }];
|
|
943
1037
|
}
|
|
944
|
-
function mapPostToolUse(input) {
|
|
1038
|
+
function mapPostToolUse(hookName, input) {
|
|
945
1039
|
const toolName = getToolName(input);
|
|
946
1040
|
const safeToolName = sanitiseToolName(toolName);
|
|
947
|
-
const outcome = (0, import_tool_kit4.
|
|
948
|
-
const durationMs = (0, import_tool_kit4.getNumber)(input, ["
|
|
1041
|
+
const outcome = (0, import_tool_kit4.outcomeForHook)(hookName, input);
|
|
1042
|
+
const durationMs = (0, import_tool_kit4.getNumber)(input, ["duration_ms", "durationMs", "elapsedMs"]) ?? (0, import_tool_kit4.getNestedNumber)(input, [["tool_response", "durationMs"], ["result", "durationMs"]]);
|
|
949
1043
|
const command = (0, import_tool_kit4.getString)(input, ["command"]) ?? (0, import_tool_kit4.getNestedString)(input, [["tool_input", "command"], ["input", "command"], ["parameters", "command"]]);
|
|
950
1044
|
const commandClass = (0, import_tool_kit5.classifyCommand)(command);
|
|
951
|
-
const gitAction = outcome === "
|
|
952
|
-
const milestoneKind = outcome === "
|
|
1045
|
+
const gitAction = outcome === "success" ? (0, import_tool_kit5.classifyGitAction)(command) : void 0;
|
|
1046
|
+
const milestoneKind = outcome === "success" ? (0, import_tool_kit5.classifyWorkMilestone)(command) : void 0;
|
|
1047
|
+
if (outcome === "cancelled") {
|
|
1048
|
+
return [{ eventType: "ai_tool_call_failed", severity: "low", metadata: { toolName: safeToolName, commandClass, outcome, durationBucket: (0, import_tool_kit4.bucketDurationMs)(durationMs), reason: "manual_interrupt" } }];
|
|
1049
|
+
}
|
|
953
1050
|
if (outcome === "failure") {
|
|
954
1051
|
if (toolName?.toLowerCase() === "bash" && (0, import_tool_kit5.isVerificationCommand)(commandClass)) {
|
|
955
1052
|
return [{ eventType: "compile_error", severity: "medium", metadata: { toolName: safeToolName, commandClass, outcome, durationBucket: (0, import_tool_kit4.bucketDurationMs)(durationMs), reason: "test_failure" } }];
|
package/dist/mapClaudeEvent.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { classifyCommand, classifyGitAction, isVerificationCommand, isReworkGitAction, classifyWorkMilestone, invitesDebrief } from "@ascenda-one/tool-kit";
|
|
2
|
-
import { bucketDurationMs, bucketLinesChanged, getNested, getNestedNumber, getNestedString, getNumber, getString,
|
|
2
|
+
import { bucketDurationMs, bucketLinesChanged, getNested, getNestedNumber, getNestedString, getNumber, getString, outcomeForHook, looksLikeCorrection } from "./safeExtract.js";
|
|
3
3
|
export function mapClaudeEvent(hookName, input) {
|
|
4
4
|
switch (hookName) {
|
|
5
5
|
case "SessionStart": return mapSessionStart(input);
|
|
6
6
|
case "UserPromptSubmit": return mapUserPromptSubmit(input);
|
|
7
7
|
case "PreToolUse": return mapPreToolUse(input);
|
|
8
|
-
|
|
8
|
+
// Success and failure arrive on different hooks with different payloads —
|
|
9
|
+
// PostToolUse carries tool_response and no exit code; PostToolUseFailure
|
|
10
|
+
// carries `error`/`is_interrupt` and no tool_response. One mapper handles
|
|
11
|
+
// both so the event vocabulary cannot drift between the two paths.
|
|
12
|
+
case "PostToolUse":
|
|
13
|
+
case "PostToolUseFailure": return mapPostToolUse(hookName, input);
|
|
9
14
|
case "PreCompact": return mapPreCompact(input);
|
|
10
15
|
case "PostCompact": return [{ eventType: "context_pressure_high", severity: "medium", metadata: { trigger: "inferred", reason: "context_limit" } }];
|
|
11
16
|
case "Stop": return mapStop(input);
|
|
@@ -30,9 +35,15 @@ export function isNewSessionStart(input) {
|
|
|
30
35
|
* (H1). Exported so the CLI can decide about the invitation without
|
|
31
36
|
* re-extracting the command — and so the "only completions, only successes"
|
|
32
37
|
* rule has one implementation rather than two that can drift.
|
|
38
|
+
*
|
|
39
|
+
* PostToolUse-only by contract (the CLI's one call site gates on the hook
|
|
40
|
+
* name): a failed merge fires PostToolUseFailure and never gets here, so
|
|
41
|
+
* "only successes" is enforced by the runtime's own event split. The
|
|
42
|
+
* remaining check is for the interrupted case — a merge the user stopped
|
|
43
|
+
* finished nothing, so it asks nothing.
|
|
33
44
|
*/
|
|
34
45
|
export function milestoneInviting(input) {
|
|
35
|
-
if (
|
|
46
|
+
if (outcomeForHook("PostToolUse", input) !== "success")
|
|
36
47
|
return false;
|
|
37
48
|
const command = getString(input, ["command"]) ?? getNestedString(input, [["tool_input", "command"], ["input", "command"], ["parameters", "command"]]);
|
|
38
49
|
return invitesDebrief(classifyWorkMilestone(command));
|
|
@@ -53,19 +64,34 @@ function mapUserPromptSubmit(input) {
|
|
|
53
64
|
function mapPreToolUse(input) {
|
|
54
65
|
return [{ eventType: "ai_tool_call_started", severity: "low", metadata: { toolName: sanitiseToolName(getToolName(input)) } }];
|
|
55
66
|
}
|
|
56
|
-
function mapPostToolUse(input) {
|
|
67
|
+
function mapPostToolUse(hookName, input) {
|
|
57
68
|
const toolName = getToolName(input);
|
|
58
69
|
const safeToolName = sanitiseToolName(toolName);
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
// The outcome is carried by *which hook fired*, not by the payload: there
|
|
71
|
+
// is no exit code anywhere in a PostToolUse payload, and a failed call is
|
|
72
|
+
// routed to PostToolUseFailure instead. inferOutcome read fields Claude
|
|
73
|
+
// never sends, so every outcome was "unknown" — which silently disabled
|
|
74
|
+
// compile_error, ai_tool_call_failed, and every outcome:"success" marker
|
|
75
|
+
// the backend's verification/commit boundaries key on.
|
|
76
|
+
const outcome = outcomeForHook(hookName, input);
|
|
77
|
+
// `duration_ms` is the real, top-level field (captured 27 Jul); the
|
|
78
|
+
// camelCase and nested forms remain as harmless fallbacks.
|
|
79
|
+
const durationMs = getNumber(input, ["duration_ms", "durationMs", "elapsedMs"]) ?? getNestedNumber(input, [["tool_response", "durationMs"], ["result", "durationMs"]]);
|
|
61
80
|
const command = getString(input, ["command"]) ?? getNestedString(input, [["tool_input", "command"], ["input", "command"], ["parameters", "command"]]);
|
|
62
81
|
const commandClass = classifyCommand(command);
|
|
63
82
|
// Only a git action that actually succeeded is a boundary or a reversion —
|
|
64
|
-
// a failed push moved nothing,
|
|
65
|
-
|
|
83
|
+
// a failed push moved nothing, a failed reset undid nothing, and an
|
|
84
|
+
// interrupted push proved nothing either way.
|
|
85
|
+
const gitAction = outcome === "success" ? classifyGitAction(command) : undefined;
|
|
66
86
|
// A failed `gh pr merge` did not complete anything, so — like gitAction — a
|
|
67
87
|
// milestone is only read off a command that actually succeeded.
|
|
68
|
-
const milestoneKind = outcome === "
|
|
88
|
+
const milestoneKind = outcome === "success" ? classifyWorkMilestone(command) : undefined;
|
|
89
|
+
if (outcome === "cancelled") {
|
|
90
|
+
// Stopped work is not wrong work: an interrupted test run is not a
|
|
91
|
+
// compile_error (it proved nothing either way), and severity stays low —
|
|
92
|
+
// the user pressing escape is routine, not risk.
|
|
93
|
+
return [{ eventType: "ai_tool_call_failed", severity: "low", metadata: { toolName: safeToolName, commandClass, outcome, durationBucket: bucketDurationMs(durationMs), reason: "manual_interrupt" } }];
|
|
94
|
+
}
|
|
69
95
|
if (outcome === "failure") {
|
|
70
96
|
if (toolName?.toLowerCase() === "bash" && isVerificationCommand(commandClass)) {
|
|
71
97
|
return [{ eventType: "compile_error", severity: "medium", metadata: { toolName: safeToolName, commandClass, outcome, durationBucket: bucketDurationMs(durationMs), reason: "test_failure" } }];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapClaudeEvent.js","sourceRoot":"","sources":["../src/mapClaudeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5J,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,SAAS,EAAE,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IAAI,KAAK,QAAQ;oBAAE,SAAS;gBAChD,MAAM,MAAM,GAAI,IAAgC,CAAC,YAAY,CAAC,CAAC;gBAC/D,MAAM,MAAM,GAAI,IAAgC,CAAC,YAAY,CAAC,CAAC;gBAC/D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ;oBAAE,SAAS;gBACvE,MAAM,GAAG,IAAI,CAAC;gBACd,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QACpC,CAAC;QACD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACzD,CAAC;AAED,SAAS,WAAW,CAAC,QAA4B;IAC/C,MAAM,KAAK,GAAG,QAAQ,EAAE,WAAW,EAAE,CAAC;IACtC,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,WAAW,CAAC;AACxE,CAAC;AAED,SAAS,gBAAgB,CAAC,QAA4B;IACpD,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChC,OAAO,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;AAC3E,CAAC"}
|
package/dist/safeExtract.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { bucketDurationMs, bucketLinesChanged, getNested, getNestedNumber, getNestedString, getNumber, getString, inferOutcome, looksLikeCorrection } from "@ascenda-one/tool-kit";
|
|
1
|
+
export { bucketDurationMs, bucketLinesChanged, getNested, getNestedNumber, getNestedString, getNumber, getString, inferOutcome, outcomeForHook, looksLikeCorrection } from "@ascenda-one/tool-kit";
|
|
2
2
|
//# sourceMappingURL=safeExtract.js.map
|
package/dist/safeExtract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safeExtract.js","sourceRoot":"","sources":["../src/safeExtract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,eAAe,EACf,SAAS,EACT,SAAS,EACT,YAAY,EACZ,mBAAmB,EACpB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"safeExtract.js","sourceRoot":"","sources":["../src/safeExtract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,eAAe,EACf,SAAS,EACT,SAAS,EACT,YAAY,EACZ,cAAc,EACd,mBAAmB,EACpB,MAAM,uBAAuB,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAavF,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hook_event_name": "PostToolUse",
|
|
3
|
+
"session_id": "captured-session",
|
|
4
|
+
"cwd": "/repo",
|
|
5
|
+
"permission_mode": "default",
|
|
6
|
+
"effort": { "level": "high" },
|
|
7
|
+
"tool_name": "Bash",
|
|
8
|
+
"tool_input": { "command": "npm test", "description": "Run test suite" },
|
|
9
|
+
"tool_response": {
|
|
10
|
+
"stdout": "Test Suites: 12 passed, 12 total",
|
|
11
|
+
"stderr": "",
|
|
12
|
+
"interrupted": false,
|
|
13
|
+
"isImage": false,
|
|
14
|
+
"noOutputExpected": false
|
|
15
|
+
},
|
|
16
|
+
"tool_use_id": "toolu_captured",
|
|
17
|
+
"duration_ms": 4200
|
|
18
|
+
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
2
|
+
"hook_event_name": "PostToolUse",
|
|
3
|
+
"session_id": "captured-session",
|
|
4
|
+
"cwd": "/repo",
|
|
5
|
+
"permission_mode": "default",
|
|
6
|
+
"tool_name": "Edit",
|
|
7
|
+
"tool_input": {
|
|
8
|
+
"file_path": "/redacted/path/example.ts",
|
|
9
|
+
"old_string": "const a = 1;",
|
|
10
|
+
"new_string": "const a = 1;\nconst b = 2;"
|
|
11
|
+
},
|
|
12
|
+
"tool_response": {
|
|
13
|
+
"filePath": "/redacted/path/example.ts",
|
|
14
|
+
"userModified": false,
|
|
15
|
+
"replaceAll": false
|
|
16
|
+
},
|
|
17
|
+
"tool_use_id": "toolu_captured_edit",
|
|
18
|
+
"duration_ms": 4200
|
|
6
19
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hook_event_name": "PostToolUseFailure",
|
|
3
|
+
"session_id": "captured-session",
|
|
4
|
+
"cwd": "/repo",
|
|
5
|
+
"permission_mode": "default",
|
|
6
|
+
"effort": { "level": "high" },
|
|
7
|
+
"tool_name": "Bash",
|
|
8
|
+
"tool_input": { "command": "npm test" },
|
|
9
|
+
"tool_use_id": "toolu_captured_fail",
|
|
10
|
+
"duration_ms": 8200,
|
|
11
|
+
"error": "Exit code 1\nTest Suites: 1 failed, 11 passed",
|
|
12
|
+
"is_interrupt": false
|
|
13
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks UserPromptSubmit" }] }],
|
|
5
5
|
"PreToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreToolUse" }] }],
|
|
6
6
|
"PostToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUse" }] }],
|
|
7
|
+
"PostToolUseFailure": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUseFailure" }] }],
|
|
7
8
|
"PreCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreCompact" }] }],
|
|
8
9
|
"PostCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostCompact" }] }],
|
|
9
10
|
"Stop": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks Stop" }] }],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"publishConfig": { "access": "public" },
|
|
3
3
|
"name": "@ascenda-one/claude-code-hooks",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"description": "Claude Code hooks adapter for Ascenda AI workload telemetry.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"build": "tsc -p ./ && npm run bundle",
|
|
18
18
|
"watch": "tsc -w -p ./",
|
|
19
19
|
"test:sample": "npm run build && cat examples/sample-post-tool-use-edit.json | node dist/cli.js PostToolUse",
|
|
20
|
+
"test:failure": "npm run build && cat examples/sample-post-tool-use-failure.json | node dist/cli.js PostToolUseFailure",
|
|
20
21
|
"test:compact": "npm run build && cat examples/sample-pre-compact-auto.json | node dist/cli.js PreCompact",
|
|
21
22
|
"bundle": "esbuild src/cli.ts --bundle --platform=node --format=esm --banner:js=\"import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);\" --outfile=dist/cli.js",
|
|
22
23
|
"test": "node --test"
|