Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: list available obsidian vault on your computer to reduce friction

Louis Beaumont13fe9d9403ba
diff --git a/pipes/obsidian/src/app/api/obsidian-paths/route.ts b/pipes/obsidian/src/app/api/obsidian-paths/route.ts
new file mode 100644
index 000000000..ae67fb81c
--- /dev/null
+++ b/pipes/obsidian/src/app/api/obsidian-paths/route.ts
@@ -0,0 +1,73 @@
+import { NextResponse } from "next/server";
+import fs from "fs/promises";
+import path from "path";
+import os from "os";
+
+async function fileExists(path: string) {
+ try {
+ await fs.access(path);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+async function readObsidianConfig(configPath: string) {
+ try {
+ const content = await fs.readFile(configPath, "utf-8");
+ return JSON.parse(content);
+ } catch {
+ return null;
+ }
+}
+
+export async function GET() {
+ const home = os.homedir();
+ const platform = os.platform();
+
+ // Define potential config locations based on OS
+ const configPaths =
+ {
+ darwin: path.join(
+ home,
+ "Library/Application Support/obsidian/obsidian.json"
+ ),
+ win32: path.join(home, "AppData/Roaming/obsidian/obsidian.json"),
+ linux: path.join(home, ".config/obsidian/obsidian.json"),
+ }[platform as "darwin" | "win32" | "linux"] || null;
+
+ // Common paths to check
+ const commonPaths = [
+ path.join(home, "Documents/Obsidian"),
+ path.join(home, "Obsidian"),
+ path.join(home, "Documents/Knowledge Base"),
+ ];
+
+ if (platform === "darwin") {
+ commonPaths.push(
+ path.join(home, "Library/Mobile Documents/iCloud~md~obsidian/Documents")
+ );
+ }
+
+ // Read actual vault paths from obsidian.json if it exists
+ let vaultPaths: string[] = [];
+ if (configPaths) {
+ const config = await readObsidianConfig(configPaths);
+ if (config?.vaults) {
+ vaultPaths = Object.values(config.vaults).map((vault: any) => vault.path);
+ }
+ }
+
+ // Check which common paths actually exist
+ const existingPaths = await Promise.all(
+ [...new Set([...vaultPaths, ...commonPaths])].map(async (p) => {
+ const exists = await fileExists(p);
+ return exists ? p : null;
+ })
+ );
+
+ return NextResponse.json({
+ paths: existingPaths.filter(Boolean),
+ configFound: Boolean(configPaths && (await fileExists(configPaths))),
+ });
+}
diff --git a/pipes/obsidian/src/components/obsidian-settings.tsx b/pipes/obsidian/src/components/obsidian-settings.tsx
index 11658bbfe..d624e5125 100644
--- a/pipes/obsidian/src/components/obsidian-settings.tsx
+++ b/pipes/obsidian/src/components/obsidian-settings.tsx
@@ -59,6 +59,7 @@ export function ObsidianSettings() {
validatedPath: null,
isChecking: false,
});
+ const [suggestedPaths, setSuggestedPaths] = useState<string[]>([]);
useEffect(() => {
if (settings?.customSettings?.obsidian?.prompt) {
@@ -66,6 +67,20 @@ export function ObsidianSettings() {
}
}, [settings?.customSettings?.obsidian?.prompt]);
+ useEffect(() => {
+ const fetchPaths = async () => {
+ try {
+ const res = await fetch("/api/obsidian-paths");
+ const data = await res.json();
+ setSuggestedPaths(data.paths);
+ } catch (err) {
+ console.warn("failed to fetch obsidian paths:", err);
+ }
+ };
+
+ fetchPaths();
+ }, []);
+
const handleSave = async (e: React.FormEvent) => {
e.preventDefault();
const formData = new FormData(e.target as HTMLFormElement);
@@ -464,6 +479,27 @@ export function ObsidianSettings() {
{pathValidation.isChecking && (
<Loader2 className="absolute right-2 top-2.5 h-4 w-4 animate-spin text-muted-foreground" />
)}
+ <div className="mt-2 flex flex-wrap gap-2">
+ {suggestedPaths.map((path) => (
+ <Badge
+ key={path}
+ variant="outline"
+ className="cursor-pointer hover:bg-muted"
+ onClick={() => {
+ const input = document.getElementById(
+ "path"
+ ) as HTMLInputElement;
+ if (input) {
+ input.value = path;
+ validatePath(path);
+ }
+ }}
+ title={path}
+ >
+ {path.split(/(\/|\\)/).pop()}
+ </Badge>
+ ))}
+ </div>
</div>
<Button
type="button"