feat(context): scoped DESIGN.md routing for multi-design-system projects#174
Open
modius wants to merge 1 commit into
Open
feat(context): scoped DESIGN.md routing for multi-design-system projects#174modius wants to merge 1 commit into
modius wants to merge 1 commit into
Conversation
Projects that ship more than one design system (e.g. an admin app + a public marketing site) currently can't tell impeccable which DESIGN.md applies to the surface being worked on — there's a single DESIGN.md next to PRODUCT.md. Add zero-config scoped DESIGN.md routing: drop a DESIGN.md inside a named subdirectory of the context dir (alongside the shared PRODUCT.md), and pass the URL or file path being designed to context.mjs. The loader matches the target's hostname labels / path segments against the scope directory names and loads the matching scope's DESIGN.md, falling back to the shared DESIGN.md when nothing matches. PRODUCT.md stays project-wide. .agents/context/PRODUCT.md (shared) .agents/context/admin/DESIGN.md -> https://admin.example.com/... | src/admin/x .agents/context/marketing/DESIGN.md -> https://example.com/marketing/... - skill/scripts/context.mjs: discoverScopes(), inferScope(), resolveDesignPath(); loadContext(cwd, target) now returns `designScope`; CLI reads argv[2]. - skill/SKILL.src.md: document passing the target in setup step 1. - tests/context.test.mjs: 7 new tests (inferScope + resolveDesignPath + loadContext). Single-DESIGN.md projects are unaffected (no target / no scope dirs -> shared). Provider copies under the harness dirs are build outputs — run `bun run build:skills` to regenerate them.
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.
What
Adds zero-config scoped DESIGN.md routing to the context loader, so a project with more than one design system can tell impeccable which one applies to the surface being worked on.
Today there's a single
DESIGN.mdnext toPRODUCT.md. Projects that ship, say, an admin app and a public marketing site (different look, shared product story) have no way to load the right design system per task.How
Drop a
DESIGN.mdinside a named subdirectory of the context dir, alongside the sharedPRODUCT.md, then pass the URL or file path you're working on tocontext.mjs:The loader infers the scope by matching the target's hostname labels / path segments against the scope directory names (host labels take precedence). No config, no hardcoded names — scopes are discovered from the filesystem.
Changes
skill/scripts/context.mjs:discoverScopes(),inferScope(),resolveDesignPath();loadContext(cwd, target)gains adesignScopefield; CLI readsargv[2].skill/SKILL.src.md: setup step 1 documents passing the target.tests/context.test.mjs: 7 new tests (inferScope,resolveDesignPath,loadContextscoped + unscoped).Compatibility
Fully backward compatible: with no target argument, or no scope subdirectories, the loader returns the shared
DESIGN.mdexactly as before. All existing context tests pass (42/42).Notes
skill/). The provider copies under the harness dirs are build outputs — they needbun run build:skillsto regenerate (I couldn't run the full build locally without the toolchain). Happy to adjust to whatever you prefer for artifact regeneration.context.mjsfor exactly this (a 3-bundle app), and the 3.1→3.5 loader rewrite wiped it — keen to land a generic version upstream so it's maintained for everyone. Glad to iterate on the design (e.g. an explicit scope→pattern map in PRODUCT.md frontmatter) if you'd prefer a different shape.Note
Low Risk
Additive, filesystem-driven context selection with fallback to the existing shared DESIGN.md; no auth, data, or breaking API changes beyond an optional second argument.
Overview
Adds zero-config scoped
DESIGN.mdrouting so projects with multiple design systems (e.g. admin vs marketing) load the right design doc for the surface being worked on, whilePRODUCT.mdstays project-wide.Convention: put scoped files under the context directory as
<scope>/DESIGN.md(e.g..agents/context/admin/DESIGN.md) next to sharedPRODUCT.md. Pass an optional URL or file path tocontext.mjs(CLIargv[2],loadContext(cwd, target)). The loader discovers scope folders, tokenizes the target (hostname labels first, then path segments), and picks the first matching scope name; otherwise it uses the shared rootDESIGN.md.loadContextnow exposesdesignScopewhen a scoped file wins.Docs & tests:
SKILL.src.mdsetup step 1 documents the optional target argument; new unit tests coverinferScope,resolveDesignPath, and scoped vs legacy single-DESIGN.mdbehavior.Compatibility: omitting the target or having no scope subdirs behaves exactly as before.
Reviewed by Cursor Bugbot for commit 064ab4e. Bugbot is set up for automated code reviews on this repo. Configure here.