status method
Where each Profile the project at project binds stands on this
machine, one ProfileBindingStatus per wayfinder.json binding in id
order: ProfileBindingState.resolved, or why select selects nothing
for its bundles, with the diagnostic it reports.
Offline and read-only, like select: it reads wayfinder.json,
wayfinder.lock, the Profile cache and the installed skills' markers,
never runs Git and writes nothing. It parses each cached package as
select does, bounded by packageTimeout. It checks no bundle
directory. Throws config-invalid when wayfinder.json cannot be read
or parsed, and profile-unresolved when project holds none.
Beside the state and diagnostic, each binding reports as data what a consent gate names: why the lock would change (ProfileBindingStatus.lockChange), whether each chain member's mirror and package file are in the cache (ProfileBindingStatus.copies), and each skill directory with its state (ProfileBindingStatus.skillDirectories).
Implementation
Future<ProfileResolutionStatus> status(String project) async {
final (:projectRoot, :configFile) = await _locate(project);
final String raw;
final WayfinderProjectConfig config;
try {
raw = await configFile.readAsString();
config = WayfinderProjectConfig.parse(raw);
} on FileSystemException catch (error) {
throw WayfinderException(
'config-invalid',
'Cannot read ${configFile.path}: ${error.message}.',
);
} on WayfinderConfigException catch (error) {
throw WayfinderException('config-invalid', error.message);
}
final location = ProjectFileLocation(
path: p.basename(configFile.path),
file: configFile.path,
);
final ids = config.profiles.keys.toList()
..sort((left, right) => left.value.compareTo(right.value));
// One read of the lock for the whole status, so the project's
// lockChange and every binding's describe the same lock even while a
// `get` replaces it.
final lock = await _readProjectLock(projectRoot);
ProfileLockChange? lockChange;
if (lock.error case final error?) {
lockChange = ProfileLockChange(
ProfileLockChangeKind.lockMissing,
error.message,
);
} else {
try {
_checkLockedOnly(raw, lock.lock);
} on ProfileLockChangeRequiredException catch (error) {
lockChange = error.change;
}
}
return ProfileResolutionStatus(
projectRoot: projectRoot,
configPath: configFile.path,
lockPath: p.join(projectRoot, 'wayfinder.lock'),
lockChange: lockChange,
bindings: List.unmodifiable([
for (final id in ids)
(await _assess(
projectRoot: projectRoot,
raw: raw,
lock: lock,
binding: config.profiles[id]!,
config: location,
)).status,
]),
);
}