Last Updated: 2026-01-25
Current Phase: Phase 2 - Handler Execution
- Pattern detection (regex-based)
- Context injection (hints, tools, constraints)
- Toast notifications
- File-based logging
- Plugin hooks (chat.message, event)
- Config schema (Zod)
- Config loader (.opencode/ability-control/config.json)
- Enable/disable built-in abilities
- Custom ability directories
- Logging configuration
- Interactive setup (
npx ability-control init) - Directory structure creation
- Example abilities
- README generation
- README.md (installation, usage, examples)
- LICENSE (MIT)
- DESIGN.md (architecture, principles)
- CHECKLIST.md (this file)
- Delete obsolete postinstall script
- Delete old .abilities/ directory
- Fix config loader path
- Rebuild plugin and CLI
Goal: Execute TypeScript functions when abilities trigger
Timeline: 4 weeks
Status: Not started
- Define
HandlerContextinterface-
ability: Readonly<Ability>- Ability definition -
params: Record<string, any>- Extracted parameters -
client: PluginClient- OpenCode client -
logger: Logger- Scoped logger -
progress: ProgressTracker- Progress updates
-
- Define
HandlerResultinterface-
success: boolean -
message: string -
data?: any -
error?: Error
-
- Create handler template generator
- Extract regex capture groups
- Map capture groups to handler params
- Support named capture groups
- Type validation (string, number, boolean)
- Default values
- Required vs optional params
- Dynamic import of TypeScript handlers
- Validate handler exports (must export
executefunction) - Cache loaded handlers (performance)
- Hot reload handlers in dev mode
- Error handling (handler not found, invalid export)
- Execute handler with context
- Timeout enforcement (default 30s)
- Error handling and recovery
- Return results to Claude
- Log execution (start, end, duration, result)
- Validate allowed tools
- Validate allowed paths (glob patterns)
- Validate denied paths
- Require user confirmation (if configured)
- Block execution if validation fails
-
Layer 1: Execution Depth Tracking
- Track execution depth per session
- Prevent ability-to-ability calls
- Detect circular references
- Enforce max depth (default: 1)
- Log loop prevention events
-
Layer 2: Message Source Detection
- Detect user vs agent messages
- Block agent self-questioning during execution
- Track who triggered execution (user/agent/handler)
- Show warning toast when agent loop detected
-
Layer 3: Pattern Detection
- Track execution history per session
- Detect same ability triggered multiple times (>3 in 60s)
- Detect rapid switching (A→B→A→B→A)
- Detect consecutive agent-triggered executions (>3)
- Block session for 5 minutes on loop detection
-
Layer 4: Rate Limiting
- Implement per-ability rate limits
- Max 3 executions per minute per ability
- Sliding window rate limiting
- Log rate limit violations
-
Configuration
- Add
execution.maxDepthconfig - Add
execution.rateLimitconfig - Add
loopDetection.enabledconfig - Add
loopDetection.agentMessageBlockingconfig - Add
loopDetection.patternDetectionconfig
- Add
-
CLI Commands
-
npx ability-control safety- Show safety status -
npx ability-control unblock- Unblock session -
npx ability-control history --loops- Show loop detections
-
-
Word Boundary Enforcement
- Add
\bword boundaries to patterns - Prevent substring matches (coo vs cookie)
- Smart boundary detection (don't break existing patterns)
- Add
-
Specificity Scoring
- Calculate pattern specificity (length, words, capture groups)
- Use specificity as tiebreaker for equal confidence
- Prefer longer, more specific patterns
-
Negative Patterns
- Support
excludein trigger definition - Skip matches if exclusion words present
- Add to YAML schema
- Support
-
Context-Aware Matching
- Support
requires(must contain words) - Support
boostIf(increase confidence) - Support
penalizeIf(decrease confidence) - Add to YAML schema
- Support
-
Confidence Calculation
- Boost for exact matches
- Boost for high match ratio (>70%)
- Penalize for low match ratio (<30%)
- Adjust based on context words
- Create
ProgressTrackerclass - Store progress in
.tmp/ability-control/progress/ - Update progress via toast notifications
- Support percentage-based progress
- Support step-based progress
- CLI:
npx ability-control active(show running abilities)
-
npx ability-control test <text>- Test pattern matching- Show matched abilities
- Show confidence scores
- Show extracted parameters
-
npx ability-control run <name>- Execute ability- Support
--dry-runflag - Support
--paramsflag (JSON) - Show execution trace
- Support
-
npx ability-control validate- Validate all abilities- Check YAML syntax
- Check schema validity
- Check handler files exist
- Check regex patterns compile
- Check permissions valid
- Unit tests for handler loader
- Unit tests for parameter extraction
- Unit tests for execution engine
- Unit tests for permission validation
- Integration tests (full ability execution)
- Example abilities with handlers
- Handler API reference
- Parameter extraction guide
- Permission system guide
- Testing guide
- Example handlers
Goal: Add missing features from original vision (Issue #33)
Timeline: 3 weeks
Status: Not started
-
Schema Definition
- Add
context.conditionalto YAML schema - Support
whenconditions (JavaScript expressions) - Support
filesarray (context files to load) - Support
hintsarray (conditional hints) - Support
toolsarray (conditional tools)
- Add
-
Condition Evaluator
- Parse JavaScript expressions safely
- Evaluate conditions against input values
- Support comparison operators (===, !==, >, <, >=, <=)
- Support logical operators (&&, ||, !)
- Sandbox evaluation (prevent code injection)
-
Context Loader
- Load
context.alwaysfiles first - Evaluate each conditional
- Load matching context files
- Merge conditional hints/tools
- Track loaded context size (optimization)
- Load
-
Validation
- Validate condition syntax
- Validate referenced files exist
- Check context size limits
- Warn if conditions never match
-
Example
context: always: files: [video-basics.md] conditional: - when: inputs.platform === "youtube" files: [youtube-specs.md] hints: [Optimize for YouTube algorithm]
-
Schema Definition
- Add
outputsto YAML schema - Support type definitions (string, integer, boolean, array, object)
- Support required vs optional
- Support nested objects
- Support array item types
- Add
-
Validation
- Validate handler return values against schema
- Generate TypeScript types from schema
- Show validation errors clearly
- Support custom validators
-
Type Generation
- Generate TypeScript interfaces from output schema
- Export types for handler implementations
- Type-safe handler return values
-
Example
outputs: videoPath: { type: string, required: true } duration: { type: integer, required: true } nextSteps: { type: array, items: { type: string } }
-
Schema Definition
- Add
guidanceto YAML schema - Support
on_successmessage - Support
on_failuremessage - Support template variables ({{inputs.platform}})
- Support suggested next abilities
- Add
-
Guidance Formatter
- Replace template variables with actual values
- Format guidance messages
- Inject into Claude's context after execution
- Show suggested abilities
-
Integration
- Show guidance in toast notifications
- Inject guidance into system prompt
- Track suggested abilities
- Enable chaining abilities
-
Example
guidance: on_success: | Video created! Suggested next abilities: - upload-video: Upload to {{inputs.platform}} - thumbnail-generator: Create thumbnail
-
Schema Definition
- Add agent configuration to agent markdown files
- Support
abilities.enabledarray - Support
abilities.disabledarray - Support wildcard patterns (video-*)
-
Agent Loader
- Parse agent markdown frontmatter
- Extract ability configuration
- Filter abilities per agent
- Cache agent configurations
-
Scoping
- Load only enabled abilities for current agent
- Respect disabled abilities
- Support global abilities (always enabled)
- Support agent inheritance
-
Example
# .opencode/agents/content-creator.md --- abilities: enabled: [video-creation, blog-writing] disabled: [code-generation] ---
-
Schema Definition
- Add
instructionsto YAML schema - Support multi-line markdown
- Support template variables
- Inject into system prompt
- Add
-
Formatter
- Format instructions as markdown
- Replace template variables
- Inject into Claude's system prompt
- Show in ability documentation
-
Example
instructions: | Create videos with video-creation. Use when: User asks for video content Requires: topic, duration, platform Returns: Video path, script path, next steps
- Unit tests for conditional context evaluation
- Unit tests for output schema validation
- Unit tests for guidance formatting
- Unit tests for agent scoping
- Integration tests (full features)
- Example abilities using all features
- Conditional context guide
- Output schema reference
- Multi-turn guidance guide
- Agent scoping guide
- Complete YAML schema reference
- Migration guide (from basic to advanced)
Goal: Multi-step workflows with dependencies
Timeline: 6 weeks
Status: Not started
- Define workflow YAML schema
- Support sequential steps
- Support parallel steps
- Support conditional steps
- Support step dependencies
- Validate workflow schema
- Build dependency graph
- Detect circular dependencies
- Calculate execution order
- Identify parallelizable steps
- Handle missing dependencies
- Execute steps in order
- Execute parallel steps concurrently
- Pass data between steps
- Handle step failures
- Rollback on error
- Resume from checkpoint
- Create tasks in
.tmp/tasks/ - Track workflow as task
- Track steps as subtasks
- Update task status
- Mark tasks complete
- Integration with task-management skill
- Track workflow progress
- Track step progress
- Show estimated time remaining
- Show current step
- Show completed steps
- Retry failed steps
- Skip optional steps
- Rollback on failure
- Cleanup on error
- Log errors
-
npx ability-control workflow <name>- Show workflow details -
npx ability-control workflow <name> --graph- Show dependency graph -
npx ability-control workflow <name> --validate- Validate workflow
- Unit tests for dependency resolution
- Unit tests for workflow executor
- Integration tests (full workflow)
- Example workflows
- Workflow schema reference
- Dependency resolution guide
- Error handling guide
- Example workflows
Goal: Publish and install abilities from registry
Timeline: 4 weeks
Status: Not started
- Design registry API
- Choose hosting (npm vs custom)
- Authentication (API keys)
- Rate limiting
- Search endpoint
- Publish endpoint
- Install endpoint
-
npx ability-control publish <name> - Validate ability before publish
- Bump version (patch, minor, major)
- Generate changelog
- Package ability (YAML + handlers + schemas)
- Upload to registry
- Tag git commit
-
npx ability-control install <name> - Download from registry
- Extract to
.opencode/ability-control/abilities/ - Update config.json
- Install dependencies (npm packages)
- Verify integrity (checksums)
-
npx ability-control search <query> - Search by name
- Search by description
- Search by tags
- Filter by author
- Sort by downloads/stars
- Semantic versioning
- Dependency tracking
- Breaking change detection
- Migration guides
- Deprecation warnings
- Code scanning (detect malicious code)
- Verified publishers
- Checksum validation
- Sandboxed execution
- Report malicious abilities
- Track downloads
- Track installs
- Track usage
- Popular abilities
- Trending abilities
- Unit tests for publish
- Unit tests for install
- Integration tests (full flow)
- Security tests
- Registry API reference
- Publishing guide
- Installing guide
- Security best practices
Goal: Make it easy to create, test, and debug abilities
Timeline: 3 weeks
Status: Not started
-
npx ability-control add <name>- Create new ability- Interactive prompts
- Generate YAML file
- Generate handler template
- Generate schema template
- Add to config.json
-
npx ability-control list- Show all abilities- Show enabled/disabled
- Show version
- Show source (built-in, custom, registry)
-
npx ability-control enable <name>- Enable ability -
npx ability-control disable <name>- Disable ability -
npx ability-control remove <name>- Remove ability -
npx ability-control history- Show execution history- Filter by ability
- Filter by date
- Show success/failure
- Show duration
- Enable via config:
"logging": { "level": "debug" } - Log all pattern matching attempts
- Log parameter extraction
- Log handler execution
- Log permission checks
- Log execution trace
- Create
@ability-control/testingpackage - Mock
HandlerContext - Mock OpenCode client
- Test pattern matching
- Test handler execution
- Test workflows
- Example test suite
- Generate README from YAML
- Generate API docs from handlers
- Generate examples from tests
- Generate changelog from git
-
npx ability-control migrate <name> --to <version> - Detect breaking changes
- Show migration guide
- Update YAML schema
- Update handler signature
- Unit tests for CLI commands
- Integration tests (full CLI flow)
- Example abilities
- CLI reference
- Debug guide
- Testing guide
- Migration guide
Goal: Integrate with OpenCode ecosystem
Timeline: 8 weeks
Status: Not started
- Load skills via
skill: <name>in YAML - Inject skill content into Claude's prompt
- Pass skill context to handlers
- Test with task-management skill
- Execute commands via
command: /<name>in YAML - Pass command results to handlers
- Test with /commit, /clean commands
- Implement confidence threshold (0.8)
- Handle multiple matches
- Prompt user to choose
- Remember user preferences
- Group related abilities
- Install collections
- Share collections
- Example: @react/components (create, update, delete)
- Contribution guide
- Code of conduct
- Issue templates
- PR templates
- Example abilities
- Integration tests (skills, commands)
- End-to-end tests
- Performance tests
- Integration guide
- Best practices
- Community guide
- Phase 1: ✅ 100% (Complete)
- Phase 2: ⏳ 0% (Not started)
- Phase 3: ⏳ 0% (Not started)
- Phase 4: ⏳ 0% (Not started)
- Phase 5: ⏳ 0% (Not started)
- Phase 6: ⏳ 0% (Not started)
Goal: Handler execution basics
Timeline: Week 1-2
- Define HandlerContext interface
- Define HandlerResult interface
- Extract regex capture groups
- Map capture groups to params
- Dynamic import handlers
- Validate handler exports
- Execute handler with timeout
- Return results to Claude
Goal: Safety and permissions
Timeline: Week 3-4
- Permission validation
- Loop prevention
- Progress tracking
- CLI: test, run, validate
- Can execute TypeScript handlers
- Can extract parameters from regex
- Can validate permissions
- Can prevent infinite loops
- Can track progress
- CLI commands work (
test,run,validate) - Example abilities work (create-component)
- Tests pass (unit + integration)
- Documentation complete
- Can execute multi-step workflows
- Can resolve dependencies
- Can execute parallel steps
- Can rollback on error
- Can integrate with task-management
- Example workflows work
- Tests pass
- Documentation complete
- Can publish to registry
- Can install from registry
- Can search registry
- Can manage versions
- Security scanning works
- Tests pass
- Documentation complete
- No ability-to-ability calls - Prevents infinite loops
- TypeScript only - Type safety, better DX
- Zod for validation - Type-safe, great DX
- npm registry first - Easier to start, custom registry later
- Complement, don't replace - Work with skills/commands
- Should we support JavaScript handlers? (Decision: No, TypeScript only)
- Should we support Python handlers? (Decision: No, TypeScript only)
- Should we use custom workflow engine? (Decision: Start simple, evaluate later)
- Should we build custom registry? (Decision: Start with npm, add custom later)
- Complexity - Workflows can get complex, need good debugging
- Performance - Handler execution might be slow, need caching
- Security - Malicious handlers, need sandboxing
- Breaking changes - Schema changes break old abilities, need migrations
- Complexity → Debug mode, execution traces, testing framework
- Performance → Handler caching, lazy loading, parallel execution
- Security → Code scanning, sandboxing, verified publishers
- Breaking changes → Semantic versioning, migration tools, deprecation warnings
Last Updated: 2026-01-25
Next Review: After Phase 2 Sprint 1 (Week 2)