First real content under app/. Lays the whole Tier 0 foundation in one
commit because the pieces depend on each other circularly (kernel →
extension → widgets → built-ins all reference types from the layer
below); splitting would leave intermediate commits that don't compile.
Key shapes:
* bare WidgetsApp root — no Material, no Cupertino, no Scaffold.
ClideTheme InheritedWidget is the only source of tokens.
* ClideKernel InheritedWidget aggregates 18 services (settings,
project, extensions, theme, panels, events, ipc, commands +
palette + keybindings, clipboard, files, notify, dialog, tray,
secrets, os, net, focus, log, i18n). ExtensionContext exposes
them through a stable interface.
* ClideExtension + sealed ContributionPoint hierarchy (Tab,
StatusItem, Toolbar, Command, TrayItem, LayoutPreset). One
manifest ships N contributions into kernel slots.
* Three-tier theme pipeline: palette (named colors) → semantic
roles → ~60 surface tokens. Defaults at each layer so legacy
palette-only themes produce a complete SurfaceTokens.
* A11y baked in from day one — every interactive primitive wraps
in Semantics(label:, hint:, button:); ensureSemantics() at boot;
theme/contrast.dart helper exposes token pairs for the WCAG
gate in the a11y test suite.
* i18n ported from fframe's L10n pattern (text-driven, namespaced
JSON catalogs, caller-supplied placeholders) with a proper
locale fallback chain (exact → language → default → placeholder)
fframe lacks.
* Four Tier-0 built-ins live (default-layout, welcome, ipc-status,
theme-picker) plus 17 id-reserving stubs so later tiers fill in
without rename churn.
.gitignore extended to cover app/ sub-package artefacts and the
Playwright harness scratch dirs.
Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
1.9 KiB
Dart
68 lines
1.9 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:clide_app/kernel/src/events/bus.dart';
|
|
import 'package:clide_app/kernel/src/events/types.dart';
|
|
import 'package:clide_app/kernel/src/log.dart';
|
|
import 'package:clide_app/kernel/src/settings.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
class ProjectManager extends ChangeNotifier {
|
|
ProjectManager({
|
|
required Logger log,
|
|
required EventBus events,
|
|
required SettingsStore settings,
|
|
}) : _log = log,
|
|
_events = events,
|
|
_settings = settings;
|
|
|
|
final Logger _log;
|
|
final EventBus _events;
|
|
final SettingsStore _settings;
|
|
|
|
Directory? _current;
|
|
Directory? get current => _current;
|
|
bool get isOpen => _current != null;
|
|
|
|
/// Open a project by path. Runs `git rev-parse --show-toplevel` to
|
|
/// find the workspace root. Returns true on success.
|
|
Future<bool> open(String path) async {
|
|
final root = await resolveWorkspace(path);
|
|
if (root == null) {
|
|
_log.warn('project', 'not a git repo: $path');
|
|
return false;
|
|
}
|
|
_current = Directory(root);
|
|
await _settings.setProjectDir(_current);
|
|
_events.emit(ProjectOpened(path: root));
|
|
notifyListeners();
|
|
return true;
|
|
}
|
|
|
|
Future<void> close() async {
|
|
if (_current == null) return;
|
|
_current = null;
|
|
await _settings.setProjectDir(null);
|
|
_events.emit(const ProjectClosed());
|
|
notifyListeners();
|
|
}
|
|
|
|
/// Walks up from [path] via `git rev-parse --show-toplevel`. Returns
|
|
/// null if the path is outside a git repo or git isn't available.
|
|
Future<String?> resolveWorkspace(String path) async {
|
|
try {
|
|
final r = await Process.run(
|
|
'git',
|
|
['rev-parse', '--show-toplevel'],
|
|
workingDirectory: path,
|
|
runInShell: false,
|
|
);
|
|
if (r.exitCode != 0) return null;
|
|
final out = (r.stdout as String).trim();
|
|
return out.isEmpty ? null : out;
|
|
} catch (e) {
|
|
_log.debug('project', 'git rev-parse failed: $e');
|
|
return null;
|
|
}
|
|
}
|
|
}
|