Repository navigation
Description
Problem or Motivation
After the Rich theme of #4748 merges, about 577 inline markups in 58 files (688 minus the 111 of messages.py) and 162 style= arguments still name colors directly, such as [green], [bold red] or style="cyan". The output of the same state can then still differ from module to module, and the theme roles do not apply there.
Proposed Solution & Architectural Design
- Move the inline markups and
style=arguments to the role names ofsrc/devops_cli/design/roles.ini(status.ok,status.warn,status.error,sev.*,muted,heading,accent,link,code). - Do the move one module group at a time, in 2 or 3 pull requests, so each pull request stays small.
- Add an ast-grep rule (Python is a built-in ast-grep language) that rejects raw color names in markup strings and
style=arguments outsideoutput/console.pyandroles.ini.
Target Subsystem
Terminal output (src/devops_cli/).
Existing Tool Considered
Rich theme roles (Rich 15.0.0, in use) and ast-grep (in use, with sgconfig.yml). No new dependency and no custom checker. Cost (estimate): about 150,000 tokens and 1 day over the pull requests.
Acceptance Criteria
- The ast-grep rule reports 0 raw color names in
src/devops_clioutside the allowed files. - The existing output tests pass.
Dependencies
- feat(output): add one Rich theme of status roles and marks #4748 (the Rich theme and its roles).
Source: #4735
Alternatives check of 2026-11-14: not-applicable.
Class: refactor, no search.
Tool: none found.
Proposed design
Problem statement
About 577 inline Rich markups and 162 style= arguments in 58 files name raw colors such as [green] and style="cyan". The same state can then render differently from module to module, and the theme roles do not apply there. The change moves each markup and each style= argument to a theme role of #4748 and adds an ast-grep rule that rejects a raw color name. The work waits on #4748 and is too big for one pull request, so three pull requests deliver it.
Acceptance criteria
Requirement: Raw color names in markup strings are rejected
The ast-grep rule SHALL report a raw Rich color name in a markup string of src/devops_cli, unless the file is src/devops_cli/output/console.py or src/devops_cli/design/roles.ini.
Scenario: A command prints a raw color
- WHEN A Python file under
src/devops_cli/commands/holds the markup string[green]ok[/green]. - THEN
ast-grep scanreports one finding at that line, and the invalid case of the rule test matches it.
Requirement: Raw color names in style arguments are rejected
The ast-grep rule SHALL report a raw Rich color name in a style= argument of src/devops_cli, unless the file is src/devops_cli/output/console.py or src/devops_cli/design/roles.ini.
Scenario: A table sets a raw color
- WHEN A Python file under
src/devops_cli/roadmap/passesstyle="cyan"to a Rich object. - THEN
ast-grep scanreports one finding at that line, and the invalid case of the rule test matches it.
Requirement: Theme role names pass the rule
The ast-grep rule MUST accept each role name of the theme in a markup string and in a style= argument.
Scenario: A module prints a role name
- WHEN A Python file under
src/devops_cli/holds[status.ok]ok[/status.ok]andstyle="muted". - THEN
ast-grep scanreports no finding for those lines, and the valid case of the rule test passes.
Requirement: The theme files keep their raw color names
The ast-grep rule MUST report no finding for src/devops_cli/output/console.py and src/devops_cli/design/roles.ini.
Scenario: The theme names a raw color
- WHEN
src/devops_cli/output/console.pypassesstyle="cyan"to a Rich object, andsrc/devops_cli/design/roles.inimapsstatus.oktogreen. - THEN
ast-grep scanreports no finding for those files, and the valid case of the rule test passes.
Requirement: No raw color name remains outside the theme
Each migrated module SHALL name a theme role instead of a raw Rich color in a markup string and in a style= argument.
Scenario: The whole package is scanned
- WHEN
ast-grep scanruns onsrc/devops_cliafter the last module group merges. - THEN The scan reports zero raw color names outside
src/devops_cli/output/console.pyandsrc/devops_cli/design/roles.ini.
Requirement: Rendered output stays the same
The rendered output of each migrated message MUST equal its output before the migration.
Scenario: The output tests run on a migrated module group
- WHEN The suite
tests/output/test_output.pyruns on the pull request of a module group. - THEN Each test passes with no change to its expected string.
Existing Tool Considered
Rich 15.0.0 (pyproject.toml:14) supplies the theme roles, and ast-grep 0.51.2 (pyproject.toml:123) supplies the scan. Neither has a built-in rule for a raw Rich color in a markup string or a style= argument, so the change writes one ast-grep rule and its rule tests. The body estimates that code at about 150,000 tokens and 1 day over the pull requests. The alternatives check of 2026-11-14 recorded not-applicable for a refactor, with no search and no tool.
Key questions
- Which file builds the shared Rich console, and which files may keep a raw color name?:
src/devops_cli/output/console.pybuilds the shared console (get_console, lines 80-114). The issue allows raw color names only in that file and insrc/devops_cli/design/roles.ini; the theme file is not in this commit, so it arrives with feat(output): add one Rich theme of status roles and marks #4748. [sources: src/devops_cli/output/console.py:80, docs/DESIGN.md:266] - Where do the ast-grep rules and their tests live?: The rules live in
.ast-grep/rules/and the rule tests in.ast-grep/rule-tests/, assgconfig.ymlsets them. [sources: sgconfig.yml:1, sgconfig.yml:3] - Does the migration include
src/devops_cli/lang/en/messages.py?: Yes. The rule scans all ofsrc/devops_cli, and the acceptance criterion exempts only the theme files. (best practice) [sources: src/devops_cli/lang/en/messages.py:120, src/devops_cli/output/console.py:80]- Chosen: Include
messages.pyin the migration. The gate allows only the theme files to name a raw color, so its 111 markups must move. The 577 count leaves them out as an estimate of the rest, not as a scope limit. - Rejected: Leave
messages.pyout of the migration. The rule would then need a second exempt file, and the gate of the body names none.
- Chosen: Include
- Which role replaces each raw color name?:
docs/DESIGN.md:266records the terminal theme:greenmaps tostatus.ok,yellowtostatus.warn,redandbold redtostatus.error, default or no color tostatus.info,dimtomuted, andcyantoaccent. Keepboldas a modifier where the role is not already bold. A severity uses the onesev.*map; a heading, link or code span usesheading,linkorcodewhere feat(output): add one Rich theme of status roles and marks #4748 defines them. A raw color with no role (magenta,blue,white) takes the role of its content:accentfor emphasis,codefor a language or code token, andmutedfor an unknown or secondary value. Do not add a new role for a hue. (best practice) [sources: docs/DESIGN.md:266, docs/adr/0024-the-project-owns-its-design-tokens-in-the-dtcg-format-and-style-dictionary-builds-them.md:12, src/devops_cli/commands/rag.py:404, src/devops_cli/review/report.py:868]- Chosen: Map by the recorded terminal theme and the meaning of the text.
docs/DESIGN.md:266records the six ANSI mappings and the one severity map; the remaining roles are semantic, so magenta, blue and white go toaccent,codeormutedinstead of new hue roles. - Rejected: Add a theme role for each raw color name. It copies the ANSI table into
roles.ini, keeps the module-to-module drift, and gives magenta, blue and white roles that the theme does not define. - Rejected: Keep the raw colors outside the console. It leaves the problem of the item and fails the ast-grep gate.
- Chosen: Map by the recorded terminal theme and the meaning of the text.
- When does the ast-grep rule land, and how does the scan stay green?: The rule lands in the first pull request with
filesset to the migrated paths, and each later pull request adds its paths. The last pull request setsfilesto all ofsrc/devops_cli. (best practice) [sources: sgconfig.yml:1, docs/DESIGN.md:78]- Chosen: Rule first, scoped by
files, extended per pull request. The scan passes at each pull request, and no list of 58 exempt files is kept. - Rejected: Rule last, after every module group. The first two pull requests can add a new raw color with no check.
- Rejected: Rule first with an allowlist of the 58 files. Each pull request edits the allowlist, and the list is easy to leave stale.
- Chosen: Rule first, scoped by
- How does the migration keep the rendered output the same?:
docs/DESIGN.md:266maps each role to the ANSI color and attribute of the markup it replaces:status.erroris bold red,status.okgreen,status.warnyellow,status.infodefault,muteddim,accentcyan. Aboldmodifier stays on a role that is not already bold. A pull request changes no expected string oftests/output/test_output.py. (best practice) [sources: docs/DESIGN.md:266, tests/output/test_output.py:414]- Chosen: Keep the expected strings and fix the role. A changed expected string hides a change of the rendered output.
- Rejected: Update the expected strings in the output tests. It accepts a different output with no record of the change.
Fit
Needs splitting into 3 items:
- Pull request 1: migrate
src/devops_cli/output/exceptconsole.py,src/devops_cli/ui/andsrc/devops_cli/lang/en/messages.py, and add the ast-grep rule and its rule tests, withfilesset to those paths. - Pull request 2: migrate
src/devops_cli/commands/andsrc/devops_cli/roadmap/, and extend the rulefilesto those paths. - Pull request 3: migrate every remaining file that the scan reports, including
src/devops_cli/ai/,docs/,github/,prometheus/,config/,server/,review/,k8s/andtelemetry/, and extend the rulefilesto all ofsrc/devops_cli.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
refactorprefix of the title gives the type.(output)scope of the title gives the scope.It is a planned consistency refactoring with a clear dependency on #4748 and no user-facing defect it fixes.It removes per-module color inconsistency and adds a lint rule that prevents future drift, improving maintainability for all CLI users.The body estimates about 150,000 tokens and 1 day across 2 or 3 pull requests, which is moderate.Both work on Rich terminal output in src/devops_cli, but #326 builds the renderables architecture while this candidate migrates existing inline markup to the theme roles that architecture provides.devops-cli-service commentedon Nov 14, 2026
Alternatives check: not-applicable
Class: refactor. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
The proposal at e5dfddb needs splitting into 3 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.
src/devops_cli/output/exceptconsole.py,src/devops_cli/ui/andsrc/devops_cli/lang/en/messages.py, and add the ast-grep rule and its rule tests, withfilesset to those paths.src/devops_cli/commands/andsrc/devops_cli/roadmap/, and extend the rulefilesto those paths.src/devops_cli/ai/,docs/,github/,prometheus/,config/,server/,review/,k8s/andtelemetry/, and extend the rulefilesto all ofsrc/devops_cli.