@riebeckite/plugin-diagnostics 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import type { AnalyzerContentConfig, DiagnosticsOptions } from "./types.js";
3
+ export declare function analyzeContent(config: AnalyzerContentConfig, options?: DiagnosticsOptions): Promise<Diagnostic[]>;
@@ -0,0 +1,4 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import type { ScanResult } from "../vault.js";
3
+ import { type AnalysisState, type NormalizedOptions } from "./shared.js";
4
+ export declare function checkUnusedAssets(source: ScanResult, state: AnalysisState, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,4 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import type { ScanResult } from "../vault.js";
3
+ import { type NormalizedOptions } from "./shared.js";
4
+ export declare function checkExcludedPublic(source: ScanResult, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,4 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import { type ScannedNote, type ScanResult } from "../vault.js";
3
+ import { type AnalysisState, type NormalizedOptions } from "./shared.js";
4
+ export declare function checkFrontmatter(note: ScannedNote, source: ScanResult, state: AnalysisState, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,4 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import { type ScannedNote, type ScanResult } from "../vault.js";
3
+ import { type AnalysisState, type NormalizedOptions } from "./shared.js";
4
+ export declare function checkMarkdownReferences(note: ScannedNote, source: ScanResult, state: AnalysisState, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,5 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import type { ScanResult } from "../vault.js";
3
+ import { type NormalizedOptions } from "./shared.js";
4
+ export declare function checkSlugCollisions(source: ScanResult, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
5
+ export declare function checkDuplicateTitles(source: ScanResult, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,4 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import type { ScanResult } from "../vault.js";
3
+ import { type AnalysisState, type NormalizedOptions } from "./shared.js";
4
+ export declare function checkOrphans(source: ScanResult, state: AnalysisState, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,11 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import { type ScanResult } from "../vault.js";
3
+ import { type NormalizedOptions } from "./shared.js";
4
+ /**
5
+ * Checks the publish boundary: content that is published must not reference
6
+ * content that is not. A published note that links to or embeds a
7
+ * non-published note can leak that note's title, excerpt, or rendered body
8
+ * into the public output (link cards, transclusion, search snippets), so it is
9
+ * reported here regardless of how the output is assembled.
10
+ */
11
+ export declare function checkPublishBoundary(source: ScanResult, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,20 @@
1
+ import type { Diagnostic, DiagnosticCode, DiagnosticSeverity } from "@riebeckite/core";
2
+ import type { DiagnosticsOptions } from "../types.js";
3
+ export type NoteLocation = {
4
+ slug?: string;
5
+ filePath?: string;
6
+ };
7
+ export type AnalysisState = {
8
+ referencedAssets: Set<string>;
9
+ incoming: Map<string, Set<string>>;
10
+ };
11
+ export type NormalizedOptions = {
12
+ reportUnusedAssets: boolean;
13
+ reportOrphans: boolean;
14
+ requiredFrontmatter: string[];
15
+ severity: Partial<Record<string, DiagnosticSeverity>>;
16
+ };
17
+ export declare function createAnalysisState(): AnalysisState;
18
+ export declare function normalizeOptions(options: DiagnosticsOptions): NormalizedOptions;
19
+ export declare function addIncoming(state: AnalysisState, target: string, source: string): void;
20
+ export declare function pushDiagnostic(diagnostics: Diagnostic[], options: NormalizedOptions, location: NoteLocation, code: DiagnosticCode, message: string, target?: string, suggestion?: string, line?: number, column?: number): void;
@@ -0,0 +1,4 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
2
+ import { type ScannedNote, type ScanResult } from "../vault.js";
3
+ import { type AnalysisState, type NormalizedOptions } from "./shared.js";
4
+ export declare function checkWikilinks(note: ScannedNote, source: ScanResult, state: AnalysisState, options: NormalizedOptions, diagnostics: Diagnostic[]): void;
@@ -0,0 +1,7 @@
1
+ export type ParsedFrontmatter = {
2
+ hasFrontmatter: boolean;
3
+ values: Record<string, unknown>;
4
+ };
5
+ export declare function parseFrontmatter(markdown: string): ParsedFrontmatter;
6
+ export declare function hasField(values: Record<string, unknown>, field: string): boolean;
7
+ export declare function getNoteTitle(values: Record<string, unknown>, slug: string): string;
@@ -0,0 +1,9 @@
1
+ export type SourcePosition = {
2
+ line: number;
3
+ column: number;
4
+ };
5
+ export declare class LineMapper {
6
+ private starts;
7
+ constructor(text: string);
8
+ positionAt(index: number): SourcePosition;
9
+ }
@@ -0,0 +1,7 @@
1
+ export type MarkdownReference = {
2
+ kind: "link" | "image";
3
+ url: string;
4
+ line: number;
5
+ column: number;
6
+ };
7
+ export declare function extractMarkdownReferences(markdown: string): MarkdownReference[];
@@ -0,0 +1,13 @@
1
+ import type { Diagnostic, DiagnosticCode } from "@riebeckite/core";
2
+ import type { DiagnosticsReport, DiagnosticsSummary } from "./types.js";
3
+ export declare class DiagnosticsFailure extends Error {
4
+ readonly report: DiagnosticsReport;
5
+ constructor(report: DiagnosticsReport);
6
+ }
7
+ export declare function buildReport(diagnostics: Diagnostic[]): DiagnosticsReport;
8
+ export declare function summarize(diagnostics: Diagnostic[]): DiagnosticsSummary;
9
+ export declare function groupByCode(diagnostics: Diagnostic[]): Map<DiagnosticCode, Diagnostic[]>;
10
+ export declare function assertNoErrors(report: DiagnosticsReport): void;
11
+ export declare function formatDiagnostics(input: Diagnostic[] | DiagnosticsReport, options?: {
12
+ color?: boolean;
13
+ }): string;
@@ -0,0 +1,32 @@
1
+ import type { ContentSource, Diagnostic, DiagnosticCode, DiagnosticSeverity } from "@riebeckite/core";
2
+ export type DiagnosticsOptions = {
3
+ failOnError?: boolean;
4
+ reportUnusedAssets?: boolean;
5
+ reportOrphans?: boolean;
6
+ requiredFrontmatter?: string[];
7
+ severity?: Partial<Record<DiagnosticCode, DiagnosticSeverity>>;
8
+ exclude?: string[];
9
+ publishStrategy?: "explicit" | "selective";
10
+ };
11
+ export type DiagnosticsSummary = {
12
+ total: number;
13
+ error: number;
14
+ warning: number;
15
+ info: number;
16
+ };
17
+ export type DiagnosticsReport = {
18
+ diagnostics: Diagnostic[];
19
+ errors: Diagnostic[];
20
+ warnings: Diagnostic[];
21
+ infos: Diagnostic[];
22
+ hasErrors: boolean;
23
+ hasWarnings: boolean;
24
+ summary: DiagnosticsSummary;
25
+ byCode: Map<DiagnosticCode, Diagnostic[]>;
26
+ };
27
+ export type AnalyzerContentConfig = {
28
+ directory: string;
29
+ source?: ContentSource;
30
+ exclude: string[];
31
+ publishStrategy: "explicit" | "selective";
32
+ };
@@ -0,0 +1,48 @@
1
+ import { type ParsedFrontmatter } from "./frontmatter.js";
2
+ import type { AnalyzerContentConfig } from "./types.js";
3
+ export type ScannedNote = {
4
+ relativePath: string;
5
+ slug: string;
6
+ markdown: string;
7
+ fm: ParsedFrontmatter;
8
+ headings: Set<string>;
9
+ blockIds: Set<string>;
10
+ excluded: boolean;
11
+ published: boolean;
12
+ };
13
+ export type ScannedAsset = {
14
+ relativePath: string;
15
+ extension: string;
16
+ };
17
+ export type ScanResult = {
18
+ includedNotes: ScannedNote[];
19
+ excludedNotes: ScannedNote[];
20
+ noteSlugs: Set<string>;
21
+ noteBySlug: Map<string, ScannedNote>;
22
+ assetPaths: Set<string>;
23
+ assets: ScannedAsset[];
24
+ filePaths: Set<string>;
25
+ targetIndex: Map<string, ResolvedTarget>;
26
+ };
27
+ export type TargetKind = "note" | "image" | "attachment";
28
+ export type ResolvedTarget = {
29
+ kind: TargetKind;
30
+ value: string;
31
+ };
32
+ export type WikilinkMatch = {
33
+ embed: boolean;
34
+ target: string;
35
+ fragment: string | null;
36
+ index: number;
37
+ };
38
+ export declare function scanVault(config: AnalyzerContentConfig): Promise<ScanResult>;
39
+ export declare function getWikilinkMatches(markdown: string): WikilinkMatch[];
40
+ export declare function resolveWikilinkTarget(target: string, targetIndex: Map<string, ResolvedTarget>): ResolvedTarget | null;
41
+ export declare function isImageTarget(target: string): boolean;
42
+ export declare function isAssetTarget(target: string): boolean;
43
+ export declare function resolveLocalReference(noteSlug: string, url: string): string | null;
44
+ export declare function resolveVaultRelative(value: string): string | null;
45
+ export declare function extractHeadings(markdown: string): Set<string>;
46
+ export declare function extractBlockIds(markdown: string): Set<string>;
47
+ export declare function fragmentExists(note: ScannedNote, fragment: string): boolean;
48
+ export declare function getExtension(filePath: string): string;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@riebeckite/plugin-diagnostics",
3
+ "version": "0.0.1",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "source": "./index.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "bin": {
17
+ "riebeckite-diagnostics": "./dist/bin.js"
18
+ },
19
+ "dependencies": {
20
+ "remark-parse": "^11.0.0",
21
+ "unified": "^11.0.5",
22
+ "unist-util-visit": "^5.1.0",
23
+ "@riebeckite/core": "0.0.1"
24
+ },
25
+ "devDependencies": {
26
+ "@types/mdast": "^4.0.4",
27
+ "@types/node": "^24.5.2"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "files": [
33
+ "LICENSE",
34
+ "README.md",
35
+ "README_ja.md",
36
+ "dist"
37
+ ],
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/Rerurate514/riebeckite.git",
41
+ "directory": "packages/plugins/diagnostics"
42
+ },
43
+ "homepage": "https://github.com/Rerurate514/riebeckite#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/Rerurate514/riebeckite/issues"
46
+ },
47
+ "description": "Content diagnostics for Riebeckite and Obsidian vaults.",
48
+ "keywords": [
49
+ "riebeckite",
50
+ "plugin",
51
+ "diagnostics",
52
+ "obsidian"
53
+ ],
54
+ "engines": {
55
+ "node": "^20.19.0 || >=22.12.0"
56
+ },
57
+ "sideEffects": false,
58
+ "scripts": {
59
+ "build": "node ../../../scripts/build_package.mjs"
60
+ }
61
+ }