Support .archify diagram files (0.2.0)
.archify files are Archify JSON diagram sources. They open as JSON, preview with the same commands, report validation problems, and get completion from a schema that dispatches on diagram_type. Adds a hello.archify example and tests for detection, the dispatching schema and the VS Code behaviour. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ export const EVIDENCE_COLLECTIONS: Record<DiagramType, string> = {
|
||||
};
|
||||
|
||||
const FILENAME_RE = /\.(architecture|workflow|sequence|dataflow|lifecycle)\.json$/i;
|
||||
const ARCHIFY_EXT_RE = /\.archify$/i;
|
||||
const MAX_SNIFF_BYTES = 8 * 1024 * 1024;
|
||||
|
||||
export function isDiagramType(value: unknown): value is DiagramType {
|
||||
@@ -24,6 +25,22 @@ export function typeFromFilename(fileName: string): DiagramType | undefined {
|
||||
return match ? (match[1].toLowerCase() as DiagramType) : undefined;
|
||||
}
|
||||
|
||||
/** `name.archify`: an Archify diagram whose type comes from `diagram_type`. */
|
||||
export function isArchifyFile(fileName: string): boolean {
|
||||
return ARCHIFY_EXT_RE.test(fileName);
|
||||
}
|
||||
|
||||
/** File names that are diagram sources regardless of their content. */
|
||||
export function isDiagramFileName(fileName: string): boolean {
|
||||
return isArchifyFile(fileName) || FILENAME_RE.test(fileName);
|
||||
}
|
||||
|
||||
/** Base name without the diagram source extension (`web.archify` → `web`). */
|
||||
export function diagramBaseName(fileName: string): string {
|
||||
const base = fileName.split(/[\\/]/).pop() ?? fileName;
|
||||
return base.replace(ARCHIFY_EXT_RE, '').replace(/\.json$/i, '');
|
||||
}
|
||||
|
||||
export interface DiagramSource {
|
||||
type: DiagramType;
|
||||
diagram: Record<string, unknown>;
|
||||
|
||||
Reference in New Issue
Block a user