workflow.ts), and workflow.yaml still runs by being translated into the same TypeScript. Each entry lists what you need to change in a workflow.ts.
2.0.0 is the first stable release. From 2.0.0 on, Codemod API stability says what can change between 2.x releases. The entries below it are the 2.0 prereleases, kept for anyone updating a workflow written against one.
Codemod 2.0 is published on npm under the To turn a
next tag, and latest is still 1.x. Run it with npx codemod@next, or pin a version:workflow.yaml package into workflow.ts, run npx codemod@next workflow upgrade ./my-package --dry-run. See Migrate from workflow.yaml.-
astGrepmoved tocodemod/ast-grep, next toparse. Importing it fromcodemod/workflow(also under another name, or re-exported) is a build error that names the new module. What it does is unchanged:forEachFile(selector, astGrep(rules))takes the same rules and options, and runs and resumes as before.codemod workflow upgradewrites the new import, andworkflow.yamlpackages run as before. -
astGrep(...)takes a reducer.forEachFile(selector, astGrep(rules), reducer, initial)was a build and type error; it now folds each file’s counts in path order and returnsreduced. TheAstGrepTakesNoReducertype is gone, andAstGrepHandlertakes a type parameter (AstGrepHandler<true>with findings). -
jssgTransformwas removed from workflows. Importing it in aworkflow.tsis a build error, and calling it from a function step,dependencyGraphcallback,forEachFilecallback or the body throws before it changes anything. Before, function steps anddependencyGraphcallbacks could change files with it. Change each file from its ownforEachFilecallback, or create files withcodemod/files. It is no longer declared oncodemod/ast-grepor part of the stable API.1.x jssg transforms keep calling it, from their originalcodemod:ast-greporcodemod/ast-grepimports: undercodemod jssg run, inworkflow.yamljs-ast-grepsteps, and in transforms an upgraded workflow runs withjssgFile. Its declaration moved tocodemod/compat; a standalone transform that calls it adds"codemod/compat"tocompilerOptions.types. -
Upgraded workflows import
jssgFileandjssgWouldChangefromcodemod/compat.codemod workflow upgradewrites the adapter only for transforms a plain callback cannot call, and now imports it fromcodemod/compat, a migration-only subpath of thecodemodpackage, with types. Workflows upgraded by earlier alphas importcodemod-internal:jssg-compat, which still works the same, without types:See 1.x compatibility APIs for where each works. -
agentandcodemod/assessmoved tocodemod/ai, andassessis nowask.agent,askand the question builders (yesNo,choice,number,list) come from one experimental module,codemod/ai. The option and result types moved with them:AskOptions,AskContext,AskResultandAskUsage(wereAssessOptions,AssessContext,AssessmentandAssessedUsage), andAgentOptions,AgentResult,CodingAgent. There are no aliases: importingagentfromcodemod/workflow, anything fromcodemod/assess, orassessfromcodemod/aiis a build error that says where it went. What they do is unchanged: steps, results (includingassessedusage) and resume are the same, and--format jsonlevents keep their shape; their experimental notices namecodemod/ai.agentandcodemod/ai.ask.codemod workflow upgradewrites the new import foraisteps.--allow-aiand the key check now apply only when the workflow (or a local file it imports) may callask. A workflow that imports onlyagentor the question builders runs without them. See Before files are sent. -
installSkillwas removed fromworkflow.ts. Importing it fromcodemod/workflowis a build error. A package’s skill is installed by aninstall-skillstep in aworkflow.yaml, which keeps running as before:codemod init --skillwrites aworkflow.yamlnow, andcodemod workflow upgradestops with an error, changing nothing, when a workflow has aninstall-skillstep. Aworkflow.tsthat calledinstallSkill, written by hand or by an earlierupgrade, goes back toworkflow.yaml:Pointworkflow.yamlworkflowincodemod.yamlat it, or list it as a second entry underworkflowsnext to yourworkflow.ts. See Package skills. -
Node.js built-in modules a workflow can’t use are a build error. Workflow code gets the pure built-ins; steps and callbacks also get
crypto,os,perf_hooks,tty,moduleandconsole. Importing any othernode:module (node:http,node:https,node:net,node:worker_threads,node:stream, …) fails the build with a hint pointing athttp(),sleep()orshell(). Before, the build allowed some of them in steps and callbacks while the CLI failed to load them, andcodemod/testingon Node.js let them run, so a workflow could pass its tests and fail in the CLI. On Node.js,import()of one fails the same way. - A plain terminal asks manual approvals as the launcher does: Decide later (the default), Approve or Reject. Before, “No” meant “decide later” in a terminal and “reject” in the launcher.
-
DECISION_API_KEY,DECISION_BASE_URL,DECISION_PATHandDECISION_AUTH_HEADERwithoutDECISION_PROVIDERbelong only to the provider you chose (--model, your saved model, or System One), never to one a package’scodemod.yamlor anask()call picks. Before, a key you set for one provider was sent to whichever provider a package named. Set the provider’s own key variable (OPENAI_API_KEY, …) orDECISION_PROVIDERto use another one. The consent question names the key variable that is sent.
astGrepresults count per rule, and per file on request.matchesByRulegives each rule that matched or fixed something its totals:{ [ruleId]: { matched, fixed } }. WithastGrep(rules, { byFile: true }),matchesByFilealso lists, in path order, each file a rule matched or fixed:{ path, rules: { [ruleId]: { matched, fixed } } }. Per-file counts are opt-in so a large target doesn’t record an entry per file; a reducer still gets each file’s counts.matchedis the first pass’s matches,fixedthe fixes applied over every pass that changed the file (planned, in a dry run).matches,changesandfailuresare unchanged. Two rules with the sameidare refused, and rules withseverity: offdon’t run. Results of steps recorded before this replay as they were recorded, without these fields: a resumed run should check for them (or start a new run). See Counts per file and rule.astGrep(rules, { findings: true })lists the matches asfindings.records: path, rule, pass, language, byte range, and whether each was fixed, detected (no fix) or skipped (reason: "overlapping-edit"). At most 1000 records, with the rest counted inomitted. See Findings.- Secret parameters. Mark a parameter
@secretinworkflow.ts(secret: trueinworkflow.yaml) and the run stores[redacted:param.<name>]in its place: in run and step records, events (--format jsonl, the journal), approval questions and the report. Values of credential-like environment variables,http()credential headers, recordedset-cookieand an agent’sapiKeyare left out the same way. The workflow still gets the real values.workflow resumeneeds a secret parameter again (--param <name>=...) and refuses, saying which, when it is missing. A resume fills in only values the run recorded replacing (text that looks like a marker stays text), and refuses rather than guess or run a finished step again. See Secret parameters. dependencies()fromcodemod/deps(experimental), inside a step: the repository’s packages, declarations and catalogs read frompackage.json,pnpm-workspace.yamland.yarnrc.yml, with no lockfile needed;bump,add,removeandrenameedit the manifests as the step’s file changes (shown, not written, in a dry run);installed,chains,dependentsandneedsInstallread the lockfiles only when first asked.dependencyGraphis unchanged.semveralso hasgte,lte,minVersion,major,coerce,maxSatisfyingandvalidRange. See Dependencies.
- Registry downloads whose size or SHA-256 doesn’t match what the registry advertises are refused before anything is extracted or cached. Before, the CDN’s gzip encoding was decoded before the check, so the mismatch was only logged. Packages cached by earlier versions are downloaded again once.
- The local report server (
--report) needs a per-server token, sent by the page it opens, on every API request, and only accepts a loopbackHostand the page’s ownOrigin. The URL printed in the terminal no longer includes the token unless the browser could not be opened. - Run failure telemetry sends an error category and step kind instead of the error text.
ask()fromcodemod/aiis checked where each call actually sends files. Before, the run asked (or required--allow-aiand a key) before step 1, naming the default provider, while a call naming another provider or model sent files there without asking. Now the first call that runs asks, naming the provider, host and model it resolves to, and each other destination is asked about again; an unattended run fails at that call, before anything is sent, naming the destination and--allow-aior the key. A workflow whoseask()a parameter turns off needs neither. See Before files are sent.- Semantic analysis is rooted in the target. A
semanticAnalysis.rootthat resolves outside it (.., or a link out of it) fails the step, anddefinition()andreferences()never return a file outside the target, including one reached through a symbolic link inside it. The JavaScript provider may still read files that imports resolve to outside the target while it indexes. - On Windows, a tagged
shell\…`template with$substitutions fails before it runs. Its values are quoted for a POSIX shell, and Windows commands run in cmd, which reads that quoting differently. A plain string,shell(command)`, still runs as written. See Shell commands. - A nested
codemod(...)step’s parameters are never recorded in plain text: its record keeps a keyed hash of them. The child’s@secretparameters belong to its step, so resuming the parent doesn’t ask for them, and the child gets them back when it runs again. codemod workflow upgradeplans every file it writes before it writes any, and refuses conflicts, naming the files: two workflows that would become one file (build.yamlandbuild.ymlboth becomebuild.ts), or a support file such as__codemod_v1/metrics.tsthat is already in the package. A directory of packages is checked as a whole first.- The transforms of a workflow
codemod workflow upgradewrote keep 1.xfs, as in aworkflow.yamlrun: reads inside the target,writeFileSync/writeFilecreating or overwriting a file, andunlinkSync/unlinkdeleting one, all shown in the step’s diff. Before, a transform importingfs, directly or through a helper library, failed every file once upgraded, and an overwrite or delete failed even in aworkflow.yamlrun.upgraderefuses a package whose transform importschild_process; it stays onworkflow.yaml. Workflows you write keep refusingfs. The upgraded header is recognised anywhere in the leading comments, so adding a license comment above it keepsfsworking. codemod workflow upgradeloads each transform the newworkflow.tsimports before writing anything. A package whose transform would not load in 2.0 stays onworkflow.yaml, with the transform and the import that stopped it named, and the command exits with code2.--dry-runreports the same.- A step whose changes move or create two files at paths that differ only by letter case, or one next to a file spelled with another case, is refused on every OS before anything is written. On macOS and Windows those paths are one file, so the second overwrote the first.
- A bare
npx codemod@next, with no command, runs 2.0 instead of re-running ascodemod@latest, which is 1.x. - On Windows, a run that finds its target busy names the run holding it, and a killed run’s lock is taken over instead of blocking every later run.
- A step that awaits a promise nothing settles stops at its
timeout, atworkflow cancel, or at Ctrl-C and SIGTERM. Before, onlykill -9stopped it. This covers function steps,forEachFilecallbacks, reducers and shard functions. - An environment variable whose name or value isn’t UTF-8 no longer crashes
codemod workflow runandresume. - A secret on several lines, such as a private key, no longer reaches
--format jsonlstep logs or the journal: each line of 8 characters or more is replaced ([redacted:param.key#2]). A failing command’s error and cut-off output no longer keep part of a secret. workflow resumereads values recorded from any environment variable back from it, so anhttp()header from{ env: "GH_PAT" }, or a short credential-named variable, no longer blocks the resume. Values that aren’t kept (http()header text,set-cookie, an agent’sapiKey) are replaced only at 8 characters or more, sox-api-key: "test"no longer redacts a laternpm testor blocks a resume.workflow status,workflow list,run_finishedand run reports show text that looks like a marker as the run produced it, not as[redacted!:...].@secretis found on inline parameter types ({ params: { ... } },WorkflowContext<{ ... }>) and on types imported from relative files. A@secrettag codemod can’t tie to a parameter stops the run before it starts instead of storing the value.ask()works in a nested codemod whose parent doesn’t import it, and its calls use the child package’sdecision_model. The launcher asks on its run screen whetherask()may send files.DECISION_MAX_CALLScaps the decision-model requests of a run. The launcher’s model list sends only the chosen provider’s key.- The built-in agent stops at
timeoutSecondsand on cancel, with the shell commands it started. dependencies():rename()onto a name the package already declares keeps one declaration;needsInstall()sees catalog bumps; YAML catalog anchors and aliases are read and kept on edit;bumpandaddleavefile:,link:, git and URL ranges alone (skippedreason"protocol");bump,removeandrenameupdate matchingoverrides,resolutions,pnpm.overridesand pnpm-workspace.yamloverrides, listing those they can’t safely edit inskipped; within, a catalog entry other packages share is left ("catalog"); apackage.jsonwith a byte order mark is read, anddependencies().unreadablelists manifests that can’t be.dependencyGraphreads pnpm lockfile 5.x keys, keeps every range of a requirement split by environment markers (uv.lock, pyproject), and reads Poetry’s space-separated clauses (>=1.2 <2.0) and single|.semver.compareand registry release sorting no longer panic on versions they can’t read; those sort last.--control stdioreports a line that isn’t UTF-8 as acontrol_errorand keeps reading, instead of pausing the run. An open approval in the launcher or a terminal closes when the run is canceled from another terminal, and a cancel sent while a resume asks about an interrupted step is kept when you pick “Decide later”.- Dry runs process, collect and fold files in the same path order as real runs (
a/xbeforea-b/x), on both hosts. A built-inshardwithoutfilesorfilterreads only the start of each file. codemod workflow upgradechanges files whose paths contain glob characters ([,{,*, …), and changes nothing when a planned file can’t be selected. Upgraded callbacks always handle{ edit, data }results, including ones built in a helper file. A symlinked transform is reported as a link.workflow runno longer suggests upgrading after a failed run, and the--v1hint also shows for 1.xfsrefusals.codemod run --v1(andCODEMOD_V1=on) refuses to run a registry package unattended without--approve, and checks the cached 1.18.7 binary’s hash before each run, downloading it again when it doesn’t match.- Search, login, OIDC, report-upload and managed-update requests send the
codemod-cli/<version>User-Agent. - The run summary counts unmodified files again for
forEachFilesteps,workflow.yamljs-ast-grepsteps included: 2.0 printedUnmodified 0(and a dry runUnchanged 0 files) after every run. - A selected file that isn’t UTF-8 text is named in the step’s log (
left out 1 file that is not UTF-8 text: ...). Before, it was left out without a word. codemod run --format jsonlwrites its “Resolving package” and “Running codemod” lines to stderr, so every line on stdout is an event.- The note that codemod.yaml asks for
fsis no longer shown forworkflow.yamlpackages or workflowsupgradewrote, whose transforms keep 1.x’s target-localfs. - On Windows, a 1.x transform that overwrites or deletes a file with
fsand reads it again in the same step sees its own change. workflow resumewaits up to two seconds for a run’s locks when it finds the run busy just after another process let go of it.- The telemetry notice isn’t shown when telemetry is off. Failure telemetry sends a category instead of error text, and runs of local packages and
jssg testsend “local package” or “local file” instead of a path.
-
fsin callbacks is replaced bycodemod/files. A callback that importsfsornode:fsfails withfs is not available in 2.0 workflows. Before, callbacks could read the target through a read-onlyfs.codemod/filesreads, lists and creates target files; new files are recorded and appear in the diff with the step’s other edits. YAML packages keep their supported target-localfscalls. -
Unattended registry packages need
--approvefor side effects. Before, an unattended run of a registry package ran itsshell(),agent(),http()and pull request steps with no flag. Now those steps fail, naming the step and the flag, until you approve them. A workflow file or directory you run yourself (workflow run -w,codemod run ./dir) stays trusted, so its steps run unattended. -
A resume asks before repeating an interrupted side effect. If a shell, agent, git, pull request, HTTP or nested codemod step was running when the process stopped, it shows as
started, and resume does not run it silently. In a terminal, choose Rerun or Skip. Unattended, the run exits3and names the step and both flags.--approvedoes not make this choice. - JSSG transform load and parse errors count as failures. A transform that fails to load or parse fails the step. Target files with syntax errors still get transformed with error recovery; Codemod logs their count without failing the step.
-
Callbacks get an empty
process.env. They can still useprocess.cwd(),process.argv,process.platformandprocess.arch. Pass values as parameters, or give ashell()step{ env }.
- Experimental APIs are labeled. Look for
@experimentalin declarations, an Experimental marker in the docs or CLI help, and a notice on first use. - Telemetry has a one-time interactive notice. Use
codemod telemetry on|off|statusto manage your saved setting. - Registry commands support JSON output. Use
--format jsonwithlogin,whoami, orpublish. In CI, uselogin --api-keyinstead of browser login.
- Step records are appended and synced to disk, and alpha.10 runs can still be read.
- New run-store files are private.
- Registry downloads get more checks: the advertised size and sha256 are compared, only regular files and directories are extracted, the registry token is no longer sent to the download URL, and stored credentials are bound to their registry.
- Registry checksum mismatches are logged, not rejected. The advertised size and sha256 are compared, but packages from the production registry fail that comparison, so the check is not enforced yet.
Breaking changes
-
A run waiting for an approval exits
3. Before,workflow run --no-interactive(andworkflow resume,codemod <package>) exited0when the run stopped at an approval, so a CI job passed with the migration half done. Now it exits3, apart from1(failed) and2(failed files,fail()), and ends with the command that continues it. See exit codes. -
Callbacks are pure. Function steps,
forEachFilecallbacks and reducers,dependencyGraphcallbacks andshard’s functions no longer getfetch,child_process,fswrites,process.envchanges or timers, whatever the run grants. Each fails with the step to use instead. They read the target through a read-onlyfswithout any flag.fetchand timers written in a workflow file are build errors. See Callbacks are pure. -
--allow-fs,--allow-fetchand--allow-child-processdo nothing for workflow runs. They are accepted with a warning;capabilitiesincodemod.yamland in aforEachFileselector are ignored (the step’s log says so). The launcher no longer shows capability toggles. -
codemod jssg runandcodemod jssg test:fswrites need--allow-fs. Without it a transform’sfsreads the target butwriteFileSync,mkdirSyncandunlinkSyncfail withEROFSand a message naming the flag, aschild_processneeds--allow-child-process. Before, writes inside the target worked with no flag. See Security & Capabilities. -
The Node.js host enforces the same rules (
codemod/host,codemod/testing), and replays the body’s clock and random numbers as the CLI does, so a test that passes does not fail under the CLI. See the Node.js host. -
Declared
stringparams stay strings.--param version=19gives"19"for a parameter declaredstring; earlier alphas parsed it as19. -
YAML with
runtime: dockerorruntime: podmanis refused before any steps run. Earlier alphas silently ran those steps on the host. -
The experimental launcher is opt-in (
CODEMOD_LAUNCHER=1). Plain terminal output is the default.CI=1never prompts, even with a terminal.
-
Runs record the codemod version.
workflow status --format jsonshowscodemodVersion. Resuming a run another version made, whose finished function steps that version built differently, is refused with the version and the steps, instead of running those steps again silently;--forceruns them again.workflow listshows runs this version cannot read asunreadable (made by codemod <version>)instead of leaving them out. -
One run per repository at a time. Before, two runs on one repository both ran and could write the same files. Now a run (or resume) on a repository another run is executing fails at once, naming that run:
another run (<ID>) is already running on <repo>: wait for it, follow it with codemod workflow attach --id <ID>, or stop it with codemod workflow cancel --id <ID>. The lock lives in the run store and goes with its process, so a killed run does not leave the repository locked. Dry runs do not lock. -
http(url, options)incodemod/workflow: an HTTP request as a step. Its response is recorded and replayed on resume, not sent again. Header values can come from the environment ({ env: "GITHUB_TOKEN" }) so tokens stay out of the run’s records. A dry run skips it unless it setsdryRun: "perform". See HTTP requests. -
workflow inspectlistshttpinuses, and shows which declared steps reach outside the target. -
1.x YAML packages run without conversion. Legacy transform metrics and workflow state still work when running
workflow.yaml, and transforms can read the target withfswithout a flag. The compatibility path never rewrites the package. See Upgrade from 1.x. -
An explicit 1.x fallback.
codemod run --v1 <package>(orCODEMOD_V1=on) uses pinned codemod 1.18.7. It is deprecated and never selected automatically. See Running a package with codemod 1.x. -
workflow upgradeconverts legacy transform metrics and warns aboutfsandchild_processimports without granting capabilities. It refuses transforms that use legacy workflow state rather than generating a workflow that cannot run. -
DO_NOT_TRACK=1turns off telemetry. Useunpublish --yesfor unattended unpublishing.
- A run paused at an approval keeps its question. Before, closing a control channel’s stdin or sending
stopwhile an approval was open left apausedrun withquestion: null, and the approval stepcanceled. Nowrun_finishedandworkflow statuskeepquestion(approval:1) andawaiting, the step staysawaiting-approval, andworkflow resume --approve approval:1gives it. - Local runs identify the package they use, dry runs omit unsaved run IDs, standalone
jssg runreports errors for each failed file, and errors on non-terminal stderr omit color. Non-interactiveinituses defaults.
- Added Upgrade from 1.x, Running in CI and from agents, Exit codes, and five tutorials, starting with Your first workflow.
--control stdio: drive a run from another program. Approvals wait for an answer on stdin instead of exiting. See Drive codemod from a program.- Rejecting an approval ends the run for good; Ctrl-C pauses it instead of canceling it.
workflow attachreplays a run’s events and follows it live;workflow inspectdescribes a workflow’s params and steps.codemod/protocol: TypeScript types for the JSONL events and the control commands.
-
Rejecting an approval ends the run as
rejected(#2525). Before, answering no to anapproval(...)step failed the step, and a resume asked again. Now the run isrejected: steps running alongside stop, nothing after the approval runs, what earlier steps changed stays changed, and the CLI exits1.workflow resumerefuses a rejected run unless you pass--force, which asks the approval again. In the launcher,nnow rejects;lstill stops the run there to resume later. -
Ctrl-C pauses;
workflow cancelends (#2525). Before, both left acanceledrun thatworkflow resumecontinued. Now Ctrl-C (and closing a control channel’s stdin) leaves the runpaused, which resumes as before. A run canceled withworkflow cancelis over: resuming it takes--force. -
--format jsonlshows a nested codemod’s steps as steps (#2525). Before, acodemod(...)step’s own steps came asstep_loglines of that step. Now they arestep_started/step_finishedevents withstep: "3/0"andparent: "3"; a client that tracks steps bypositionalone should usestep. Text output and the launcher show them as before. -
A dry run that reaches an approval exits
1(#2525). It is not saved, so it cannot wait to be resumed; it says to pass--approveinstead of exiting0with no diff. With--control stdioit waits like a real run.
--control stdioonworkflow run,workflow resumeandcodemod <package>(#2525), with--format jsonl: ahelloline first, then the run’s events;question/question_closedaround every approval and agent pick; commandsapprove,reject,answerandstopon stdin. Experimental.workflow resume --approve <QUESTION_ID>gives one approval (approval:3);--approvealone still gives all.workflow statusandrun_finishedshow thequestiona run waits for.- Events:
seqkeeps counting across resumes; step events carrystep,parentandkind;run_logcarriesstep;run_startedechoestarget,params,dry_runandsettings; real runs reportstep_diffper changed file. workflow attach --id <ID>: every saved run keeps its events in the run store; attach prints them and follows a run another process executes.workflow inspect -w <file> --format json: declared params (type, doc comment,@default), imports, capabilities andstep(...)calls, for a setup form.codemod/protocol: types for all of the above, kept in step with the Rust types by a test.
workflow send <EVENT>to a run waiting for an approval said it sent the event and did nothing; it now fails and names theworkflow resume --approvecommand.- A canceled run could be resumed to success.
workflow list --format jsonleft outfailedFiles;workflow status --format jsonshowedattemptsandfilesasnullfor most steps.attemptsis now always the count, andfilesis set for every step that works on files.- A run waiting at a question over the control channel now stops when
workflow cancelis run from another terminal.
- The control protocol is experimental: messages can still change (
hello.protocolgoes up when a change breaks clients). workflow attachonly watches; answering a run’s questions takes its control channel orworkflow resume.- Runs started with
runWorkflowin Node.js have no control channel and keep no event journal. - With
--allow-fsor--allow-child-process, everyforEachFile, function anddependencyGraphstep counts as a write. - Dry runs are not saved, so
workflow statusandworkflow attachcan’t show them; their output is inrun_finishedand the text output. - The skill files
codemod aiinstalls still saynpx codemod ai ...unpinned. codemod/assesshas no free-text question type.- Values interpolated into shell commands (
${{ }}in a translatedrun:, or${x}inshell(...)) are not shell-quoted. Quote them yourself, or use theshell`...`tagged template, which does.
run_finishedcarries the workflow’s return value and each step’s result, dry runs too.fail()ends a run as failed and keeps its report as the output (exit code2).- A run that only reads is no longer stopped by uncommitted changes.
workflow statusandworkflow listprint JSON with--format json.
-
The uncommitted-changes check happens at the first write (#2521, #2523). Before,
workflow runandcodemod <package>refused to start on a target with uncommitted changes (or outside a git repository) without--allow-dirty. Now the run starts and checks just before it first changes the target: a step that writes, renames or deletes a file, ashell,agentorinstallSkillstep, a git step with--managed-git, or a step whose code getsfsorchild_process. A run that only reads (a check, a report) never stops at it.A run that writes still stops before it writes: an interactive run asks (in the launcher too), and an unattended run fails that step, writes nothing and exits1.--approvedoesn’t answer it;--allow-dirtystill skips it.workflow resumechecks again only a run that stopped before it first wrote;workflow resume --allow-dirtyskips that. -
run_finishedhasoutputandsteps(#2521). With--format jsonl,run_finishedadds the workflow’s return value and every recorded step with its result, also for dry runs. Anoutputover 1 MiB as JSON isnullwithoutput_omitted: { bytes, limit }; step results share another 1 MiB. In text format, a run that returned something ends withOutput: <JSON>, cut at 200 characters.
-
fail(message, { output?, exitCode? })(#2521) fromcodemod/workflow: end the run asfailedand keep a report. Before, throwing lost the output and catching the failure exited0. The run’s error ismessage, its output isoutput(inrun_finished.output,workflow status --format jsonandrunWorkflow(...).output), and the CLI exits2, orexitCode(1 to 125). A plainthrowstill exits1. Call it from the workflow body. -
workflow status --format jsonandworkflow list --format json(#2521): a run’s status, params, timings, error,output,exitCodeand steps with their results and durations. -
A repo health workflow in CI (#2522): the codemod repo checks itself with
.codemod/workflows/health.ts(one crossterm in the binary, no@latestpins in docs and CLI messages), which reports withfail().
- The no-command next steps (
npx codemod ai,init,<package>) andcodemod ai’s “no coding agent detected” warning pin the version you are running instead ofcodemod@latest, which is 1.x. - The MCP setup, troubleshooting, publish-from-CI and Codemod Studio docs no longer point at the
latesttag, which is 1.x. - The test that guards CLI messages against
@latestpins read only up to a file’s first#[cfg(test)]; it now skips only test code.
- With
--allow-fsor--allow-child-process, everyforEachFile, function anddependencyGraphstep counts as a write. - Dry runs are not saved, so
workflow statuscan’t show them; their output is inrun_finishedand the text output. - A
--dry-runthat reachesapproval()without--approveexits0at “Waiting for approval” with no diff, and can’t be resumed. Use--dry-run --approve. - The skill files
codemod aiinstalls still saynpx codemod ai ...unpinned. codemod/assesshas no free-text question type.- Values interpolated into shell commands (
${{ }}in a translatedrun:, or${x}inshell(...)) are not shell-quoted. Quote them yourself, or use theshell`...`tagged template, which does.
- An interactive launcher for runs in a terminal.
codemod/assess: ask an AI decision model typed questions about a file.- A run where some files failed now exits with code
2. workflow upgradewrites plain, typedforEachFilecallbacks.
-
A run with failed files exits 2 (#2516). A step where some files failed is
partial. Before,workflow run,codemod <package>andworkflow resumestill exited 0. Now they exit2when the run finished but files failed (1is still a hard failure or a cancel,0is success or waiting for an approval). If your CI treated exit 0 as “all good”, it now sees failed files.With--format jsonl,run_finishedgainsfailed_filesandpartial_steps.statusstayssucceeded. -
The launcher opens in interactive terminals (#2519).
workflow run,codemod <package>andworkflow resumeopen a terminal UI instead of printing lines. Scripts, pipes, CI,--format jsonland--no-interactiveget the same plain output as before. To keep plain output in a terminal: -
workflow upgradewrites plain typed callbacks (#2518). It imports each jssg transform and calls it from aforEachFilecallback, instead of wrapping it in the internalcodemod-internal:jssg-compatadapter. Files you already upgraded keep working. Re-runupgradeon theworkflow.yamlto get the new shape.The adapter is kept only where a plain callback can’t do the job (root.rename(),jssgTransform, adry_runstep, a templatedbase_path), andupgradesays which transform and why.
-
codemod/assess(#2517): ask a decision model (System One by default, or OpenAI) typed questions about a file from aforEachFilecallback or a function step. Answers are recorded with the step, so a resume doesn’t ask again. -
--allow-ai(#2517): a workflow that usescodemod/assesschecks for permission and an API key before step 1. Pass--allow-ai, or answer the prompt in an interactive run. -
The launcher (#2519): a setup screen (target, dry run, params, capabilities, agent, decision model), then live steps, logs, diffs and in-place approvals. After a dry run, press
ato apply it for real. -
--model <provider>/<model>(#2519) picks the decision model forcodemod/assess.--agentdefaults to the agent you picked in the launcher. -
More lockfiles (#2515):
dependencyGraphreads Yarn 1yarn.lock,bun.lock,package-lock.jsonv1 andnpm-shrinkwrap.json. -
codemod <package> --approve --managed-git(#2515): registry runs take the same start flags asworkflow run.
dependencyGraphon a target with no lockfile runs the callback on an empty graph instead of failing the step.codemod publishrespects.gitignorefiles (nested too) and never packsnode_modulesor.git.shardin a dry run sees the files earlier steps changed.- Hints after login, publish and
initpin the version you are running (npx codemod@2.0.0-alpha.7 login) instead ofcodemod@latest, which is 1.x. - Callbacks wrapped in
satisfies,asor parentheses build. - A callback that leaves a timer running no longer keeps its worker alive.
jssg testchecksdata.jsononce per case, and--filterand--fail-fastrespect it.- Poetry path dependencies outside the repo are plain nodes, not repo packages.
- The docs still show
npx codemod@latestin places, which is 1.x. npx codemod aiandnpx codemod inithints are not version-pinned yet.codemod/assesshas no free-text question type.- Values interpolated into shell commands (
${{ }}in a translatedrun:, or${x}inshell(...)) are not shell-quoted. Quote them yourself, or use theshell`...`tagged template, which does.
- Dry runs keep each step’s changes in memory, so later steps see them, and end with the diff of the whole run.
forEachFiletakes a reducer.- A simpler
codemod/depsgraph API. - Git steps moved to
codemod/git.
-
codemod/depsrenames (#2506).dependencyGraph(callback)no longer needs an options object.node.workspace→node.dir,node.isWorkspace→node.local,node.dependents()→node.installedBy().node.workspacesReaching()is gone: useg.chains({ to }).g.node(name)throws when several versions are installed: useg.nodes(name). -
dependentsreturns only your own packages by default (#2506). Pass{ includeThirdParty: true }for the old behavior. -
Git steps moved to
codemod/git(#2507). Importing them fromcodemod/workflowis a build error that names the new module. -
definition()resolves through barrel files (#2509). It follows re-exports and tsconfigpathsto where the symbol is declared. Code that expected the barrel’sexport { x } from "./x"line now gets the original file. -
deps.dependencyGraphthrough a namespace import is a build error (#2513). ImportdependencyGraphby name.import * as depsstill works forsemverandregistry.
-
Reducer for
forEachFile(#2508): folds each file’s output into one value, in path order, without holding every output in memory. -
Dry runs show a diff (#2511):
--dry-runkeeps changes in memory across steps and ends with the diff of the whole run (run_diffevents with--format jsonl). -
Test a callback file on its own (#2510):
codemod jssg test --callback -l typescript ./scripts/migrate.ts, orrunCallbackfromcodemod/testing. -
shardtakes every file by default (#2507) when you give nofilesorfilter. - Docs: a Build your first workflow tutorial (#2490).
- An
astGreprule withlanguage: "typescript"also runs on.js,.mjsand.cjsfiles (and"tsx"on.jsx). definition()andreferences()follow re-export chains and tsconfigpaths.g.chains()goes from one workspace to another (packages/web → @demo/shared → moment).codemod jssg runkeeps the edits a transform makes to other files withjssgTransform.${{ }}in a translatedworkflow.yamlprints arrays and objects as JSON again, not[object Object].jssg testwritesdata.jsonat the case root instead of failing with “Unexpected output file”.- Function and
dependencyGraphsteps no longer hang on leftover timers. **/*never enters.git.
dependencyGraphfails when the target has no lockfile, and on Yarn 1 lockfiles.codemod publishpacks gitignored files and nestednode_modules.codemod <package>has no--approveor--managed-git.- In a dry run,
shardreads files from disk, not earlier steps’ changes.
- Per-file logic is a
forEachFilecallback, written inline or imported from its own file.jssg(...)and file paths are gone from the workflow API. - The dependency API moved to
codemod/deps, and reads Python lockfiles. - Fixes from the review of the v2 engine: safer file writes, agent cancel on Windows, and more.
--versionprints the real version. Earlier alphas print1.18.7.
workflow.yaml files need no change: the translation handles them.-
jssg(...)was removed: per-file logic is aforEachFilecallback (#2498). Write it inline, or keep it as a file’s default export and import it. Values a transform read fromoptions.paramsbecome variables the callback captures.In the callback,parse(file)(fromcodemod/ast-grep) gives you the root,file.write(text)replaces returning text, andfile.rename(path)replacesroot.rename().semanticAnalysisandcapabilitiesare nowforEachFileselector options.jssg(path, { reduce })is gone; aforEachFilereducer arrives in alpha.6. -
astGrep(rules)runs only insideforEachFile, and takes rules, not paths (#2498). Import YAML rules or write them inline. Its only option isrepeat. -
shardtakes functions, not paths (#2498).method: { function: "./scripts/shard.ts" }→ an imported or inline function.jssg: { path }→filter: (file) => boolean.filePattern→files. -
The dependency API moved to
codemod/deps(#2493). -
dependencyGraphreads only root lockfiles by default (#2492). Nested ones need a glob, such as{ lockfiles: "**/yarn.lock" }. -
Shell steps run in the target directory by default (#2496). Pass
cwdto run somewhere else. -
Managed git steps can’t run alongside other steps (#2496).
branch,commitandpullRequestfail when started while other steps run, including in parallel shards. Sequential shards still work.
astGrep(rules, { repeat: true })(#2498) runs the rules again on their own output until nothing changes, so nested matches such asconsole.log(console.log(x))are all fixed in one step.- Python lockfiles (#2494):
dependencyGraphreadsuv.lock,poetry.lockandPipfile.lock.semverfollows PEP 440 with{ ecosystem: "pypi" }, andregistry.pypi(name)reads PyPI. - Cross-file
jssgTransformin translatedworkflow.yaml(#2504, #2505): a 1.x transform that edits other files keeps working, and concurrent edits to the same file are no longer lost. - Faster
forEachFile(#2500): files are read lazily and in parallel, with much lower memory on large targets.
- Overlapping ast-grep matches no longer corrupt files (#2499). The outer match wins; use
repeatto fix the inner ones too. --versionprints the npm version, not1.18.7(#2502).- From the engine review (#2496):
- Renames through symlinks that leave the target are refused, and so are ast-grep base paths outside it.
- Canceling stops an agent even after it closed its output, and stops its child processes on Windows.
- Nested registry runs respect preview-only restrictions.
workflow upgradeupdates the manifest of a nested workflow.- A shard prescan fails when the transform fails on every file.
- Registry packages with only a
workflow.tsvalidate and cache. import { sep, delimiter } from "node:path"works.
- Semantic analysis (
definition(),references()) in callbacks doesn’t work on the Node.js host. - Imports in a workflow need the real file extension (
./migrate.ts). - Several bugs found in this alpha are fixed in alpha.6, including TypeScript rules not running on
.jsfiles and[object Object]in translated${{ }}values.
- Workflow state is gone. Steps get values from the workflow and return what they found.
- Shell steps return
{ stdout, stderr, exitCode }. - Transforms return data, and metrics are removed.
- A dependency graph step: query the target’s lockfiles and the npm and crates.io registries.
-
No workflow state (#2489).
getState,setState,unsetState,acquireLockand the step-output functions were removed; importing one is a build error. Give a step what it needs (captured variables, shellenv) and read what it found from its result.${{ state.x }}inworkflow.yamlstill translates. A jssg transform that callsgetState/setStatefails to load. -
Shell steps return what the command printed (#2491):
{ stdout, stderr, exitCode }, keeping the last 1 MiB of each stream. A non-zero exit fails the step;shell(cmd, { allowFailure: true })returns the exit code instead. Step logs tag stderr lines with[stderr]. -
Transforms return
{ edit, data }, and metrics are removed (#2489, #2491).codemod/metricsanduseMetricAtomare gone. A transform returns its findings asdata(any JSON), and the step’sdatais[{ file, data }], sorted by path.jssg testsnapshotsdata.jsoninstead ofmetrics.json.
dependencyGraph,registryandsemver(#2486): a step reads the target’s lockfiles (Yarn Berry, pnpm, package-lock, Cargo) into a graph, and its callback queries the graph and the npm and crates.io registries. Registry answers are recorded with the step, so a resume doesn’t ask again. These moved tocodemod/depsin alpha.5.
workflow validate -w src/workflow.tsresolves local imports when the path is relative (#2488).- Shell redirects such as
2>&1work in Windows batch scripts.
--versionprints1.18.7(fixed in alpha.5).dependencyGraphfails on Yarn 1 lockfiles, and reads no Python, Go or bun lockfiles.- A translated
workflow.yamlstep that writes$STATE_OUTPUTSneeds a POSIX shell; on Windows it loses the state.
- Step retries, timeouts,
sleepandwaitForEvent. - A step where some files fail is
partial, and the run goes on. codemod initscaffoldssrc/workflow.tsand atests/workflow.test.ts.
codemod workflow testwas removed. New packages get atests/workflow.test.tsthat runs the workflow on each fixture withnode:testandcodemod/testing.codemod initno longer asks to add an agent skill, and--with-skillis gone.--skillstill makes a skill-only package. Angular was dropped from theinittemplates.- A step is matched on resume by its label and content, not by the order steps ran in.
NondeterminismErroris gone: a changed step runs again. Runs recorded by alpha.2 replay nothing.
- Step options
retries,retryDelayandtimeout:step(label, task, { retries: 2, timeout: "10m" }). sleep(duration)andwaitForEvent(name, { timeout })steps, andcodemod workflow send <event> --id <run>to deliver an event to a run.- Partial steps: a
forEachFile,jssgorastGrepstep fails only when every file fails. Otherwise the rest of its changes apply, the failed files are logged with their errors, and the run goes on. shell`...`as a tagged template quotes each interpolated value for the shell.import.meta.dirname,filenameandurlin workflows, steps and callbacks.codemod initwritessrc/workflow.ts, with transforms inline asforEachFilecallbacks, scripts insrc/scripts/and rules insrc/rules/.
- Shell commands started at the same time no longer wait for each other’s output pipes.
- Language types import as types in ES module projects.
- The C and Python
inittemplates.
--versionprints1.18.7(fixed in alpha.5).
- Workflows are TypeScript. A
workflow.tsdefault export runs steps.step()records each step’s result, so a resumed run replays finished steps and runs failed ones again. forEachFile(selector, callback)runs a per-file callback in parallel and applies all of a step’s file changes together.workflow.yamlis translated into the same TypeScript at run time.codemod workflow upgrade [PATH] [--keep-yaml] [--dry-run]writes that translation to disk.codemod/testing(runWorkflow,fixtures,assertTree) runs workflows fromnode:test, Vitest or Bun, andcodemod/hostruns them in Node.js.- Modules are imported as
codemod/workflow,codemod/ast-grepand so on. Thecodemod:*spelling still works.
workflow.ts
codemod initwritesworkflow.ts.codemod workflow tuiand the TUI were removed. Runs print text, or JSONL with--format jsonl.- Runs are resumed by id:
codemod workflow resume --id <run-id> [--approve]. Runs started by 1.x can’t be resumed. - Git steps (
branch,commit,pullRequest) need--managed-git. runtime: dockerandruntime: podmanare not supported; those steps run on the machine.
--versionprints1.18.7(fixed in alpha.5).codemod:llmdoesn’t work inside transforms run byjssgsteps.- Not yet checked on Windows.