Browse Source

Merge branch 'main' into feature/oac-package-refactor

Darren Hinde 6 months ago
parent
commit
b5a71334a3

+ 2340 - 0
.opencode/context/openagents-repo/features/oac-package-refactor.md

@@ -0,0 +1,2340 @@
+<!-- Context: openagents-repo/oac-package-refactor | Priority: medium | Version: 1.0 | Updated: 2026-02-15 -->
+
+# Feature: OAC Package Refactor
+
+**Purpose**: Transform OpenAgents Control into a flexible npm package with CLI tooling for multi-IDE support and community contributions
+
+**Status**: In Development  
+**Branch**: `feature/oac-package-refactor`  
+**Priority**: CRITICAL  
+**Version Target**: 1.0.0
+
+---
+
+## Vision
+
+Transform `@nextsystems/oac` from a simple installer into a comprehensive CLI package manager that:
+- ✅ Manages agents, skills, and contexts across multiple IDEs (OpenCode, Cursor, Claude Code, Windsurf)
+- ✅ Provides flexible configuration for agent behavior and permissions
+- ✅ Supports community contributions via shadcn-like component registry
+- ✅ Handles context files from multiple locations
+- ✅ Enables version management and updates
+- ✅ Maintains backward compatibility with existing workflows
+- ✅ **CRITICAL**: User runs in project root, chooses local or global install, always confirms overwrites (unless YOLO mode)
+
+---
+
+## Core Features
+
+### 1. Multi-IDE Support
+
+**Goal**: One configuration, multiple IDEs
+
+```bash
+# Configure once
+oac configure
+
+# Install for any IDE
+oac install opencode
+oac install cursor
+oac install claude
+
+# Apply updates to all
+oac update --all
+```
+
+**Implementation**:
+- Use compatibility layer adapters for IDE-specific translation
+- Maintain single source of truth in OAC format
+- Auto-detect IDE configurations
+- Handle IDE-specific limitations gracefully
+
+---
+
+### 2. Flexible Configuration System
+
+**Goal**: User-controlled agent behavior and permissions
+
+**Configuration File**: `~/.config/oac/config.json` (global) or `.oac/config.json` (local/project)
+
+**CRITICAL BEHAVIOR**:
+- User runs `oac` commands in their project root directory
+- Always asks: "Install locally (this project) or globally?"
+- Always confirms before overwriting files (unless `--yolo` flag)
+- YOLO mode (`--yolo`): Auto-confirms all, reports changes at end
+- Default mode: Interactive approval for every file conflict
+
+```json
+{
+  "version": "1.0.0",
+  "preferences": {
+    "defaultIDE": "opencode",
+    "installLocation": "local",
+    "autoUpdate": false,
+    "updateChannel": "stable",
+    "confirmOverwrites": true,
+    "yoloMode": false
+  },
+  "ides": {
+    "opencode": {
+      "enabled": true,
+      "path": ".opencode",
+      "profile": "developer"
+    },
+    "cursor": {
+      "enabled": false,
+      "path": ".cursor",
+      "profile": "developer"
+    }
+  },
+  "agents": {
+    "behavior": {
+      "approvalGates": true,
+      "contextLoading": "lazy",
+      "delegationThreshold": 4
+    },
+    "permissions": {
+      "bash": "approve",
+      "write": "approve",
+      "edit": "approve",
+      "task": "approve"
+    }
+  },
+  "context": {
+    "locations": [
+      ".opencode/context",
+      ".claude/context",
+      "docs/context"
+    ],
+    "autoDiscover": true,
+    "cacheEnabled": true
+  }
+}
+```
+
+**Commands**:
+```bash
+oac configure                              # Interactive wizard
+oac configure set agents.permissions.bash auto
+oac configure get ides.opencode.enabled
+oac configure show
+oac configure reset
+```
+
+---
+
+### 3. User Approval & YOLO Mode (CRITICAL)
+
+**Goal**: User maintains full control over their project, with optional fast mode
+
+**Default Behavior: Interactive Approval**
+
+Every operation that modifies files asks for confirmation:
+
+```bash
+# User runs in project root
+cd ~/my-project
+oac install opencode
+
+# OAC asks:
+? Install location:
+  > Local (this project: ~/my-project/.opencode)
+    Global (~/.config/oac)
+
+# User selects "Local"
+
+# OAC shows what will be installed:
+📦 Installing OpenCode Developer Profile
+  
+  Will create/modify:
+  ✓ .opencode/agent/core/openagent.md
+  ✓ .opencode/agent/core/opencoder.md
+  ⚠ .opencode/agent/subagents/code/test-engineer.md (exists - will overwrite)
+  ✓ .opencode/context/core/standards/code-quality.md
+  ✓ .opencode/config.json
+  
+  Total: 15 files (2 new, 12 updated, 1 conflict)
+
+? Proceed with installation? (Y/n)
+
+# If conflicts exist:
+⚠ File exists: .opencode/agent/subagents/code/test-engineer.md
+  
+  Current: 245 lines, modified 2 days ago
+  New:     312 lines, version 0.8.0
+  
+? What would you like to do?
+  > Skip (keep existing)
+    Overwrite (replace with new)
+    Backup (save as .bak, install new)
+    Diff (show changes)
+    Skip all conflicts
+    Overwrite all conflicts
+```
+
+**YOLO Mode: Fast & Furious**
+
+Skip all confirmations, auto-resolve conflicts, report at end:
+
+```bash
+# Enable YOLO mode
+oac install opencode --yolo
+
+# Or set in config
+oac configure set preferences.yoloMode true
+
+# YOLO mode behavior:
+📦 Installing OpenCode Developer Profile (YOLO MODE)
+  
+  ⚡ Auto-confirming all operations...
+  ✓ Created .opencode/agent/core/openagent.md
+  ✓ Created .opencode/agent/core/opencoder.md
+  ⚠ Overwrote .opencode/agent/subagents/code/test-engineer.md (backed up to .bak)
+  ✓ Created .opencode/context/core/standards/code-quality.md
+  ✓ Created .opencode/config.json
+  
+  ✅ Installation complete!
+  
+  📊 Summary:
+  - 13 files created
+  - 2 files overwritten (backups in .opencode/.backups/)
+  - 0 files skipped
+  - Total time: 1.2s
+  
+  ⚠ Review changes: git diff
+```
+
+**Conflict Resolution Strategies**
+
+```typescript
+enum ConflictStrategy {
+  ASK = 'ask',           // Ask user for each conflict (default)
+  SKIP = 'skip',         // Skip all conflicts, keep existing
+  OVERWRITE = 'overwrite', // Overwrite all conflicts
+  BACKUP = 'backup',     // Backup existing, install new
+  YOLO = 'yolo'          // Auto-resolve (backup + overwrite)
+}
+```
+
+**Configuration**
+
+```json
+{
+  "preferences": {
+    "confirmOverwrites": true,
+    "yoloMode": false,
+    "conflictStrategy": "ask",
+    "autoBackup": true,
+    "backupLocation": ".opencode/.backups"
+  }
+}
+```
+
+**Commands with Approval Control**
+
+```bash
+# Interactive (default)
+oac install opencode
+oac update
+oac add agent:rust-specialist
+
+# YOLO mode (skip confirmations)
+oac install opencode --yolo
+oac update --yolo
+oac add agent:rust-specialist --yolo
+
+# Force overwrite (no backups)
+oac install opencode --force
+
+# Skip conflicts (keep existing)
+oac install opencode --skip-existing
+
+# Dry run (show what would happen)
+oac install opencode --dry-run
+```
+
+**Safety Features**
+
+- ✅ Always create backups before overwriting (unless `--force`)
+- ✅ Show diff before overwriting
+- ✅ Maintain backup history in `.opencode/.backups/`
+- ✅ Git integration: detect uncommitted changes, warn user
+- ✅ Rollback support: `oac rollback` to undo last operation
+- ✅ Audit log: `.oac/audit.log` tracks all operations
+
+**Example: Full Interactive Flow**
+
+```bash
+cd ~/my-awesome-project
+oac install opencode
+
+# Step 1: Location
+? Install location:
+  > Local (this project: ~/my-awesome-project/.opencode)
+    Global (~/.config/oac)
+
+# Step 2: Profile
+? Select profile:
+  > developer (Full development setup)
+    essential (Minimal setup)
+    business (Content and product focus)
+    custom (Choose components)
+
+# Step 3: Review
+📦 Installing OpenCode Developer Profile
+  
+  Will install to: ~/my-awesome-project/.opencode
+  
+  Components:
+  - 2 core agents (openagent, opencoder)
+  - 8 subagents (tester, reviewer, coder-agent, ...)
+  - 7 commands (commit, test, context, ...)
+  - 15 context files
+  
+  Total size: ~2.5 MB
+
+? Proceed? (Y/n) y
+
+# Step 4: Conflict Resolution (if any)
+⚠ 3 files already exist:
+  
+  1. .opencode/agent/subagents/code/test-engineer.md
+     Current: 245 lines, modified 2 days ago
+     New:     312 lines, version 0.8.0
+     
+? Action:
+  > Backup and overwrite
+    Skip (keep existing)
+    Show diff
+    
+# Step 5: Installation
+⚡ Installing...
+  ✓ Created .opencode/agent/core/openagent.md
+  ✓ Created .opencode/agent/core/opencoder.md
+  ⚠ Backed up .opencode/agent/subagents/code/test-engineer.md → .backups/TestEngineer.md.2026-02-14
+  ✓ Overwrote .opencode/agent/subagents/code/test-engineer.md
+  ...
+  
+# Step 6: Summary
+✅ Installation complete!
+
+📊 Summary:
+- 13 files created
+- 2 files updated
+- 3 files backed up
+- 0 files skipped
+
+📁 Installed to: ~/my-awesome-project/.opencode
+
+🔍 Next steps:
+  1. Review changes: git diff
+  2. Test setup: oac doctor
+  3. Configure: oac configure
+  
+💡 Tip: Use 'oac --yolo' to skip confirmations next time
+```
+
+---
+
+### 4. Community Component Registry (shadcn-like)
+
+**Goal**: Enable users to create and share custom agents, skills, and contexts
+
+**Registry Structure**:
+```json
+{
+  "version": "1.0.0",
+  "official": {
+    "agents": [...],
+    "skills": [...],
+    "contexts": [...]
+  },
+  "community": {
+    "agents": [
+      {
+        "id": "rust-specialist",
+        "name": "Rust Specialist",
+        "author": "community-user",
+        "source": "https://github.com/user/oac-rust-specialist",
+        "version": "1.0.0",
+        "downloads": 1234,
+        "verified": false
+      }
+    ]
+  }
+}
+```
+
+**Commands**:
+```bash
+# Add component from registry
+oac add agent:rust-specialist
+
+# Add from GitHub URL
+oac add https://github.com/user/oac-rust-specialist
+
+# Add from local path
+oac add ./my-custom-agent
+
+# List available community components
+oac browse agents
+oac browse skills
+
+# Publish your component
+oac publish ./my-agent --type agent
+
+# Search registry
+oac search "rust"
+```
+
+**Component Package Format**:
+```
+my-custom-agent/
+├── oac.json                 # Component metadata
+├── agent.md                 # Agent prompt
+├── tests/                   # Optional tests
+│   └── smoke-test.yaml
+├── context/                 # Optional context files
+│   └── rust-patterns.md
+└── README.md                # Documentation
+```
+
+**oac.json Schema**:
+```json
+{
+  "name": "rust-specialist",
+  "version": "1.0.0",
+  "type": "agent",
+  "description": "Expert in Rust programming",
+  "author": "username",
+  "license": "MIT",
+  "repository": "https://github.com/user/oac-rust-specialist",
+  "keywords": ["rust", "systems", "programming"],
+  "dependencies": {
+    "agents": [],
+    "skills": [],
+    "contexts": ["core/standards/code-quality"]
+  },
+  "files": {
+    "agent": "agent.md",
+    "tests": "tests/",
+    "context": "context/"
+  }
+}
+```
+
+---
+
+### 4. Context Resolution System (CRITICAL)
+
+**Goal**: Intelligent context resolution for agents running locally or globally
+
+**The Problem**:
+- Agents can run from **global install** (`~/.config/oac/`) or **local install** (`./opencode/`)
+- Context files exist in **project-specific** locations AND **global** locations
+- Need to resolve: "Which context file should the agent use?"
+- User preferences (global) vs project requirements (local)
+
+**The Solution: Layered Context Resolution**
+
+#### Context Layers (Priority Order)
+
+```
+1. PROJECT OVERRIDE    (./.oac/context/)           [Highest Priority]
+   ↓ User's project-specific overrides
+   
+2. PROJECT CONTEXT     (./.opencode/context/)
+   ↓ Project-specific context files
+   
+3. IDE CONTEXT         (./.cursor/context/, ./.claude/context/)
+   ↓ IDE-specific context (if different IDE)
+   
+4. PROJECT DOCS        (./docs/, ./docs/context/)
+   ↓ Project documentation
+   
+5. USER GLOBAL         (~/.config/oac/context/)
+   ↓ User's personal preferences/standards
+   
+6. OAC GLOBAL          (~/.config/oac/official/)   [Lowest Priority]
+   ↓ Official OAC context files
+```
+
+#### Resolution Algorithm
+
+```typescript
+class ContextResolver {
+  async resolve(ref: string, options: ResolveOptions): Promise<string | null> {
+    const { 
+      agentLocation,  // 'global' | 'local'
+      projectRoot,    // Current working directory
+      preferLocal     // User preference
+    } = options;
+    
+    // Build search paths based on agent location and preferences
+    const searchPaths = this.buildSearchPaths(agentLocation, projectRoot, preferLocal);
+    
+    // Search in priority order
+    for (const basePath of searchPaths) {
+      const fullPath = path.join(basePath, ref);
+      if (await fs.pathExists(fullPath)) {
+        return fullPath;
+      }
+    }
+    
+    return null; // Not found
+  }
+  
+  private buildSearchPaths(
+    agentLocation: 'global' | 'local',
+    projectRoot: string,
+    preferLocal: boolean
+  ): string[] {
+    const paths: string[] = [];
+    
+    // If agent is running locally OR user prefers local context
+    if (agentLocation === 'local' || preferLocal) {
+      // Prioritize project context
+      paths.push(
+        path.join(projectRoot, '.oac/context'),        // Project override
+        path.join(projectRoot, '.opencode/context'),   // Project context
+        path.join(projectRoot, '.cursor/context'),     // IDE context
+        path.join(projectRoot, '.claude/context'),
+        path.join(projectRoot, 'docs/context'),        // Project docs
+        path.join(projectRoot, 'docs')
+      );
+    }
+    
+    // Always include global context (fallback)
+    paths.push(
+      path.join(os.homedir(), '.config/oac/context'),     // User global
+      path.join(os.homedir(), '.config/oac/official')     // OAC official
+    );
+    
+    // If agent is running globally AND user prefers global
+    if (agentLocation === 'global' && !preferLocal) {
+      // Reverse priority: global first, then project
+      return [
+        path.join(os.homedir(), '.config/oac/context'),
+        path.join(os.homedir(), '.config/oac/official'),
+        ...paths.slice(0, -2) // Add project paths after global
+      ];
+    }
+    
+    return paths;
+  }
+}
+```
+
+#### Configuration
+
+```json
+{
+  "context": {
+    "resolution": {
+      "preferLocal": true,           // Prefer project context over global
+      "allowOverrides": true,        // Allow .oac/context/ overrides
+      "fallbackToGlobal": true,      // Fall back to global if not found locally
+      "cacheResolution": true        // Cache resolved paths
+    },
+    "locations": {
+      "project": [
+        ".oac/context",              // Project overrides (highest priority)
+        ".opencode/context",         // Project context
+        ".cursor/context",           // IDE-specific
+        ".claude/context",
+        "docs/context",              // Project docs
+        "docs"
+      ],
+      "global": [
+        "~/.config/oac/context",     // User global context
+        "~/.config/oac/official"     // OAC official context
+      ]
+    },
+    "autoDiscover": true,
+    "validation": {
+      "warnOnMissing": true,
+      "errorOnMissing": false,
+      "suggestAlternatives": true
+    }
+  }
+}
+```
+
+#### Example Scenarios
+
+**Scenario 1: Agent runs locally, context exists in project**
+
+```bash
+# User is in project directory
+cd ~/my-project
+
+# Agent runs locally
+oac install opencode --local
+
+# Agent needs: 'core/standards/code-quality.md'
+# Resolution:
+# 1. Check: ~/my-project/.oac/context/core/standards/code-quality.md ❌
+# 2. Check: ~/my-project/.opencode/context/core/standards/code-quality.md ✅
+# → Uses project-specific context
+```
+
+**Scenario 2: Agent runs globally, no project context**
+
+```bash
+# User is in project directory
+cd ~/my-project
+
+# Agent runs from global install
+oac install opencode --global
+
+# Agent needs: 'core/standards/code-quality.md'
+# Resolution:
+# 1. Check: ~/.config/oac/context/core/standards/code-quality.md ✅
+# → Uses global context
+```
+
+**Scenario 3: Project override**
+
+```bash
+# User wants custom code quality standards for this project
+mkdir -p ~/my-project/.oac/context/core/standards
+cp ~/.config/oac/official/core/standards/code-quality.md \
+   ~/my-project/.oac/context/core/standards/code-quality.md
+
+# Edit project-specific version
+vim ~/my-project/.oac/context/core/standards/code-quality.md
+
+# Agent needs: 'core/standards/code-quality.md'
+# Resolution:
+# 1. Check: ~/my-project/.oac/context/core/standards/code-quality.md ✅
+# → Uses project override (highest priority)
+```
+
+**Scenario 4: Mixed context (project + global)**
+
+```bash
+# Project has some context
+~/my-project/.opencode/context/
+  └── project/
+      └── architecture.md
+
+# Global has standard context
+~/.config/oac/official/
+  └── core/
+      └── standards/
+          └── code-quality.md
+
+# Agent needs both:
+# - 'project/architecture.md' → Found in project ✅
+# - 'core/standards/code-quality.md' → Falls back to global ✅
+```
+
+#### Context Merging (Advanced)
+
+For certain context types, we can **merge** instead of override:
+
+```typescript
+interface ContextMergeStrategy {
+  type: 'override' | 'merge' | 'append';
+  mergeKey?: string; // For merge strategy
+}
+
+// Example: Merge project and global standards
+const merged = await contextResolver.resolveWithMerge(
+  'core/standards/code-quality.md',
+  {
+    strategy: 'merge',
+    mergeKey: 'standards', // Merge 'standards' sections
+    preferLocal: true      // Local takes precedence on conflicts
+  }
+);
+
+// Result:
+// - Global standards: base rules
+// - Project standards: additional/override rules
+// - Final: combined ruleset
+```
+
+#### CLI Commands for Context Management
+
+```bash
+# Show context resolution for a reference
+oac context resolve 'core/standards/code-quality.md'
+  → Resolved to: ~/my-project/.opencode/context/core/standards/code-quality.md
+  → Source: project
+  → Fallbacks checked: 2
+
+# List all available context files
+oac context list
+  --local                       # Project context only
+  --global                      # Global context only
+  --all                         # All (default)
+  --tree                        # Show as tree
+
+# Validate context references
+oac context validate
+  → Checking 45 context references...
+  ✓ 42 resolved
+  ⚠ 3 missing (using fallbacks)
+  
+# Create project override
+oac context override 'core/standards/code-quality.md'
+  → Copied from: ~/.config/oac/official/core/standards/code-quality.md
+  → To: ~/my-project/.oac/context/core/standards/code-quality.md
+  → Edit this file to customize for your project
+
+# Show context sources
+oac context sources
+  Project Context:
+    .oac/context/              (2 files)
+    .opencode/context/         (15 files)
+    docs/                      (8 files)
+  
+  Global Context:
+    ~/.config/oac/context/     (5 files)
+    ~/.config/oac/official/    (42 files)
+  
+  Total: 72 context files
+
+# Sync global context to project
+oac context sync --to-project
+  → Copying global context to project...
+  ✓ Copied 42 files to .opencode/context/
+
+# Sync project context to global
+oac context sync --to-global
+  → Copying project context to global...
+  ⚠ This will affect all projects using global context
+  ? Proceed? (y/N)
+```
+
+#### Agent Context Loading
+
+Agents need to know where they're running from:
+
+```typescript
+// In agent prompt or configuration
+class AgentContext {
+  location: 'global' | 'local';
+  projectRoot: string | null;
+  contextResolver: ContextResolver;
+  
+  async loadContext(ref: string): Promise<string> {
+    const resolved = await this.contextResolver.resolve(ref, {
+      agentLocation: this.location,
+      projectRoot: this.projectRoot || process.cwd(),
+      preferLocal: true
+    });
+    
+    if (!resolved) {
+      throw new Error(`Context not found: ${ref}`);
+    }
+    
+    return fs.readFile(resolved, 'utf-8');
+  }
+}
+```
+
+#### Environment Variables
+
+```bash
+# Override context resolution behavior
+OAC_CONTEXT_PREFER_LOCAL=true        # Prefer project context
+OAC_CONTEXT_PREFER_GLOBAL=true       # Prefer global context
+OAC_CONTEXT_PROJECT_ROOT=/path/to/project
+OAC_CONTEXT_GLOBAL_ROOT=~/.config/oac
+OAC_CONTEXT_CACHE_ENABLED=true
+OAC_CONTEXT_VALIDATION=strict        # strict | warn | off
+```
+
+#### Visual Representation
+
+```
+Agent Running Locally (in ~/my-project):
+┌─────────────────────────────────────────┐
+│ Agent: openagent (local)                │
+│ Working Dir: ~/my-project               │
+└─────────────────────────────────────────┘
+              ↓
+    Needs: 'core/standards/code-quality.md'
+              ↓
+┌─────────────────────────────────────────┐
+│ Context Resolver                        │
+│ Mode: preferLocal = true                │
+└─────────────────────────────────────────┘
+              ↓
+    Search Priority:
+    1. ~/my-project/.oac/context/... ❌
+    2. ~/my-project/.opencode/context/... ✅ FOUND
+    3. (skip remaining)
+              ↓
+    Returns: ~/my-project/.opencode/context/core/standards/code-quality.md
+
+
+Agent Running Globally:
+┌─────────────────────────────────────────┐
+│ Agent: openagent (global)               │
+│ Working Dir: ~/my-project               │
+└─────────────────────────────────────────┘
+              ↓
+    Needs: 'core/standards/code-quality.md'
+              ↓
+┌─────────────────────────────────────────┐
+│ Context Resolver                        │
+│ Mode: preferLocal = true (default)      │
+└─────────────────────────────────────────┘
+              ↓
+    Search Priority:
+    1. ~/my-project/.oac/context/... ❌
+    2. ~/my-project/.opencode/context/... ❌
+    3. ~/.config/oac/context/... ❌
+    4. ~/.config/oac/official/... ✅ FOUND
+              ↓
+    Returns: ~/.config/oac/official/core/standards/code-quality.md
+```
+
+#### Best Practices
+
+**For Users**:
+- ✅ Use global context for personal coding standards
+- ✅ Use project context for project-specific requirements
+- ✅ Use `.oac/context/` for temporary overrides
+- ✅ Keep project context in version control
+- ✅ Keep global context private (personal preferences)
+
+**For Projects**:
+- ✅ Include essential context in `.opencode/context/`
+- ✅ Document required context files in README
+- ✅ Use `oac context validate` in CI/CD
+- ✅ Provide `.oac/context/` examples for common overrides
+
+**For OAC**:
+- ✅ Ship official context in `~/.config/oac/official/`
+- ✅ Never modify user's global context without permission
+- ✅ Warn when context is missing
+- ✅ Suggest alternatives when context not found
+
+---
+
+### 5. Version Management & Updates
+
+**Goal**: Keep agents and components up-to-date across all IDEs
+
+```bash
+# Check for updates
+oac update --check
+
+# Update all components
+oac update
+
+# Update and apply to specific IDE
+oac update --claude --global
+oac update --opencode --local
+
+# Update specific component
+oac update agent:openagent
+
+# Update from specific version
+oac update --version 0.8.0
+
+# Rollback to previous version
+oac rollback agent:openagent
+```
+
+**Update Flow**:
+1. Fetch latest registry from GitHub
+2. Compare with local cache
+3. Show available updates
+4. Download updated components
+5. Apply to configured IDEs
+6. Validate installation
+
+---
+
+### 5. Agent Customization & Personal Presets (CRITICAL)
+
+**Goal**: Allow users to view, customize, and save personal agent configurations
+
+**The Problem**:
+- Users want to customize agent prompts for their workflow
+- Users want to save personal presets
+- Updates shouldn't overwrite customizations
+- Need easy way to view and edit agent configs
+
+**The Solution: Multi-Layer Customization System**
+
+#### Layer 1: View Agent Configuration
+
+```bash
+# View agent prompt and config
+oac show agent:openagent
+  → Opens agent file in pager (less/bat)
+  → Shows: prompt, config, metadata
+
+# View in editor
+oac edit agent:openagent
+  → Opens in $EDITOR (vim/vscode/etc.)
+  → Read-only by default (shows warning)
+
+# View config only
+oac config show agent:openagent
+  → Shows just the configuration (YAML frontmatter)
+
+# Export agent
+oac export agent:openagent --output ./my-openagent.md
+  → Exports to file for inspection
+```
+
+#### Layer 2: Create Personal Preset
+
+```bash
+# Create personal preset (copy to user space)
+oac customize agent:openagent
+
+? What would you like to customize?
+  > Create personal preset (recommended)
+    Edit in place (advanced)
+    Fork to new agent
+
+? Preset name: my-openagent
+? Description: My customized OpenAgent with stricter approval gates
+
+✓ Created preset: ~/.config/oac/presets/agents/my-openagent.md
+✓ Linked to: agent:openagent (base)
+
+📝 Edit your preset:
+  oac edit preset:my-openagent
+
+💡 Use your preset:
+  oac use preset:my-openagent
+```
+
+**Preset Structure**:
+```
+~/.config/oac/
+├── presets/
+│   ├── agents/
+│   │   ├── my-openagent.md          # User's custom version
+│   │   ├── my-opencoder.md
+│   │   └── strict-reviewer.md
+│   ├── skills/
+│   │   └── my-git-workflow.md
+│   └── .presets.json                # Preset metadata
+```
+
+**Preset Metadata** (`.presets.json`):
+```json
+{
+  "presets": {
+    "my-openagent": {
+      "type": "agent",
+      "base": "agent:openagent",
+      "baseVersion": "0.7.1",
+      "created": "2026-02-14T10:30:00Z",
+      "modified": "2026-02-14T15:45:00Z",
+      "customizations": [
+        "Modified approval gates",
+        "Added custom context paths",
+        "Changed delegation threshold"
+      ],
+      "autoUpdate": false,
+      "updateStrategy": "manual"
+    }
+  }
+}
+```
+
+#### Layer 3: Edit Personal Preset
+
+```bash
+# Edit preset in default editor
+oac edit preset:my-openagent
+  → Opens ~/.config/oac/presets/agents/my-openagent.md in $EDITOR
+
+# Edit with specific editor
+oac edit preset:my-openagent --editor code
+  → Opens in VS Code
+
+# Interactive customization wizard
+oac customize preset:my-openagent --interactive
+
+? What would you like to customize?
+  ✓ Approval gates behavior
+  ✓ Context loading strategy
+  ☐ Delegation threshold
+  ☐ Tool permissions
+
+? Approval gates:
+  > Always ask (current)
+    Auto-approve reads
+    YOLO mode by default
+
+? Context loading:
+  > Lazy (current)
+    Eager (load all upfront)
+    Manual (user specifies)
+
+✓ Updated preset: my-openagent
+✓ Changes saved to ~/.config/oac/presets/agents/my-openagent.md
+```
+
+#### Layer 4: Use Personal Preset
+
+```bash
+# Use preset instead of base agent
+oac use preset:my-openagent
+  → Activates preset in current project
+
+# Use preset globally
+oac use preset:my-openagent --global
+  → Sets as default for all projects
+
+# Use preset for specific IDE
+oac use preset:my-openagent --ide opencode
+  → Applies to OpenCode only
+
+# List active presets
+oac presets list --active
+  opencode: preset:my-openagent
+  cursor: agent:openagent (base)
+  claude: preset:strict-reviewer
+
+# Switch back to base
+oac use agent:openagent
+  → Deactivates preset, uses base agent
+```
+
+#### Layer 5: Update Management (CRITICAL)
+
+**Problem**: Updates shouldn't overwrite user customizations
+
+**Solution**: Smart update strategy with user control
+
+```bash
+# Check for updates to base agent
+oac update --check
+
+📦 Updates Available:
+
+agent:openagent (base for preset:my-openagent)
+  Current: 0.7.1
+  Latest:  0.8.0
+  
+  Changes:
+  - Added new context loading patterns
+  - Improved delegation logic
+  - Fixed approval gate bug
+  
+  ⚠️ You have a personal preset based on this agent
+  
+? How would you like to update?
+  > Review changes first (recommended)
+    Update base, keep my customizations
+    Update base, merge my customizations
+    Skip this update
+    Auto-update base (don't ask again)
+
+# Review changes before updating
+oac diff agent:openagent 0.7.1 0.8.0
+  → Shows diff between versions
+
+# Update with merge strategy
+oac update agent:openagent --merge-preset my-openagent
+
+⚡ Updating agent:openagent (0.7.1 → 0.8.0)
+
+📝 Merging with preset:my-openagent...
+
+✓ Base agent updated
+⚠️ Conflicts detected in preset:
+
+  Section: Approval Gates
+  Base (new):    "Always ask before execution"
+  Your preset:   "Auto-approve read operations"
+  
+? Keep your customization? (Y/n) y
+
+✓ Preset updated with merge
+✓ Backup saved: ~/.config/oac/presets/.backups/my-openagent.2026-02-14.md
+
+📊 Summary:
+  - Base agent: Updated to 0.8.0
+  - Your preset: Merged (3 conflicts resolved)
+  - Customizations: Preserved
+```
+
+**Update Strategies**:
+```typescript
+enum PresetUpdateStrategy {
+  MANUAL = 'manual',           // User reviews every update
+  AUTO_BASE = 'auto-base',     // Auto-update base, keep preset unchanged
+  AUTO_MERGE = 'auto-merge',   // Auto-merge, prompt on conflicts
+  LOCKED = 'locked'            // Never update base
+}
+```
+
+**Configuration**:
+```json
+{
+  "presets": {
+    "my-openagent": {
+      "updateStrategy": "manual",
+      "autoUpdate": false,
+      "mergeStrategy": {
+        "onConflict": "ask",     // ask | keep-mine | keep-theirs
+        "backupOnMerge": true,
+        "maxBackups": 10
+      }
+    }
+  }
+}
+```
+
+#### Layer 6: Preset Sharing
+
+```bash
+# Export preset for sharing
+oac export preset:my-openagent --output ./my-openagent-preset.md
+  → Exports with metadata
+
+# Share preset with team
+oac share preset:my-openagent
+  → Generates shareable link or file
+
+# Import preset from teammate
+oac import preset ./teammate-preset.md
+  → Imports as new preset
+
+# Publish preset to community
+oac publish preset:my-openagent --public
+  → Publishes to community registry (optional)
+```
+
+#### Layer 7: In-Place Editing (Advanced)
+
+**Warning**: Editing installed agents directly is risky
+
+```bash
+# Edit installed agent (not recommended)
+oac edit agent:openagent --in-place
+
+⚠️  WARNING: Editing installed agent directly
+  
+  This will modify the installed agent file.
+  Updates will overwrite your changes.
+  
+  Recommended: Create a preset instead
+    oac customize agent:openagent
+  
+? Are you sure you want to edit in-place? (y/N) n
+
+# Force in-place edit (advanced users)
+oac edit agent:openagent --in-place --force
+
+⚠️  Editing: .opencode/agent/core/openagent.md
+⚠️  Changes will be overwritten on update
+⚠️  Creating backup: (example: .opencode/.backups/openagent.md.2026-02-14)
+
+[Opens in editor]
+
+✓ Saved changes
+⚠️ Remember: Updates will overwrite this file
+💡 Tip: Create a preset to preserve customizations
+```
+
+#### CLI Commands Summary
+
+```bash
+# View
+oac show agent:openagent              # View agent
+oac config show agent:openagent       # View config only
+oac export agent:openagent            # Export to file
+
+# Customize
+oac customize agent:openagent         # Create preset (wizard)
+oac edit preset:my-openagent          # Edit preset
+oac customize preset:my-openagent --interactive  # Interactive wizard
+
+# Use
+oac use preset:my-openagent           # Activate preset
+oac use preset:my-openagent --global  # Set as default
+oac presets list                      # List presets
+oac presets list --active             # Show active presets
+
+# Update
+oac update --check                    # Check for updates
+oac diff agent:openagent 0.7.1 0.8.0  # Show changes
+oac update agent:openagent --merge-preset my-openagent
+
+# Share
+oac export preset:my-openagent        # Export preset
+oac import preset ./preset.md         # Import preset
+oac share preset:my-openagent         # Share with team
+oac publish preset:my-openagent       # Publish to community
+
+# Advanced
+oac edit agent:openagent --in-place   # Edit installed agent (risky)
+oac fork agent:openagent my-agent     # Fork to new agent
+```
+
+#### Configuration Schema
+
+```json
+{
+  "presets": {
+    "enabled": true,
+    "location": "~/.config/oac/presets",
+    "defaultUpdateStrategy": "manual",
+    "backupOnEdit": true,
+    "maxBackups": 10,
+    "warnOnInPlaceEdit": true
+  },
+  "customization": {
+    "allowInPlaceEdit": true,
+    "requireConfirmation": true,
+    "autoBackup": true,
+    "showDiffOnUpdate": true
+  }
+}
+```
+
+#### Preset File Format
+
+```markdown
+---
+# Preset Metadata
+preset:
+  name: my-openagent
+  base: agent:openagent
+  baseVersion: 0.7.1
+  type: agent
+  created: 2026-02-14T10:30:00Z
+  modified: 2026-02-14T15:45:00Z
+  
+# Customizations
+customizations:
+  - section: "Approval Gates"
+    description: "Auto-approve read operations"
+  - section: "Context Loading"
+    description: "Changed to eager loading"
+  
+# Update Strategy
+update:
+  strategy: manual
+  autoUpdate: false
+  mergeStrategy: ask
+---
+
+# My Custom OpenAgent
+
+[Your customized agent prompt here]
+
+<!-- CUSTOMIZATION: Approval Gates -->
+**Modified Behavior**: Auto-approve read operations (glob, read, grep)
+<!-- END CUSTOMIZATION -->
+
+[Rest of agent prompt...]
+```
+
+#### Visual Workflow
+
+```
+User wants to customize agent:openagent
+              ↓
+    oac customize agent:openagent
+              ↓
+    ┌─────────────────────────────┐
+    │ Create Personal Preset      │
+    │                             │
+    │ Name: my-openagent          │
+    │ Base: agent:openagent       │
+    │ Location: ~/.config/oac/    │
+    └─────────────────────────────┘
+              ↓
+    Copy base agent to preset location
+              ↓
+    ┌─────────────────────────────┐
+    │ Edit Preset                 │
+    │                             │
+    │ oac edit preset:my-openagent│
+    │ [Opens in $EDITOR]          │
+    └─────────────────────────────┘
+              ↓
+    User makes changes, saves
+              ↓
+    ┌─────────────────────────────┐
+    │ Activate Preset             │
+    │                             │
+    │ oac use preset:my-openagent │
+    └─────────────────────────────┘
+              ↓
+    Preset is now active
+              ↓
+    Base agent updates (0.7.1 → 0.8.0)
+              ↓
+    ┌─────────────────────────────┐
+    │ Update Check                │
+    │                             │
+    │ ⚠️ Preset based on updated  │
+    │    agent                    │
+    │                             │
+    │ ? How to update?            │
+    │   > Review changes          │
+    │     Merge                   │
+    │     Skip                    │
+    └─────────────────────────────┘
+              ↓
+    User reviews diff
+              ↓
+    ┌─────────────────────────────┐
+    │ Merge Strategy              │
+    │                             │
+    │ Conflicts:                  │
+    │ - Approval gates (yours)    │
+    │ - Context loading (theirs)  │
+    │                             │
+    │ ? Keep your changes? Y/n    │
+    └─────────────────────────────┘
+              ↓
+    Preset updated with merge
+    Backup created
+    Customizations preserved
+```
+
+#### Best Practices
+
+**For Users**:
+- ✅ Always create presets instead of editing in-place
+- ✅ Use descriptive preset names
+- ✅ Document your customizations in preset metadata
+- ✅ Review updates before merging
+- ✅ Keep backups of important presets
+
+**For OAC**:
+- ✅ Default to preset creation (safest)
+- ✅ Warn loudly on in-place edits
+- ✅ Always create backups before updates
+- ✅ Show clear diffs before merging
+- ✅ Preserve user customizations by default
+- ✅ Make it easy to revert to base agent
+
+#### Edge Cases Handled
+
+1. **User edits in-place, then update arrives**
+   - Detect local modifications
+   - Warn user
+   - Offer to create preset from modifications
+   - Backup before overwriting
+
+2. **Preset based on old version, multiple updates behind**
+   - Show all changes since preset creation
+   - Offer step-by-step merge or bulk merge
+   - Highlight breaking changes
+
+3. **User has multiple presets for same base agent**
+   - Allow multiple presets
+   - Each preset tracks its own base version
+   - Update each independently
+
+4. **Preset conflicts with IDE limitations**
+   - Warn if preset won't work with IDE
+   - Suggest compatible alternatives
+   - Auto-adapt if possible
+
+5. **User deletes base agent but has preset**
+   - Preset becomes standalone
+   - Warn that updates won't work
+   - Offer to reinstall base
+
+---
+
+### 6. IDE Feature Parity & Capacity Management (CRITICAL)
+
+**Goal**: Support different feature sets per IDE based on their capabilities
+
+**The Problem**:
+- Different IDEs support different features
+- OpenCode and Claude Code: Full feature support (agents, skills, context, plugins, tools)
+- Cursor: Limited (single .cursorrules file, no skills/plugins)
+- Windsurf: Partial support
+- Need to gracefully handle unsupported features
+
+**Feature Support Matrix**:
+
+```typescript
+interface IDECapabilities {
+  id: string;
+  name: string;
+  features: {
+    multipleAgents: boolean;
+    skills: boolean;
+    plugins: boolean;
+    tools: boolean;
+    contexts: boolean;
+    commands: boolean;
+    granularPermissions: boolean;
+    hooks: boolean;
+  };
+  limits?: {
+    maxAgents?: number;
+    maxFileSize?: number;
+    maxContextFiles?: number;
+  };
+}
+
+const IDE_CAPABILITIES: Record<string, IDECapabilities> = {
+  opencode: {
+    id: 'opencode',
+    name: 'OpenCode',
+    features: {
+      multipleAgents: true,
+      skills: true,
+      plugins: true,
+      tools: true,
+      contexts: true,
+      commands: true,
+      granularPermissions: true,
+      hooks: true
+    }
+    // No limits - full support
+  },
+  
+  claude: {
+    id: 'claude',
+    name: 'Claude Code',
+    features: {
+      multipleAgents: true,
+      skills: true,
+      plugins: true,
+      tools: true,
+      contexts: true,
+      commands: false,
+      granularPermissions: false,
+      hooks: true
+    }
+    // Full support except commands and granular permissions
+  },
+  
+  cursor: {
+    id: 'cursor',
+    name: 'Cursor IDE',
+    features: {
+      multipleAgents: false,  // Single .cursorrules file
+      skills: false,
+      plugins: false,
+      tools: false,
+      contexts: true,         // Embedded in .cursorrules
+      commands: false,
+      granularPermissions: false,
+      hooks: false
+    },
+    limits: {
+      maxAgents: 1,           // Merge all agents into one
+      maxFileSize: 100000     // ~100KB limit for .cursorrules
+    }
+  },
+  
+  windsurf: {
+    id: 'windsurf',
+    name: 'Windsurf',
+    features: {
+      multipleAgents: true,
+      skills: false,
+      plugins: false,
+      tools: false,
+      contexts: true,
+      commands: false,
+      granularPermissions: false,
+      hooks: false
+    },
+    limits: {
+      maxAgents: 10
+    }
+  }
+};
+```
+
+**Feature Detection & Warnings**:
+
+```bash
+# User tries to install skill for Cursor
+oac install cursor --profile developer
+
+⚠ Feature Compatibility Warning:
+  
+  IDE: Cursor
+  Profile: developer
+  
+  Unsupported features in this profile:
+  ❌ Skills (8 skills will be skipped)
+  ❌ Plugins (2 plugins will be skipped)
+  ❌ Commands (7 commands will be skipped)
+  ⚠ Multiple agents (2 agents will be merged into .cursorrules)
+  
+  Supported features:
+  ✓ Agents (will merge into single .cursorrules)
+  ✓ Contexts (will embed in .cursorrules)
+  
+? How would you like to proceed?
+  > Continue with supported features only
+    Cancel installation
+    Show detailed compatibility report
+    Create custom profile for Cursor
+
+# Detailed compatibility report
+oac compatibility cursor --profile developer
+
+IDE Compatibility Report: Cursor
+Profile: developer
+
+┌─────────────────────┬──────────┬────────────────────────┐
+│ Feature             │ Status   │ Action                 │
+├─────────────────────┼──────────┼────────────────────────┤
+│ Agents (2)          │ ⚠ Merge  │ Combine into .cursorrules │
+│ Subagents (8)       │ ⚠ Merge  │ Combine into .cursorrules │
+│ Skills (8)          │ ❌ Skip   │ Not supported          │
+│ Plugins (2)         │ ❌ Skip   │ Not supported          │
+│ Commands (7)        │ ❌ Skip   │ Not supported          │
+│ Contexts (15)       │ ✓ Embed  │ Embed in .cursorrules  │
+│ Tools (3)           │ ❌ Skip   │ Not supported          │
+└─────────────────────┴──────────┴────────────────────────┘
+
+Estimated .cursorrules size: 45KB (within 100KB limit)
+
+Recommendations:
+• Use OpenCode or Claude Code for full feature support
+• Create Cursor-specific profile with essential agents only
+• Consider using oac create profile --for cursor
+```
+
+**Adaptive Installation**:
+
+```typescript
+class AdaptiveInstaller {
+  async install(ide: string, profile: string, options: InstallOptions) {
+    const capabilities = IDE_CAPABILITIES[ide];
+    const components = await this.loadProfile(profile);
+    
+    // Filter components based on IDE capabilities
+    const supported = this.filterByCapabilities(components, capabilities);
+    const unsupported = components.filter(c => !supported.includes(c));
+    
+    // Warn user about unsupported features
+    if (unsupported.length > 0 && !options.yolo) {
+      const proceed = await this.warnUnsupportedFeatures(
+        ide,
+        supported,
+        unsupported,
+        capabilities
+      );
+      
+      if (!proceed) {
+        return { cancelled: true };
+      }
+    }
+    
+    // Apply transformations for IDE-specific limitations
+    const transformed = await this.transformForIDE(supported, capabilities);
+    
+    // Install
+    return this.installComponents(transformed, ide, options);
+  }
+  
+  private filterByCapabilities(
+    components: Component[],
+    capabilities: IDECapabilities
+  ): Component[] {
+    return components.filter(component => {
+      switch (component.type) {
+        case 'agent':
+        case 'subagent':
+          return capabilities.features.multipleAgents || 
+                 components.filter(c => c.type === 'agent').length === 1;
+        case 'skill':
+          return capabilities.features.skills;
+        case 'plugin':
+          return capabilities.features.plugins;
+        case 'tool':
+          return capabilities.features.tools;
+        case 'context':
+          return capabilities.features.contexts;
+        case 'command':
+          return capabilities.features.commands;
+        default:
+          return false;
+      }
+    });
+  }
+  
+  private async transformForIDE(
+    components: Component[],
+    capabilities: IDECapabilities
+  ): Promise<Component[]> {
+    // Special handling for Cursor: merge all agents
+    if (capabilities.id === 'cursor') {
+      const agents = components.filter(c => c.type === 'agent' || c.type === 'subagent');
+      const contexts = components.filter(c => c.type === 'context');
+      
+      // Merge agents into single .cursorrules
+      const merged = await this.mergeAgentsForCursor(agents, contexts);
+      
+      return [merged];
+    }
+    
+    return components;
+  }
+}
+```
+
+**IDE-Specific Profiles**:
+
+```bash
+# Create profile optimized for specific IDE
+oac create profile --for cursor --name cursor-essentials
+
+? Select components for Cursor profile:
+  Agents (select up to 3 - will be merged):
+  ✓ openagent
+  ✓ opencoder
+  ✓ frontend-specialist
+  
+  Contexts (will be embedded):
+  ✓ core/standards/code-quality
+  ✓ development/react-patterns
+  
+  ⚠ Skills, plugins, and commands are not supported by Cursor
+
+✓ Created profile: cursor-essentials
+✓ Estimated .cursorrules size: 32KB
+✓ Compatible with Cursor IDE
+
+# List IDE-specific profiles
+oac profiles --for cursor
+  cursor-essentials
+  cursor-minimal
+  cursor-frontend
+
+# Install IDE-specific profile
+oac install cursor --profile cursor-essentials
+```
+
+**Component Creation with IDE Support**:
+
+```bash
+# Create component with IDE compatibility info
+oac create agent rust-specialist
+
+? Which IDEs should support this agent?
+  ✓ OpenCode (full support)
+  ✓ Claude Code (full support)
+  ✓ Cursor (will be merged with other agents)
+  ✓ Windsurf (full support)
+
+? Agent size optimization:
+  > Standard (no optimization)
+    Compact (optimize for Cursor's file size limit)
+    Minimal (essential instructions only)
+
+✓ Created agent with multi-IDE support
+✓ Estimated sizes:
+  - OpenCode: 15KB (standalone)
+  - Claude Code: 15KB (standalone)
+  - Cursor: +15KB (merged into .cursorrules)
+  - Windsurf: 15KB (standalone)
+```
+
+**Capacity Warnings**:
+
+```bash
+# Installing too many components for Cursor
+oac install cursor --profile developer
+
+⚠ Capacity Warning:
+  
+  IDE: Cursor
+  Limit: 100KB for .cursorrules
+  
+  Current profile size: 125KB
+  ❌ Exceeds limit by 25KB
+  
+? How would you like to proceed:
+  > Remove optional components (interactive)
+    Use compact mode (reduce file sizes)
+    Create custom profile
+    Cancel installation
+
+# Interactive component selection
+? Select components to include (max 100KB):
+  
+  Core (required):
+  ✓ openagent (12KB)
+  ✓ opencoder (15KB)
+  
+  Specialists (optional):
+  ✓ frontend-specialist (18KB)
+  ✓ devops-specialist (16KB)
+  ☐ data-analyst (14KB)
+  ☐ copywriter (12KB)
+  
+  Contexts:
+  ✓ core/standards (8KB)
+  ✓ development/patterns (12KB)
+  
+  Current: 81KB / 100KB
+  Remaining: 19KB
+```
+
+**CLI Commands for IDE Management**:
+
+```bash
+# Check IDE compatibility
+oac compatibility <ide>
+  --profile <profile>           # Check profile compatibility
+  --component <component>       # Check component compatibility
+
+# List supported IDEs
+oac ides
+  --features                    # Show feature matrix
+  --limits                      # Show capacity limits
+
+# Show IDE capabilities
+oac ide info <ide>
+  → Shows full feature support matrix
+
+# Optimize for IDE
+oac optimize --for <ide>
+  → Optimizes current installation for IDE
+  → Removes unsupported features
+  → Compacts files if needed
+
+# Validate IDE installation
+oac validate --ide <ide>
+  → Checks if installation is valid for IDE
+  → Warns about unsupported features
+  → Checks capacity limits
+```
+
+**Configuration**:
+
+```json
+{
+  "ides": {
+    "opencode": {
+      "enabled": true,
+      "path": ".opencode",
+      "profile": "developer",
+      "features": "all"
+    },
+    "cursor": {
+      "enabled": true,
+      "path": ".cursor",
+      "profile": "cursor-essentials",
+      "features": "auto-detect",
+      "optimization": {
+        "mergeAgents": true,
+        "embedContexts": true,
+        "compactMode": true,
+        "maxFileSize": 100000
+      }
+    },
+    "claude": {
+      "enabled": true,
+      "path": ".claude",
+      "profile": "developer",
+      "features": "all"
+    }
+  },
+  "compatibility": {
+    "warnUnsupported": true,
+    "autoOptimize": false,
+    "strictMode": false
+  }
+}
+```
+
+**Best Practices**:
+
+**For Full Features** (OpenCode, Claude Code):
+- ✅ Use standard profiles (developer, business, etc.)
+- ✅ Install all component types
+- ✅ No optimization needed
+
+**For Limited IDEs** (Cursor):
+- ✅ Create IDE-specific profiles
+- ✅ Keep agent count low (1-3 agents)
+- ✅ Use compact mode
+- ✅ Embed contexts instead of separate files
+- ✅ Monitor file size limits
+
+**For All IDEs**:
+- ✅ Check compatibility before installing: `oac compatibility <ide>`
+- ✅ Use `--dry-run` to preview changes
+- ✅ Create custom profiles for specific needs
+- ✅ Validate after installation: `oac validate --ide <ide>`
+
+---
+
+## CLI Commands Reference
+
+**CRITICAL**: All commands run in project root directory. User chooses local (project) or global install.
+
+### Installation & Setup
+
+```bash
+# Initialize OAC in current directory (interactive)
+oac init [profile]
+  --local                       # Force local install (./opencode)
+  --global                      # Force global install (~/.config/oac)
+  --yolo                        # Skip all confirmations
+  --dry-run                     # Show what would happen
+
+# Install for specific IDE (asks local/global)
+oac install [ide]
+  --local                       # Install to current directory
+  --global                      # Install to global config
+  --profile <name>              # Use specific profile
+  --yolo                        # Auto-confirm all
+  --skip-existing               # Skip conflicts, keep existing
+  --force                       # Overwrite all, no backups
+  --dry-run                     # Preview changes
+
+# Configure OAC settings
+oac configure
+  set <key> <value>             # Set config value
+  get <key>                     # Get config value
+  show                          # Show all config
+  reset                         # Reset to defaults
+```
+
+### Component Management
+
+```bash
+# Add component from registry (asks local/global)
+oac add <component>
+  --local                       # Add to current project
+  --global                      # Add to global config
+  --yolo                        # Auto-confirm
+  --dry-run                     # Preview
+
+# Remove component
+oac remove <component>
+  --local                       # Remove from current project
+  --global                      # Remove from global
+  --yolo                        # Auto-confirm
+
+# List installed components
+oac list [--type]
+  --local                       # List local components
+  --global                      # List global components
+  --agents                      # List agents only
+  --skills                      # List skills only
+  --contexts                    # List contexts only
+
+# Search registry
+oac search <query>
+  --type <type>                 # Filter by type
+  --verified                    # Verified only
+
+# Browse available components
+oac browse [type]
+  --verified                    # Verified only
+  --community                   # Community only
+```
+
+### Updates & Sync
+
+```bash
+# Update components (asks which to update)
+oac update [options]
+  --check                       # Check for updates only
+  --all                         # Update all components
+  --local                       # Update local install
+  --global                      # Update global install
+  --claude                      # Apply to Claude Code
+  --opencode                    # Apply to OpenCode
+  --yolo                        # Auto-confirm all
+  --dry-run                     # Preview updates
+
+# Apply config to IDE (asks for confirmation)
+oac apply [ide]
+  --all                         # Apply to all configured IDEs
+  --yolo                        # Auto-confirm
+  --force                       # Overwrite all
+  --dry-run                     # Preview
+
+# Sync across all IDEs
+oac sync
+  --yolo                        # Auto-confirm
+  --dry-run                     # Preview
+```
+
+### Creation & Scaffolding (Interactive)
+
+```bash
+# Interactive component creation wizard
+oac create
+  ? What would you like to create?
+    > Agent
+      Skill
+      Context
+      Plugin
+      Command
+      Tool
+  
+  ? Component type:
+    > agent
+      subagent
+  
+  ? Name: rust-specialist
+  ? Description: Expert in Rust programming
+  ? Category: development
+  
+  ✓ Created .opencode/agent/subagents/development/rust-specialist.md
+  ✓ Created tests/smoke-test.yaml
+  ✓ Added to registry
+  
+  Next steps:
+  1. Edit agent prompt
+  2. Add tests
+  3. Test: oac test agent:rust-specialist
+
+# Create specific component types
+oac create agent [name]
+  --category <category>         # Agent category
+  --template <template>         # Use template
+  --with-tests                  # Include test scaffold
+  --interactive                 # Interactive wizard (default)
+
+oac create skill [name]
+  --trigger <pattern>           # Skill trigger pattern
+  --template <template>
+
+oac create context [name]
+  --category <category>
+  --template <template>
+
+oac create plugin [name]
+  --type <type>                 # Plugin type
+
+# List available templates
+oac templates
+  --type <type>                 # Filter by type
+  
+# Use template
+oac create agent --template specialist
+  → Uses specialist agent template
+```
+
+### Publishing (Community)
+
+```bash
+# Publish component to registry
+oac publish <path>
+  --type <type>                 # Component type
+  --dry-run                     # Validate only
+
+# Remove from registry
+oac unpublish <component>
+
+# Validate component package
+oac validate <path>
+```
+
+### Utilities
+
+```bash
+# Check installation health
+oac doctor
+  --local                       # Check local install
+  --global                      # Check global install
+  --fix                         # Auto-fix issues (asks confirmation)
+
+# Clean cache and temp files
+oac clean
+  --cache                       # Clean cache only
+  --backups                     # Clean backups only
+  --all                         # Clean everything
+  --yolo                        # Auto-confirm
+
+# Rollback last operation
+oac rollback
+  --steps <n>                   # Rollback n operations
+  --to <timestamp>              # Rollback to timestamp
+
+# Show version info
+oac version
+  --check                       # Check for updates
+
+# Show help
+oac help [command]
+```
+
+### Global Flags (All Commands)
+
+```bash
+--yolo                          # Skip all confirmations, auto-resolve conflicts
+--dry-run                       # Show what would happen, don't execute
+--verbose                       # Show detailed output
+--quiet                         # Minimal output
+--no-color                      # Disable colors
+--json                          # Output as JSON
+```
+
+---
+
+## Architecture
+
+### Directory Structure
+
+```
+@nextsystems/oac/
+├── bin/
+│   └── oac.js                  # CLI entry point
+├── src/
+│   ├── cli/
+│   │   ├── commands/           # CLI command implementations
+│   │   │   ├── init.ts
+│   │   │   ├── install.ts
+│   │   │   ├── configure.ts
+│   │   │   ├── add.ts
+│   │   │   ├── update.ts
+│   │   │   ├── apply.ts
+│   │   │   ├── publish.ts
+│   │   │   └── ...
+│   │   ├── config/
+│   │   │   ├── manager.ts      # Configuration management
+│   │   │   ├── schema.ts       # Zod schemas
+│   │   │   └── defaults.ts     # Default configs
+│   │   └── index.ts            # CLI orchestrator
+│   ├── core/
+│   │   ├── registry/
+│   │   │   ├── loader.ts       # Load registry
+│   │   │   ├── resolver.ts     # Resolve dependencies
+│   │   │   ├── validator.ts    # Validate registry
+│   │   │   └── publisher.ts    # Publish components
+│   │   ├── installer/
+│   │   │   ├── component.ts    # Install components
+│   │   │   ├── profile.ts      # Install profiles
+│   │   │   └── ide.ts          # IDE-specific setup
+│   │   ├── updater/
+│   │   │   ├── version.ts      # Version checking
+│   │   │   ├── fetcher.ts      # Fetch updates
+│   │   │   └── applier.ts      # Apply updates
+│   │   └── context/
+│   │       ├── locator.ts      # Find context files
+│   │       ├── resolver.ts     # Resolve paths
+│   │       └── validator.ts    # Validate refs
+│   ├── adapters/
+│   │   ├── base.ts             # Base adapter
+│   │   ├── opencode.ts         # OpenCode adapter
+│   │   ├── cursor.ts           # Cursor adapter
+│   │   ├── claude.ts           # Claude Code adapter
+│   │   └── windsurf.ts         # Windsurf adapter
+│   ├── types/
+│   │   ├── registry.ts         # Registry types
+│   │   ├── config.ts           # Config types
+│   │   └── component.ts        # Component types
+│   └── utils/
+│       ├── logger.ts           # Logging
+│       ├── spinner.ts          # Progress indicators
+│       └── prompts.ts          # Interactive prompts
+├── config/
+│   ├── oac.config.json         # Default config
+│   └── ide-mappings.json       # IDE mappings
+├── .opencode/                  # Existing structure
+├── registry.json               # Official registry
+├── community-registry.json     # Community registry
+└── package.json
+```
+
+---
+
+## Technical Stack
+
+### Dependencies
+
+```json
+{
+  "dependencies": {
+    "commander": "^12.0.0",      // CLI framework
+    "inquirer": "^9.2.0",        // Interactive prompts
+    "zod": "^3.22.0",            // Schema validation
+    "chalk": "^5.3.0",           // Terminal colors
+    "ora": "^8.0.0",             // Spinners
+    "boxen": "^7.1.0",           // Boxes
+    "table": "^6.8.0",           // Tables
+    "fs-extra": "^11.2.0",       // File system
+    "glob": "^10.3.0",           // Pattern matching
+    "semver": "^7.6.0",          // Version comparison
+    "node-fetch": "^3.3.0",      // HTTP requests
+    "yaml": "^2.3.0",            // YAML parsing
+    "tar": "^6.2.0",             // Package extraction
+    "simple-git": "^3.22.0"      // Git operations
+  }
+}
+```
+
+---
+
+## Implementation Phases
+
+### Phase 1: Core CLI Infrastructure (Week 1)
+**Goal**: Set up CLI framework and configuration system
+
+**Tasks**:
+- Set up TypeScript project in `src/`
+- Install dependencies (Commander, Zod, inquirer)
+- Create configuration schema and manager
+- Implement basic commands (init, configure, list)
+- Write tests
+
+**Deliverables**:
+- `src/cli/index.ts`
+- `src/cli/config/manager.ts`
+- `src/cli/config/schema.ts`
+- `oac configure` works
+- `oac list` works
+
+---
+
+### Phase 2: Registry & Component Management (Week 2)
+**Goal**: Component installation and management
+
+**Tasks**:
+- Port registry validation to TypeScript
+- Implement registry loader and resolver
+- Create component installer
+- Implement profile installer
+- Add dependency resolution
+
+**Deliverables**:
+- `src/core/registry/loader.ts`
+- `src/core/installer/component.ts`
+- `oac install opencode --profile developer` works
+
+---
+
+### Phase 3: IDE Adapters Integration (Week 3)
+**Goal**: Multi-IDE support
+
+**Tasks**:
+- Move compatibility layer to `src/adapters/`
+- Implement IDE-specific installers
+- Create adapter registry
+- Implement `oac apply` command
+- Add IDE detection
+
+**Deliverables**:
+- `src/adapters/opencode.ts`
+- `src/adapters/cursor.ts`
+- `oac apply cursor` works
+
+---
+
+### Phase 4: Update System (Week 4)
+**Goal**: Version management
+
+**Tasks**:
+- Create version checker
+- Implement update fetcher
+- Create update applier
+- Implement `oac update` command
+- Add update notifications
+
+**Deliverables**:
+- `src/core/updater/version.ts`
+- `oac update --check` works
+- `oac update --claude --global` works
+
+---
+
+### Phase 5: Context System (Week 5)
+**Goal**: Flexible context locations
+
+**Tasks**:
+- Create context locator service
+- Implement context resolver
+- Add context validator
+- Update agents to use locator
+- Add context discovery
+
+**Deliverables**:
+- `src/core/context/locator.ts`
+- Context files resolve from multiple locations
+
+---
+
+### Phase 6: Community Registry (Week 6)
+**Goal**: shadcn-like component sharing
+
+**Tasks**:
+- Design component package format
+- Implement `oac add` command
+- Implement `oac publish` command
+- Create community registry
+- Add component validation
+- Implement search and browse
+
+**Deliverables**:
+- `src/cli/commands/add.ts`
+- `src/cli/commands/publish.ts`
+- `src/core/registry/publisher.ts`
+- `oac add agent:rust-specialist` works
+- `oac publish ./my-agent` works
+
+---
+
+### Phase 7: Polish & Documentation (Week 7)
+**Goal**: Production-ready package
+
+**Tasks**:
+- Add comprehensive error handling
+- Improve CLI UX
+- Write user documentation
+- Create migration guide
+- Update README
+- Publish to npm
+
+**Deliverables**:
+- `docs/cli-reference.md`
+- `docs/configuration.md`
+- `docs/community-components.md`
+- `docs/migration-guide.md`
+
+---
+
+## Community Component Guidelines
+
+### Component Types
+
+**Agents**: AI agent prompts for specific domains
+- Example: `rust-specialist`, `python-expert`, `devops-guru`
+
+**Skills**: Auto-invoked guidance for specific tasks
+- Example: `git-workflow`, `testing-patterns`, `security-checks`
+
+**Contexts**: Shared knowledge files
+- Example: `rust-patterns`, `react-best-practices`, `api-design`
+
+**Tools**: Custom MCP tools
+- Example: `database-inspector`, `api-tester`, `log-analyzer`
+
+---
+
+### Publishing Requirements
+
+**Must have**:
+- ✅ Valid `oac.json` metadata
+- ✅ Component file (agent.md, skill.md, etc.)
+- ✅ README.md with usage instructions
+- ✅ LICENSE file (MIT, Apache 2.0, etc.)
+- ✅ Passes validation (`oac validate`)
+
+**Should have**:
+- ✅ Tests (smoke-test.yaml minimum)
+- ✅ Examples in README
+- ✅ Version history in CHANGELOG.md
+- ✅ GitHub repository
+
+**Nice to have**:
+- ✅ Context files
+- ✅ Multiple test cases
+- ✅ Screenshots/demos
+- ✅ Video tutorial
+
+---
+
+### Verification System
+
+**Verified Components**: Official or community-approved
+- ✅ Reviewed by maintainers
+- ✅ Follows best practices
+- ✅ Has comprehensive tests
+- ✅ Well-documented
+- ✅ Actively maintained
+
+**Unverified Components**: Community contributions
+- ⚠️ Use at your own risk
+- ⚠️ May not follow best practices
+- ⚠️ May have limited testing
+
+---
+
+## Backward Compatibility
+
+**Preserve existing workflows**:
+- ✅ Keep `install.sh` for direct usage
+- ✅ Keep `bin/oac.js` as entry point
+- ✅ Keep registry.json format
+- ✅ Keep `.opencode/` structure
+- ✅ Support legacy `oac [profile]` syntax
+
+**Migration path**:
+```bash
+# Old way (still works)
+npm install -g @nextsystems/oac
+oac developer
+
+# New way (enhanced)
+npm install -g @nextsystems/oac
+oac configure
+oac install opencode
+oac add agent:rust-specialist
+```
+
+---
+
+## Success Metrics
+
+**Must have**:
+- ✅ Multi-IDE installation works
+- ✅ Configuration persists
+- ✅ Updates work across IDEs
+- ✅ Community components can be added
+- ✅ Context resolution works
+- ✅ Backward compatible
+
+**Nice to have**:
+- ✅ 100+ community components
+- ✅ Auto-update notifications
+- ✅ IDE auto-detection
+- ✅ Plugin system
+
+---
+
+## Related Files
+
+**Core Concepts**:
+- `core-concepts/agents.md` - Agent system
+- `core-concepts/registry.md` - Registry system
+- `concepts/compatibility-layer.md` - Multi-IDE support
+
+**Guides**:
+- `guides/npm-publishing.md` - Publishing workflow
+- `guides/adding-agent.md` - Creating agents
+
+**Lookup**:
+- `lookup/file-locations.md` - File structure
+- `lookup/compatibility-layer-structure.md` - Adapter structure
+
+---
+
+## Next Steps
+
+**Immediate**:
+1. ✅ Create feature branch
+2. ✅ Create context file (this file)
+3. Create GitHub issue for tracking
+4. Set up project board
+
+**Phase 1 Start**:
+1. Set up TypeScript project structure
+2. Install dependencies
+3. Create configuration schema
+4. Implement `oac configure` command
+
+---
+
+**Last Updated**: 2026-02-14  
+**Version**: 1.0.0-alpha  
+**Status**: Planning → Implementation

+ 601 - 0
.opencode/context/openagents-repo/features/oac-refactor-feedback.md

@@ -0,0 +1,601 @@
+<!-- Context: openagents-repo/oac-refactor-feedback | Priority: medium | Version: 1.0 | Updated: 2026-02-15 -->
+
+# OAC Package Refactor - Critical Feedback & Recommendations
+
+**Date**: 2026-02-14  
+**Source**: Parallel review by CodeReviewer + User Research Agent  
+**Status**: Action Required Before Phase 1
+
+---
+
+## Executive Summary
+
+**Overall Assessment**: The OAC refactor plan is **80% solid** but needs critical additions before implementation.
+
+**Key Findings**:
+- ✅ Core architecture is sound (approval system, context resolution, multi-IDE)
+- ⚠️ Missing critical features (discovery, lockfile, security)
+- ❌ Some approaches need rethinking (context merging, local/global UX)
+- 💡 Repository structure needs optimization for extensibility
+
+---
+
+## 🚨 CRITICAL Issues to Address Before Phase 1
+
+### 1. Security & Verification (BLOCKER)
+
+**Problem**: Community components have no security layer
+
+**Required Additions**:
+```typescript
+interface ComponentSecurity {
+  signature: string;           // GPG signature
+  checksum: string;            // SHA-256 hash
+  scanResults: {
+    malware: boolean;
+    secrets: boolean;
+    externalCalls: string[];
+  };
+  permissions: {
+    fileSystem: 'read' | 'write' | 'none';
+    network: 'allowed' | 'denied';
+    shell: 'allowed' | 'denied';
+  };
+}
+```
+
+**Add to Phase 1**:
+- Component signing mechanism
+- Checksum verification
+- Basic malware scanning (ClamAV)
+- Secret detection (gitleaks)
+
+**CLI Commands**:
+```bash
+oac verify <component>        # Verify signature
+oac audit                     # Security scan
+oac trust @author             # Trust publisher
+```
+
+---
+
+### 2. Discovery & Browse Experience (CRITICAL GAP)
+
+**Problem**: Users can't discover what's available
+
+**Current Plan**: Only `oac add` (assumes you know what exists)
+
+**Required Additions**:
+```bash
+oac browse                    # Interactive TUI browser
+oac search "rust" --verified  # Search registry
+oac trending                  # Popular components
+oac info agent:rust-specialist # Detailed info
+oac preview agent:rust        # Show what it does
+```
+
+**Implementation**:
+- Interactive TUI using `ink` or `blessed`
+- Web registry at https://registry.openagents.dev
+- Component ratings and reviews
+- Download counts and trending
+
+**Add to Phase 1**: Basic `oac browse` and `oac search`
+
+---
+
+### 3. Lockfile for Reproducibility (CRITICAL GAP)
+
+**Problem**: No way to guarantee reproducible installs (teams need this)
+
+**Required Addition**:
+```json
+// oac.lock
+{
+  "version": "1.0.0",
+  "lockfileVersion": 1,
+  "components": {
+    "agent:openagent": {
+      "version": "0.7.1",
+      "resolved": "https://github.com/.../openagent.md",
+      "integrity": "sha256-abc123...",
+      "dependencies": {
+        "context:code-quality": "^1.0.0"
+      }
+    }
+  }
+}
+```
+
+**CLI Commands**:
+```bash
+oac lock                      # Generate lock file
+oac install --frozen          # Use exact locked versions
+oac lock verify               # Verify integrity
+```
+
+**Add to Phase 2**: Lockfile generation and frozen installs
+
+---
+
+### 4. Version Conflict Management (CRITICAL GAP)
+
+**Problem**: No strategy for handling version conflicts
+
+**Required Additions**:
+```json
+{
+  "dependencies": {
+    "agents": {
+      "tester": "^1.0.0",     // Semver range
+      "reviewer": "~2.1.0"    // Patch updates only
+    }
+  },
+  "peerDependencies": {
+    "openagent": "^0.5.0"     // Required version
+  }
+}
+```
+
+**CLI Commands**:
+```bash
+oac outdated                  # Show outdated components
+oac update --check-breaking   # Warn about breaking changes
+oac pin <component> <version> # Pin to specific version
+oac deps tree                 # Show dependency tree
+oac deps conflicts            # Show conflicts
+```
+
+**Add to Phase 2**: Semver support and conflict detection
+
+---
+
+### 5. Interactive Onboarding (HIGH PRIORITY)
+
+**Problem**: First-time users need guidance
+
+**Required Addition**:
+```bash
+oac init
+
+┌─────────────────────────────────────────────────┐
+│  Welcome to OpenAgents Control! 👋              │
+│  Let's set up your AI agent environment.        │
+└─────────────────────────────────────────────────┘
+
+? What's your primary use case?
+  > Software Development
+    Content Creation
+    Data Analysis
+
+? Which IDE do you use?
+  ✓ OpenCode
+  ✓ Cursor
+
+? Install location preference?
+  > Ask each time (recommended)
+    Always local
+    Always global
+
+✓ Configuration saved!
+📦 Installing recommended agents...
+✓ Done! Try: oac browse
+```
+
+**Add to Phase 1**: Interactive wizard for `oac init`
+
+---
+
+### 6. Visual Feedback & Progress (HIGH PRIORITY)
+
+**Problem**: Long operations feel unresponsive
+
+**Required Addition**:
+```bash
+📦 Installing OpenCode Developer Profile
+⠋ Downloading components... [████████████░░░░░░░░] 60% (12/20)
+✓ openagent.md (15KB)
+✓ opencoder.md (18KB)
+⠋ Installing contexts...
+```
+
+**Implementation**:
+- Use `ora` for spinners
+- Use `cli-progress` for progress bars
+- Color-coded output with `chalk`
+- Clear success/error states
+
+**Add to Phase 1**: Progress indicators for all long operations
+
+---
+
+## ⚠️ Approaches That Need Rethinking
+
+### 1. Context Merging is Dangerous
+
+**Current Plan**: Merge context files from multiple sources
+
+**Problem**:
+- Conflicts between sections
+- Unclear merge strategy
+- Hard to debug
+
+**Better Approach**: Use composition instead
+```typescript
+interface ContextComposition {
+  base: string;                // Base context
+  overrides: string[];         // Override files (applied in order)
+  strategy: 'override' | 'append' | 'prepend';
+}
+```
+
+**Action**: Replace merging with composition in Phase 5
+
+---
+
+### 2. Local vs Global UX is Confusing
+
+**Current Plan**: Ask "local or global?" on every command
+
+**Problem**:
+- Decision fatigue
+- Most users want one or the other
+- No clear guidance
+
+**Better Approach**: Auto-detection with smart defaults
+```bash
+# Set default once
+oac configure set preferences.installLocation auto
+
+# Auto-detect based on context:
+# - In git repo? → local
+# - Has .opencode/? → local
+# - In home dir? → global
+
+# Override when needed
+oac install --global
+oac install --local
+```
+
+**Action**: Implement auto-detection in Phase 1
+
+---
+
+### 3. Cursor Agent Merging is Problematic
+
+**Current Plan**: Merge all agents into single .cursorrules
+
+**Problem**:
+- Loss of modularity
+- Hard to debug
+- 100KB limit is restrictive
+- Merge conflicts on updates
+
+**Better Approach**: Router agent pattern
+```markdown
+# Cursor Router Agent
+When user asks about testing → delegate to tester patterns
+When user asks about frontend → delegate to frontend patterns
+Default → delegate to openagent patterns
+
+[Embedded agent patterns as sections, not full agents]
+```
+
+**Action**: Implement router pattern in Phase 3
+
+---
+
+## 💡 Recommended Additions
+
+### 1. Plugin Architecture for Extensibility
+
+**Why**: Keep core lean, allow community extensions
+
+```typescript
+interface OACPlugin {
+  name: string;
+  version: string;
+  hooks: {
+    beforeInstall?: (context: InstallContext) => void;
+    afterInstall?: (context: InstallContext) => void;
+  };
+  commands?: Command[];
+  adapters?: IDEAdapter[];
+}
+```
+
+**Add to Phase 6**: Plugin system
+
+---
+
+### 2. Workspace Support for Monorepos
+
+**Why**: Teams use monorepos, need first-class support
+
+```json
+// oac-workspace.json
+{
+  "version": "1.0.0",
+  "packages": ["packages/*", "apps/*"],
+  "shared": {
+    "context": ".oac/shared/context",
+    "config": ".oac/shared/config.json"
+  }
+}
+```
+
+**Add to v1.1**: Workspace support
+
+---
+
+### 3. Component Marketplace with Ratings
+
+**Why**: Discovery and trust
+
+```typescript
+interface ComponentMarketplace {
+  downloads: number;
+  rating: number;           // 1-5 stars
+  reviews: Review[];
+  verified: boolean;
+  maintainer: string;
+  lastUpdated: Date;
+}
+```
+
+**Add to v1.1**: Marketplace features
+
+---
+
+## 🏗️ Repository Structure Recommendation
+
+### Use Monorepo (pnpm workspaces)
+
+```
+@nextsystems/oac/
+├── packages/
+│   ├── core/                  # Core CLI package
+│   │   ├── src/
+│   │   │   ├── cli/
+│   │   │   ├── config/
+│   │   │   ├── approval/
+│   │   │   └── context/
+│   │   ├── tests/
+│   │   └── package.json
+│   ├── adapters/              # IDE adapters package
+│   │   ├── src/
+│   │   │   ├── opencode/
+│   │   │   ├── cursor/
+│   │   │   ├── claude/
+│   │   │   └── windsurf/
+│   │   └── package.json
+│   ├── registry/              # Registry package
+│   │   ├── src/
+│   │   └── package.json
+│   ├── security/              # Security scanning
+│   │   ├── src/
+│   │   └── package.json
+│   └── cli/                   # CLI entry point
+│       ├── bin/
+│       └── package.json
+├── .opencode/                 # Official components
+├── registry.json              # Official registry
+├── community-registry.json    # Community registry
+├── pnpm-workspace.yaml        # Monorepo config
+└── package.json               # Root package
+```
+
+**Why Monorepo**:
+- ✅ Shared dependencies
+- ✅ Atomic commits across packages
+- ✅ Easier to maintain consistency
+- ✅ Easier to test integrations
+- ✅ Single version for all packages
+
+**Tools**: pnpm workspaces + Turborepo
+
+---
+
+## 🤝 Community Contribution Workflow
+
+### Recommended Process
+
+```bash
+# 1. Create component locally
+oac create agent my-specialist
+
+# 2. Test locally
+oac test agent:my-specialist
+
+# 3. Package for submission
+oac package agent:my-specialist
+# Creates: my-specialist.oac.tar.gz
+
+# 4. Submit to registry
+oac submit my-specialist.oac.tar.gz
+# Uploads to GitHub, creates PR
+
+# 5. Automated checks run
+# - Security scan (ClamAV)
+# - Secret scan (gitleaks)
+# - Dependency check
+# - Test execution
+# - Size check
+
+# 6. Manual review (for verification badge)
+# - Code quality review
+# - Documentation review
+# - Test coverage review
+
+# 7. Approval and publish
+# - Merged to community-registry.json
+# - Available via `oac add`
+```
+
+### Security Scanning Pipeline
+
+```yaml
+# .github/workflows/component-scan.yml
+name: Component Security Scan
+
+on:
+  pull_request:
+    paths:
+      - 'community-registry.json'
+
+jobs:
+  scan:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Malware scan
+        run: clamav scan component/
+      
+      - name: Secret scan
+        run: gitleaks detect --source component/
+      
+      - name: Dependency audit
+        run: npm audit
+      
+      - name: Test execution
+        run: oac test component/
+```
+
+---
+
+## 📋 Updated Feature Prioritization
+
+### MVP (v1.0.0 - Must Ship)
+
+| Feature | Priority | Status | Action |
+|---------|----------|--------|--------|
+| Core CLI | P0 | ✅ Planned | Keep |
+| Multi-IDE support | P0 | ✅ Planned | Keep |
+| Approval gates | P0 | ✅ Planned | Keep |
+| Configuration system | P0 | ✅ Planned | Keep |
+| Context resolution | P0 | ✅ Planned | Fix merging |
+| **Discovery** (`browse`, `search`) | P0 | 🚨 **ADD** | Phase 1 |
+| **Lockfile** (`oac.lock`) | P0 | 🚨 **ADD** | Phase 2 |
+| **Security** (verify, audit) | P0 | 🚨 **ADD** | Phase 1 |
+| **Onboarding** (interactive init) | P0 | 🚨 **ADD** | Phase 1 |
+| **Progress UI** (spinners, bars) | P0 | 🚨 **ADD** | Phase 1 |
+| **Auto-detection** (local/global) | P0 | 🚨 **ADD** | Phase 1 |
+
+### Post-MVP (v1.1.0)
+
+| Feature | Priority | Impact |
+|---------|----------|--------|
+| Preview/try mode | P1 | High |
+| Dependency management | P1 | High |
+| Plugin system | P1 | Medium |
+| Workspace support | P1 | Medium |
+| Marketplace features | P1 | High |
+
+---
+
+## 📚 Documentation Requirements
+
+### Critical Docs (Before Launch)
+
+1. **Quick Start (5-Minute Guide)**
+   - Install → Init → Add Agent → Start Coding
+
+2. **CLI Reference** (Auto-Generated)
+   - Every command documented
+   - Examples for each flag
+   - Common use cases
+
+3. **Recipes / Cookbook**
+   - Set up React project
+   - Share config with team
+   - Create custom agent
+   - Troubleshooting
+
+4. **Component Creation Guide**
+   - Step-by-step agent creation
+   - Testing guide
+   - Publishing checklist
+
+5. **Migration Guide**
+   - From current OAC to v1.0
+   - Breaking changes
+   - Upgrade path
+
+---
+
+## ✅ Action Items (Before Phase 1)
+
+### Immediate (This Week)
+
+1. ✅ **Update context file** with critical additions
+2. ✅ **Update Phase 1 tasks** to include:
+   - Discovery (browse, search)
+   - Security (verify, checksum)
+   - Onboarding (interactive init)
+   - Progress UI (spinners, bars)
+   - Auto-detection (local/global)
+3. ✅ **Update Phase 2 tasks** to include:
+   - Lockfile generation
+   - Version conflict detection
+   - Semver support
+
+### Before Implementation
+
+4. ⬜ **Set up monorepo structure** (pnpm workspaces)
+5. ⬜ **Create security scanning workflow**
+6. ⬜ **Design TUI for browse command**
+7. ⬜ **Write Quick Start docs**
+
+---
+
+## 🎯 Key Takeaways
+
+### What's Good (Keep)
+
+1. ✅ User approval system with YOLO mode
+2. ✅ Layered context resolution (fix merging)
+3. ✅ Multi-IDE support via adapters
+4. ✅ Community registry concept
+5. ✅ Backward compatibility
+
+### What's Missing (Add)
+
+1. 🚨 Discovery (browse, search, trending)
+2. 🚨 Lockfile (reproducibility)
+3. 🚨 Security (verification, scanning)
+4. 🚨 Onboarding (interactive wizard)
+5. 🚨 Progress UI (spinners, bars)
+6. 🚨 Auto-detection (local/global)
+
+### What Needs Fixing (Rethink)
+
+1. ⚠️ Context merging → Use composition
+2. ⚠️ Always asking local/global → Auto-detect
+3. ⚠️ Cursor agent merging → Router pattern
+4. ⚠️ No version management → Add semver + lockfile
+
+---
+
+## 📊 Success Metrics (Post-Launch)
+
+| Metric | Target (6 months) |
+|--------|-------------------|
+| GitHub stars | 1,000+ |
+| npm downloads/month | 10,000+ |
+| Community components | 50+ |
+| Active contributors | 20+ |
+| Docs page views | 5,000+/month |
+
+---
+
+## 🚀 Next Steps
+
+1. **Update OAC refactor plan** with critical additions
+2. **Update Phase 1 tasks** to include new features
+3. **Set up monorepo structure**
+4. **Start Phase 1 implementation**
+
+---
+
+**Status**: Ready to proceed with updated plan  
+**Confidence**: High (80% → 95% with additions)  
+**Risk**: Low (critical gaps identified and addressed)

+ 452 - 0
.opencode/context/openagents-repo/features/oac-refactor-quickstart.md

@@ -0,0 +1,452 @@
+<!-- Context: openagents-repo/oac-refactor-quickstart | Priority: medium | Version: 1.0 | Updated: 2026-02-15 -->
+
+# OAC Package Refactor - Quick Start
+
+**Purpose**: Quick reference for working on the OAC package refactor  
+**Issue**: #206  
+**Branch**: `feature/oac-package-refactor`  
+**Context**: `features/oac-package-refactor.md`
+
+---
+
+## Current Status
+
+✅ **Planning Complete**
+- Context file created
+- GitHub issue #206 created
+- Feature branch created and pushed
+- **CRITICAL features defined**:
+  - User approval system with YOLO mode
+  - Layered context resolution (project + global)
+
+📝 **Next: Phase 1 - Core CLI Infrastructure**
+
+## Critical Features Overview
+
+### 1. User Approval System
+- **Default**: Interactive approval for ALL file operations
+- **YOLO Mode** (`--yolo`): Skip confirmations, auto-resolve, report at end
+- **Always asks**: Local vs global install location
+- **Conflict handling**: Show diffs, ask user, create backups
+- **Safety**: Git detection, rollback support, audit log
+
+### 2. Context Resolution
+- **6-layer priority**: Project override → Project → IDE → Docs → User global → OAC official
+- **Smart resolution**: Based on agent location (global vs local)
+- **Configurable**: `preferLocal` option
+- **CLI tools**: `oac context resolve`, `list`, `validate`, `override`, `sync`
+
+---
+
+## Quick Commands
+
+```bash
+# Switch to feature branch
+git checkout feature/oac-package-refactor
+
+# View full context
+cat .opencode/context/openagents-repo/features/oac-package-refactor.md
+
+# View GitHub issue
+gh issue view 206
+
+# Start Phase 1
+# (See Phase 1 section below)
+```
+
+---
+
+## Phase 1: Core CLI Infrastructure
+
+**Goal**: Set up TypeScript project and configuration system
+
+### Tasks
+
+1. **Set up TypeScript project structure**
+   ```bash
+   mkdir -p src/{cli/{commands,config},core/{context,installer,approval},types,utils}
+   npm install --save-dev typescript @types/node tsx vitest
+   npx tsc --init
+   ```
+
+2. **Install CLI dependencies**
+   ```bash
+   npm install commander inquirer zod chalk ora boxen
+   npm install --save-dev @types/inquirer
+   ```
+
+3. **Create configuration schema** (CRITICAL)
+   - File: `src/cli/config/schema.ts`
+   - Use Zod for validation
+   - Define OACConfig interface
+   - **Include**: `confirmOverwrites`, `yoloMode`, `preferLocal`, context resolution config
+
+4. **Create configuration manager**
+   - File: `src/cli/config/manager.ts`
+   - Read/write config files
+   - Merge global and local configs (priority: local > global)
+   - Validate with schema
+   - **Support**: `~/.config/oac/config.json` (global) and `.oac/config.json` (local)
+
+5. **Create approval system** (CRITICAL)
+   - File: `src/core/approval/manager.ts`
+   - Interactive prompts for file operations
+   - YOLO mode support
+   - Conflict resolution strategies
+   - Backup management
+   - Audit logging
+
+6. **Create context resolver** (CRITICAL)
+   - File: `src/core/context/resolver.ts`
+   - 6-layer priority resolution
+   - Agent location detection (global vs local)
+   - `preferLocal` configuration
+   - Fallback support
+   - Validation and suggestions
+
+7. **Implement basic CLI commands**
+   - File: `src/cli/index.ts` (Commander setup)
+   - File: `src/cli/commands/configure.ts`
+   - File: `src/cli/commands/list.ts`
+   - File: `src/cli/commands/init.ts`
+   - **Add global flags**: `--yolo`, `--dry-run`, `--local`, `--global`
+
+8. **Update bin/oac.js**
+   - Point to compiled TypeScript
+   - Handle both legacy and new commands
+   - Detect current working directory
+
+9. **Write tests**
+   - Test configuration schema
+   - Test config manager (global + local merge)
+   - Test approval system (interactive + YOLO)
+   - Test context resolver (all 6 layers)
+   - Test CLI commands
+
+### Deliverables
+
+- [ ] TypeScript project configured
+- [ ] Configuration schema defined (with approval + context config)
+- [ ] Configuration manager working (global + local merge)
+- [ ] **Approval system working** (interactive + YOLO mode)
+- [ ] **Context resolver working** (6-layer priority)
+- [ ] `oac configure` command works
+- [ ] `oac list` command works
+- [ ] `oac init` command works (asks local vs global)
+- [ ] `oac context resolve` command works
+- [ ] Tests passing (including approval + context tests)
+
+### Validation
+
+```bash
+# Test configuration (global + local)
+oac configure show
+oac configure set agents.permissions.bash auto
+oac configure get agents.permissions.bash
+oac configure set preferences.yoloMode true
+
+# Test list
+oac list
+oac list --agents
+oac list --local
+oac list --global
+
+# Test init (should ask local vs global)
+cd /tmp/test-project
+oac init developer
+# Should prompt: "Install locally or globally?"
+
+# Test approval system
+cd /tmp/test-project
+oac install opencode
+# Should show file list and ask for confirmation
+
+# Test YOLO mode
+oac install opencode --yolo
+# Should auto-confirm and report at end
+
+# Test context resolution
+oac context resolve 'core/standards/code-quality.md'
+# Should show resolved path and priority
+
+oac context list
+# Should show all context files from all layers
+
+oac context validate
+# Should validate all context references
+```
+
+---
+
+## Project Structure (Phase 1)
+
+```
+@nextsystems/oac/
+├── bin/
+│   └── oac.js                  # Updated entry point
+├── src/
+│   ├── cli/
+│   │   ├── commands/
+│   │   │   ├── configure.ts    # NEW - Config management
+│   │   │   ├── list.ts         # NEW - List components
+│   │   │   ├── init.ts         # NEW - Initialize (asks local/global)
+│   │   │   └── context.ts      # NEW - Context commands (resolve, list, validate)
+│   │   ├── config/
+│   │   │   ├── manager.ts      # NEW - Global + local merge
+│   │   │   ├── schema.ts       # NEW - Zod schema (approval + context config)
+│   │   │   └── defaults.ts     # NEW - Default config
+│   │   └── index.ts            # NEW - Commander setup (global flags)
+│   ├── core/
+│   │   ├── approval/
+│   │   │   ├── manager.ts      # NEW - Approval system (CRITICAL)
+│   │   │   ├── strategies.ts   # NEW - Conflict strategies
+│   │   │   └── backup.ts       # NEW - Backup management
+│   │   ├── context/
+│   │   │   ├── resolver.ts     # NEW - 6-layer resolution (CRITICAL)
+│   │   │   ├── locator.ts      # NEW - Find context files
+│   │   │   └── validator.ts    # NEW - Validate references
+│   │   └── installer/
+│   │       └── location.ts     # NEW - Detect local vs global
+│   ├── types/
+│   │   ├── config.ts           # NEW - Config types
+│   │   ├── approval.ts         # NEW - Approval types
+│   │   └── context.ts          # NEW - Context types
+│   └── utils/
+│       ├── logger.ts           # NEW - Logging
+│       ├── prompts.ts          # NEW - Interactive prompts
+│       └── git.ts              # NEW - Git detection
+├── config/
+│   └── oac.config.json         # NEW - Default config
+├── tsconfig.json               # NEW
+├── package.json                # UPDATED
+└── .opencode/                  # EXISTING
+```
+
+---
+
+## Configuration Schema (Reference)
+
+```typescript
+// src/cli/config/schema.ts
+import { z } from 'zod';
+
+export const OACConfigSchema = z.object({
+  version: z.string(),
+  preferences: z.object({
+    defaultIDE: z.enum(['opencode', 'cursor', 'claude', 'windsurf']),
+    installLocation: z.enum(['local', 'global']),
+    autoUpdate: z.boolean(),
+    updateChannel: z.enum(['stable', 'beta', 'alpha'])
+  }),
+  ides: z.record(z.object({
+    enabled: z.boolean(),
+    path: z.string(),
+    profile: z.string()
+  })),
+  agents: z.object({
+    behavior: z.object({
+      approvalGates: z.boolean(),
+      contextLoading: z.enum(['lazy', 'eager']),
+      delegationThreshold: z.number()
+    }),
+    permissions: z.object({
+      bash: z.enum(['approve', 'auto', 'deny']),
+      write: z.enum(['approve', 'auto', 'deny']),
+      edit: z.enum(['approve', 'auto', 'deny']),
+      task: z.enum(['approve', 'auto', 'deny'])
+    })
+  }),
+  context: z.object({
+    locations: z.array(z.string()),
+    autoDiscover: z.boolean(),
+    cacheEnabled: z.boolean()
+  }),
+  registry: z.object({
+    source: z.string().url(),
+    localCache: z.string(),
+    updateInterval: z.number()
+  })
+});
+
+export type OACConfig = z.infer<typeof OACConfigSchema>;
+```
+
+---
+
+## Default Configuration (Reference)
+
+```json
+{
+  "version": "1.0.0",
+  "preferences": {
+    "defaultIDE": "opencode",
+    "installLocation": "local",
+    "autoUpdate": false,
+    "updateChannel": "stable"
+  },
+  "ides": {
+    "opencode": {
+      "enabled": true,
+      "path": ".opencode",
+      "profile": "developer"
+    },
+    "cursor": {
+      "enabled": false,
+      "path": ".cursor",
+      "profile": "developer"
+    },
+    "claude": {
+      "enabled": false,
+      "path": ".claude",
+      "profile": "developer"
+    },
+    "windsurf": {
+      "enabled": false,
+      "path": ".windsurf",
+      "profile": "developer"
+    }
+  },
+  "agents": {
+    "behavior": {
+      "approvalGates": true,
+      "contextLoading": "lazy",
+      "delegationThreshold": 4
+    },
+    "permissions": {
+      "bash": "approve",
+      "write": "approve",
+      "edit": "approve",
+      "task": "approve"
+    }
+  },
+  "context": {
+    "locations": [
+      ".opencode/context",
+      ".claude/context",
+      "docs/context"
+    ],
+    "autoDiscover": true,
+    "cacheEnabled": true
+  },
+  "registry": {
+    "source": "https://raw.githubusercontent.com/darrenhinde/OpenAgentsControl/main/registry.json",
+    "localCache": "~/.config/oac/registry.cache.json",
+    "updateInterval": 86400
+  }
+}
+```
+
+---
+
+## Testing Strategy
+
+### Unit Tests
+```typescript
+// src/cli/config/manager.test.ts
+import { describe, it, expect } from 'vitest';
+import { ConfigManager } from './manager';
+
+describe('ConfigManager', () => {
+  it('should load default config', async () => {
+    const manager = new ConfigManager();
+    const config = await manager.load();
+    expect(config.version).toBe('1.0.0');
+  });
+
+  it('should validate config schema', async () => {
+    const manager = new ConfigManager();
+    const valid = await manager.validate(mockConfig);
+    expect(valid).toBe(true);
+  });
+
+  it('should merge global and local configs', async () => {
+    const manager = new ConfigManager();
+    const config = await manager.load();
+    expect(config.preferences.defaultIDE).toBeDefined();
+  });
+});
+```
+
+### Integration Tests
+```bash
+# Test CLI commands
+npm run build
+./bin/oac.js configure show
+./bin/oac.js list
+./bin/oac.js init developer
+```
+
+---
+
+## Development Workflow
+
+1. **Create feature branch** ✅
+   ```bash
+   git checkout feature/oac-package-refactor
+   ```
+
+2. **Set up TypeScript project**
+   ```bash
+   mkdir -p src/{cli/{commands,config},core,types,utils}
+   npm install dependencies
+   npx tsc --init
+   ```
+
+3. **Implement Phase 1 tasks**
+   - Configuration schema
+   - Configuration manager
+   - CLI commands
+
+4. **Write tests**
+   ```bash
+   npm run test
+   ```
+
+5. **Build and test locally**
+   ```bash
+   npm run build
+   npm pack
+   npm install -g ./nextsystems-oac-*.tgz
+   oac configure
+   ```
+
+6. **Commit and push**
+   ```bash
+   git add .
+   git commit -m "feat(phase1): implement core CLI infrastructure"
+   git push
+   ```
+
+---
+
+## Resources
+
+**Context Files**:
+- `features/oac-package-refactor.md` - Full feature context
+- `core-concepts/registry.md` - Registry system
+- `guides/npm-publishing.md` - Publishing workflow
+
+**External Docs**:
+- Commander.js: https://github.com/tj/commander.js
+- Zod: https://zod.dev
+- Inquirer: https://github.com/SBoudrias/Inquirer.js
+
+**GitHub**:
+- Issue: https://github.com/darrenhinde/OpenAgentsControl/issues/206
+- Branch: `feature/oac-package-refactor`
+
+---
+
+## Next Phase Preview
+
+**Phase 2: Registry & Component Management**
+- Port registry validation to TypeScript
+- Implement registry loader/resolver
+- Create component installer
+- Profile installer
+- Dependency resolution
+
+---
+
+**Last Updated**: 2026-02-14  
+**Status**: Ready to start Phase 1