@@ -55,14 +55,11 @@ public function clone_repo( string $url, ?string $name = null ): array|\WP_Error
5555 $ this ->save_state ($ state );
5656
5757 return array (
58- 'success ' => true ,
59- 'backend ' => 'github_api ' ,
60- 'name ' => $ name ,
61- 'path ' => 'github:// ' . $ repo ,
62- 'message ' => sprintf ('Registered %s as remote workspace "%s". ' , $ repo , $ name ),
63- 'conversation_state ' => 'incomplete ' ,
64- 'next_required_tool ' => 'workspace_worktree_add ' ,
65- 'next_required_args ' => array ( 'repo ' => $ name ),
58+ 'success ' => true ,
59+ 'backend ' => 'github_api ' ,
60+ 'name ' => $ name ,
61+ 'path ' => 'github:// ' . $ repo ,
62+ 'message ' => sprintf ('Registered %s as remote workspace "%s". ' , $ repo , $ name ),
6663 );
6764 }
6865
@@ -97,17 +94,14 @@ public function worktree_add( string $repo_name, string $branch, ?string $from =
9794 $ this ->save_state ($ state );
9895
9996 return array (
100- 'success ' => true ,
101- 'backend ' => 'github_api ' ,
102- 'handle ' => $ handle ,
103- 'path ' => 'github:// ' . $ repo . '# ' . $ branch ,
104- 'branch ' => $ branch ,
105- 'slug ' => $ slug ,
106- 'created_branch ' => true ,
107- 'message ' => sprintf ('Registered remote workspace %s for %s. ' , $ handle , $ repo ),
108- 'conversation_state ' => 'incomplete ' ,
109- 'next_required_tool ' => 'workspace_read or workspace_edit or workspace_write ' ,
110- 'next_required_args ' => array ( 'repo ' => $ handle ),
97+ 'success ' => true ,
98+ 'backend ' => 'github_api ' ,
99+ 'handle ' => $ handle ,
100+ 'path ' => 'github:// ' . $ repo . '# ' . $ branch ,
101+ 'branch ' => $ branch ,
102+ 'slug ' => $ slug ,
103+ 'created_branch ' => true ,
104+ 'message ' => sprintf ('Registered remote workspace %s for %s. ' , $ handle , $ repo ),
111105 );
112106 }
113107
@@ -332,14 +326,12 @@ public function write_file( string $handle, string $path, string $content ): arr
332326 $ this ->save_state ($ state );
333327
334328 return array (
335- 'success ' => true ,
336- 'backend ' => 'github_api ' ,
337- 'path ' => $ path ,
338- 'size ' => strlen ($ content ),
339- 'created ' => true ,
340- 'conversation_state ' => 'incomplete ' ,
341- 'next_required_tool ' => 'workspace_git_status ' ,
342- 'next_required_args ' => array ( 'name ' => $ context ['handle ' ] ),
329+ 'success ' => true ,
330+ 'backend ' => 'github_api ' ,
331+ 'name ' => $ context ['handle ' ],
332+ 'path ' => $ path ,
333+ 'size ' => strlen ($ content ),
334+ 'created ' => true ,
343335 );
344336 }
345337
@@ -390,13 +382,11 @@ public function edit_file( string $handle, string $path, string $old_string, str
390382 }
391383
392384 return array (
393- 'success ' => true ,
394- 'backend ' => 'github_api ' ,
395- 'path ' => $ write ['path ' ],
396- 'replacements ' => $ replace_all ? $ count : 1 ,
397- 'conversation_state ' => 'incomplete ' ,
398- 'next_required_tool ' => 'workspace_git_status ' ,
399- 'next_required_args ' => array ( 'name ' => $ context ['handle ' ] ),
385+ 'success ' => true ,
386+ 'backend ' => 'github_api ' ,
387+ 'name ' => $ context ['handle ' ],
388+ 'path ' => $ write ['path ' ],
389+ 'replacements ' => $ replace_all ? $ count : 1 ,
400390 );
401391 }
402392
@@ -494,20 +484,17 @@ public function git_status( string $handle ): array|\WP_Error {
494484
495485 $ files = array_values (array_unique (array_values ( (array ) $ context ['changed_files ' ])));
496486 return array (
497- 'success ' => true ,
498- 'backend ' => 'github_api ' ,
499- 'name ' => $ handle ,
500- 'repo ' => $ context ['repo_name ' ],
501- 'is_worktree ' => true ,
502- 'path ' => 'github:// ' . $ context ['repo ' ] . '# ' . $ context ['branch ' ],
503- 'branch ' => $ context ['branch ' ],
504- 'remote ' => 'https://github.com/ ' . $ context ['repo ' ] . '.git ' ,
505- 'commit ' => '' !== $ context ['last_commit_sha ' ] ? $ context ['last_commit_sha ' ] : null ,
506- 'dirty ' => count ($ files ),
507- 'files ' => $ files ,
508- 'conversation_state ' => 'incomplete ' ,
509- 'next_required_tool ' => count ($ files ) > 0 ? 'workspace_git_commit ' : 'workspace_edit or workspace_write ' ,
510- 'next_required_args ' => array ( 'name ' => $ handle ),
487+ 'success ' => true ,
488+ 'backend ' => 'github_api ' ,
489+ 'name ' => $ handle ,
490+ 'repo ' => $ context ['repo_name ' ],
491+ 'is_worktree ' => true ,
492+ 'path ' => 'github:// ' . $ context ['repo ' ] . '# ' . $ context ['branch ' ],
493+ 'branch ' => $ context ['branch ' ],
494+ 'remote ' => 'https://github.com/ ' . $ context ['repo ' ] . '.git ' ,
495+ 'commit ' => '' !== $ context ['last_commit_sha ' ] ? $ context ['last_commit_sha ' ] : null ,
496+ 'dirty ' => count ($ files ),
497+ 'files ' => $ files ,
511498 );
512499 }
513500
@@ -583,17 +570,12 @@ public function git_commit( string $handle, string $message ): array|\WP_Error {
583570 $ this ->save_state ($ state );
584571
585572 return array (
586- 'success ' => true ,
587- 'backend ' => 'github_api ' ,
588- 'name ' => $ handle ,
589- 'commit ' => $ last_sha ,
590- 'message ' => sprintf ('Committed remote workspace changes to %s. ' , $ context ['branch ' ]),
591- 'conversation_state ' => 'incomplete ' ,
592- 'next_required_tool ' => 'workspace_git_push ' ,
593- 'next_required_args ' => array (
594- 'name ' => $ handle ,
595- 'branch ' => $ context ['branch ' ],
596- ),
573+ 'success ' => true ,
574+ 'backend ' => 'github_api ' ,
575+ 'name ' => $ handle ,
576+ 'branch ' => $ context ['branch ' ],
577+ 'commit ' => $ last_sha ,
578+ 'message ' => sprintf ('Committed remote workspace changes to %s. ' , $ context ['branch ' ]),
597579 );
598580 }
599581
@@ -1043,24 +1025,18 @@ public function git_push( string $handle, string $remote = 'origin', ?string $br
10431025 $ branch_url = '' !== $ push_branch ? 'https://github.com/ ' . $ context ['repo ' ] . '/tree/ ' . rawurlencode ($ push_branch ) : null ;
10441026
10451027 return array (
1046- 'success ' => true ,
1047- 'kind ' => 'branch_push ' ,
1048- 'backend ' => 'github_api ' ,
1049- 'name ' => $ handle ,
1050- 'repo ' => $ context ['repo ' ],
1051- 'workspace_repo ' => $ context ['repo_name ' ] ?? $ handle ,
1052- 'github_repo ' => $ context ['repo ' ],
1053- 'remote ' => $ remote ,
1054- 'branch ' => $ push_branch ,
1055- 'url ' => $ branch_url ,
1056- 'html_url ' => $ branch_url ,
1057- 'message ' => 'Remote workspace branch already updated via GitHub API. ' ,
1058- 'conversation_state ' => 'incomplete ' ,
1059- 'next_required_tool ' => 'create_github_pull_request ' ,
1060- 'next_required_args ' => array (
1061- 'repo ' => $ context ['repo ' ],
1062- 'head ' => $ push_branch ,
1063- ),
1028+ 'success ' => true ,
1029+ 'kind ' => 'branch_push ' ,
1030+ 'backend ' => 'github_api ' ,
1031+ 'name ' => $ handle ,
1032+ 'repo ' => $ context ['repo ' ],
1033+ 'workspace_repo ' => $ context ['repo_name ' ] ?? $ handle ,
1034+ 'github_repo ' => $ context ['repo ' ],
1035+ 'remote ' => $ remote ,
1036+ 'branch ' => $ push_branch ,
1037+ 'url ' => $ branch_url ,
1038+ 'html_url ' => $ branch_url ,
1039+ 'message ' => 'Remote workspace branch already updated via GitHub API. ' ,
10641040 );
10651041 }
10661042
0 commit comments