plugins/file/commands/create architecture
Implements the 'create' file/folder command — defining its dir/name arguments and folder/tree UI options, validating names and workspace containment, and adapting handler results to CLI or web tree responses.
Architectural role
Leaf creation endpoint within the commands file-operations family (create/delete/edit/rename/view/tree/search). Sits beneath the file plugin's centralized dispatcher (plugins/file/adapter.ts/handleFile) and registration (init.ts) aggregation at plugins/file/commands — invoked via dispatch fan-out, not directly. Completes the file lifecycle as the write-origin that sibling view/edit/delete/rename/tree commands subsequently operate on, sharing the validate-workspace-containment → execute filesystem → adapt to CLI/web pattern via shared workspace-root/path-validation and web tree rendering.
Source map
adapter.ts— Adapter trims and validates dir/name args, resolves workspace root, calls handleCreateCommand, and returns error text, 'Created' for non-web, or renderTreeForWeb with alias/treeDir/ext/expanded/revealPath for web. definition.ts— Factory returns the 'create' SubcommandDefinition with required string args dir and name and options --folder, --tree-dir, --ext, and --expanded.handler.ts— Validates single-segment name, checks workspace containment and that the target directory exists and is a directory, then creates an empty file or folder or returns typed errors for escapes/exists.
Integration details
adapter.ts— Channel-adaptation boundary between dispatcher and domain logic — sanitizes dir/name args, resolves workspace root, delegates to handler, then maps typed success/error to CLI text ('Created') or web tree UI (renderTreeForWeb with alias/treeDir/ext/expanded/revealPath). Implements the adapt phase of the file-command pattern shared with sibling file/git commands. definition.ts— Declarative contract for discovery and dispatch — registers the create subcommand shape (required dir/name, --folder/--tree-dir/--ext/--expanded) for CLI and web tooling via the file plugin's SubcommandDefinition system. Pure schema with no validation or I/O, consumed by the parent container and dispatcher/help.handler.ts— Isolated domain executor owning containment and filesystem invariants — validates single-segment name, verifies target directory exists/is-directory within workspace, and creates empty file or folder or returns typed escape/exists errors for the adapter to render. No CLI/web awareness; relies on shared validation.