Caching & Lockfiles
Compiling with AI is improving in speed, but it is still orders of magnitude slower than traditional compilation. To mitigate this and ensure build stability, Intend implements an aggressive caching strategy using the intend.lock file.
How it Works
The lockfile system does not care about file names or modification dates. It cares about content and configuration.
1. Hash Computation
When intend build runs, for every .intent file:
- File Content Hash: A SHA-256 hash of the
.intentsource code. - Configuration Hash: A hash of the project's generator settings (Provider, Model, Temperature).
- Dependencies: If an intent imports other intents, their contracts are included in the source context, ensuring that changes in upstream intents trigger downstream updates if necessary.
2. Lockfile Lookup
The compiler checks the project root's intend.lock file for an entry matching the relative path of the .intent file.
- Hit: If both the
sourceHashandconfigHashmatch, the stored TypeScript code is returned immediately. Time: ~1ms. - Miss: If the hashes differ or no entry exists, the AI generation pipeline is triggered.
3. Storage
On a successful build (after passing all validation loops), the result is written to the lockfile:
json
{
"src/intents/user.intent": {
"sourceHash": "a1b2c3...",
"configHash": "f5e6d7...",
"generatedCode": "export async function ...",
"model": "gemini-2.0-flash",
"provider": "gemini",
"timestamp": 1700000000000
}
}Benefits
- Determinism: By storing the actual generated code, we ensure that a build on your machine is identical to a build in CI or on a teammate's machine.
- Instant Rebuilds: Building unchanged files takes practically zero time and costs zero tokens.
- Auditability: Because
intend.lockis a text file, you can see changes to the AI's implementation in your Git history.