@dogsbay/format-obsidian 0.2.0-beta.16 → 0.2.0-beta.160

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,25 @@
1
+ /**
2
+ * What the Obsidian exporter can and cannot represent — a CONTRACT (the
3
+ * format-docusaurus pattern): `validateCapabilities` rejects any non-full
4
+ * entry without a note, and a test asserts every `MATRIX_ROWS` type has
5
+ * exactly one declaration here. Each entry states what a READER sees in the
6
+ * vault, measured by running `treeToObsidian` on nodes parsed from real
7
+ * Dogsbay MD — not what the serializer intends.
8
+ *
9
+ * Several rich blocks are emitted as `dogsbay-*` fenced code blocks
10
+ * (`dogsbay-tabs`, `dogsbay-steps`, `dogsbay-deflist`, `dogsbay-card`,
11
+ * `dogsbay-code`) that the `dogsbay-docs` Obsidian plugin renders. The vault
12
+ * export bundles that plugin by default; WITHOUT it a reader sees those
13
+ * blocks as literal code. "full" for them means "full with the plugin".
14
+ *
15
+ * IMPORTANT: this exporter keeps NO ledger. `walkInline` is called without a
16
+ * `report` callback, so even the losses the shared inline walk does report
17
+ * (unsafe link/image targets, inline types with no emitter) go nowhere. Every
18
+ * partial/none below is therefore, today, a loss nothing records at export
19
+ * time — this declaration is the only place it is stated.
20
+ *
21
+ * Support levels: full — faithful · partial — survives with reduced fidelity
22
+ * (note says how) · none — dropped or flattened (note says what is lost).
23
+ */
24
+ import type { CapabilityDeclaration } from "@dogsbay/serialize-core";
25
+ export declare const OBSIDIAN_CAPABILITIES: CapabilityDeclaration[];
@@ -0,0 +1,171 @@
1
+ export const OBSIDIAN_CAPABILITIES = [
2
+ // ── Blocks ───────────────────────────────────────────────
3
+ { feature: "heading", support: "full", rendersAs: "`#`–`######` + a sanitized, per-page-unique `^block-id` from the slug" },
4
+ { feature: "paragraph", support: "full" },
5
+ { feature: "blockquote", support: "full", rendersAs: "`> …`" },
6
+ { feature: "unordered-list", support: "full", rendersAs: "`- item`" },
7
+ { feature: "ordered-list", support: "full", rendersAs: "`1. item` (honours `start`)" },
8
+ { feature: "hr", support: "full", rendersAs: "`---`" },
9
+ {
10
+ feature: "table",
11
+ support: "partial",
12
+ rendersAs: "GFM pipe table",
13
+ note: "Cells are single-line: a block inside a cell (list, code, paragraphs) is flattened to one line of text (`- a - b`). A table `caption` is dropped.",
14
+ },
15
+ {
16
+ feature: "code",
17
+ support: "partial",
18
+ rendersAs: "plain fence; `dogsbay-code` block (lang/file/highlight/annotations header) when it carries a title, highlights or annotations",
19
+ note: "Faithful at top level and one container deep. Nested two or more containers deep (tabs/steps/deflist) it becomes a 4-space indented code block: language, title, highlights and annotations are lost.",
20
+ },
21
+ { feature: "math-block", support: "full", rendersAs: "`$$ … $$` (native Obsidian MathJax)" },
22
+ { feature: "deflist", support: "full", rendersAs: "`dogsbay-deflist` block (plugin renders a `<dl>`; definition bodies are full block markdown)" },
23
+ {
24
+ feature: "figure",
25
+ support: "partial",
26
+ rendersAs: "the image, then the caption as an italic paragraph",
27
+ note: "No figure/figcaption semantics; the caption is a separate paragraph.",
28
+ },
29
+ { feature: "footnote-list", support: "full", rendersAs: "`[^label]: …` definitions (native Obsidian footnotes)" },
30
+ {
31
+ feature: "html",
32
+ support: "partial",
33
+ rendersAs: "raw HTML passed through (`/_assets/` src/href made vault-relative)",
34
+ note: "Obsidian's reading-view sanitizer strips scripts, `style`, `class`, `data-*` and most attributes; layout-only markup does nothing. Markdown inside the HTML block is not rendered.",
35
+ },
36
+ {
37
+ feature: "html-container",
38
+ support: "partial",
39
+ rendersAs: "its HTML (Obsidian sanitizes it), or its children in place",
40
+ note: "A children-only container's own markup (tag, class) is dropped; the content is kept.",
41
+ },
42
+ { feature: "diagram", support: "full", rendersAs: "```mermaid fence (native Obsidian Mermaid)" },
43
+ {
44
+ feature: "youtube",
45
+ support: "partial",
46
+ rendersAs: "thumbnail image linking to youtube.com/watch",
47
+ note: "Not an embedded player: the video opens in a browser.",
48
+ },
49
+ // ── Components ───────────────────────────────────────────
50
+ {
51
+ feature: "callout",
52
+ support: "partial",
53
+ rendersAs: "Obsidian callout `> [!variant] Title`",
54
+ note: "Variant names pass through verbatim; one Obsidian does not know renders as a note. A custom `icon` is dropped.",
55
+ },
56
+ { feature: "details", support: "full", rendersAs: "foldable callout `> [!variant]- Title` (`+` when open)" },
57
+ { feature: "details-sheet", support: "partial", rendersAs: "a normal collapsible block", note: "Obsidian has no side-sheet component: a `sheet` details is written as an ordinary collapsible block, content intact." },
58
+ { feature: "theme", support: "partial", rendersAs: "the content, unthemed", note: "Obsidian has no scoped themes: the wrapper is dropped and the content kept, in the page's own theme." },
59
+ { feature: "tabs-variant", support: "partial", rendersAs: "the default tabs", note: "Obsidian draws one tab style: a pills or underline variant shows as the default." },
60
+ { feature: "tone", support: "partial", rendersAs: "untinted cards", note: "Obsidian cards take no tone: the colour is lost, the content kept." },
61
+ { feature: "tabs", support: "full", rendersAs: "`dogsbay-tabs` block (plugin renders tabs; fence characters alternate by nesting depth)" },
62
+ { feature: "steps", support: "full", rendersAs: "`dogsbay-steps` block (plugin renders numbered steps with titles)" },
63
+ {
64
+ feature: "accordion",
65
+ support: "partial",
66
+ rendersAs: "one collapsed foldable callout per item, `> [!note]- Label`",
67
+ note: "Obsidian has no accordion: items fold independently, so opening one does not close the others, and a `defaultValue` is not applied.",
68
+ },
69
+ {
70
+ feature: "cards",
71
+ support: "partial",
72
+ rendersAs: "each card as its own `dogsbay-card` block, stacked",
73
+ note: "No grid container: the column layout is lost.",
74
+ },
75
+ {
76
+ feature: "card",
77
+ support: "partial",
78
+ rendersAs: "`dogsbay-card` block (title, href with `.md`, icon, body)",
79
+ note: "An icon that is a registry NAME (`open-book`, `discord`) is dropped — the vault has no icon registry; image-path and emoji icons are kept.",
80
+ },
81
+ {
82
+ feature: "link-card",
83
+ support: "partial",
84
+ rendersAs: "`dogsbay-card` block (title, href, description as the body)",
85
+ note: "Rendered as a card by the dogsbay-docs plugin; the link-card's compact styling is not distinct from a card's.",
86
+ },
87
+ {
88
+ feature: "files",
89
+ support: "partial",
90
+ rendersAs: "the nested list",
91
+ note: "No file-tree view: folders and files are a nested bulleted list.",
92
+ },
93
+ {
94
+ feature: "grid",
95
+ support: "partial",
96
+ rendersAs: "its children stacked (cards as `dogsbay-card` blocks)",
97
+ note: "No grid container: the column layout is lost.",
98
+ },
99
+ {
100
+ feature: "link-button",
101
+ support: "partial",
102
+ rendersAs: "`dogsbay-link-button` block (plugin renders the button with its variant)",
103
+ note: "A button is a block in the vault: one written inline in a sentence stands on its own line. An unsafe href leaves the label as plain text.",
104
+ },
105
+ { feature: "related", support: "full", rendersAs: "bold label + the link list" },
106
+ {
107
+ feature: "example",
108
+ support: "partial",
109
+ rendersAs: "the rendered example content",
110
+ note: "No case: the fallthrough renders children only. The example's frame and its `source` (the Markdown shown alongside the result) are dropped.",
111
+ },
112
+ {
113
+ feature: "container",
114
+ support: "partial",
115
+ rendersAs: "its children in place",
116
+ note: "No case: the container's name and title (`props.title` / `meta.title`) are dropped; only the body survives.",
117
+ },
118
+ { feature: "annotation-list", support: "full", rendersAs: "its children; the annotations also ride in the `dogsbay-code` header" },
119
+ // ── API reference ────────────────────────────────────────
120
+ {
121
+ feature: "endpoint",
122
+ support: "partial",
123
+ rendersAs: "`### METHOD path` heading, summary, description, Markdown tables for parameters / request body / responses, folded `[!example]` callouts for samples and examples",
124
+ note: "Static: no try-it, no response-tab switching. Spec descriptions are neutralized (their Markdown headings become bold lines); nested schema properties flatten to dotted rows.",
125
+ },
126
+ {
127
+ feature: "api-doc",
128
+ support: "partial",
129
+ rendersAs: "the doc HTML converted to Markdown",
130
+ note: "Inline tags become Markdown and the rest is stripped (flatten mode): block structure inside the docstring HTML (lists, tables) is flattened.",
131
+ },
132
+ { feature: "api-class", support: "full", rendersAs: "`### kind \\`name\\``, `Bases:` line, signature in a python fence, children" },
133
+ { feature: "api-member", support: "full", rendersAs: "`#### kind \\`name\\``, signature in a python fence, children" },
134
+ { feature: "api-params", support: "full", rendersAs: "HTML table (name, description, TYPE / DEFAULT / REQUIRED meta)" },
135
+ { feature: "api-source", support: "full", rendersAs: "`*Source: file:line*` + the source in a fence" },
136
+ // ── Inline ───────────────────────────────────────────────
137
+ {
138
+ feature: "link",
139
+ support: "full",
140
+ rendersAs: "`[text](vault/path#^block-id)` — site paths made vault-relative, anchors as block-id refs",
141
+ note: "An unsafe scheme keeps the text and drops the target (not recorded).",
142
+ },
143
+ {
144
+ feature: "image",
145
+ support: "partial",
146
+ rendersAs: "`![alt](_assets/…)` (site root stripped)",
147
+ note: "The image `title` is dropped; an unsafe source leaves only the alt text.",
148
+ },
149
+ { feature: "kbd", support: "full", rendersAs: "`<kbd>Ctrl</kbd>+<kbd>S</kbd>` (Obsidian keeps `<kbd>`)" },
150
+ { feature: "math", support: "full", rendersAs: "`$…$`" },
151
+ { feature: "highlight", support: "full", rendersAs: "`==text==`" },
152
+ {
153
+ feature: "badge",
154
+ support: "partial",
155
+ rendersAs: "the badge text as plain text",
156
+ note: "No inline emitter: the shared walk's fallback writes the text and its report goes nowhere. Variant/styling lost — `Beta` reads as a word in the sentence.",
157
+ },
158
+ {
159
+ feature: "icon",
160
+ support: "partial",
161
+ rendersAs: "`:name:` shortcode text",
162
+ note: "Obsidian does not render emoji/icon shortcodes: the reader sees the literal `:name:`.",
163
+ },
164
+ { feature: "footnote-ref", support: "full", rendersAs: "`[^label]`" },
165
+ {
166
+ feature: "html-inline",
167
+ support: "partial",
168
+ rendersAs: "raw inline HTML passed through",
169
+ note: "Obsidian's sanitizer strips attributes and most tags in reading view; `<kbd>`, `<b>`, `<i>` and similar survive.",
170
+ },
171
+ ];
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  import type { FormatPlugin } from "@dogsbay/types";
2
2
  export declare const plugin: FormatPlugin;
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js CHANGED
@@ -1,17 +1,23 @@
1
- import { existsSync, mkdirSync, writeFileSync, cpSync, readdirSync, statSync } from "node:fs";
2
- import { join, dirname, resolve, relative } from "node:path";
1
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, cpSync, statSync, copyFileSync } from "node:fs";
2
+ import { join, dirname, resolve, relative, isAbsolute } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { exportObsidianVault } from "./project.js";
5
+ import { mountCopies, assetsReferenced, assetCopies } from "@dogsbay/corpus";
6
+ import { readFolder } from "@dogsbay/corpus/folder";
7
+ const IMAGE_EXTS = new Set([".png", ".jpg", ".jpeg", ".gif", ".svg", ".webp"]);
8
+ import { OBSIDIAN_CAPABILITIES } from "./capabilities.js";
5
9
  const PLUGIN_ID = "dogsbay-docs";
