@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
60 lines (59 loc) • 2.86 kB
TypeScript
/**
* AddCommand - Add content to a Minecraft project
*
* This ToolCommand provides content addition capabilities across all surfaces.
*
* Two modes of operation:
* 1. **Gallery mode** (default): Adds from pre-built gallery templates.
* Example: `/add entity my_mob`
* 2. **Wizard mode**: Uses ContentGenerator to procedurally create content from
* traits and properties — the same engine powering the web Content Wizard.
* Activated when `--traits` or any wizard flag is provided.
* Example: `/add entity my_orc --traits hostile,melee_attacker,humanoid --health 30`
*
* @see ContentGenerator.ts for the procedural generation engine
* @see ContentWriter.ts for writing generated files to a project
* @see ContentWizard.tsx for the web UI equivalent
*/
import type { IToolCommandMetadata, IToolCommandResult } from "../IToolCommand";
import { ToolCommandBase } from "../IToolCommand";
import type { IToolCommandContext } from "../IToolCommandContext";
import type { IMinecraftContentDefinition } from "../../../minecraft/IContentMetaSchema";
interface IValidationError {
flag: string;
message: string;
}
/**
* Validate wizard flag values and return any errors.
*/
/** Union of all possible flag value types from the command parser. */
export type WizardFlagValue = string | boolean | number | string[];
export declare function validateWizardFlags(contentType: string, flags: Record<string, WizardFlagValue>): IValidationError[];
/**
* Determine whether wizard-mode generation should be used instead of gallery mode.
* Returns true if traits or any wizard-specific flag is provided.
*/
export declare function shouldUseWizardMode(contentType: string, traits: string[] | undefined, flags: Record<string, WizardFlagValue>): boolean;
/**
* Build an IMinecraftContentDefinition from CLI args and flags.
* Mirrors the _buildDefinition() logic in ContentWizard.tsx.
*/
export declare function buildDefinitionFromFlags(contentType: string, name: string, traits: string[] | undefined, flags: Record<string, WizardFlagValue>): IMinecraftContentDefinition;
export declare class AddCommand extends ToolCommandBase {
readonly metadata: IToolCommandMetadata;
execute(context: IToolCommandContext, args: string[], flags: Record<string, string | boolean | string[]>): Promise<IToolCommandResult>;
/**
* Wizard mode: build an IMinecraftContentDefinition → ContentGenerator → ContentWriter.
*/
private _executeWizardMode;
/**
* Gallery mode: add from a pre-built gallery template.
*/
private _executeGalleryMode;
/**
* Custom completions based on argument position and type context.
*/
getCompletions(context: IToolCommandContext, args: string[], partialArg: string, argIndex: number): Promise<string[]>;
}
export declare const addCommand: AddCommand;
export {};