Protected ReadonlyaiProtected ReadonlyfileProtected ReadonlyloggerProtectedmigrationIn-flight migration promise used to serialize migrate calls. Startup and the initial
workspace-trust resolution both trigger a migration, and the Re-run AGENTS.md migration
command can land on top of either; without this guard they race on the same legacy file, and
whichever createFile loses throws because the write deliberately passes no overwrite.
Protected ReadonlyworkspaceProtected ReadonlyworkspaceProtecteddoWrites AGENTS.md for every workspace root that still has a legacy project-info fragment.
Writing into the workspace requires trust; the agent settings rename does not, because it addresses user scope on both the read and the write side. Concurrent callers join the run already under way rather than starting a second one.
ProtectedmigrateCarries the retargeted agent's settings from its former id to AgentsMd, including the prompt
ids in selectedVariants. Does nothing once the new id is present.
Reads and writes user scope only, explicitly. The effective value is merged across scopes
and, while the workspace is untrusted, has its workspace and folder contributions suppressed,
whereas a update() write lands in the narrowest scope the key is already defined in. Passing
that merged value to update() would therefore rewrite a workspace-scoped
ai-features.agentSettings with an object assembled from a different set of scopes, dropping
every entry the read had suppressed. Addressing one scope on both sides is what makes this
safe to run outside the trust gate.
A ProjectInfo entry stored in workspace or folder scope is consequently left alone rather
than renamed; it goes stale, which costs the user that agent's model assignment, and is the
deliberate trade against touching a file the workspace owns.
Protectedmigrate
Migrates the legacy
.prompts/project-info.prompttemplateprompt fragment to a rootAGENTS.md, and carries the retargeted agent's settings over to its new id.Idempotent: once the legacy file has been renamed to
.baka re-run does nothing, and anAGENTS.mdthat already exists is never overwritten.