feat: load category prefix mappings from .toneforge/config.yaml with lazy loading and fallback#246
Draft
feat: load category prefix mappings from .toneforge/config.yaml with lazy loading and fallback#246
.toneforge/config.yaml with lazy loading and fallback#246Conversation
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
…with js-yaml Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor category classifier to use YAML config
feat: load category prefix mappings from Mar 13, 2026
.toneforge/config.yaml with lazy loading and fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hard-coded
RECIPE_NAME_CATEGORY_MAPincategory.tsmade adding categories require TypeScript changes. This refactor externalizes that map to a committed YAML config, with lazy loading and safe fallback behavior.Changes
.toneforge/config.yaml— New file containing the canonicalprefixToCategorymap (all existing mappings preserved). Maintainers extend categories here, no TS edits needed.src/classify/dimensions/category.ts—CategoryClassifiernow:configPathconstructor arg (defaults toprocess.cwd()/.toneforge/config.yaml, resolved at first classify call)loadMappings()console.warn+ falls back to in-memory defaultscontext.categorypath unchanged — still bypasses config entirelysrc/classify/__tests__/category.test.ts— 8 new tests covering: valid config load, override of built-in defaults, missing-file fallback + warning, single-warn caching, and three malformed-config error cases (array root, missingprefixToCategorykey, non-string value).package.json— Addedjs-yaml@4.1.1(runtime) and@types/js-yaml(dev).Example: adding a new category
Original prompt
This section details on the original issue you should resolve
<issue_title>Category System Config Refactoring</issue_title>
<issue_description>
Problem statement
Refactor the category classifier to load prefix-to-category mappings from a repository-stored YAML config (
.toneforge/config.yamlif present) instead of requiring hard-coded mappings insrc/classify/dimensions/category.ts. This will make adding and maintaining categories easier without TypeScript code changes while preserving current fallback heuristics and tests.Users
card-gamewithout changing TypeScript).User stories
Success criteria
.toneforge/config.yaml(or extends an existing.toneforgeconfig if present) and uses it when available.npm testandnpx tsc --noEmitsucceed.Constraints
js-yaml) to parse.toneforge/config.yaml..toneforgeconfig is present, extend/merge with it; otherwise look for.toneforge/config.yamlin the repo root. The classifier will not create or write this file automatically.Existing state
src/classify/dimensions/category.tswith mappings such asweapon,footstep,ui,ambient,character,creature,vehicle,impact(plus aliases likeslam->impact,card->card-game).docs/prd/CLASSIFY_PRD.mddescribing classification goals and vocabulary.TF-0MM65RIDV0EJH50O(Card Game Sound Effects Recipe Library) andTF-0MM79DNLZ0J2RP2P(Add card-game Classifier Category).Desired change
RECIPE_NAME_CATEGORY_MAPto a YAML config with a minimal schema (prefix-to-category map)..toneforge/config.yamlon the first call toCategoryClassifier.classify()and caches mappings in memory.src/classify/dimensions/category.tsto prefer config mappings, falling back to the in-file defaults when necessary.Related work
RECIPE_NAME_CATEGORY_MAP(will be updated).Notes
inferCategoryFromMetrics. The config only affects recipe-name prefix mapping and optional explicitcontext.categorynormalization.Files to change (suggested)
Recommended next question for implementer
js-yaml) acceptable, or should the implementation ins...✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.