UNPKG

@jjdenhertog/ai-driven-development

Version:

AI-driven development workflow with learning capabilities for Claude

36 lines 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.processToolExecutions = processToolExecutions; const createToolEntry_1 = require("./createToolEntry"); function processToolExecutions(logEntries) { var _a, _b; const executions = []; const toolStarts = new Map(); for (const entry of logEntries) { if (((_a = entry.data) === null || _a === void 0 ? void 0 : _a.hook_event_name) === 'PreToolUse' && entry.data.tool_name) { const key = `${entry.data.tool_name}-${entry.timestamp}`; toolStarts.set(key, entry); } else if (((_b = entry.data) === null || _b === void 0 ? void 0 : _b.hook_event_name) === 'PostToolUse' && entry.data.tool_name) { // Find matching PreToolUse let matchingStart; let matchingKey; for (const [key, start] of toolStarts) { if (key.startsWith(entry.data.tool_name)) { matchingStart = start; matchingKey = key; break; } } if (matchingStart && matchingKey) { toolStarts.delete(matchingKey); const duration = new Date(entry.timestamp).getTime() - new Date(matchingStart.timestamp).getTime(); const toolEntry = (0, createToolEntry_1.createToolEntry)(entry.data.tool_name, matchingStart.data.tool_input, entry.data.tool_response, matchingStart.timestamp, duration); executions.push(toolEntry); } } } return executions; } //# sourceMappingURL=processToolExecutions.js.map