feat: add /features command and lifecycle visibility

This commit is contained in:
Jerop Kipruto
2026-02-18 11:53:18 -05:00
parent 04f22a51b1
commit 0640faa4c6
11 changed files with 473 additions and 1 deletions
+32
View File
@@ -67,6 +67,18 @@ export interface FeatureSpec {
description?: string;
}
/**
* FeatureInfo provides a summary of a feature's current state and metadata.
*/
export interface FeatureInfo {
key: string;
enabled: boolean;
stage: FeatureStage;
since?: string;
until?: string;
description?: string;
}
/**
* FeatureGate provides a read-only interface to query feature status.
*/
@@ -79,6 +91,10 @@ export interface FeatureGate {
* Returns all known feature keys.
*/
knownFeatures(): string[];
/**
* Returns all features with their status and metadata.
*/
getFeatureInfo(): FeatureInfo[];
/**
* Returns a mutable copy of the current gate.
*/
@@ -189,6 +205,22 @@ class FeatureGateImpl implements MutableFeatureGate {
return Array.from(this.specs.keys());
}
getFeatureInfo(): FeatureInfo[] {
return Array.from(this.specs.entries())
.map(([key, specs]) => {
const latestSpec = specs[specs.length - 1];
return {
key,
enabled: this.enabled(key),
stage: latestSpec.preRelease,
since: latestSpec.since,
until: latestSpec.until,
description: latestSpec.description,
};
})
.sort((a, b) => a.key.localeCompare(b.key));
}
deepCopy(): MutableFeatureGate {
const copy = new FeatureGateImpl();
copy.specs = new Map(