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

224 hivemind question platform agnostic data transformation #225

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
7e72e3e
feat: move bot as a new folder
Behzad-rabiei Oct 22, 2024
7c40900
fix: fix the issue
Behzad-rabiei Oct 22, 2024
3833ddc
add codes
Behzad-rabiei Oct 22, 2024
de6771f
fix: update workflow
Behzad-rabiei Oct 22, 2024
d245599
test: test the bot
Behzad-rabiei Oct 22, 2024
ed88a91
test: test the bot
Behzad-rabiei Oct 22, 2024
8bbd9cc
test: fix bug
Behzad-rabiei Oct 22, 2024
e084b90
test: check the test ci
Behzad-rabiei Oct 23, 2024
c6714c0
test: check test ci
Behzad-rabiei Oct 23, 2024
0033c1d
test: check test ci!
Behzad-rabiei Oct 23, 2024
6267c1d
refactor: clean the workflows
Behzad-rabiei Oct 23, 2024
cfe6f79
fix: fix the lint ci
Behzad-rabiei Oct 23, 2024
0ae3492
fix: fix the lint ci
Behzad-rabiei Oct 23, 2024
786583d
fix: fix the lint ci!!
Behzad-rabiei Oct 23, 2024
af3355d
fix: fix the lint ci :)
Behzad-rabiei Oct 23, 2024
1de91cb
fix: fix the lint ci :(
Behzad-rabiei Oct 23, 2024
ffaea59
fix: fix the ci :/
Behzad-rabiei Oct 23, 2024
2d0d5de
fix: fix the lint ci
Behzad-rabiei Oct 23, 2024
00e40fa
fix: fix the lint ci :)
Behzad-rabiei Oct 23, 2024
25ef0c5
fix: fix the lint ci
Behzad-rabiei Oct 23, 2024
ae4c08e
test
Behzad-rabiei Oct 23, 2024
3d51529
fix lint ci
Behzad-rabiei Oct 23, 2024
645b4e5
test 2
Behzad-rabiei Oct 23, 2024
26f95bc
fix: fix lints errors
Behzad-rabiei Oct 23, 2024
ccce869
format: change prettier setting and format code
Behzad-rabiei Oct 24, 2024
a5d09a9
lint: update lints
Behzad-rabiei Oct 24, 2024
9b5afa9
lint: lint the bot
Behzad-rabiei Oct 24, 2024
f846209
lint: lint the hivemind-adapter
Behzad-rabiei Oct 24, 2024
bfe7e2e
update lint ci
Behzad-rabiei Oct 24, 2024
0fa7a73
update lint ci config
Behzad-rabiei Oct 24, 2024
5c89dd0
bot: format the code
Behzad-rabiei Oct 24, 2024
4505abc
bot: fix lint issues
Behzad-rabiei Oct 24, 2024
2c4ef7e
bot: fix lint issues!
Behzad-rabiei Oct 24, 2024
54a2072
format: format the code
Behzad-rabiei Oct 24, 2024
981b9ea
update bot ci
Behzad-rabiei Oct 24, 2024
0c74949
bot: check ci
Behzad-rabiei Oct 24, 2024
8eca6b0
update bot ci!
Behzad-rabiei Oct 24, 2024
21473ad
bot: check test ci
Behzad-rabiei Oct 24, 2024
c4a5328
ci: update test ci
Behzad-rabiei Oct 24, 2024
3d7569d
bot: test the test ci
Behzad-rabiei Oct 24, 2024
8dab3fa
bot: fix dockerFile
Behzad-rabiei Oct 24, 2024
cac48f9
bot: fix dockerFile
Behzad-rabiei Oct 24, 2024
4e74991
bot: fix workdir
Behzad-rabiei Oct 24, 2024
8fea8f2
bot: fix workdir
Behzad-rabiei Oct 24, 2024
1ba0919
bot: fix workdir
Behzad-rabiei Oct 24, 2024
d3c49ac
bot: fix workdir
Behzad-rabiei Oct 24, 2024
f7fbe1f
bot: fix dockerfile
Behzad-rabiei Oct 24, 2024
fe5be33
bot: fix dockerfile
Behzad-rabiei Oct 24, 2024
685e7fa
bot: fix dockerfile!
Behzad-rabiei Oct 24, 2024
d4af98b
bot: fix dockerfile
Behzad-rabiei Oct 24, 2024
b06a491
bot: fix dockerfile
Behzad-rabiei Oct 24, 2024
a9c0966
bot: fix channel service
Behzad-rabiei Oct 25, 2024
2a4153c
ci: update workflows
Behzad-rabiei Oct 25, 2024
d8c9e71
bot: test ci
Behzad-rabiei Oct 25, 2024
553a00f
bot: test ci
Behzad-rabiei Oct 25, 2024
2a1032a
bot: test ci
Behzad-rabiei Oct 25, 2024
f3b1fd6
bot: test ci
Behzad-rabiei Oct 25, 2024
5c82534
bot: test ci
Behzad-rabiei Oct 25, 2024
b15175c
bot: test ci
Behzad-rabiei Oct 25, 2024
881e64d
bot: test ci
Behzad-rabiei Oct 25, 2024
9a31a79
bot: test ci
Behzad-rabiei Oct 25, 2024
bc78e3a
bot: test ci
Behzad-rabiei Oct 25, 2024
69503c6
bot: test ci
Behzad-rabiei Oct 25, 2024
8f86f27
bot: test ci
Behzad-rabiei Oct 25, 2024
4b00e40
bot: test ci
Behzad-rabiei Oct 25, 2024
0f56904
bot: test ci
Behzad-rabiei Oct 25, 2024
32d1dd3
bot: test ci
Behzad-rabiei Oct 25, 2024
6199521
update dockerfiles
Behzad-rabiei Oct 27, 2024
4380dd1
update workflows
Behzad-rabiei Oct 27, 2024
6b3eebb
test CIs
Behzad-rabiei Oct 27, 2024
9795dee
test CIs
Behzad-rabiei Oct 27, 2024
3b8f593
fix workflows
Behzad-rabiei Oct 27, 2024
f42c843
fix workflows
Behzad-rabiei Oct 27, 2024
c78d2d6
update workflows
Behzad-rabiei Oct 27, 2024
0a1748d
test cis
Behzad-rabiei Oct 27, 2024
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
51 changes: 51 additions & 0 deletions .github/workflows/bot-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# .github/workflows/bot-ci.yml

