Accelerators
Accelerators are Cohesive Code’s adjustment workflow. They let a process propose an artifact, attach instructions, and avoid overwriting a file once it has been changed.
ctx.accelerate(id, templatePath, data, instructionsPath?);The runtime:
- Uses the active scope.
- Renders
templatePathrelative toccode_path. - Writes or updates accelerator state.
- Targets
output_path/<id>. - Writes the target only when it is safe.
Safe-write behavior
Section titled “Safe-write behavior”If the target file does not exist, Cohesive Code writes it.
If the target file exists and still matches the last generated snapshot, Cohesive Code may overwrite it with the new rendered content.
If the target file exists and differs from the last generated snapshot, Cohesive Code leaves it alone. This is what protects human and agent adjustments.
State path
Section titled “State path”Accelerator state is stored at:
<hidden_path>/accelerators/<scope>/<artifact-id>.accelerated.jsonThe default scope is the process file name without .ts. Override it with:
ctx.setScope("generate-api");Instructions
Section titled “Instructions”An optional instructions file can be attached to an artifact:
ctx.accelerate( "handlers.go", "templates/handlers.tpl", model, "instructions/handlers.md",);Instruction paths are normalized under ccode_path.
Inspecting work
Section titled “Inspecting work”ccode list acceleratedccode list accelerated generate-apiccode get accelerated generate-api:handlers.goccode get accelerated generate-api:handlers.go --instructionsUse --for-agent for JSON output.
Cleanup behavior
Section titled “Cleanup behavior”After a successful ccode run, the runner removes accelerator state files in scopes used by that run when those states were not produced during the run. This prevents old unresolved state from lingering after a process stops emitting an artifact.