From 5a0f5451155923c4b47042f5297b082d69923c2f Mon Sep 17 00:00:00 2001 From: Nicolas Vuillamy Date: Tue, 14 Jan 2025 21:22:47 +0100 Subject: [PATCH] Display number of AI prompts API calls at the end of a command --- CHANGELOG.md | 3 +++ src/hooks/postrun/notify.ts | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db2fcad16..2bc921069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,11 @@ Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image `hardisgroupcom/sfdx-hardis@beta` +## [5.15.3] 2025-01-14 + - [hardis:project:generate:flow-git-diff](https://sfdx-hardis.cloudity.com/hardis/project/generate/flow-git-diff/) New parameters --commit-before and --commit-after - [hardis:doc:project2markdown](https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/): Filter flows from managed packages +- Display number of AI prompts API calls at the end of a command ## [5.15.2] 2025-01-13 diff --git a/src/hooks/postrun/notify.ts b/src/hooks/postrun/notify.ts index 668479e4b..7cfafe6ab 100644 --- a/src/hooks/postrun/notify.ts +++ b/src/hooks/postrun/notify.ts @@ -5,17 +5,17 @@ import { Hook } from '@oclif/core'; // The use of this method is deprecated: use NotifProvider.sendNotification :) const hook: Hook<'postrun'> = async (options) => { - if (globalThis.hardisLogFileStream) { - globalThis.hardisLogFileStream.end(); - globalThis.hardisLogFileStream = null; - } - // Skip hooks from other commands than hardis commands const commandId = options?.Command?.id || ''; if (!commandId.startsWith('hardis')) { return; } + if (globalThis.hardisLogFileStream) { + globalThis.hardisLogFileStream.end(); + globalThis.hardisLogFileStream = null; + } + // Close WebSocketClient if existing if (globalThis.webSocketClient) { try { @@ -28,6 +28,10 @@ const hook: Hook<'postrun'> = async (options) => { globalThis.webSocketClient = null; } + const aiCounter = globalThis?.aiCallsNumber || 0; + if (aiCounter > 0) { + uxLog(this, c.grey(`AI prompts API calls: ${aiCounter}`)); + } elapseEnd(`${options?.Command?.id} execution time`); };