fix(core): dedupe design system section in generated AGENTS.md#66
Conversation
… exist When both design.enforce and design.instructions are set, buildDesignSection emitted two near-identical blocks: the generic numbered EN enforcement list and the custom instructions. The custom instructions are richer and project-specific, so they should take precedence. Now the generic EN block is only emitted as a fallback when no instructions are provided.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughIn ChangesDesign Enforcement Conditional Guard
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/src/prompt-builders.ts (1)
513-527: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winTreat whitespace-only
design.instructionsas absent before suppressing enforcement.Using raw truthiness here suppresses the mandatory block for values like
" ", buttrim()then renders the custom instructions empty. That drops both instruction sources. Normalize once (e.g.,const instructions = design.instructions?.trim();) and gate both checks oninstructions.Proposed fix
export function buildDesignSection(config: HubConfig): string | null { const design = config.design; if (!design) return null; + const instructions = design.instructions?.trim(); - const hasContent = design.skills?.length || design.libraries?.length || design.icons || design.instructions; + const hasContent = design.skills?.length || design.libraries?.length || design.icons || instructions; if (!hasContent) return null; const parts: string[] = []; parts.push(`\n## Design System`); - if (design.enforce && design.skills?.length && !design.instructions) { + if (design.enforce && design.skills?.length && !instructions) { const skillList = design.skills.map((s) => `\`${s}\``).join(", "); parts.push(` **DESIGN ENFORCEMENT — MANDATORY** ... `); } - if (design.instructions) { - parts.push(`\n${design.instructions.trim()}`); + if (instructions) { + parts.push(`\n${instructions}`); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/prompt-builders.ts` around lines 513 - 527, The code has a whitespace handling issue where whitespace-only strings in design.instructions suppress the enforcement block due to truthiness, but then trim() renders them empty, losing both instruction sources. Normalize design.instructions once at the beginning by creating a variable like instructions = design.instructions?.trim(), then use this normalized variable in both the condition checking !design.instructions (to gate the enforcement block) and the condition outputting custom instructions (replacing the current if (design.instructions) check). This ensures consistent behavior for empty, whitespace-only, and non-empty instruction values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/core/src/prompt-builders.ts`:
- Around line 513-527: The code has a whitespace handling issue where
whitespace-only strings in design.instructions suppress the enforcement block
due to truthiness, but then trim() renders them empty, losing both instruction
sources. Normalize design.instructions once at the beginning by creating a
variable like instructions = design.instructions?.trim(), then use this
normalized variable in both the condition checking !design.instructions (to gate
the enforcement block) and the condition outputting custom instructions
(replacing the current if (design.instructions) check). This ensures consistent
behavior for empty, whitespace-only, and non-empty instruction values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f9fbb89f-57e0-479b-8f53-3d75ad4df74d
📒 Files selected for processing (1)
packages/core/src/prompt-builders.ts
Problema
buildDesignSectionemitia dois blocos quase idênticos no AGENTS.md gerado quando o config tinha tantodesign.enforcequantodesign.instructions:DESIGN ENFORCEMENT — MANDATORY, passos 1-5)design.instructionscustomizadas (no caso do arvore-hub, um parágrafo PT mais rico e específico)Ambos dizem essencialmente a mesma coisa — o segundo é uma versão melhor e project-specific do primeiro. Resultado: duplicação de conteúdo e inflação do prompt em todo turn.
Mudança
Quando
design.instructionsestá presente, pulamos o bloco genérico EN — as instruções customizadas o substituem. O bloco EN continua sendo emitido como fallback quando não háinstructions, então configs que só usamenforcesem instructions não mudam.```diff
```
Verificação
pnpm build(packages/core) ✅pnpm lint(packages/core) ✅Notas
Investigando o AGENTS.md gerado do arvore-hub, também havia resíduo de versões antigas do template (bloco "Automatic Skill Creation" com paths do Cursor + Delivery duplicado). Esse conteúdo já não existe na 0.26.0 — some ao atualizar o hub e regenerar. Este PR cobre só a duplicação que ainda persiste na versão atual.
Summary by CodeRabbit