Patch mode & AI
The agent can patch your files in two ways: AST-based (syntax-aware, deterministic) or AI-based (LLM rewrites whole files). By default it uses hybrid mode.
Modes
| Mode | Flag | Description |
|---|---|---|
| hybrid | --patch-mode hybrid (default) | Try AST patching first; fall back to AI if needed and configured |
| ast | --patch-mode ast | AST-only. No LLM, no API key. Best when your code layout is standard. |
| ai | --patch-mode ai | AI-first. Send entire files to an LLM for patching. Useful for complex or unusual layouts. |
Example — use AI for everything:
npx @synchronized-studio/cmsassets-agent init --patch-mode ai
When to use AI mode
- AST fails — e.g. non-standard formatting, mixed patterns, or edge cases the parser doesn’t handle.
- Unusual structure — large files, many injection points, or custom patterns.
- Extra safety — you can combine AI patching with AI verification (see below).
AI mode requires:
OPENAI_API_KEYin the environment- Optional dependency
openai(install if you use AI:npm install openai).
AI verification (optional)
After patching, you can run an AI review over the changed files to catch mistakes:
npx @synchronized-studio/cmsassets-agent verify --dir .
With the right profile, the verifier uses an LLM to check that each patched file still makes sense (no broken exports, no unreachable code, correct transformer usage). Useful after apply or when you’ve run the agent in AI mode.
Summary
- Default hybrid is enough for most projects.
- Use
--patch-mode astfor a strict, no-API, deterministic run. - Use
--patch-mode aiwhen AST struggles or you want the model to handle tricky files. - Use
verifyfor an extra AI check after patching.
✦
Need help understanding this?Ask CMS Assets Copilot about features, setup, or integrations.
Ask Copilot →