execute method

  1. @override
Future<CommandResult> execute(
  1. String args,
  2. ToolUseContext context
)
override

Execute and return result via callback.

Implementation

@override
Future<CommandResult> execute(String args, ToolUseContext context) async {
  final blurb = args.trim();

  // Bare /ultraplan (no args) just shows usage.
  if (blurb.isEmpty) {
    return TextCommandResult(
      [
        'Usage: /ultraplan <prompt>, or include "ultraplan" anywhere',
        'in your prompt',
        '',
        'Advanced multi-agent plan mode with our most powerful model',
        '(Opus). Runs in Neomage on the web. When the plan is ready,',
        'you can execute it in the web session or send it back here.',
        'Terminal stays free while the remote plans.',
        'Requires /login.',
        '',
        'Terms: $ccrTermsUrl',
      ].join('\n'),
    );
  }

  // Check eligibility.
  final eligibility = await checkRemoteAgentEligibility();
  if (!eligibility.eligible) {
    final reasons = eligibility.errors
        .map(formatPreconditionError)
        .join('\n');
    return TextCommandResult(
      'ultraplan: cannot launch remote session --\n$reasons',
    );
  }

  // Build the prompt.
  final prompt = buildUltraplanPrompt(blurb);

  // In the full implementation, this would:
  // 1. Set ultraplanLaunchPending in app state (shows pre-launch dialog)
  // 2. The dialog handles terms acceptance, then calls launchUltraplan
  // 3. launchUltraplan calls teleportToRemote and starts polling
  //
  // For the Dart port, we return the launch message and delegate to the
  // controller for the async flow.

  return TextCommandResult(
    '$diamondOpen ultraplan\n'
    'Starting Neomage on the web...\n\n'
    'Prompt: $blurb\n\n'
    'The remote session will draft an advanced plan using Opus.\n'
    'When ready, you can approve and execute it from the web interface\n'
    'or send it back here for local execution.',
  );
}