Ash Weekly: Issue #18
CheckCodegenStatus plug, `--dev` migrations, Ash.Scope, shared action context, usage-rules.md, `ash_ai.gen.chat` improvements, `Igniter.Scribe`
Ash Weekly!
Welcome to Ash Weekly — your quick, informal digest of what’s new and notable in the world of Ash Framework. Got something cool? Drop it in the #showcase channel on Discord!
Shameless Plugs
Check out Ash Premium Support from Alembic.
Sponsor me if you like what I do.
Boy do we have a lot of stuff for you today.
AshPhoenix.Plug.CheckCodegenStatus
Now when there are files pending code generation, you’re presented with a button to generate code and run migrations. Super nice DX improvement. This is set up for all newly generated projects. TO set it up for your existing project place `plug AshPhoenix.Plug.CheckCodegenStatus` just after `plug Phoenix.CodeReloader` in your endpoint.
Here it is in action!
--dev migrations
This powers the plug shown above! Ash’s migration generator is very convenient, but it does come with its own set of challenges. One interesting one is that often, while developing, we want to just make some migrations and not worry about naming them, or how “good” or “right” they are. We’re just going to throw them away and consolidate a nice migration at the end. This working pattern has now been codified with the `--dev` option, which tells us to just give it an auto incrementing name. Then later, you can run `mix ash.codegen finish_some_feature` and we’ll delete those dev migrations, roll them back in your local database, and create one new migration with all the changes for your feature.
IMPORTANT: You should make sure that you have `mix ash.codegen --check` in your CI pipeline to ensure you don’t commit any dev migrations.
Ash.Scope
Ash.Scope is inspired (very directly) from Phoenix’s introduction of `MyApp.Scope`. It is a protocol to take a module containing, actor, tenant, context etc. and providing it all at once to Ash actions. Read the docs for more.
Shared Action Context
A common request has been a way to set some piece of context (context is a freeform map on `Ash.Changeset`, `Ash.Query`, and `Ash.ActionInput`) in a way that will be automatically provided to “nested” action calls. You can now do this by setting context into the `shared` key. This is added to the current query, and retained for nested action calls. Read the docs for more.
usage-rules.md
UsageRules is a development tool for Elixir projects that helps gather and consolidate usage rules from dependencies. The package provides Mix tasks to collect documentation from dependencies that have usage-rules.md
files and combine them into a single rules file for your project.
Folks often have trouble pairing Elixir & Ash with LLMs. usage-rules.md is the answer to this! Now, you can get the rules from your packages into your own rules file. We’ve seen this make a *massive* impact on the performance of LLM agents.
If you’re on the latest version of your Ash packages, try it out!
ash_ai.gen.chat improvements
The original version of `ash_ai.gen.chat` did not store tool calls and their results. This means your agents have a sort of “amnesia” about why they did what they did, and what the results were. Now, we store these tool calls and their results, and keep them in the agent’s chat history. You’ll find this to be *significantly* more useful and to make a much more compelling demo. Remember, `ash_ai.gen.chat` is just a starting point/demo, you’re meant to build on it, or build your own. We’ve also made it look much better visually.
Igniter.Scribe
Igniter tasks are really cool, but we often need to make sure that we have manual guides that are kept up to date to align with our installation functions. `Igniter.Scribe` is a suite of tools to help with that, from within your igniter task itself. When you run the task with `—scribe` it will generate a markdown file explaining the changes. The new manual installation guide was generated directly from the igniter task! See the Igniter.Scribe docs for mor
Releases
Ash: 3.5.12-3.5.13
`Ash.Type.String`, `Ash.Type.CiString` and the built in `match` validation all now warn on the use
of regexes. OTP 28 no longer supports building regexes at compile time. You’ll see a warning when using them. Now, you provide the regex as a `”string”` or as a tuple in the form of `{“string”, “flags”}`.
Introduced `Ash.Scope`, see above for more.
Introduced `:shared` context, see above for more.
Added `precision` and `scale` constraints to the `:decimal` type.
Added `Ash.Error.Framework.PendingCodegen` error, used for the new `AshPhoenix.Plug.CheckCodegenStatus`
Support upsert & upsert_identity options in `Ash.Generator.changeset_genereator`
Improved `usage-rules.md`
Introduced a builtin `:duration` type, with custom functions & operators to go with it
Support a `debug?: true` option on `manage_relationship`, which prints out additional information about what is created/updated/destroyed
Added a `strict_load` option to `Ash.Query.build`, which loads the provided statement with `strict?: true` set.
Reactor: 0.15.3-0.15.4
Add support for recursive sub-reactors
Add usage-rules.md
AshAi: 0.1.2-0.1.10
Overhaul `ash_ai.gen.chat` visually
Store tool calls in `ash_ai.gen.chat`
Allow configuring the dev MCP path
Add usage-rules.md for AshAi itself
Igniter: 0.5.52-0.6.4
Introduce `Igniter.Scribe` and `--scribe` option.
Track the task name and parent as keys in the igniter
Add `quite_on_no_changes?` assign
Add usage-rules.md
Added `igniter.init_library` for setupp
Spark: 2.2.57-2.2.62
Add `:number` type that allows integers or floats
Make compiled DSL modules (resources, domains etc.) much smaller via under-the-hood optimizations
AshGraphql: 1.7.11-1.7.13
Add various additional fields to pagination metadata
Support new codegen tooling from ash upgrade
AshJsonApi: 1.4.32-1.4.33
Add support for serializing decimals
AshAuthentication: 4.8.7-4.9.0
Add a builtin Argon2 password hashing strategy
Improve validation of the results of secret module callbacks
handle more formats of params in magic link token endpoints
AshPostgres: 2.5.20-2.6.0
Support the new --dev flag for codegen
Support the new scale & precision consstraints for decimal types
AshSqlite: 0.2.7-0.2.9
Support strict tables DSL option
Support the new --dev flag for codegen
AshOban: 0.4.7-0.4.8
Add `on_error_fails_job?` option for triggers
Add usage-rules.md
AshPhoenix: 2.3.2-2.3.3
Support `Ash.Scope` in forms
Add `AshPhoenix.Plug.CheckCodegenStatus`
add usage-rules.md
Good stuff!
Amazing! Thank you!