Projects initialized in camelCase/PascalCase directories used to end
up with prefixes like "boardGameTracker-" (17 chars + uppercase) that
nibs config set-prefix would reject, locking the project out of the
very command meant to fix the problem. This closes the loop.
- Add --prefix flag to nibs init; when passed, honor case exactly and
only auto-append a trailing dash if missing, then validate via
reprefix.ValidatePrefix
- When --prefix is NOT passed, derive strings.ToLower(dirName) + "-"
(case is incidental on a dirname, safe to normalize) and validate
- Differentiated error messages: derived failures name the source
dirname AND suggest --prefix as the escape hatch; explicit failures
only surface the validation reason (mentioning --prefix would be
tautological since the user already used it)
- Document the partial-init state in a comment: .nibs/ is created by
core.Init BEFORE prefix validation runs, so a validation failure
leaves the empty dir on disk and re-running with a corrected flag
is idempotent (MkdirAll is a no-op on existing dirs)
- 8 new TestInit_* tests covering: explicit valid with dash, explicit
auto-append, explicit uppercase rejected x3 (BGT/BGT-/Foo-), explicit
invalid charset x2 (BAD_/bad_ split to isolate rules), derived
regression (myproj stays unchanged), derived camelCase lowercased
(boardGame -> boardgame-), derived length/charset failures, and
TestInit_DerivedPrefix_DefaultBranch_Getwd which uses t.Chdir to
cover the else-branch path that every other test would miss
- Lock the asymmetry in at cmd/config_test.go via a new
TestSetPrefix_UppercaseExplicitRejected: set-prefix must never
silently lowercase explicit input. cmd/config.go itself is
unchanged — its existing behavior already matches the rule
Refs: nibs-xnbt, nibs-dkyq, nibs-j7rr
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>