diff --git a/agents/architect.yaml b/agents/architect.yaml index 5095c42574..657442e566 100644 --- a/agents/architect.yaml +++ b/agents/architect.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - context-caching - memory-persistence -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/agents/coder.yaml b/agents/coder.yaml index 5565f2d92a..566fceaa0d 100644 --- a/agents/coder.yaml +++ b/agents/coder.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - flash-attention - token-reduction -createdAt: "2026-01-12T18:35:04.018Z" +createdAt: "2026-01-13T15:29:56.248Z" diff --git a/agents/reviewer.yaml b/agents/reviewer.yaml index 2ed0ca9491..8cbdb8645a 100644 --- a/agents/reviewer.yaml +++ b/agents/reviewer.yaml @@ -7,4 +7,4 @@ capabilities: - best-practices optimizations: - incremental-analysis -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/agents/security-architect.yaml b/agents/security-architect.yaml index 1b524e9d29..58c6debead 100644 --- a/agents/security-architect.yaml +++ b/agents/security-architect.yaml @@ -7,4 +7,4 @@ capabilities: - security-review optimizations: - pattern-matching -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/agents/tester.yaml b/agents/tester.yaml index 795c4fc9fe..5b9173e278 100644 --- a/agents/tester.yaml +++ b/agents/tester.yaml @@ -7,4 +7,4 @@ capabilities: - coverage optimizations: - parallel-execution -createdAt: "2026-01-12T18:35:04.019Z" +createdAt: "2026-01-13T15:29:56.249Z" diff --git a/v3/implementation/adrs/ADR-025-auto-update-system.md b/v3/implementation/adrs/ADR-025-auto-update-system.md new file mode 100644 index 0000000000..72c7bd66ea --- /dev/null +++ b/v3/implementation/adrs/ADR-025-auto-update-system.md @@ -0,0 +1,268 @@ +# ADR-025: Auto-Update System for @claude-flow Packages + +## Status +**Accepted** - 2026-01-13 + +## Context + +The Claude Flow V3 ecosystem consists of multiple packages: +- `@claude-flow/cli` - Main CLI tool +- `@claude-flow/embeddings` - Vector embeddings +- `@claude-flow/security` - Security utilities +- `@claude-flow/integration` - agentic-flow integration +- `@claude-flow/testing` - Test utilities + +When one package is updated, dependent packages may need updates for compatibility. Currently, users must manually check for updates, leading to: +- Version mismatches causing runtime errors +- Missing security patches +- Delayed access to performance improvements +- Inconsistent behavior across installations + +## Decision + +Implement an **auto-update system** that: + +1. **Checks for updates on startup** (with rate limiting) +2. **Validates package compatibility** before updating +3. **Auto-updates minor/patch versions** (configurable) +4. **Notifies users** of major version updates +5. **Maintains update history** for rollback capability + +### Update Check Frequency + +| Trigger | Behavior | +|---------|----------| +| First run of day | Full update check | +| Subsequent runs same day | Skip check (use cache) | +| `--force-update` flag | Force immediate check | +| `--no-update` flag | Skip all update checks | +| CI/CD environment | Skip by default | + +### Package Priority + +| Priority | Packages | Auto-Update | +|----------|----------|-------------| +| Critical | `@claude-flow/security` | Always (patches) | +| High | `@claude-flow/cli` | Minor + Patch | +| Normal | `@claude-flow/embeddings`, `@claude-flow/integration` | Patch only | +| Low | `@claude-flow/testing` | Notify only | + +## Implementation + +### Architecture + +``` +┌─────────────────────────────────────────────────────────┐ +│ CLI Startup │ +└─────────────────────┬───────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────┐ +│ UpdateChecker Service │ +│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │ +│ │ RateLimiter │ │ NPM Registry│ │ Version Compare │ │ +│ │ (24h cache) │ │ Client │ │ (semver) │ │ +│ └─────────────┘ └─────────────┘ └─────────────────┘ │ +└─────────────────────┬───────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────┐ +│ PackageValidator │ +│ - Dependency compatibility check │ +│ - Peer dependency verification │ +│ - Breaking change detection │ +└─────────────────────┬───────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────┐ +│ UpdateExecutor │ +│ - npm install with specific versions │ +│ - Rollback on failure │ +│ - Update history logging │ +└─────────────────────────────────────────────────────────┘ +``` + +### Core Components + +#### 1. UpdateChecker (`src/update/checker.ts`) + +```typescript +interface UpdateCheckResult { + package: string; + currentVersion: string; + latestVersion: string; + updateType: 'major' | 'minor' | 'patch' | 'none'; + shouldAutoUpdate: boolean; + changelog?: string; +} + +interface UpdateConfig { + enabled: boolean; + checkIntervalHours: number; // Default: 24 + autoUpdatePatch: boolean; // Default: true + autoUpdateMinor: boolean; // Default: false + autoUpdateMajor: boolean; // Default: false + excludePackages: string[]; // Packages to skip + priorityPackages: string[]; // Check these first +} +``` + +#### 2. RateLimiter (`src/update/rate-limiter.ts`) + +```typescript +interface RateLimitState { + lastCheck: string; // ISO timestamp + checksToday: number; + packageVersions: Record; +} + +// Stored in: ~/.claude-flow/update-state.json +``` + +#### 3. PackageValidator (`src/update/validator.ts`) + +```typescript +interface ValidationResult { + valid: boolean; + incompatibilities: string[]; + warnings: string[]; + requiredPeerUpdates: string[]; +} +``` + +### Update Flow + +``` +1. CLI Start + │ + ├─► Check rate limit cache (~/.claude-flow/update-state.json) + │ └─► If checked within 24h AND no --force-update → Skip + │ + ├─► Query npm registry for @claude-flow/* packages + │ └─► Compare versions using semver + │ + ├─► For each package with available update: + │ ├─► Check update priority (critical/high/normal/low) + │ ├─► Validate compatibility with other packages + │ └─► Determine if auto-update applies + │ + ├─► Execute auto-updates (if any) + │ ├─► npm install @claude-flow/package@version + │ ├─► Verify installation success + │ └─► Log to update history + │ + └─► Display notification for non-auto updates + └─► "Run `npx claude-flow update` to update X packages" +``` + +### CLI Commands + +```bash +# Check for updates (manual) +npx claude-flow update check + +# Update all packages +npx claude-flow update all + +# Update specific package +npx claude-flow update @claude-flow/embeddings + +# View update history +npx claude-flow update history + +# Rollback last update +npx claude-flow update rollback + +# Configure auto-update +npx claude-flow config set update.autoUpdateMinor true +npx claude-flow config set update.checkIntervalHours 12 +``` + +### Environment Variables + +```bash +# Disable auto-update entirely +CLAUDE_FLOW_AUTO_UPDATE=false + +# Force update check +CLAUDE_FLOW_FORCE_UPDATE=true + +# CI/CD mode (no interactive prompts, no auto-update) +CI=true +``` + +### Configuration File + +```json +// claude-flow.config.json +{ + "update": { + "enabled": true, + "checkIntervalHours": 24, + "autoUpdate": { + "patch": true, + "minor": false, + "major": false + }, + "priority": { + "@claude-flow/security": "critical", + "@claude-flow/cli": "high", + "@claude-flow/embeddings": "normal", + "@claude-flow/integration": "normal", + "@claude-flow/testing": "low" + }, + "exclude": [] + } +} +``` + +## Security Considerations + +1. **Registry verification**: Only fetch from official npm registry +2. **Checksum validation**: Verify package integrity before install +3. **Rollback capability**: Maintain previous versions for quick rollback +4. **Audit logging**: Log all update operations for traceability +5. **Signature verification**: Verify npm package signatures when available + +## Consequences + +### Positive +- Users always have latest security patches +- Reduced version mismatch issues +- Improved ecosystem consistency +- Automatic performance improvements +- Reduced support burden + +### Negative +- Slightly slower startup (mitigated by rate limiting) +- Requires network access (gracefully degrades offline) +- Potential for breaking changes (mitigated by validation) + +### Neutral +- Additional storage for update state (~1KB) +- New CLI commands to learn + +## Alternatives Considered + +1. **No auto-update**: Rejected - too many version mismatch issues +2. **Update on every run**: Rejected - too slow, network overhead +3. **Weekly update check**: Rejected - security patches delayed too long +4. **npm-check-updates integration**: Rejected - external dependency + +## Implementation Plan + +| Phase | Task | Priority | +|-------|------|----------| +| 1 | UpdateChecker service | High | +| 2 | RateLimiter with file cache | High | +| 3 | PackageValidator | High | +| 4 | UpdateExecutor with rollback | Medium | +| 5 | CLI commands | Medium | +| 6 | Configuration integration | Medium | +| 7 | Telemetry/logging | Low | + +## References + +- [npm registry API](https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md) +- [semver specification](https://semver.org/) +- [ADR-013: Core Security Module](./ADR-013-core-security-module.md)