feat: add plugin template and 'aidevops plugin init' command (t136.4)#763
feat: add plugin template and 'aidevops plugin init' command (t136.4)#763alex-solovyev merged 1 commit intomainfrom
Conversation
Create plugin-template/ with AGENTS.md, main-agent.md, and example-subagent.md templates with placeholder substitution. Add 'init' subcommand to cmd_plugin() that scaffolds a new plugin directory from the template. Update plugins.md with init docs. Fixes: t136.4 ref:GH#731
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
WalkthroughThe pull request introduces a plugin initialization system for the AIDEvOps framework. It adds documentation, template files for scaffolding, and a shell script implementation of a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Mon Feb 9 05:33:01 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@aidevops.sh`:
- Line 2503: Help text for the "init" subcommand is missing the third positional
arg; update the echo lines that print the init usage (the lines that currently
output 'init [dir] [name] Scaffold a new plugin from template') to include
'[namespace]' so they read 'init [dir] [name] [namespace] Scaffold a new plugin
from template'; make the same change for the second occurrence referenced in the
file (the other echo at the later help block) to keep help output consistent
with plugins.md and the PR description.
- Around line 2422-2434: After parsing args in the init case, call
validate_namespace "$namespace" and abort (return non-zero) if it fails so
reserved names like custom/draft/plugins are rejected; also sanitize plugin_name
before any sed interpolation (escape sed metacharacters such as & and any chosen
delimiter like |) or switch to a safer substitution method so names containing
|, & or other special chars cannot break or inject into sed expressions (look
for the init case, the namespace variable, the validate_namespace function, and
places where plugin_name is used inside sed).
🧹 Nitpick comments (1)
aidevops.sh (1)
2427-2434: Existing-directory check skipped whentarget_diris.(current directory).When
target_dirdefaults to., the file-existence check is bypassed entirely, so runningaidevops plugin inittwice in the same directory silently overwritesAGENTS.md,<namespace>.md, etc. Consider either warning on overwrite or checking regardless of the directory value.Proposed approach
- if [[ "$target_dir" != "." && -d "$target_dir" ]]; then - local existing_count - existing_count=$(find "$target_dir" -maxdepth 1 -type f | wc -l | tr -d ' ') - if [[ "$existing_count" -gt 0 ]]; then - print_error "Directory '$target_dir' already has files. Use an empty directory." - return 1 - fi - fi + if [[ -d "$target_dir" ]]; then + if [[ -f "$target_dir/AGENTS.md" ]]; then + print_error "Directory '$target_dir' already contains AGENTS.md. Aborting to avoid overwrite." + return 1 + fi + fi
| init) | ||
| local target_dir="${1:-.}" | ||
| local plugin_name="${2:-my-plugin}" | ||
| local namespace="${3:-$plugin_name}" | ||
|
|
||
| if [[ "$target_dir" != "." && -d "$target_dir" ]]; then | ||
| local existing_count | ||
| existing_count=$(find "$target_dir" -maxdepth 1 -type f | wc -l | tr -d ' ') | ||
| if [[ "$existing_count" -gt 0 ]]; then | ||
| print_error "Directory '$target_dir' already has files. Use an empty directory." | ||
| return 1 | ||
| fi | ||
| fi |
There was a problem hiding this comment.
Missing validate_namespace call — reserved namespaces not enforced.
The init subcommand accepts a namespace argument but never calls validate_namespace(), which is defined and used by other subcommands (add, etc.) in this same function. A user could scaffold a plugin with a reserved namespace like custom, draft, or plugins, creating confusion or collisions when later installed.
Additionally, plugin_name is unsanitized and interpolated directly into sed expressions. While the | delimiter reduces risk from /, characters like | or & in the name could still break or inject into sed.
Proposed fix: add validation after argument parsing
init)
local target_dir="${1:-.}"
local plugin_name="${2:-my-plugin}"
local namespace="${3:-$plugin_name}"
+ # Validate namespace against reserved names and format rules
+ if ! validate_namespace "$namespace"; then
+ return 1
+ fi
+
+ # Validate plugin_name is safe for sed interpolation
+ if [[ ! "$plugin_name" =~ ^[a-zA-Z][a-zA-Z0-9_-]*$ ]]; then
+ print_error "Invalid plugin name '$plugin_name': must be alphanumeric with hyphens/underscores"
+ return 1
+ fi
+
if [[ "$target_dir" != "." && -d "$target_dir" ]]; then📝 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.
| init) | |
| local target_dir="${1:-.}" | |
| local plugin_name="${2:-my-plugin}" | |
| local namespace="${3:-$plugin_name}" | |
| if [[ "$target_dir" != "." && -d "$target_dir" ]]; then | |
| local existing_count | |
| existing_count=$(find "$target_dir" -maxdepth 1 -type f | wc -l | tr -d ' ') | |
| if [[ "$existing_count" -gt 0 ]]; then | |
| print_error "Directory '$target_dir' already has files. Use an empty directory." | |
| return 1 | |
| fi | |
| fi | |
| init) | |
| local target_dir="${1:-.}" | |
| local plugin_name="${2:-my-plugin}" | |
| local namespace="${3:-$plugin_name}" | |
| # Validate namespace against reserved names and format rules | |
| if ! validate_namespace "$namespace"; then | |
| return 1 | |
| fi | |
| # Validate plugin_name is safe for sed interpolation | |
| if [[ ! "$plugin_name" =~ ^[a-zA-Z][a-zA-Z0-9_-]*$ ]]; then | |
| print_error "Invalid plugin name '$plugin_name': must be alphanumeric with hyphens/underscores" | |
| return 1 | |
| fi | |
| if [[ "$target_dir" != "." && -d "$target_dir" ]]; then | |
| local existing_count | |
| existing_count=$(find "$target_dir" -maxdepth 1 -type f | wc -l | tr -d ' ') | |
| if [[ "$existing_count" -gt 0 ]]; then | |
| print_error "Directory '$target_dir' already has files. Use an empty directory." | |
| return 1 | |
| fi | |
| fi |
🤖 Prompt for AI Agents
In `@aidevops.sh` around lines 2422 - 2434, After parsing args in the init case,
call validate_namespace "$namespace" and abort (return non-zero) if it fails so
reserved names like custom/draft/plugins are rejected; also sanitize plugin_name
before any sed interpolation (escape sed metacharacters such as & and any chosen
delimiter like |) or switch to a safer substitution method so names containing
|, & or other special chars cannot break or inject into sed expressions (look
for the init case, the namespace variable, the validate_namespace function, and
places where plugin_name is used inside sed).
| echo " enable <name> Enable a disabled plugin (redeploys files)" | ||
| echo " disable <name> Disable a plugin (removes files, keeps config)" | ||
| echo " remove <name> Remove a plugin entirely" | ||
| echo " init [dir] [name] Scaffold a new plugin from template" |
There was a problem hiding this comment.
Help text omits the [namespace] argument.
The init subcommand accepts three positional args ([dir] [name] [namespace]), but both help lines show only [dir] [name]. The PR description and plugins.md documentation correctly show all three. Keep the help output consistent.
Proposed fix
- echo " init [dir] [name] Scaffold a new plugin from template"
+ echo " init [dir] [name] [namespace] Scaffold a new plugin from template"- echo " aidevops plugin init ./my-plugin my-plugin"
+ echo " aidevops plugin init ./my-plugin my-plugin my-ns"Also applies to: 2519-2519
🤖 Prompt for AI Agents
In `@aidevops.sh` at line 2503, Help text for the "init" subcommand is missing the
third positional arg; update the echo lines that print the init usage (the lines
that currently output 'init [dir] [name] Scaffold a new plugin from template')
to include '[namespace]' so they read 'init [dir] [name] [namespace] Scaffold a
new plugin from template'; make the same change for the second occurrence
referenced in the file (the other echo at the later help block) to keep help
output consistent with plugins.md and the PR description.



Summary
plugin-template/in.agents/templates/with AGENTS.md, main-agent.md, and example-subagent.mdaidevops plugin init [dir] [name] [namespace]subcommand that scaffolds a new plugin from the template{{PLACEHOLDER}}substitution for plugin name, namespace, repo URL, etc.plugins.mdto document theinitcommandDetails
Part of the Plugin System plan (t136). Follows t136.3 (setup.sh deployment, PR #762).
Template files
AGENTS.mdmain-agent.mdexample-subagent.mdUsage
Generates:
Testing
bash -n aidevops.sh-- syntax OKaidevops plugin help-- showsinitcommandaidevops plugin init /tmp/test test-plugin test-- scaffolds correctly with all placeholders substitutedFixes: t136.4 ref:GH#731
Summary by CodeRabbit
New Features
plugin init[directory] [name] command to scaffold new plugins with auto-generated configuration, main agent files, example subagents, and scripts directory.Documentation