#Captain's Log

#Install

composer require 4rn0/statamic-captains-log

Nothing to publish. Captain's Log is active as soon as Statamic's Git integration is.

#Settings

Control panel > Tools > Utilities > Captain's Log. Users need the "Captain's Log" utility permission.

Setting Meaning
Enabled Off: Statamic's own messages and escaping.
Mode Rules, or AI with rules as fallback.
Provider, model Leave the model empty for the provider's cheapest text model.
Style instructions Passed to the model, for example "Use Conventional Commits".

Settings are saved in resources/addons/captains-log.yaml, so they travel with your repository.

In AI mode the page says whether AI is really in use: active, no API key for the provider, or a sync queue. Next to that it says how the last attempt went: when the last summary was written, or the error the provider gave. The provider, model and style instructions are only shown in AI mode; they are kept when you switch back to rules.

When changes are waiting for a commit, the page shows under "Next commit" what the rules make of them. That is the case with a dispatch_delay, a scheduled commit or commits by hand; a site that commits right after every save never has anything waiting. The author is left out, and in AI mode the provider still rewrites the message when the commit runs in the queue or on the command line. The Commit button of Statamic's Git utility always uses the rules, so there the commit gets exactly this message.

#Language

There is no setting for it. Messages use statamic.git.locale (STATAMIC_GIT_LOCALE), the language Statamic uses for its own commit messages, and otherwise that of the default site. Rule-based messages are translated into English and Dutch; other locales get English. In AI mode the model writes in that locale.

For another language in the CP, publish the language files and add your own next to en and nl:

php artisan vendor:publish --tag=captainslog-lang

#API keys

Keys live in .env, never in the settings:

ANTHROPIC_API_KEY=
OPENAI_API_KEY=
GEMINI_API_KEY=
MISTRAL_API_KEY=
GROQ_API_KEY=
DEEPSEEK_API_KEY=
XAI_API_KEY=
COHERE_API_KEY=
OPENROUTER_API_KEY=
AZURE_OPENAI_API_KEY=

Azure also needs AZURE_OPENAI_URL and AZURE_OPENAI_DEPLOYMENT. Bedrock uses your AWS credentials (AWS_BEARER_TOKEN_BEDROCK, or the access key and AWS_BEDROCK_REGION), an OpenAI-compatible endpoint needs OPENAI_COMPATIBLE_URL and Ollama needs no key; for those three the settings page cannot tell whether they are set up. These are the variables of laravel/ai; publish its config only if you need more.

#How it works

Every content event is recorded in the cache. When Statamic commits, the records become the message and are cleared.

Clearing the cache while changes are waiting for a commit, with php artisan cache:clear in a deploy script for instance, removes those records. Nothing breaks: that commit gets Statamic's own message, or names only what was saved after the clear.

  • The subject is at most 72 characters: titles are replaced by counts when they do not fit. The list below it stops after 50 changes ("... and 12 more").
  • An update of an entry or an asset names the handles of the fields that changed: Update "Crew" (pages): rank, bio. In a batch they are in the list, not in the subject; for a single change they are left out when the subject would pass 72 characters. A changed slug or date counts as a field.
  • An entry that went from draft to published, or back, gets Publish or Unpublish instead of Update. An asset gets Rename "beach.jpg" to "sea.jpg" (photos) or Move "sea.jpg" to "2027" (photos). What counts is the difference with how things were before the first save of the batch: unpublished and published again is an update.
  • The author is only added to the subject ("- by Kim") when Git does not already commit as that user: with use_authenticated off, or for a commit from the command line.
  • A revision is only mentioned when nothing else changed: publishing an entry saves one along with it.
  • An updated user is only mentioned when nothing else changed: the control panel saves the user file for every changed preference. Added and deleted users are always mentioned.
  • Without records (a manual commit after changes made outside Statamic) Statamic's message is kept.
  • AI is used only in Statamic's queued commit job or on the command line, with a 10 second timeout per request. A rate limited or overloaded provider may be retried once by laravel/ai. The commit button in the control panel always uses rules, and so does a save with the sync queue.
  • The records are cleared after every commit attempt. When Git itself refuses (a lock file, a hook), the next commit takes those files along and only describes what changed since.
  • When only form submissions, users or addon settings changed there is nothing to summarise: no call, rule-based message.
  • The AI subject has no author name; Git already records the author.
  • Changes from events listed in statamic.git.ignored_events are still described by the next commit that includes them.

#Without a queue worker

Set the queue connection for Git only:

STATAMIC_GIT_QUEUE_CONNECTION=deferred

The commit then runs after the response is sent, so the editor does not wait. That needs PHP-FPM or LiteSpeed; on other setups (Apache with mod_php) the save may stay open until the model has answered. A PHP process stays busy during the call. dispatch_delay does not apply.

Or turn off automatic commits (STATAMIC_GIT_AUTOMATIC=false) and schedule the commit. On the command line AI is used whatever the queue:

Schedule::command('statamic:git:commit')->everyTenMinutes();

Keep in mind that a command that saves content with the sync queue and automatic commits on (an import) then asks the provider for every save.

#Custom commit commands

Titles are written by editors and end up in a shell command. Captain's Log therefore only replaces the message when every {{ message }} in statamic.git.commands stands inside double quotes, as in the default:

'{{ git }} -c "user.name={{ name }}" -c "user.email={{ email }}" commit -m "{{ message }}"',

Text of your own may share the quotes, such as the [BOT] prefix Statamic suggests to keep a pushed commit from deploying again:

'{{ git }} -c "user.name={{ name }}" -c "user.email={{ email }}" commit -m "[BOT] {{ message }}"',

Anything else (single quotes, no quotes, a backslash, $ or backtick inside the same quotes, a modifier on the tag, Windows) keeps Statamic's message and logs a warning.

#When something is off

Problems never block a commit. Look for "Captain's Log" warnings in storage/logs.

The queue worker has to be restarted after changing .env (php artisan queue:restart).