codesift-mcp 0.5.28 → 0.5.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +4 -1
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/git-hooks-installer.d.ts +29 -0
- package/dist/cli/git-hooks-installer.d.ts.map +1 -0
- package/dist/cli/git-hooks-installer.js +145 -0
- package/dist/cli/git-hooks-installer.js.map +1 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +5 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/setup.d.ts +5 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +15 -1
- package/dist/cli/setup.js.map +1 -1
- package/dist/register-tools.d.ts.map +1 -1
- package/dist/register-tools.js +125 -11
- package/dist/register-tools.js.map +1 -1
- package/dist/storage/index-store.d.ts.map +1 -1
- package/dist/storage/index-store.js +15 -14
- package/dist/storage/index-store.js.map +1 -1
- package/dist/storage/registry.d.ts +9 -0
- package/dist/storage/registry.d.ts.map +1 -1
- package/dist/storage/registry.js +28 -0
- package/dist/storage/registry.js.map +1 -1
- package/dist/tools/astro-content-collections.d.ts.map +1 -1
- package/dist/tools/astro-content-collections.js +1 -141
- package/dist/tools/astro-content-collections.js.map +1 -1
- package/dist/tools/astro-db-audit.d.ts +30 -0
- package/dist/tools/astro-db-audit.d.ts.map +1 -0
- package/dist/tools/astro-db-audit.js +244 -0
- package/dist/tools/astro-db-audit.js.map +1 -0
- package/dist/tools/astro-db-parser.d.ts +24 -0
- package/dist/tools/astro-db-parser.d.ts.map +1 -0
- package/dist/tools/astro-db-parser.js +150 -0
- package/dist/tools/astro-db-parser.js.map +1 -0
- package/dist/tools/astro-helpers.d.ts +13 -0
- package/dist/tools/astro-helpers.d.ts.map +1 -0
- package/dist/tools/astro-helpers.js +116 -0
- package/dist/tools/astro-helpers.js.map +1 -0
- package/dist/tools/astro-middleware.d.ts +26 -0
- package/dist/tools/astro-middleware.d.ts.map +1 -0
- package/dist/tools/astro-middleware.js +139 -0
- package/dist/tools/astro-middleware.js.map +1 -0
- package/dist/tools/astro-sessions.d.ts +26 -0
- package/dist/tools/astro-sessions.d.ts.map +1 -0
- package/dist/tools/astro-sessions.js +140 -0
- package/dist/tools/astro-sessions.js.map +1 -0
- package/dist/tools/constant-resolution-tools.d.ts.map +1 -1
- package/dist/tools/constant-resolution-tools.js +8 -4
- package/dist/tools/constant-resolution-tools.js.map +1 -1
- package/dist/tools/index-tools.d.ts.map +1 -1
- package/dist/tools/index-tools.js +16 -40
- package/dist/tools/index-tools.js.map +1 -1
- package/dist/tools/pattern-tools.d.ts.map +1 -1
- package/dist/tools/pattern-tools.js +20 -25
- package/dist/tools/pattern-tools.js.map +1 -1
- package/dist/tools/python-constants-tools.d.ts +3 -1
- package/dist/tools/python-constants-tools.d.ts.map +1 -1
- package/dist/tools/python-constants-tools.js +3 -2
- package/dist/tools/python-constants-tools.js.map +1 -1
- package/dist/tools/react-tools.d.ts +7 -1
- package/dist/tools/react-tools.d.ts.map +1 -1
- package/dist/tools/react-tools.js.map +1 -1
- package/dist/tools/sql-tools.d.ts +26 -0
- package/dist/tools/sql-tools.d.ts.map +1 -1
- package/dist/tools/sql-tools.js +84 -9
- package/dist/tools/sql-tools.js.map +1 -1
- package/dist/tools/status-tools.js +12 -19
- package/dist/tools/status-tools.js.map +1 -1
- package/dist/tools/typescript-constants-tools.d.ts +3 -0
- package/dist/tools/typescript-constants-tools.d.ts.map +1 -1
- package/dist/tools/typescript-constants-tools.js +53 -13
- package/dist/tools/typescript-constants-tools.js.map +1 -1
- package/dist/utils/constant-file-pattern.d.ts +6 -0
- package/dist/utils/constant-file-pattern.d.ts.map +1 -0
- package/dist/utils/constant-file-pattern.js +27 -0
- package/dist/utils/constant-file-pattern.js.map +1 -0
- package/dist/utils/import-graph.d.ts.map +1 -1
- package/dist/utils/import-graph.js +15 -9
- package/dist/utils/import-graph.js.map +1 -1
- package/dist/utils/ts-imports.d.ts +2 -1
- package/dist/utils/ts-imports.d.ts.map +1 -1
- package/dist/utils/ts-imports.js +8 -0
- package/dist/utils/ts-imports.js.map +1 -1
- package/dist/utils/tsconfig-paths.d.ts +5 -4
- package/dist/utils/tsconfig-paths.d.ts.map +1 -1
- package/dist/utils/tsconfig-paths.js +17 -14
- package/dist/utils/tsconfig-paths.js.map +1 -1
- package/hooks/hook-chain.sh +7 -0
- package/hooks/post-commit +8 -0
- package/hooks/post-commit-review-backlog.sh +107 -0
- package/package.json +2 -1
package/dist/register-tools.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as pathModule from "node:path";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
/** Boolean that also accepts "true"/"false" strings (LLMs often send strings instead of booleans) */
|
|
3
4
|
const zBool = () => z.union([z.boolean(), z.string().transform((s) => s === "true")]).optional();
|
|
@@ -207,6 +208,16 @@ const FRAMEWORK_TOOL_GROUPS = {
|
|
|
207
208
|
"resolve_php_service",
|
|
208
209
|
"php_security_scan",
|
|
209
210
|
"php_project_audit",
|
|
211
|
+
// PHP stacks (Yii2/Laravel/Symfony) overwhelmingly run on MySQL/Postgres with
|
|
212
|
+
// raw .sql migrations and ActiveRecord models. The SQL toolchain is the
|
|
213
|
+
// missing entry-point for schema/drift/lint/dml work — auto-revealing it
|
|
214
|
+
// here closes the gap that 0 SQL tools have ever been called from PHP repos.
|
|
215
|
+
"analyze_schema",
|
|
216
|
+
"trace_query",
|
|
217
|
+
"sql_audit",
|
|
218
|
+
"diff_migrations",
|
|
219
|
+
"search_columns",
|
|
220
|
+
"migration_lint",
|
|
210
221
|
],
|
|
211
222
|
// Kotlin / Android / Gradle — detected by build.gradle.kts or settings.gradle.kts
|
|
212
223
|
"build.gradle.kts": [
|
|
@@ -363,6 +374,20 @@ const PRISMA_TOOLS = [
|
|
|
363
374
|
"analyze_prisma_schema",
|
|
364
375
|
"migration_lint",
|
|
365
376
|
];
|
|
377
|
+
/**
|
|
378
|
+
* Raw-SQL toolchain — auto-enabled when a project has loose `*.sql` files
|
|
379
|
+
* (migrations, seeds, mysqldump). Independent of any ORM. Targets the
|
|
380
|
+
* "PHP/Yii2 + MySQL legacy" segment that historically called 0 of these
|
|
381
|
+
* tools because they were hidden behind discover_tools.
|
|
382
|
+
*/
|
|
383
|
+
const SQL_TOOLS = [
|
|
384
|
+
"analyze_schema",
|
|
385
|
+
"trace_query",
|
|
386
|
+
"sql_audit",
|
|
387
|
+
"diff_migrations",
|
|
388
|
+
"search_columns",
|
|
389
|
+
"migration_lint",
|
|
390
|
+
];
|
|
366
391
|
const AUTO_LOAD_CACHE_TTL_MS = 5_000;
|
|
367
392
|
const autoLoadToolsCache = new Map();
|
|
368
393
|
/**
|
|
@@ -386,14 +411,36 @@ export async function detectAutoLoadTools(cwd) {
|
|
|
386
411
|
if (existsSync(join(cwd, "prisma", "schema.prisma"))) {
|
|
387
412
|
toEnable.push(...PRISMA_TOOLS);
|
|
388
413
|
}
|
|
414
|
+
// Raw SQL detection — fires on any project with loose `*.sql` files in
|
|
415
|
+
// common schema/migration dirs. Catches mysqldump/pg_dump artifacts and
|
|
416
|
+
// hand-written migrations across PHP/Python/Go/Java stacks regardless of
|
|
417
|
+
// ORM. Composer-based PHP repos already pull SQL_TOOLS via FRAMEWORK_TOOL_GROUPS;
|
|
418
|
+
// this branch covers everything else (e.g. Django + raw migrations,
|
|
419
|
+
// standalone schema repos).
|
|
420
|
+
if (hasSqlFilesShallow(cwd, readdirSync)) {
|
|
421
|
+
toEnable.push(...SQL_TOOLS);
|
|
422
|
+
}
|
|
389
423
|
const detectFromPackageJson = (pkgRoot) => {
|
|
390
424
|
const enabled = [];
|
|
391
425
|
const pkgPath = join(pkgRoot, "package.json");
|
|
392
426
|
if (!existsSync(pkgPath))
|
|
393
427
|
return enabled;
|
|
428
|
+
let pkg;
|
|
394
429
|
try {
|
|
395
|
-
|
|
396
|
-
|
|
430
|
+
pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
/* malformed or unreadable package.json — omit silently */
|
|
434
|
+
return enabled;
|
|
435
|
+
}
|
|
436
|
+
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg))
|
|
437
|
+
return enabled;
|
|
438
|
+
try {
|
|
439
|
+
const manifest = pkg;
|
|
440
|
+
const allDeps = {
|
|
441
|
+
...manifest.dependencies,
|
|
442
|
+
...manifest.devDependencies,
|
|
443
|
+
};
|
|
397
444
|
const hasReact = !!(allDeps["react"] ||
|
|
398
445
|
allDeps["next"] ||
|
|
399
446
|
allDeps["@remix-run/react"] ||
|
|
@@ -422,14 +469,18 @@ export async function detectAutoLoadTools(cwd) {
|
|
|
422
469
|
// npm/yarn/pnpm workspaces field — content-based monorepo signal.
|
|
423
470
|
// Complements the file-based signals (pnpm-workspace.yaml, lerna.json,
|
|
424
471
|
// nx.json, turbo.json) so plain `"workspaces": [...]` setups also fire.
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
472
|
+
const ws = manifest.workspaces;
|
|
473
|
+
const hasWorkspaces = Array.isArray(ws) ||
|
|
474
|
+
(ws !== null &&
|
|
475
|
+
typeof ws === "object" &&
|
|
476
|
+
!Array.isArray(ws) &&
|
|
477
|
+
Array.isArray(ws.packages));
|
|
428
478
|
if (hasWorkspaces)
|
|
429
479
|
enabled.push(...MONOREPO_TOOLS);
|
|
430
480
|
}
|
|
431
|
-
catch {
|
|
432
|
-
|
|
481
|
+
catch (err) {
|
|
482
|
+
const detail = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
483
|
+
console.warn(`[codesift-mcp] detectFromPackageJson(${pkgRoot}): ${detail}`);
|
|
433
484
|
}
|
|
434
485
|
return enabled;
|
|
435
486
|
};
|
|
@@ -481,7 +532,8 @@ export function detectAutoLoadToolsCached(cwd) {
|
|
|
481
532
|
* Skips node_modules, dist, build, .next, .astro, .git.
|
|
482
533
|
*/
|
|
483
534
|
function hasJsxFilesShallow(cwd, readdirSyncFn) {
|
|
484
|
-
|
|
535
|
+
// ESM-safe path import (avoid `require("node:path")`, which throws under ESM).
|
|
536
|
+
const { join } = pathModule;
|
|
485
537
|
const IGNORE = new Set([
|
|
486
538
|
"node_modules", "dist", "build", ".next", ".astro", ".git",
|
|
487
539
|
"out", "coverage", ".turbo", ".vercel", ".cache",
|
|
@@ -519,6 +571,65 @@ function hasJsxFilesShallow(cwd, readdirSyncFn) {
|
|
|
519
571
|
}
|
|
520
572
|
return false;
|
|
521
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* Quick scan for *.sql files in conventional schema/migration directories.
|
|
576
|
+
* Used to auto-enable the SQL toolchain on any project that ships raw SQL
|
|
577
|
+
* regardless of language stack. Stops on first hit; depth capped at 3 so
|
|
578
|
+
* nested package dirs (e.g. monorepo apps/*) are still reachable.
|
|
579
|
+
*/
|
|
580
|
+
function hasSqlFilesShallow(cwd, readdirSyncFn) {
|
|
581
|
+
const { join } = pathModule;
|
|
582
|
+
const IGNORE = new Set([
|
|
583
|
+
"node_modules", "dist", "build", ".next", ".astro", ".git",
|
|
584
|
+
"out", "coverage", ".turbo", ".vercel", ".cache", "vendor",
|
|
585
|
+
]);
|
|
586
|
+
// SQL conventionally lives in dedicated dirs — scanning every src/ tree
|
|
587
|
+
// would trigger false positives on test fixtures and string-literal SQL.
|
|
588
|
+
const DEEP_ROOTS = [
|
|
589
|
+
"migrations", "migration", "db", "database", "schema", "schemas",
|
|
590
|
+
"sql", "ddl", "seeds", "seed", "supabase",
|
|
591
|
+
"prisma/migrations", "drizzle/migrations",
|
|
592
|
+
];
|
|
593
|
+
function scanDeep(dir, depth) {
|
|
594
|
+
if (depth > 3)
|
|
595
|
+
return false;
|
|
596
|
+
let entries;
|
|
597
|
+
try {
|
|
598
|
+
entries = readdirSyncFn(dir, { withFileTypes: true });
|
|
599
|
+
}
|
|
600
|
+
catch {
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
for (const e of entries) {
|
|
604
|
+
if (e.isFile() && /\.sql$/i.test(e.name))
|
|
605
|
+
return true;
|
|
606
|
+
}
|
|
607
|
+
for (const e of entries) {
|
|
608
|
+
if (e.isDirectory() && !IGNORE.has(e.name) && !e.name.startsWith(".")) {
|
|
609
|
+
if (scanDeep(join(dir, e.name), depth + 1))
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
// Top-level: dump files like `schema.sql` / `init.sql` / `database.sql`.
|
|
616
|
+
try {
|
|
617
|
+
const rootEntries = readdirSyncFn(cwd, { withFileTypes: true });
|
|
618
|
+
for (const e of rootEntries) {
|
|
619
|
+
if (e.isFile() && /\.sql$/i.test(e.name))
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
catch { /* skip */ }
|
|
624
|
+
for (const root of DEEP_ROOTS) {
|
|
625
|
+
try {
|
|
626
|
+
if (scanDeep(join(cwd, root), 0))
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
catch { /* skip */ }
|
|
630
|
+
}
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
522
633
|
// ---------------------------------------------------------------------------
|
|
523
634
|
// Output schemas — typed results for structured validation & documentation
|
|
524
635
|
// ---------------------------------------------------------------------------
|
|
@@ -3701,13 +3812,14 @@ const TOOL_DEFINITIONS = [
|
|
|
3701
3812
|
{
|
|
3702
3813
|
name: "analyze_schema",
|
|
3703
3814
|
category: "analysis",
|
|
3704
|
-
searchHint: "SQL schema ERD entity relationship tables views columns foreign key database migration",
|
|
3705
|
-
description: "Analyze SQL schema: tables, views, columns, foreign keys, relationships. Output as JSON or Mermaid ERD.",
|
|
3815
|
+
searchHint: "SQL schema ERD entity relationship tables views columns foreign key database migration MySQL Postgres SQLite dialect",
|
|
3816
|
+
description: "Analyze SQL schema: tables, views, columns, foreign keys, relationships. Auto-detects dialect (mysql/postgres/sqlite/mssql) from schema fingerprints. Output as JSON or Mermaid ERD.",
|
|
3706
3817
|
schema: lazySchema(() => ({
|
|
3707
3818
|
repo: z.string().optional().describe("Repository identifier (default: auto-detected from CWD)"),
|
|
3708
3819
|
file_pattern: z.string().optional().describe("Filter SQL files by pattern (e.g. 'migrations/')"),
|
|
3709
3820
|
output_format: z.enum(["json", "mermaid"]).optional().describe("Output format (default: json)"),
|
|
3710
3821
|
include_columns: zBool().describe("Include column details in output (default: true)"),
|
|
3822
|
+
dialect: z.enum(["auto", "mysql", "postgres", "sqlite", "mssql", "unknown"]).optional().describe("Force dialect, or 'auto' to detect from ENGINE=InnoDB / SERIAL / AUTOINCREMENT etc. (default: auto)"),
|
|
3711
3823
|
})),
|
|
3712
3824
|
handler: async (args) => {
|
|
3713
3825
|
const { analyzeSchema } = await import("./tools/sql-tools.js");
|
|
@@ -3718,9 +3830,11 @@ const TOOL_DEFINITIONS = [
|
|
|
3718
3830
|
opts.output_format = args.output_format;
|
|
3719
3831
|
if (args.include_columns != null)
|
|
3720
3832
|
opts.include_columns = args.include_columns;
|
|
3833
|
+
if (args.dialect != null)
|
|
3834
|
+
opts.dialect = args.dialect;
|
|
3721
3835
|
const result = await analyzeSchema(args.repo, opts);
|
|
3722
3836
|
const parts = [];
|
|
3723
|
-
parts.push(`Tables: ${result.tables.length} | Views: ${result.views.length} | Relationships: ${result.relationships.length}`);
|
|
3837
|
+
parts.push(`Tables: ${result.tables.length} | Views: ${result.views.length} | Relationships: ${result.relationships.length} | Dialect: ${result.detected_dialect}`);
|
|
3724
3838
|
if (result.warnings.length > 0)
|
|
3725
3839
|
parts.push(`Warnings: ${result.warnings.join("; ")}`);
|
|
3726
3840
|
if (result.mermaid) {
|