Skip to content

warpgrep_codebase_search returns no contexts when OpenCode passes snapshot git dir as worktree #24

Description

@fpdy

Summary

warpgrep_codebase_search consistently fails through the OpenCode Morph plugin with:

Search failed: search returned no error details.

However, calling @morphllm/morphsdk directly with repoRoot set to the real workspace directory succeeds for the same queries. This suggests the plugin may be resolving the search root to OpenCode's snapshot git directory instead of the actual worktree.

Environment

  • @morphllm/opencode-morph-plugin: 2.0.13
  • Plugin runtime log reports: Plugin v2.0.0 loaded [edit, warpgrep, warpgrep-github, compact]
  • @morphllm/morphsdk: 0.2.173
  • OpenCode: 1.16.2
  • OS: macOS
  • Node.js used for direct SDK test: v24.13.0
  • MORPH_API_KEY: configured

Reproduction

In an OpenCode session inside a normal git repository, run:

warpgrep_codebase_search({
  "search_term": "Find README.md and CHANGELOG.md files in this repository."
})

Observed result:

Search failed: search returned no error details.

I also tried several different query shapes, all with the same result:

  • Find README.md and CHANGELOG.md files in this repository.
  • Find package version 0.7.0.
  • Find documentation describing supported Dynamic Workflows executors: codex, claude, and opencode.
  • Find the acp_opencode executor implementation and validation rules.
  • Find the scheduler implementation for workflow task dependencies and foreach.

All failed identically through the tool.

Control checks

Normal local search tools can see the files:

  • README.md
  • CHANGELOG.md
  • plugin source files
  • docs

Direct SDK usage also works when repoRoot is set to the real workspace directory:

import { WarpGrepClient } from "@morphllm/morphsdk";

const client = new WarpGrepClient({
  morphApiKey: process.env.MORPH_API_KEY,
  timeout: 60000,
  debug: true,
});

const gen = client.execute({
  searchTerm: "Find README.md and CHANGELOG.md files in this repository.",
  repoRoot: process.cwd(),
  streamSteps: true,
});

let final;
for (;;) {
  const r = await gen.next();
  if (r.done) {
    final = r.value;
    break;
  }
  console.log(r.value);
}

console.log(final);

This succeeds and returns contexts for README.md and CHANGELOG.md.

Relevant logs / findings

OpenCode logs show the session has:

cwd=<REAL_WORKSPACE_PATH>
git=<OPENCODE_SNAPSHOT_GIT_PATH>

The git path points under OpenCode's snapshot storage, e.g.:

<HOME>/.local/share/opencode/snapshot/<project-id>/<snapshot-id>

That directory appears to be a git metadata directory, containing entries like:

config
description
HEAD
hooks/
index
info/
objects/
packed-refs
refs/

It is not the real source worktree.

The plugin code appears to prefer worktree over directory:

function resolveSessionRepoRoot(sessionDirectory, sessionWorktree) {
  return sessionWorktree || sessionDirectory;
}

Then warpgrep_codebase_search calls:

warpGrep.execute({
  searchTerm: args.search_term,
  repoRoot: resolveSessionRepoRoot(directory, worktree),
  streamSteps: true,
});

If OpenCode passes the snapshot git directory as worktree, WarpGrep searches the snapshot metadata instead of the real repository directory.

Expected behavior

warpgrep_codebase_search should search the actual source workspace, e.g. the session directory, not OpenCode's internal snapshot git directory.

For the query:

Find README.md and CHANGELOG.md files in this repository.

I would expect contexts for:

README.md
CHANGELOG.md

Actual behavior

The tool returns:

Search failed: search returned no error details.

OpenCode/Morph logs report:

WarpGrep: 0 contexts in N turns

Suspected cause

resolveSessionRepoRoot() may be using the wrong field. In this OpenCode version, worktree appears to refer to an internal snapshot git directory rather than the checked-out project worktree.

Possible fixes:

  1. Prefer directory over worktree for local warpgrep_codebase_search.
  2. Detect OpenCode snapshot git directories and fall back to directory.
  3. Validate that the selected repoRoot contains normal source files, not only git metadata.
  4. Improve the error message when WarpGrep returns success: false without an error.

Notes

This does not look like a missing API key or Morph API outage:

  • MORPH_API_KEY is configured.
  • Direct SDK calls with the same key succeed.
  • The failure only occurs through the OpenCode plugin tool path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions