From 842ede4cc323bea05fd5bf704e0f6fb71509c134 Mon Sep 17 00:00:00 2001 From: Jason Jacobs Date: Tue, 9 Jul 2024 20:11:12 -0700 Subject: [PATCH 1/2] 0.21.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2752fe..6fd735c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "command-ai", - "version": "0.20.0", + "version": "0.21.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "command-ai", - "version": "0.20.0", + "version": "0.21.0", "license": "MIT", "dependencies": { "chalk": "^5.3.0", diff --git a/package.json b/package.json index 8287c6c..a761896 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "command-ai", - "version": "0.20.0", + "version": "0.21.0", "description": "Command AI", "main": "ai.js", "type": "module", From a6a69a076ef7136c0b941cc7d787067902740b64 Mon Sep 17 00:00:00 2001 From: Jason Jacobs Date: Tue, 9 Jul 2024 22:20:01 -0700 Subject: [PATCH 2/2] fix goodbye issue and ai's not working --- ai.js | 3 ++- aic.js | 9 ++++----- aiq.js | 15 +++++++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ai.js b/ai.js index b1375d0..fee6469 100755 --- a/ai.js +++ b/ai.js @@ -147,7 +147,8 @@ async function main(continuePrompt = true) { } } -if (import.meta.url === `file://${process.argv[1]}`) { + +if (!`file://${process.argv[1]}`.includes('!')) { main(); } diff --git a/aic.js b/aic.js index 3a8c4f8..7bc7feb 100755 --- a/aic.js +++ b/aic.js @@ -51,8 +51,6 @@ async function chatPrompt() { } async function startConversation(client, initialQuestion) { - const exitWords = new Set(["exit", "goodbye", "quit"]); - let continueConversation = true; let question = initialQuestion; @@ -61,7 +59,7 @@ async function startConversation(client, initialQuestion) { question = await chatPrompt(); } - if (shouldExitConversation(question, exitWords)) { + if (shouldExitConversation(question)) { continueConversation = false; break; } @@ -74,7 +72,8 @@ async function startConversation(client, initialQuestion) { process.exit(0); } -function shouldExitConversation(question, exitWords) { +function shouldExitConversation(question) { + const exitWords = new Set(["exit", "goodbye", "quit"]); return !question || exitWords.has(question.toLowerCase().trim()); } @@ -95,7 +94,7 @@ async function main(startConvo = true) { } } -if (import.meta.url === `file://${process.argv[1]}`) { +if (!`file://${process.argv[1]}`.includes('!')) { main(); } diff --git a/aiq.js b/aiq.js index f6e9b16..0c26dc1 100755 --- a/aiq.js +++ b/aiq.js @@ -429,6 +429,11 @@ async function promptConnectionDetails(existingConfig = {}) { }; } +function shouldExitConversation(question) { + const exitWords = new Set(["exit", "goodbye", "quit"]); + return !question || exitWords.has(question.toLowerCase().trim()); +} + async function promptForCommands(dbConfigs, connectionNameOrFile, client) { let command; do { @@ -441,10 +446,12 @@ async function promptForCommands(dbConfigs, connectionNameOrFile, client) { ]); command = input.command; - if (command.toLowerCase() !== "exit") { - await processQuery(dbConfigs, connectionNameOrFile, command, client); + if (shouldExitConversation(command)) { + break; } - } while (command.toLowerCase() !== "exit"); + + await processQuery(dbConfigs, connectionNameOrFile, command, client); + } while (true); } async function handleNoOrSingleParam() { @@ -487,7 +494,7 @@ async function main(prompt = true) { process.exit(0); } -if (import.meta.url === `file://${process.argv[1]}`) { +if (!`file://${process.argv[1]}`.includes('!')) { main(); }