Skip to content

Introduce capability extension system for provisioning#22

Merged
TimBeyer merged 10 commits intomainfrom
claude/plugin-extension-system-K72zG
Mar 16, 2026
Merged

Introduce capability extension system for provisioning#22
TimBeyer merged 10 commits intomainfrom
claude/plugin-extension-system-K72zG

Conversation

@TimBeyer
Copy link
Copy Markdown
Owner

Summary

Refactor the hardcoded provisioning stages into a capability-focused extension system. Each feature (system packages, Homebrew, 1Password, Tailscale, OpenClaw, etc.) is now a self-contained, versioned capability module with lifecycle hooks, sequential migrations, config schema contributions, and an injected toolkit SDK.

Key Changes

  • New @clawctl/capabilities package: Centralized capability definitions with atomic, reusable modules

    • registry.ts: Static registry of all capabilities with enable/disable logic
    • runner.ts: Phase runner that collects and executes hooks from enabled capabilities
    • state.ts: Capability state tracking for version-based migrations
    • agents-md.ts: Moved from host-core, now VM-side and capability-driven
  • New ProvisionContext SDK (@clawctl/types): Injected into all capability steps

    • Replaces direct imports of VM-side tools
    • Provides unified interface for exec, file ops, network, shell profile, and config reading
    • Safe to import from both host CLI (config validation) and VM CLI (execution)
  • Capability modules in packages/capabilities/src/capabilities/:

    • system-base.ts: APT packages, Node.js, systemd-linger (core)
    • homebrew.ts: Homebrew installation and shell profile (core)
    • openclaw.ts: OpenClaw install, env vars, gateway stub (core)
    • checkpoint.ts: Checkpoint skill (core)
    • tailscale.ts: Tailscale installation (optional)
    • one-password.ts: 1Password CLI, wrapper, exec-approvals, skills (optional)
  • Helper modules in packages/capabilities/src/helpers/:

    • Ported tool logic from vm-cli/src/tools/ (apt, node, homebrew, tailscale, op-cli, openclaw, systemd, skills)
    • All parameterized with ProvisionContext instead of direct exec/fs imports
  • VM-side integration:

    • vm-cli/src/capabilities/context.ts: Real ProvisionContext implementation wiring SDK to vm-cli primitives
    • vm-cli/src/commands/provision/index.ts: Refactored to use runPhase() from capabilities registry
    • Removed old stage files: stages.ts, system.ts, tools.ts, openclaw.ts, workspace.ts
  • Host-side updates:

    • Removed host-core/src/agents-md.ts (moved to capabilities)
    • Updated provision.ts to write capability-aware config
    • Removed patchAgentsMd export (now VM-side responsibility)
  • Type system:

    • New capability types in @clawctl/types/src/capability.ts: CapabilityDef, CapabilityHook, ProvisionContext, ProvisionResult, etc.
    • ProvisionConfig moved from types.ts to capability.ts with backwards-compat fields (onePassword, tailscale)
    • Capability-aware schema in types/src/schemas/index.ts
  • Testing: Added comprehensive tests for registry and state modules

Notable Implementation Details

  • Multi-phase hooks: Capabilities can define hooks for pre/main/post timing within each lifecycle phase
  • Dependency resolution: Hooks are sorted by declared dependencies before execution
  • Idempotent migrations: Sequential version-based migrations run only when installed version differs from declared version
  • Backwards compatibility: Old config flags (onePassword, tailscale) still work via capability enabled() functions
  • Doctor checks: Capabilities contribute health checks that are collected and run by the doctor command
  • AGENTS.md patching: Now VM-side, assembled from capability contributions after workspace phase

https://claude.ai/code/session_01Mz4WN3iXvqi7hddiMjAkLx

claude added 10 commits March 16, 2026 08:24
- Add capability types (CapabilityDef, ProvisionContext, etc.) to @clawctl/types
- Create @clawctl/capabilities package with:
  - Helper modules (apt, node, systemd, homebrew, openclaw, tailscale, op-cli, skills)
  - Capability definitions (system-base, homebrew, openclaw, checkpoint, tailscale, one-password)
  - Registry with dependency resolution and pre/main/post hook timing
  - State tracking with sequential migration support
  - Runner (runPhase) replacing runStage
  - VM-side AGENTS.md writer
- Wire VM-side: ProvisionContext SDK, provision command, doctor command
- Add backwards-compatible provision config translation

https://claude.ai/code/session_01Mz4WN3iXvqi7hddiMjAkLx
- Wire host-side: provision.ts writes capabilities map, headless.ts maps
  config, bootstrap.ts removes patchAgentsMd, create.ts removes patchAgentsMd
- Delete old stage files (stages.ts, system.ts, tools.ts, openclaw.ts, workspace.ts)
- Delete old tool wrappers (apt, node, homebrew, tailscale, skills, op-cli)
- Delete host-side agents-md.ts (replaced by VM-side capability runner)
- Add registry tests (21 tests) and state tests (10 tests)
- Fix formatting across capability package files
- All 275 tests pass, lint clean, build succeeds

https://claude.ai/code/session_01Mz4WN3iXvqi7hddiMjAkLx
Remove stale task directory from failed plan mode session.
Create new task with full scope covering all PR review feedback.

https://claude.ai/code/session_01Mz4WN3iXvqi7hddiMjAkLx
- Rename ProvisionContext → CapabilityContext across all packages
- Add apt, systemd, agentsMd facets to CapabilityContext SDK
- Move registry (application wiring) from capabilities to vm-cli
- Colocate capability helpers into capability directories
- Inline skill content in checkpoint and one-password capabilities
- Replace agentsMdSection field with ctx.agentsMd.update() SDK action
- Update runner to receive resolved hooks (decouple from registry)
- Extract basePhase/hookTiming utilities to capabilities/util.ts
- Delete shared helpers/ directory, agents-md.ts, and registry.ts

All 275 tests pass. Lint and format clean. Binary builds.

https://claude.ai/code/session_01Mz4WN3iXvqi7hddiMjAkLx
The bootstrap prompt (openclaw agent --message) populates the base
AGENTS.md. Capability-contributed sections must be appended after that,
not during provision-workspace which runs before onboard.

- Move agents-md-checkpoint step from provision-workspace to bootstrap hook
- Move agents-md-one-password step from provision-workspace to bootstrap hook
- Add `claw provision bootstrap` subcommand
- Wire host to call `claw provision bootstrap` after the bootstrap prompt
- Remove stale comment about AGENTS.md in bootstrap.ts

https://claude.ai/code/session_01Mz4WN3iXvqi7hddiMjAkLx
New docs/capabilities.md covering the extension system: lifecycle
phases, hook timing, CapabilityContext SDK, writing capabilities,
the runner, state tracking, migrations, and AGENTS.md managed sections.

Updated vm-cli.md and vm-provisioning.md to reference the capabilities
system and include the bootstrap provision phase.

https://claude.ai/code/session_01Mz4WN3iXvqi7hddiMjAkLx
@TimBeyer TimBeyer merged commit d32fbef into main Mar 16, 2026
4 checks passed
@TimBeyer TimBeyer deleted the claude/plugin-extension-system-K72zG branch March 16, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants