Skip to content

fix(core): dedupe design system section in generated AGENTS.md#66

Merged
Jott4 merged 1 commit into
mainfrom
fix/design-section-dedupe-enforce-block
Jun 24, 2026
Merged

fix(core): dedupe design system section in generated AGENTS.md#66
Jott4 merged 1 commit into
mainfrom
fix/design-section-dedupe-enforce-block

Conversation

@Jott4

@Jott4 Jott4 commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problema

buildDesignSection emitia dois blocos quase idênticos no AGENTS.md gerado quando o config tinha tanto design.enforce quanto design.instructions:

  1. O bloco genérico EN numerado (DESIGN ENFORCEMENT — MANDATORY, passos 1-5)
  2. As design.instructions customizadas (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.instructions está 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ó usam enforce sem instructions não mudam.

```diff

  • if (design.enforce && design.skills?.length) {
  • if (design.enforce && design.skills?.length && !design.instructions) {
    ```

Verificação

  • pnpm build (packages/core) ✅
  • pnpm lint (packages/core) ✅
  • Sem testes/snapshots no core que cubram essa seção

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

  • Bug Fixes
    • Refined design enforcement guidance conditions to be more context-aware, ensuring prompts display only when all required configuration criteria are met.

… 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.
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rhm-website Ready Ready Preview, Comment Jun 23, 2026 7:16pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

In buildDesignSection, the condition for including the "DESIGN ENFORCEMENT — MANDATORY" guidance block gains a !design.instructions guard, so that block is suppressed whenever design.instructions is provided, even if enforcement is enabled and skills are present.

Changes

Design Enforcement Conditional Guard

Layer / File(s) Summary
!design.instructions guard in enforcement block
packages/core/src/prompt-builders.ts
The conditional controlling the "DESIGN ENFORCEMENT — MANDATORY" section now also requires !design.instructions, suppressing the block when custom design instructions are already set.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐇 A tiny guard, a single line,
When instructions exist, enforcement won't shine.
No double rules when yours are laid bare,
The rabbit hops lightly with logic so rare.
One condition changed — precision divine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: deduplicating the design system section in generated AGENTS.md files by conditionally excluding the generic enforcement block when custom instructions are provided.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/design-section-dedupe-enforce-block

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Treat whitespace-only design.instructions as absent before suppressing enforcement.

Using raw truthiness here suppresses the mandatory block for values like " ", but trim() then renders the custom instructions empty. That drops both instruction sources. Normalize once (e.g., const instructions = design.instructions?.trim();) and gate both checks on instructions.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9965a3e and b91abe2.

📒 Files selected for processing (1)
  • packages/core/src/prompt-builders.ts

@Jott4
Jott4 merged commit bcbe29a into main Jun 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant