From d3274f3e7db36f04cde124627d2f6b55cc913812 Mon Sep 17 00:00:00 2001 From: Snobbish Bee <125891987+snobbee@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:25:17 +0100 Subject: [PATCH] ci(ci): fix ci issues --- .github/workflows/block-mini.yml | 48 +-- biome.json | 96 +++++ package.json | 5 +- .../src/plugins/ideationPlugin.ts | 383 +++++++++--------- plugins/plugin-github/src/templates.ts | 1 + pnpm-lock.yaml | 3 + scripts/detect-minified-code.sh | 53 +++ scripts/{smokeTests.sh => smoke-tests.sh} | 0 8 files changed, 353 insertions(+), 236 deletions(-) create mode 100644 biome.json create mode 100755 scripts/detect-minified-code.sh rename scripts/{smokeTests.sh => smoke-tests.sh} (100%) diff --git a/.github/workflows/block-mini.yml b/.github/workflows/block-mini.yml index eaacd20d1..9882e6660 100644 --- a/.github/workflows/block-mini.yml +++ b/.github/workflows/block-mini.yml @@ -13,48 +13,8 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Detect potential minified code - shell: bash - run: | - echo "Scanning for potential minified JS/TS code..." - - # We'll look in .ts, .tsx, .js, .jsx files, skipping common build dirs. - FILES=$(find . \ - \( -name 'node_modules' -prune \) -o \ - \( -name 'dist' -prune \) -o \ - \( -name 'build' -prune \) -o \ - -type f \( -name '*.ts' -o -name '*.tsx' -o -name '*.js' -o -name '*.jsx' \) \ - -print) - - if [ -z "$FILES" ]; then - echo "No relevant JS/TS files found." - exit 0 - fi - - THRESHOLD=1000 - VIOLATIONS=0 + - name: Make script executable + run: chmod +x ./scripts/detect-minified-code.sh - for file in $FILES; do - # Use grep -En to capture line number and text - # If any line is ≥ THRESHOLD chars, we store those lines in RESULTS - RESULTS=$(grep -En ".{${THRESHOLD},}" "$file" || true) - if [ -n "$RESULTS" ]; then - # We have potential minified lines - while IFS= read -r match; do - # 'match' will be something like "1234:the entire matched line" - LINENUM=$(echo "$match" | cut -d: -f1) - # If you want the text, you can do: - # MATCHED_LINE=$(echo "$match" | cut -d: -f2-) - - echo "::error file=$file,line=$LINENUM::Detected potential minified code (≥ $THRESHOLD chars)." - done <<< "$RESULTS" - VIOLATIONS=1 - fi - done - - if [ "$VIOLATIONS" -eq 1 ]; then - echo "ERROR: Minified code detected. Please remove or exclude it." - exit 1 - else - echo "No minified code detected." - fi + - name: Detect potential minified code + run: ./scripts/detect-minified-code.sh diff --git a/biome.json b/biome.json new file mode 100644 index 000000000..41a96b1fe --- /dev/null +++ b/biome.json @@ -0,0 +1,96 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": "warn", + "noArrayIndexKey": "warn", + "noPrototypeBuiltins": "warn", + "noDuplicateObjectKeys": "warn", + "noGlobalIsNan": "warn", + "noDuplicateFontNames": "warn", + "noSelfCompare": "warn", + "noDoubleEquals": "warn", + "noImplicitAnyLet": "warn", + "noAssignInExpressions": "warn", + "noExportsInTest": "warn", + "noConstEnum": "warn", + "noEmptyInterface": "warn" + }, + "correctness": { + "noUnusedVariables": "warn", + "noUnreachable": "warn", + "useExhaustiveDependencies": "warn", + "noSwitchDeclarations": "warn", + "noUnnecessaryContinue": "warn", + "noInnerDeclarations": "warn" + }, + "style": { + "useConst": "warn", + "useTemplate": "warn", + "useImportType": "warn", + "useNodejsImportProtocol": "warn", + "noUselessElse": "warn", + "useSelfClosingElements": "warn", + "useNumberNamespace": "warn", + "noUnusedTemplateLiteral": "warn", + "noInferrableTypes": "warn", + "noNonNullAssertion": "warn", + "noParameterAssign": "warn", + "useDefaultParameterLast": "warn", + "useExponentiationOperator": "warn", + "noVar": "warn", + "useSingleVarDeclarator": "warn", + "useExportType": "warn" + }, + "a11y": { + "useAltText": "warn", + "useFocusableInteractive": "warn", + "useMediaCaption": "warn", + "noSvgWithoutTitle": "warn", + "useKeyWithClickEvents": "warn" + }, + "complexity": { + "noForEach": "warn", + "useOptionalChain": "warn", + "useArrowFunction": "warn", + "useFlatMap": "warn", + "useLiteralKeys": "warn", + "noBannedTypes": "warn", + "noStaticOnlyClass": "warn", + "noThisInStatic": "warn", + "noUselessConstructor": "warn", + "noUselessTernary": "warn", + "noUselessSwitchCase": "warn", + "noUselessCatch": "warn" + }, + "performance": { + "noDelete": "warn", + "noAccumulatingSpread": "warn" + } + }, + "ignore": [ + "**/dist/**", + "**/node_modules/**", + "**/coverage/**", + "**/*.json" + ] + }, + "formatter": { + "enabled": true + }, + "javascript": { + "parser": { + "unsafeParameterDecoratorsEnabled": true + }, + "formatter": { + "quoteStyle": "double", + "semicolons": "always" + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 912012470..42345ce7b 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,12 @@ "build": "turbo build", "dev": "turbo --concurrency 100 dev", "lint": "turbo lint", - "format": "prettier --write \"**/*.{ts,tsx,md}\"" + "format": "prettier --write \"**/*.{ts,tsx,md}\"", + "smokeTests": "bash ./scripts/smokeTests.sh", + "detectMinifiedCode": "bash ./scripts/detect-minified-code.sh" }, "dependencies": { + "@biomejs/biome": "^1.9.4", "csv-parse": "5.6.0", "csv-writer": "1.6.0", "sharp": "0.33.5", diff --git a/plugins/plugin-github/src/plugins/ideationPlugin.ts b/plugins/plugin-github/src/plugins/ideationPlugin.ts index 803240759..87fc867a6 100644 --- a/plugins/plugin-github/src/plugins/ideationPlugin.ts +++ b/plugins/plugin-github/src/plugins/ideationPlugin.ts @@ -1,211 +1,212 @@ +// @minified-ignore-file import { - composeContext, - elizaLogger, - generateObject, - Action, - HandlerCallback, - IAgentRuntime, - Memory, - ModelClass, - Plugin, - State, - stringToUuid, + composeContext, + elizaLogger, + generateObject, + type Action, + type HandlerCallback, + type IAgentRuntime, + type Memory, + ModelClass, + type Plugin, + type State, + stringToUuid, } from "@elizaos/core"; import { ideationTemplate } from "../templates"; import { IdeationSchema, isIdeationContent } from "../types"; export const ideationAction: Action = { - name: "IDEATION", - similes: [ - "THINK", - "IDEATE", - "IDEAS", - "IDEATION", - "CO_CREATION", - "BRAINSTORM", - "THOUGHTS", - "SUGGESTIONS", - "THINKING", - ], - description: - "Generates ideas and suggestions based on user message using the context of the files and previous messages", - validate: async (runtime: IAgentRuntime) => { - const token = !!runtime.getSetting("GITHUB_API_TOKEN"); + name: "IDEATION", + similes: [ + "THINK", + "IDEATE", + "IDEAS", + "IDEATION", + "CO_CREATION", + "BRAINSTORM", + "THOUGHTS", + "SUGGESTIONS", + "THINKING", + ], + description: + "Generates ideas and suggestions based on user message using the context of the files and previous messages", + validate: async (runtime: IAgentRuntime) => { + const token = !!runtime.getSetting("GITHUB_API_TOKEN"); - return token; - }, - handler: async ( - runtime: IAgentRuntime, - message: Memory, - state?: State, - options?: any, - callback?: HandlerCallback - ) => { - // elizaLogger.log("[ideation] Composing state for message:", message); + return token; + }, + handler: async ( + runtime: IAgentRuntime, + message: Memory, + state?: State, + _options?: any, + callback?: HandlerCallback, + ) => { + // elizaLogger.log("[ideation] Composing state for message:", message); - if (!state) { - state = (await runtime.composeState(message, {})) as State; - } else { - state = await runtime.updateRecentMessageState(state); - } + if (!state) { + state = (await runtime.composeState(message, {})) as State; + } else { + state = await runtime.updateRecentMessageState(state); + } - const context = composeContext({ - state, - template: ideationTemplate, - }); + const context = composeContext({ + state, + template: ideationTemplate, + }); - const details = await generateObject({ - runtime, - context, - modelClass: ModelClass.SMALL, - schema: IdeationSchema, - }); + const details = await generateObject({ + runtime, + context, + modelClass: ModelClass.SMALL, + schema: IdeationSchema, + }); - if (!isIdeationContent(details.object)) { - elizaLogger.error("Invalid content:", details.object); - throw new Error("Invalid content"); - } + if (!isIdeationContent(details.object)) { + elizaLogger.error("Invalid content:", details.object); + throw new Error("Invalid content"); + } - const content = details.object; + const content = details.object; - elizaLogger.info("Generating ideas based on the context..."); + elizaLogger.info("Generating ideas based on the context..."); - const timestamp = Date.now(); - const userIdUUID = stringToUuid(`${runtime.agentId}-${timestamp}`); - const memoryUUID = stringToUuid( - `${message.roomId}-${runtime.agentId}-${timestamp}`, - ); + const timestamp = Date.now(); + const userIdUUID = stringToUuid(`${runtime.agentId}-${timestamp}`); + const memoryUUID = stringToUuid( + `${message.roomId}-${runtime.agentId}-${timestamp}`, + ); - const newMemory: Memory = { - id: memoryUUID, - userId: userIdUUID, - agentId: runtime.agentId, - content: { - text: content.response, - action: "IDEATION", - source: "github", - inReplyTo: stringToUuid(`${message.roomId}-${runtime.agentId}`), - }, - roomId: message.roomId, - createdAt: timestamp, - }; + const newMemory: Memory = { + id: memoryUUID, + userId: userIdUUID, + agentId: runtime.agentId, + content: { + text: content.response, + action: "IDEATION", + source: "github", + inReplyTo: stringToUuid(`${message.roomId}-${runtime.agentId}`), + }, + roomId: message.roomId, + createdAt: timestamp, + }; - await runtime.messageManager.createMemory(newMemory); + await runtime.messageManager.createMemory(newMemory); - if (callback) { - await callback({ - text: content.response, - attachments: [], - }); - } - }, - examples: [ - [ - { - user: "{{user}}", - content: { - text: "Think about ways to enhance the security of user1/repo1", - }, - }, - { - user: "{{agentName}}", - content: { - text: "Based on the current state of the repository and previous interactions, here are some detailed suggestions:\n\n1. **Enhance Documentation**: The README could be expanded with more comprehensive setup instructions and examples, which aligns with previous feedback from contributors. Consider adding a 'Getting Started' section to guide new users.\n2. **Refactor Legacy Code**: Several modules identified in past code reviews could be refactored for better maintainability. Focus on the `utils` directory, which has been flagged for complexity in previous pull requests.\n3. **Increase Test Coverage**: Previous issues highlighted gaps in test coverage, particularly in the authentication module. Implementing unit tests for edge cases could improve reliability.\n4. **Optimize Database Queries**: Recent performance logs suggest that certain database queries could be optimized to reduce load times. Look into indexing strategies for frequently queried tables.\n5. **Implement CI/CD Pipeline**: Automating the deployment process was a recurring suggestion in past discussions, which could improve efficiency and reduce errors. Consider using GitHub Actions for seamless integration.", - action: "IDEATION", - }, - }, - ], - [ - { - user: "{{user}}", - content: { - text: "Ideate on improving the frontend of user2/repo2", - }, - }, - { - user: "{{agentName}}", - content: { - text: "Analyzing the repository and considering previous user feedback, here are some frontend improvement ideas:\n\n1. **Redesign UI for Better UX**: The current design could be more intuitive. Implementing a modern design framework like Material-UI could enhance user experience.\n2. **Improve Accessibility**: Past user feedback has pointed out accessibility issues. Implementing ARIA roles and ensuring color contrast could be beneficial. Consider using tools like Lighthouse to audit accessibility.\n3. **Optimize Asset Loading**: There are opportunities to lazy-load images and scripts to improve page load times, as noted in previous performance audits. This could significantly enhance the user experience on slower networks.\n4. **Enhance State Management**: Transitioning to a more robust state management solution like Redux could address issues raised in past bug reports, particularly those related to data consistency.\n5. **Implement Responsive Design**: Ensuring the application is fully responsive was a common request in user surveys. Use CSS Grid and Flexbox to create a fluid layout that adapts to different screen sizes.", - action: "IDEATION", - }, - }, - ], - [ - { - user: "{{user}}", - content: { - text: "Generate ideas for backend improvements in user3/repo3", - }, - }, - { - user: "{{agentName}}", - content: { - text: "Here are some backend improvement suggestions, taking into account the repository's history and current state:\n\n1. **Optimize API Endpoints**: Previous performance tests indicate that certain API endpoints could be optimized for faster response times. Consider implementing pagination for data-heavy endpoints.\n2. **Implement Caching Strategies**: Introducing caching for frequently accessed data could significantly reduce server load, as discussed in past meetings. Tools like Redis could be beneficial here.\n3. **Enhance Security Protocols**: A security audit revealed potential vulnerabilities that should be addressed to protect user data. Implementing OAuth 2.0 for authentication could enhance security.\n4. **Improve Error Logging**: Enhancing the logging system to capture more detailed error information could aid in faster debugging, as suggested in recent retrospectives. Consider using structured logging with tools like Logstash.\n5. **Refactor Monolithic Services**: Consider breaking down monolithic services into microservices to improve scalability and maintainability. This approach was recommended in previous architecture reviews.", - action: "IDEATION", - }, - }, - ], - [ - { - user: "{{user}}", - content: { - text: "Co-create ideas for improving the deployment process of user4/repo4", - }, - }, - { - user: "{{agentName}}", - content: { - text: "Here are some deployment process improvement ideas, informed by past deployment logs and team feedback:\n\n1. **Automate Deployment with CI/CD**: Implementing a CI/CD pipeline could streamline the deployment process and reduce manual errors, as previously discussed. GitHub Actions or Jenkins could be used for this purpose.\n2. **Implement Blue-Green Deployments**: This strategy could minimize downtime and allow for safer rollbacks, which was a concern raised in past incidents. It also provides a seamless user experience during updates.\n3. **Containerize Applications**: Using Docker to containerize applications can ensure consistency across environments, as suggested in previous technical meetings. This approach also simplifies scaling and deployment.\n4. **Monitor Deployment Metrics**: Setting up monitoring tools to track deployment success and application performance post-deployment could provide valuable insights. Tools like Prometheus and Grafana could be integrated for real-time monitoring.\n5. **Optimize Build Process**: Reviewing and optimizing the build process to reduce build times was a recurring theme in past developer feedback. Consider using parallel builds and caching strategies to speed up the process.", - action: "IDEATION", - }, - }, - ], - [ - { - user: "{{user}}", - content: { - text: "Brainstorm ways to improve the testing strategy for user5/repo5", - }, - }, - { - user: "{{agentName}}", - content: { - text: "Considering the current testing framework and previous feedback, here are some suggestions:\n\n1. **Expand Unit Testing**: Increase the coverage of unit tests, especially for critical modules, to catch bugs early in the development cycle.\n2. **Integrate End-to-End Testing**: Implement end-to-end tests using tools like Cypress to ensure the application works as expected from the user's perspective.\n3. **Adopt Test-Driven Development (TDD)**: Encourage the practice of writing tests before code to improve code quality and design.\n4. **Use Mocking Libraries**: Utilize mocking libraries to simulate complex dependencies and isolate tests for more reliable results.\n5. **Automate Regression Testing**: Set up automated regression tests to quickly identify any new bugs introduced by recent changes.", - action: "IDEATION", - }, - }, - ], - [ - { - user: "{{user}}", - content: { - text: "Provide suggestions for enhancing the user experience in user6/repo6", - }, - }, - { - user: "{{agentName}}", - content: { - text: "Based on user feedback and current design trends, here are some suggestions to enhance user experience:\n\n1. **Simplify Navigation**: Streamline the navigation structure to make it more intuitive and user-friendly.\n2. **Improve Load Times**: Optimize assets and implement lazy loading to improve page load times, enhancing the overall user experience.\n3. **Enhance Visual Design**: Update the visual design to align with modern aesthetics, using consistent color schemes and typography.\n4. **Increase Interactivity**: Add interactive elements such as animations and transitions to make the application more engaging.\n5. **Conduct User Testing**: Regularly conduct user testing sessions to gather feedback and make informed design decisions.", - action: "IDEATION", - }, - }, - ], - [ - { - user: "{{user}}", - content: { - text: "Share thoughts on improving the code quality of user7/repo7", - }, - }, - { - user: "{{agentName}}", - content: { - text: "Here are some thoughts on improving code quality, considering past code reviews and current standards:\n\n1. **Adopt Coding Standards**: Implement consistent coding standards across the project to improve readability and maintainability.\n2. **Conduct Regular Code Reviews**: Establish a process for regular code reviews to catch issues early and share knowledge among team members.\n3. **Refactor Complex Code**: Identify and refactor complex code sections to simplify logic and improve clarity.\n4. **Implement Static Code Analysis**: Use tools like ESLint or SonarQube to automatically detect code smells and enforce best practices.\n5. **Encourage Pair Programming**: Promote pair programming sessions to facilitate knowledge sharing and improve code quality through collaboration.", - action: "IDEATION", - }, - }, - ], - ], + if (callback) { + await callback({ + text: content.response, + attachments: [], + }); + } + }, + examples: [ + [ + { + user: "{{user}}", + content: { + text: "Think about ways to enhance the security of user1/repo1", + }, + }, + { + user: "{{agentName}}", + content: { + text: "Based on the current state of the repository and previous interactions, here are some detailed suggestions:\n\n1. **Enhance Documentation**: The README could be expanded with more comprehensive setup instructions and examples, which aligns with previous feedback from contributors. Consider adding a 'Getting Started' section to guide new users.\n2. **Refactor Legacy Code**: Several modules identified in past code reviews could be refactored for better maintainability. Focus on the `utils` directory, which has been flagged for complexity in previous pull requests.\n3. **Increase Test Coverage**: Previous issues highlighted gaps in test coverage, particularly in the authentication module. Implementing unit tests for edge cases could improve reliability.\n4. **Optimize Database Queries**: Recent performance logs suggest that certain database queries could be optimized to reduce load times. Look into indexing strategies for frequently queried tables.\n5. **Implement CI/CD Pipeline**: Automating the deployment process was a recurring suggestion in past discussions, which could improve efficiency and reduce errors. Consider using GitHub Actions for seamless integration.", + action: "IDEATION", + }, + }, + ], + [ + { + user: "{{user}}", + content: { + text: "Ideate on improving the frontend of user2/repo2", + }, + }, + { + user: "{{agentName}}", + content: { + text: "Analyzing the repository and considering previous user feedback, here are some frontend improvement ideas:\n\n1. **Redesign UI for Better UX**: The current design could be more intuitive. Implementing a modern design framework like Material-UI could enhance user experience.\n2. **Improve Accessibility**: Past user feedback has pointed out accessibility issues. Implementing ARIA roles and ensuring color contrast could be beneficial. Consider using tools like Lighthouse to audit accessibility.\n3. **Optimize Asset Loading**: There are opportunities to lazy-load images and scripts to improve page load times, as noted in previous performance audits. This could significantly enhance the user experience on slower networks.\n4. **Enhance State Management**: Transitioning to a more robust state management solution like Redux could address issues raised in past bug reports, particularly those related to data consistency.\n5. **Implement Responsive Design**: Ensuring the application is fully responsive was a common request in user surveys. Use CSS Grid and Flexbox to create a fluid layout that adapts to different screen sizes.", + action: "IDEATION", + }, + }, + ], + [ + { + user: "{{user}}", + content: { + text: "Generate ideas for backend improvements in user3/repo3", + }, + }, + { + user: "{{agentName}}", + content: { + text: "Here are some backend improvement suggestions, taking into account the repository's history and current state:\n\n1. **Optimize API Endpoints**: Previous performance tests indicate that certain API endpoints could be optimized for faster response times. Consider implementing pagination for data-heavy endpoints.\n2. **Implement Caching Strategies**: Introducing caching for frequently accessed data could significantly reduce server load, as discussed in past meetings. Tools like Redis could be beneficial here.\n3. **Enhance Security Protocols**: A security audit revealed potential vulnerabilities that should be addressed to protect user data. Implementing OAuth 2.0 for authentication could enhance security.\n4. **Improve Error Logging**: Enhancing the logging system to capture more detailed error information could aid in faster debugging, as suggested in recent retrospectives. Consider using structured logging with tools like Logstash.\n5. **Refactor Monolithic Services**: Consider breaking down monolithic services into microservices to improve scalability and maintainability. This approach was recommended in previous architecture reviews.", + action: "IDEATION", + }, + }, + ], + [ + { + user: "{{user}}", + content: { + text: "Co-create ideas for improving the deployment process of user4/repo4", + }, + }, + { + user: "{{agentName}}", + content: { + text: "Here are some deployment process improvement ideas, informed by past deployment logs and team feedback:\n\n1. **Automate Deployment with CI/CD**: Implementing a CI/CD pipeline could streamline the deployment process and reduce manual errors, as previously discussed. GitHub Actions or Jenkins could be used for this purpose.\n2. **Implement Blue-Green Deployments**: This strategy could minimize downtime and allow for safer rollbacks, which was a concern raised in past incidents. It also provides a seamless user experience during updates.\n3. **Containerize Applications**: Using Docker to containerize applications can ensure consistency across environments, as suggested in previous technical meetings. This approach also simplifies scaling and deployment.\n4. **Monitor Deployment Metrics**: Setting up monitoring tools to track deployment success and application performance post-deployment could provide valuable insights. Tools like Prometheus and Grafana could be integrated for real-time monitoring.\n5. **Optimize Build Process**: Reviewing and optimizing the build process to reduce build times was a recurring theme in past developer feedback. Consider using parallel builds and caching strategies to speed up the process.", + action: "IDEATION", + }, + }, + ], + [ + { + user: "{{user}}", + content: { + text: "Brainstorm ways to improve the testing strategy for user5/repo5", + }, + }, + { + user: "{{agentName}}", + content: { + text: "Considering the current testing framework and previous feedback, here are some suggestions:\n\n1. **Expand Unit Testing**: Increase the coverage of unit tests, especially for critical modules, to catch bugs early in the development cycle.\n2. **Integrate End-to-End Testing**: Implement end-to-end tests using tools like Cypress to ensure the application works as expected from the user's perspective.\n3. **Adopt Test-Driven Development (TDD)**: Encourage the practice of writing tests before code to improve code quality and design.\n4. **Use Mocking Libraries**: Utilize mocking libraries to simulate complex dependencies and isolate tests for more reliable results.\n5. **Automate Regression Testing**: Set up automated regression tests to quickly identify any new bugs introduced by recent changes.", + action: "IDEATION", + }, + }, + ], + [ + { + user: "{{user}}", + content: { + text: "Provide suggestions for enhancing the user experience in user6/repo6", + }, + }, + { + user: "{{agentName}}", + content: { + text: "Based on user feedback and current design trends, here are some suggestions to enhance user experience:\n\n1. **Simplify Navigation**: Streamline the navigation structure to make it more intuitive and user-friendly.\n2. **Improve Load Times**: Optimize assets and implement lazy loading to improve page load times, enhancing the overall user experience.\n3. **Enhance Visual Design**: Update the visual design to align with modern aesthetics, using consistent color schemes and typography.\n4. **Increase Interactivity**: Add interactive elements such as animations and transitions to make the application more engaging.\n5. **Conduct User Testing**: Regularly conduct user testing sessions to gather feedback and make informed design decisions.", + action: "IDEATION", + }, + }, + ], + [ + { + user: "{{user}}", + content: { + text: "Share thoughts on improving the code quality of user7/repo7", + }, + }, + { + user: "{{agentName}}", + content: { + text: "Here are some thoughts on improving code quality, considering past code reviews and current standards:\n\n1. **Adopt Coding Standards**: Implement consistent coding standards across the project to improve readability and maintainability.\n2. **Conduct Regular Code Reviews**: Establish a process for regular code reviews to catch issues early and share knowledge among team members.\n3. **Refactor Complex Code**: Identify and refactor complex code sections to simplify logic and improve clarity.\n4. **Implement Static Code Analysis**: Use tools like ESLint or SonarQube to automatically detect code smells and enforce best practices.\n5. **Encourage Pair Programming**: Promote pair programming sessions to facilitate knowledge sharing and improve code quality through collaboration.", + action: "IDEATION", + }, + }, + ], + ], }; export const githubIdeationPlugin: Plugin = { diff --git a/plugins/plugin-github/src/templates.ts b/plugins/plugin-github/src/templates.ts index 03c6c9331..d8da31100 100644 --- a/plugins/plugin-github/src/templates.ts +++ b/plugins/plugin-github/src/templates.ts @@ -1,3 +1,4 @@ +// @minified-ignore-file import { createTemplate } from "./utils"; export const contextTemplate = ` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 913f95585..c1ccf7883 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@biomejs/biome': + specifier: ^1.9.4 + version: 1.9.4 csv-parse: specifier: 5.6.0 version: 5.6.0 diff --git a/scripts/detect-minified-code.sh b/scripts/detect-minified-code.sh new file mode 100755 index 000000000..5fb104f39 --- /dev/null +++ b/scripts/detect-minified-code.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +echo "Scanning for potential minified JS/TS code..." + +# We'll look in .ts, .tsx, .js, .jsx files, skipping common build dirs. +FILES=$(find . \ + \( -name 'node_modules' -prune \) -o \ + \( -name 'dist' -prune \) -o \ + \( -name 'build' -prune \) -o \ + -type f \( -name '*.ts' -o -name '*.tsx' -o -name '*.js' -o -name '*.jsx' \) \ + -print) + +if [ -z "$FILES" ]; then + echo "No relevant JS/TS files found." + exit 0 +fi + +THRESHOLD=1000 +VIOLATIONS=0 + +for file in $FILES; do + # First check if file has the ignore comment in first 3 lines + if head -n 3 "$file" | grep -q "@minified-ignore-file"; then + echo "Skipping $file (file-level ignore found)" + continue + fi + + # Use awk to check line lengths, but ignore lines that have @minified-ignore + RESULTS=$(awk -v threshold=$THRESHOLD ' + length($0) >= threshold && !/.*@minified-ignore.*/ { + print NR ":" $0 + } + ' "$file" || true) + + if [ -n "$RESULTS" ]; then + # We have potential minified lines + while IFS= read -r match; do + # 'match' will be something like "1234:the entire matched line" + LINENUM=$(echo "$match" | cut -d: -f1) + echo "::error file='$file:$LINENUM' Detected potential minified code (≥ $THRESHOLD chars)." + done <<< "$RESULTS" + VIOLATIONS=1 + fi +done + +if [ "$VIOLATIONS" -eq 1 ]; then + echo "ERROR: Minified code detected. Please remove or exclude it." + echo "Tip: Add '@minified-ignore' comment before long lines that should be ignored." + echo " Or add '@minified-ignore-file' at the top of the file to ignore the entire file." + exit 1 +else + echo "No minified code detected." +fi \ No newline at end of file diff --git a/scripts/smokeTests.sh b/scripts/smoke-tests.sh similarity index 100% rename from scripts/smokeTests.sh rename to scripts/smoke-tests.sh