Skip to content

Refactor common settings logic for hooks, skills, and agents #17348

@sehoon38

Description

@sehoon38

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

  1. Create a shared utility for feature toggling.
  2. Refactor hookSettings.ts, skillSettings.ts, and agentSettings.ts to use this shared utility.
  3. Ensure all existing tests pass.

Metadata

Metadata

Assignees

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalityhelp wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions