Repository navigation
Description
Verified against (commit SHA or released version)
Commit a8f8cca244b4daf1b5d37ec3fe7c2c4fff2492a3 (package 0.15.0), Windows, Node 24.18.0.
Discord Username / User ID
iamharrie
What does this improvement do?
Make testsprite agent install --dir "" (and the deprecated init --agent --dir "" wrapper) fail locally instead of silently selecting the current working directory.
agent install is a write command. An explicit empty --dir falls through to path.resolve(''), which is the current working directory. Without --dry-run, it can install or overwrite skill files in the caller's current project even though the caller supplied an invalid destination. A whitespace-only value is also accepted and resolves to a child directory literally named on Windows.
init --agent passes its --dir through to the same installer and has the same behavior. That broadens the impact to the onboarding command a new user is most likely to run.
The neighboring testsprite agent status --dir "" command already rejects the same input with VALIDATION_ERROR / exit 5, so the install and inspection paths disagree about an explicitly empty destination.
Reproduction
From a newly-created empty temporary directory, run the compiled CLI with --dry-run so no files are written:
testsprite --output json --dry-run agent install --target claude --dir ""
testsprite --output json agent status --dir ""
testsprite --output json --dry-run init --agent claude --dir ""The first and third commands succeed and preview files under the current directory; the second returns a VALIDATION_ERROR with exit 5 and details: { "field": "dir", "reason": "must not be empty" }. --dir " " similarly previews a path under <cwd>/ instead of rejecting the blank-looking value.
Details / implementation notes
runStatus in src/commands/agent.ts explicitly guards this case before resolving its root:
if (opts.dir !== undefined && opts.dir.trim() === '') {
throw localValidationError('dir', 'must not be empty');
}runInstall has no equivalent validation and immediately chooses:
const dir = opts.dir ?? deps.cwd ?? process.cwd();
const root = path.resolve(dir);Suggested change: apply the same trim-and-reject guard to runInstall, then use the trimmed explicit value when resolving the root. This keeps an omitted --dir meaning “current working directory,” while an explicit blank value is rejected before asset reads, path checks, output, or writes.
Regression coverage belongs in src/commands/agent.test.ts: assert that dir: '' and dir: ' ' reject with VALIDATION_ERROR, exit 5, details.field: 'dir', and no filesystem calls. Existing runStatus coverage already defines the desired contract.
Confirmations
- Searched the current public issue and PR history; no existing report covers explicit blank
agent install --dirvalidation. - Reproduced with the compiled CLI, not only an imported helper.
- Supplied Discord identity for reward coordination.
Activity
ruili-testsprite commentedon Oct 31, 2026
Thanks @IamHarrie-Labs, confirmed: a blank
--dironagent installfalls back to the current directory. #577, #582, #604, #646 and #663 all come from the same place, a blank option value read as an omitted one, so we'll fix it once for every option ourselves instead of flag by flag. Closing as not planned.