Obsidian format parser: aliases, wikilinks, and tags extraction

未关闭
#604 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust
领域
backend

调研方向

Start by reading terraphim_automata/src/markdown_directives.rs and the MarkdownDirectives definition in terraphim_types, then inspect haystack configuration in terraphim_config. Use real Obsidian vault fixtures and add tests for frontmatter aliases and tags, wikilinks, inline tags, mixed syntax, and format routing. Done means all listed patterns merge into the shared struct and the obsidian configuration is accepted.

由索引模型根据 Issue 内容生成。

描述

architecture enhancement

Summary

Extend parse_markdown_directives_content() in terraphim_automata/src/markdown_directives.rs to parse Obsidian-native patterns alongside the existing Logseq synonyms:: syntax.

Current Parser

The parser handles 4 directives:

  • synonyms:: -> synonyms (Logseq property syntax)
  • type::: -> document type
  • route:: -> LLM routing config
  • priority:: -> priority score

New Patterns to Parse

1. YAML Frontmatter
---
aliases: [context management, semantic scope]
tags: [engineering, knowledge-graph]
---
  • aliases: -> treated as synonyms (same semantics as synonyms::)
  • tags: -> stored as concept categories (new field in MarkdownDirectives)
  • Supports both YAML list syntax ([a, b]) and multi-line (- a\n- b)
2. Wikilinks
Related to [[knowledge graph]] and [[ontology]] concepts.
  • Extract all [[target]] and [[target|display text]] patterns
  • Store as related concepts (new Vec<String> field in MarkdownDirectives)
  • These become edges in the rolegraph, not synonyms
3. Inline Tags
This concept is important for #engineering and #search.
  • Extract #tag patterns (excluding headings ## heading)
  • Store as categories alongside YAML frontmatter tags
  • Deduplicate with YAML tags

Parser Mode Configuration

Add a format field to haystack config:

[[roles.engineer.haystacks]]
location = "~/.config/terraphim/kg"
format = "terraphim"  # synonyms:: + type::: + route:: + priority:: (default)

[[roles.engineer.haystacks]]
location = "~/synced/pages"
format = "logseq"     # synonyms:: only

[[roles.engineer.haystacks]]
location = "~/synced/ObsidianVault"
format = "obsidian"   # aliases: + [[wikilinks]] + #tags + synonyms::

All formats output the same MarkdownDirectives struct. The obsidian format is a superset that also accepts synonyms:: (for Dataview users).

Extended Struct

pub struct MarkdownDirectives {
    pub doc_type: DocumentType,
    pub synonyms: Vec<String>,           // existing
    pub route: Option<RouteDirective>,    // existing
    pub priority: Option<u8>,            // existing
    pub categories: Vec<String>,         // NEW: from tags:/\#tag
    pub related_concepts: Vec<String>,   // NEW: from [[wikilinks]]
}

Test Plan

  • Fixture: real Obsidian vault files with YAML frontmatter, wikilinks, and tags
  • Test: aliases parsed as synonyms alongside existing synonyms:: support
  • Test: wikilinks extracted as related concepts
  • Test: tags extracted from both YAML frontmatter and inline #tags, deduplicated
  • Test: mixed format (file has both synonyms:: and aliases:) merges correctly
  • Test: obsidian format config flag routes to extended parser

Affected Crates

  • terraphim_automata (primary -- extend markdown_directives.rs)
  • terraphim_types (add categories + related_concepts to MarkdownDirectives)
  • terraphim_config (add format field to haystack config)

Estimated Effort

~4 hours

Part of

Epic #603

主要语言
Rust
星标
62
派生
5
平均合并
2 小时 27 分钟
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

terraphim/terraphim-ai 的其他 Issue

查看 terraphim/terraphim-ai 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。