Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codesight",
"version": "1.14.0",
"version": "1.14.0-emerge.0",
"description": "See your codebase clearly. Universal AI context generator that maps routes, schema, components, dependencies, and more for Claude Code, Cursor, Copilot, Codex, and any AI coding tool.",
"main": "dist/index.js",
"bin": {
Expand Down
6 changes: 5 additions & 1 deletion src/detectors/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ const UI_PRIMITIVES = new Set([

function isUIPrimitive(filePath: string): boolean {
const name = basename(filePath, extname(filePath)).toLowerCase();
// Note: do NOT match a bare `/ui/` segment here. That collides with monorepo
// workspaces literally named `ui/` (e.g. `ui/src/components/*.tsx`), where
// every custom component would be wrongly filtered. The real shadcn case is
// `components/ui/` (caught below) or lowercase primitive filenames (caught
// via UI_PRIMITIVES). Vendor paths (`@radix-ui`, `@shadcn`) are kept.
return (
UI_PRIMITIVES.has(name) ||
filePath.includes("/ui/") ||
filePath.includes("/components/ui/") ||
filePath.includes("@radix-ui") ||
filePath.includes("@shadcn")
Expand Down
14 changes: 3 additions & 11 deletions src/plugins/terraform/file-collector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readdir, readFile, stat } from "node:fs/promises";
import { join, dirname, resolve, extname } from "node:path";
import { join, resolve, extname } from "node:path";
import type { TerraformPluginConfig } from "./types.js";

const SKIP_DIRS = new Set([".terraform", ".git", "node_modules", ".terragrunt-cache"]);
Expand All @@ -12,7 +12,7 @@ export interface CollectedFiles {

/**
* Collect .tf and .tfvars files from the best-matching infrastructure location.
* Tries: explicit config path → in-project subdirs → sibling repos → project root.
* Tries: explicit config path → in-project subdirs (terraform/, infra/, etc.) → project root.
*/
export async function collectTfFiles(
projectRoot: string,
Expand All @@ -32,15 +32,7 @@ export async function collectTfFiles(
if (files.tfFiles.length > 0) return files;
}

// 3. Sibling infrastructure repo
const parent = dirname(projectRoot);
for (const sibling of ["infrastructure", "infra", "terraform", "deploy"]) {
const candidate = join(parent, sibling);
const files = await scanDirForTf(candidate);
if (files.tfFiles.length > 0) return files;
}

// 4. .tf files at project root
// 3. .tf files at project root
const rootFiles = await scanDirForTf(projectRoot, 1);
if (rootFiles.tfFiles.length > 0) return rootFiles;

Expand Down
12 changes: 6 additions & 6 deletions src/plugins/terraform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ export type { TerraformPluginConfig } from "./types.js";
/**
* Create a Terraform infrastructure plugin for codesight.
*
* Scans .tf files — either co-located in the project or in a separate
* infrastructure repo — and generates an infrastructure section with
* deployment context for AI agents.
* Scans .tf files co-located in the project (terraform/, infra/, etc.) and generates
* an infrastructure section with deployment context for AI agents.
* Use infraPath to point at a separate infrastructure repository.
*
* @example
* // Auto-discover infrastructure
* // Auto-discover co-located terraform
* createTerraformPlugin()
*
* @example
* // Explicit centralised infra repo
* // Explicit separate infra repo
* createTerraformPlugin({
* infraPath: '../infrastructure',
* serviceName: 'query-service',
* serviceName: 'my-service',
* })
*/
export function createTerraformPlugin(config: TerraformPluginConfig = {}): CodesightPlugin {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/terraform/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** User-facing configuration for the Terraform infrastructure plugin */
export interface TerraformPluginConfig {
/** Path to infra repo — absolute or relative to project root.
* Default: auto-discovers ../infrastructure, ./terraform, ./infra, ./deploy */
/** Path to a separate infrastructure repo — absolute or relative to project root.
* Default: auto-discovers ./terraform, ./infra, ./infrastructure, ./deploy, ./iac */
infraPath?: string;
/** Override service name matching (default: project.name from package.json etc.) */
serviceName?: string;
Expand Down
37 changes: 37 additions & 0 deletions tests/detectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,43 @@ describe("Component Detection", async () => {
assert.ok(components.length >= 2);
assert.ok(components.some((c: any) => c.name === "UserProfile" && c.props.includes("name")));
});

it("detects components in a workspace named `ui/` without filtering them as shadcn primitives", async () => {
// Regression: a bare `/ui/` segment in the file path used to trigger the
// shadcn-primitive filter, which wrongly dropped every custom component
// in monorepos whose UI package is literally named `ui/` (e.g. morgan).
// The real shadcn case lives at `components/ui/<primitive>.tsx` and is
// still filtered here.
const dir = await writeFixture("ui-workspace-app", {
"package.json": JSON.stringify({ name: "root", private: true }),
"pnpm-workspace.yaml": "packages:\n - ui\n",
"ui/package.json": JSON.stringify({
name: "@app/ui",
dependencies: { react: "^19.0.0" },
}),
// Custom app component inside the `ui` workspace. PascalCase name, so
// the UI_PRIMITIVES filename filter must not catch it either.
"ui/src/components/AppShell.tsx": `interface AppShellProps { children: React.ReactNode; width?: "default" | "narrow" }
const AppShell = ({ children, width = "default" }: AppShellProps) => {
return <div>{children}</div>;
};
export default AppShell;`,
// shadcn primitive at the canonical path. Must still be filtered.
"ui/src/components/ui/button.tsx": `export const Button = ({ label }: { label: string }) => <button>{label}</button>;`,
});
const project = await mods.detectProject(dir);
assert.equal(project.componentFramework, "react", "react workspace dep should be aggregated");
const files = await mods.collectFiles(dir);
const components = await mods.detectComponents(files, project);
assert.ok(
components.some((c: any) => c.name === "AppShell"),
`expected AppShell to be detected, got: ${components.map((c: any) => c.name).join(", ") || "<none>"}`,
);
assert.ok(
!components.some((c: any) => c.name === "Button"),
"shadcn primitive at components/ui/button.tsx should still be filtered",
);
});
});

// =================== DEPENDENCY GRAPH TESTS ===================
Expand Down
3 changes: 0 additions & 3 deletions tests/fixtures/config-app/.env.example

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/config-app/package.json

This file was deleted.

2 changes: 0 additions & 2 deletions tests/fixtures/config-app/src/config.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/django-app/requirements.txt

This file was deleted.

5 changes: 0 additions & 5 deletions tests/fixtures/django-app/urls.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/drizzle-schema/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions tests/fixtures/drizzle-schema/src/schema.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/elysia-app/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/fixtures/elysia-app/src/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/elysia-detect/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/express-app/package.json

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/express-app/src/routes.ts

This file was deleted.

8 changes: 0 additions & 8 deletions tests/fixtures/fastapi-app/main.py

This file was deleted.

2 changes: 0 additions & 2 deletions tests/fixtures/fastapi-app/requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/fastify-app/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions tests/fixtures/fastify-app/src/server.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/graph-app/package.json

This file was deleted.

2 changes: 0 additions & 2 deletions tests/fixtures/graph-app/src/auth.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/graph-app/src/db.ts

This file was deleted.

3 changes: 0 additions & 3 deletions tests/fixtures/graph-app/src/middleware.ts

This file was deleted.

3 changes: 0 additions & 3 deletions tests/fixtures/graph-app/src/routes.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/hono-app/package.json

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/hono-app/src/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/js-imports/package.json

This file was deleted.

2 changes: 0 additions & 2 deletions tests/fixtures/js-imports/src/main.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/js-imports/src/utils.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/middleware-app/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions tests/fixtures/middleware-app/src/middleware/auth.ts

This file was deleted.

4 changes: 0 additions & 4 deletions tests/fixtures/middleware-app/src/middleware/rate-limit.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/monorepo-detect/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/monorepo-detect/packages/api/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/monorepo-detect/packages/web/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/nestjs-app/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions tests/fixtures/nestjs-app/src/users.controller.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/nestjs-detect/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/next-app/package.json

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/next-app/src/app/api/users/route.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/nuxt-app/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/nuxt-app/server/api/users.get.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/nuxt-app/server/api/users.post.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/nuxt-app/server/api/users/[id].get.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/nuxt-detect/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/prisma-schema/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions tests/fixtures/prisma-schema/prisma/schema.prisma

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/raw-http-app/package.json

This file was deleted.

7 changes: 0 additions & 7 deletions tests/fixtures/raw-http-app/src/server.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/react-app/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions tests/fixtures/react-app/src/ProjectCard.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions tests/fixtures/react-app/src/UserProfile.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/remix-app/app/routes/users.tsx

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/remix-app/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/remix-detect/package.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/sveltekit-app/package.json

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/sveltekit-app/src/routes/api/users/+server.ts

This file was deleted.

Loading
Loading