From 44c745d2d7ac3e4aea98cfba65cbe8f140c93b26 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 14 Apr 2026 15:07:06 -0400 Subject: [PATCH] feat: ability categories and tool-ability linkage Register datamachine-code/workspace and datamachine-code/github ability categories. Update all 23 ability registrations from flat 'datamachine' to the proper subcategory. Add ability metadata to all tool registerTool() calls (workspace tools linked to abilities, GitHub tools with access_level). Companion to Extra-Chill/data-machine#1052. --- data-machine-code.php | 18 +++++++++++++++- inc/Abilities/GitHubAbilities.php | 12 +++++------ inc/Abilities/WorkspaceAbilities.php | 32 ++++++++++++++-------------- inc/Tools/GitHubIssueTool.php | 2 +- inc/Tools/GitHubTools.php | 10 ++++----- inc/Tools/WorkspaceTools.php | 10 ++++----- 6 files changed, 50 insertions(+), 34 deletions(-) diff --git a/data-machine-code.php b/data-machine-code.php index 8c971d9..35eebda 100644 --- a/data-machine-code.php +++ b/data-machine-code.php @@ -64,12 +64,28 @@ function datamachine_code_register_system_abilities() { return; } + wp_register_ability_category( + 'datamachine-code/workspace', + array( + 'label' => __( 'Code Workspace', 'data-machine-code' ), + 'description' => __( 'Git workspace management — clone, read, write, edit, and git operations.', 'data-machine-code' ), + ) + ); + + wp_register_ability_category( + 'datamachine-code/github', + array( + 'label' => __( 'GitHub', 'data-machine-code' ), + 'description' => __( 'GitHub issue, pull request, and repository operations.', 'data-machine-code' ), + ) + ); + wp_register_ability( 'datamachine/create-github-issue', array( 'label' => 'Create GitHub Issue', 'description' => 'Create a new GitHub issue in a repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/github', 'input_schema' => array( 'type' => 'object', 'required' => array( 'title' ), diff --git a/inc/Abilities/GitHubAbilities.php b/inc/Abilities/GitHubAbilities.php index ea70176..7f0b2ab 100644 --- a/inc/Abilities/GitHubAbilities.php +++ b/inc/Abilities/GitHubAbilities.php @@ -56,7 +56,7 @@ private function registerAbilities(): void { array( 'label' => 'List GitHub Issues', 'description' => 'List issues from a GitHub repository with optional filters', - 'category' => 'datamachine', + 'category' => 'datamachine-code/github', 'input_schema' => array( 'type' => 'object', 'required' => array( 'repo' ), @@ -111,7 +111,7 @@ private function registerAbilities(): void { array( 'label' => 'Get GitHub Issue', 'description' => 'Get a single GitHub issue with full details', - 'category' => 'datamachine', + 'category' => 'datamachine-code/github', 'input_schema' => array( 'type' => 'object', 'required' => array( 'repo', 'issue_number' ), @@ -145,7 +145,7 @@ private function registerAbilities(): void { array( 'label' => 'Update GitHub Issue', 'description' => 'Update a GitHub issue (title, body, labels, assignees, state)', - 'category' => 'datamachine', + 'category' => 'datamachine-code/github', 'input_schema' => array( 'type' => 'object', 'required' => array( 'repo', 'issue_number' ), @@ -199,7 +199,7 @@ private function registerAbilities(): void { array( 'label' => 'Comment on GitHub Issue', 'description' => 'Add a comment to a GitHub issue', - 'category' => 'datamachine', + 'category' => 'datamachine-code/github', 'input_schema' => array( 'type' => 'object', 'required' => array( 'repo', 'issue_number', 'body' ), @@ -237,7 +237,7 @@ private function registerAbilities(): void { array( 'label' => 'List GitHub Pull Requests', 'description' => 'List pull requests from a GitHub repository', - 'category' => 'datamachine', + 'category' => 'datamachine-code/github', 'input_schema' => array( 'type' => 'object', 'required' => array( 'repo' ), @@ -280,7 +280,7 @@ private function registerAbilities(): void { array( 'label' => 'List GitHub Repositories', 'description' => 'List repositories for a user or organization', - 'category' => 'datamachine', + 'category' => 'datamachine-code/github', 'input_schema' => array( 'type' => 'object', 'required' => array( 'owner' ), diff --git a/inc/Abilities/WorkspaceAbilities.php b/inc/Abilities/WorkspaceAbilities.php index 572183f..ab7b510 100644 --- a/inc/Abilities/WorkspaceAbilities.php +++ b/inc/Abilities/WorkspaceAbilities.php @@ -50,7 +50,7 @@ private function registerAbilities(): void { array( 'label' => 'Get Workspace Path', 'description' => 'Get the agent workspace directory path. Optionally create the directory.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -80,7 +80,7 @@ private function registerAbilities(): void { array( 'label' => 'List Workspace Repos', 'description' => 'List repositories in the agent workspace.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array(), @@ -116,7 +116,7 @@ private function registerAbilities(): void { array( 'label' => 'Show Workspace Repo', 'description' => 'Show detailed info about a workspace repository (branch, remote, latest commit, dirty status).', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -154,7 +154,7 @@ private function registerAbilities(): void { array( 'label' => 'Read Workspace File', 'description' => 'Read the contents of a text file from a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -203,7 +203,7 @@ private function registerAbilities(): void { array( 'label' => 'List Workspace Directory', 'description' => 'List directory contents within a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -252,7 +252,7 @@ private function registerAbilities(): void { array( 'label' => 'Clone Workspace Repo', 'description' => 'Clone a git repository into the workspace.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -287,7 +287,7 @@ private function registerAbilities(): void { array( 'label' => 'Remove Workspace Repo', 'description' => 'Remove a repository from the workspace.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -316,7 +316,7 @@ private function registerAbilities(): void { array( 'label' => 'Write Workspace File', 'description' => 'Create or overwrite a file in a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -355,7 +355,7 @@ private function registerAbilities(): void { array( 'label' => 'Edit Workspace File', 'description' => 'Find-and-replace text in a workspace repository file.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -401,7 +401,7 @@ private function registerAbilities(): void { array( 'label' => 'Workspace Git Status', 'description' => 'Get git status information for a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -439,7 +439,7 @@ private function registerAbilities(): void { array( 'label' => 'Workspace Git Log', 'description' => 'Read git log entries for a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -484,7 +484,7 @@ private function registerAbilities(): void { array( 'label' => 'Workspace Git Diff', 'description' => 'Read git diff output for a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -530,7 +530,7 @@ private function registerAbilities(): void { array( 'label' => 'Workspace Git Pull', 'description' => 'Run git pull --ff-only for a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -564,7 +564,7 @@ private function registerAbilities(): void { array( 'label' => 'Workspace Git Add', 'description' => 'Stage repository paths with git add.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -603,7 +603,7 @@ private function registerAbilities(): void { array( 'label' => 'Workspace Git Commit', 'description' => 'Commit staged changes in a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( @@ -638,7 +638,7 @@ private function registerAbilities(): void { array( 'label' => 'Workspace Git Push', 'description' => 'Push commits for a workspace repository.', - 'category' => 'datamachine', + 'category' => 'datamachine-code/workspace', 'input_schema' => array( 'type' => 'object', 'properties' => array( diff --git a/inc/Tools/GitHubIssueTool.php b/inc/Tools/GitHubIssueTool.php index 9146891..e9f6af8 100644 --- a/inc/Tools/GitHubIssueTool.php +++ b/inc/Tools/GitHubIssueTool.php @@ -28,7 +28,7 @@ class GitHubIssueTool extends BaseTool { * Constructor. */ public function __construct() { - $this->registerTool( 'create_github_issue', array( $this, 'getToolDefinition' ), array( 'chat', 'pipeline' ) ); + $this->registerTool( 'create_github_issue', array( $this, 'getToolDefinition' ), array( 'chat', 'pipeline' ), array( 'ability' => 'datamachine/create-github-issue' ) ); } /** diff --git a/inc/Tools/GitHubTools.php b/inc/Tools/GitHubTools.php index 0bc4355..8140595 100644 --- a/inc/Tools/GitHubTools.php +++ b/inc/Tools/GitHubTools.php @@ -24,11 +24,11 @@ class GitHubTools extends BaseTool { */ public function __construct() { $contexts = array( 'chat', 'pipeline' ); - $this->registerTool( 'list_github_issues', array( $this, 'getListIssuesDefinition' ), $contexts ); - $this->registerTool( 'get_github_issue', array( $this, 'getGetIssueDefinition' ), $contexts ); - $this->registerTool( 'manage_github_issue', array( $this, 'getManageIssueDefinition' ), $contexts ); - $this->registerTool( 'list_github_pulls', array( $this, 'getListPullsDefinition' ), $contexts ); - $this->registerTool( 'list_github_repos', array( $this, 'getListReposDefinition' ), $contexts ); + $this->registerTool( 'list_github_issues', array( $this, 'getListIssuesDefinition' ), $contexts, array( 'access_level' => 'editor' ) ); + $this->registerTool( 'get_github_issue', array( $this, 'getGetIssueDefinition' ), $contexts, array( 'access_level' => 'editor' ) ); + $this->registerTool( 'manage_github_issue', array( $this, 'getManageIssueDefinition' ), $contexts, array( 'access_level' => 'editor' ) ); + $this->registerTool( 'list_github_pulls', array( $this, 'getListPullsDefinition' ), $contexts, array( 'access_level' => 'editor' ) ); + $this->registerTool( 'list_github_repos', array( $this, 'getListReposDefinition' ), $contexts, array( 'access_level' => 'editor' ) ); } /** diff --git a/inc/Tools/WorkspaceTools.php b/inc/Tools/WorkspaceTools.php index 9e32b0f..c0dfc8f 100644 --- a/inc/Tools/WorkspaceTools.php +++ b/inc/Tools/WorkspaceTools.php @@ -54,11 +54,11 @@ public function check_configuration( $configured, $tool_id ) { */ public function __construct() { $contexts = array( 'chat', 'pipeline' ); - $this->registerTool( 'workspace_path', array( $this, 'getPathDefinition' ), $contexts ); - $this->registerTool( 'workspace_list', array( $this, 'getListDefinition' ), $contexts ); - $this->registerTool( 'workspace_show', array( $this, 'getShowDefinition' ), $contexts ); - $this->registerTool( 'workspace_ls', array( $this, 'getLsDefinition' ), $contexts ); - $this->registerTool( 'workspace_read', array( $this, 'getReadDefinition' ), $contexts ); + $this->registerTool( 'workspace_path', array( $this, 'getPathDefinition' ), $contexts, array( 'ability' => 'datamachine/workspace-path' ) ); + $this->registerTool( 'workspace_list', array( $this, 'getListDefinition' ), $contexts, array( 'ability' => 'datamachine/workspace-list' ) ); + $this->registerTool( 'workspace_show', array( $this, 'getShowDefinition' ), $contexts, array( 'ability' => 'datamachine/workspace-show' ) ); + $this->registerTool( 'workspace_ls', array( $this, 'getLsDefinition' ), $contexts, array( 'ability' => 'datamachine/workspace-ls' ) ); + $this->registerTool( 'workspace_read', array( $this, 'getReadDefinition' ), $contexts, array( 'ability' => 'datamachine/workspace-read' ) ); } /**