feat(cli): clide project new — create + git-init a new project (T-487)

The backend half of the new-project flow (story T-486). createNewProject
validates the name, makes <parent>/<name>/, runs git init (injected from the
toolchain in main.dart so the handler stays Flutter-free), and writes a minimal
scaffold (.gitignore + a CLAUDE.md stub). The project.new verb wraps it; --dir
defaults to the current workspace's parent so a new project lands beside it.

Create-only by design — opening the new workspace and the account roadblock are
the UI flow's job (T-488). Closes T-487.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 08:23:18 +02:00
co-authored by Claude Opus 4.8
parent b9fc720f97
commit adaf8966dc
6 changed files with 196 additions and 0 deletions
+9
View File
@@ -43,6 +43,7 @@ import 'package:clide/src/daemon/editor_commands.dart';
import 'package:clide/src/daemon/files_commands.dart';
import 'package:clide/src/daemon/git_commands.dart';
import 'package:clide/src/daemon/image_commands.dart';
import 'package:clide/src/daemon/project_commands.dart';
import 'package:clide/src/daemon/instance_command.dart';
import 'package:clide/src/daemon/log_commands.dart';
import 'package:clide/src/daemon/pane_commands.dart';
@@ -332,6 +333,14 @@ Future<void> main() async {
registerEditorCommands(dispatcher, editorRegistry);
final gitClient = GitClient(toolchain: tc, workDir: workRoot);
registerGitCommands(dispatcher, gitClient, eventSink);
// `clide project new <name>` (T-487): create + git-init a new project dir.
// git init runs over the *new* dir via the toolchain; --dir defaults to the
// current workspace's parent so a new project lands beside this one.
registerProjectCommands(
dispatcher,
gitInit: (dir) => GitClient(toolchain: tc, workDir: Directory(dir)).init(),
defaultParent: () => workRoot.parent.path,
);
final pql = PqlClient(workDir: workRoot, toolchain: tc);
registerPqlCommands(dispatcher, pql);
registerPanelCommands(dispatcher, ArrangementPanelResizer(arrangement));