Skip to content

Commit

Permalink
Display number of AI prompts API calls at the end of a command
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Jan 14, 2025
1 parent b39cf42 commit 5a0f545
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions src/hooks/postrun/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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`);
};

Expand Down

0 comments on commit 5a0f545

Please sign in to comment.