- Introduced commands for exporting graph data and displaying chains from the current note. - Enhanced linting functionality with options for showing canonical hints and specifying chain traversal direction. - Added new utility functions for graph traversal and index building. - Updated settings interface to include new options for user configuration.
131 lines
4.2 KiB
TypeScript
131 lines
4.2 KiB
TypeScript
import { App, Notice, PluginSettingTab, Setting } from "obsidian";
|
|
import type MindnetCausalAssistantPlugin from "../main";
|
|
import { VocabularyLoader } from "../vocab/VocabularyLoader";
|
|
|
|
export class MindnetSettingTab extends PluginSettingTab {
|
|
plugin: MindnetCausalAssistantPlugin;
|
|
|
|
constructor(app: App, plugin: MindnetCausalAssistantPlugin) {
|
|
super(app, plugin);
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
display(): void {
|
|
const { containerEl } = this;
|
|
|
|
containerEl.empty();
|
|
|
|
containerEl.createEl("h2", { text: "Mindnet Settings" });
|
|
|
|
// Edge vocabulary path
|
|
new Setting(containerEl)
|
|
.setName("Edge vocabulary path")
|
|
.setDesc("Vault-relative path to the edge vocabulary markdown file")
|
|
.addText((text) =>
|
|
text
|
|
.setPlaceholder("_system/dictionary/edge_vocabulary.md")
|
|
.setValue(this.plugin.settings.edgeVocabularyPath)
|
|
.onChange(async (value) => {
|
|
this.plugin.settings.edgeVocabularyPath = value;
|
|
await this.plugin.saveSettings();
|
|
})
|
|
)
|
|
.addButton((button) =>
|
|
button
|
|
.setButtonText("Validate")
|
|
.setCta()
|
|
.onClick(async () => {
|
|
try {
|
|
const text = await VocabularyLoader.loadText(
|
|
this.app,
|
|
this.plugin.settings.edgeVocabularyPath
|
|
);
|
|
new Notice(
|
|
`Edge vocabulary file found (${text.length} characters)`
|
|
);
|
|
} catch (e) {
|
|
const msg = e instanceof Error ? e.message : String(e);
|
|
new Notice(
|
|
`Failed to load edge vocabulary: ${msg}`
|
|
);
|
|
}
|
|
})
|
|
);
|
|
|
|
// Graph schema path
|
|
new Setting(containerEl)
|
|
.setName("Graph schema path")
|
|
.setDesc("Vault-relative path to the graph schema markdown file")
|
|
.addText((text) =>
|
|
text
|
|
.setPlaceholder("_system/dictionary/graph_schema.md")
|
|
.setValue(this.plugin.settings.graphSchemaPath)
|
|
.onChange(async (value) => {
|
|
this.plugin.settings.graphSchemaPath = value;
|
|
await this.plugin.saveSettings();
|
|
})
|
|
);
|
|
|
|
// Strict mode toggle
|
|
new Setting(containerEl)
|
|
.setName("Strict mode")
|
|
.setDesc("Enable strict validation mode")
|
|
.addToggle((toggle) =>
|
|
toggle
|
|
.setValue(this.plugin.settings.strictMode)
|
|
.onChange(async (value) => {
|
|
this.plugin.settings.strictMode = value;
|
|
await this.plugin.saveSettings();
|
|
})
|
|
);
|
|
|
|
// Max hops number input
|
|
new Setting(containerEl)
|
|
.setName("Max hops")
|
|
.setDesc("Maximum number of hops for graph traversal")
|
|
.addText((text) =>
|
|
text
|
|
.setPlaceholder("3")
|
|
.setValue(String(this.plugin.settings.maxHops))
|
|
.onChange(async (value) => {
|
|
const numValue = parseInt(value, 10);
|
|
if (!isNaN(numValue) && numValue > 0) {
|
|
this.plugin.settings.maxHops = numValue;
|
|
await this.plugin.saveSettings();
|
|
}
|
|
})
|
|
);
|
|
|
|
// Show canonical hints toggle
|
|
new Setting(containerEl)
|
|
.setName("Show canonical hints")
|
|
.setDesc("Show INFO findings with canonical edge type resolution in lint results")
|
|
.addToggle((toggle) =>
|
|
toggle
|
|
.setValue(this.plugin.settings.showCanonicalHints)
|
|
.onChange(async (value) => {
|
|
this.plugin.settings.showCanonicalHints = value;
|
|
await this.plugin.saveSettings();
|
|
})
|
|
);
|
|
|
|
// Chain direction dropdown
|
|
new Setting(containerEl)
|
|
.setName("Chain direction")
|
|
.setDesc("Direction for chain traversal: forward, backward, or both")
|
|
.addDropdown((dropdown) =>
|
|
dropdown
|
|
.addOption("forward", "Forward")
|
|
.addOption("backward", "Backward")
|
|
.addOption("both", "Both")
|
|
.setValue(this.plugin.settings.chainDirection)
|
|
.onChange(async (value) => {
|
|
if (value === "forward" || value === "backward" || value === "both") {
|
|
this.plugin.settings.chainDirection = value;
|
|
await this.plugin.saveSettings();
|
|
}
|
|
})
|
|
);
|
|
}
|
|
}
|