forgecraft-mcp 0.2.1 → 0.4.0

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.
Files changed (105) hide show
  1. package/dist/analyzers/language-detector.d.ts +17 -0
  2. package/dist/analyzers/language-detector.d.ts.map +1 -0
  3. package/dist/analyzers/language-detector.js +89 -0
  4. package/dist/analyzers/language-detector.js.map +1 -0
  5. package/dist/analyzers/package-json.d.ts.map +1 -1
  6. package/dist/analyzers/package-json.js +5 -5
  7. package/dist/analyzers/package-json.js.map +1 -1
  8. package/dist/analyzers/project-context.d.ts +23 -0
  9. package/dist/analyzers/project-context.d.ts.map +1 -0
  10. package/dist/analyzers/project-context.js +181 -0
  11. package/dist/analyzers/project-context.js.map +1 -0
  12. package/dist/index.js +4 -27
  13. package/dist/index.js.map +1 -1
  14. package/dist/registry/composer.d.ts +3 -1
  15. package/dist/registry/composer.d.ts.map +1 -1
  16. package/dist/registry/composer.js +28 -0
  17. package/dist/registry/composer.js.map +1 -1
  18. package/dist/registry/loader.d.ts.map +1 -1
  19. package/dist/registry/loader.js +40 -1
  20. package/dist/registry/loader.js.map +1 -1
  21. package/dist/registry/mcp-discovery.js +1 -0
  22. package/dist/registry/mcp-discovery.js.map +1 -1
  23. package/dist/registry/renderer.d.ts +19 -2
  24. package/dist/registry/renderer.d.ts.map +1 -1
  25. package/dist/registry/renderer.js +64 -2
  26. package/dist/registry/renderer.js.map +1 -1
  27. package/dist/shared/filesystem.d.ts +45 -0
  28. package/dist/shared/filesystem.d.ts.map +1 -0
  29. package/dist/shared/filesystem.js +122 -0
  30. package/dist/shared/filesystem.js.map +1 -0
  31. package/dist/shared/types.d.ts +48 -0
  32. package/dist/shared/types.d.ts.map +1 -1
  33. package/dist/tools/add-module.d.ts +1 -1
  34. package/dist/tools/audit.js +2 -2
  35. package/dist/tools/audit.js.map +1 -1
  36. package/dist/tools/configure-mcp.d.ts +3 -0
  37. package/dist/tools/configure-mcp.d.ts.map +1 -1
  38. package/dist/tools/configure-mcp.js +38 -1
  39. package/dist/tools/configure-mcp.js.map +1 -1
  40. package/dist/tools/convert.js +4 -4
  41. package/dist/tools/convert.js.map +1 -1
  42. package/dist/tools/forgecraft-router.d.ts +127 -0
  43. package/dist/tools/forgecraft-router.d.ts.map +1 -0
  44. package/dist/tools/forgecraft-router.js +305 -0
  45. package/dist/tools/forgecraft-router.js.map +1 -0
  46. package/dist/tools/generate-claude-md.d.ts +1 -0
  47. package/dist/tools/generate-claude-md.d.ts.map +1 -1
  48. package/dist/tools/generate-claude-md.js +23 -57
  49. package/dist/tools/generate-claude-md.js.map +1 -1
  50. package/dist/tools/get-reference.d.ts +28 -0
  51. package/dist/tools/get-reference.d.ts.map +1 -0
  52. package/dist/tools/get-reference.js +63 -0
  53. package/dist/tools/get-reference.js.map +1 -0
  54. package/dist/tools/list.d.ts +18 -2
  55. package/dist/tools/list.d.ts.map +1 -1
  56. package/dist/tools/list.js +50 -2
  57. package/dist/tools/list.js.map +1 -1
  58. package/dist/tools/refresh-project.d.ts.map +1 -1
  59. package/dist/tools/refresh-project.js +8 -10
  60. package/dist/tools/refresh-project.js.map +1 -1
  61. package/dist/tools/scaffold.d.ts +5 -1
  62. package/dist/tools/scaffold.d.ts.map +1 -1
  63. package/dist/tools/scaffold.js +58 -31
  64. package/dist/tools/scaffold.js.map +1 -1
  65. package/dist/tools/setup-project.d.ts +3 -3
  66. package/dist/tools/setup-project.d.ts.map +1 -1
  67. package/dist/tools/setup-project.js +8 -4
  68. package/dist/tools/setup-project.js.map +1 -1
  69. package/package.json +1 -1
  70. package/templates/analytics/mcp-servers.yaml +1 -0
  71. package/templates/api/mcp-servers.yaml +1 -0
  72. package/templates/api/skills.yaml +54 -0
  73. package/templates/cli/mcp-servers.yaml +1 -0
  74. package/templates/data-lineage/mcp-servers.yaml +2 -0
  75. package/templates/data-pipeline/mcp-servers.yaml +1 -0
  76. package/templates/data-pipeline/skills.yaml +56 -0
  77. package/templates/fintech/mcp-servers.yaml +1 -0
  78. package/templates/fintech/skills.yaml +35 -0
  79. package/templates/game/mcp-servers.yaml +1 -0
  80. package/templates/healthcare/mcp-servers.yaml +1 -0
  81. package/templates/healthcare/skills.yaml +35 -0
  82. package/templates/hipaa/mcp-servers.yaml +1 -0
  83. package/templates/hipaa/skills.yaml +39 -0
  84. package/templates/infra/mcp-servers.yaml +2 -0
  85. package/templates/library/mcp-servers.yaml +2 -0
  86. package/templates/medallion-architecture/mcp-servers.yaml +2 -0
  87. package/templates/ml/mcp-servers.yaml +1 -0
  88. package/templates/mobile/mcp-servers.yaml +1 -0
  89. package/templates/observability-xray/mcp-servers.yaml +1 -0
  90. package/templates/realtime/mcp-servers.yaml +1 -0
  91. package/templates/soc2/mcp-servers.yaml +2 -0
  92. package/templates/social/mcp-servers.yaml +2 -0
  93. package/templates/state-machine/mcp-servers.yaml +1 -0
  94. package/templates/universal/hooks.yaml +63 -0
  95. package/templates/universal/instructions.yaml +41 -118
  96. package/templates/universal/mcp-servers.yaml +12 -0
  97. package/templates/universal/nfr.yaml +1 -1
  98. package/templates/universal/reference.yaml +111 -0
  99. package/templates/universal/review.yaml +2 -2
  100. package/templates/universal/skills.yaml +106 -0
  101. package/templates/web-react/mcp-servers.yaml +2 -0
  102. package/templates/web-react/skills.yaml +56 -0
  103. package/templates/web-static/mcp-servers.yaml +2 -0
  104. package/templates/web3/mcp-servers.yaml +1 -0
  105. package/templates/zero-trust/mcp-servers.yaml +1 -0
