Skip to content

harness analyze-repo --scaffold ignores --force — always refuses when target dir exists #135

Description

@sparkling

harness analyze-repo . --scaffold <name> --force doesn't overwrite an existing directory — it fails with the same "already exists. Pass --force to overwrite." error whether or not --force is passed.

Repro:

$ harness analyze-repo . --force --scaffold coding-harness
/path/coding-harness already exists. Pass --force to overwrite.

(--force was passed. It made no difference.)

Root cause: analyzeRepoCmd's own argument parser only recognizes a fixed set of flags:

// packages/create-agent-harness/src/analyze-repo.ts
for (let i = 0; i < args.length; i++) {
  const a = args[i];
  if (a === '--embed') embed = true;
  else if (a === '--json') json = true;
  else if (a === '--out') outDir = args[++i] ?? null;
  else if (a === '--scaffold') scaffoldName = args[++i] ?? null;
  else if (a === '--host') host = (args[++i] ?? 'claude-code') as Host;
  else if (a && !a.startsWith('-')) dir = a;
}

There's no --force case — it's silently dropped, not even captured into a variable. Then the scaffold call never forwards a force field:

const r = await scaffold({ name: scaffoldName, template: plan.template, host, targetDir: target, description: `Harness for ${profile.name}`, generatorVersion: '0.1.0' });

ScaffoldOptions.force (index.ts:223) is left undefined, so writeAtomic(opts.targetDir, rendered, { force: opts.force }) always takes the "refuse, target exists" branch.

Contrast with the top-level metaharness <name> --force path, which works correctly: index.ts:165-166 parses --force/-f into args.force, and index.ts:752 forwards force: args.force into scaffold().

Suggested fix: add --force/-f to analyzeRepoCmd's parser and forward it into the scaffold(...) call at analyze-repo.ts:392, mirroring what index.ts already does for the top-level scaffold path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions