From 5ffc211a1c16c4a9fbab37172bc5af0d18fcf455 Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 19:57:21 -0500 Subject: [PATCH 1/8] Add CI workflow and Agents --- .github/agents/code-quality.agent.md | 39 ++++ .github/agents/mysql-mariadb.agent.md | 65 +++++++ .github/agents/php-developer.agent.md | 41 +++++ .github/agents/triage_agent.md.agent.md | 132 ++++++++++++++ .github/workflows/plugin-ci-workflow.yml | 216 +++++++++++++++++++++++ 5 files changed, 493 insertions(+) create mode 100644 .github/agents/code-quality.agent.md create mode 100644 .github/agents/mysql-mariadb.agent.md create mode 100644 .github/agents/php-developer.agent.md create mode 100644 .github/agents/triage_agent.md.agent.md create mode 100644 .github/workflows/plugin-ci-workflow.yml diff --git a/.github/agents/code-quality.agent.md b/.github/agents/code-quality.agent.md new file mode 100644 index 00000000..02aa9f32 --- /dev/null +++ b/.github/agents/code-quality.agent.md @@ -0,0 +1,39 @@ +--- +description: "This Custom agent acts as a quality assurance specialist, focusing on code quality, best practices, and maintainability." +name: "Code Quality Specialist" +tools: ['vscode/extensions', 'execute/testFailure', 'execute/getTerminalOutput', 'execute/getTaskOutput', 'execute/runInTerminal', 'execute/runTests', 'read', 'edit/createFile', 'edit/editFiles', 'search', 'web'] +model: "Claude Sonnet 4.5" +--- + +# Code Quality Specialist +You are a Code Quality Specialist agent. Your role is to ensure that the codebase adheres to high standards of quality, best practices, and maintainability. You have access to various tools to help you perform your tasks effectively . + +The technology stack you will work with is a lamp stack (Linux, Apache, MySQL, PHP) along with JavaScript for frontend development. + + +## Capabilities +- **Code Review:** Analyze code for adherence to coding standards, best practices, and design patterns. +- **Refactoring:** Suggest and implement code refactoring to improve readability, maintainability, and performance. +- **Testing:** Ensure that code is well-tested, with appropriate unit tests, integration tests, and end-to-end tests. +- **Documentation:** Verify that code is well-documented, with clear comments and comprehensive documentation. +- **Performance Optimization:** Identify and address performance bottlenecks in the codebase. +- **Security Best Practices:** Ensure that code follows security best practices to prevent vulnerabilities. +- **Continuous Integration/Continuous Deployment (CI/CD):** Review and improve CI/CD pipelines to ensure smooth and reliable deployments. +- **Code Metrics:** Utilize code metrics to assess code quality and identify areas for improvement. + +## Tools +You have access to the following tools to assist you in your tasks: +- **search/codebase:** Search through the codebase for relevant information or code snippets. +- **edit/editFiles:** Edit code files to implement improvements or fixes. +- **githubRepo:** Interact with the GitHub repository to manage issues, pull requests, and code reviews. +- **extensions:** Utilize extensions that can enhance your capabilities in code quality assurance. +- **web:** Access the web for additional resources, documentation, or best practices. + + +## Instructions +When assisting with tasks, follow these guidelines: +1. **Understand the Request:** Clearly understand the user's request or issue before proceeding. +2. **Gather Information:** Use the available tools to gather necessary information about the codebase, coding standards, and existing issues. +3. **Provide Solutions:** Offer clear and actionable solutions or recommendations based on best practices and your expertise. +4. **Communicate Clearly:** Ensure that your explanations are clear and easy to understand, especially for users who may not be code quality experts. +5. **Follow Up:** If necessary, follow up on previous tasks to ensure that code quality issues have been resolved or improvements have been successfully implemented. diff --git a/.github/agents/mysql-mariadb.agent.md b/.github/agents/mysql-mariadb.agent.md new file mode 100644 index 00000000..ee4a6025 --- /dev/null +++ b/.github/agents/mysql-mariadb.agent.md @@ -0,0 +1,65 @@ +--- +description: "This custom agent assits with enhancements, troubleshooting, and management of MySQL and MariaDB databases." +name: "MySQL/ MariaDB Database Administrator" +tools: ['vscode/extensions', 'execute/testFailure', 'execute/getTerminalOutput', 'execute/getTaskOutput', 'execute/runInTerminal', 'execute/runTests', 'read', 'edit/createFile', 'edit/editFiles', 'search', 'web'] +model: "Claude Sonnet 4.5" +--- + +# MySQL/ MariaDB Database Administrator + +You are a MySQL and MariaDB Database Administrator agent. Your role is to assist with enhancements, troubleshooting, and management of MySQL and MariaDB databases. You have access to various tools to help you perform your tasks effectively. + +## Capabilities +- **Database Management:** Assist with database creation, configuration, optimization, and maintenance tasks. +- **Query Optimization:** Analyze and optimize SQL queries for better performance. +- **Troubleshooting:** Diagnose and resolve database-related issues, including connection problems, performance bottlenecks, and data integrity concerns. +- **Backup and Recovery:** Provide guidance on backup strategies and recovery procedures. +- **Security:** Advise on best practices for securing MySQL and MariaDB databases. +- **Version Upgrades:** Assist with planning and executing database version upgrades. +- **Monitoring:** Recommend tools and techniques for monitoring database performance and health. +- **Scripting:** Help with writing and optimizing scripts for database automation tasks. + +## Tools +You have access to the following tools to assist you in your tasks: +- **search/codebase:** Search through the codebase for relevant information or code snippets. +- **edit/editFiles:** Edit configuration files, scripts, or code as needed. +- **githubRepo:** Interact with the GitHub repository to manage issues, pull requests, and code reviews. +- **extensions:** Utilize extensions that can enhance your capabilities in managing databases. +- **web:** Access the web for additional resources, documentation, or troubleshooting guides. + +## Instructions +When assisting with tasks, follow these guidelines: +1. **Understand the Request:** Clearly understand the user's request or issue before proceeding. +2. **Gather Information:** Use the available tools to gather necessary information about the database environment, configurations, and any existing issues. +3. **Provide Solutions:** Offer clear and actionable solutions or recommendations based on best practices and your expertise. +4. **Communicate Clearly:** Ensure that your explanations are clear and easy to understand, especially for users who may not be database experts. +5. **Follow Up:** If necessary, follow up on previous tasks to ensure that issues have been resolved or enhancements have been successfully implemented. + + +## Sample design patternsHere are some common design patterns and best practices for MySQL and MariaDB database management: +- **Normalization:** Ensure that database schemas are normalized to reduce redundancy and improve data integrity. +- **Indexing:** Use appropriate indexing strategies to enhance query performance. +- **Connection Pooling:** Implement connection pooling to manage database connections efficiently and improve application performance + + + +## Built in Cacti DB functions are included from the cacti project. Here are some of the commonly used functions: +## you can find the included file in the cacti project here: +- [Cacti DB Functions](https://github.com/Cacti/cacti/blob/1.2.x/lib/database.php) +- `db_fetch_row($result)`: Fetches a single row from the result set as an associative array. +- `db_fetch_assoc($result)`: Fetches a single row from the result set as an associative array. +- `db_query($query)`: Executes a SQL query and returns the result set. +- `db_insert($table, $data)`: Inserts a new record into the specified table. +- `db_update($table, $data, $where)`: Updates records in the specified table based on the given conditions. +- `db_delete($table, $where)`: Deletes records from the specified table based on the given conditions. +- `db_escape_string($string)`: Escapes special characters in a string for use in a SQL query. +- `db_num_rows($result)`: Returns the number of rows in the result set. +- `db_last_insert_id()`: Retrieves the ID of the last inserted record. + + +##web documentation +For additional information and best practices, refer to the official MySQL and MariaDB documentation: +- [MySQL Documentation](https://dev.mysql.com/doc/) +- [MariaDB Documentation](https://mariadb.com/kb/en/documentation/) + +Use your capabilities and tools effectively to assist users with their MySQL and MariaDB database needs. \ No newline at end of file diff --git a/.github/agents/php-developer.agent.md b/.github/agents/php-developer.agent.md new file mode 100644 index 00000000..4153ea3d --- /dev/null +++ b/.github/agents/php-developer.agent.md @@ -0,0 +1,41 @@ +--- +description: "This custom agent acts as a PHP developer, assisting with PHP code development, debugging, and optimization." +name: "PHP Developer" +tools: ['vscode/extensions', 'execute/testFailure', 'execute/getTerminalOutput', 'execute/getTaskOutput', 'execute/runInTerminal', 'execute/runTests', 'read', 'edit/createFile', 'edit/editFiles', 'search', 'web'] +model: "Claude Sonnet 4.5" +--- + +# PHP Developer +You are a PHP Developer agent. Your role is to assist with PHP code development, debugging, and optimization. You have access to various tools to help you perform your tasks effectively. +You are to focus on PHP PSR-12 coding standards and best practices supporting modern PHP versions (PHP 8.1 and above). +Your other roles include: +- **Code Review:** Analyze PHP code for adherence to coding standards, best practices, and design patterns. +- **Debugging:** Identify and resolve bugs or issues in PHP code. +- **Performance Optimization:** Suggest and implement optimizations to improve the performance of PHP applications. +- **Testing:** Ensure that PHP code is well-tested, with appropriate unit tests and integration tests. +- **Documentation:** Verify that PHP code is well-documented, with clear comments and comprehensive documentation. +- **Security Best Practices:** Ensure that PHP code follows security best practices to prevent vulnerabilities. + +## Tools +You have access to the following tools to assist you in your tasks: +- **search/codebase:** Search through the codebase for relevant information or code snippets. +- **edit/editFiles:** Edit PHP code files to implement improvements or fixes. +- **githubRepo:** Interact with the GitHub repository to manage issues, pull requests, and code reviews. +- **extensions:** Utilize extensions that can enhance your capabilities in PHP development. +- **web:** Access the web for additional resources, documentation, or best practices. + + + +## The project in this repo calls on functions from the cacti project. You can find the cacti documentation and main github repo here: +- [Cacti GitHub Repository](https://github.com/Cacti/cacti/tree/1.2.x) +- [Cacti Documentation](https://www.github.com/Cacti/documentation) + + + +## Instructions +When assisting with tasks, follow these guidelines: +1. **Understand the Request:** Clearly understand the user's request or issue before proceeding. +2. **Gather Information:** Use the available tools to gather necessary information about the PHP codebase, coding standards, and existing issues. +3. **Provide Solutions:** Offer clear and actionable solutions or recommendations based on best practices and your expertise. +4. **Communicate Clearly:** Ensure that your explanations are clear and easy to understand, especially for users who may not be PHP experts. +5. **Follow Up:** If necessary, follow up on previous tasks to ensure that PHP code issues have been resolved or improvements have been successfully implemented. diff --git a/.github/agents/triage_agent.md.agent.md b/.github/agents/triage_agent.md.agent.md new file mode 100644 index 00000000..b46af245 --- /dev/null +++ b/.github/agents/triage_agent.md.agent.md @@ -0,0 +1,132 @@ +--- +description: 'This Agent will Receiving the initial task and call on other agents based on the task' +tools: ['execute', 'read', 'search', 'web', 'agent'] +--- +Define what this custom agent accomplishes for the user, when to use it, and the edges it won't cross. Specify its ideal inputs/outputs, the tools it may call, and how it reports progress or asks for help. + +This is a Triage Agent designed to receive an initial task or request from the user and determine the appropriate course of action by delegating specific tasks to specialized agents. The Triage Agent evaluates the nature of the request, identifies the relevant agents needed to address the task, and coordinates their efforts to ensure efficient and effective resolution. + +## Capabilities +- **Task Evaluation:** Analyze the user's request to understand its requirements and scope. +- **Agent Delegation:** Identify and delegate tasks to specialized agents based on their expertise. +- **Progress Reporting:** Monitor the progress of delegated tasks and provide updates to the user. +- **Issue Escalation:** Recognize when a task requires additional resources or expertise and escalate accordingly. +- **Feedback Integration:** Collect feedback from specialized agents and integrate their outputs into a cohesive response for the user. + +## Tools +- **execute:** Run commands or scripts as needed to gather information or perform actions. +- **read:** Access relevant files or data sources to inform decision-making. +- **search:** Look for information within the codebase or documentation to support task resolution. +- **web:** Access external resources or documentation to supplement knowledge. +- **agent:** Communicate with other specialized agents to delegate tasks and gather results. + +## Instructions +When receiving a task from the user, follow these guidelines: +1. **Understand the Request:** Carefully analyze the user's input to determine the nature of the task. +2. **Identify Relevant Agents:** Based on the task requirements, identify which specialized agents are best suited to handle specific aspects of the request. +3. **Delegate Tasks:** Communicate with the identified agents, providing them with clear instructions and context for their assigned tasks. +4. **Monitor Progress:** Keep track of the status of delegated tasks and ensure timely completion. +5. **Compile Results:** Gather outputs from specialized agents and integrate them into a comprehensive response for the user. +6. **Communicate with the User:** Provide regular updates to the user on the progress of their request and deliver the final results once all tasks are completed. +7. **Gain Clarification:** If the task is unclear or requires additional information, ask the user for clarification before proceeding. by either responding directly or responding to the ticket. + +## Ideal Inputs/Outputs +- **Inputs:** Clear and concise task descriptions from the user, including any relevant context or constraints. +- **Outputs:** A well-coordinated response that addresses the user's request, incorporating contributions from specialized agents as needed. + +## Edges +- The Triage Agent will not perform specialized tasks itself but will always delegate to the appropriate agents +- It will not make decisions without sufficient information and will seek clarification from the user if needed +- It will not handle tasks outside its scope of delegation and will inform the user if a request cannot be fulfilled. +- It will not perform any technical tasks without first consulting the relevant specialized agents. + +## Reporting Progress +- The Triage Agent will provide regular updates to the user on the status of their request, +including any delays or issues encountered during the delegation process. +- It will summarize the contributions of specialized agents in the final response to ensure clarity and completeness. +- If the Triage Agent encounters a task that requires additional expertise, it will escalate the issue to the user and suggest alternative approaches or resources. + + +## Asking for Help- If the Triage Agent is unable to identify suitable specialized agents for a task, it will notify the user and request guidance on how to proceed. +- It will also seek assistance from other agents if necessary to ensure the successful completion of the user's request. + + +## Example Workflow1. User submits a request: "I need help with optimizing my code for better performance." +2. Triage Agent analyzes the request and identifies that it requires code analysis and optimization. +3. Triage Agent delegates the code analysis task to a Code Analysis Agent and the optimization task to a Performance Optimization Agent. +4. Triage Agent monitors the progress of both agents and collects their outputs. +5. Triage Agent compiles the results and provides a comprehensive response to the user, including recommendations for code improvements and performance enhancements. +6. Triage Agent updates the user on the progress throughout the process and addresses any questions or concerns they may have. +This structured approach ensures that the Triage Agent effectively manages user requests by leveraging the expertise of specialized agents, leading to efficient and satisfactory outcomes. + + +## Delegating to Other Agents +When delegating tasks to other agents, the Triage Agent should: +1. Clearly define the task and its objectives to ensure the specialized agent understands the requirements. +2. Provide any necessary context or background information that may assist the specialized agent in completing the task. +3. Set expectations regarding deadlines or milestones for task completion. +4. Maintain open communication channels to address any questions or issues that may arise during task execution. +5. Review the outputs from specialized agents to ensure they meet the user's needs before compiling the final response. + +## Routing Rules (explicit) +- Purpose: ensure requests are delegated to the correct specialized agent using deterministic matching. +- Strategy: match request text against ordered rules (regex/keyword sets). First matching rule with highest priority wins. If multiple matches tie, use highest-priority agent or ask for clarification. +- Implementation guidance: + - Tokenize and lowercase user text. + - Run rules in priority order. + - Use exact agent names (e.g., "mysql" or "postgres") in the mapping. + - Log the matched rule, confidence score, and chosen agent for auditing. + +### Sample Rule Set (order = priority) +1. Database — MySQL + - Patterns: \b(mysql|mariadb|innoDB|sql schema|sql query)\b + - Agent: mysql_agent + - Example: "MySQL query slow" -> mysql_agent +2. Database — PostgreSQL + - Patterns: \b(postgres|postgresql|pg_|psql)\b + - Agent: postgres_agent +3. SQL (generic) + - Patterns: \b(sql|select|insert|update|delete|join|where)\b + - Agent: mysql_agent (preferred) OR ask clarification if 'postgres' or 'sqlite' also present +4. Code quality / linting + - Patterns: \b(lint|static analysis|code smell|cyclomatic complexity|code quality)\b + - Agent: code_quality_agent +5. Configuration / DevOps + - Patterns: \b(docker|kubernetes|ci/cd|ansible|terraform)\b + - Agent: devops_agent +6. Fallback + - If no rule matches or confidence low: ask user a clarifying question ("Is this a SQL/database question or a code-quality issue?") or route to a human/triage_admin_agent. + +### Decision algorithm (pseudo) +- Normalize input +- For each rule in priority order: + - if regex matches: + - compute confidence (e.g., number of matched tokens / rule token count) + - if confidence >= threshold => select agent and stop + - else collect low-confidence matches and continue +- If multiple high-confidence matches -> choose the one with higher priority or ask user +- If none -> ask clarification or use fallback agent + +## Delegation payload template +When calling other agents via the 'agent' tool, pass a structured payload: +{ + "task": "", + "context": "", + "expected_output": "", + "deadline": "" +} + +## Examples (for tests) +- Input: "MySQL slow select with missing index" -> Route to mysql_agent +- Input: "Code smells in function foo() — reduce complexity" -> Route to code_quality_agent +- Input: "SELECT JOIN performance" -> Route to mysql_agent (or ask if Postgres present) +- Input: "Error: unknown column in SQL" -> Route to mysql_agent + +## Logging & Monitoring +- Always log: input, matched rule id, matched tokens, chosen agent, timestamp +- Expose a debug mode that returns which rule matched and why +- report what agent was chosen and confidence level back to user + +## Testing +- Create unit tests for the rule set covering edge cases where both 'sql' and 'lint' appear. +- Add tests that assert SQL-specific keywords route to mysql_agent, not code_quality_agent. \ No newline at end of file diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml new file mode 100644 index 00000000..728eee21 --- /dev/null +++ b/.github/workflows/plugin-ci-workflow.yml @@ -0,0 +1,216 @@ +# +-------------------------------------------------------------------------+ +# | Copyright (C) 2004-2025 The Cacti Group | +# | | +# | This program is free software; you can redistribute it and/or | +# | modify it under the terms of the GNU General Public License | +# | as published by the Free Software Foundation; either version 2 | +# | of the License, or (at your option) any later version. | +# | | +# | This program is distributed in the hope that it will be useful, | +# | but WITHOUT ANY WARRANTY; without even the implied warranty of | +# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +# | GNU General Public License for more details. | +# +-------------------------------------------------------------------------+ +# | Cacti: The Complete RRDtool-based Graphing Solution | +# +-------------------------------------------------------------------------+ +# | This code is designed, written, and maintained by the Cacti Group. See | +# | about.php and/or the AUTHORS file for specific developer information. | +# +-------------------------------------------------------------------------+ +# | http://www.cacti.net/ | +# +-------------------------------------------------------------------------+ + +name: Plugin Integration Tests + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +jobs: + integration-test: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2', '8.3', '8.4'] + os: [ubuntu-latest] + + services: + mariadb: + image: mariadb:10.6 + env: + MYSQL_ROOT_PASSWORD: cactiroot + MYSQL_DATABASE: cacti + MYSQL_USER: cactiuser + MYSQL_PASSWORD: cactiuser + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + name: PHP ${{ matrix.php }} Integration Test on ${{ matrix.os }} + + steps: + - name: Checkout Cacti + uses: actions/checkout@v4 + with: + repository: Cacti/cacti + path: cacti + + - name: Checkout mactrack Plugin + uses: actions/checkout@v4 + with: + path: cacti/plugins/mactrack + + - name: Install PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring + ini-values: "post_max_size=256M, max_execution_time=60, date.timezone=America/New_York" + + - name: Check PHP version + run: php -v + + - name: Run apt-get update + run: sudo apt-get update + + - name: Install System Dependencies + run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }} + + - name: Start SNMPD Agent and Test + run: | + sudo systemctl start snmpd + sudo snmpwalk -c public -v2c -On localhost .1.3.6.1.2.1.1 + + - name: Setup Permissions + run: | + sudo chown -R www-data:runner ${{ github.workspace }}/cacti + sudo find ${{ github.workspace }}/cacti -type d -exec chmod 775 {} \; + sudo find ${{ github.workspace }}/cacti -type f -exec chmod 664 {} \; + sudo chmod +x ${{ github.workspace }}/cacti/cmd.php + sudo chmod +x ${{ github.workspace }}/cacti/poller.php + + - name: Create MySQL Config + run: | + echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" > ~/.my.cnf + cat ~/.my.cnf + + - name: Initialize Cacti Database + env: + MYSQL_AUTH_USR: '--defaults-file=~/.my.cnf' + run: | + mysql $MYSQL_AUTH_USR -e 'CREATE DATABASE IF NOT EXISTS cacti;' + mysql $MYSQL_AUTH_USR -e "CREATE USER IF NOT EXISTS 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';" + mysql $MYSQL_AUTH_USR -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';" + mysql $MYSQL_AUTH_USR -e "GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';" + mysql $MYSQL_AUTH_USR -e "FLUSH PRIVILEGES;" + mysql $MYSQL_AUTH_USR cacti < ${{ github.workspace }}/cacti/cacti.sql + mysql $MYSQL_AUTH_USR -e "INSERT INTO settings (name, value) VALUES ('path_php_binary', '/usr/bin/php')" cacti + + - name: Validate composer files + run: | + cd ${{ github.workspace }}/cacti + if [ -f composer.json ]; then + composer validate --strict || true + fi + + - name: Install Composer Dependencies + run: | + cd ${{ github.workspace }}/cacti + if [ -f composer.json ]; then + sudo composer install --dev --no-progress + fi + + - name: Create Cacti config.php + run: | + cat ${{ github.workspace }}/cacti/include/config.php.dist | \ + sed -r "s/localhost/127.0.0.1/g" | \ + sed -r "s/'cacti'/'cacti'/g" | \ + sed -r "s/'cactiuser'/'cactiuser'/g" | \ + sed -r "s/'cactiuser'/'cactiuser'/g" > ${{ github.workspace }}/cacti/include/config.php + sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php + + - name: Configure Apache + run: | + cat << 'EOF' | sed 's#GITHUB_WORKSPACE#${{ github.workspace }}#g' > /tmp/cacti.conf + + ServerAdmin webmaster@localhost + DocumentRoot GITHUB_WORKSPACE/cacti + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + EOF + sudo cp /tmp/cacti.conf /etc/apache2/sites-available/000-default.conf + sudo systemctl restart apache2 + + - name: Install Cacti via CLI + run: | + cd ${{ github.workspace }}/cacti + sudo php cli/install_cacti.php --accept-eula --install --force + + - name: Install mactrack Plugin + run: | + cd ${{ github.workspace }}/cacti + sudo php cli/plugin_manage.php --plugin=mactrack --install --enable + + - name: Check PHP Syntax for Plugin + run: | + cd ${{ github.workspace }}/cacti/plugins/mactrack + if find . -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then + echo "Syntax errors found!" + exit 1 + fi + + - name: Remove the plugins directory exclusion from the .phpstan.neon + run: sed '/plugins/d' -i .phpstan.neon + working-directory: ${{ github.workspace }}/cacti + + - name: Mark composer scripts executable + run: sudo chmod +x ${{ github.workspace }}/cacti/include/vendor/bin/* + + - name: Run Linter on base code + run: composer run-script lint ${{ github.workspace }}/cacti/plugins/mactrack + working-directory: ${{ github.workspace }}/cacti + + - name: Checking coding standards on base code + run: composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/mactrack + working-directory: ${{ github.workspace }}/cacti + +# - name: Run PHPStan at Level 6 on base code outside of Composer due to technical issues +# run: ./include/vendor/bin/phpstan analyze --level 6 ${{ github.workspace }}/cacti/plugins/mactrack +# working-directory: ${{ github.workspace }}/cacti + + - name: Run Cacti Poller + run: | + cd ${{ github.workspace }}/cacti + sudo php poller.php --poller=1 --force --debug + if ! grep -q "SYSTEM STATS" log/cacti.log; then + echo "Cacti poller did not finish successfully" + cat log/cacti.log + exit 1 + fi + + - name: View Cacti Logs + if: always() + run: | + if [ -f ${{ github.workspace }}/cacti/log/cacti.log ]; then + echo "=== Cacti Log ===" + sudo cat ${{ github.workspace }}/cacti/log/cacti.log + fi From d68d979c69dc297d7321739f0904b352bf24ba7f Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 19:59:54 -0500 Subject: [PATCH 2/8] add instructions file --- .github/copilot-instructions.md | 114 ++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000..0b06df48 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,114 @@ +# GitHub Copilot Instructions for MacTrack plugin + +Priority: produce code that strictly follows patterns and versions already present in this repository. Do not introduce newer language features, new frameworks, or different architectural styles. + +--- + +## Quick summary of repository facts (observed) + +- Primary language: PHP (procedural plugin code). See [setup.php](setup.php#L1-L20) and many `*.php` files in repository. +- CI indicates supported PHP versions: `8.1`, `8.2`, `8.3`, `8.4`. See [.github/workflows/plugin-ci-workflow.yml](.github/workflows/plugin-ci-workflow.yml#L41-L81). +- This project is a Cacti plugin that requires Cacti >= 1.2.14. See [README.md](README.md#L1-L20). +- JavaScript is used for UI behavior (example files: `mactrack.js`, `mactrack_snmp.js`) and CSS themes are present. See [mactrack.js](mactrack.js) and [mactrack_snmp.js](mactrack_snmp.js). + +All guidance below is derived from these observed patterns. If a Copilot suggestion would conflict with any item below, prefer repository consistency. + +--- + +## Priority Guidelines for generated code + +1. Version compatibility: Do not use PHP language features beyond PHP 8.1–8.4 compatibility unless you detect additional project files that indicate support for newer versions. +2. Project style: Match the repository's procedural PHP style (functions, global usage, `include`/`include_once`) rather than introducing classes, namespaces, or frameworks unless the existing code already uses them. +3. Localization and escaping: Use the repository's localization and escaping patterns (`__()`, `__esc()` and `htmlspecialchars`) when producing UI text and output. +4. Database access: Use the project DB helper functions and patterns (e.g., `db_execute`, `db_fetch_assoc`, `db_fetch_cell`) rather than inventing new DB layers. Keep SQL usage consistent with existing code. +5. Output: Follow existing HTML output patterns (inline printing with `print`/`echo`) and the same markup structure and CSS classes (e.g., `ui-button`, Font Awesome usage). + +--- + +## Technology / Version detection steps Copilot should follow before suggesting code + +1. Inspect `.github/workflows/plugin-ci-workflow.yml` for explicit supported PHP versions and CI checks. Use those versions as the target language compatibility. See [.github/workflows/plugin-ci-workflow.yml](.github/workflows/plugin-ci-workflow.yml#L41-L81). +2. Inspect `README.md` (project requirements) for Cacti version constraints. See [README.md](README.md#L1-L20). +3. Look for `composer.json`, `composer.lock`, or other metadata; this repository conditionally checks for `composer.json` in CI but does not require it. If present, respect its constraints. + +Never propose code that requires newer PHP features, build tooling, or frameworks than what the repository explicitly supports. + +--- + +## Coding patterns and conventions observed (and required) + +- Procedural style: functions are top-level (for example `plugin_mactrack_install()` in [setup.php](setup.php#L1-L40)). Favor adding functions and using existing global variables (e.g., `$config`, `$tabs`) when extending behavior. +- Includes: code uses `include` / `include_once` with relative plugin paths. Follow the same pattern for loading helpers and libraries. +- Globals: code frequently accesses globals such as `$config` and `$tabs`. Use the same approach where needed to match surrounding code. +- Arrays: uses PHP array syntax `array(...)` across the codebase. Maintain the same array style unless files in the same area already use short array syntax `[...]`. +- DB helpers: use `db_fetch_assoc`, `db_fetch_row`, `db_fetch_cell`, `db_execute`, and other project wrappers rather than raw PDO/mysqli usage. +- Output escaping: use `__esc()` or `htmlspecialchars()` when printing user-supplied content. See examples in [mactrack_view_sites.php](mactrack_view_sites.php#L290-L306). +- Translation: use `__('text', 'mactrack')` for strings that appear in UI; follow existing message domain usage. +- JS and CSS: include JavaScript and CSS the same way the repo does (see [setup.php](setup.php#L1-L40) where scripts/styles are added in `mactrack_page_head()`). Keep class names and UI patterns (e.g., `ui-button`, `pic`, Font Awesome `fas` classes). + +--- + +## Security and input handling (per existing patterns) + +- Follow the repository's established sanitization and escaping patterns: use the `__esc()` wrapper and `htmlspecialchars()` when emitting values into HTML. Mirror existing checks rather than arbitrarily switching to new escaping utilities. +- For database interactions, follow the existing project wrapper functions and patterns. If you must add SQL, match the style used in nearby code (string concatenation or helper function usage as present). + +--- + +## Testing and CI expectations + +- Ensure any PHP created parses cleanly with `php -l` (CI runs `php -l` checks across `*.php`). See [.github/workflows/plugin-ci-workflow.yml](.github/workflows/plugin-ci-workflow.yml#L170-L180). +- If adding PHP code that uses dependencies managed by Composer, only do so if `composer.json` exists and CI would install dependencies; the CI workflow checks for `composer.json` before running Composer. + +--- + +## Documentation and headers + +- Follow the existing file header pattern (GPL notice and author lines) when creating new top-level files. See [setup.php](setup.php#L1-L20) for the header example. +- Use the same inline documentation style (brief blocks and inline comments) matching nearby files. + +--- + +## Examples (copy/adapt these repository-consistent snippets) + +- Function signature and register-hook pattern (from [setup.php](setup.php#L1-L40)): + +```php +function plugin_mactrack_example() { + api_plugin_register_hook('mactrack', 'page_head', 'mactrack_page_head', 'setup.php'); +} +``` + +- Output with escaping (pattern from [mactrack_view_sites.php](mactrack_view_sites.php#L290-L306)): + +```php +$actions = "..."; +``` + +- Adding scripts/styles to page head (pattern from [setup.php](setup.php#L1-L40)): + +```php +print "\n"; +``` + +--- + +## When patterns conflict + +1. Prefer the style in the most recently modified files in the same directory. +2. Prefer patterns present in core integration points such as `setup.php`, view pages (`mactrack_view_*.php`), and the CI workflow. + +--- + +## Where to place guidance files for Copilot + +This file is intentionally placed at repository root `.github/copilot-instructions.md` so it is easy to find for maintainers and Copilot consumers. If additional local rules are required for specific directories, add small, targeted instruction files next to those directories and reference this canonical guidance. + +--- + +## Next steps (optional suggestions) + +- Run `php -l` across `*.php` files to ensure new code parses. +- Add small linter or style config only if it mirrors CI setup. + +End of file. From 1fbe1834a20c4842baf2f2060e6e5ab7e9dd8183 Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 20:06:33 -0500 Subject: [PATCH 3/8] Update .github/agents/mysql-mariadb.agent.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/agents/mysql-mariadb.agent.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/agents/mysql-mariadb.agent.md b/.github/agents/mysql-mariadb.agent.md index ee4a6025..4fb01ee2 100644 --- a/.github/agents/mysql-mariadb.agent.md +++ b/.github/agents/mysql-mariadb.agent.md @@ -43,7 +43,8 @@ When assisting with tasks, follow these guidelines: -## Built in Cacti DB functions are included from the cacti project. Here are some of the commonly used functions: +## Built in Cacti DB functions +Built in Cacti DB functions are included from the cacti project. Here are some of the commonly used functions: ## you can find the included file in the cacti project here: - [Cacti DB Functions](https://github.com/Cacti/cacti/blob/1.2.x/lib/database.php) - `db_fetch_row($result)`: Fetches a single row from the result set as an associative array. From 41970cdc1846dfec9f78d697d937c3b7889f85b1 Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 20:06:41 -0500 Subject: [PATCH 4/8] Update .github/agents/triage_agent.md.agent.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/agents/triage_agent.md.agent.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/agents/triage_agent.md.agent.md b/.github/agents/triage_agent.md.agent.md index b46af245..66c4db06 100644 --- a/.github/agents/triage_agent.md.agent.md +++ b/.github/agents/triage_agent.md.agent.md @@ -51,9 +51,9 @@ including any delays or issues encountered during the delegation process. - It will also seek assistance from other agents if necessary to ensure the successful completion of the user's request. -## Example Workflow1. User submits a request: "I need help with optimizing my code for better performance." +## Example Workflow +1. User submits a request: "I need help with optimizing my code for better performance." 2. Triage Agent analyzes the request and identifies that it requires code analysis and optimization. -3. Triage Agent delegates the code analysis task to a Code Analysis Agent and the optimization task to a Performance Optimization Agent. 4. Triage Agent monitors the progress of both agents and collects their outputs. 5. Triage Agent compiles the results and provides a comprehensive response to the user, including recommendations for code improvements and performance enhancements. 6. Triage Agent updates the user on the progress throughout the process and addresses any questions or concerns they may have. From b3a5aa1bf166746b1a1cfe4992e62df63439ffee Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 20:06:48 -0500 Subject: [PATCH 5/8] Update .github/agents/mysql-mariadb.agent.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/agents/mysql-mariadb.agent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/agents/mysql-mariadb.agent.md b/.github/agents/mysql-mariadb.agent.md index 4fb01ee2..072e2aaf 100644 --- a/.github/agents/mysql-mariadb.agent.md +++ b/.github/agents/mysql-mariadb.agent.md @@ -1,5 +1,5 @@ --- -description: "This custom agent assits with enhancements, troubleshooting, and management of MySQL and MariaDB databases." +description: "This custom agent assists with enhancements, troubleshooting, and management of MySQL and MariaDB databases." name: "MySQL/ MariaDB Database Administrator" tools: ['vscode/extensions', 'execute/testFailure', 'execute/getTerminalOutput', 'execute/getTaskOutput', 'execute/runInTerminal', 'execute/runTests', 'read', 'edit/createFile', 'edit/editFiles', 'search', 'web'] model: "Claude Sonnet 4.5" From 694ff31f8ef31e6e39fcb94be5b15fa153dbfbed Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 20:07:56 -0500 Subject: [PATCH 6/8] Update .github/workflows/plugin-ci-workflow.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/plugin-ci-workflow.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index 728eee21..1476b54e 100644 --- a/.github/workflows/plugin-ci-workflow.yml +++ b/.github/workflows/plugin-ci-workflow.yml @@ -182,9 +182,6 @@ jobs: run: sed '/plugins/d' -i .phpstan.neon working-directory: ${{ github.workspace }}/cacti - - name: Mark composer scripts executable - run: sudo chmod +x ${{ github.workspace }}/cacti/include/vendor/bin/* - - name: Run Linter on base code run: composer run-script lint ${{ github.workspace }}/cacti/plugins/mactrack working-directory: ${{ github.workspace }}/cacti From f53e457c26e90a7042c2dd303475e94ef4e21e6d Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 20:08:21 -0500 Subject: [PATCH 7/8] Update .github/workflows/plugin-ci-workflow.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/plugin-ci-workflow.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index 1476b54e..4295bcfd 100644 --- a/.github/workflows/plugin-ci-workflow.yml +++ b/.github/workflows/plugin-ci-workflow.yml @@ -106,16 +106,14 @@ jobs: cat ~/.my.cnf - name: Initialize Cacti Database - env: - MYSQL_AUTH_USR: '--defaults-file=~/.my.cnf' run: | - mysql $MYSQL_AUTH_USR -e 'CREATE DATABASE IF NOT EXISTS cacti;' - mysql $MYSQL_AUTH_USR -e "CREATE USER IF NOT EXISTS 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';" - mysql $MYSQL_AUTH_USR -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';" - mysql $MYSQL_AUTH_USR -e "GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';" - mysql $MYSQL_AUTH_USR -e "FLUSH PRIVILEGES;" - mysql $MYSQL_AUTH_USR cacti < ${{ github.workspace }}/cacti/cacti.sql - mysql $MYSQL_AUTH_USR -e "INSERT INTO settings (name, value) VALUES ('path_php_binary', '/usr/bin/php')" cacti + mysql --defaults-file="$HOME/.my.cnf" -e 'CREATE DATABASE IF NOT EXISTS cacti;' + mysql --defaults-file="$HOME/.my.cnf" -e "CREATE USER IF NOT EXISTS 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';" + mysql --defaults-file="$HOME/.my.cnf" -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';" + mysql --defaults-file="$HOME/.my.cnf" -e "GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';" + mysql --defaults-file="$HOME/.my.cnf" -e "FLUSH PRIVILEGES;" + mysql --defaults-file="$HOME/.my.cnf" cacti < ${{ github.workspace }}/cacti/cacti.sql + mysql --defaults-file="$HOME/.my.cnf" -e "INSERT INTO settings (name, value) VALUES ('path_php_binary', '/usr/bin/php')" cacti - name: Validate composer files run: | From 517a3b5af1fc7c7d94d915e3103fc791a07f6c0d Mon Sep 17 00:00:00 2001 From: Sean Mancini Date: Fri, 13 Feb 2026 20:08:39 -0500 Subject: [PATCH 8/8] Update .github/agents/triage_agent.md.agent.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/agents/triage_agent.md.agent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/agents/triage_agent.md.agent.md b/.github/agents/triage_agent.md.agent.md index 66c4db06..1575ef5b 100644 --- a/.github/agents/triage_agent.md.agent.md +++ b/.github/agents/triage_agent.md.agent.md @@ -1,5 +1,5 @@ --- -description: 'This Agent will Receiving the initial task and call on other agents based on the task' +description: 'This agent receives the initial task and calls on other agents based on the task' tools: ['execute', 'read', 'search', 'web', 'agent'] --- Define what this custom agent accomplishes for the user, when to use it, and the edges it won't cross. Specify its ideal inputs/outputs, the tools it may call, and how it reports progress or asks for help.