-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(assistant): Code refactor and first draft of agenda assistant
- Loading branch information
1 parent
bcf04da
commit 07c7988
Showing
28 changed files
with
2,664 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,33 @@ | ||
module.exports = { | ||
root: true, | ||
ignorePatterns: [], | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx', 'd.ts'], | ||
}, | ||
}, | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
env: { | ||
node: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: 'module', | ||
}, | ||
plugins: [ | ||
'@typescript-eslint', | ||
'extra-rules', | ||
"overrides": [ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"files": [ | ||
".eslintrc.{js,cjs}" | ||
], | ||
"parserOptions": { | ||
"sourceType": "script" | ||
} | ||
} | ||
], | ||
rules: { | ||
// Following are rules we added to the airbnb-base ruleset. | ||
'extra-rules/no-commented-out-code': 'warn', | ||
|
||
// Following are rules we explicitly don't want to follow. | ||
'no-console': 'off', // Logging is a good practice. | ||
'import/extensions': ['error', 'always', { // Never allow .js .ts in imports. Make transition from .js to .ts easier. | ||
js: 'never', | ||
ts: 'never', | ||
}], | ||
'no-restricted-imports': ['error', { | ||
name: 'pg', | ||
importNames: ['Pool'], | ||
message: 'Use Pool from src/utils/db instead.', | ||
}], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['./src/**/*.test.js'], | ||
globals: { | ||
jest: true, | ||
it: true, | ||
fit: true, | ||
describe: true, | ||
afterAll: true, | ||
beforeAll: true, | ||
afterEach: true, | ||
expect: true, | ||
fail: true, | ||
}, | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
}; | ||
|
||
"rules": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.env | ||
node_modules | ||
/token.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# assistant | ||
|
||
A NodeJS app bridging the gap between openai/chatgpt and various tools : Home-Assistant, calendar, emails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,44 @@ | ||
|
||
// TODO: Switch to winston, use ENV_VAR to set log level we want to see | ||
|
||
let PROGRESS_INDEX = 0; | ||
|
||
/** | ||
* Log a message to the console with proper formatting | ||
* @param {string} category - The category of the log | ||
* @param {string} severity - The severity level of the log | ||
* @param {...string} messages - The messages to be logged | ||
*/ | ||
export async function log(category, severity, ...messages) { | ||
export async function log( | ||
category: string, | ||
severity: string, | ||
...messages: string[] | ||
) { | ||
if (severity === "debug") { | ||
return null; | ||
} | ||
const emojiForCategory = { | ||
openai: "🧠", | ||
ha: "🏠", | ||
google: "🔍", | ||
app: "🤖", | ||
prompt: "🗣️", | ||
response: "📢", | ||
server: "🌐", | ||
}; | ||
const emoji = emojiForCategory[category] || ""; | ||
return console.log(emoji, `[${category.toUpperCase()}]`, ...messages); | ||
} | ||
|
||
//if(severity === 'debug') { return null; } | ||
const emojiForCategory = { | ||
'openai': '🧠', | ||
'ha': '🏠', | ||
'app': '🤖', | ||
'prompt': '🗣️', | ||
'response': '📢', | ||
} | ||
const emoji = emojiForCategory[category] || ''; | ||
return console.log(emoji, `[${category.toUpperCase()}]`, ...messages); | ||
} | ||
/** | ||
* Logs progress bar message | ||
* @param {string} action - The action being performed | ||
* @param {string} [message] - Overwrite the default message entirely | ||
*/ | ||
export function logLoading(action = "Loading", message?: string) { | ||
const defaultMessage = `${action}${".".repeat((PROGRESS_INDEX % 3) + 1)}`; | ||
PROGRESS_INDEX = (PROGRESS_INDEX + 1) % 3; | ||
const messageToDisplay = message || defaultMessage; | ||
process.stdout.clearLine(0); | ||
process.stdout.cursorTo(0); | ||
process.stdout.write(messageToDisplay); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.