poteto-mode worktree cleanup: untracked files are labelled "scratch, safe to drop", and paths with spaces are truncated

Offen
#1,054 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
65/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
awk, git, markdown, shell
Bereich
tooling

Rechercherichtung

Start by reading scripts/worktree-audit.sh and playbooks/worktree-cleanup.md, then reproduce both defects: a merged-branch worktree with an untracked new-provider-parser.ts, and a worktree path containing a space. The audit needs to hold non-ignored untracked files instead of calling them scratch, parse git worktree list --porcelain -z so full paths survive, and mark failed git inspections as unknown rather than clean. Update the playbook wording and add tests for untracked-only, spaced-path, and git-failure cases; done when those tests pass and the audit no longer labels such work safe.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Found against pstack 0.15.34 at cursor/plugins 519d36aa98955bf680db01bcde5fdfba686dc901 (harness/pstack/claude-code/skills/poteto-mode/). Line numbers refer to that commit.

scripts/worktree-audit.sh, together with playbooks/worktree-cleanup.md, can lead an agent to delete work that
exists nowhere in git. There are two defects.

A. Untracked files are classed as disposable.

  • worktree-audit.sh:93-97: a worktree whose git status --porcelain has only ?? lines becomes scratch:N. The
    bucket logic (:125) then rates it safe when the branch is merged or has a PR.
  • worktree-cleanup.md:6 says "scratch:N is untracked throwaway, safe to drop", and step 7 runs
    git worktree remove --force <path>.

Being untracked doesn't make a file disposable. A new source file that hasn't been git added yet is the most common
form of unfinished work.

Repro:

  1. Create a worktree on a branch that is already merged (or has a merged PR).
  2. Add an untracked new-provider-parser.ts with unfinished code.
  3. Run the audit. The row is scratch:1, bucket safe.
  4. Follow the playbook. The worktree is force-removed and the file is lost, without the decision the playbook requires
    for tracked WIP.

B. Path parsing and failed inspection.

  • worktree-audit.sh:31 and :80 use awk '{print $2}' on git worktree list --porcelain, which drops everything
    after the first space. A worktree at /tmp/my worktrees/branch-one is read as /tmp/my.
  • :93: git -C "$wt" status --porcelain 2>/dev/null. When $wt is wrong or git fails, the output is empty and the
    row is reported as clean, so a failed inspection looks safe.
  • :115-116: transcript matching passes the path to rg -e as a regex (. and + match other paths), and
    xargs stat splits filenames on whitespace.

Repro (parsing):

Input:  worktree /tmp/my worktrees/branch-one
Output: /tmp/my

Suggested fix:

  • Treat untracked files that aren't ignored as WIP (hold-wip), the same as tracked edits. Only drop them after the
    user has confirmed them by name, or after they have been preserved (stash with -u, or copied out). Change the
    playbook text to match.
  • Parse git worktree list --porcelain -z (NUL-delimited) and keep the full path.
  • When rev-parse, log or status fails, make the row unknown / held, never clean.
  • Use rg -F (fixed strings) for the transcript match, and rg -l0 … | xargs -0 stat.
  • Add tests for a worktree with only untracked files, a path with a space, and a git failure.
Vorherrschende Sprache
TypeScript
Sterne
18.2k
Forks
2k
Ø Merge
3 Std. 56 Min.
Gemergte PRs (30 T.)
96

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus cursor/plugins

Alle Issues in cursor/plugins

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.