{"_id":"@coderifts/contract-path","_rev":"5-26d270cb8828a4f70d4a078205b24d6d","name":"@coderifts/contract-path","dist-tags":{"latest":"1.3.1"},"versions":{"1.0.0":{"name":"@coderifts/contract-path","version":"1.0.0","keywords":["coderifts","openapi","asyncapi","graphql","grpc","mcp","contract","path"],"author":{"name":"CodeRifts","email":"hello@coderifts.com"},"license":"MIT","_id":"@coderifts/contract-path@1.0.0","maintainers":[{"name":"zsobpeter","email":"zsobpeter@gmail.com"}],"homepage":"https://coderifts.com","bugs":{"url":"https://github.com/coderifts/app/issues"},"dist":{"shasum":"bbe4c3365da5fed773b2ef9f85f3ebe46d16c914","tarball":"https://registry.npmjs.org/@coderifts/contract-path/-/contract-path-1.0.0.tgz","fileCount":6,"integrity":"sha512-tV7c1Fi9PLo3xH9kKith3IiAfXsk5lAdyItfol3L2wgpaN7cF0c8vZuMFhBK6NA1bgLcVV03/KzPaiDPeYHvYw==","signatures":[{"sig":"MEYCIQDbt61wAJsPPkDMk9VJv7LLxw2iOlY4icxRMhpPsjLxawIhANmcD7zqtqWQrN5ldyvRpA7K1c9+T62fM8VI8KbVer7z","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5930},"main":"./index.cjs","types":"./index.d.ts","module":"./index.mjs","engines":{"node":">=20.0.0"},"exports":{".":{"import":{"types":"./index.d.ts","default":"./index.mjs"},"require":{"types":"./index.d.ts","default":"./index.cjs"}}},"gitHead":"06e4ef3388270597b986aa975d027f1ffb7c44e2","scripts":{"test":"node --test test/*.test.js","prepublishOnly":"npm test"},"_npmUser":{"name":"zsobpeter","email":"zsobpeter@gmail.com"},"repository":{"url":"git+https://github.com/coderifts/app.git","type":"git","directory":"packages/contract-path"},"_npmVersion":"11.6.2","description":"Path-name classifier for API contract artifacts (OpenAPI, AsyncAPI, GraphQL, gRPC, MCP). Single list. Zero dependencies.","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/contract-path_1.0.0_1787590806270_0.1814412179714766","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@coderifts/contract-path","version":"1.1.0","keywords":["coderifts","openapi","asyncapi","graphql","grpc","mcp","contract","path"],"author":{"name":"CodeRifts","email":"hello@coderifts.com"},"license":"MIT","_id":"@coderifts/contract-path@1.1.0","maintainers":[{"name":"zsobpeter","email":"zsobpeter@gmail.com"}],"homepage":"https://coderifts.com","bugs":{"url":"https://github.com/coderifts/api-governance/issues"},"dist":{"shasum":"979a7401689028746e5f0c204aa306a1bea35177","tarball":"https://registry.npmjs.org/@coderifts/contract-path/-/contract-path-1.1.0.tgz","fileCount":9,"integrity":"sha512-VfPmt+vyYwXi7BQVKIthazQSTzVxPtF0gL8sM81ROTY8ePKt1T9FbYnmBpxNaweEmAQvPshuk+Ytl54UgdUNJw==","signatures":[{"sig":"MEUCIHnm61c/N+Uld95yzV1Xl+qKxh/ni52CJxC9jQ0t8LeKAiEA1dyUbCfYvWKF9uEd6tX6yKDTm5mPxTB5gTKZwQ68hAk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQCOuyPnmBNAkdkLiVzSUN7z5AGJ/7M9+Twsm/8T8SsKdAIgStCBw8vciOAJG0pOfQ1Q0HqBmogBNLYvuqUocyFuEnE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":81452},"main":"./index.cjs","types":"./index.d.ts","module":"./index.mjs","engines":{"node":">=20.0.0"},"exports":{".":{"import":{"types":"./index.d.ts","default":"./index.mjs"},"require":{"types":"./index.d.ts","default":"./index.cjs"}},"./contract-write":{"import":"./contract-write.mjs","require":"./contract-write.cjs"}},"gitHead":"4819418f48c963d04ec44b81034a1a409b95e530","scripts":{"test":"node --test test/*.test.js","prepublishOnly":"npm test"},"_npmUser":{"name":"zsobpeter","email":"zsobpeter@gmail.com"},"repository":{"url":"git+https://github.com/coderifts/api-governance.git","type":"git"},"_npmVersion":"11.6.2","description":"Path-name classifier for API contract artifacts (OpenAPI, AsyncAPI, GraphQL, gRPC, MCP). Single list. Zero dependencies.","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/contract-path_1.1.0_1791109897661_0.41151743026541876","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@coderifts/contract-path","version":"1.2.0","keywords":["coderifts","openapi","asyncapi","graphql","grpc","mcp","contract","path"],"author":{"name":"CodeRifts","email":"hello@coderifts.com"},"license":"MIT","_id":"@coderifts/contract-path@1.2.0","maintainers":[{"name":"zsobpeter","email":"zsobpeter@gmail.com"}],"homepage":"https://coderifts.com","bugs":{"url":"https://github.com/coderifts/api-governance/issues"},"dist":{"shasum":"fd0215e97b1ce63fc459af38997eab1b93992931","tarball":"https://registry.npmjs.org/@coderifts/contract-path/-/contract-path-1.2.0.tgz","fileCount":9,"integrity":"sha512-hcgMWd991v/aOB4bxz+W4+j3eUyr+UYO/xSR6cbIsClVT8XltaiYEbU4CiqVk2/3HlIFwPaKz7t6OZkVM2OFVA==","signatures":[{"sig":"MEQCICmebkDEENW+WDRfDhRD1XnDidxd6PCLq+04ojp6RxfUAiAI8Iz3fRmZ79coG9ZLSONjvMdgNs/PYIubP3/q2zm27A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQDgc22rNyk6aeCiNIu04RWrKKRXHDdM/Ji+hPbZupdKDgIhANEpBGZd9Zt48/TGR8NAp7CrZd5mx4PtajBjA8sQJsxY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":84781},"main":"./index.cjs","types":"./index.d.ts","module":"./index.mjs","engines":{"node":">=20.0.0"},"exports":{".":{"import":{"types":"./index.d.ts","default":"./index.mjs"},"require":{"types":"./index.d.ts","default":"./index.cjs"}},"./contract-write":{"import":"./contract-write.mjs","require":"./contract-write.cjs"}},"gitHead":"f738e3b50828c7e721394aad751b28dab7644e6b","scripts":{"test":"node --test test/*.test.js","prepublishOnly":"npm test"},"_npmUser":{"name":"zsobpeter","email":"zsobpeter@gmail.com"},"repository":{"url":"git+https://github.com/coderifts/api-governance.git","type":"git"},"_npmVersion":"11.6.2","description":"Path-name classifier for API contract artifacts (OpenAPI, AsyncAPI, GraphQL, gRPC, MCP). Single list. Zero dependencies.","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/contract-path_1.2.0_1791316733401_0.1627004506995895","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@coderifts/contract-path","version":"1.3.0","keywords":["coderifts","openapi","asyncapi","graphql","grpc","mcp","contract","path"],"author":{"name":"CodeRifts","email":"hello@coderifts.com"},"license":"MIT","_id":"@coderifts/contract-path@1.3.0","maintainers":[{"name":"zsobpeter","email":"zsobpeter@gmail.com"}],"homepage":"https://coderifts.com","bugs":{"url":"https://github.com/coderifts/api-governance/issues"},"dist":{"shasum":"b4e8abcf5596497dddee3f17d2346de8b961564d","tarball":"https://registry.npmjs.org/@coderifts/contract-path/-/contract-path-1.3.0.tgz","fileCount":9,"integrity":"sha512-ie7Gjj/vzuhgKesiXcq7TS3AwFFntn6WIDr1WEP4FCOfC7Xjim4dB+S6QpN1ZQO6DrZJopwHemv8IIMBs3C0QA==","signatures":[{"sig":"MEUCIBdTKcQ+7CLjezPToDojkGjXUPeAyrxu+/swn2bbsOXiAiEAmHM5RnRMumlzCzPUK+Hb/F7N3/GCTOpXj/sy4Ykefjo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCrxmz+R+PfaoUViiCSGlgPUSvfWaS4VoZ2qx1lUbPV5AIhAOUXedh86Z0JztYYGEam0ns+ACux1H8K9VCyvtJ4hrwY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":93160},"main":"./index.cjs","types":"./index.d.ts","module":"./index.mjs","engines":{"node":">=20.0.0"},"exports":{".":{"import":{"types":"./index.d.ts","default":"./index.mjs"},"require":{"types":"./index.d.ts","default":"./index.cjs"}},"./contract-write":{"import":"./contract-write.mjs","require":"./contract-write.cjs"}},"gitHead":"c8897c9050c1f7b949135701c8fb0f63e5e9ae6f","scripts":{"test":"node --test test/*.test.js","prepublishOnly":"npm test"},"_npmUser":{"name":"zsobpeter","email":"zsobpeter@gmail.com"},"repository":{"url":"git+https://github.com/coderifts/api-governance.git","type":"git"},"_npmVersion":"11.6.2","description":"Path-name classifier for API contract artifacts (OpenAPI, AsyncAPI, GraphQL, gRPC, MCP). Single list. Zero dependencies.","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/contract-path_1.3.0_1791445655411_0.41350526917402264","host":"s3://npm-registry-packages-npm-production"}},"1.3.1":{"_id":"@coderifts/contract-path@1.3.1","bugs":{"url":"https://github.com/coderifts/api-governance/issues"},"dist":{"shasum":"040e948c7de6d7e33ef20523ae820f60b56c4dfe","tarball":"https://registry.npmjs.org/@coderifts/contract-path/-/contract-path-1.3.1.tgz","fileCount":9,"integrity":"sha512-2kvW3NTC7zsNjxRrPiVYRfFXHCxC2+FkBGaDcdRcdHUur9cp+XISg0YYecmdPcT54YkJ4gpoNDCpRC+qCHHlVw==","signatures":[{"sig":"MEUCICpCizjPyZ3OFmgvnMdE+APmQNmqMcgZo7TGHWqVHRjdAiEAvvoge47tPe3xE+pgj5Uuy/H9OzHr47XmDPr1yL2K+3I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCwF7uE1v00UmxYdKXfgPJwfcABIht4xR6ddbIAesVfkAIhAMfO2GeRN4O5g5t4B7C/ssz2uCW1kCDGKuRdAIsaDcCt"}],"unpackedSize":101407},"main":"./index.cjs","name":"@coderifts/contract-path","types":"./index.d.ts","author":{"name":"CodeRifts","email":"hello@coderifts.com"},"module":"./index.mjs","engines":{"node":">=20.0.0"},"exports":{".":{"import":{"types":"./index.d.ts","default":"./index.mjs"},"require":{"types":"./index.d.ts","default":"./index.cjs"}},"./contract-write":{"import":"./contract-write.mjs","require":"./contract-write.cjs"}},"gitHead":"705029db948ca954483daa644e9877040537305e","license":"MIT","scripts":{"test":"node --test test/*.test.js","prepublishOnly":"npm test"},"version":"1.3.1","_npmUser":{"name":"zsobpeter","email":"zsobpeter@gmail.com"},"homepage":"https://coderifts.com","keywords":["coderifts","openapi","asyncapi","graphql","grpc","mcp","contract","path"],"repository":{"url":"git+https://github.com/coderifts/api-governance.git","type":"git"},"_npmVersion":"11.6.2","description":"Path-name classifier for API contract artifacts (OpenAPI, AsyncAPI, GraphQL, gRPC, MCP). Single list. Zero dependencies.","directories":{},"maintainers":[{"name":"zsobpeter","email":"zsobpeter@gmail.com"}],"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/contract-path_1.3.1_1791555790009_0.13437239284933344"}}},"time":{"created":"2026-08-24T17:00:06.111Z","modified":"2026-10-09T14:23:10.290Z","1.0.0":"2026-08-24T17:00:06.441Z","1.1.0":"2026-10-04T10:31:37.740Z","1.2.0":"2026-10-06T19:58:53.500Z","1.3.0":"2026-10-08T07:47:35.508Z","1.3.1":"2026-10-09T14:23:10.098Z"},"bugs":{"url":"https://github.com/coderifts/api-governance/issues"},"author":{"name":"CodeRifts","email":"hello@coderifts.com"},"license":"MIT","homepage":"https://coderifts.com","keywords":["coderifts","openapi","asyncapi","graphql","grpc","mcp","contract","path"],"repository":{"url":"git+https://github.com/coderifts/api-governance.git","type":"git"},"description":"Path-name classifier for API contract artifacts (OpenAPI, AsyncAPI, GraphQL, gRPC, MCP). Single list. Zero dependencies.","maintainers":[{"name":"zsobpeter","email":"zsobpeter@gmail.com"}],"readme":"# @coderifts/contract-path\n\nPath-name classifier for API contract artifacts. **Single list.** Zero runtime\ndependencies.\n\nThis is the same classifier the CodeRifts merge gate and the generic\n`derivation: \"server\"` path (ID637 6b) use. Hosts (OpenAI-Agents guardrail,\nhooks, other packages) import it from npm instead of reaching into the app\ncheckout.\n\nClassification is **path-name only**. The module does not read file content.\n\n```bash\nnpm install @coderifts/contract-path\n```\n\n```js\nconst { looksLikeContractPath, typeForPath } = require('@coderifts/contract-path');\n// or: import { looksLikeContractPath, typeForPath } from '@coderifts/contract-path';\n\nif (looksLikeContractPath(filename)) {\n  const type = typeForPath(filename); // 'openapi' | 'asyncapi' | 'graphql' | 'grpc' | 'mcp_manifest'\n}\n```\n\nCall `looksLikeContractPath` first. `typeForPath` is a mapping, not a gate:\n`typeForPath('package.json')` returns `'openapi'` even though `looksLike` is\nfalse.\n\n## What counts\n\nA path is a contract artifact when **all** of:\n\n1. It is not under `node_modules/` or `vendor/`.\n2. Its extension matches `.(ya?ml|json|graphql|gql|proto)` (case-insensitive).\n3. Its path-name contains `openapi`, `swagger`, `asyncapi`, or `mcp`, **or**\n   the extension is `.graphql` / `.gql` / `.proto`.\n\n| Path | looksLike | type (if looksLike) |\n|---|---|---|\n| `api/openapi.yaml` | true | `openapi` |\n| `swagger.json` | true | `openapi` |\n| `asyncapi.yaml` | true | `asyncapi` |\n| `schema.graphql` | true | `graphql` |\n| `svc/user.proto` | true | `grpc` |\n| `mcp.json` / `.well-known/mcp.json` | true | `mcp_manifest` |\n| `package.json` | false | — |\n| `tsconfig.json` | false | — |\n| `package-lock.json` / `pnpm-lock.yaml` | false | — |\n| `.github/workflows/ci.yml` | false | — |\n| `README.md` / `src/index.js` | false | — |\n| `node_modules/openapi.yaml` | false | — |\n| `vendor/openapi.yaml` | false | — |\n\nExisting behaviour, not a new rule: `.github/workflows/openapi.yaml` is\n**true** today because the file name contains `openapi`. Do not invent a\nworkflow exclusion in this module.\n\n## Dual module\n\nCJS (`index.cjs`) is the algorithm. ESM (`index.mjs`) re-exports it via\n`createRequire` so there is one list, not two.\n\n## contract-write: does this tool call touch a contract file?\n\n`@coderifts/contract-path/contract-write` is the one decision function the three local CodeRifts entry\npoints share: the agent-hooks Claude Code hook, `coderifts claude-hook`, and the CodeRifts mod. It uses\nthe list above, word for word, plus the two names those hooks gated before (`*tool-schema*.json` as\n`agent_tools`, `tools.json` / `tools.wire.v1.json` as `mcp_manifest`).\n\n```js\nconst { decideToolCall } = require('@coderifts/contract-path/contract-write');\n// or: import { decideToolCall } from '@coderifts/contract-path/contract-write';\n\nconst d = await decideToolCall({ tool: 'Edit', input: { file_path, old_string, new_string } }, {\n  cwd,\n  readFile: (p) => /* the text, or null when the file does not exist; throw when it cannot be read */,\n  listDir: (dir) => /* [{ name, kind: 'file' | 'directory' }] for one level, or null */,\n});\n// d.action: 'pass' | 'gate' (d.type, d.before, d.after) | 'refuse' (d.why) | 'ask' (d.why, d.scopes)\n```\n\n- **Write / Edit / MultiEdit** on a contract file: `gate`, with the text before and after (an Edit is\n  applied to the file as it is; `replace_all` and the empty-`old_string` create form follow Claude Code).\n  An edit that does not apply, or a contract file that cannot be read, is `refuse` — never guessed.\n- **Bash**: a write to a named contract file is `refuse` (use the Write or Edit tool, where the after\n  text is seen). A write that can reach a directory holding a contract file without naming it\n  (`find … -exec sed -i`, `xargs`, a glob, `rm -rf <dir>`, `git stash pop`, a pipe into `sh`) is `ask`.\n  A read passes.\n\nIt reads the command text; it does not parse shell. A shape it does not recognise passes — a local hook\nis feedback, and the required check on the pull request is the guarantee. Pure: no imports and no I/O\n(the CodeRifts mod loads it as a hooks module).\n","readmeFilename":"README.md"}