@@ -209,35 +209,6 @@ def remove_from_gitignore(project_root: Path) -> None:
209209 gitignore .write_text ("" .join (new_lines ))
210210
211211
212- def auto_init_project () -> Path :
213- """Auto-initialize project from CWD.
214-
215- Runs core ``init`` logic without parent-directory confirmation and without
216- the "run ``ccc index``" prompt. Returns the project root (CWD).
217- """
218- from .settings import project_settings_path
219-
220- cwd = Path .cwd ().resolve ()
221- settings_file = project_settings_path (cwd )
222-
223- if not settings_file .is_file ():
224- # Create user settings if missing
225- user_path = user_settings_path ()
226- if not user_path .is_file ():
227- save_user_settings (default_user_settings ())
228- _typer .echo (f"Created user settings: { user_path } " )
229-
230- # Create project settings
231- save_project_settings (cwd , default_project_settings ())
232- _typer .echo (f"Created project settings: { settings_file } " )
233- _typer .echo ("You can edit the settings files to customize indexing behavior." )
234-
235- # Update .gitignore
236- add_to_gitignore (cwd )
237-
238- return cwd
239-
240-
241212# ---------------------------------------------------------------------------
242213# Commands
243214# ---------------------------------------------------------------------------
@@ -289,19 +260,7 @@ def init(
289260@app .command ()
290261def index () -> None :
291262 """Create/update index for the codebase."""
292- from .client import ensure_daemon
293-
294- # Auto-init if not in an initialized project
295- root = find_project_root (Path .cwd ())
296- if root is None :
297- root = auto_init_project ()
298-
299- try :
300- client = ensure_daemon ()
301- except Exception as e :
302- _typer .echo (f"Error: Failed to connect to daemon: { e } " , err = True )
303- raise _typer .Exit (code = 1 )
304- project_root = str (root )
263+ client , project_root = require_daemon_for_project ()
305264
306265 _run_index_with_progress (client , project_root )
307266
0 commit comments