## ADDED Requirements ### Requirement: Display Profile Includes The system SHALL display the ordered list of profiles that a config profile includes, with each include showing the included profile's name and scope. #### Scenario: View includes on profile editor - **WHEN** a user opens a config profile in the editor - **AND** that profile has includes configured - **THEN** the editor shows an "Includes" section - **AND** each include displays the profile name - **AND** each include displays a scope badge (Global, Project, Tool, or Project + Tool) - **AND** includes are shown in their resolution order (first to last) #### Scenario: Empty includes section - **WHEN** a user opens a config profile in the editor - **AND** that profile has no includes - **THEN** the "Includes" section is visible but empty - **AND** it shows a message indicating no includes are configured ### Requirement: Add Profile Includes The system SHALL allow users to add other compatible profiles as includes to the currently edited profile. #### Scenario: Add an include - **WHEN** a user clicks "Add Include" in the profile editor - **THEN** a dropdown appears with available profiles - **AND** the dropdown excludes the current profile - **AND** the dropdown excludes profiles already included - **AND** the dropdown excludes profiles that would create an include cycle - **AND** each option shows the profile name with its scope badge - **WHEN** the user selects a profile - **THEN** it is appended to the includes list - **AND** it appears at the end of the resolution order #### Scenario: Prevent self-inclusion - **GIVEN** a user is editing profile "A" - **WHEN** they attempt to include profile "A" itself - **THEN** profile "A" does not appear in the dropdown #### Scenario: Prevent duplicate includes - **GIVEN** profile "A" already includes profile "B" - **WHEN** a user attempts to add another include - **THEN** profile "B" does not appear in the dropdown #### Scenario: Prevent cyclic includes - **GIVEN** profile "A" includes profile "B" - **AND** profile "B" includes profile "C" - **WHEN** a user is editing profile "C" - **THEN** profile "A" does not appear in the dropdown - **AND** profile "B" does not appear in the dropdown - **BECAUSE** including either would create a cycle ### Requirement: Remove Profile Includes The system SHALL allow users to remove includes from a profile. #### Scenario: Remove an include - **WHEN** a user clicks the remove button on an include row - **THEN** that include is removed from the list - **AND** the remaining includes maintain their relative order ### Requirement: Reorder Profile Includes The system SHALL allow users to reorder profile includes via drag-and-drop, where order determines resolution priority. #### Scenario: Reorder includes via drag-and-drop - **GIVEN** a profile includes profiles in order: B, C, D - **WHEN** a user drags "C" before "B" - **THEN** the order becomes: C, B, D - **AND** the resolution order is updated accordingly #### Scenario: Resolution order affects overrides - **GIVEN** profile "A" includes "B" then "C" - **AND** both "B" and "C" define the same environment variable "FOO" - **WHEN** the profile is resolved - **THEN** the value from "C" wins because it comes later in the order ### Requirement: Save Profile Includes The system SHALL save profile includes when the user saves the profile form. #### Scenario: Save includes with profile - **GIVEN** a user has modified the includes list (added, removed, or reordered) - **WHEN** they click "Save Profile" - **THEN** the includes are saved via the includes API - **AND** the profile fields are saved via the profile update API - **AND** both operations succeed or both fail #### Scenario: Include cycle error on save - **GIVEN** a user has configured includes that would create a cycle - **WHEN** they attempt to save - **THEN** the save fails - **AND** an error message displays the cycle path - **AND** the form remains editable so the user can fix it ### Requirement: Show Include Count in Profile List The system SHALL display the number of includes each profile has in the profile list sidebar. #### Scenario: Profile list shows include count - **WHEN** a user views the config profiles list - **THEN** each profile that has includes shows a badge with the count - **AND** profiles with no includes show no badge