DashboardcraftCraft workspace selection must be parse…

Craft workspace selection must be parsed before yargs builders and never overwritten

Category: gotcha
Confidence: 1.00
ID: 01a06c95-9de2-705e-bef0-0b8e33b4000d
Project ID: e16af391-c497-4837-b681-c849a5514499
Cross-project: No
Recalled in other projects: 1
Source session: 012Op1WSIwriqapwe
Created: 2026-07-22 11:25:36
Updated: 2026-09-04 13:22:19

Cross-Project Recalls

ProjectHitsLast recalled
opencode-lore 1 2026-08-05

Content

Parse Craft workspace selection from raw argv before yargs builders and set it once: builders run before middleware, so builder-time configuration otherwise misses --workspace. Use parseArgs({ tokens: true }) and explicitly narrow token.kind === 'option' before reading option-only fields such as value or inlineValue. For separated --workspace, accept only a following non-flag string; accept inline --workspace=-foo; empty, bare, or flag-followed forms fall back to CRAFT_WORKSPACE. Repeated options use the last value, but a final valueless option clears earlier CLI selection. Do not let middleware overwrite this selection with a falsy bare option. Builders needing target choices should tolerate configuration failure and fall back to all target names.

Move to: