Skip to content

[Hackathon] fix(agent): explicit blank --target or --skill silently writes fallback defaults #582

Closed as not planned

Description

@IamHarrie-Labs

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?

Reject an explicitly blank --target or --skill for testsprite agent install instead of treating it as if the option were omitted.

Those two meanings are materially different for a write command. With no --target, auto-detection and the documented Claude fallback are useful. With --target "$AGENT" where an automation variable is unset, the caller asked for a specific target but the CLI silently chooses one and writes three skill files into that agent's configuration directory. Likewise, --skill "$SKILL" silently expands into all default skills rather than doing no work or reporting the bad input.

This creates a quiet broadening failure in shell scripts and coding-agent hooks: a missing variable changes a narrowly scoped install into an unrequested default install. On a real run it creates or modifies project files; a later commit can then distribute those unintended instructions to the rest of a team.

The deprecated testsprite init --agent "" onboarding wrapper has the same target-selection behavior. It accepts the blank value, configures the requested profile, and reports detectedBy: "fallback" / target: "claude" while previewing the three Claude skill writes. That makes the failure more consequential: an unset AGENT variable in a setup script can both persist credentials and install guidance for an agent the caller did not select.

Reproduction

From a new empty temporary directory, these commands both exit 0 and write all three Claude skill files:

testsprite --output json agent install --target ""
testsprite --output json agent install --target claude --skill ""
testsprite --output json --dry-run init --api-key sk-user-fixture --agent ""

The first prints:

[info] no coding agent detected; installing for claude.

and writes:

.claude/skills/testsprite-verify/SKILL.md
.claude/skills/testsprite-onboard/SKILL.md
.claude/skills/testsprite-ci/SKILL.md

Whitespace-only values have the same behavior:

testsprite --output json --dry-run agent install --target "  " --skill "  "

It exits 0, selects the Claude fallback, and previews all three writes. The same outcome occurs with --dry-run; only the writes are suppressed.

Details / implementation notes

In runInstall, both option arrays are split, trimmed, and then .filter(Boolean) is applied before the code decides whether the option was present:

const rawTargets = opts.target
  .flatMap(s => s.split(','))
  .map(s => s.trim())
  .filter(Boolean);
// rawTargets.length === 0 then triggers detection/fallback

const rawSkills = (opts.skills ?? [])
  .flatMap(s => s.split(','))
  .map(s => s.trim())
  .filter(Boolean);
// rawSkills.length === 0 then selects DEFAULT_SKILLS

Check whether the respective Commander option was explicitly supplied before filtering. If it was, reject an all-empty/whitespace-only list with VALIDATION_ERROR / exit 5. Preserve the current behavior when the option is truly absent, and preserve valid comma-separated/repeated values.

Regression coverage in src/commands/agent.test.ts should assert that target: [''], target: [' '], skills: [''], and skills: [' '] reject before detection, asset reads, or filesystem writes. It should also retain the intended no-option fallback and default-skill tests.

Add an integration-level init / setup regression for --agent "", ensuring it is rejected before credentials are configured or any agent target is resolved.

Confirmations

  • Reproduced with the compiled CLI on the real write path in a disposable directory.
  • Searched the current public issue and PR tracker, including agent-install target/skill reports; no matching report found.
  • Supplied Discord identity for reward coordination.

Activity

  1. added
    needs-triage
    hackathon
    on Oct 30, 2026
  2. removed
    needs-triage
    on Oct 31, 2026
  3. ruili-testsprite commented on Oct 31, 2026

    @ruili-testsprite
    Contributor

    Thanks @IamHarrie-Labs, confirmed: a blank --target or --skill falls back to the default. #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hackathon

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions