Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions inc/Abilities/AbilityRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,13 @@

class AbilityRegistry {

public static function canonical_slug( string $slug ): string {
if ( str_starts_with($slug, 'datamachine/') ) {
return 'datamachine-code/' . substr($slug, strlen('datamachine/'));
}

return $slug;
}

/**
* Register a DMC-owned ability and, for shipped datamachine/* slugs, a deprecated alias.
* Register a DMC-owned ability.
*
* @param string $slug Legacy or canonical ability slug.
* @param string $slug Canonical ability slug.
* @param array<string,mixed> $args Ability registration args.
*/
public static function register( string $slug, array $args ): void {
$canonical = self::canonical_slug($slug);
wp_register_ability($canonical, $args);

if ( $canonical === $slug || ! str_starts_with($slug, 'datamachine/') ) {
return;
}

$alias_args = $args;
$alias_args['meta'] = array_merge(
$alias_args['meta'] ?? array(),
array(
'deprecated' => true,
'replacement' => $canonical,
)
);

wp_register_ability($slug, $alias_args);
wp_register_ability($slug, $args);
}
}
2 changes: 1 addition & 1 deletion inc/Abilities/CodeTaskAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct() {

public function register(): void {
AbilityRegistry::register(
'datamachine/create-code-task',
'datamachine-code/create-code-task',
array(
'label' => 'Create Code Task',
'description' => 'Create an isolated workspace worktree from a structured evidence packet.',
Expand Down
52 changes: 26 additions & 26 deletions inc/Abilities/GitHubAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function __construct() {
private function registerAbilities(): void {
$register_callback = function () {
AbilityRegistry::register(
'datamachine/list-github-issues',
'datamachine-code/list-github-issues',
array(
'label' => 'List GitHub Issues',
'description' => 'List issues from a GitHub repository with optional filters',
Expand Down Expand Up @@ -162,7 +162,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-issue',
'datamachine-code/get-github-issue',
array(
'label' => 'Get GitHub Issue',
'description' => 'Get a single GitHub issue with full details',
Expand Down Expand Up @@ -196,7 +196,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/update-github-issue',
'datamachine-code/update-github-issue',
array(
'label' => 'Update GitHub Issue',
'description' => 'Update a GitHub issue (title, body, labels, assignees, state)',
Expand Down Expand Up @@ -252,7 +252,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/create-github-issue',
'datamachine-code/create-github-issue',
array(
'label' => 'Create GitHub Issue',
'description' => 'Create a new GitHub issue with optional labels, assignees, and milestone',
Expand Down Expand Up @@ -304,7 +304,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/create-github-pull-request',
'datamachine-code/create-github-pull-request',
array(
'label' => 'Create GitHub Pull Request',
'description' => 'Open a new GitHub pull request from a head branch into a base branch',
Expand Down Expand Up @@ -371,7 +371,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/comment-github-issue',
'datamachine-code/comment-github-issue',
array(
'label' => 'Comment on GitHub Issue',
'description' => 'Add a comment to a GitHub issue',
Expand Down Expand Up @@ -413,7 +413,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/comment-github-pull-request',
'datamachine-code/comment-github-pull-request',
array(
'label' => 'Comment on GitHub Pull Request',
'description' => 'Add a comment to a GitHub pull request without broader issue-management permissions',
Expand Down Expand Up @@ -455,7 +455,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/add-github-labels',
'datamachine-code/add-github-labels',
array(
'label' => 'Add GitHub Labels',
'description' => 'Add one or more labels to a GitHub issue or pull request without replacing existing labels.',
Expand Down Expand Up @@ -487,7 +487,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/remove-github-label',
'datamachine-code/remove-github-label',
array(
'label' => 'Remove GitHub Label',
'description' => 'Remove a single label from a GitHub issue or pull request without touching other labels.',
Expand Down Expand Up @@ -518,7 +518,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/upsert-github-pull-review-comment',
'datamachine-code/upsert-github-pull-review-comment',
array(
'label' => 'Upsert GitHub Pull Request Review Comment',
'description' => 'Create or update one managed bot-authored GitHub pull request review comment identified by a hidden marker',
Expand Down Expand Up @@ -570,7 +570,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/merge-github-pull-request',
'datamachine-code/merge-github-pull-request',
array(
'label' => 'Merge GitHub Pull Request',
'description' => 'Merge an open GitHub pull request after verifying the expected head SHA',
Expand Down Expand Up @@ -623,7 +623,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/cleanup-github-pull-request',
'datamachine-code/cleanup-github-pull-request',
array(
'label' => 'Cleanup GitHub Pull Request',
'description' => 'Delete a merged pull request head branch through the GitHub API without checking out local branches',
Expand Down Expand Up @@ -672,7 +672,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/list-github-pulls',
'datamachine-code/list-github-pulls',
array(
'label' => 'List GitHub Pull Requests',
'description' => 'List pull requests from a GitHub repository',
Expand Down Expand Up @@ -715,7 +715,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-pull',
'datamachine-code/get-github-pull',
array(
'label' => 'Get GitHub Pull Request',
'description' => 'Get a single GitHub pull request with normalized metadata',
Expand Down Expand Up @@ -749,7 +749,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/list-github-pull-files',
'datamachine-code/list-github-pull-files',
array(
'label' => 'List GitHub Pull Request Files',
'description' => 'List changed files for a GitHub pull request',
Expand Down Expand Up @@ -792,7 +792,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-check-runs',
'datamachine-code/get-github-check-runs',
array(
'label' => 'Get GitHub Check Runs',
'description' => 'Get GitHub check runs for a commit SHA or ref with an overall summary',
Expand Down Expand Up @@ -837,7 +837,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-commit-statuses',
'datamachine-code/get-github-commit-statuses',
array(
'label' => 'Get GitHub Commit Statuses',
'description' => 'Get unmanaged GitHub commit statuses for a commit SHA or ref',
Expand Down Expand Up @@ -874,7 +874,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-actions-artifact',
'datamachine-code/get-github-actions-artifact',
array(
'label' => 'Get GitHub Actions Artifact',
'description' => 'Download a GitHub Actions artifact for a pull request or commit SHA and optionally parse JSON files from the ZIP',
Expand Down Expand Up @@ -928,7 +928,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-pull-review-context',
'datamachine-code/get-github-pull-review-context',
array(
'label' => 'Get GitHub Pull Request Review Context',
'description' => 'Get a review-ready payload for a GitHub pull request and its changed files',
Expand Down Expand Up @@ -1014,7 +1014,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-repo-review-profile',
'datamachine-code/get-github-repo-review-profile',
array(
'label' => 'Get GitHub Repository Review Profile',
'description' => 'Get bounded repository-level review context for a GitHub repository',
Expand Down Expand Up @@ -1064,7 +1064,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-pr-documentation-impact',
'datamachine-code/get-github-pr-documentation-impact',
array(
'label' => 'Get GitHub PR Documentation Impact',
'description' => 'Build a heuristic documentation-impact packet for a GitHub pull request',
Expand Down Expand Up @@ -1110,7 +1110,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/list-github-tree',
'datamachine-code/list-github-tree',
array(
'label' => 'List GitHub Repository Tree',
'description' => 'List files in a GitHub repository tree at a branch or ref',
Expand Down Expand Up @@ -1149,7 +1149,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/get-github-file',
'datamachine-code/get-github-file',
array(
'label' => 'Get GitHub Files',
'description' => 'Get decoded content for one or more files in a GitHub repository',
Expand Down Expand Up @@ -1200,7 +1200,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/create-or-update-github-file',
'datamachine-code/create-or-update-github-file',
array(
'label' => 'Create or Update GitHub File',
'description' => 'Create or update a file in a GitHub repository via the Contents API (upsert). If the file exists, it is updated; if not, it is created.',
Expand Down Expand Up @@ -1252,7 +1252,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/list-github-repos',
'datamachine-code/list-github-repos',
array(
'label' => 'List GitHub Repositories',
'description' => 'List repositories for a user or organization',
Expand Down Expand Up @@ -1299,7 +1299,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/github-status',
'datamachine-code/github-status',
array(
'label' => 'Get GitHub Integration Status',
'description' => 'Inspect GitHub authentication, default repository, and registered repository status.',
Expand Down
16 changes: 8 additions & 8 deletions inc/Abilities/GitSyncAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function registerAbilities(): void {
// -----------------------------------------------------------------

AbilityRegistry::register(
'datamachine/gitsync-list',
'datamachine-code/gitsync-list',
array(
'label' => 'List GitSync Bindings',
'description' => 'List every registered GitSync binding with a lightweight summary.',
Expand All @@ -84,7 +84,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/gitsync-status',
'datamachine-code/gitsync-status',
array(
'label' => 'GitSync Binding Status',
'description' => 'Report on-disk + upstream status for a single GitSync binding.',
Expand Down Expand Up @@ -122,7 +122,7 @@ private function registerAbilities(): void {
// -----------------------------------------------------------------

AbilityRegistry::register(
'datamachine/gitsync-bind',
'datamachine-code/gitsync-bind',
array(
'label' => 'Bind GitSync Path',
'description' => 'Register a binding between a site-owned local directory (relative to ABSPATH) and a GitHub repository. First pull materializes files.',
Expand Down Expand Up @@ -153,7 +153,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/gitsync-unbind',
'datamachine-code/gitsync-unbind',
array(
'label' => 'Unbind GitSync Path',
'description' => 'Remove a binding. Directory preserved by default; pass purge=true to delete it.',
Expand Down Expand Up @@ -182,7 +182,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/gitsync-pull',
'datamachine-code/gitsync-pull',
array(
'label' => 'Pull GitSync Binding',
'description' => 'Download all files from the pinned branch to the local directory. Uses GitHub Contents API — no git binary required.',
Expand Down Expand Up @@ -219,7 +219,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/gitsync-submit',
'datamachine-code/gitsync-submit',
array(
'label' => 'Submit GitSync Binding as Pull Request',
'description' => 'Upload changed local files to the sticky proposal branch (gitsync/<slug>) by default, or to a keyed proposal branch (gitsync/<slug>-<proposal-slug>) when proposal is provided, and open or update a PR against the pinned branch.',
Expand Down Expand Up @@ -262,7 +262,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/gitsync-push',
'datamachine-code/gitsync-push',
array(
'label' => 'Push GitSync Binding Directly',
'description' => 'Commit changed local files directly to the pinned branch — no PR. Requires policy.write_enabled=true AND policy.safe_direct_push=true (two-key authorization).',
Expand Down Expand Up @@ -296,7 +296,7 @@ private function registerAbilities(): void {
);

AbilityRegistry::register(
'datamachine/gitsync-policy-update',
'datamachine-code/gitsync-policy-update',
array(
'label' => 'Update GitSync Binding Policy',
'description' => 'Update one or more policy fields on an existing binding (write_enabled, safe_direct_push, allowed_paths, conflict, auto_pull, pull_interval).',
Expand Down
Loading
Loading