6
10
  export const plugin = {
7
11
  name: "obsidian",
8
12
  canImport: false,
9
13
  canExport: true,
14
+ capabilities: OBSIDIAN_CAPABILITIES,
10
15
  detectSource: (path) => existsSync(join(path, ".obsidian")),
11
16
  importOptions: [],
12
17
  exportOptions: [
13
- { flags: "--tabs <mode>", description: "Tab handling: dogsbay-tabs (default) or flatten", default: "dogsbay-tabs" },
18
+ { flags: "--assets <mode>", description: "Asset files: used (only what the notes refer to, default) or all (every file the importer mounted)", default: "used" },
14
19
  { flags: "--plugin <mode>", description: "Plugin setup: bundled (copy into vault), registry (list only), none", default: "bundled" },
20
+ { flags: "--graph-groups <path>", description: "JSON file of graph-view colour groups: [{ \"query\": \"path:guides\", \"color\": \"#F2B36F\" }]. Replaces the default hub group. Ignored if the vault already has a graph.json" },
15
21
  ],
16
22
  async export(pages, nav, output, opts) {
17
23
  const pluginMode = opts.plugin ?? "bundled";
@@ -26,10 +32,72 @@ export const plugin = {
26
32
  writeFileSync(fullPath, content);
27
33
  }
28
34
  console.log(`Generated ${result.files.size} vault files`);
29
- // Copy images from source docs directory into vault
35
+ // Mounted asset dirs (a Starlight `src/assets`, a Docusaurus `static/`), copied to where the
36
+ // `/_assets/…` refs importers rewrite image paths to point. Without this the vault carried the
37
+ // reference and not the file. Each mount is read through @dogsbay/corpus's contained reader
38
+ // (a symlink out of it, `node_modules` and `.git` are not copied — cpSync copied links to
39
+ // anywhere) and listed by the same rules as the Dogsbay MD export (`mountCopies`). By default
40
+ // only what a note refers to is copied: a whole Docusaurus `static/` brought other products'
41
+ // images and the site's `_headers`/`_redirects` (Tigera: 149 MB copied, 38 MB used).
42
+ const mounts = opts.assetMounts ?? [];
43
+ const assetsMode = opts.assets ?? "used";
44
+ if (assetsMode !== "used" && assetsMode !== "all")
45
+ throw new Error(`--assets must be used or all (got ${JSON.stringify(assetsMode)})`);
46
+ const copies = [];
47
+ for (const mount of mounts) {
48
+ if (!existsSync(mount.dir))
49
+ continue;
50
+ const folder = readFolder(mount.dir);
51
+ for (const c of mountCopies(folder.paths, [{ ...mount, dir: "" }]))
52
+ copies.push({ from: folder.absolute(c.from), to: c.to });
53
+ }
54
+ const roots = [...new Set(mounts.map((m) => m.root ?? "_assets"))];
55
+ const notes = [...result.files.values()].filter((v) => typeof v === "string");
56
+ // The same rules as Docusaurus's browser import (@dogsbay/corpus): references in every
57
+ // spelling, the last mount wins a path, an HTML file brings its folder, a note wins its path
58
+ const used = assetsMode === "all" ? undefined : assetsReferenced(notes, new Set(copies.map((c) => c.to)), roots);
59
+ const chosen = assetCopies(copies, new Set(result.files.keys()), used, roots.flatMap((r) => [`${r}/`, `${r}/pages/`]));
60
+ const written = new Set();
61
+ const outside = [];
62
+ let bytes = 0;
63
+ for (const { from, to } of chosen) {
64
+ // never outside the vault (a mount's `into`/`root` from an importer)
65
+ const dest = resolve(output, to);
66
+ const rel = relative(resolve(output), dest);
67
+ if (!rel || rel.startsWith("..") || isAbsolute(rel)) {
68
+ outside.push(to);
69
+ continue;
70
+ }
71
+ mkdirSync(dirname(dest), { recursive: true });
72
+ copyFileSync(from, dest);
73
+ written.add(to);
74
+ bytes += statSync(dest).size;
75
+ }
76
+ if (outside.length)
77
+ console.warn(` skipped ${outside.length} asset path(s) outside the vault, e.g. ${JSON.stringify(outside[0])}`);
78
+ const seen = written;
79
+ if (copies.length) {
80
+ console.log(assetsMode === "all"
81
+ ? `Copied ${seen.size} asset file(s) (${(bytes / 1e6).toFixed(1)} MB)`
82
+ : `Copied ${seen.size} of ${copies.length} asset file(s) the notes refer to (${(bytes / 1e6).toFixed(1)} MB); --assets all copies every file`);
83
+ }
84
+ // Co-located images from the source docs directory (the mkdocs shape, where media sits next
85
+ // to the markdown rather than in its own tree): read contained too, at the same place.
30
86
  const sourceDir = opts.sourceDir;
31
- if (sourceDir) {
32
- copyImages(sourceDir, output);
87
+ if (sourceDir && existsSync(sourceDir)) {
88
+ const folder = readFolder(sourceDir);
89
+ let count = 0;
90
+ for (const path of folder.paths) {
91
+ const dot = path.lastIndexOf(".");
92
+ if (dot === -1 || !IMAGE_EXTS.has(path.slice(dot).toLowerCase()))
93
+ continue;
94
+ const dest = join(output, path);
95
+ mkdirSync(dirname(dest), { recursive: true });
96
+ copyFileSync(folder.absolute(path), dest);
97
+ count++;
98
+ }
99
+ if (count > 0)
100
+ console.log(`Copied ${count} images into vault`);
33
101
  }
34
102
  // Set up plugin
35
103
  if (pluginMode === "bundled") {
@@ -38,8 +106,8 @@ export const plugin = {
38
106
  else if (pluginMode === "registry") {
39
107
  installRegistryRef(output);
40
108
  }
41
- // Pre-configure Front Matter Title plugin (graph view shows title, not filename)
42
- installFrontMatterTitleConfig(output);
109
+ // Pre-configure graph view: colour groups + forces tuned for a docs vault
110
+ installGraphConfig(output, opts.graphGroups);
43
111
  },
44
112
  };
45
113
  /**
@@ -72,12 +140,17 @@ function installBundledPlugin(vaultDir) {
72
140
  * Write .obsidian/community-plugins.json listing the plugin.
73
141
  * Obsidian will prompt the user to install it from the registry.
74
142
  */
75
- /** Recommended community plugins — listed so Obsidian prompts to install them */
76
- const FRONT_MATTER_TITLE_ID = "obsidian-front-matter-title-plugin";
77
- const RECOMMENDED_PLUGINS = [
78
- PLUGIN_ID,
79
- FRONT_MATTER_TITLE_ID, // Shows frontmatter title in graph view instead of filename
80
- ];
143
+ /**
144
+ * Plugins listed in community-plugins.json.
145
+ *
146
+ * Only plugins the vault actually SHIPS belong here. Listing one we don't
147
+ * bundle made Obsidian report it as enabled while nothing loaded — the vault
148
+ * carried a data.json for Front Matter Title and no plugin, so graph labels
149
+ * silently fell back to filenames. Section notes are named `_<folder>.md` for
150
+ * exactly that reason, and readers who want frontmatter titles everywhere can
151
+ * install Front Matter Title themselves (see docs/obsidian-vaults.md).
152
+ */
153
+ const RECOMMENDED_PLUGINS = [PLUGIN_ID];
81
154
  function installRegistryRef(vaultDir) {
82
155
  const obsidianDir = join(vaultDir, ".obsidian");
83
156
  mkdirSync(obsidianDir, { recursive: true });
@@ -85,56 +158,84 @@ function installRegistryRef(vaultDir) {
85
158
  console.log(`Listed plugins in community-plugins.json: ${RECOMMENDED_PLUGINS.join(", ")}`);
86
159
  }
87
160
  /**
88
- * Pre-configure Front Matter Title plugin so graph view shows titles.
89
- * User still needs to install the plugin from community browser,
90
- * but the settings will be ready when they do.
91
- */
92
- function installFrontMatterTitleConfig(vaultDir) {
93
- const configDir = join(vaultDir, ".obsidian", "plugins", FRONT_MATTER_TITLE_ID);
94
- mkdirSync(configDir, { recursive: true });
95
- const settings = {
96
- templates: {
97
- common: { main: "title", fallback: "fallback_title" },
98
- },
99
- features: {
100
- graph: { enabled: true, templates: { main: "", fallback: "" } },
101
- explorer: { enabled: true, templates: { main: "", fallback: "" } },
102
- tab: { enabled: true, templates: { main: "", fallback: "" } },
103
- },
104
- };
105
- writeFileSync(join(configDir, "data.json"), JSON.stringify(settings, null, 2) + "\n");
106
- }
107
- /**
108
- * Copy images from source docs directory into the vault root.
109
- * Image paths in markdown (e.g. /img/foo.png) become relative vault paths.
161
+ * Read `--graph-groups <path>`: `[{ "query": "path:guides", "color": "#F2B36F" }]`.
162
+ *
163
+ * Colours are accepted as `#RRGGBB`, `RRGGBB`, or a raw number, and converted
164
+ * to the decimal int Obsidian stores — asking an author to write `15905647`
165
+ * would be a needless papercut.
166
+ *
167
+ * Throws on a malformed file rather than silently shipping the default: a
168
+ * caller who passed the flag wants THEIR groups, and a quiet fallback would
169
+ * look like the flag being ignored.
110
170
  */
111
- function copyImages(sourceDir, vaultDir) {
112
- const imageExts = new Set([".png", ".jpg", ".jpeg", ".gif", ".svg", ".webp"]);
113
- let count = 0;
114
- function walk(dir) {
115
- for (const entry of readdirSync(dir)) {
116
- const full = join(dir, entry);
117
- if (statSync(full).isDirectory()) {
118
- walk(full);
119
- }
120
- else {
121
- const ext = entry.substring(entry.lastIndexOf(".")).toLowerCase();
122
- if (imageExts.has(ext)) {
123
- const rel = relative(sourceDir, full);
124
- const dest = join(vaultDir, rel);
125
- mkdirSync(dirname(dest), { recursive: true });
126
- cpSync(full, dest);
127
- count++;
128
- }
129
- }
130
- }
131
- }
171
+ function readGraphGroups(path) {
172
+ let raw;
132
173
  try {
133
- walk(sourceDir);
174
+ raw = JSON.parse(readFileSync(path, "utf8"));
175
+ }
176
+ catch (err) {
177
+ throw new Error(`--graph-groups: could not parse ${path} as JSON: ${err.message}`);
134
178
  }
135
- catch { /* source may not exist */ }
136
- if (count > 0)
137
- console.log(`Copied ${count} images into vault`);
179
+ if (!Array.isArray(raw)) {
180
+ throw new Error(`--graph-groups: ${path} must contain a JSON array of { query, color }`);
181
+ }
182
+ return raw.map((entry, i) => {
183
+ const g = entry;
184
+ if (!g || typeof g.query !== "string" || !g.query) {
185
+ throw new Error(`--graph-groups: entry ${i} needs a non-empty "query" string`);
186
+ }
187
+ let rgb;
188
+ if (typeof g.color === "number") {
189
+ rgb = g.color;
190
+ }
191
+ else if (typeof g.color === "string") {
192
+ const hex = g.color.replace(/^#/, "");
193
+ if (!/^[0-9a-fA-F]{6}$/.test(hex)) {
194
+ throw new Error(`--graph-groups: entry ${i} colour "${g.color}" is not #RRGGBB`);
195
+ }
196
+ rgb = parseInt(hex, 16);
197
+ }
198
+ else {
199
+ throw new Error(`--graph-groups: entry ${i} needs a "color" (#RRGGBB or a number)`);
200
+ }
201
+ return { query: g.query, color: { a: 1, rgb } };
202
+ });
203
+ }
204
+ function installGraphConfig(vaultDir, groupsPath) {
205
+ const obsidianDir = join(vaultDir, ".obsidian");
206
+ const graphPath = join(obsidianDir, "graph.json");
207
+ if (existsSync(graphPath))
208
+ return; // the reader's own view state — leave it
209
+ const colorGroups = groupsPath
210
+ ? readGraphGroups(groupsPath)
211
+ : // Default: only the group that is true of EVERY Dogsbay vault. Anything
212
+ // corpus-specific (a genre axis, a per-book split) belongs to whoever
213
+ // knows the corpus — pass --graph-groups for those.
214
+ [{ query: "file:/^_/", color: { a: 1, rgb: 0xf2b3_6f } }];
215
+ mkdirSync(obsidianDir, { recursive: true });
216
+ writeFileSync(graphPath, JSON.stringify({
217
+ "collapse-filter": false,
218
+ search: "",
219
+ showTags: false,
220
+ showAttachments: false,
221
+ hideUnresolved: true, // unresolved links are noise, not nodes
222
+ showOrphans: true,
223
+ "collapse-color-groups": false,
224
+ colorGroups,
225
+ "collapse-display": true,
226
+ showArrow: true, // direction matters when hubs point outward
227
+ textFadeMultiplier: -1.5, // labels only when zoomed in; a docs vault is dense
228
+ nodeSizeMultiplier: 0.9,
229
+ lineSizeMultiplier: 0.7,
230
+ "collapse-forces": true,
231
+ centerStrength: 0.5,
232
+ repelStrength: 7, // below the default 10 — let clusters tighten
233
+ linkStrength: 1,
234
+ linkDistance: 180,
235
+ scale: 1,
236
+ close: false,
237
+ }, null, 2) + "\n");
238
+ console.log("Pre-configured graph view (.obsidian/graph.json)");
138
239
  }
139
240
  /**
140
241
  * Find the built plugin dist directory.
@@ -158,4 +259,3 @@ function resolvePluginDist() {
158
259
  }
159
260
  return null;
160
261
  }
161
- //# sourceMappingURL=cli.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { treeToObsidian } from "./serialize.js";
2
2
  export { exportObsidianVault } from "./project.js";
3
+ export { OBSIDIAN_CAPABILITIES } from "./capabilities.js";
3
4
  export type { ObsidianVaultOptions, ObsidianVaultExport } from "./project.js";
4
5
  export type { TreeNode, InlineNode, ExportPage, NavItem } from "@dogsbay/types";
5
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Obsidian format plugin — serialize (tree → Obsidian markdown) + vault export
2
2
  export { treeToObsidian } from "./serialize.js";
3
3
  export { exportObsidianVault } from "./project.js";
4
- //# sourceMappingURL=index.js.map
4
+ export { OBSIDIAN_CAPABILITIES } from "./capabilities.js";
package/dist/project.d.ts CHANGED
@@ -2,21 +2,67 @@
2
2
  * Obsidian vault exporter.
3
3
  *
4
4
  * Takes ExportPage[] + NavItem[] and generates a complete Obsidian vault
5
- * with folder structure from nav, sidebar_position frontmatter, _index.md
5
+ * with folder structure from nav, sidebar_position frontmatter, folder notes
6
6
  * per section, and _nav.yml for lossless round-trip.
7
7
  */
8
8
  import type { ExportPage, NavItem } from "@dogsbay/types";
9
9
  export interface ObsidianVaultOptions {
10
10
  vaultName?: string;
11
- assetsDir?: string;
12
11
  /** Section name — pages go under this subfolder, nav gets a top-level entry */
13
12
  section?: string;
13
+ /**
14
+ * Emit a `_<folder>.md` folder note per nav section (default `true`).
15
+ *
16
+ * These are **invented by this exporter** — no source format supplies them,
17
+ * and they do not appear in `_nav.yml` (a section is a label-only nav entry
18
+ * with no path), so the folder note is the only thing that makes a section
19
+ * addressable at all.
20
+ *
21
+ * Measured on the OpenShift 4.22 vault (2,105 notes), they are load-bearing
22
+ * once populated — they carry the nav as real links, and are the sole
23
+ * inbound link for ~470 content pages that no prose links to:
24
+ *
25
+ * | | notes | edges | no inbound | isolated |
26
+ * |---|---|---|---|---|
27
+ * | with, populated | 2,105 | 6,954 | 44 | 0 |
28
+ * | without | 1,796 | 4,893 | 523 | 278 |
29
+ *
30
+ * Set `false` for a vault that mirrors the source exactly — at the cost of
31
+ * the folder-click affordance and the nav-as-links layer.
32
+ */
33
+ sectionIndexes?: boolean;
34
+ /**
35
+ * Give every folder note a body listing its children (default `true`).
36
+ * Ignored when `sectionIndexes` is `false`.
37
+ *
38
+ * Without it a section index is frontmatter and nothing else: clicking a
39
+ * folder in Obsidian yields a title and white space, and the note has no
40
+ * outbound links, so it sits outside the graph. On the OpenShift 4.22 export
41
+ * that was 309 of 309 section indexes with zero links — the entire outer
42
+ * ring of orphans in the graph view.
43
+ *
44
+ * The listing is ordinary markdown links, so it also feeds backlinks, the
45
+ * local graph, and any consumer that reads links rather than a nav file.
46
+ *
47
+ * Set `false` to keep the frontmatter-only stubs (previous behaviour).
48
+ */
49
+ sectionIndexLinks?: boolean;
14
50
  }
15
51
  export interface ObsidianVaultExport {
16
52
  files: Map<string, string>;
17
53
  }
54
+ /**
55
+ * Path of a section's folder note.
56
+ *
57
+ * Named `_<folder>.md`, not `_index.md`: Obsidian labels graph nodes and tabs
58
+ * by FILENAME, so a vault of 309 sections showed 309 identical `_index` nodes.
59
+ * The leading underscore keeps the note sorted to the top of its folder and
60
+ * distinguishes it from a content page that shares the folder's name — 20
61
+ * sections in the OpenShift corpus contain `<folder>/<folder>.md`, so the bare
62
+ * folder name would collide. No page in that corpus starts with `_`.
63
+ */
64
+ export declare function sectionNotePath(folderPath: string): string;
18
65
  /**
19
66
  * Export pages + nav to an Obsidian vault file map.
20
67
  */
21
68
  export declare function exportObsidianVault(pages: ExportPage[], nav: NavItem[], options?: ObsidianVaultOptions): ObsidianVaultExport;
22
- //# sourceMappingURL=project.d.ts.map