Description
There is significant code duplication between hookSettings.ts, skillSettings.ts, and agentSettings.ts in packages/cli/src/utils/.
All three files implement similar logic for:
- Enabling/disabling features (hooks, skills, agents).
- Iterating over writable scopes (User, Workspace).
- Checking existing states and modifying settings.
- Defining result interfaces (
HookActionResult, SkillActionResult, AgentActionResult) that share a common structure.
Additionally, ModifiedScope is currently defined in skillSettings.ts and imported by the others, which creates an implicit dependency.
Proposed Solution
Extract the common logic into a generic utility (e.g., packages/cli/src/utils/featureToggleUtils.ts or similar).
This utility should handle:
- The generic flow of checking scopes and updating settings.
- A shared
FeatureActionResult interface.
ModifiedScope definition.
Acceptance Criteria
- Create a shared utility for feature toggling.
- Refactor
hookSettings.ts, skillSettings.ts, and agentSettings.ts to use this shared utility.
- Ensure all existing tests pass.
Description
There is significant code duplication between
hookSettings.ts,skillSettings.ts, andagentSettings.tsinpackages/cli/src/utils/.All three files implement similar logic for:
HookActionResult,SkillActionResult,AgentActionResult) that share a common structure.Additionally,
ModifiedScopeis currently defined inskillSettings.tsand imported by the others, which creates an implicit dependency.Proposed Solution
Extract the common logic into a generic utility (e.g.,
packages/cli/src/utils/featureToggleUtils.tsor similar).This utility should handle:
FeatureActionResultinterface.ModifiedScopedefinition.Acceptance Criteria
hookSettings.ts,skillSettings.ts, andagentSettings.tsto use this shared utility.