name: Bot CI Pipeline

on:
push:
paths:
- "bot/**"
pull_request:
paths:
- "bot/**"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding branch restrictions to the workflow triggers.

The workflow currently runs on all branches. To optimize CI resources, consider limiting the workflow to run only on main/master branch for pushes and pull requests targeting these branches.

 on:
   push:
+    branches: [ main, master ]
     paths:
       - "bot/**"
   pull_request:
+    branches: [ main, master ]
     paths:
       - "bot/**"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
push:
paths:
- "bot/**"
pull_request:
paths:
- "bot/**"
on:
push:
branches: [ main, master ]
paths:
- "bot/**"
pull_request:
branches: [ main, master ]
paths:
- "bot/**"


jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: super-linter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_DOCKERFILE_HADOLINT: false
VALIDATE_JSCPD: false
VALIDATE_PYTHON_FLAKE8: false
VALIDATE_PYTHON_MYPY: false

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- run: npm install --force
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid using --force with npm install.

Using --force can mask dependency conflicts and potentially lead to runtime issues. Consider resolving package conflicts properly instead.

-      - run: npm install --force
+      - run: npm install
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- run: npm install --force
- run: npm install

- run: npm run test
- uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run test:cov

build-push:
# needs: [lint, test]
needs: [lint, test]
uses: ./.github/workflows/build-push.yml
with:
app_name: "bot"
context: "./bot"
dockerfile: "./bot/Dockerfile"
59 changes: 59 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# .github/workflows/build-push.yml
name: Build and Push Docker Image

