NAME

Skilletor::Engine - sync, check and status for Claude Code, Codex and Hermes – the reference's engine pipeline after the resolve

VERSION

version 0.008000

SYNOPSIS

use Skilletor::Engine;

my $engine = Skilletor::Engine->new( home => $ENV{HOME}, project_dir => $project );

my $report = $engine->sync( scope => 'all', force => 0 );   # what `skilletor sync --json` prints
my $check  = $engine->check( scope => 'all' );              # `skilletor check --json`
my $status = $engine->status( scope => 'all' );             # `skilletor status --json`

DESCRIPTION

The reference's engine (engine.ts) after the resolve: sync, check and status for Claude Code, Codex and Hermes. It extends Skilletor::Resolver – a sync runs the very resolve that class reports, then builds every declared item in memory, applies it (Skilletor::Apply), writes the managed blocks (Skilletor::Gitignore) and the project's plugin requirement (Skilletor::ClaudeSettings), runs the briefing check (Skilletor::Briefing) and keeps the records check compares with (Skilletor::State). Most callers want "sync" in Skilletor.

What it writes is the reference's, byte for byte – installed files with their executable bits, the lock, the .gitignore blocks, .worktreeinclude, .claude/settings.json – and the reports are the reference's SyncReport, CheckReport and StatusReport, field for field, booleans as JSON::MaybeXS booleans, every object's keys in the order the reference builds them (hashes from "js_ordered" in Skilletor::JSON), so "report_json" in Skilletor::Report prints the bytes --json prints. The state records (render-inputs.json with the same RENDER_FORMAT, sources-read.json, unreached.json) are the same bytes too, so a check of either implementation accepts what the other synced: the shared conformance cases, t/52-parity-sync.t and t/65-report-json.t hold both to that. Like the reference, a sync holds the sync lock ("with_lock" in Skilletor::State); check and status read without it.

Claude Code, Codex and Hermes

The port installs for Claude Code, Codex and Hermes, as the reference does (spec §14). For Codex: the skills of both scopes in .agents/skills, each agent converted to Codex's TOML (Skilletor::Convert), the rules as sections of one skilletor-rules.md under $CODEX_HOME or the project's .codex, with a pointer block in the scope's AGENTS.md (Skilletor::AgentsMD). The pointer is refused – a warning, nothing written – when that AGENTS.md is a link, malformed, or the very file Claude Code reads as CLAUDE.md; an AGENTS.override.md beside it and a project AGENTS.md over project_doc_max_bytes are warnings. A sync's report carries the run's notes (the items an active harness gets no copy of) and, like status, the run's warnings (Codex has not trusted skilletor's SessionStart hook). The SessionStart hook injects the rules files ("codex_rules_files").

Hermes gets skills only (spec §16), and only while the user config's targets names it – it is never detected. Its user root is the Hermes home's skills ("hermes_home"), its project root the project's .hermes/skills, which gets no managed .gitignore block; in a project where Codex is a target too, Hermes reads the Codex copy in .agents/skills and gets none of its own. The user scope records the Hermes home it synced under in the state dir ("hermes_home" in Skilletor::State): a sync under another home removes the lock's Hermes entries from the old one, with a warning, and installs them anew under the new one, and check counts the move as targetsChanged; once Hermes is no target, a sync removes its entries from the recorded home and drops the record. What Hermes gets no copy of – agents and rules, project skills Codex serves – is a sync's notes. "hermes_opt_in_hint" words how to opt in. Lock entries of a harness neither implementation knows are kept untouched, as the reference keeps them.

Templates

A declared item with a .njk file is rendered as the reference renders it (Skilletor::Render), once per target, with the reference's context: the item's vars (source defaults, bundle vars, the scope's), project (in the project scope), scope, harness, target (the root the copy goes to), host ("host"), user ("user") and item. A template that fails is a warning (template error in skill greet: skills/greet/SKILL.md.njk: …, the reference's) and leaves the item as it is installed, files and lock entry; its source still counts as read. An item whose main template renders to whitespace once its frontmatter is removed does not apply in the scope: it is skipped (renders-empty), what it installed is removed, and its lock entry says why.

Errors

A config error, or no agent harness, is the report's error (the reference's message); nothing is touched. Like the reference, a sync that fails while it writes (Skilletor::Error::Apply, a file system error) throws: what landed is owned by the lock, its entries marked partial, and the scope's records are cleared so check asks for the retry. An unreadable lock throws Skilletor::Error::Lock, a sync lock held too long Skilletor::Error::LockTimeout.

is_git_work_tree

is_git_work_tree => sub { my ( $dir ) = @_; ... }

Does a user-scope root lie inside a git work tree (spec §6.4)? Default: ask git ("is_git_work_tree" in Skilletor::Gitignore). A user root gets a .gitignore block only inside one.

git_tracked

git_tracked => sub { my ( $dir, $paths ) = @_; return [ ...tracked... ] }

Which of the written paths does git track? Default: one git ls-files ("git_tracked" in Skilletor::Gitignore). Each tracked item is a warning with the command that untracks it.

git_remote

git_remote => sub { my ( $project_dir ) = @_; return $url }

The project's origin, a render input of the project scope. Default: ask git.

hermes_home

$HERMES_HOME (spec §16.2), by default from the environment: the Hermes home whose skills is the user scope's Hermes root – the Hermes plugin passes its session's. A leading ~ is the "home" in Skilletor::Resolver. Unset or empty: the home the last user-scope sync recorded, else Hermes' default (~/.hermes; %LOCALAPPDATA%\hermes on Windows), so a run no Hermes started serves the same home as the Hermes session before it.

plugin_root

CLAUDE_PLUGIN_ROOT by default: the running plugin's install, which names skilletor's marketplace for the settings requirement. Unset outside a plugin.

host

host => { name => 'box', os => 'linux' }

The render context's host. Default: the machine's host name and its OS as Node's process.platform names it (linux, darwin, win32, …).

user

user => { name => 'me', home => $home }

The render context's user. Default: the login name of the effective user, as Node's os.userInfo() finds it, and "home" in Skilletor::Resolver. A user without a passwd entry fails every item's build with Node's message, as the reference's does.

sync

my $report = $engine->sync( scope => 'user' | 'project' | 'all', force => 0 );

{
  scopes => [ {
    scope => 'user',
    added => [ { key, type, name, source } ], updated => [...], removed => [...],
    unchanged => [...], skipped => [...],
    conflicts => [ { path, replace?, notFile? } ], overwritten => [ { path } ],
    warnings => [...], trustRequests => [ { name, kind, url } ],
    gitignoreUpdated? => [ '.claude/.gitignore', '.worktreeinclude' ],
    settingsSkipped?  => [...],
    settingsUpdated?  => { path, enabled => [...], declared => [...] },
    briefingMissing?  => [ { key, harness, missing => [...] } ],
  } ],
  warnings? => [...],     # the run's: Codex has not trusted the SessionStart hook
  notes?    => [...],     # what an active harness got no copy of (spec §16.3)
  error? => $message,
}

force adopts a file in an item's way, deletes one at a claimed path or replaces a link (spec §6.3). "report_text" in Skilletor::Report words the report as the CLI does, "report_hook" in Skilletor::Report as the hooks do. The sync honours "fetch" in Skilletor::Resolver: never syncs from the cache alone.

The options the reference's hooks set (spec §8):

  • if_changed => 1: once the sync lock is held, a "check" with local decides – nothing changed (and no error): nothing runs and the report is { scopes => [] }. A run that waited out another's sync of the same change finds nothing left.

  • deadline => $epoch_ms: a scope whose sources are resolved only after it does not reach its apply; the sync dies with sync stopped before applying the <scope> scope: its sources took too long, the scope's records are dropped as after any sync that stopped, and any earlier scope that completed remains in place.

  • lock_timeout_ms => $ms: how long this call waits for the sync lock, over "lock_timeout_ms" in Skilletor::Resolver.

check

my $check = $engine->check( scope => 'all', local => 0 );
# { changed, sources => [ { name, scope, changed } ], warnings,
#   targetsChanged?, layoutChanged?, declaredChanged?, varsChanged?, trustRequests?, error? }

Whether a sync is due, without one: source versions (git ls-remote, an HTTP HEAD; a local source always counts as changed), the drift of the lock against the config and the layout, the render inputs. It reads no installed file – an edited file is a sync's to overwrite, not drift. With local no source is asked (no fetch, no ls-remote, no request; sources stays empty): the lock against the config, the layout and the render inputs alone. Untrusted sources are named either way.

status

my $status = $engine->status( scope => 'all' );
# { scopes => [ { scope, targets, declared => [ { key, source, installed, via?, skipped?,
#   partial?, briefingMissing? } ], orphans, wildcards, bundles, trustRequests,
#   sourceVersions } ], projectIsHome?, warnings?, error? }

Offline and read-only: the lock and the config.

codex_rules_files

my @files = $engine->codex_rules_files;

The Codex rules files the SessionStart hook injects (spec §14.8): the user scope's, then the project's, each when it exists and Codex is a target of that scope. When the config or the targets cannot be loaded, every existing file (the last good state). Reads no source and never throws.

hermes_opt_in_hint

my $line = $engine->hermes_opt_in_hint;
# Hermes gets no skills: "hermes" is not in "targets"; to opt in, set
# "targets": ["claude", "hermes"] in ~/.claude/skilletor.json

For a run Hermes started (spec §16.4): while hermes is no machine target, the line that says how to opt in, naming the targets in use plus hermes. Undef when Hermes is a target, or when the config or the targets cannot be read (that error is reported on its own). Never throws.

RENDER_FORMAT

The render format hashed into the render inputs (the reference's, 2).

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/skilletor/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)