fix(init): add warnings for file deletion

Amolith created

- Add prominent warning listing files that will be deleted from root
- Clarify that files are preserved in the new worktree
- Improve dirty repo error with complete stash/pop workflow hint

Assisted-by: Claude Opus 4.5 via Amp

Change summary

src/wt/cmd/init.lua | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)

Detailed changes

src/wt/cmd/init.lua 🔗

@@ -134,7 +134,10 @@ function M.cmd_init(args)
 	-- Check for uncommitted changes
 	local status_out = shell.run_cmd("git status --porcelain")
 	if status_out ~= "" then
-		shell.die("uncommitted changes; commit or stash before converting")
+		io.stderr:write("error: uncommitted changes\n")
+		io.stderr:write("hint: commit, or stash and restore after:\n")
+		io.stderr:write("  git stash -u && wt init && cd <worktree> && git stash pop\n")
+		os.exit(exit.EXIT_USER_ERROR)
 	end
 
 	-- Detect default branch
@@ -196,14 +199,22 @@ function M.cmd_init(args)
 		io.stderr:write("warning: " .. w .. "\n")
 	end
 
-	-- Confirm with gum (unless -y/--yes)
-	if not skip_confirm then
-		local confirm_msg = "Convert to wt bare structure? This will move .git to .bare"
-		if #orphaned > 0 then
-			confirm_msg = confirm_msg .. " and remove " .. #orphaned .. " items from root"
+	-- Prominent warning about file deletion
+	if #orphaned > 0 then
+		io.stderr:write("\n")
+		io.stderr:write("WARNING: The following " .. #orphaned .. " items will be DELETED from project root:\n")
+		for _, item in ipairs(orphaned) do
+			io.stderr:write("  - " .. item .. "\n")
 		end
+		io.stderr:write("\n")
+		io.stderr:write("These files are preserved in the new worktree at:\n")
+		io.stderr:write("  " .. worktree_path .. "\n")
+		io.stderr:write("\n")
+	end
 
-		local confirm_code = os.execute("gum confirm '" .. confirm_msg .. "'")
+	-- Confirm with gum (unless -y/--yes)
+	if not skip_confirm then
+		local confirm_code = os.execute("gum confirm 'Convert to wt bare structure?'")
 		if confirm_code ~= true then
 			print("Aborted")
 			os.exit(exit.EXIT_USER_ERROR)