diff --git a/bun.lock b/bun.lock index 3d60886..343007f 100644 --- a/bun.lock +++ b/bun.lock @@ -27,7 +27,7 @@ "dts-bundle-generator": "9.5.1", "esbuild": "0.28.2", "lefthook": "^2.2.2", - "structured-context-map-views": "^0.5.0", + "structured-context-map-views": "^0.6.0", }, "peerDependencies": { "typescript": "^5", @@ -541,9 +541,9 @@ "strip-bom-string": ["strip-bom-string@1.0.0", "", {}, "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g=="], - "structured-context": ["structured-context@0.22.1", "", { "dependencies": { "ajv": "^8.20.0", "chokidar": "^5.0.0", "commander": "^15.0.0", "fast-glob": "^3.3.3", "gray-matter": "^4.0.3", "js-yaml": "^5.4.3", "json-schema-to-ts": "^3.1.1", "json5": "^2.2.3", "jsonata": "^2.2.1", "mdast-util-to-string": "^4.0.0", "remark-gfm": "^4.0.1", "remark-parse": "^11.0.0", "unified": "^11.0.5", "unist-util-visit": "^5.1.0" }, "peerDependencies": { "typescript": "^5" }, "bin": { "sctx": "dist/index.js" } }, "sha512-YBCurh4UAL+0uC0OLYTfAVONu3RQkuozqXkHn3/iM/z7xIsjQQPdwPrS8Lf16TaIVs/NufOiQwRwPsbj7pY8dA=="], + "structured-context": ["structured-context@0.23.0", "", { "dependencies": { "ajv": "^8.20.0", "chokidar": "^5.0.0", "commander": "^15.0.0", "fast-glob": "^3.3.3", "gray-matter": "^4.0.3", "js-yaml": "^5.4.3", "json-schema-to-ts": "^3.1.1", "json5": "^2.2.3", "jsonata": "^2.2.1", "mdast-util-to-string": "^4.0.0", "remark-gfm": "^4.0.1", "remark-parse": "^11.0.0", "unified": "^11.0.5", "unist-util-visit": "^5.1.0" }, "peerDependencies": { "typescript": "^5" }, "bin": { "sctx": "dist/index.js" } }, "sha512-KWriaOPuyYW2kDoYEjDYvyHm7s1bUQqQ6QT8c2fRUDRbKzS65mFJhc3o9e7TpdFLwXi6VM3NFZEKszww9ZoYPQ=="], - "structured-context-map-views": ["structured-context-map-views@0.5.0", "", { "dependencies": { "ajv": "^8.20.0", "commander": "^15.0.0", "json-schema-to-ts": "^3.1.1", "json5": "^2.2.3" }, "peerDependencies": { "react": "^19.3.0", "react-dom": "^19.3.0", "structured-context": "^0.22.1" }, "bin": { "structured-context-map-views": "dist/cli.js" } }, "sha512-WrAiYsMlF4sW0iLeQ2gtyI9lhW8wyNJN+ugdvZGifGLNPFsrx2mVbZXe44m/A/kjyEwG1Dfk9+Tk+rp/20NgDA=="], + "structured-context-map-views": ["structured-context-map-views@0.6.0", "", { "dependencies": { "ajv": "^8.20.0", "commander": "^15.0.0", "json-schema-to-ts": "^3.1.1", "json5": "^2.2.3" }, "peerDependencies": { "react": "^19.3.0", "react-dom": "^19.3.0", "structured-context": "^0.23.0" }, "bin": { "structured-context-map-views": "dist/cli.js" } }, "sha512-KtiJXTpDwru7ca577p4CZerBhm6WjPqIU+mchygwIQJLDYoLTaNGm+A7as2IiM20GCerWtmPWwKl6FO7bFXdwA=="], "to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="], diff --git a/package.json b/package.json index ad91c1a..73db597 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "dts-bundle-generator": "9.5.1", "esbuild": "0.28.2", "lefthook": "^2.2.2", - "structured-context-map-views": "^0.5.0" + "structured-context-map-views": "^0.6.0" }, "peerDependencies": { "typescript": "^5" diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json index 0334d47..319bf28 100644 --- a/plugin/.claude-plugin/plugin.json +++ b/plugin/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "structured-context", - "version": "0.23.0", + "version": "0.23.1", "description": "Structured content authoring for Obsidian — automatic validation hooks, slash commands, and agent skills to keep markdown files compliant with your schema.", "homepage": "https://github.com/mindsocket/structured-context", "repository": "https://github.com/mindsocket/structured-context", diff --git a/plugin/hooks/map-pane.tsx b/plugin/hooks/map-pane.tsx index 01eb19b..6b393b7 100644 --- a/plugin/hooks/map-pane.tsx +++ b/plugin/hooks/map-pane.tsx @@ -126,33 +126,10 @@ function findOccurrence(occurrences: Occurrence[], key: string): Occurrence | un return undefined; } -type Issue = PaneData['validation']['issues'][number]; - -// PROTOTYPE: structured-context-map-views 0.5 takes issues by node plus the global rule violations. -// Drop this once a map-views release takes the issue list itself. -function byNode(list: Issue[]): Parameters[0] { - const issues: Record< - string, - Record & { line?: number; column?: number }> - > = {}; - const ruleViolations: { ruleId: string; severity: Issue['severity']; description: string }[] = []; - for (const issue of list) { - if (issue.kind === 'parse') continue; - if (issue.nodeId === undefined) { - if (issue.kind === 'rule') ruleViolations.push(issue); - continue; - } - const { kind, message, severity, source } = issue; - issues[issue.nodeId] ??= {}; - issues[issue.nodeId]![issue.key] = { kind, message, severity, line: source?.line, column: source?.column }; - } - return { issues, ruleViolations } as Parameters[0]; -} - function project(data: PaneData, hierarchy?: string): { graph: Graph; tree: Tree; annotations: Annotations } { const graph = spaceGraphFrom(data.graph as Parameters[0], { hierarchy }); const tree = buildTree(graph, 'pane'); - const annotations = annotationsFrom(byNode(data.validation.issues), graph); + const annotations = annotationsFrom(data.validation, graph); return { graph, tree, annotations }; } @@ -266,8 +243,6 @@ export function registerMapPane(on: On): void { const counts = { error: 0, warning: 0, info: 0 }; for (const results of annotations.annotations.values()) for (const a of results) counts[a.severity]++; for (const a of annotations.unattached) counts[a.severity]++; - const parseIssues = data.validation.issues.filter((issue) => issue.kind === 'parse'); - for (const issue of parseIssues) counts[issue.severity]++; const toggle = (key: string) => update($, collapsed, (keys) => (keys.includes(key) ? keys.filter((k) => k !== key) : [...keys, key])); @@ -367,22 +342,12 @@ export function registerMapPane(on: On): void { {unattached.slice(0, UNATTACHED_LIMIT).map((a) => ( {' '} - {a.nodeId ?? 'space'}: {describe(a)} + {a.nodeId ?? a.location?.file ?? 'space'}: {describe(a)} ))} {unattached.length > UNATTACHED_LIMIT && ( {` and ${unattached.length - UNATTACHED_LIMIT} more`} )} - {parseIssues.length > 0 && Could not parse ({parseIssues.length}):} - {parseIssues.slice(0, UNATTACHED_LIMIT).map((issue) => ( - - {' '} - {issue.source?.file}: {issue.severity}: {issue.message} - - ))} - {parseIssues.length > UNATTACHED_LIMIT && ( - {` and ${parseIssues.length - UNATTACHED_LIMIT} more`} - )} ); }); diff --git a/plugin/hooks/projection.js b/plugin/hooks/projection.js index 97a653f..580ab0b 100644 --- a/plugin/hooks/projection.js +++ b/plugin/hooks/projection.js @@ -1,34 +1,24 @@ // Generated by scripts/build-mod-projection.ts from structured-context/browser and structured-context-map-views. // Do not edit: run `bun run build:mod-projection`. -// node_modules/structured-context-map-views/dist/projection-CYShQhug.js +// node_modules/structured-context-map-views/dist/projection-C-dATsdO.js function annotationsFrom(input, graph) { const annotations = /* @__PURE__ */ new Map(); const unattached = []; - for (const [id, issues] of Object.entries(input.issues)) { - const nodeId = id; - for (const [key, { kind, message, severity, line, column }] of Object.entries(issues)) { - const annotation = { - severity, - source: kind, - message, - ...kind === "rule" && key.startsWith("rule:") && { ruleId: key.slice(5) } - }; - if (graph.nodes.has(nodeId)) annotations.set(nodeId, [...annotations.get(nodeId) ?? [], annotation]); - else unattached.push({ - ...annotation, - nodeId, - ...line !== void 0 && { line }, - ...column !== void 0 && { column } - }); - } + for (const { kind, severity, message, nodeId, source, ruleId } of input.issues) { + const annotation = { + severity, + source: kind, + message, + ...kind === "rule" && ruleId !== void 0 && { ruleId } + }; + if (nodeId !== void 0 && graph.nodes.has(nodeId)) annotations.set(nodeId, [...annotations.get(nodeId) ?? [], annotation]); + else unattached.push({ + ...annotation, + ...nodeId !== void 0 && { nodeId }, + ...source !== void 0 && { location: source } + }); } - for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) if (nodeId === void 0) unattached.push({ - severity, - source: "rule", - message: description, - ruleId - }); return { annotations, unattached