@aiready/contract-enforcement 0.2.0 → 0.2.1

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.
@@ -1,18 +1,19 @@
1
-
2
- > @aiready/contract-enforcement@0.2.0 build /Users/pengcao/projects/aiready/packages/contract-enforcement
3
- > tsup src/index.ts --format cjs,esm --dts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Target: es2020
9
- CJS Build start
10
- ESM Build start
11
- ESM dist/index.mjs 15.46 KB
12
- ESM ⚡️ Build success in 76ms
13
- CJS dist/index.js 16.88 KB
14
- CJS ⚡️ Build success in 86ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 4708ms
17
- DTS dist/index.d.ts 2.45 KB
18
- DTS dist/index.d.mts 2.45 KB
1
+
2
+ 
3
+ > @aiready/contract-enforcement@0.2.1 build /Users/pengcao/projects/aiready/packages/contract-enforcement
4
+ > tsup src/index.ts --format cjs,esm --dts
5
+
6
+ CLI Building entry: src/index.ts
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.5.1
9
+ CLI Target: es2020
10
+ CJS Build start
11
+ ESM Build start
12
+ CJS dist/index.js 16.88 KB
13
+ CJS ⚡️ Build success in 287ms
14
+ ESM dist/index.mjs 15.46 KB
15
+ ESM ⚡️ Build success in 289ms
16
+ DTS Build start
17
+ DTS ⚡️ Build success in 5891ms
18
+ DTS dist/index.d.ts 2.45 KB
19
+ DTS dist/index.d.mts 2.45 KB
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @aiready/contract-enforcement
2
+
3
+ > AIReady Spoke: Measures structural type safety and contract enforcement to reduce downstream fallback cascades for AI agents.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@aiready/contract-enforcement.svg)](https://npmjs.com/package/@aiready/contract-enforcement)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Overview
9
+
10
+ AI agents rely on strong structural contracts to navigate codebases safely. When type safety is bypassed or errors are swallowed, agents lose context and may hallucinate or fail silently. The **Contract Enforcement** analyzer detects defensive coding anti-patterns and scores how well the codebase enforces structural contracts.
11
+
12
+ ## 🏛️ Architecture
13
+
14
+ ```
15
+ 🎯 USER
16
+
17
+
18
+ 🎛️ @aiready/cli (orchestrator)
19
+ │ │ │ │ │ │ │ │ │ │
20
+ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
21
+ [PAT] [CTX] [CON] [AMP] [DEP] [DOC] [SIG] [AGT] [TST] [CTR]
22
+ │ │ │ │ │ │ │ │ │ │
23
+ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
24
+
25
+
26
+ 🏢 @aiready/core
27
+
28
+ Legend:
29
+ PAT = pattern-detect CTX = context-analyzer
30
+ CON = consistency AMP = change-amplification
31
+ DEP = deps-health DOC = doc-drift
32
+ SIG = ai-signal-clarity AGT = agent-grounding
33
+ TST = testability CTR = contract-enforcement ★
34
+ ★ = YOU ARE HERE
35
+ ```
36
+
37
+ ## Features
38
+
39
+ - **Type Escape Hatches**: Detects `as any`, `as unknown`, and `any` parameter/return types that bypass type safety.
40
+ - **Fallback Cascades**: Identifies deep optional chaining (`?.?.?`) and nullish coalescing with literal defaults that suggest missing upstream guarantees.
41
+ - **Error Transparency**: Flags swallowed catch blocks where errors are silenced, hiding failures from agents.
42
+ - **Boundary Validation**: Detects unvalidated environment variable access and unnecessary guard clauses that could be handled via stronger types at the source.
43
+
44
+ ## Scoring Dimensions
45
+
46
+ - **Type Escape Hatches (35%)**: Measures the density of `any` and `unknown` bypasses.
47
+ - **Fallback Cascades (25%)**: Evaluates reliance on inline defaults vs. structural guarantees.
48
+ - **Error Transparency (20%)**: penalizes silent failures and swallowed exceptions.
49
+ - **Boundary Validation (20%)**: Assesses the use of validated schemas vs. ad-hoc guards.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pnpm add @aiready/contract-enforcement
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ This tool is designed to be run through the unified AIReady CLI.
60
+
61
+ ```bash
62
+ # Scan for contract enforcement quality
63
+ aiready scan . --tools contract-enforcement
64
+ ```
65
+
66
+ ## License
67
+
68
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aiready/contract-enforcement",
3
- "version": "0.2.0",
4
- "description": "Measures structural contract enforcement to reduce defensive coding cascades",
3
+ "version": "0.2.1",
4
+ "description": "Measures structural type safety and boundary validation to reduce fallback cascades for AI agents",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -12,9 +12,27 @@
12
12
  "import": "./dist/index.js"
13
13
  }
14
14
  },
15
+ "keywords": [
16
+ "aiready",
17
+ "contract-enforcement",
18
+ "type-safety",
19
+ "static-analysis",
20
+ "ai-ready",
21
+ "typescript",
22
+ "structural-contracts",
23
+ "defensive-coding",
24
+ "error-handling"
25
+ ],
26
+ "author": "AIReady Team",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/caopengau/aiready-contract-enforcement.git"
31
+ },
32
+ "homepage": "https://github.com/caopengau/aiready-contract-enforcement",
15
33
  "dependencies": {
16
34
  "@typescript-eslint/typescript-estree": "^8.53.0",
17
- "@aiready/core": "0.24.0"
35
+ "@aiready/core": "0.24.1"
18
36
  },
19
37
  "devDependencies": {
20
38
  "@types/node": "^24.0.0",
@@ -30,6 +48,7 @@
30
48
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
31
49
  "test": "vitest run",
32
50
  "lint": "eslint src",
33
- "clean": "rm -rf dist"
51
+ "clean": "rm -rf dist",
52
+ "release": "pnpm build && pnpm publish --no-git-checks"
34
53
  }
35
54
  }