on:
workflow_call:
inputs:
app_name:
description: "Name of the application (bot or hivemind-adapter)"
required: true
type: string
context:
description: "Build context path"
required: true
type: string
dockerfile:
description: "Path to the Dockerfile"
required: true
type: string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation for security.

Consider adding pattern validation to restrict input values:

  • app_name should only accept 'bot' or 'hivemind-adapter'
  • context and dockerfile should be validated to prevent path traversal
 inputs:
   app_name:
     description: "Name of the application (bot or hivemind-adapter)"
     required: true
     type: string
+    pattern: '^(bot|hivemind-adapter)$'
   context:
     description: "Build context path"
     required: true
     type: string
+    pattern: '^[a-zA-Z0-9/_.-]+$'
   dockerfile:
     description: "Path to the Dockerfile"
     required: true
     type: string
+    pattern: '^[a-zA-Z0-9/_.-]+Dockerfile[a-zA-Z0-9._-]*$'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
workflow_call:
inputs:
app_name:
description: "Name of the application (bot or hivemind-adapter)"
required: true
type: string
context:
description: "Build context path"
required: true
type: string
dockerfile:
description: "Path to the Dockerfile"
required: true
type: string
on:
workflow_call:
inputs:
app_name:
description: "Name of the application (bot or hivemind-adapter)"
required: true
type: string
pattern: '^(bot|hivemind-adapter)$'
context:
description: "Build context path"
required: true
type: string
pattern: '^[a-zA-Z0-9/_.-]+$'
dockerfile:
description: "Path to the Dockerfile"
required: true
type: string
pattern: '^[a-zA-Z0-9/_.-]+Dockerfile[a-zA-Z0-9._-]*$'


