Skip to content

fix(components): do not filter custom components in workspaces named ui/#43

Closed
neilwashere wants to merge 6 commits into
Houseofmvps:mainfrom
emerge-protocol:fix/components-ui-workspace-false-positive
Closed

fix(components): do not filter custom components in workspaces named ui/#43
neilwashere wants to merge 6 commits into
Houseofmvps:mainfrom
emerge-protocol:fix/components-ui-workspace-false-positive

Conversation

@neilwashere
Copy link
Copy Markdown
Contributor

Summary

isUIPrimitive in src/detectors/components.ts had a filePath.includes(\"/ui/\") check intended to filter shadcn primitives. The check is too broad: it matches every file under a monorepo workspace literally named `ui/` (e.g. `ui/src/components/*.tsx`), so every custom component in such a repo is wrongly dropped.

The real shadcn case (`components/ui/.tsx`) is still caught by the more specific `/components/ui/` check; lowercase primitive file names are still caught by the `UI_PRIMITIVES` set; vendor path checks (`@radix-ui`, `@shadcn`) are unchanged.

Reproduction

In our internal use we ran `codesight --wiki` against a pnpm workspace where the frontend package is literally named `ui` (the workspace tree is roughly `packages: shared, server, ui`). The scanner correctly identified `react` in the aggregated workspace deps and set `project.componentFramework = "react"`, but `detectComponents` returned an empty array, so the generated wiki reported `0 components` and skipped the `ui.md` article entirely.

After the fix the same repo reports 130 components with prop signatures extracted via AST (component names + props from `AppShell`, `BubbleContextMenu`, `ChatBubble`, etc.), and the `ui.md` article is generated as expected.

Change

One-line removal of the over-broad path check, plus a comment explaining why the bare `/ui/` segment is unsafe.

 function isUIPrimitive(filePath: string): boolean {
   const name = basename(filePath, extname(filePath)).toLowerCase();
   return (
     UI_PRIMITIVES.has(name) ||
-    filePath.includes(\"/ui/\") ||
     filePath.includes(\"/components/ui/\") ||
     filePath.includes(\"@radix-ui\") ||
     filePath.includes(\"@shadcn\")
   );
 }

Test plan

  • Added regression test `detects components in a workspace named \`ui/\` without filtering them as shadcn primitives` in `tests/detectors.test.ts`. Fixture has both a workspace-level `ui/src/components/AppShell.tsx` (must be detected) and a real shadcn `ui/src/components/ui/button.tsx` (must still be filtered). New test passes.
  • Existing `detects React components with props` test still passes (no regression on shadcn-primitive-name filtering or on the standard `src/` layout).
  • Full `pnpm test` suite: 116/117 pass on this branch. The single failure (`tests/monorepo.test.ts:312`, "creates CLAUDE.md with package count and index reference") also fails on `main` pre-change (verified by stash + re-run), so it is unrelated to this PR.
  • Manual end-to-end: re-ran `npx codesight --wiki` against the affected repo. Component count went 0 -> 130; total wiki tokens 15,736 -> 19,077; `ui.md` article now generated with component name + props + file paths.

🤖 Generated with Claude Code

neilwashere and others added 6 commits May 26, 2026 08:57
* feat: add customSections to plugin API for first-class plugin output

Plugins could previously only return routes, schemas, components, and
middleware — they had no way to contribute new types of content to
CODESIGHT.md. This meant plugin-generated insights were invisible to
agents unless they knew to look for a separate file.

Add customSections to PluginDetectorResult and ScanResult so plugins
can return arbitrary markdown sections that get rendered into
CODESIGHT.md alongside built-in sections, written as individual .md
files, and referenced in AI config files (CLAUDE.md, .cursorrules, etc).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add terraform infrastructure plugin (AWS-focused)

Add a plugin that scans Terraform/HCL files and generates
infrastructure.md with deployment context for AI agents — where a
service runs, what env vars and SSM secrets it receives, whether it's
public-facing, what it depends on, and per-environment overrides.

Supports two modes: in-project (terraform/ subdir alongside code) and
external path (separate infrastructure repo, default ../infrastructure).
Uses regex + brace-counting for zero-dependency HCL parsing, following
the same approach as the Go extractor.

The HCL parser and service matcher are provider-agnostic, but the
infrastructure extractor currently targets AWS patterns (ECS, SSM
Parameter Store, ALB, Route53, CloudWatch). Azure and GCP extraction
would require additional provider-specific logic in the extractor — the
parser and matcher layers would not need changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address PR review comments

- formatter.ts: sanitise customSections names to safe basenames and
  reject collisions with built-in section names
- hcl-parser.ts: skip comment stripping inside heredoc bodies to avoid
  corrupting literal content
- extractor.ts: fix IAM statement extraction to read action/actions
  instead of falling back to effect
- package.json: add dist/* wildcard export to preserve deep imports,
  update test script to run all test files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address review findings — reserved name bypass, name mismatch, regex safety

- Fix reserved name "CODESIGHT" casing mismatch in formatter.ts (was uppercase,
  safeName is always lowercased so the guard never matched)
- Sanitize section names in ai-config.ts to match filenames written by formatter.ts
- Move BLOCK_HEADER regex inside function body to prevent shared mutable state
  under concurrent use
- Add string-aware bracket counting in multi-line list parser
- Remove dead TF_EXTENSIONS constant
- Add informational TODOs for parallel file reads, parseTfvars multiline
  limitation, and custom section name collision

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests dynamically create fixtures via writeFixture() — no need to track them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove duplicate scan() from index.ts (now lives in core.ts since upstream refactor)
- Port customSections plugin API into core.ts scan() to preserve the feature
- Narrow .gitignore pattern from tests/fixtures/ to only ignore generated .codesight/ output
- Restore terraform fixture files deleted by the overly-broad gitignore commit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The ../infrastructure sibling scan was specific to a particular monorepo
layout. The general case is terraform co-located in the project; users
with a separate infra repo should set infraPath explicitly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
First release of the emerge fork on top of upstream Houseofmvps/codesight@v1.14.0.
Adds customSections plugin API, terraform plugin (with sibling-repo discovery
removed), and CI/CD plugin deltas not yet upstreamed in this exact form.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`isUIPrimitive` had a `filePath.includes("/ui/")` check intended to filter
shadcn primitives. That check is too broad: it matches every file under a
monorepo workspace literally named `ui/` (e.g. `ui/src/components/*.tsx`),
so every custom component in such a repo was wrongly dropped.

The real shadcn case (`components/ui/<primitive>.tsx`) is still caught by
the more specific `/components/ui/` check, and lowercase primitive file
names are still caught by the `UI_PRIMITIVES` set. Vendor path checks
(`@radix-ui`, `@shadcn`) are unchanged.

Repro: morgan monorepo (`packages: shared, server, ui`) reported 0
components. After the fix, 130 components are detected with prop
signatures extracted via AST. Includes a regression test fixture that
asserts a workspace-level `ui/src/components/AppShell.tsx` is detected
while a sibling `ui/src/components/ui/button.tsx` is still filtered.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@neilwashere neilwashere deleted the fix/components-ui-workspace-false-positive branch May 26, 2026 09:27
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