-
Notifications
You must be signed in to change notification settings - Fork 14
Add TypeSpec AI Tools emitter to generate Effect SchemasFeature/schema gen #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adilhbay
wants to merge
25
commits into
the-dev-tools:main
Choose a base branch
from
adilhbay:feature/schema-gen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Use Object.values().map() instead of manual listing in index.ts - Delete schemas-effect.ts (209 lines of unnecessary re-exports) - Delete test-effect-schemas.ts (development artifact) - Build validation map dynamically from EffectSchemas Adding a new tool now requires only 2 steps: 1. Add schema to MutationSchemas/ExplorationSchemas/ExecutionSchemas 2. Run pnpm generate:schemas
Replace hand-written Effect Schema definitions with TypeSpec-generated code. This introduces a new emitter that transforms @aitool decorated models into Effect Schema TypeScript files. New emitter infrastructure (tools/spec-lib/src/ai-tools/): - lib.ts: @aitool decorator and ToolCategory enum - main.tsp: TypeSpec declarations - emitter.tsx: Alloy.js emitter generating Effect Schemas - index.ts: Module exports Tool definitions moved to TypeSpec (packages/spec/api/flow.tsp): - 12 Mutation tools (CreateJsNode, ConnectNodes, etc.) - 8 Exploration tools (GetWorkflowGraph, SearchApiDocs, etc.) - 3 Execution tools (RunWorkflow, StopWorkflow, ValidateWorkflow) The emitter generates code that imports shared schemas from common.ts and produces the same JSON Schema output as the hand-written files. Co-Authored-By: Claude Opus 4.5 <[email protected]>
… decorator Replace 23 duplicate AI tool models with a @mutationTool decorator on collection models. The emitter resolves Insert/Update/Delete properties at emit time based on primary keys, visibility, and exclude lists. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Auto-generate Get{ModelName} exploration tools from @mutationTool-decorated
collections using PK fields. Annotate FlowRunRequest/FlowStopRequest with
@aitool for execution schema generation.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ema generation Add a new @explorationTool decorator that generates custom exploration tools from collection model primary keys. Apply it to the Flow model to create a ValidateWorkflow tool. Also wire up execution and exploration schemas into the JSON schema generator alongside mutations. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Extract getFieldSchema/formatStringLiteral to field-schema.ts, replace implicit auto-generated Get* exploration tools with explicit @explorationTool decorators on each mutation model, unify 3 import components and 4 tool/property schema components into single generic versions, and simplify CategoryFiles to a uniform rendering path. Reduces emitter from 772 to 331 lines. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Make sourceHandle optional on Edge model so ConnectNodes allows omitting it for sequential flows. Add exclude support to the emitter's Update case so UpdateNodeConfig correctly omits the immutable kind field. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…o feature/schema-gen
…tools into feature/schema-gen
Replace single ConnectNodes tool with two specialized tools: - ConnectSequentialNodes: excludes sourceHandle for ManualStart/JS/HTTP nodes - ConnectBranchingNodes: requires sourceHandle for Condition/For/ForEach nodes This eliminates the need for optional sourceHandle which caused Go type issues. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fix OptionalPosition to apply annotations inside Schema.optional wrapper - Fix emitter to generate correct code for optional fields with descriptions - Add src/tools to tsconfig.lib.json include list - Fix index signature access to use bracket notation in index.ts Schema.optional() returns a PropertySignature that cannot be piped, so annotations must be applied to the inner schema first. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…tter output The emitter now generates common.ts and index.ts alongside the category files in dist/ai-tools/v1/, removing the dependency on hand-written src/tools/ files. JSON Schema conversion happens at module import time instead of a separate build step. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…nd mutationTool Makes name, title, and description optional on explorationTool/mutationTool decorators, computing defaults from the model name using PascalCase splitting. Simplifies flow.tsp by removing redundant decorator arguments that match the derived defaults. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use <hbr /> instead of {'\n'} and code tag instead of manual brace
expressions for improved readability. Output is unchanged.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
These files don't use any TypeSpec data - they're just hardcoded strings in the emitter. Moving them to source files in packages/spec/src/tools/ reduces complexity and makes them easier to maintain. - Create packages/spec/src/tools/common.ts with shared schemas - Create packages/spec/src/tools/index.ts with runtime utilities - Remove CommonSchemaFile and IndexFile components from emitter - Update package.json exports to point to source files - Generated files now import from @the-dev-tools/spec/tools/common Co-Authored-By: Claude Opus 4.5 <[email protected]>
Consolidates schema-related code in spec-lib package. The emitter now generates imports from @the-dev-tools/spec-lib/common, avoiding circular dependencies by hardcoding enum values instead of importing from protobuf. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Documents that ErrorHandling and SourceHandle literals must stay in sync with protobuf definitions in api/flow/v1/flow.proto. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Runtime utilities (schemaToToolDefinition, validateToolInput, allToolSchemas) are only used by the agent, so they belong in the client package. The spec package now only exports the generated schemas. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use Effect's idiomatic error handling with Schema.decodeUnknownEither and Either.mapLeft instead of wrapping decodeUnknownSync in try-catch. Co-Authored-By: Claude Opus 4.5 <[email protected]>
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
@mutationTool,@explorationTool, and@executionTooldecorators