Migrate to 2.0
The migrate-to-2.0 skill rewrites 1.x Triton.instance code to the 2.0 static API and flags the immediate-vs-buffered publishing gotcha for you to confirm.
The migrate-to-2.0 skill automates the mechanical half of Migrating from Triton 1.x to 2.0: it finds every Triton.instance.* call and rewrites it to the 2.0 static, builder-first API, using the same method mapping the migration guide documents. Where a rename could quietly change behavior, it stops and asks rather than guessing.
This skill is about converting existing logging, not adding new logging. If a class has no logging at all, that's a job for instrument-apex. A typical org runs migrate-to-2.0 first (to clear the 1.x singleton) and instrument-org second (to fill the gaps).
Usage
/pharos:migrate-to-2.0 <path> [--collapse-exceptions] [--collapse-dml] [--deploy]<path>
✅
A .cls/.trigger file, or a directory to sweep.
--collapse-exceptions
While migrating, collapse hand-assembled error logs down to .exception(e). On by default; pass --no-collapse-exceptions to keep them verbatim.
--collapse-dml
Collapse hand-built bulk-DML failure logs to .dmlResults(results).
--deploy
Deploy after you accept the diff.
If you vendor Triton as source
When the Triton*.cls files live in your repository instead of arriving as a package, the library upgrade is part of the change: 2.0 removes Triton.instance, so the library and every caller have to land together. Before rewriting a single caller, the skill has you settle three things:
Re-add org-local enum values. Diff your
TritonTypesagainst the incoming 2.0 one; a wholesale copy drops any values you added, and every reference to them stops compiling. (Org-localCategoryvalues are better retired than preserved — see the note on removed categories in the migration guide.)Sweep the right branch. The sweep is only as complete as its path and its branch, so run it on the branch that holds every caller.
Keep Jest tests out of deploys. Add
**/__tests__/**and**/__mocks__/**to your project's.forceignore. Triton's own repository already ignores them, but a.forceignoreonly governs the project it sits in.
What it rewrites
The skill applies the method mapping call by call:
Drops
.instance— everyTriton.instance.<method>(...)becomes a staticTriton.<method>(...).Moves positional args onto a builder — old positional signatures become
Triton.t.area(...).summary(...)...builder chains.Maps level methods correctly (see the gotcha below).
Collapses hand-set error fields to
.exception(e)and hand-built DML summaries to.dmlResults(...)when the flags allow.Covers every 1.x overload. It lists every distinct
Triton.instance.<member>in scope — including property reads such asTRANSACTION_ID— and matches each by name and argument shape against the mapping table. A call whose exact overload isn't in the table stops the skill; it never guesses a mapping.Sweeps test classes too.
@isTestclasses are migrated as well: 1.x calls in tests won't compile against 2.0 either.Leaves post-processing alone. 2.0 sets no post-processing controls on Apex logs, so the narrower set the 1.x warning, debug, and event methods asked for (stack trace, user info, related objects) isn't restated by default. If you want it back, the skill appends
.postProcessing(...)to those calls and flags each one.Flags ad-hoc taxonomy strings —
.area('InvoiceSync')and the like — suggesting apublic static final Stringconstant per Custom Classifications, and never editing the shippedTritonTypesenums.
The one gotcha it will not guess on
The migration guide's behavioral change is the reason this can't be a blind find-and-replace:
In 1.x, bare methods (
error,warning,debug,event,dmlResult,integrationError, andlog) published immediately;add*methods buffered.In 2.0, all level methods buffer — you opt into immediate publishing with
Triton.logNow(...).
So the mapping sends old bare methods to Triton.logNow(...) and old add* methods to the buffering level methods. But whether a given old bare call relied on immediate publishing is a judgment the skill won't make silently:
It also audits flush coverage as it goes: now that level methods buffer, any path that logs must also flush (end of handler/execute, or a finally). Missing flushes are reported alongside the diff.
Successful DML: check the library, not the call site
1.x addDMLResult and dmlResult logged only when a row failed. The 2.0 mapping — Triton.error(Triton.t.area(area).dmlResults(results)) — keeps that by itself: from Triton 2.0.0, dmlResults(...) emits nothing when every row succeeded, or the list is null or empty, whichever method it's passed to. So the rewrite is correct as written, with or without a failure check around the call.
What the skill verifies is the library you're migrating to. A copy of the 2.0 source vendored before 2.0.0 has no such skip, and there the same rewrite would log an empty ERROR record — and open an issue — on every successful DML. The skill checks the vendored TritonBuilder.cls for an isSuppressed() method; if it's missing, it has you upgrade the library in the same change rather than adding guards at each call site.
Example rewrite
Review and deploy
Before it shows you anything, the skill runs two checks a reviewer reading a diff would miss:
No 1.x member survives — no
Triton.instanceleft in scope, and no half-migrated static call to a method 2.0 doesn't have (Triton.addError(...)and friends).Every enum reference resolves — each
TritonTypes.<enum>.<value>exists in the 2.0TritonTypes. This catches removed values such asTritonTypes.Category.Event, and org-local values a re-vendored library dropped.
Re-run the first check right before merge, not just at sweep time: a 1.x caller merged in the meantime leaves the branch uncompilable. The setup-standards CI check that fails the build on any Triton.instance makes that automatic.
Like every skill here, it then presents a summary — calls migrated, bare-method confirmations pending, the library-version check, collapses applied, flush gaps found, any .attribute(...) fallbacks — then the diff, with yes / modify / skip. On yes it writes back to the original file; with --deploy it runs sf project deploy start.
What it doesn't touch
The skill rewrites Apex only. Check these by hand, using LWC changes to check and the Log_Level__mdt item in the 2.0 upgrade notes:
LWC — removed
CATEGORYkeys (WARNING,DEBUG,EVENT), code that compares area strings, and code that relied onlogNow()rejecting.Flow XML — Log actions that pass a removed category (
Integration,Warning,Event,Debug) or a version-suffixedflowApiName.Log_Level__mdtrules keyed on a removed category, which silently stop matching.
Where to go next
Migrating from Triton 1.x to 2.0 — the conceptual guide this skill automates; read the gotcha section.
Audit Logging Coverage — finds the
Triton.instanceusage to point this skill at.Instrument the Org — add logging where there was none, after migration.
Buffering, Flushing & Deferred Publishing — why the immediate-vs-buffered change matters.
Last updated