env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-${{ inputs.app_name }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider making the registry configurable.

While using GHCR is good, consider making the registry configurable to support potential future requirements to use different registries.

 env:
-  REGISTRY: ghcr.io
+  REGISTRY: ${{ inputs.registry || 'ghcr.io' }}
   IMAGE_NAME: ${{ github.repository }}-${{ inputs.app_name }}

And add to inputs:

registry:
  description: "Container registry URL (defaults to ghcr.io)"
  required: false
  type: string


jobs:
build-push:
name: Build and Push Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Comment on lines +32 to +59
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance build performance and security.

Consider the following improvements:

  1. Add layer caching for faster builds
  2. Add security scanning for vulnerabilities
  3. Specify build platforms explicitly
 - name: Build and push Docker image
   uses: docker/build-push-action@v5
   with:
     context: ${{ inputs.context }}
     file: ${{ inputs.dockerfile }}
     push: true
     tags: ${{ steps.meta.outputs.tags }}
     labels: ${{ steps.meta.outputs.labels }}
+    cache-from: type=gha
+    cache-to: type=gha,mode=max
+    platforms: linux/amd64,linux/arm64

And add before the build step:

- name: Run Trivy vulnerability scanner
  uses: aquasecurity/trivy-action@master
  with:
    image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
    format: 'table'
    exit-code: '1'
    ignore-unfixed: true
    vuln-type: 'os,library'
    severity: 'CRITICAL,HIGH'

11 changes: 0 additions & 11 deletions .github/workflows/ci.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/hivemind-adapter-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# .github/workflows/hivemind-adapter-ci.yml

name: Hivemind Adapter CI Pipeline

on:
push:
paths:
- "hivemind-adapter/**"
pull_request:
paths:
- "hivemind-adapter/**"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding branch filters for push events.

While the path filters are correctly configured, consider adding branch filters for the push event to avoid unnecessary workflow runs on feature branches.

 on:
   push:
+    branches:
+      - main
+      - develop
     paths:
       - "hivemind-adapter/**"
   pull_request:
     paths:
       - "hivemind-adapter/**"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
push:
paths:
- "hivemind-adapter/**"
pull_request:
paths:
- "hivemind-adapter/**"
on:
push:
branches:
- main
- develop
paths:
- "hivemind-adapter/**"
pull_request:
paths:
- "hivemind-adapter/**"


jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: super-linter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_DOCKERFILE_HADOLINT: false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Enabling Dockerfile validation is recommended

Both bot/Dockerfile and hivemind-adapter/Dockerfile contain multi-stage builds with potential areas where hadolint could provide valuable feedback:

  • Multiple npm install commands that could be optimized
  • Potential security considerations with node base images
  • Copy operations that might benefit from .dockerignore optimization
  • Possible improvements in layer caching

Specific locations that would benefit from hadolint validation:

  • bot/Dockerfile: npm ci operations and base image selection
  • hivemind-adapter/Dockerfile: multiple npm install commands and COPY operations
🔗 Analysis chain

Reconsider disabling Dockerfile validation.

Dockerfile validation (hadolint) is currently disabled. Consider enabling it to catch potential issues in Dockerfile best practices and security.


Let me search more broadly for any Dockerfile in the repository to make a well-informed decision.


Let me check the content of these Dockerfiles to determine if Dockerfile validation would be valuable.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the Dockerfile exists and contains content
if [ -f "hivemind-adapter/Dockerfile" ]; then
    echo "Dockerfile exists. Consider enabling hadolint validation."
    cat hivemind-adapter/Dockerfile
fi

Length of output: 161


Script:

#!/bin/bash
# Search for any Dockerfile in the repository
fd Dockerfile

# Also check if there are any docker-compose files that might indicate Docker usage
fd docker-compose

Length of output: 291


Script:

#!/bin/bash
# Check contents of both Dockerfiles
echo "=== bot/Dockerfile ==="
cat bot/Dockerfile

echo -e "\n=== hivemind-adapter/Dockerfile ==="
cat hivemind-adapter/Dockerfile

Length of output: 1236

VALIDATE_JSCPD: false
VALIDATE_PYTHON_FLAKE8: false
VALIDATE_PYTHON_MYPY: false

# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v3
# with:
# node-version: 20
# cache: "npm"
# - run: npm install --force
# - run: npm run test
# - uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageCommand: npm run test:cov

build-push:
# needs: [lint, test]
needs: [lint]
uses: ./.github/workflows/build-push.yml
with:
app_name: "hivemind-adapter"
context: "./hivemind-adapter"
dockerfile: "./hivemind-adapter/Dockerfile"
12 changes: 0 additions & 12 deletions .github/workflows/production.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/publish.yml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions package-lock.json → bot/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json → bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@pyroscope/nodejs": "^0.2.8",
"@sentry/node": "^7.51.2",
"@togethercrew.dev/db": "^3.0.63",
"@togethercrew.dev/tc-messagebroker": "^0.0.46",
"@togethercrew.dev/tc-messagebroker": "^0.0.48",
"babel-jest": "^29.5.0",
"bullmq": "^3.14.0",
"discord.js": "^14.15.2",
Expand Down
43 changes: 43 additions & 0 deletions bot/src/commands/info/question.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { SlashCommandBuilder } from 'discord.js';
import { interactionService } from '../../services';
import RabbitMQ, { Event, Queue as RabbitMQQueue } from '@togethercrew.dev/tc-messagebroker';
import { type ChatInputCommandInteraction_broker } from '../../interfaces/Hivemind.interface';
import parentLogger from '../../config/logger';
const logger = parentLogger.child({ command: 'question' });

export default {
data: new SlashCommandBuilder()
.setName('question')
.setDescription('Ask a question and get an answer from Hivemind!')
.addStringOption((option) =>
option.setName('question').setDescription('Your question to Hivemind').setRequired(true),
),

async execute(interaction: ChatInputCommandInteraction_broker) {
logger.info({ interaction_id: interaction.id, user: interaction.user }, 'question command started');

try {
await interactionService.createInteractionResponse(interaction, {
type: 5,
data: { flags: 64 },
});
RabbitMQ.publish(
RabbitMQQueue.DISCORD_HIVEMIND_ADAPTER,
Event.DISCORD_HIVEMIND_ADAPTER.QUESTION_COMMAND_RECEIVED,
{
interaction,
},
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure the 'interaction' object is serializable before publishing

The interaction object from discord.js contains methods and properties that may not be serializable or may include unnecessary or sensitive information. Directly publishing it could lead to serialization errors or unintended data exposure, including PII (Personally Identifiable Information). It's recommended to extract and send only the required data needed by the consumer.

Apply this diff to extract the necessary data:

RabbitMQ.publish(
  RabbitMQQueue.DISCORD_HIVEMIND_ADAPTER,
  Event.DISCORD_HIVEMIND_ADAPTER.QUESTION_COMMAND_RECEIVED,
  {
-   interaction,
+   interactionData: {
+     id: interaction.id,
+     user: {
+       id: interaction.user.id,
+       username: interaction.user.username,
+       discriminator: interaction.user.discriminator,
+     },
+     guildId: interaction.guildId,
+     channelId: interaction.channelId,
+     options: interaction.options.data,
+   },
  },
);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RabbitMQ.publish(
RabbitMQQueue.DISCORD_HIVEMIND_ADAPTER,
Event.DISCORD_HIVEMIND_ADAPTER.QUESTION_COMMAND_RECEIVED,
{
interaction,
},
);
RabbitMQ.publish(
RabbitMQQueue.DISCORD_HIVEMIND_ADAPTER,
Event.DISCORD_HIVEMIND_ADAPTER.QUESTION_COMMAND_RECEIVED,
{
interactionData: {
id: interaction.id,
user: {
id: interaction.user.id,
username: interaction.user.username,
discriminator: interaction.user.discriminator,
},
guildId: interaction.guildId,
channelId: interaction.channelId,
options: interaction.options.data,
},
},
);

} catch (error) {
logger.error(error, 'question command failed');
await interactionService.createInteractionResponse(interaction, {
type: 4,
data: {
content:
"Sorry, we couldn't process your request at the moment. Please report this issue to the TogetherCrew development team. Thank you for your patience!",
flags: 64,
},
});
}
},
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.ts → bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ async function app(): Promise<void> {
}

app().catch((error) => {
logger.fatal({ error }, 'Failed To start the application!!');
logger.fatal(error, 'Failed To start the application!!!');
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions hivemind-adapter/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
56 changes: 56 additions & 0 deletions hivemind-adapter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
9 changes: 9 additions & 0 deletions hivemind-adapter/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"**/*.ts": [
"eslint --fix",
"prettier --write"
],
"**/*.md": [
"prettier --write"
]
}
Comment on lines +1 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider enhancing the pre-commit hooks configuration.

The current configuration is good, but could be improved with additional checks:

 {
   "**/*.ts": [
+    "tsc --noEmit",
     "eslint --fix",
     "prettier --write"
   ],
   "**/*.md": [
+    "cspell",
     "prettier --write"
   ],
+  "**/*.{json,yml,yaml}": [
+    "prettier --write"
+  ]
 }

These changes would:

  1. Add type checking for TypeScript files
  2. Add spell checking for documentation
  3. Ensure consistent formatting for configuration files
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"**/*.ts": [
"eslint --fix",
"prettier --write"
],
"**/*.md": [
"prettier --write"
]
}
{
"**/*.ts": [
"tsc --noEmit",
"eslint --fix",
"prettier --write"
],
"**/*.md": [
"cspell",
"prettier --write"
],
"**/*.{json,yml,yaml}": [
"prettier --write"
]
}

7 changes: 7 additions & 0 deletions hivemind-adapter/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"singleQuote": true,
"printWidth": 80
}
Loading
Loading