Files
MokoCLI/lib/Enterprise/RecoverySuggestion.php
T
jmiller 4009d68a7a
Universal: PR Check / Branch Policy (pull_request) Failing after 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Generic: Repo Health / Access control (pull_request) Successful in 3s
Universal: PR Check / Validate PR (pull_request) Failing after 14s
Universal: PR Check / Secret Scan (pull_request) Successful in 15s
Generic: Project CI / Lint & Validate (pull_request) Successful in 57s
Platform: mokocli CI / Gate 1: Code Quality (pull_request) Successful in 2m4s
Universal: Build & Release / Promote to RC (pull_request) Has been skipped
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Branch Cleanup / Delete merged branch (pull_request) Successful in 2s
Universal: Build & Release / Build & Release Pipeline (pull_request) Successful in 35s
Universal: Workflow Sync Trigger / Sync workflows to live repos (pull_request) Failing after 28m16s
Generic: Project CI / Tests (pull_request) Has been cancelled
Platform: mokocli CI / Gate 2: Unit Tests (8.1) (pull_request) Has been cancelled
Platform: mokocli CI / Gate 2: Unit Tests (8.2) (pull_request) Has been cancelled
Platform: mokocli CI / Gate 2: Unit Tests (8.3) (pull_request) Has been cancelled
Platform: mokocli CI / Gate 3: Self-Health Check (pull_request) Has been cancelled
Platform: mokocli CI / Gate 4: Governance (pull_request) Has been cancelled
Platform: mokocli CI / Gate 5: Template Integrity (pull_request) Has been cancelled
Platform: mokocli CI / CI Summary (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report: Scripts Governance (pull_request) Has been cancelled
Generic: Repo Health / Report: Repository Health (pull_request) Has been cancelled
chore: rename all mokoplatform -> mokocli references
The repo was renamed mokoplatform -> mokocli; this rewrites every stale
reference across the tree (case-sensitive):

  MokoPlatform  -> MokoCLI   (DEFGROUP/INGROUP doc tags)
  mokoplatform  -> mokocli   (repo URLs, /opt & /tmp paths, clone URLs,
                              EXCLUDE lists, XML xmlns + <root> namespace)
  moko-platform -> moko-cli  (marker files)

XML namespace URIs and ManifestParser::NAMESPACE_URI are changed in
lockstep so local manifest-vs-parser validation stays consistent. The
external standards.mokoconsulting.tech namespace endpoint must be updated
to match separately (tracked in #336).

Refs #336

Claude-Session: https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
2026-07-05 15:25:45 -05:00

95 lines
2.7 KiB
PHP

<?php
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
* SPDX-License-Identifier: GPL-3.0-or-later
* FILE INFORMATION
* DEFGROUP: MokoCLI.Enterprise
* INGROUP: MokoCLI.Lib
* REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
* PATH: /lib/Enterprise/RecoverySuggestion.php
* BRIEF: Smart error recovery suggestions for validators
*/
declare(strict_types=1);
namespace MokoCli;
/**
* Generates actionable fix suggestions when validators detect problems.
*
* Each method returns a human-readable suggestion string that tells the
* developer exactly what to do to fix the issue.
*/
class RecoverySuggestion
{
/**
* Suggest creating a missing required file.
*/
public static function forMissingFile(string $file, string $template = ''): string
{
$suggestion = "Create the missing file: {$file}";
if ($template !== '') {
$suggestion .= "\n Copy from template: {$template}";
}
return $suggestion;
}
/**
* Suggest adding a missing XML element.
*/
public static function forMissingXmlElement(string $element, string $value, string $file, int $afterLine = 0): string
{
$snippet = "<{$element}>{$value}</{$element}>";
if ($afterLine > 0) {
return "Add {$snippet} after line {$afterLine} in {$file}";
}
return "Add {$snippet} to {$file}";
}
/**
* Suggest fixing a version mismatch.
*/
public static function forVersionMismatch(string $file, string $found, string $expected): string
{
return "Update version in {$file}: change \"{$found}\" to \"{$expected}\"";
}
/**
* Suggest creating a missing directory.
*/
public static function forMissingDirectory(string $dir): string
{
return "Create the missing directory:\n mkdir -p {$dir}";
}
/**
* Suggest fixing a syntax error.
*/
public static function forSyntaxError(string $file, int $line, string $error): string
{
return "Fix syntax error at {$file}:{$line}\n {$error}";
}
/**
* Suggest fixing a missing license header.
*/
public static function forMissingHeader(string $file): string
{
return "Add SPDX license header to {$file}:\n"
. " /* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>\n"
. " * SPDX-License-Identifier: GPL-3.0-or-later */";
}
/**
* Suggest running a command to fix an issue.
*/
public static function forCommand(string $command, string $context = ''): string
{
$suggestion = "Run: {$command}";
if ($context !== '') {
$suggestion = "{$context}\n {$suggestion}";
}
return $suggestion;
}
}