Skip to content

Exclude unused files: a BGM plan ships with the files it names - #101

Merged
Psychronic-Games merged 1 commit into
Psychronic-Games:mainfrom
Xehanort88:pr/plan-pieces-kept
Nov 30, 2026
Merged

Psychronic-Games merged 1 commit into
Psychronic-Games:mainfrom
Xehanort88:pr/plan-pieces-kept

Conversation

@Xehanort88

Copy link
Copy Markdown
Contributor

The problem

AudioManager.playBgmPlan(folder) (the BGM plan player, a separate PR) plays audio/<folder>/plan.json, and the plan names the audio files it plays. Nothing else in a project names them. The deployment pruner (editor/build-scripts/unused-assets.cjs) never read plan.json, so a build with Exclude unused files left every piece out.

The plan file itself usually stayed, because the word "plan" appears somewhere in any project's text. That is the worst outcome: a build that ships the plan without its files, and stops on the Retry screen as soon as the plan plays. This was measured on a real project, where all 14 pieces of two plans were reported "nothing in the project names it".

What changed

analyze() reads every audio/**/plan.json shaped like a plan: a files map of { path } plus a clips array. Any other file named plan.json is judged by name as before. A plan is played by its folder, so it ships when its folder would. That means one of the following:

  • the folder's name appears in the project, for example in the script call that plays it;
  • the folder is on the Always include list;
  • a plugin lists the folder;
  • a playtest loaded the plan or any of its files.

When a plan ships, every file it names ships with it.

  • Paths are relative to the plan's folder, and a \ separator is accepted.
  • A path leading out of the folder keeps nothing.
  • Files beside the plan that it does not name, such as a reference mix, are judged as usual.
  • A plan nothing keeps is left out whole, never shipped without its files.

The per-file reasons reuse the existing ones ("named in the project", "loaded in a playtest", "in the Always include list"), so there are no new strings.

Verification

  • A new test in editor/tests/unused-assets.test.cjs uses synthetic plans only. It covers:

    • a plan played by a script call ships with both its files;
    • a file beside it, a reference mix and an out-of-folder path are left out;
    • an unplayed plan is left out together with its files, and its folder is removed from a pruned copy;
    • a plan reached only by a playtest ships;
    • Always include keeps a plan's folder;
    • a plan.json that is not a plan is judged by name;
    • an encrypted copy keeps .wav_ pieces and the plain plan.json.

    The file passes 14 of 14, also on this branch cut from upstream/main.

  • On a real project, with a read-only analyze:

    • nothing playing the plans: all 16 plan files are left out;
    • Always include on the plans folder: all 16 ship;
    • Always include on one plan.json: that plan and its own pieces ship, and nothing else does.
  • Full npm test (Git Bash, Windows): the failing-test names are identical to the main baseline, the known environmental set.

Limits

  • A folder name that appears in the project's text for some other reason keeps its plan. That follows the file's existing "when in doubt, keep" rule.
  • A folder name the game builds at run time is not recognised. Examples are "plans/" + area, or any name that does not share a start of three or more characters with something in the project's text.
  • None of the pruner's reason strings are in the translation catalog. That predates this change, and this change adds no new strings.

🤖 Generated with Claude Code

A plan (audio/<folder>/plan.json, played by AudioManager.playBgmPlan) is the
only thing in a project that names its pieces, and the pruner never read it,
so a deployment with Exclude unused files left every piece out. The plan
itself usually stayed, because "plan" is a word somewhere in any project:
a build that ships a plan without its files and stops on Retry when it plays.

analyze() now reads each audio/**/plan.json shaped like a plan. The plan
ships when its folder would (named in the project, Always include, a plugin
listing it, a playtest loading the plan or any of its files), and then every
file it names ships too; a path out of the plan's folder keeps nothing. A
plan nothing keeps is left out whole. Reasons reuse the existing ones, so
no new strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Psychronic-Games
Psychronic-Games merged commit cfd429f into Psychronic-Games:main Nov 30, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants