Skip to content

Latest commit

 

History

History
134 lines (104 loc) · 5.31 KB

File metadata and controls

134 lines (104 loc) · 5.31 KB

Data Machine Code

Developer tools extension for Data Machine. GitHub integration, workspace management, git operations, and code tools for WordPress AI agents.

What It Does

Data Machine Code extracts developer-oriented tooling from Data Machine core into a standalone extension. Not every WordPress site needs GitHub integration or workspace management — but if you're using Data Machine as a coding agent platform, this plugin gives your agents the tools to work with code repositories directly from WordPress.

Features

GitHub Integration

  • List, view, update, close, and comment on issues
  • List pull requests and repositories
  • Create issues (async via Action Scheduler)
  • GitHub fetch handler for pipeline workflows

Workspace Management

  • Clone and manage git repositories in a secure workspace directory
  • Read, write, and edit files within workspace repos
  • List directory contents with file metadata

Git Operations

  • Status, log, diff (read-only)
  • Pull, add, commit, push (policy-controlled)
  • Per-repo write/push policies with path allowlists and branch restrictions

AI Agent Tools

  • 10 chat tools for GitHub and workspace operations
  • Async GitHub issue creation via system tasks
  • All tools register through Data Machine's tool system

WP-CLI

# GitHub
wp datamachine-code github issues --repo=owner/repo
wp datamachine-code github view 123 --repo=owner/repo
wp datamachine-code github close 123 --repo=owner/repo
wp datamachine-code github comment 123 "Fixed." --repo=owner/repo
wp datamachine-code github pulls --repo=owner/repo
wp datamachine-code github repos owner
wp datamachine-code github status

# Workspace
wp datamachine-code workspace path
wp datamachine-code workspace list
wp datamachine-code workspace clone https://github.com/org/repo.git
wp datamachine-code workspace show repo-name

# Worktrees — one per branch, parallel-safe
wp datamachine-code workspace worktree add repo-name fix/foo
wp datamachine-code workspace worktree list
wp datamachine-code workspace worktree remove repo-name fix/foo
wp datamachine-code workspace worktree prune

# All read/write/git ops accept either <repo> (primary) or <repo>@<branch-slug> (worktree)
wp datamachine-code workspace read repo-name@fix-foo src/main.php
wp datamachine-code workspace ls repo-name@fix-foo src/
wp datamachine-code workspace write repo-name@fix-foo path/to/file.txt @content.txt
wp datamachine-code workspace edit repo-name@fix-foo path/to/file.txt --old="foo" --new="bar"
wp datamachine-code workspace remove repo-name
wp datamachine-code workspace git status repo-name@fix-foo
wp datamachine-code workspace git pull repo-name@fix-foo
wp datamachine-code workspace git add repo-name@fix-foo --path=src/file.php
wp datamachine-code workspace git commit repo-name@fix-foo "fix: something"
wp datamachine-code workspace git push repo-name@fix-foo
wp datamachine-code workspace git log repo-name@fix-foo
wp datamachine-code workspace git diff repo-name@fix-foo

Worktrees: parallel-safe branch work

The workspace is worktree-native. Each branch lives in its own directory at <workspace>/<repo>@<branch-slug> (slashes in branch names become dashes). Multiple agent sessions can edit different branches of the same repo simultaneously without stepping on each other.

The primary checkout (bare <repo>) is read-only by default for mutating operations — pass --allow-primary-mutation to override. The default-deny is intentional: the primary tracks the deployed branch, and silent branch-switches on it are how parallel agents corrupt each other's work.

~/.datamachine/workspace/
├── data-machine/                    ← primary, hands-off by default
├── data-machine@fix-foo/            ← worktree for fix/foo
└── data-machine@feat-bar/           ← worktree for feat/bar

Requirements

Installation

  1. Install and activate Data Machine core
  2. Clone this repo to wp-content/plugins/data-machine-code
  3. Run composer install
  4. Activate the plugin

Configuration

Set your GitHub Personal Access Token and default repository in Data Machine settings:

  • github_pat — GitHub Personal Access Token with repo access
  • github_default_repo — Default repository in owner/repo format

Workspace git policies are configured via the datamachine_workspace_git_policies option for per-repo write/push controls.

Architecture

data-machine (core)
├── AI engine, pipelines, jobs, agents
├── Memory system, tools framework
└── Base classes for extensions
    │
    ├── data-machine-socials (social platforms)
    ├── data-machine-code (developer tools) ← this plugin
    └── data-machine-business (transforms)

Data Machine Code extends core base classes (BaseTool, SystemTask, BaseCommand, FetchHandler) and registers its capabilities through standard Data Machine hooks (datamachine_tools, datamachine_tasks, Abilities API).

Roadmap

  • Phase 1: Core extraction complete, own settings management
  • Phase 2: New dev tools — grep, search, code analysis, enhanced git
  • Phase 3: Full PR workflow — autonomous code changes
  • Phase 4: Multi-repo orchestration, webhooks, admin UI

License

GPL v2 or later