paperclipai/paperclip · error · Error

Could not resolve worktree

Error message

Could not resolve worktree "${selector}". Use a path, a listed worktree directory name, branch name, or "current".

What it means

Resolution-failure sentinel for worktree selectors: the value matched neither an existing filesystem path, a listed worktree directory name, nor a known branch label (and was not 'current'), so no endpoint could be resolved.

Solutions

  1. Use a path, a listed worktree directory name, a branch name, or "current".
  2. Run `paperclipai worktree:list` to see valid selectors.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cli/src/commands/worktree.ts:2860 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-08-18). Data as JSON: /api/errors/eecc8c7f4cf5fbf6. Report an issue: GitHub.

Appendix: source

Thrown at cli/src/commands/worktree.ts:3675

    if (!existsSync(configPath)) {
      throw new Error(`Resolved worktree path ${directPath} does not contain .paperclip/config.json.`);
    }
    return {
      rootPath: directPath,
      configPath,
      label: path.basename(directPath),
      isCurrent: false,
    };
  }

  const matched = choices.find((choice) =>
    (allowCurrent || !choice.isCurrent)
    && (choice.worktree === directPath
      || path.basename(choice.worktree) === trimmed
      || choice.branchLabel === trimmed),
  );
  if (!matched) {
    throw new Error(
      `Could not resolve worktree "${selector}". Use a path, a listed worktree directory name, branch name, or "current".`,
    );
  }
  if (!matched.hasPaperclipConfig && !matched.isCurrent) {
    throw new Error(`Resolved worktree "${selector}" does not look like a Paperclip worktree.`);
  }
  return resolveEndpointFromChoice(matched);
}

async function promptForSourceEndpoint(excludeWorktreePath?: string): Promise<ResolvedWorktreeEndpoint> {
  const excluded = excludeWorktreePath ? path.resolve(excludeWorktreePath) : null;
  const currentEndpoint = resolveCurrentWorktreeEndpoint();
  const choices = toMergeSourceChoices(process.cwd())
    .filter((choice) => choice.hasPaperclipConfig || choice.isCurrent)
    .filter((choice) => path.resolve(choice.worktree) !== excluded)
    .map((choice) => ({
      value: choice.isCurrent ? "__current__" : choice.worktree,
      label: choice.branchLabel,

View on GitHub (pinned to 01ad858492)