OpenWriterControle/.opencode/command/commit-openagents.md
Darren Hinde 193271091a
feat: add ExternalScout and optimize ContextScout with research-backed patterns (#128)
* feat: add ExternalScout and optimize ContextScout with research-backed patterns

## New Features

### ExternalScout Subagent (v2.0.0)
- Fetches live, version-specific documentation for external libraries via Context7 API
- Supports 18+ libraries: Drizzle, Better Auth, Next.js, TanStack, Cloudflare Workers, AWS Lambda, Vercel, Shadcn/ui, Radix UI, Tailwind CSS, Zustand, Jotai, Zod, React Hook Form, Vitest, Playwright
- Lazy-loads query patterns for specific libraries only
- Filters and formats results by relevance (Critical → High → Medium)
- Fallback to official docs via webfetch
- 42% token reduction via research-backed optimization
- Added to registry with skill:context7 dependency

### Context7 Skill
- Registered in system for external documentation fetching
- Library registry with 18+ supported libraries
- Query optimization patterns per library
- Navigation guide and README

## Optimizations

### ContextScout v5.1.0
- Optimized with research-backed prompt engineering patterns
- Critical rules moved to first 15% of prompt (position sensitivity)
- Added 3-tier execution priority system
- 20% token reduction via visual operators (→, |, @refs)
- Simplified XML structure (4% XML) for multi-model compatibility (Claude, Gemini, GPT-4)
- Added external library detection and ExternalScout recommendation
- Added dependency: subagent:externalscout
- 100% behavior preservation

### ExternalScout v2.0.0 Optimizations
- 42% token reduction via visual operators and inline mappings
- Critical rules moved to first 15% of prompt
- Added 3-tier execution priority system
- Added references to prompt engineering docs and context system
- Enhanced workflow structure with checkpoints
- Added dependencies: context:prompt-engineering, context:context-system
- 100% behavior preservation

## Registry Updates
- Added ExternalScout subagent entry
- Added Context7 skill entry
- Updated ContextScout dependencies to include ExternalScout
- Added version numbers to both subagents
- Enhanced descriptions with optimization details
- Added 'optimized' tag to both subagents

## Files Added
- .opencode/agent/subagents/core/externalscout.md
- .opencode/skill/context7/README.md
- .opencode/skill/context7/library-registry.md
- .opencode/skill/context7/navigation.md
- .opencode/agent/subagents/core/contextscout-v4-backup.md (backup)
- .opencode/agent/subagents/core/externalscout-v1-backup.md (backup)

## Files Modified
- .opencode/agent/subagents/core/contextscout.md (v4.0.0 → v5.1.0)
- registry.json (added ExternalScout, Context7, updated ContextScout)
- CHANGELOG.md (documented all changes)
- VERSION (0.5.5 → 0.6.0)
- package.json (0.5.5 → 0.6.0)

## Research Patterns Applied
- Position sensitivity: Critical rules in first 15%
- Nesting reduction: ≤4 levels
- Instruction ratio: 40-50%
- Single source of truth: @references
- Token optimization: Visual operators (→, |, @)
- Multi-model compatibility: Simplified XML structure

## Breaking Changes
None - 100% backward compatible

## Testing
- ContextScout: Maintains identical behavior with improved structure
- ExternalScout: New functionality, ready for testing
- Both agents: Optimized for Claude, Gemini, GPT-4 compatibility

Closes #[issue-number-if-applicable]

* refactor: Lean down ExternalScout - fetch, filter, save, return locations only

- Removed bloated Stage 6 (FormatAndReturn) with fancy formatting
- Removed multi-library integration guides and query optimization sections
- Removed complex output formatting and success criteria bloat
- Simplified workflow to 5 lean stages: Detect → Fetch → Filter → Persist → Return
- New output format: file locations + brief summary + official docs link
- Kept essential error handling and source citations
- Version bumped to 2.0.0
- Focus: Fast, accurate documentation retrieval without extra bloat

* feat: Add ExternalScout and optimize context system

- Add ExternalScout agent for fetching current external library documentation
- Add OpenImplementer agent for lightweight focused coding tasks
- Reorganize specialists to subagents/ directory for cleaner structure
- Optimize ContextScout with leaner, more focused implementation
- Update registry with new agents and reorganized categories
- Enhance documentation (README, guides, context files)
- Add external context integration workflows
- Add comprehensive CONTEXT_SYSTEM_GUIDE.md
- Deprecate codebase-agent and codebase-pattern-analyst
- Update all profiles to reflect new agent structure
- Create context-manager skill with 8 operations
- Add external context management scripts

BREAKING CHANGES: None (all changes backward compatible)

Fixes: Outdated training data issues for external libraries

* fix: resolve ShellCheck issues and add missing context files to registry

- Fix all 'read' commands to use -r flag (SC2162) to prevent backslash mangling
- Fix exit code checks to use direct command evaluation instead of $? (SC2181)
- Add double quotes around variable in comparison (SC2086)
- Add 8 missing context files to registry.json:
  - external-libraries.md (new workflow for external library handling)
  - visual-development.md
  - development/README.md
  - learning/README.md
  - product/README.md
  - data/README.md
  - mastra-ai/README.md
  - context-bundle-template.md
- Registry now has 226 valid paths with 0 missing files
- All ShellCheck warnings resolved

* docs: add external-libraries-workflow guide to openagents-repo context

- Create new guide for handling external library dependencies
- Covers when to use ExternalScout, supported libraries, and workflow steps
- Integrates with existing agent/skill creation guides
- Updated navigation.md to include new guide with ⭐⭐⭐⭐ priority
- Added to registry with dependencies on core external-libraries context
- Fills critical gap in developer documentation for external package handling

* fix: resolve ShellCheck SC2145 errors in context router

- Change $@ to $* in echo statements to fix SC2145 warnings
- Prevents argument mixing in string context
- All ShellCheck errors now resolved (only SC2034 warnings remain)

* fix: resolve all ShellCheck warnings in manage-external-context.sh

- Add -r flag to all read commands (SC2162)
- Declare and assign variables separately (SC2155)
- Quote variable in find -mtime command (SC2086)
- Fix subshell count issue by using process substitution (SC2030/SC2031)
- Comment out unused variables (SC2034)
- All ShellCheck warnings now resolved

* fix: remove unused variables in context router to pass ShellCheck

- Comment out SCRIPT_DIR and PROJECT_ROOT (SC2034)
- Variables were defined but never used
- All ShellCheck warnings now resolved across all shell scripts

* fix: replace bash registry validation with Python script

- Create fast Python validation script (validate-registry.py)
- Replace hanging bash script with Python in CI workflow
- Python script validates all 231 registry paths in <1 second
- Fixes registry validation timeout issues in CI
- All paths validated successfully

* chore: trigger CI re-run for workflow updates

* Revert "fix: replace bash registry validation with Python script"

This reverts commit 03843935d075f1350afb721b5235e9406005810f.

* fix: remove verbose flag and add timeout to registry validation

- Remove -v flag from validation script (reduces output, faster execution)
- Add 60 second timeout to prevent hanging
- Show full output instead of tail -20 for better debugging
- Fixes CI timeout issues while keeping original bash script

* feat: add TypeScript registry validator with full skill support

- Add fast TypeScript validator using Bun (< 1 second vs bash hanging)
- Add skill dependency type support to validator
- Add files array to skills in registry for complete installation
- Update install.sh to download all skill files when files array present
- Add npm scripts: validate:registry, validate:registry:verbose, validate:registry:fix
- Fix skill IDs: context-manager → context (matches folder name)
- Add orphaned file scanning with skill support file exclusions
- Add enhanced fix suggestions with actual file searching
- Remove duplicate context-manager.md file
- Add comprehensive README for registry validation scripts

Skills now install completely with all supporting files:
- SKILL.md (main definition)
- router.sh (CLI entry point)
- scripts/ (supporting scripts)
- config/ (configuration files)
- All other supporting files

Validation results:
- 231 paths validated (all valid)
- 4 skills registered with complete file lists
- Orphaned files reduced from 6 to 2
- Only 1 dependency issue remaining (context:prompt-engineering)

* fix: use TypeScript validator in CI instead of hanging bash script

- Install Bun in CI workflow
- Switch from bash validator to TypeScript validator
- Removes 60s timeout (TypeScript completes in <1s)
- Fixes CI hanging issue on registry validation

* chore: retrigger CI checks

Empty commit to retrigger CI after workflow fix in PR #129

* fix: use official Bun setup action in CI

- Replace manual Bun installation with oven-sh/setup-bun@v2
- Fixes PATH issue where bun wasn't available in subsequent steps
- Ensures Bun is properly installed before running TypeScript validator

* chore: retrigger CI after Bun setup fix in PR #131

Empty commit to retrigger CI once PR #131 is merged to main

* fix: remove non-existent context:prompt-engineering dependency from ExternalScout
2026-01-29 11:16:12 +00:00

16 KiB
Raw Blame History

description
Smart commit command for opencode-agents repository with automatic validation and conventional commits

Commit OpenAgents Control Command

You are an AI agent that helps create well-formatted git commits specifically for the opencode-agents repository. This command handles the complete commit workflow including validation, testing, and pushing changes.

Instructions for Agent

When the user runs this command, execute the following workflow:

1. Smart Repo Analysis (Automatic)

Before doing anything, analyze the repo state:

# Check current branch and status
git status
git branch --show-current

# Check for workflow issues
git tag --sort=-v:refname | head -5  # Check recent tags
cat VERSION  # Check current version
git log --oneline -5  # Check recent commits

# Check for stale automation branches
git branch -a | grep -E "chore/version-bump|docs/auto-sync" | wc -l

Intelligent Analysis:

  • 🔍 Version Sync Check: Compare VERSION file with latest git tag
    • If VERSION > latest tag → Suggest creating missing release
    • If tags are missing → Offer to trigger release workflow
  • 🧹 Branch Cleanup: Detect stale automation branches
    • Count chore/version-bump-* branches
    • Count docs/auto-sync-* branches
    • If > 3 stale branches → Suggest cleanup
  • 🔄 Workflow Health: Check if workflows are working
    • Look for recent workflow runs
    • Check for disabled workflows that might be needed
  • 📊 Repo State: Summarize current state
    • Current branch
    • Uncommitted changes
    • Recent activity

Present Analysis:

📊 Repo Health Check:
- Current branch: <branch>
- Version: <VERSION> | Latest tag: <tag>
- Stale branches: <count> automation branches
- Uncommitted changes: <count> files

[If issues detected:]
⚠️ Issues Found:
- Missing release for v<VERSION> (tag not created)
- <count> stale automation branches need cleanup

Would you like to:
1. Fix issues first (recommended)
2. Continue with commit
3. View detailed analysis

If user chooses "Fix issues":

  • Offer to trigger create-release.yml workflow for missing tags
  • Offer to clean up stale branches
  • Offer to audit workflows if problems detected

2. Pre-Commit Validation (Optional)

Ask user:

Would you like to run smoke tests before committing? (y/n)
- y: Run validation tests
- n: Skip directly to commit

If user chooses to run tests:

cd evals/framework && npm run eval:sdk -- --agent=core/openagent --pattern="**/smoke-test.yaml"
cd evals/framework && npm run eval:sdk -- --agent=core/opencoder --pattern="**/smoke-test.yaml"

Validation Rules:

  • ⚠️ If tests fail, ask user if they want to proceed or fix issues first
  • ✅ Tests are optional - user can skip and commit directly

3. Analyze Changes

  • Run git status to see all untracked files
  • Run git diff to see both staged and unstaged changes
  • Run git log --oneline -5 to see recent commit style
  • Identify the scope of changes (evals, scripts, docs, agents, workflows, etc.)
  • Special Detection: Check if changes are workflow-related
    • If .github/workflows/ modified → Suggest workflow validation
    • If new workflow added → Offer to document it
    • If workflow disabled/deleted → Ask for confirmation

4. Stage Files Intelligently

Auto-stage based on change type:

  • If modifying evals framework → stage evals/framework/
  • If modifying core agents → stage .opencode/agent/core/
  • If modifying content agents → stage .opencode/agent/content/
  • If modifying data agents → stage .opencode/agent/data/
  • If modifying meta agents → stage .opencode/agent/meta/
  • If modifying subagents → stage .opencode/agent/subagents/
  • If modifying commands → stage .opencode/command/
  • If modifying context → stage .opencode/context/
  • If modifying scripts → stage scripts/
  • If modifying docs → stage docs/
  • If modifying CI/CD → stage .github/workflows/
  • If user provides specific files → stage only those

Never auto-stage:

  • node_modules/
  • .env files
  • test_tmp/ or temporary directories
  • evals/results/ (test results)

5. Generate Commit Message

Follow Conventional Commits (NO EMOJIS):

<type>(<scope>): <description>

[optional body]

Types for this repo:

  • feat - New features (agents, commands, tools)
  • fix - Bug fixes
  • refactor - Code restructuring without behavior change
  • test - Test additions or modifications
  • docs - Documentation updates
  • chore - Maintenance tasks (dependencies, cleanup)
  • ci - CI/CD pipeline changes
  • perf - Performance improvements

Scopes for this repo:

  • evals - Evaluation framework changes
  • agents/core - Core agents (openagent, opencoder, openimplementer)
  • agents/meta - Meta agents (system-builder, repo-manager)
  • agents/content - Content category agents (copywriter, technical-writer)
  • agents/data - Data category agents (data-analyst)
  • subagents/core - Core subagents (task-manager, documentation, contextscout, externalscout)
  • subagents/code - Code subagents (coder-agent, tester, reviewer, build-agent)
  • subagents/development - Development specialist subagents (frontend-specialist, devops-specialist)
  • subagents/system-builder - System builder subagents (domain-analyzer, agent-generator, context-organizer, workflow-designer, command-creator)
  • subagents/utils - Utility subagents (image-specialist)
  • commands - Slash command changes
  • context - Context file changes
  • scripts - Build/test script changes
  • ci - GitHub Actions workflow changes
  • docs - Documentation changes
  • registry - Registry.json changes

Examples:

feat(evals): add parallel test execution support
fix(agents/core): correct delegation logic in openagent
fix(subagents/development): update frontend-specialist validation rules
feat(agents/content): add new copywriter capabilities
feat(agents/meta): enhance system-builder with new templates
refactor(evals): split test-runner into modular components
test(evals): add smoke tests for openagent
feat(subagents/code): add build validation to build-agent
feat(subagents/system-builder): improve domain-analyzer pattern detection
docs(readme): update installation instructions
chore(deps): upgrade evaluation framework dependencies
feat(registry): add new agent categories
ci: add automatic version bumping workflow

6. Commit Analysis

<commit_analysis>

  • List all files that have been changed or added
  • Summarize the nature of changes (new feature, bug fix, refactor, etc.)
  • Identify the primary scope (evals, agents, scripts, etc.)
  • Determine the purpose/motivation behind changes
  • Assess impact on the overall project
  • Check for sensitive information (API keys, tokens, etc.)
  • Draft a concise commit message focusing on "why" not "what"
  • Ensure message follows conventional commit format
  • Verify message is specific and not generic </commit_analysis>

7. Execute Commit

git add <relevant-files>
git commit -m "<type>(<scope>): <description>"
git status  # Verify commit succeeded

8. Post-Commit Actions

Ask user:

✅ Commit created: <commit-hash>
📝 Message: <commit-message>

Would you like to:
1. Push to remote (git push origin <branch>)
2. Create another commit
3. Done

If user chooses push:

git push origin <current-branch>

Then inform based on commit type:

For workflow changes (.github/workflows/):

🚀 Pushed workflow changes!

This will trigger:
- Workflow validation on PR
- Registry validation
- PR checks

⚠️ Important:
- New workflows won't run until merged to main
- Test workflows using workflow_dispatch if available
- Check GitHub Actions tab for workflow syntax errors

For feature/fix commits to main:

🚀 Pushed to main!

This will trigger:
- Post-merge version bump workflow
- Create version bump PR automatically
- Update VERSION, package.json, CHANGELOG.md
- After version bump PR merges → Create git tag & release

Expected flow:
1. Your commit merged ✅
2. Version bump PR created (automated)
3. Review & merge version bump PR
4. Git tag & GitHub release created automatically

For other commits:

🚀 Pushed to remote!

This will trigger:
- PR checks (if on feature branch)
- Registry validation
- Build & test validation

Workflow Management (Smart Automation)

Automatic Workflow Analysis

When committing workflow changes or when issues are detected, provide intelligent guidance:

1. Version & Release Sync

# Check if version and tags are in sync
VERSION=$(cat VERSION)
LATEST_TAG=$(git tag --sort=-v:refname | head -1)

if [ "v$VERSION" != "$LATEST_TAG" ]; then
  echo "⚠️ Version mismatch detected!"
  echo "VERSION file: $VERSION"
  echo "Latest tag: $LATEST_TAG"
  echo ""
  echo "Would you like to:"
  echo "1. Trigger create-release workflow to create v$VERSION tag/release"
  echo "2. Manually create tag: git tag v$VERSION && git push origin v$VERSION"
  echo "3. Ignore (version bump PR may be pending)"
fi

2. Stale Branch Cleanup

# Detect stale automation branches
STALE_BRANCHES=$(git branch -a | grep -E "chore/version-bump|docs/auto-sync" | wc -l)

if [ "$STALE_BRANCHES" -gt 3 ]; then
  echo "🧹 Found $STALE_BRANCHES stale automation branches"
  echo ""
  echo "Would you like to clean them up?"
  echo "1. Yes - delete merged automation branches"
  echo "2. No - keep them"
  echo "3. Show me the branches first"
fi

3. Workflow Health Check

# Check for common workflow issues
if [ -f .github/workflows/post-merge.yml.disabled ]; then
  echo "ℹ️ Found disabled workflow: post-merge.yml.disabled"
  echo "This workflow has been replaced by post-merge-pr.yml + create-release.yml"
  echo ""
  echo "Would you like to delete it? (cleanup)"
fi

# Check if create-release.yml exists
if [ ! -f .github/workflows/create-release.yml ]; then
  echo "⚠️ Missing create-release.yml workflow"
  echo "Tags and releases won't be created automatically!"
  echo ""
  echo "Would you like to create it?"
fi

4. Workflow Documentation

When new workflows are added, offer to update documentation:

✅ New workflow detected: <workflow-name>.yml

Would you like to:
1. Add entry to .github/workflows/WORKFLOW_AUDIT.md
2. Update navigation.md with workflow info
3. Skip documentation (do it later)

Workflow Commit Best Practices

For workflow changes, always:

  • Test workflow syntax before committing
  • Document what the workflow does
  • Explain why changes were made
  • Note any breaking changes
  • Update workflow audit documentation

Commit message format for workflows:

ci(workflows): <what changed>

Why: <reason for change>
Impact: <what this affects>
Testing: <how to test>

Example:

ci(workflows): add automatic release creation workflow

Why: Version bumps were happening but tags/releases weren't being created
Impact: After version bump PRs merge, tags and releases will be created automatically
Testing: Manually trigger workflow with: gh workflow run create-release.yml

Repository-Specific Rules

Version Bumping (Automatic via CI/CD)

Commits trigger automatic version bumps:

  • feat: → minor bump (0.0.1 → 0.1.0)
  • fix: → patch bump (0.0.1 → 0.0.2)
  • feat!: or BREAKING CHANGE: → major bump (0.1.0 → 1.0.0)
  • [alpha] in message → alpha bump (0.1.0-alpha.1 → 0.1.0-alpha.2)
  • Default → patch bump (0.0.1 → 0.0.2)

Files to Always Check

Before committing, verify these are in sync:

  • VERSION file
  • package.json version
  • CHANGELOG.md (if manually updated)

Pre-Commit Hooks

This repo may have pre-commit hooks that:

  • Run linting
  • Format code
  • Run type checks

If hooks modify files:

  • Automatically amend the commit to include hook changes
  • Inform user that files were auto-formatted

Error Handling

If Smoke Tests Fail

⚠️ Smoke tests failed for <agent-name>

Failures:
<test-output>

Options:
1. Fix issues and retry
2. Run full test suite (cd evals/framework && npm run eval:sdk -- --agent=<category>/<agent>)
3. Proceed anyway (not recommended)
4. Cancel commit

What would you like to do?

If No Changes Detected

ℹ️ No changes to commit. Working tree is clean.

Recent commits:
<git log --oneline -3>

Would you like to:
1. Check git status
2. View recent commits
3. Exit

If Merge Conflicts

⚠️ Merge conflicts detected. Please resolve conflicts first.

Conflicted files:
<list-files>

Run: git status

Active Workflows in This Repo

Understanding the automation:

  1. create-release.yml ✅ NEW

    • Triggers: After version bump PRs merge (detects version-bump label)
    • Creates: Git tags and GitHub releases
    • Manual: Can trigger via gh workflow run create-release.yml
  2. post-merge-pr.yml ✅ Active

    • Triggers: Push to main
    • Creates: Version bump PR (updates VERSION, package.json, CHANGELOG.md)
    • Skips: If commit has version-bump or automated label
  3. pr-checks.yml ✅ Active

    • Triggers: Pull requests
    • Validates: PR title format, builds framework, runs tests
    • Required: Must pass before merge
  4. validate-registry.yml ✅ Active

    • Triggers: Pull requests
    • Validates: Registry.json, prompt library structure
    • Auto-fixes: Adds new components to registry
  5. update-registry.yml ✅ Active

    • Triggers: Push to main (when .opencode/ changes)
    • Updates: Registry.json automatically
    • Direct push: No PR needed
  6. sync-docs.yml ✅ Active

    • Triggers: Push to main (when registry/components change)
    • Creates: GitHub issue for OpenCode to sync docs
    • Optional: Can be simplified if too complex
  7. validate-test-suites.yml ✅ Active

    • Triggers: Pull requests (when evals/ changes)
    • Validates: YAML test files
    • Required: Must pass before merge

Workflow Flow for Version Bumps:

1. Merge feat/fix PR to main
   ↓
2. post-merge-pr.yml creates version bump PR
   ↓
3. Review & merge version bump PR
   ↓
4. create-release.yml creates tag & release
   ↓
5. Done! 🎉

Agent Behavior Notes

  • Repo health first - Always run smart analysis before committing
  • Workflow awareness - Understand which workflows will trigger
  • Optional validation - Ask user if they want to run smoke tests (not mandatory)
  • Smart staging - Only stage relevant files based on change scope and category structure
  • Conventional commits - Strictly follow conventional commit format (NO EMOJIS)
  • Scope awareness - Use appropriate scope for this repository (include category paths)
  • Version awareness - Inform user about automatic version bumping and release creation
  • CI/CD awareness - Remind user that push triggers automated workflows
  • Security - Never commit sensitive information (API keys, tokens, .env files)
  • Atomic commits - Each commit should have a single, clear purpose
  • Push guidance - Always ask before pushing to remote
  • Category-aware - Recognize new agent organization (core, development, content, data, meta, learning, product)
  • Cleanup suggestions - Offer to clean up stale branches and disabled workflows
  • Documentation - Suggest updating workflow docs when workflows change

Quick Reference

Common Workflows

Feature Addition:

# 1. Optional: Run smoke tests
cd evals/framework && npm run eval:sdk -- --agent=core/openagent --pattern="**/smoke-test.yaml"

# 2. Stage and commit
git add <files>
git commit -m "feat(evals): add new evaluation metric"

# 3. Push
git push origin main

Bug Fix:

git add <files>
git commit -m "fix(agents/core): correct delegation threshold logic"
git push origin main

Documentation:

git add docs/
git commit -m "docs(guides): update testing documentation"
git push origin main

Refactoring:

git add evals/framework/src/
git commit -m "refactor(evals): extract validation logic into separate module"
git push origin main

Success Criteria

A successful commit should:

  • ✅ Follow conventional commit format (NO EMOJIS)
  • ✅ Have appropriate scope with category path (e.g., agents/core, subagents/code)
  • ✅ Be atomic (single purpose)
  • ✅ Have clear, concise message
  • ✅ Not include sensitive information
  • ✅ Not include generated files (node_modules, build artifacts)
  • ✅ Only stage relevant files based on category structure
  • ✅ Trigger appropriate CI/CD workflows when pushed
  • ✅ Optionally pass smoke tests if validation was requested