DES-374: Token candidates + parallel pipeline + sub-agent fix proposals#5
Merged
Merged
Conversation
Three additions to lotus-audit-ios, all working together off a single
audit run:
1. **Token candidates** (new analyser script): finds hardcoded values used
3+ times in iOS code that aren't already Lotus tokens. Classifies each
as `use-existing-token` (adoption gap — value matches a token, just
typed as a literal), `near-miss` (1pt off — likely typo), or
`new-candidate` (worth proposing as a new Figma token). Excludes the
colour-system definition files (UIColor+JP.swift, +Design2.0.swift,
+fromHEX.swift) so their internal hex literals don't surface as
candidates. Real findings on the live iOS repo include 5× literal
`10pt` spacing — iOS has `spacingSemiSmall=10` but Figma doesn't, so
this surfaces as a "new-candidate" for Figma.
2. **Parallel pipeline**: Stage 1 (4 data scripts) and Stage 2 (3
analysers) have no inter-stage dependencies and now run in parallel
via simultaneous `Bash` tool calls in a single message. Roughly halves
wall-clock time from the old sequential run. Documented in SKILL.md
with a 4-stage mermaid diagram replacing the old 5-phase flow.
3. **Per-file fix-proposal sub-agents**: new Stage 3 in the pipeline
spawns one general-purpose `Task` agent per top worst-offender file
(top 10, ≥5 violations). Each sub-agent reads the file with full Lotus
token namespace context and proposes concrete migrations as JSON:
line, current snippet, proposed snippet, token used, confidence,
optional caveat. Orchestrator aggregates to /tmp/fix-proposals.json;
build-report.mjs renders a "Suggested fixes — worst-offender files"
section. Smoke-test on 4 real files produced 47 high-confidence
migrations including .jpGreen → LotusColours.Brand.justparkGreen,
Font.heavy.font(forSize: 16) → LotusTypography.bodyMediumBold, and
`.padding(8)` → `.padding(LotusSpacing.spacingXSmall)`.
Files:
- scripts/token-candidates.mjs (new)
- scripts/build-report.mjs (consume both new inputs; degrade gracefully)
- SKILL.md
- allowed-tools += Task
- Pipeline mermaid diagram now shows Stage 1/2/3/4
- Phases reorganised as parallel Stage 1 + parallel Stage 2 +
sub-agent Stage 3 + Stage 4 (build-report)
- Stage 3 includes the full sub-agent prompt template + aggregation
contract, plus the "skip if Task tool unavailable" graceful-degrade
- Report-structure list bumped to include the two new sections
- Important rules note the parallel-execution expectation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
🚨 gitStream Monthly Automation Limit Reached 🚨 Your organization has exceeded the number of pull requests allowed for automation with gitStream. To continue automating your PR workflows and unlock additional features, please contact LinearB. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: DES-374 — Lotus Design System (Epic)
Stacked on: #4 (typography parity)
Summary
Three additions, all building on the same audit run.
1. Token candidates from iOS
New
scripts/token-candidates.mjsfinds hardcoded values used 3+ times in iOS code that aren't already Lotus tokens. Classifies each as:Real findings on the live iOS repo include
10ptspacing used 5× — iOS already hasLotusSpacing.spacingSemiSmall = 10but Figma doesn't. The script surfaces this as a "new-candidate" for Figma. Other findings: 20× literal12pt(should usespacingSmall),5ptnear-miss ofspacingXXSmall=4, etc.Excludes the colour-system definition files (
UIColor+JP.swift,UIColor+Design2.0.swift,UIColor+fromHEX.swift) so their internal hex literals don't surface as candidates.2. Parallel pipeline
Stage 1 (four extract scripts: figma-fetch, parse-colours, parse-typography, scan-ios) and Stage 2 (three analysers: colour-parity, typography-parity, token-candidates) have no inter-script dependencies. Now invoked via simultaneous
Bashtool calls in a single message. Roughly halves wall-clock time vs the old sequential run.SKILL.md now leads with a four-stage mermaid diagram (Stage 1 / 2 / 3 / 4) and explicitly tells the orchestrator: "send these as four parallel Bash tool calls in one message".
3. Per-file fix-proposal sub-agents (new Stage 3)
New stage spawns one general-purpose
Taskagent per worst-offender file (top 10, gated to ≥5 violations). Each sub-agent reads its file with the full Lotus token namespace as context, then proposes concrete migrations as JSON: line, current snippet, proposed snippet, token used, confidence, optional caveat.Orchestrator aggregates results to
/tmp/fix-proposals.json.build-report.mjsrenders a new "Suggested fixes — worst-offender files" section with one table per file.Smoke-test on 4 real files produced 47 high-confidence migrations including:
.jpGreen→LotusColours.Brand.justparkGreenFont.heavy.font(forSize: 16)→LotusTypography.bodyMediumBold.padding(8)→.padding(LotusSpacing.spacingXSmall).cornerRadius(4)→.cornerRadius(LotusCorners.radiusXSmall)jpDarkGray6→LotusColours.Text.secondary("muted body/secondary text colour throughout this cell").allowed-toolsaddsTask. Skill degrades gracefully if Task isn't available — Stage 3 just gets skipped.Architectural notes
The skill now uses three different Claude Code primitives in concert:
This is the right division of labour. Scripts handle volume; sub-agents handle judgement. The report builder consumes both.
Test plan
~/code/ioswith focused Lotus tab.build-report.mjsrenders new sections; degrades gracefully when their inputs are absent.Followups (not in this PR)
Lotus/-prefixed files fromworstFiles[*]so a definition file likeUIColor+Design2.0.swiftnever tops the list.🤖 Generated with Claude Code