@@ -0,0 +1,54 @@
1
+ tag: API
2
+ section: skills
3
+ skills:
4
+ - id: api-test-endpoint
5
+ name: Test API Endpoint
6
+ filename: api-test-endpoint.md
7
+ description: "Test an API endpoint with various scenarios"
8
+ tier: core
9
+ content: |
10
+ Test the API endpoint specified in $ARGUMENTS.
11
+
12
+ Steps:
13
+ 1. Find the route handler and read the implementation
14
+ 2. Identify the request schema (params, query, body)
15
+ 3. Run these test scenarios:
16
+ - **Happy path**: valid request with expected response
17
+ - **Validation**: missing required fields, wrong types, boundary values
18
+ - **Auth**: unauthenticated, wrong role, expired token (if applicable)
19
+ - **Edge cases**: empty body, large payload, special characters
20
+ 4. For each scenario, report:
21
+ - Request: method, path, headers, body
22
+ - Expected: status code, response shape
23
+ - Actual: what happened
24
+ - Verdict: PASS / FAIL
25
+
26
+ Use `curl` or the project's test framework. If tests don't exist for this endpoint, offer to create them.
27
+
28
+ - id: api-add-endpoint
29
+ name: Add API Endpoint
30
+ filename: api-add-endpoint.md
31
+ description: "Scaffold a new API endpoint following project patterns"
32
+ tier: recommended
33
+ content: |
34
+ Create a new API endpoint. $ARGUMENTS should describe the endpoint (e.g., "POST /api/users - create a user").
35
+
36
+ Steps:
37
+ 1. Identify existing endpoint patterns in the project:
38
+ - Router file structure
39
+ - Validation approach (Zod, Joi, class-validator, etc.)
40
+ - Response format conventions
41
+ - Error handling patterns
42
+ - Middleware chain
43
+ 2. Create the endpoint following discovered patterns:
44
+ - Route handler (thin — delegates to service layer)
45
+ - Input validation schema
46
+ - Service method with business logic
47
+ - Error handling with appropriate HTTP status codes
48
+ 3. Add tests:
49
+ - Happy path test
50
+ - Validation error test
51
+ - At least one edge case
52
+ 4. Update any route index/registry if the project uses one
53
+
54
+ Follow existing patterns exactly. Do not introduce new patterns or libraries.
@@ -7,4 +7,5 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-filesystem", "/"]
8
8
  tags: [CLI, LIBRARY]
9
9
  category: general
10
+ tier: recommended
10
11
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-postgres"]
8
8
  tags: [DATA-LINEAGE, DATA-PIPELINE]
9
9
  category: database
10
+ tier: recommended
10
11
  env:
11
12
  POSTGRES_CONNECTION_STRING: ""
12
13
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/postgres"
@@ -17,4 +18,5 @@ servers:
17
18
  args: ["-y", "@modelcontextprotocol/server-filesystem"]
18
19
  tags: [DATA-LINEAGE, UNIVERSAL]
19
20
  category: filesystem
21
+ tier: optional
20
22
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-postgres"]
8
8
  tags: [DATA-PIPELINE, API]
9
9
  category: database
10
+ tier: recommended
10
11
  env:
11
12
  POSTGRES_CONNECTION_STRING: ""
12
13
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/postgres"
@@ -0,0 +1,56 @@
1
+ tag: DATA-PIPELINE
2
+ section: skills
3
+ skills:
4
+ - id: pipeline-validate-schema
5
+ name: Validate Pipeline Schema
6
+ filename: pipeline-validate-schema.md
7
+ description: "Validate data pipeline schemas and detect drift"
8
+ tier: core
9
+ content: |
10
+ Validate data pipeline schemas for consistency and detect drift.
11
+
12
+ Steps:
13
+ 1. **Find schema definitions**: Search for schema files, model definitions, or DDL:
14
+ - SQL migration files
15
+ - ORM models (SQLAlchemy, Prisma, TypeORM, etc.)
16
+ - Avro/Protobuf/JSON Schema definitions
17
+ - DataFrame column definitions
18
+ 2. **Check for drift**: Compare schemas across pipeline stages:
19
+ - Source schema vs. ingestion schema
20
+ - Ingestion schema vs. transformation output
21
+ - Transformation output vs. serving layer
22
+ 3. **Validate contracts**:
23
+ - All nullable fields explicitly marked
24
+ - Default values defined for new columns
25
+ - Breaking changes (column removal, type change) flagged
26
+ - Backward/forward compatibility for event schemas
27
+ 4. **Report**:
28
+ - Schema location and version
29
+ - Drift detected between stages
30
+ - Breaking changes that need migration
31
+
32
+ If $ARGUMENTS specifies a pipeline or table name, focus on that. Otherwise, scan all schemas.
33
+
34
+ - id: pipeline-trace-lineage
35
+ name: Trace Data Lineage
36
+ filename: pipeline-trace-lineage.md
37
+ description: "Trace data lineage from source to destination"
38
+ tier: recommended
39
+ content: |
40
+ Trace the data lineage for the field or table specified in $ARGUMENTS.
41
+
42
+ Steps:
43
+ 1. Start from the target field/table
44
+ 2. Trace backward through transformations:
45
+ - Which upstream tables/sources feed into it?
46
+ - What transformations are applied (joins, filters, aggregations)?
47
+ - What business logic modifies the values?
48
+ 3. Trace forward to consumers:
49
+ - Which downstream tables/reports/APIs consume it?
50
+ - What would break if the source schema changed?
51
+ 4. Document the lineage:
52
+ - Source → Transform → Target chain
53
+ - Data freshness (batch frequency, streaming lag)
54
+ - Owner/team for each stage
55
+
56
+ Output a text-based lineage diagram showing the data flow.
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@stripe/mcp-server"]
8
8
  tags: [FINTECH]
9
9
  category: general
10
+ tier: recommended
10
11
  env:
11
12
  STRIPE_SECRET_KEY: ""
12
13
  url: "https://github.com/stripe/agent-toolkit"
@@ -0,0 +1,35 @@
1
+ tag: FINTECH
2
+ section: skills
3
+ skills:
4
+ - id: fintech-money-audit
5
+ name: Money Calculation Audit
6
+ filename: fintech-money-audit.md
7
+ description: "Audit codebase for monetary calculation safety"
8
+ tier: core
9
+ content: |
10
+ Audit the codebase for monetary calculation risks.
11
+
12
+ Scan for:
13
+ 1. **Floating-point arithmetic on money**:
14
+ - Any use of `float`, `double`, or JavaScript `number` for currency amounts
15
+ - Arithmetic operations (+, -, *, /) on money values without decimal/integer cents
16
+ - Rounding errors in tax, discount, or fee calculations
17
+ 2. **Currency handling**:
18
+ - Money values stored without currency code
19
+ - Mixed-currency arithmetic without explicit conversion
20
+ - Missing exchange rate snapshots for audit trail
21
+ 3. **Rounding**:
22
+ - Inconsistent rounding modes (banker's rounding vs. standard)
23
+ - Rounding applied at intermediate steps instead of final result
24
+ - Missing rounding specification in calculations
25
+ 4. **Overflow / precision**:
26
+ - Integer cents stored in types too small for large amounts
27
+ - Multiplication (e.g., interest) without precision guards
28
+ - Division without remainder handling
29
+
30
+ For each finding, report:
31
+ - **File**: path
32
+ - **Line**: number
33
+ - **Risk**: CRITICAL | HIGH | MEDIUM
34
+ - **Issue**: what could go wrong
35
+ - **Fix**: recommended change (e.g., use Decimal library, store as integer cents)
@@ -7,4 +7,5 @@ servers:
7
7
  args: ["-y", "@anthropic/unity-mcp"]
8
8
  tags: [GAME]
9
9
  category: game-engine
10
+ tier: recommended
10
11
  url: "https://github.com/CoplayDev/unity-mcp"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-postgres"]
8
8
  tags: [DATA-PIPELINE, API, HEALTHCARE]
9
9
  category: database
10
+ tier: recommended
10
11
  env:
11
12
  POSTGRES_CONNECTION_STRING: ""
12
13
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/postgres"
@@ -0,0 +1,35 @@
1
+ tag: HEALTHCARE
2
+ section: skills
3
+ skills:
4
+ - id: healthcare-phi-audit
5
+ name: PHI Audit
6
+ filename: healthcare-phi-audit.md
7
+ description: "Scan codebase for PHI exposure risks"
8
+ tier: core
9
+ content: |
10
+ Audit the codebase for Protected Health Information (PHI) exposure risks.
11
+
12
+ Scan for:
13
+ 1. **Logging**: Search for log statements that might include PHI fields:
14
+ - Patient name, DOB, SSN, MRN, address, phone, email
15
+ - Diagnosis codes, treatment plans, lab results
16
+ - Any field from a patient/member/encounter model
17
+ 2. **Error messages**: Check that error responses don't leak PHI in:
18
+ - API error bodies
19
+ - Exception messages
20
+ - Stack traces exposed to clients
21
+ 3. **Storage**: Verify PHI at rest is protected:
22
+ - Database fields containing PHI are identified and encrypted
23
+ - File uploads with PHI use encrypted storage
24
+ - Temporary files are cleaned up
25
+ 4. **Transmission**: Verify PHI in transit:
26
+ - All endpoints serving PHI require HTTPS
27
+ - No PHI in URL query parameters (use POST body)
28
+ - No PHI in client-side analytics or tracking
29
+
30
+ Report each finding with:
31
+ - **File**: path
32
+ - **Line**: number
33
+ - **Risk**: HIGH | MEDIUM | LOW
34
+ - **PHI type**: what data is exposed
35
+ - **Fix**: recommended remediation
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-postgres"]
8
8
  tags: [HIPAA, HEALTHCARE, API]
9
9
  category: database
10
+ tier: recommended
10
11
  env:
11
12
  POSTGRES_CONNECTION_STRING: ""
12
13
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/postgres"
@@ -0,0 +1,39 @@
1
+ tag: HIPAA
2
+ section: skills
3
+ skills:
4
+ - id: hipaa-compliance-check
5
+ name: HIPAA Compliance Check
6
+ filename: hipaa-compliance-check.md
7
+ description: "Verify HIPAA technical safeguard compliance"
8
+ tier: core
9
+ content: |
10
+ Check the project for HIPAA technical safeguard compliance.
11
+
12
+ Verify each requirement:
13
+
14
+ **Access Controls (§164.312(a))**:
15
+ - [ ] Unique user identification — every user has a unique ID
16
+ - [ ] Emergency access procedure — documented break-glass process
17
+ - [ ] Automatic logoff — session timeout configured
18
+ - [ ] Encryption/decryption — PHI encrypted at rest
19
+
20
+ **Audit Controls (§164.312(b))**:
21
+ - [ ] Audit logging enabled for all PHI access
22
+ - [ ] Logs include: who, what, when, where (IP)
23
+ - [ ] Logs are tamper-evident (append-only, signed, or immutable storage)
24
+ - [ ] Log retention meets minimum period (6 years)
25
+
26
+ **Integrity Controls (§164.312(c))**:
27
+ - [ ] Data validation on PHI fields
28
+ - [ ] Checksums or signatures for data integrity verification
29
+
30
+ **Transmission Security (§164.312(e))**:
31
+ - [ ] TLS 1.2+ enforced for all PHI transmission
32
+ - [ ] No PHI in URL parameters
33
+ - [ ] Encryption for PHI in message queues or event streams
34
+
35
+ For each gap, report:
36
+ - **Requirement**: HIPAA section reference
37
+ - **Status**: COMPLIANT | GAP | PARTIAL
38
+ - **Finding**: what's missing
39
+ - **Remediation**: specific implementation steps
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "mcp-server-docker"]
8
8
  tags: [INFRA]
9
9
  category: deployment
10
+ tier: recommended
10
11
  url: "https://github.com/ckreiling/mcp-server-docker"
11
12
 
12
13
  - name: kubernetes
@@ -15,4 +16,5 @@ servers:
15
16
  args: ["-y", "mcp-server-kubernetes"]
16
17
  tags: [INFRA]
17
18
  category: deployment
19
+ tier: optional
18
20
  url: "https://github.com/strowk/mcp-k8s-go"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-filesystem", "/"]
8
8
  tags: [CLI, LIBRARY]
9
9
  category: general
10
+ tier: recommended
10
11
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem"
11
12
 
12
13
  - name: npm-search
@@ -15,4 +16,5 @@ servers:
15
16
  args: ["-y", "mcp-server-npm-search"]
16
17
  tags: [LIBRARY]
17
18
  category: documentation
19
+ tier: optional
18
20
  url: "https://github.com/nicholasgriffintn/npm-search-mcp-server"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-postgres"]
8
8
  tags: [MEDALLION-ARCHITECTURE, DATA-PIPELINE]
9
9
  category: database
10
+ tier: recommended
10
11
  env:
11
12
  POSTGRES_CONNECTION_STRING: ""
12
13
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/postgres"
@@ -17,4 +18,5 @@ servers:
17
18
  args: ["-y", "@modelcontextprotocol/server-filesystem"]
18
19
  tags: [MEDALLION-ARCHITECTURE, DATA-PIPELINE]
19
20
  category: filesystem
21
+ tier: optional
20
22
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem"
@@ -7,4 +7,5 @@ servers:
7
7
  args: ["-y", "mcp-server-jupyter"]
8
8
  tags: [ML, DATA-PIPELINE]
9
9
  category: ai-ml
10
+ tier: recommended
10
11
  url: "https://github.com/datalayer/jupyter-mcp-server"
@@ -7,4 +7,5 @@ servers:
7
7
  args: ["-y", "mcp-server-android"]
8
8
  tags: [MOBILE]
9
9
  category: devtools
10
+ tier: recommended
10
11
  url: "https://github.com/nicholasgriffintn/android-mcp-server"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "mcp-server-cloudwatch"]
8
8
  tags: [OBSERVABILITY-XRAY, INFRA]
9
9
  category: monitoring
10
+ tier: recommended
10
11
  env:
11
12
  AWS_REGION: ""
12
13
  AWS_ACCESS_KEY_ID: ""
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "mcp-server-redis"]
8
8
  tags: [REALTIME]
9
9
  category: database
10
+ tier: recommended
10
11
  env:
11
12
  REDIS_URL: "redis://localhost:6379"
12
13
  url: "https://github.com/nicholasgriffintn/redis-mcp-server"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-github"]
8
8
  tags: [SOC2, UNIVERSAL]
9
9
  category: version-control
10
+ tier: recommended
10
11
  env:
11
12
  GITHUB_PERSONAL_ACCESS_TOKEN: ""
12
13
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/github"
@@ -17,6 +18,7 @@ servers:
17
18
  args: ["-y", "mcp-server-sentry"]
18
19
  tags: [SOC2, API]
19
20
  category: monitoring
21
+ tier: optional
20
22
  env:
21
23
  SENTRY_AUTH_TOKEN: ""
22
24
  url: "https://github.com/modelcontextprotocol/servers"
@@ -7,6 +7,7 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-postgres"]
8
8
  tags: [DATA-PIPELINE, API, SOCIAL]
9
9
  category: database
10
+ tier: recommended
10
11
  env:
11
12
  POSTGRES_CONNECTION_STRING: ""
12
13
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/postgres"
@@ -17,6 +18,7 @@ servers:
17
18
  args: ["-y", "mcp-server-redis"]
18
19
  tags: [REALTIME, SOCIAL]
19
20
  category: database
21
+ tier: optional
20
22
  env:
21
23
  REDIS_URL: "redis://localhost:6379"
22
24
  url: "https://github.com/nicholasgriffintn/redis-mcp-server"
@@ -7,4 +7,5 @@ servers:
7
7
  args: ["-y", "@modelcontextprotocol/server-sequential-thinking"]
8
8
  tags: [UNIVERSAL, STATE-MACHINE]
9
9
  category: general
10
+ tier: optional
10
11
  url: "https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking"
@@ -182,6 +182,69 @@ hooks:
182
182
  fi
183
183
  echo "🔍 Production quality scan passed"
184
184
 
185
+ - name: function-length
186
+ trigger: pre-commit
187
+ description: "Warn when staged functions exceed the configured maximum line count"
188
+ filename: pre-commit-function-length.sh
189
+ script: |
190
+ #!/bin/bash
191
+ MAX_LENGTH={{max_function_length | default: 50}}
192
+ STAGED=$(git diff --cached --name-only --diff-filter=ACM)
193
+ SOURCE_FILES=$(echo "$STAGED" | grep -E '\.(ts|tsx|js|jsx)$' | grep -vE '(\.test\.|\.spec\.|__tests__|tests/)')
194
+ if [ -z "$SOURCE_FILES" ]; then exit 0; fi
195
+ WARNINGS=0
196
+ for file in $SOURCE_FILES; do
197
+ # Heuristic: find function/method declarations and count lines to next declaration or closing brace
198
+ awk -v max="$MAX_LENGTH" -v fname="$file" '
199
+ /^[[:space:]]*(export )?(async )?(function |const [a-zA-Z]+ = (async )?\(|[a-zA-Z]+\(.*\) \{|[a-zA-Z]+\(.*\): )/ {
200
+ if (start > 0 && NR - start > max) {
201
+ printf " ⚠️ %s:%d — function starting here is %d lines (max %d)\n", fname, start, NR - start, max
202
+ warnings++
203
+ }
204
+ start = NR
205
+ }
206
+ END {
207
+ if (start > 0 && NR - start > max) {
208
+ printf " ⚠️ %s:%d — function starting here is %d lines (max %d)\n", fname, start, NR - start, max
209
+ warnings++
210
+ }
211
+ }
212
+ ' "$file"
213
+ WARNINGS=$((WARNINGS + $?))
214
+ done
215
+ # Warning only — does not block commit since bash heuristics aren't perfect
216
+ exit 0
217
+
218
+ - name: import-cycle-detector
219
+ trigger: pre-commit
220
+ description: "Detect circular import dependencies in TypeScript and Python projects"
221
+ filename: pre-commit-import-cycles.sh
222
+ script: |
223
+ #!/bin/bash
224
+ echo "🔄 Checking for circular imports..."
225
+ if [ -f "tsconfig.json" ]; then
226
+ if command -v npx &> /dev/null; then
227
+ RESULT=$(npx --yes madge --circular --extensions ts src/ 2>&1)
228
+ if echo "$RESULT" | grep -q "Found.*circular"; then
229
+ echo "❌ Circular imports detected in TypeScript:"
230
+ echo "$RESULT"
231
+ exit 1
232
+ fi
233
+ echo " ✅ No circular imports (TypeScript)"
234
+ fi
235
+ fi
236
+ if [ -f "pyproject.toml" ] || [ -f "setup.py" ]; then
237
+ if command -v lint-imports &> /dev/null; then
238
+ lint-imports 2>&1
239
+ if [ $? -ne 0 ]; then
240
+ echo "❌ Circular imports detected in Python"
241
+ exit 1
242
+ fi
243
+ echo " ✅ No circular imports (Python)"
244
+ fi
245
+ fi
246
+ echo "🔄 Import cycle check passed"
247
+
185
248
  - name: code-review
186
249
  trigger: pre-commit
187
250
  description: "AI assistant reviews diff against project standards"