Skip to content

sdk/local: nebi owns existing project directories (#683) - #694

Open
gsegovia2018 wants to merge 1 commit into
ux-rework-devfrom
guillermo/683-directory-ownership
Open

gsegovia2018 wants to merge 1 commit into
ux-rework-devfrom
guillermo/683-directory-ownership

Conversation

@gsegovia2018

@gsegovia2018 gsegovia2018 commented Nov 26, 2026 •

Copy link
Copy Markdown

Closes #683.

Summary

Implements the decision in #683: a project may use an existing directory, nebi owns it once the project is created, and deleting the project with its files removes that directory with everything in it, the same as a directory nebi created.

  • CreateProject no longer distinguishes nebi-created and existing directories.
  • DeleteProject with DeleteFiles no longer refuses existing directories.
  • Removed Project.ManagedDir, ProjectDetail.ManagedDir (managed_dir in JSON) and ErrFilesNotManaged.

Protected directories (beyond the decision)

Owning any existing directory means delete-with-files can now remove far more than before, so this adds ErrProtectedPath. CreateProject refuses, and DeleteProject refuses to delete the files of, a directory that is:

  • a filesystem root,
  • the home directory or a directory that contains it,
  • the projects directory (Options.ProjectsDir, default ~/nebi-projects) or a directory that contains it.

The checks compare directories on disk (os.SameFile), so symlinks and case-insensitive filesystems are covered. The delete-time check also guards rows created before this change. Projects inside the projects directory, such as ~/nebi-projects/foo, are unaffected.

The projects directory is guarded because a project there would contain every default project directory, including directories kept by delete-without-files, and would already block every default create with ErrPathTaken.

Notes

Deleting the whole directory

Delete-with-files removes the whole directory, including files nebi never wrote. pmeier confirmed this is the intended behavior for now (comment); finer-grained deletion can come later.

Testing

go test -race ./internal/client/..., go vet, gofmt and golangci-lint are clean. New tests cover create and delete refusing the root, home, the projects directory, their parents and a symlink to home, plus deleting an existing directory with its files.

AI disclosure
  • Model: Claude Opus 5.5 (claude-opus-5-5) via Claude Code.
  • What was generated: the code and test changes in internal/client/sdk/local and this PR description, reviewed and approved by the author before pushing.
  • Prompt summary: analyze Directory ownership and deletion behavior #683, plan and implement the decision (existing directories allowed, ManagedDir removed), run a multi-reviewer critical pass, then explain the changes before opening a draft PR.
  • Agent instructions: strictly necessary diffs only, no drive-by changes, tests before claiming done, show a change summary and wait for approval before pushing.

@pmeier

pmeier commented Nov 26, 2026

Copy link
Copy Markdown
Member

Delete-with-files now removes the whole directory, including files nebi never wrote. Is that the intended behavior, or should it remove only nebi's files (pixi.toml, pixi.lock, .pixi), or should create make a nebi subfolder inside a chosen directory?

IMO full deletion is fine for now. Ownership means that the directory and everything in it belongs to nebi and in turn can be deleted if the user instructs nebi to do so. We can build more complex logic later.

@pmeier
pmeier requested a review from MUFFANUJ November 27, 2026 12:58
@pmeier pmeier linked an issue Nov 27, 2026 that may be closed by this pull request
@gsegovia2018
gsegovia2018 marked this pull request as ready for review November 27, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Directory ownership and deletion behavior

2 participants