fix(mosaic): seed TOOLS.md from defaults on install #458
Reference in New Issue
Block a user
Delete Branch "fix/tools-md-seeding"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes mosaicstack/stack#457.
~/.config/mosaic/TOOLS.mdwas never created during a bootstrap install even thoughAGENTS.mddeclares it as mandatory reading at position 5 of the load order. A fresh 0.0.29 install left the file missing and the agent contract pointing at nothing.Root cause
packages/mosaic/framework/install.shlines 228-236 explicitly seedAGENTS.md STANDARDS.mdfromdefaults/—TOOLS.mdwas listed inPRESERVE_PATHSbut never seeded in the first place.While investigating I also found:
FileConfigAdapter.syncFramework(packages/mosaic/src/config/file-adapter.ts) was iterating every file underframework/defaults/, which meant on a fresh install it would silently seeddefaults/SOUL.md(hardcoded "Jarvis") anddefaults/USER.md(placeholder) into the user's mosaic home before the wizard's own identity stages ran.packages/mosaic/framework/templates/TOOLS.md.templatestill referenced~/.config/mosaic/rails/git/...and~/.config/mosaic/rails/codex/.... Therails/tree was renamed totools/in the v1→v2 framework migration — so any user who did runmosaic initwould end up with aTOOLS.mdfull of broken paths.preservePathsdrift:install.shpreserves 8 paths across upgrades;file-adapter.tswas only preserving 4. This has been masked in production because the framework source tree has no root-level contract files — but the two code paths should agree regardless.Fix
packages/mosaic/framework/install.sh— extend the explicit defaults-seed loop fromAGENTS.md STANDARDS.mdtoAGENTS.md STANDARDS.md TOOLS.md.packages/mosaic/src/config/file-adapter.ts— replace the greedyreaddirSync(defaultsDir)loop with an exportedDEFAULT_SEED_FILES = ['AGENTS.md', 'STANDARDS.md', 'TOOLS.md']whitelist. AlignpreservePathswith the bashPRESERVE_PATHSlist so both install paths have the same upgrade-preservation semantics.packages/mosaic/framework/templates/TOOLS.md.template— replacerails/withtools/.Tests
Adds
packages/mosaic/src/config/file-adapter.test.ts(5 tests, all green):SOUL.md/USER.mdfromdefaults/— wizard stages own those.README.md/AUDIT-*.md(framework-internal).keepmode, includingAGENTS.md— this test plants a root-levelAGENTS.mdin the fixture'ssourceDirto actually exercisesyncDirectory's preserve path, not just the seed loop.defaults/directory is absent.Test plan
pnpm --filter @mosaicstack/mosaic run typecheckgreenpnpm --filter @mosaicstack/mosaic run lintgreenpnpm --filter @mosaicstack/mosaic exec vitest run→ 275/276 pass (the one failure,src/commands/uninstall.spec.ts:138, is a pre-existing EACCES issue on main and is unrelated to this change)pnpm typecheck/pnpm lint/pnpm format:checkgreenbash framework/install.shagainst a tmp MOSAIC_HOME — prints "Seeded TOOLS.md from defaults" and the file landsAffected version
Ships in
@mosaicstack/mosaic0.0.30.