Skip to content

Conversation

@jmarx
Copy link
Collaborator

@jmarx jmarx commented Oct 31, 2025

Description of the Change

Closes #

How to test the Change

Changelog Entry

Added - New feature
Changed - Existing functionality
Deprecated - Soon-to-be removed feature
Removed - Feature
Fixed - Bug fix
Security - Vulnerability

Credits

Props @username, @username2, ...

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@what-the-diff
Copy link

what-the-diff bot commented Oct 31, 2025

PR Summary

  • Incorporation of Abilities Integration Instance
    With this change, we've added a function call within our class setup process that initiates the instance of Abilities Integration. This addition should improve our ability to integrate different class functionalities in a smoother and more efficient way.

@mauteri
Copy link
Contributor

mauteri commented Oct 31, 2025

@jmarx quick notes:

  1. Let's put the classes in a subdirectory called ai
  2. Move your settings to the GatherPress Settings under a new tab called AI. Add a dropdown for service (OpenAI) for now and a field for API key.

This looks great! Thx!

// Handle relative patterns first (next, last, this, tomorrow, yesterday).
$relative_weekday_pattern = '/^(next|last|this)\s+'
. '(monday|tuesday|wednesday|thursday|friday|saturday|sunday)$/i';
if ( preg_match( $relative_weekday_pattern, $pattern_low, $matches ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this would be a cleaner approach than this super long if/elseif statement.

private function get_pattern_handlers(): array {
	return [
		'/^(next|last|this)\s+(monday|tuesday|...)$/i' => 'handle_relative_weekday',
		'/^(tomorrow|yesterday)$/i' => 'handle_relative_day',
		// ...
	];
}

private function calculate_recurring_dates( string $pattern, int $occurrences, \DateTime $start ): array {
	foreach ( $this->get_pattern_handlers() as $regex => $method ) {
		if ( preg_match( $regex, $pattern, $matches ) ) {
			return $this->$method( $matches, $occurrences, $start );
		}
	}
	return array();
}

private function get_nth_weekday_of_month( int $year, int $month, string $weekday, int $nth ): string {
if ( -1 === $nth ) {
// Last occurrence.
$date = new \DateTime( "last {$weekday} of {$year}-{$month}" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add use DateTime at top of file and call new DateTime (here and everywhere)

private function get_gatherpress_functions() {
// Check if external AI plugin's calculate-dates ability is available.
// If so, use it instead of GatherPress's own implementation.
$calculate_dates_ability = Abilities_Integration::get_calculate_dates_ability();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems variable is only used once, so no need to set the variable, just include it in the array.

'tool_choice' => 'auto',
);

$response = wp_remote_post(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Max iterations reached.
return array(
'response' => 'Task partially completed. Maximum iterations reached.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need translation function?

),
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make the AI Experiments plugin a dependency of this feature. Not sure when/if that code is making it into core eventually. But we should be utilizing core settings when we can and not including our own settings of the same thing. Maybe get some guidance here from @jeffpaul

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauteri very hard disagree. But just wait a bit for my latest stuff :) I'll explain what im doing

$status.show();

// Send to backend
$.ajax( {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to REST API and use apiFetch

@@ -0,0 +1,168 @@
.gp-ai-assistant {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to prepend with gatherpress- not gp-

),
utility_style: path.resolve( process.cwd(), 'src', 'utility.scss' ),
'ai-assistant': path.resolve( process.cwd(), 'src/ai', 'index.js' ),
'ai-assistant-style': path.resolve( process.cwd(), 'src/ai', 'style.scss' ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use underscores to keep format.

jmarx added 20 commits January 2, 2026 11:45
- Extract and return model/provider metadata from AI responses
- Display model info (provider and model name) in AI Assistant UI with styling
- Add admin notice on wp-ai-client settings page recommending OpenAI
- Update font size for model info display to 13px
- Test MAX_ITERATIONS constant
- Test process_prompt with various error conditions
- Test has_api_key method with different scenarios
- Test get_gatherpress_abilities method
- Test function_name_to_ability_name conversion
- Test method existence for private methods using reflection
- All 20 tests pass (3 skipped when dependencies not available)
- Fix line length issues by breaking long lines
- Add @throws tag to process_conversation_loop method
- Add phpcs:ignore for empty catch block with explanation
- Add phpcs:ignore for translation strings that exceed line length
- Fix inline comment punctuation
- All errors resolved, warnings suppressed with appropriate comments
- Fix empty catch block by adding code (set provider_name to empty string)
- Fix line length issues by shortening translation strings
- Add @throws tag to process_conversation_loop method
- Fix inline comment punctuation
- All errors and warnings resolved (0 errors, 0 warnings)
- Break long translation string across multiple lines
- All linting issues resolved for class-setup.php
…, init_wp_ai_client, increase_ai_request_timeout)
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

Preview changes with Playground

You can preview the recent changes for PR#1204 with the following PHP versions:

PHP Version 8.4

PHP Version 8.2

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

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