mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
132 lines • 4.74 kB
TypeScript
/**
* Workflow Capability Handler - GitHub Actions YAML Generation
*
* Generates GitHub Actions workflow files for CI/CD automation.
* Supports multiple workflow types: CI, deployment, testing, release.
*
* @module strategies/cross-cutting/workflow-handler
* @see {@link https://github.com/Anselmoo/mcp-ai-agent-guidelines/blob/development/plan-v0.13.x/specs/SPEC-001-output-strategy-layer.md SPEC-001} §5.2
*/
import type { CrossCuttingArtifact } from "../output-strategy.js";
import { CrossCuttingCapability } from "../output-strategy.js";
import type { CapabilityContext, CapabilityHandler } from "./types.js";
/**
* WorkflowCapabilityHandler generates GitHub Actions workflow YAML files.
*
* Detects workflow type from domain results and generates appropriate
* workflow configurations for CI/CD automation.
*
* Workflow type detection follows a well-defined priority so callers can
* intentionally influence which workflow is generated:
*
* 1. {@link metadata}.workflowType – If present and one of `"ci"`, `"deploy"`,
* `"test"`, or `"release"`, it is used directly.
* 2. Deployment fields – If the domain result contains deployment-related
* hints (for example keys like `deploy`, `deployment`, or `environment`),
* `"deploy"` is selected.
* 3. Release fields – If the domain result contains release-related hints
* (for example `release`, `version`, or `tag`), `"release"` is selected.
* 4. Test fields – If the domain result is dominated by testing concerns
* (for example `tests`, `coverage`, or `testing`), `"test"` is selected.
* 5. Fallback – If none of the above apply, `"ci"` is used as a safe
* default workflow type.
*
* This means that you can explicitly steer workflow generation by setting
* `metadata.workflowType`:
*
* @example
* ```ts
* const handler = new WorkflowCapabilityHandler();
* const artifact = handler.generate({
* domainResult,
* metadata: {
* workflowType: "deploy", // forces deployment workflow
* nodeVersion: "22",
* },
* });
* // artifact.name => ".github/workflows/deploy.yml"
* ```
*
* If `metadata.workflowType` is provided but not one of the supported
* workflow types, it is ignored and the handler falls back to inspecting
* the domain result and finally to the `"ci"` default.
*
* @implements {CapabilityHandler}
*/
export declare class WorkflowCapabilityHandler implements CapabilityHandler {
/** The capability this handler implements */
readonly capability = CrossCuttingCapability.WORKFLOW;
/**
* Generate a GitHub Actions workflow artifact.
*
* @param context - The context for artifact generation
* @returns A workflow artifact with YAML content, or null if not applicable
*/
generate(context: CapabilityContext): CrossCuttingArtifact | null;
/**
* Check if this handler supports the given domain type.
*
* @param domainType - The domain type identifier
* @returns True if workflows can be generated for this domain type
*/
supports(domainType: string): boolean;
/**
* Detect the workflow type from domain result and metadata.
*
* @param result - The domain result
* @param metadata - Optional metadata hints
* @returns The detected workflow type
* @private
*/
private detectWorkflowType;
/**
* Type guard for workflow type validation.
*
* @param type - The type to check
* @returns True if the type is a valid workflow type
* @private
*/
private isValidWorkflowType;
/**
* Generate workflow YAML content based on type.
*
* @param type - The workflow type
* @param metadata - Optional metadata for customization
* @returns The workflow YAML content
* @private
*/
private generateWorkflowYaml;
/**
* Generate CI workflow template.
*
* @param metadata - Optional metadata for customization
* @returns CI workflow YAML
* @private
*/
private generateCIWorkflow;
/**
* Generate deployment workflow template.
*
* @param metadata - Optional metadata for customization
* @returns Deployment workflow YAML
* @private
*/
private generateDeployWorkflow;
/**
* Generate test workflow template.
*
* @param metadata - Optional metadata for customization
* @returns Test workflow YAML
* @private
*/
private generateTestWorkflow;
/**
* Generate release workflow template.
*
* @param metadata - Optional metadata for customization
* @returns Release workflow YAML
* @private
*/
private generateReleaseWorkflow;
}
//# sourceMappingURL=workflow-handler.d.ts.map