@ascenda-one/claude-code-hooks 0.1.6 → 0.1.8
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 +278 -23
- package/dist/cli.js.map +1 -1
- 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
|
}
|
|
@@ -198,14 +271,15 @@ var require_payload = __commonJS({
|
|
|
198
271
|
"../packages/tool-kit/out/payload.js"(exports) {
|
|
199
272
|
"use strict";
|
|
200
273
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
201
|
-
exports.getString =
|
|
274
|
+
exports.getString = getString3;
|
|
202
275
|
exports.getNumber = getNumber2;
|
|
203
276
|
exports.getNested = getNested2;
|
|
204
|
-
exports.getNestedString =
|
|
277
|
+
exports.getNestedString = getNestedString3;
|
|
205
278
|
exports.getNestedNumber = getNestedNumber2;
|
|
206
279
|
exports.inferOutcome = inferOutcome2;
|
|
280
|
+
exports.outcomeForHook = outcomeForHook2;
|
|
207
281
|
exports.looksLikeCorrection = looksLikeCorrection2;
|
|
208
|
-
function
|
|
282
|
+
function getString3(input, keys) {
|
|
209
283
|
for (const key of keys) {
|
|
210
284
|
const value = input[key];
|
|
211
285
|
if (typeof value === "string" && value.trim())
|
|
@@ -230,7 +304,7 @@ var require_payload = __commonJS({
|
|
|
230
304
|
}
|
|
231
305
|
return current;
|
|
232
306
|
}
|
|
233
|
-
function
|
|
307
|
+
function getNestedString3(input, paths) {
|
|
234
308
|
for (const path of paths) {
|
|
235
309
|
const value = getNested2(input, path);
|
|
236
310
|
if (typeof value === "string" && value.trim())
|
|
@@ -250,11 +324,23 @@ var require_payload = __commonJS({
|
|
|
250
324
|
const exitCode = getNumber2(input, ["exitCode", "exit_code", "status"]) ?? getNestedNumber2(input, [["tool_response", "exitCode"], ["tool_response", "exit_code"], ["result", "exitCode"], ["result", "exit_code"]]);
|
|
251
325
|
if (typeof exitCode === "number")
|
|
252
326
|
return exitCode === 0 ? "success" : "failure";
|
|
253
|
-
const error =
|
|
327
|
+
const error = getString3(input, ["error", "errorMessage"]) ?? getNestedString3(input, [["tool_response", "error"], ["result", "error"]]);
|
|
254
328
|
if (error)
|
|
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;
|
|
@@ -713,12 +799,138 @@ var require_salt = __commonJS({
|
|
|
713
799
|
}
|
|
714
800
|
});
|
|
715
801
|
|
|
802
|
+
// ../packages/tool-kit/out/liveBus.js
|
|
803
|
+
var require_liveBus = __commonJS({
|
|
804
|
+
"../packages/tool-kit/out/liveBus.js"(exports) {
|
|
805
|
+
"use strict";
|
|
806
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
807
|
+
if (k2 === void 0) k2 = k;
|
|
808
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
809
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
810
|
+
desc = { enumerable: true, get: function() {
|
|
811
|
+
return m[k];
|
|
812
|
+
} };
|
|
813
|
+
}
|
|
814
|
+
Object.defineProperty(o, k2, desc);
|
|
815
|
+
} : function(o, m, k, k2) {
|
|
816
|
+
if (k2 === void 0) k2 = k;
|
|
817
|
+
o[k2] = m[k];
|
|
818
|
+
});
|
|
819
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
820
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
821
|
+
} : function(o, v) {
|
|
822
|
+
o["default"] = v;
|
|
823
|
+
});
|
|
824
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
825
|
+
var ownKeys = function(o) {
|
|
826
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
827
|
+
var ar = [];
|
|
828
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
829
|
+
return ar;
|
|
830
|
+
};
|
|
831
|
+
return ownKeys(o);
|
|
832
|
+
};
|
|
833
|
+
return function(mod) {
|
|
834
|
+
if (mod && mod.__esModule) return mod;
|
|
835
|
+
var result = {};
|
|
836
|
+
if (mod != null) {
|
|
837
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
838
|
+
}
|
|
839
|
+
__setModuleDefault(result, mod);
|
|
840
|
+
return result;
|
|
841
|
+
};
|
|
842
|
+
}();
|
|
843
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
844
|
+
exports.liveBusSocketCandidates = liveBusSocketCandidates;
|
|
845
|
+
exports.liveBusSocketPath = liveBusSocketPath;
|
|
846
|
+
exports.bucketPromptSize = bucketPromptSize2;
|
|
847
|
+
exports.emitLiveSignal = emitLiveSignal2;
|
|
848
|
+
var fs = __importStar(__require("fs"));
|
|
849
|
+
var net = __importStar(__require("net"));
|
|
850
|
+
var os = __importStar(__require("os"));
|
|
851
|
+
var path = __importStar(__require("path"));
|
|
852
|
+
var WRITE_TIMEOUT_MS = 50;
|
|
853
|
+
var APP_BUNDLE_ID = "one.ascenda.ascendaMissionControl";
|
|
854
|
+
function liveBusSocketCandidates() {
|
|
855
|
+
const override = process.env.ASCENDA_LIVE_BUS_SOCKET;
|
|
856
|
+
if (override)
|
|
857
|
+
return [override];
|
|
858
|
+
const home = os.homedir();
|
|
859
|
+
return [
|
|
860
|
+
path.join(home, ".ascenda", "live.sock"),
|
|
861
|
+
path.join(home, "Library", "Containers", APP_BUNDLE_ID, "Data", ".ascenda", "live.sock")
|
|
862
|
+
];
|
|
863
|
+
}
|
|
864
|
+
function liveBusSocketPath() {
|
|
865
|
+
const candidates = liveBusSocketCandidates();
|
|
866
|
+
for (const candidate of candidates) {
|
|
867
|
+
try {
|
|
868
|
+
if (fs.statSync(candidate).isSocket())
|
|
869
|
+
return candidate;
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return candidates[0];
|
|
874
|
+
}
|
|
875
|
+
function bucketPromptSize2(text) {
|
|
876
|
+
const length = typeof text === "string" ? text.length : 0;
|
|
877
|
+
if (length <= 280)
|
|
878
|
+
return "s";
|
|
879
|
+
if (length <= 2e3)
|
|
880
|
+
return "m";
|
|
881
|
+
if (length <= 8e3)
|
|
882
|
+
return "l";
|
|
883
|
+
return "xl";
|
|
884
|
+
}
|
|
885
|
+
function emitLiveSignal2(signal) {
|
|
886
|
+
return new Promise((resolve) => {
|
|
887
|
+
let settled = false;
|
|
888
|
+
const done = () => {
|
|
889
|
+
if (settled)
|
|
890
|
+
return;
|
|
891
|
+
settled = true;
|
|
892
|
+
try {
|
|
893
|
+
socket.destroy();
|
|
894
|
+
} catch {
|
|
895
|
+
}
|
|
896
|
+
resolve();
|
|
897
|
+
};
|
|
898
|
+
let socket;
|
|
899
|
+
try {
|
|
900
|
+
socket = net.createConnection(liveBusSocketPath());
|
|
901
|
+
} catch {
|
|
902
|
+
resolve();
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
const timer = setTimeout(done, WRITE_TIMEOUT_MS);
|
|
906
|
+
if (typeof timer.unref === "function")
|
|
907
|
+
timer.unref();
|
|
908
|
+
if (typeof socket.unref === "function")
|
|
909
|
+
socket.unref();
|
|
910
|
+
socket.on("error", done);
|
|
911
|
+
socket.on("connect", () => {
|
|
912
|
+
try {
|
|
913
|
+
socket.write(`${JSON.stringify(signal)}
|
|
914
|
+
`, () => {
|
|
915
|
+
clearTimeout(timer);
|
|
916
|
+
done();
|
|
917
|
+
});
|
|
918
|
+
} catch {
|
|
919
|
+
clearTimeout(timer);
|
|
920
|
+
done();
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
|
|
716
928
|
// ../packages/tool-kit/out/index.js
|
|
717
929
|
var require_out2 = __commonJS({
|
|
718
930
|
"../packages/tool-kit/out/index.js"(exports) {
|
|
719
931
|
"use strict";
|
|
720
932
|
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;
|
|
933
|
+
exports.parseIngestResponse = exports.postToolEventsBatch = exports.postToolEvent = exports.renewToolToken = exports.getPairingStatus = exports.createPairingSession = exports.AscendaApiError = exports.liveBusSocketCandidates = exports.liveBusSocketPath = exports.bucketPromptSize = exports.emitLiveSignal = 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
934
|
var commandClassifier_1 = require_commandClassifier();
|
|
723
935
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
724
936
|
return commandClassifier_1.classifyCommand;
|
|
@@ -770,6 +982,9 @@ var require_out2 = __commonJS({
|
|
|
770
982
|
Object.defineProperty(exports, "inferOutcome", { enumerable: true, get: function() {
|
|
771
983
|
return payload_1.inferOutcome;
|
|
772
984
|
} });
|
|
985
|
+
Object.defineProperty(exports, "outcomeForHook", { enumerable: true, get: function() {
|
|
986
|
+
return payload_1.outcomeForHook;
|
|
987
|
+
} });
|
|
773
988
|
Object.defineProperty(exports, "looksLikeCorrection", { enumerable: true, get: function() {
|
|
774
989
|
return payload_1.looksLikeCorrection;
|
|
775
990
|
} });
|
|
@@ -800,6 +1015,19 @@ var require_out2 = __commonJS({
|
|
|
800
1015
|
Object.defineProperty(exports, "hashWithMachineSalt", { enumerable: true, get: function() {
|
|
801
1016
|
return salt_1.hashWithMachineSalt;
|
|
802
1017
|
} });
|
|
1018
|
+
var liveBus_1 = require_liveBus();
|
|
1019
|
+
Object.defineProperty(exports, "emitLiveSignal", { enumerable: true, get: function() {
|
|
1020
|
+
return liveBus_1.emitLiveSignal;
|
|
1021
|
+
} });
|
|
1022
|
+
Object.defineProperty(exports, "bucketPromptSize", { enumerable: true, get: function() {
|
|
1023
|
+
return liveBus_1.bucketPromptSize;
|
|
1024
|
+
} });
|
|
1025
|
+
Object.defineProperty(exports, "liveBusSocketPath", { enumerable: true, get: function() {
|
|
1026
|
+
return liveBus_1.liveBusSocketPath;
|
|
1027
|
+
} });
|
|
1028
|
+
Object.defineProperty(exports, "liveBusSocketCandidates", { enumerable: true, get: function() {
|
|
1029
|
+
return liveBus_1.liveBusSocketCandidates;
|
|
1030
|
+
} });
|
|
803
1031
|
var http_1 = require_http();
|
|
804
1032
|
Object.defineProperty(exports, "AscendaApiError", { enumerable: true, get: function() {
|
|
805
1033
|
return http_1.AscendaApiError;
|
|
@@ -902,8 +1130,13 @@ function mapClaudeEvent(hookName, input) {
|
|
|
902
1130
|
return mapUserPromptSubmit(input);
|
|
903
1131
|
case "PreToolUse":
|
|
904
1132
|
return mapPreToolUse(input);
|
|
1133
|
+
// Success and failure arrive on different hooks with different payloads —
|
|
1134
|
+
// PostToolUse carries tool_response and no exit code; PostToolUseFailure
|
|
1135
|
+
// carries `error`/`is_interrupt` and no tool_response. One mapper handles
|
|
1136
|
+
// both so the event vocabulary cannot drift between the two paths.
|
|
905
1137
|
case "PostToolUse":
|
|
906
|
-
|
|
1138
|
+
case "PostToolUseFailure":
|
|
1139
|
+
return mapPostToolUse(hookName, input);
|
|
907
1140
|
case "PreCompact":
|
|
908
1141
|
return mapPreCompact(input);
|
|
909
1142
|
case "PostCompact":
|
|
@@ -922,7 +1155,7 @@ function isNewSessionStart(input) {
|
|
|
922
1155
|
return !source || source === "startup" || source === "resume";
|
|
923
1156
|
}
|
|
924
1157
|
function milestoneInviting(input) {
|
|
925
|
-
if ((0, import_tool_kit4.
|
|
1158
|
+
if ((0, import_tool_kit4.outcomeForHook)("PostToolUse", input) !== "success") return false;
|
|
926
1159
|
const command = (0, import_tool_kit4.getString)(input, ["command"]) ?? (0, import_tool_kit4.getNestedString)(input, [["tool_input", "command"], ["input", "command"], ["parameters", "command"]]);
|
|
927
1160
|
return (0, import_tool_kit5.invitesDebrief)((0, import_tool_kit5.classifyWorkMilestone)(command));
|
|
928
1161
|
}
|
|
@@ -941,15 +1174,18 @@ function mapUserPromptSubmit(input) {
|
|
|
941
1174
|
function mapPreToolUse(input) {
|
|
942
1175
|
return [{ eventType: "ai_tool_call_started", severity: "low", metadata: { toolName: sanitiseToolName(getToolName(input)) } }];
|
|
943
1176
|
}
|
|
944
|
-
function mapPostToolUse(input) {
|
|
1177
|
+
function mapPostToolUse(hookName, input) {
|
|
945
1178
|
const toolName = getToolName(input);
|
|
946
1179
|
const safeToolName = sanitiseToolName(toolName);
|
|
947
|
-
const outcome = (0, import_tool_kit4.
|
|
948
|
-
const durationMs = (0, import_tool_kit4.getNumber)(input, ["
|
|
1180
|
+
const outcome = (0, import_tool_kit4.outcomeForHook)(hookName, input);
|
|
1181
|
+
const durationMs = (0, import_tool_kit4.getNumber)(input, ["duration_ms", "durationMs", "elapsedMs"]) ?? (0, import_tool_kit4.getNestedNumber)(input, [["tool_response", "durationMs"], ["result", "durationMs"]]);
|
|
949
1182
|
const command = (0, import_tool_kit4.getString)(input, ["command"]) ?? (0, import_tool_kit4.getNestedString)(input, [["tool_input", "command"], ["input", "command"], ["parameters", "command"]]);
|
|
950
1183
|
const commandClass = (0, import_tool_kit5.classifyCommand)(command);
|
|
951
|
-
const gitAction = outcome === "
|
|
952
|
-
const milestoneKind = outcome === "
|
|
1184
|
+
const gitAction = outcome === "success" ? (0, import_tool_kit5.classifyGitAction)(command) : void 0;
|
|
1185
|
+
const milestoneKind = outcome === "success" ? (0, import_tool_kit5.classifyWorkMilestone)(command) : void 0;
|
|
1186
|
+
if (outcome === "cancelled") {
|
|
1187
|
+
return [{ eventType: "ai_tool_call_failed", severity: "low", metadata: { toolName: safeToolName, commandClass, outcome, durationBucket: (0, import_tool_kit4.bucketDurationMs)(durationMs), reason: "manual_interrupt" } }];
|
|
1188
|
+
}
|
|
953
1189
|
if (outcome === "failure") {
|
|
954
1190
|
if (toolName?.toLowerCase() === "bash" && (0, import_tool_kit5.isVerificationCommand)(commandClass)) {
|
|
955
1191
|
return [{ eventType: "compile_error", severity: "medium", metadata: { toolName: safeToolName, commandClass, outcome, durationBucket: (0, import_tool_kit4.bucketDurationMs)(durationMs), reason: "test_failure" } }];
|
|
@@ -1134,6 +1370,7 @@ async function main() {
|
|
|
1134
1370
|
hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: MILESTONE_DEBRIEF_INVITE }
|
|
1135
1371
|
}));
|
|
1136
1372
|
}
|
|
1373
|
+
await emitLive(hookName, input);
|
|
1137
1374
|
const config = loadConfigFromEnv();
|
|
1138
1375
|
const client = new AscendaClient(config);
|
|
1139
1376
|
const mappedEvents = mapClaudeEvent(hookName, input);
|
|
@@ -1153,6 +1390,24 @@ async function main() {
|
|
|
1153
1390
|
}
|
|
1154
1391
|
}
|
|
1155
1392
|
}
|
|
1393
|
+
async function emitLive(hookName, input) {
|
|
1394
|
+
const event = hookName === "UserPromptSubmit" ? "prompt_submitted" : hookName === "PreToolUse" ? "tool_call" : hookName === "PreCompact" ? "compaction" : hookName === "PostToolUseFailure" ? "tool_failure" : hookName === "Stop" ? "stop" : void 0;
|
|
1395
|
+
if (!event) return;
|
|
1396
|
+
try {
|
|
1397
|
+
const prompt = event === "prompt_submitted" ? (0, import_tool_kit6.getString)(input, ["prompt", "userPrompt", "message"]) ?? (0, import_tool_kit6.getNestedString)(input, [["payload", "prompt"], ["payload", "message"]]) : void 0;
|
|
1398
|
+
await (0, import_tool_kit6.emitLiveSignal)({
|
|
1399
|
+
tool: process.env.ASCENDA_TOOL_TYPE ?? "claude_code",
|
|
1400
|
+
// Concurrent sessions must count as separate streams for the X gauge.
|
|
1401
|
+
// Without a session id every window collapses into one, so fall back to
|
|
1402
|
+
// this process's parent — still per-session in practice, since Claude
|
|
1403
|
+
// Code spawns hooks from the session process.
|
|
1404
|
+
session: (0, import_tool_kit6.getString)(input, ["session_id", "sessionId"]) ?? process.env.ASCENDA_SESSION_ID ?? `ppid-${process.ppid}`,
|
|
1405
|
+
event,
|
|
1406
|
+
...prompt !== void 0 ? { sizeBucket: (0, import_tool_kit6.bucketPromptSize)(prompt) } : {}
|
|
1407
|
+
});
|
|
1408
|
+
} catch {
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1156
1411
|
async function readJsonFromStdin() {
|
|
1157
1412
|
const chunks = [];
|
|
1158
1413
|
for await (const chunk of process.stdin) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAwC,MAAM,YAAY,CAAC;AAErF,MAAM,gBAAgB,GACpB,yEAAyE;IACzE,oEAAoE;IACpE,uDAAuD,CAAC;AAE1D;;;;;;;;;;;GAW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AG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9E,OAAO,MAAyB,CAAC;AACnC,CAAC;AAED,IAAI,EAAE;KACH,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACf,yEAAyE;IACzE,0EAA0E;IAC1E,yEAAyE;IACzE,oEAAoE;IACpE,iEAAiE;IACjE,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACxE,CAAC,CAAC;KACD,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
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,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,
|
|
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,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhL,MAAM,UAAU,cAAc,CAAC,QAA6B,EAAE,KAAsB;IAClF,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,cAAc,CAAC,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QACnD,KAAK,kBAAkB,CAAC,CAAC,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3D,KAAK,YAAY,CAAC,CAAC,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/C,0EAA0E;QAC1E,yEAAyE;QACzE,0EAA0E;QAC1E,mEAAmE;QACnE,KAAK,aAAa,CAAC;QACnB,KAAK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AAK,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.8",
|
|
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"
|