Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools hot fix #10

Merged
merged 5 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]


## [0.0.5a-alpha] - 2024-08-01

### Changed

- Hot fix for multiple tool result blocks
- Hot fix for undefined usage tokens


## [0.0.5-alpha] - 2024-08-01

### Changed
Expand All @@ -26,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use haiku to create semantic names for conversations based on initial prompts
- Use haiku to write commit messages


## [0.0.3-alpha] - 2024-07-27

### Changed
Expand All @@ -38,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- file searching, adding to conversation, and patching
- project editor to handle different data sources (only local filesystem so far)


## [0.0.2-alpha] - 2024-07-23

### Added
Expand All @@ -46,5 +56,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- File handling capabilities
- Conversation management features


## [0.0.1-alpha] - 2023-07-20
- Initial alpha release
2 changes: 1 addition & 1 deletion api/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbai-api",
"version": "0.0.5-alpha",
"version": "0.0.5a-alpha",
"exports": "./src/main.ts",
"tasks": {
"start": "deno run --allow-read --allow-write --allow-run --allow-net --allow-env src/main.ts",
Expand Down
18 changes: 9 additions & 9 deletions api/src/editor/projectEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ export class ProjectEditor {

let changesMade = false;
let allOperationsSkipped = true;
const toolWarnings = [];
for (const operation of operations) {
const { search, replace } = operation;

Expand All @@ -643,7 +644,7 @@ export class ProjectEditor {
JSON.stringify(operation)
}. Operation skipped.`;
logger.warn(warningMessage);
this.conversation?.addMessageForToolResult(toolUseId, warningMessage, true);
toolWarnings.push(warningMessage);
continue; // Skip this operation
}

Expand All @@ -656,6 +657,10 @@ export class ProjectEditor {
allOperationsSkipped = false;
}
}
let toolWarning = '';
if (toolWarnings.length > 0) {
toolWarning = `Tool Use Warnings: \n${toolWarnings.join('\n')}\n`;
}

if (changesMade) {
await Deno.writeTextFile(fullFilePath, content);
Expand All @@ -672,20 +677,15 @@ export class ProjectEditor {
// Add success tool result message
this.conversation?.addMessageForToolResult(
toolUseId,
`Search and replace operations applied successfully to file: ${filePath}`,
`${toolWarning}Search and replace operations applied successfully to file: ${filePath}`,
);
} else {
const noChangesMessage = allOperationsSkipped
? `No changes were made to the file: ${filePath}. All operations were skipped due to identical search and replace strings.`
: `No changes were made to the file: ${filePath}. The search strings were not found in the file content.`;
? `${toolWarning}No changes were made to the file: ${filePath}. All operations were skipped due to identical search and replace strings.`
: `${toolWarning}No changes were made to the file: ${filePath}. The search strings were not found in the file content.`;
logger.info(noChangesMessage);
this.conversation?.addMessageForToolResult(toolUseId, noChangesMessage, true);
}

this.conversation?.addMessageForToolResult(
toolUseId,
`Search and replace operations applied successfully to file: ${filePath}`,
);
} catch (error) {
let errorMessage = `Failed to apply search and replace to ${filePath}: ${error.message}`;
logger.error(errorMessage);
Expand Down
2 changes: 1 addition & 1 deletion cli/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbai-cli",
"version": "0.0.5-alpha",
"version": "0.0.5a-alpha",
"exports": "./src/main.ts",
"tasks": {
"start": "deno run --allow-read --allow-write --allow-run --allow-net src/main.ts",
Expand Down
16 changes: 8 additions & 8 deletions cli/src/commands/conversationStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ function handleConversationUpdate(formatter: LogFormatter, data: ConversationRes
colors.green(`${symbols.info} ${statementCount} `) + colors.magenta(`${symbols.radioOn} ${turnCount} `) +
colors.blue(`${symbols.clockwiseRightAndLeftSemicircleArrows} ${totalTurnCount}`);

const summaryLine2 = colors.bold.cyan(`└─ `) + colors.red(`${symbols.arrowDown} ${tokenUsage.inputTokens} `) +
colors.yellow(`${symbols.arrowUp} ${tokenUsage.outputTokens} `) +
colors.green(`${symbols.radioOn} ${tokenUsage.totalTokens}`);
const summaryLine2 = colors.bold.cyan(`└─ `) + colors.red(`${symbols.arrowDown} ${tokenUsage?.inputTokens} `) +
colors.yellow(`${symbols.arrowUp} ${tokenUsage?.outputTokens} `) +
colors.green(`${symbols.radioOn} ${tokenUsage?.totalTokens}`);

const titleLine = colors.bold.cyan(`│ Title: ${colors.white(title.padEnd(45))} │`);
const maxLength = Math.max(summaryLine1.length, summaryLine2.length, titleLine.length);
Expand All @@ -326,7 +326,7 @@ function handleConversationUpdate(formatter: LogFormatter, data: ConversationRes
console.log(summaryLine2 + ' '.repeat(maxLength - summaryLine2.length) + colors.bold.cyan('─┘') + '\n');

// console.log(colors.dim.italic(
// `Token Usage: Input: ${tokenUsage.inputTokens}, Output: ${tokenUsage.outputTokens}, Total: ${tokenUsage.totalTokens}`,
// `Token Usage: Input: ${tokenUsage?.inputTokens}, Output: ${tokenUsage?.outputTokens}, Total: ${tokenUsage?.totalTokens}`,
// ));
}

Expand Down Expand Up @@ -384,9 +384,9 @@ function handleConversationComplete(response: ConversationResponse, options: { i
colors.green(`${symbols.info} ${statementCount} `) + colors.magenta(`${symbols.radioOn} ${turnCount} `) +
colors.blue(`${symbols.clockwiseRightAndLeftSemicircleArrows} ${totalTurnCount}`);

const summaryLine2 = colors.bold.cyan(`└─ `) + colors.red(`${symbols.arrowDown} ${tokenUsage.inputTokens} `) +
colors.yellow(`${symbols.arrowUp} ${tokenUsage.outputTokens} `) +
colors.green(`${symbols.radioOn} ${tokenUsage.totalTokens}`);
const summaryLine2 = colors.bold.cyan(`└─ `) + colors.red(`${symbols.arrowDown} ${tokenUsage?.inputTokens} `) +
colors.yellow(`${symbols.arrowUp} ${tokenUsage?.outputTokens} `) +
colors.green(`${symbols.radioOn} ${tokenUsage?.totalTokens}`);

const titleLine = colors.bold.cyan(`│ Title: ${colors.white(title.padEnd(45))} │`);
const maxLength = Math.max(summaryLine1.length, summaryLine2.length, titleLine.length);
Expand All @@ -397,7 +397,7 @@ function handleConversationComplete(response: ConversationResponse, options: { i
console.log(summaryLine2 + ' '.repeat(maxLength - summaryLine2.length) + colors.bold.cyan('─┘'));

console.log(colors.dim.italic(
`Token Usage: Input: ${tokenUsage.inputTokens}, Output: ${tokenUsage.outputTokens}, Total: ${tokenUsage.totalTokens}`,
`Token Usage: Input: ${tokenUsage?.inputTokens}, Output: ${tokenUsage?.outputTokens}, Total: ${tokenUsage?.totalTokens}`,
));
}
}
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbai",
"version": "0.0.5-alpha",
"version": "0.0.5a-alpha",
"exports": "./cli/src/main.ts",
"tasks": {
"format": "deno fmt src/ && deno task -c ./cli/deno.jsonc format && deno task -c ./api/deno.jsonc format",
Expand Down
7 changes: 4 additions & 3 deletions src/shared/utils/fileListing.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, relative } from '@std/path';
import { globToRegExp, join, relative } from '@std/path';
import { exists, walk } from '@std/fs';
import { ConfigManager } from 'shared/configManager.ts';
import { logger } from './logger.utils.ts';
Expand Down Expand Up @@ -63,8 +63,9 @@ async function generateFileListingTier(

function shouldExclude(path: string, excludeOptions: string[]): boolean {
return excludeOptions.some((option) => {
const pattern = option.replace('--exclude=', '').replace(/\*/g, '.*');
return new RegExp(pattern).test(path);
const pattern = option.replace('--exclude=', '');
const regex = globToRegExp(pattern, { extended: true, globstar: true });
return regex.test(path);
});
}

Expand Down
2 changes: 1 addition & 1 deletion version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.0.5-alpha";
export const VERSION = "0.0.5a-alpha";
Loading