---
id: TASK-2.1
title: Implement `profiles` command in commands module
status: Done
assignee:
  - codex
created_date: '2026-01-29 18:16'
updated_date: '2026-01-29 18:20'
labels: []
dependencies: []
references:
  - lua/zync/api/commands/commands.lua
  - lua/zync/api/manager.lua
  - lua/zync/api/configurator.lua
  - lua/zync/api.lua
parent_task_id: TASK-2
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Add the `profiles`/`p` command to the commands module and manager so it mirrors existing list commands (boards/runners) and surfaces the configured profile list or the profile-less message.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 `profiles` command is registered in `lua/zync/api/commands/commands.lua` with shorthand `p` and documented in CLI help
- [x] #2 Manager implements a `profiles` handler that lists configured profiles or prints the profile-less message when none are configured
- [x] #3 Profile list order is deterministic (as defined in zconf.lua) and exits 0
- [x] #4 Command works from project root or build dir without breaking existing commands
- [x] #5 Unit/integration hooks are in place for tests (no missing exports)
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1) Add `profiles` to the command registry in `lua/zync/api/commands/commands.lua` with shorthand `p`, mirroring boards/runners.
2) Implement `Manager.profiles` in `lua/zync/api/manager.lua` to print profiles (deterministic order) or the profile‑less message when none configured.
3) Ensure order comes from config (use `config.profile_order` if available, or fall back to deterministic derivation).
4) Wire the command handler to manager and ensure it works from project root or build dir (using existing `config.project_dir`/build dir logic).
5) Update any exports or references needed for test hooks.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added `config.profile_order` in configurator to preserve zconf profile order (`lua/zync/api/configurator.lua`).

Implemented `Manager.profiles` to list configured profiles or emit profile-less message (`lua/zync/api/manager.lua`).

Registered `profiles`/`p` command in `lua/zync/api/commands/commands.lua`.
<!-- SECTION:NOTES:END -->
