tui: @/ cannot mention project root in non-Git locations

Aperta Adatta ai principianti
#61,640 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend, search

Direzione di ricerca

Inizia da packages/core/src/filesystem/search.ts ed esamina come il backend ripgrep crea il proprio indice delle directory a partire dalle voci di rg --files. Confronta il comportamento non Git con il backend fff e il lavoro correlato sulle directory vuote in #60450. L’obiettivo è che GET /api/fs/find?query=/ includa {"path":"/","type":"directory"} per una posizione non Git, mantenendo il comportamento esistente per le posizioni gestite da Git.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

reproduced

Summary

In a non-Git location, typing @/ no longer offers the location root as a mention, so the project directory itself cannot be attached to a prompt. Git-backed locations still list / and attach the directory correctly.

Environment

  • opencode version: 2.2.5
  • OS: Linux 6.18.60-1-lts (x86_64)
  • Terminal: TUI, TERM=xterm-256color, COLORTERM=truecolor, TERM_PROGRAM unset
  • Shell: /usr/bin/bash
  • Install/channel: latest release (/usr/bin/opencode)
  • Active plugins: none found (no plugin entries in global config; no local .opencode/plugin or .opencode/plugins)

Reproduction

  1. Create a non-Git project:

    mkdir -p /tmp/opencode-nongit/src
    printf 'x\n' > /tmp/opencode-nongit/README.md
    printf 'y\n' > /tmp/opencode-nongit/src/a.ts
    cd /tmp/opencode-nongit
    
  2. Start opencode and type @/.

  3. The picker lists src/, src/a.ts, etc., but has no / entry for the location root. There is nothing to select that represents the project directory.

  4. Query the API directly:

    opencode api --standalone GET '/api/fs/find?query=/'
    

    Output contains no {"path":"/","type":"directory"}:

    {"location":{"directory":"/tmp/opencode-nongit"},"data":[{"path":"src/","type":"directory"},{"path":"src/a.ts","type":"file"}]}
    
  5. Compare with a Git-backed location. After git init and restarting, the same query includes the root, and selecting @/ inserts @/ and attaches the directory listing:

    {"data":[{"path":"/","type":"directory"},{"path":"src/","type":"directory"}, ...]}
    

Expected Behavior

@/ should list and select the location root in non-Git locations too, matching Git-backed locations and V1 behavior.

Actual Behavior

In a non-Git location, @/ has no project-root entry, so the project directory cannot be mentioned. GET /api/fs/find?query=/ omits the root.

Additional Context

  • Reproducible consistently on 2.2.5.

  • Root cause: packages/core/src/filesystem/search.ts selects the fff backend only for VCS, non-home locations:

    return location.vcs && !Protected.isHome(location.directory) ? fffLayer : ripgrepLayer
    

    Non-Git locations use the ripgrep backend, whose directory index is built only from parent components of rg --files entries. The location root is never added. V1 selected fff for non-Git locations too, so this is a V2 regression.

  • Related: #60293 / #60450 cover empty directories in the ripgrep index, but not the root. #60450 starts its walk at the root with known=true and only publishes provably empty child directories, so it will not add /.

  • Workaround: temporarily git init to force the fff backend; this is not a reasonable workaround.

Lingua principale
TypeScript
Stelle
224k
Fork
30k
Merge medio
6h 12m
PR unite (30g)
445

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anomalyco/opencode

Tutte le issue di anomalyco/opencode

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.