feat(codemode): extract utilities into AI-free main entry point#1102
Merged
mattzcarey merged 2 commits intomainfrom Mar 13, 2026
Merged
feat(codemode): extract utilities into AI-free main entry point#1102mattzcarey merged 2 commits intomainfrom
mattzcarey merged 2 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: ccb9cfa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
pass ci so I can merge this? |
Contributor
Author
on it boss |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Move sanitizeToolName, JSON Schema conversion utilities, and a new generateTypesFromJsonSchema function into a separate sanitize.ts module with zero AI SDK dependencies. The main entry point (import from "@cloudflare/codemode") no longer requires the ai or zod peer dependencies — they are now optional and only needed when importing from "@cloudflare/codemode/ai". BREAKING: generateTypes and ToolDescriptor/ToolDescriptors types moved from the main entry to "@cloudflare/codemode/ai".
60e3c31 to
0cae03b
Compare
805e182 to
15f44a5
Compare
Split the package so the main entry point has zero dependency on `ai`/`zod`: - `utils.ts` — sanitizeToolName, toCamelCase, and string helpers - `json-schema-types.ts` — JSON Schema → TypeScript type generation - `tool-types.ts` — AI SDK dependent type generation (moved from types.ts) The main entry (`@cloudflare/codemode`) now exports sanitizeToolName, normalizeCode, generateTypesFromJsonSchema, jsonSchemaToType, and the executor classes. The `/ai` entry point keeps createCodeTool and generateTypes which require the ai/zod peer deps. Also fixes duplicate type declarations when extractParamDescriptions throws, and moves json-schema from runtime deps to @types/json-schema in devDependencies.
15f44a5 to
ccb9cfa
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The main entry point (
@cloudflare/codemode) no longer requires theaiorzodpeer dependencies. They are now optional and only needed when importing from@cloudflare/codemode/ai.This lets projects like Cloudflare MCP use the tested utility functions (
sanitizeToolName,normalizeCode,generateTypesFromJsonSchema, executors) without pulling in the AI SDK.Changes
utils.ts— pure helpers with zero deps:sanitizeToolName,toCamelCase,escapeJsDoc,escapeStringLiteral,quotePropjson-schema-types.ts— JSON Schema → TypeScript conversion +generateTypesFromJsonSchema(no AI SDK)types.ts→tool-types.ts— AI-dependentgenerateTypes+ToolDescriptor/ToolDescriptorstypesai.ts— now also exportsgenerateTypes,ToolDescriptor,ToolDescriptorspackage.json—aiandzodpeer deps markedoptional: true, addedjson-schemaas direct deputils.test.ts,tool-types.test.ts,json-schema-types.test.ts(11 new tests for the AI-free APIs)generateTypesFromJsonSchemaBreaking change
generateTypesandToolDescriptor/ToolDescriptorstypes moved from the main entry to@cloudflare/codemode/ai:Module structure
ai/zod@cloudflare/codemodesanitizeToolName,normalizeCode,generateTypesFromJsonSchema,jsonSchemaToType,DynamicWorkerExecutor,ToolDispatcher@cloudflare/codemode/aicreateCodeTool,generateTypes,ToolDescriptor,ToolDescriptorsSource file layout
Test plan
dist/index.jshas noaiimports, onlydist/ai.jsdoesnormalizeCodefrom the main entry without needingai