fix(cli): add missing --depth-gradient flag to project context set #889

Closed
opened 2026-03-13 23:27:26 +00:00 by freemo · 1 comment
Owner

Metadata

  • Commit Message: fix(cli): add --depth-gradient flag to project context set
  • Branch: feature/m4-context-depth-gradient

Background and Context

The specification defines agents project context set with a --depth-gradient <HOP:INT_OR_NAME> repeatable flag (CLI Synopsis line 253). This flag controls how context detail depth degrades with graph distance from focus nodes — a key ACMS feature for managing context budget across related resources.

The current implementation in src/cleveragents/cli/commands/project_context.py includes 22 flags but does not include --depth-gradient. The underlying _default_acms_config() function at line 179 includes a "depth_gradient": {} default, confirming the domain model supports it, but the CLI does not expose it.

Spec reference: [--depth-gradient <HOP:INT_OR_NAME>]... on agents project context set

Expected Behavior

agents project context set --depth-gradient 1:summary --depth-gradient 2:outline --depth-gradient 3:title myproject should configure per-hop depth degradation for the project's context policy.

Acceptance Criteria

  • --depth-gradient flag is added to project context set (repeatable)
  • Flag accepts HOP:INT_OR_NAME format (e.g., 1:summary, 2:5, 3:title)
  • Values are parsed and stored in the project's ContextConfig.depth_gradient field
  • Invalid formats produce clear error messages
  • project context show displays configured depth gradients
  • Multiple --depth-gradient flags in one command are all applied

Subtasks

  • Add --depth-gradient Typer option to project_context.py set command
  • Implement parsing logic for HOP:INT_OR_NAME format
  • Store parsed values in ProjectContextPolicy
  • Display depth gradient in project context show output
  • Tests (Behave): Scenarios for valid gradients, invalid formats, multiple values
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `fix(cli): add --depth-gradient flag to project context set` - **Branch**: `feature/m4-context-depth-gradient` ## Background and Context The specification defines `agents project context set` with a `--depth-gradient <HOP:INT_OR_NAME>` repeatable flag (CLI Synopsis line 253). This flag controls how context detail depth degrades with graph distance from focus nodes — a key ACMS feature for managing context budget across related resources. The current implementation in `src/cleveragents/cli/commands/project_context.py` includes 22 flags but does **not** include `--depth-gradient`. The underlying `_default_acms_config()` function at line 179 includes a `"depth_gradient": {}` default, confirming the domain model supports it, but the CLI does not expose it. **Spec reference**: `[--depth-gradient <HOP:INT_OR_NAME>]...` on `agents project context set` ## Expected Behavior `agents project context set --depth-gradient 1:summary --depth-gradient 2:outline --depth-gradient 3:title myproject` should configure per-hop depth degradation for the project's context policy. ## Acceptance Criteria - [ ] `--depth-gradient` flag is added to `project context set` (repeatable) - [ ] Flag accepts `HOP:INT_OR_NAME` format (e.g., `1:summary`, `2:5`, `3:title`) - [ ] Values are parsed and stored in the project's `ContextConfig.depth_gradient` field - [ ] Invalid formats produce clear error messages - [ ] `project context show` displays configured depth gradients - [ ] Multiple `--depth-gradient` flags in one command are all applied ## Subtasks - [ ] Add `--depth-gradient` Typer option to `project_context.py` `set` command - [ ] Implement parsing logic for `HOP:INT_OR_NAME` format - [ ] Store parsed values in `ProjectContextPolicy` - [ ] Display depth gradient in `project context show` output - [ ] Tests (Behave): Scenarios for valid gradients, invalid formats, multiple values - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added the
Points
2
Priority
Medium
State
Verified
Type
Task
labels 2026-03-13 23:30:23 +00:00
freemo added this to the v3.4.0 milestone 2026-03-13 23:30:32 +00:00
hurui200320 was assigned by freemo 2026-03-14 04:26:58 +00:00
hurui200320 was unassigned by freemo 2026-03-29 02:30:30 +00:00
freemo self-assigned this 2026-03-29 02:30:30 +00:00
freemo added
State
In Progress
and removed
State
Verified
labels 2026-03-29 02:30:40 +00:00
Author
Owner

Implementation Notes

PR: #1186 | Branch: feature/m4-context-depth-gradient | Commit: 4a48e4f2

Changes

src/cleveragents/cli/commands/project_context.py

  • Added --depth-gradient as a repeatable List[str] Typer option to the context_set command (inserted between --skeleton-ratio and --auto-refresh)
  • Parsing logic: splits on first :, validates hop is non-negative integer, value parsed as int or kept as named level string
  • Stores parsed gradient as dict[str, int | str] in acms["depth_gradient"]
  • Updated context_show rich output to display depth gradient (sorted by hop number)

features/project_context_depth_gradient.feature (6 scenarios)

  • Single integer gradient (0:9)
  • Single named level gradient (1:SIGNATURES)
  • Multiple gradients (0:9,1:4,2:MODULE_LISTING)
  • Invalid format (missing colon) → exit 1
  • Invalid hop (non-integer) → exit 1
  • Display in context show output

Nox Results

  • lint: pass
  • format: pass (1705 files unchanged)
  • typecheck: 0 errors, 0 warnings, 0 informations
  • unit_tests (context features): 56 scenarios passed, 0 failed across 4 feature files
## Implementation Notes PR: #1186 | Branch: `feature/m4-context-depth-gradient` | Commit: `4a48e4f2` ### Changes **`src/cleveragents/cli/commands/project_context.py`** - Added `--depth-gradient` as a repeatable `List[str]` Typer option to the `context_set` command (inserted between `--skeleton-ratio` and `--auto-refresh`) - Parsing logic: splits on first `:`, validates hop is non-negative integer, value parsed as int or kept as named level string - Stores parsed gradient as `dict[str, int | str]` in `acms["depth_gradient"]` - Updated `context_show` rich output to display depth gradient (sorted by hop number) **`features/project_context_depth_gradient.feature`** (6 scenarios) - Single integer gradient (`0:9`) - Single named level gradient (`1:SIGNATURES`) - Multiple gradients (`0:9,1:4,2:MODULE_LISTING`) - Invalid format (missing colon) → exit 1 - Invalid hop (non-integer) → exit 1 - Display in `context show` output ### Nox Results - `lint`: pass - `format`: pass (1705 files unchanged) - `typecheck`: 0 errors, 0 warnings, 0 informations - `unit_tests` (context features): 56 scenarios passed, 0 failed across 4 feature files
freemo added
State
In Review
and removed
State
In Progress
labels 2026-03-29 09:31:00 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#889