Generate Archify cards from registry descriptions for model diagrams
An architecture diagram inside a model that defines no cards gets one card per drawn shared element with a description, as the extension does. Test covers the resolved JSON; formats.md and SKILL.md describe the rule.
This commit is contained in:
1 parent
55894fbade
commit
c68f7df108
4 files changed
+26
-1
No files matched your search
@@ -28,6 +28,18 @@ const COPY = {
|
||||
};
|
||||
// What a diagram may override on a shared element. Everything else in COPY is fixed.
|
||||
export const OVERRIDE = ['label', 'sublabel', 'tag'];
|
||||
// Archify card dot colour per component type (the colour Archify gives the node).
|
||||
const DOT_BY_TYPE = { frontend: 'cyan', backend: 'emerald', database: 'violet', cloud: 'amber', security: 'rose', messagebus: 'orange', external: 'slate' };
|
||||
export const dotForType = (type) => DOT_BY_TYPE[type ?? ''] ?? 'slate';
|
||||
|
||||
// Archify info cards for shared elements: one per element with a description,
|
||||
// titled by its label. An architecture diagram without cards of its own gets
|
||||
// these for the elements it draws, as the extension does.
|
||||
export function cardsFromElements(elements) {
|
||||
return elements
|
||||
.filter((element) => typeof element.description === 'string' && element.description.trim())
|
||||
.map((element) => ({ dot: dotForType(element.type), title: element.label ?? element.id, items: [element.description.trim()] }));
|
||||
}
|
||||
// Registry-only fields, never sent to Archify.
|
||||
const REGISTRY_ONLY = ['description', 'diagram'];
|
||||
const SKIP_DIRS = new Set(['node_modules', '.git']);
|
||||
@@ -241,6 +253,11 @@ export function resolveDiagram(file, { root, elements } = {}) {
|
||||
}
|
||||
return merged;
|
||||
});
|
||||
if (type === 'architecture' && diagram.cards === undefined && refs.length) {
|
||||
const drawn = [...new Set(refs)].map((ref) => elements?.[ref]).filter(Boolean);
|
||||
const cards = cardsFromElements(drawn);
|
||||
if (cards.length) diagram.cards = cards;
|
||||
}
|
||||
result.resolved = diagram;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user