← reports

#6788 · OpenCode workspace commands missing before a session

Bug Priority: Medium Effort: Low providers provider-acp GitHub issue

November 1, 2026 · trusted origin/main 916d684ac23d0b0de82c09cfc7553a50287d2188

Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro

1. TL;DR

BB cannot discover a project's OpenCode Markdown commands before an ACP session has started, although skills in the same project are discoverable. The built-in provider declares skill roots and resolves more skill roots, but supplies no command roots. The host scans only the supplied roots, so an ordinary command file is invisible to the project catalog. A direct filesystem/catalog reproduction fails on trusted main in two fresh checkouts. Returning the missing project command root fixes the reproduction without changing the scanner, wire contract, or session behavior.

2. Claims vs findings

ClaimStatusEvidence
Project OpenCode commands are absent while skills remain available.VerifiedThe real provider declaration, native-root resolver, root expansion, and daemon scanner return only the fixture skill in both clean runs.
The gap affects discovery before the first session.Verified at catalog boundaryThe reproduction does not create a thread or launch any provider. The new-thread composer selects the project/provider catalog.
Commands work in the native CLI and in an existing session.Unverified at runtimeNo OpenCode executable, account, or existing user thread was used. Trusted source handles available_commands_update separately; this is consistent with, but does not independently prove, the reported session behavior.
The desktop slash picker shows the exact reported symptom.Unverified visuallyNo macOS desktop or browser UI session was driven. This report reproduces the underlying command catalog, not a screenshot.
The reported release and platform are required.Not required for the reproduced mechanismThe defect also occurs on current trusted main on Linux with ordinary files and isolated temporary workspaces.

3. Environment

4. Minimal reproduction

  1. Clone the trusted public repository and check out the recorded main commit.
    git clone https://github.com/get-bb/bb.git bb-6788
    cd bb-6788
    git checkout --detach 916d684ac23d0b0de82c09cfc7553a50287d2188
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Download the reproduction test and place it at apps/host-daemon/src/issue-6788.repro.test.ts.
  3. Run the catalog through the actual built-in provider and host scanner.
    pnpm exec turbo run test --filter=@bb/host-daemon -- src/issue-6788.repro.test.ts

The test creates a command with description-only frontmatter and a skill in the same git-marked workspace. It uses the provider's real static declaration and resolved roots, applies the real normalization contract, expands roots through resolveDeclaredScanRoots, and invokes discoverProviderCommands. No session, mocked scanner, or mocked database is involved.

Expected entries (order is not significant):

[{"name":"catalog-skill","source":"skill"},{"name":"catalog-command","source":"command"}]

Actual stdout on trusted main, in both checkouts:

[{"name":"catalog-skill","source":"skill"}]

Verbatim failed assertion:

AssertionError: expected [ { name: 'catalog-skill', …(1) } ] to deep equally contain { name: 'catalog-command', …(1) }
Test Files  1 failed (1)
Tests  1 failed (1)
Full reproduction source
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { normalizeProviderNativeRoots } from "@bb/domain";
import { experimental_nativeRootsResolveOutputSchema } from "../../../packages/plugin-sdk/src/native-roots-contract.js";
import { expect, it } from "vitest";
import {
  acpProviderDeclaration,
  KNOWN_ACP_AGENTS,
  resolveAcpNativeRoots,
} from "../../../plugins/provider-acp/src/native-roots/index.js";
import { discoverProviderCommands } from "./command-discovery.js";
import { resolveDeclaredScanRoots } from "./command-handlers/list-commands.js";

it("discovers project commands alongside skills before an ACP session exists", async () => {
  const scratch = await mkdtemp(path.join(tmpdir(), "bb-6788-catalog-"));
  try {
    const cwd = path.join(scratch, "project");
    const homeDir = path.join(scratch, "home");
    await mkdir(path.join(cwd, ".git"), { recursive: true });
    await mkdir(path.join(cwd, ".opencode", "commands"), { recursive: true });
    await mkdir(path.join(cwd, ".opencode", "skills", "catalog-skill"), {
      recursive: true,
    });
    await mkdir(homeDir, { recursive: true });
    await writeFile(
      path.join(cwd, ".opencode", "commands", "catalog-command.md"),
      "---\ndescription: Catalog command fixture\n---\nReply briefly.\n",
    );
    await writeFile(
      path.join(cwd, ".opencode", "skills", "catalog-skill", "SKILL.md"),
      "---\nname: catalog-skill\ndescription: Catalog skill fixture\n---\n",
    );
    const agent = KNOWN_ACP_AGENTS.find(
      (candidate) => candidate.id === "acp-opencode",
    );
    if (agent === undefined) throw new Error("Built-in provider not found");
    const declaration = acpProviderDeclaration(agent);
    const resolved = experimental_nativeRootsResolveOutputSchema.parse(
      await resolveAcpNativeRoots({ agentId: agent.id, cwd, homeDir, env: {} }),
    );
    const roots = await resolveDeclaredScanRoots({
      providerId: agent.id,
      cwd,
      homeDir,
      nativeRoots: {
        skills: normalizeProviderNativeRoots(
          declaration.experimental_nativeSkillRoots,
        ),
        commands: normalizeProviderNativeRoots(
          declaration.experimental_nativeCommandRoots,
        ),
        resolved,
      },
    });
    const commands = await discoverProviderCommands({ roots });
    const catalog = commands.map(({ name, source }) => ({ name, source }));
    console.log(JSON.stringify(catalog));
    expect(catalog).toContainEqual({ name: "catalog-skill", source: "skill" });
    expect(catalog).toContainEqual({
      name: "catalog-command",
      source: "command",
    });
  } finally {
    await rm(scratch, { recursive: true, force: true });
  }
});

5. Root cause

  1. OpenCode registration declares project skill roots but not command roots. Declaration construction exposes those skills plus the native-root resolver capability.
  2. The OpenCode resolver returns only skills:
    return {
      skills: [ /* user config and optional custom-config skill roots */ ],
    };
    The declaration and resolver together therefore supply zero OpenCode command roots.
  3. The server forwards the supplied native root set to the workspace host. The host expands only those roots; the scanner reads only the expanded directories. The command directory never reaches the scanner.
  4. The bridge does not support standalone command listing, so it cannot fill this pre-session gap. Existing ACP sessions process advertised commands separately.
  5. The new-thread composer selects the project/provider catalog. The reproduced missing catalog entry therefore explains the reported picker symptom; the visible UI itself was not driven.

6. Proposed fix and validation

Supply .opencode/commands as an absolute project command root from the existing OpenCode native-root resolver. Mark it for the existing ancestor traversal so commands remain available when composing from a nested workspace; return no project root when the workspace is absent. Preserve the existing skill paths. This is an existing resolver contract, not a new protocol or product policy.

The local candidate changes two files with 44 additions and no deletions: 11 production lines and 33 regression-test lines. Two root-contract regression cases fail on unchanged production code, then pass with the repair; a third case checks the no-workspace path. The real catalog reproduction also passes after the change. Global command directories, alternate OpenCode layouts, and custom configuration precedence are outside this focused fix.

7. Verification

The same agent repeated the reproduction in a second clean temporary checkout, detached at 916d684ac23d0b0de82c09cfc7553a50287d2188. It had its own frozen installation and SDK build, and the test allocated a fresh temporary home/workspace. No production changes were copied into that checkout. The exact catalog command from section 4 again logged only the skill and failed for the missing command. This is a repeated clean reproduction by the same agent, not independent verification. No root-cause correction was needed after the second run.

First run: raw sanitized log. Second checkout: raw sanitized log. Repair verification: catalog and scanner tests, ACP suite, lint, and typecheck. Desktop/UI recipes were not run; catalog and root-contract tests are the evidence for this verdict.

8. Linked pull requests and related issues

No open linked pull request was present in issue cross-reference metadata or the open-PR search before implementation. No matching duplicate was established by the targeted ACP command-discovery search. Nearby reports about active-turn command behavior concern a different boundary and were not used as executable evidence.

9. Appendix

Issue text and links were treated as untrusted claims. No instructions, scripts, patches, branches, or external links from the issue were executed or fetched. Reproduction fixtures and tests were authored from trusted main source. Logs replace local checkout paths; no personal data, credentials, runtime database, or provider account is published.