From 65484efb41d52c713b2e0fa00641388ea6a83d11 Mon Sep 17 00:00:00 2001 From: Corneliu CROITORU Date: Fri, 26 Jul 2024 16:30:49 +0200 Subject: [PATCH 1/4] draft refactoring --- .github/workflows/npm-publish.yml | 11 +++++-- .github/workflows/run-lint.yml | 15 ---------- .github/workflows/run-security-checks.yml | 19 ++++++++++-- .github/workflows/run-tests.yml | 24 +++------------ .gitignore | 29 +++++++++---------- docs/src/env.d.ts | 2 ++ .eslintrc.js => typescript/.eslintrc.js | 0 .npmignore => typescript/.npmignore | 0 .../package-lock.json | 0 package.json => typescript/package.json | 0 .../tests}/Orchestrator.test.ts | 0 .../tests}/agents/Agents.test.ts | 0 .../classifiers/AnthropicClassifier.test.ts | 0 .../classifiers/BedrockClassifier.test.ts | 0 .../tests}/classifiers/Classifier.test.ts | 0 {tests => typescript/tests}/mock/mockAgent.ts | 0 .../tests}/retrievers/Retriever.test.ts | 0 .../tests}/storage/ChatStorage.test.ts | 0 .../tests}/utils/Utils.test.ts | 0 tsconfig.json => typescript/tsconfig.json | 0 20 files changed, 43 insertions(+), 57 deletions(-) create mode 100644 docs/src/env.d.ts rename .eslintrc.js => typescript/.eslintrc.js (100%) rename .npmignore => typescript/.npmignore (100%) rename package-lock.json => typescript/package-lock.json (100%) rename package.json => typescript/package.json (100%) rename {tests => typescript/tests}/Orchestrator.test.ts (100%) rename {tests => typescript/tests}/agents/Agents.test.ts (100%) rename {tests => typescript/tests}/classifiers/AnthropicClassifier.test.ts (100%) rename {tests => typescript/tests}/classifiers/BedrockClassifier.test.ts (100%) rename {tests => typescript/tests}/classifiers/Classifier.test.ts (100%) rename {tests => typescript/tests}/mock/mockAgent.ts (100%) rename {tests => typescript/tests}/retrievers/Retriever.test.ts (100%) rename {tests => typescript/tests}/storage/ChatStorage.test.ts (100%) rename {tests => typescript/tests}/utils/Utils.test.ts (100%) rename tsconfig.json => typescript/tsconfig.json (100%) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 2c9fdc8c..80b165e5 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -3,21 +3,26 @@ name: Publish to NPM -on: - workflow_dispatch +on: + workflow_dispatch: jobs: build-and-publish: runs-on: ubuntu-latest + defaults: + run: + working-directory: typescript steps: - uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6 - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 with: node-version: 20 registry-url: https://registry.npmjs.org/ + - run: cp ../LICENSE . + - run: cp ../README.md . - run: npm install - run: npm run build - run: npm pack - run: npm publish --access=public env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/run-lint.yml b/.github/workflows/run-lint.yml index c2b81f6c..ea3be780 100644 --- a/.github/workflows/run-lint.yml +++ b/.github/workflows/run-lint.yml @@ -28,18 +28,3 @@ jobs: run: npm install - name: Run linting run: npm run lint - # - name: Spell check - # uses: streetsidesoftware/cspell-action@4dc9d4bdf3974ed26d6f2e973c1e168edff47d80 - # with: - # files: '**/*.{md,ts}' - # strict: true - # check_dot_files: true - # incremental_files_only: false - # config: 'cspell.config.yml' - # - name: Run ShellCheck - # uses: ludeeus/action-shellcheck@cd81f4475ab741e097ec0fe73b692f3e49d66b8c - # with: - # scandir: '.' - # ignore_paths: >- - # node_modules - # .husky diff --git a/.github/workflows/run-security-checks.yml b/.github/workflows/run-security-checks.yml index a8529c31..5327b1f3 100644 --- a/.github/workflows/run-security-checks.yml +++ b/.github/workflows/run-security-checks.yml @@ -1,5 +1,4 @@ name: Run security checks on the project - on: workflow_call: workflow_dispatch: @@ -10,23 +9,37 @@ permissions: jobs: scan: runs-on: ubuntu-latest + defaults: + run: + working-directory: typescript steps: # Checkout and setup. - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 with: fetch-depth: 0 + - name: Install dependencies run: npm install # NPM audit. - name: Run audit run: npm audit - + continue-on-error: true + # GitLeaks. - name: Run Gitleaks uses: gitleaks/gitleaks-action@4df650038e2eb9f7329218df929c2780866e61a3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} - + + # Output results + - name: Output npm audit results + run: npm audit --json > npm_audit_results.json + + - name: Upload npm audit results + uses: actions/upload-artifact@v3 + with: + name: npm-audit-results + path: typescript/npm_audit_results.json \ No newline at end of file diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3ee59ce1..2ffbf3b4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,5 +1,4 @@ name: Run tests on the project - on: push: branches: @@ -8,14 +7,14 @@ on: types: - opened - edited - - permissions: contents: read - jobs: lint: runs-on: ubuntu-latest + defaults: + run: + working-directory: typescript steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 @@ -27,19 +26,4 @@ jobs: - name: Install dependencies run: npm install - name: Run tests - run: npm run coverage - # - name: Spell check - # uses: streetsidesoftware/cspell-action@4dc9d4bdf3974ed26d6f2e973c1e168edff47d80 - # with: - # files: '**/*.{md,ts}' - # strict: true - # check_dot_files: true - # incremental_files_only: false - # config: 'cspell.config.yml' - # - name: Run ShellCheck - # uses: ludeeus/action-shellcheck@cd81f4475ab741e097ec0fe73b692f3e49d66b8c - # with: - # scandir: '.' - # ignore_paths: >- - # node_modules - # .husky + run: npm run coverage \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4d7a462c..54bec619 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,26 @@ -!jest.config.js -*.d.ts -node_modules -.package-lock.json +!typescript/jest.config.js +typescript/*.d.ts +typescript/node_modules +typescript/.package-lock.json -# CDK asset staging directory -.cdk.staging -cdk.out +examples/chat-demo-app/cdk.out -lib/**/*.js -bin/*.js +examples/chat-demo-app/lib/**/*.js +examples/chat-demo-app/bin/*.js -!lambda/url_rewrite/*.js -resources/ui/public/aws-exports.json -resources/ui/dist +!examples/lambda/url_rewrite/*.js +examples/resources/ui/public/aws-exports.json +examples/resources/ui/dist .DS_Store -**/dist/**/* +typescript/dist/**/* -*.tgz +typescript/*.tgz *aws-exports.json !download.js examples/local-demo/.env - -coverage/**/* \ No newline at end of file +typescript/coverage/**/* \ No newline at end of file diff --git a/docs/src/env.d.ts b/docs/src/env.d.ts new file mode 100644 index 00000000..c13bd73c --- /dev/null +++ b/docs/src/env.d.ts @@ -0,0 +1,2 @@ +/// +/// \ No newline at end of file diff --git a/.eslintrc.js b/typescript/.eslintrc.js similarity index 100% rename from .eslintrc.js rename to typescript/.eslintrc.js diff --git a/.npmignore b/typescript/.npmignore similarity index 100% rename from .npmignore rename to typescript/.npmignore diff --git a/package-lock.json b/typescript/package-lock.json similarity index 100% rename from package-lock.json rename to typescript/package-lock.json diff --git a/package.json b/typescript/package.json similarity index 100% rename from package.json rename to typescript/package.json diff --git a/tests/Orchestrator.test.ts b/typescript/tests/Orchestrator.test.ts similarity index 100% rename from tests/Orchestrator.test.ts rename to typescript/tests/Orchestrator.test.ts diff --git a/tests/agents/Agents.test.ts b/typescript/tests/agents/Agents.test.ts similarity index 100% rename from tests/agents/Agents.test.ts rename to typescript/tests/agents/Agents.test.ts diff --git a/tests/classifiers/AnthropicClassifier.test.ts b/typescript/tests/classifiers/AnthropicClassifier.test.ts similarity index 100% rename from tests/classifiers/AnthropicClassifier.test.ts rename to typescript/tests/classifiers/AnthropicClassifier.test.ts diff --git a/tests/classifiers/BedrockClassifier.test.ts b/typescript/tests/classifiers/BedrockClassifier.test.ts similarity index 100% rename from tests/classifiers/BedrockClassifier.test.ts rename to typescript/tests/classifiers/BedrockClassifier.test.ts diff --git a/tests/classifiers/Classifier.test.ts b/typescript/tests/classifiers/Classifier.test.ts similarity index 100% rename from tests/classifiers/Classifier.test.ts rename to typescript/tests/classifiers/Classifier.test.ts diff --git a/tests/mock/mockAgent.ts b/typescript/tests/mock/mockAgent.ts similarity index 100% rename from tests/mock/mockAgent.ts rename to typescript/tests/mock/mockAgent.ts diff --git a/tests/retrievers/Retriever.test.ts b/typescript/tests/retrievers/Retriever.test.ts similarity index 100% rename from tests/retrievers/Retriever.test.ts rename to typescript/tests/retrievers/Retriever.test.ts diff --git a/tests/storage/ChatStorage.test.ts b/typescript/tests/storage/ChatStorage.test.ts similarity index 100% rename from tests/storage/ChatStorage.test.ts rename to typescript/tests/storage/ChatStorage.test.ts diff --git a/tests/utils/Utils.test.ts b/typescript/tests/utils/Utils.test.ts similarity index 100% rename from tests/utils/Utils.test.ts rename to typescript/tests/utils/Utils.test.ts diff --git a/tsconfig.json b/typescript/tsconfig.json similarity index 100% rename from tsconfig.json rename to typescript/tsconfig.json From f7648670999d097926ae0d9c1965ec6bbcf28c67 Mon Sep 17 00:00:00 2001 From: Corneliu CROITORU Date: Fri, 26 Jul 2024 16:33:08 +0200 Subject: [PATCH 2/4] update gh --- .github/workflows/run-security-checks.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/run-security-checks.yml b/.github/workflows/run-security-checks.yml index 5327b1f3..f50de0f4 100644 --- a/.github/workflows/run-security-checks.yml +++ b/.github/workflows/run-security-checks.yml @@ -33,13 +33,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} - - # Output results - - name: Output npm audit results - run: npm audit --json > npm_audit_results.json - - - name: Upload npm audit results - uses: actions/upload-artifact@v3 - with: - name: npm-audit-results - path: typescript/npm_audit_results.json \ No newline at end of file + \ No newline at end of file From c27384eac16f31340962f0e86545a3d04c33f8f6 Mon Sep 17 00:00:00 2001 From: Corneliu CROITORU Date: Fri, 26 Jul 2024 16:35:10 +0200 Subject: [PATCH 3/4] add jest to ts folder --- jest.config.js => typescript/jest.config.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jest.config.js => typescript/jest.config.js (100%) diff --git a/jest.config.js b/typescript/jest.config.js similarity index 100% rename from jest.config.js rename to typescript/jest.config.js From 814b1c7915666a50d0bbd46fb5a54640feac13ff Mon Sep 17 00:00:00 2001 From: Corneliu CROITORU Date: Fri, 26 Jul 2024 16:35:56 +0200 Subject: [PATCH 4/4] move src folder to ts folder --- {src => typescript/src}/agentOverlapAnalyzer.ts | 0 {src => typescript/src}/agents/agent.ts | 0 {src => typescript/src}/agents/amazonBedrockAgent.ts | 0 {src => typescript/src}/agents/bedrockLLMAgent.ts | 0 {src => typescript/src}/agents/lambdaAgent.ts | 0 {src => typescript/src}/agents/lexBotAgent.ts | 0 {src => typescript/src}/agents/openAIAgent.ts | 0 {src => typescript/src}/classifiers/anthropicClassifier.ts | 0 {src => typescript/src}/classifiers/bedrockClassifier.ts | 0 {src => typescript/src}/classifiers/classifier.ts | 0 {src => typescript/src}/index.ts | 0 {src => typescript/src}/orchestrator.ts | 0 {src => typescript/src}/retrievers/AmazonKBRetriever.ts | 0 {src => typescript/src}/retrievers/retriever.ts | 0 {src => typescript/src}/storage/chatStorage.ts | 0 {src => typescript/src}/storage/dynamoDbChatStorage.ts | 0 {src => typescript/src}/storage/memoryChatStorage.ts | 0 {src => typescript/src}/types/index.ts | 0 {src => typescript/src}/utils/chatUtils.ts | 0 {src => typescript/src}/utils/helpers.ts | 0 {src => typescript/src}/utils/logger.ts | 0 21 files changed, 0 insertions(+), 0 deletions(-) rename {src => typescript/src}/agentOverlapAnalyzer.ts (100%) rename {src => typescript/src}/agents/agent.ts (100%) rename {src => typescript/src}/agents/amazonBedrockAgent.ts (100%) rename {src => typescript/src}/agents/bedrockLLMAgent.ts (100%) rename {src => typescript/src}/agents/lambdaAgent.ts (100%) rename {src => typescript/src}/agents/lexBotAgent.ts (100%) rename {src => typescript/src}/agents/openAIAgent.ts (100%) rename {src => typescript/src}/classifiers/anthropicClassifier.ts (100%) rename {src => typescript/src}/classifiers/bedrockClassifier.ts (100%) rename {src => typescript/src}/classifiers/classifier.ts (100%) rename {src => typescript/src}/index.ts (100%) rename {src => typescript/src}/orchestrator.ts (100%) rename {src => typescript/src}/retrievers/AmazonKBRetriever.ts (100%) rename {src => typescript/src}/retrievers/retriever.ts (100%) rename {src => typescript/src}/storage/chatStorage.ts (100%) rename {src => typescript/src}/storage/dynamoDbChatStorage.ts (100%) rename {src => typescript/src}/storage/memoryChatStorage.ts (100%) rename {src => typescript/src}/types/index.ts (100%) rename {src => typescript/src}/utils/chatUtils.ts (100%) rename {src => typescript/src}/utils/helpers.ts (100%) rename {src => typescript/src}/utils/logger.ts (100%) diff --git a/src/agentOverlapAnalyzer.ts b/typescript/src/agentOverlapAnalyzer.ts similarity index 100% rename from src/agentOverlapAnalyzer.ts rename to typescript/src/agentOverlapAnalyzer.ts diff --git a/src/agents/agent.ts b/typescript/src/agents/agent.ts similarity index 100% rename from src/agents/agent.ts rename to typescript/src/agents/agent.ts diff --git a/src/agents/amazonBedrockAgent.ts b/typescript/src/agents/amazonBedrockAgent.ts similarity index 100% rename from src/agents/amazonBedrockAgent.ts rename to typescript/src/agents/amazonBedrockAgent.ts diff --git a/src/agents/bedrockLLMAgent.ts b/typescript/src/agents/bedrockLLMAgent.ts similarity index 100% rename from src/agents/bedrockLLMAgent.ts rename to typescript/src/agents/bedrockLLMAgent.ts diff --git a/src/agents/lambdaAgent.ts b/typescript/src/agents/lambdaAgent.ts similarity index 100% rename from src/agents/lambdaAgent.ts rename to typescript/src/agents/lambdaAgent.ts diff --git a/src/agents/lexBotAgent.ts b/typescript/src/agents/lexBotAgent.ts similarity index 100% rename from src/agents/lexBotAgent.ts rename to typescript/src/agents/lexBotAgent.ts diff --git a/src/agents/openAIAgent.ts b/typescript/src/agents/openAIAgent.ts similarity index 100% rename from src/agents/openAIAgent.ts rename to typescript/src/agents/openAIAgent.ts diff --git a/src/classifiers/anthropicClassifier.ts b/typescript/src/classifiers/anthropicClassifier.ts similarity index 100% rename from src/classifiers/anthropicClassifier.ts rename to typescript/src/classifiers/anthropicClassifier.ts diff --git a/src/classifiers/bedrockClassifier.ts b/typescript/src/classifiers/bedrockClassifier.ts similarity index 100% rename from src/classifiers/bedrockClassifier.ts rename to typescript/src/classifiers/bedrockClassifier.ts diff --git a/src/classifiers/classifier.ts b/typescript/src/classifiers/classifier.ts similarity index 100% rename from src/classifiers/classifier.ts rename to typescript/src/classifiers/classifier.ts diff --git a/src/index.ts b/typescript/src/index.ts similarity index 100% rename from src/index.ts rename to typescript/src/index.ts diff --git a/src/orchestrator.ts b/typescript/src/orchestrator.ts similarity index 100% rename from src/orchestrator.ts rename to typescript/src/orchestrator.ts diff --git a/src/retrievers/AmazonKBRetriever.ts b/typescript/src/retrievers/AmazonKBRetriever.ts similarity index 100% rename from src/retrievers/AmazonKBRetriever.ts rename to typescript/src/retrievers/AmazonKBRetriever.ts diff --git a/src/retrievers/retriever.ts b/typescript/src/retrievers/retriever.ts similarity index 100% rename from src/retrievers/retriever.ts rename to typescript/src/retrievers/retriever.ts diff --git a/src/storage/chatStorage.ts b/typescript/src/storage/chatStorage.ts similarity index 100% rename from src/storage/chatStorage.ts rename to typescript/src/storage/chatStorage.ts diff --git a/src/storage/dynamoDbChatStorage.ts b/typescript/src/storage/dynamoDbChatStorage.ts similarity index 100% rename from src/storage/dynamoDbChatStorage.ts rename to typescript/src/storage/dynamoDbChatStorage.ts diff --git a/src/storage/memoryChatStorage.ts b/typescript/src/storage/memoryChatStorage.ts similarity index 100% rename from src/storage/memoryChatStorage.ts rename to typescript/src/storage/memoryChatStorage.ts diff --git a/src/types/index.ts b/typescript/src/types/index.ts similarity index 100% rename from src/types/index.ts rename to typescript/src/types/index.ts diff --git a/src/utils/chatUtils.ts b/typescript/src/utils/chatUtils.ts similarity index 100% rename from src/utils/chatUtils.ts rename to typescript/src/utils/chatUtils.ts diff --git a/src/utils/helpers.ts b/typescript/src/utils/helpers.ts similarity index 100% rename from src/utils/helpers.ts rename to typescript/src/utils/helpers.ts diff --git a/src/utils/logger.ts b/typescript/src/utils/logger.ts similarity index 100% rename from src/utils/logger.ts rename to typescript/src/utils/logger.ts