Dianel555/DSkills / skills/agent-wiki
agent-wiki
UnverifiedIncremental LLM-friendly wiki generator for Obsidian note vaults. Use when: (1) Building wiki from notes, (2) Ingesting notes to wiki, (3) Obsidian LLM wiki, (4) Incremental knowledge base management. Triggers: 'build wiki from notes', 'ingest notes to wiki', 'Obsidian LLM wiki', 'incremental knowledge base'.
scripts/agent_wiki/authors.py
View on GitHub"""Extract and aggregate paper authors from topic sources (read-only).
Drives the batched authors backfill: ``extract`` resolves each topic's
``sources`` to the root-level source notes and pulls the ``作者:`` row from each
note's metadata table; ``aggregate`` deduplicates the first author per paper into
a per-topic list the Agent can write into frontmatter. Neither modifies files.
"""
from __future__ import annotations
import re
from pathlib import Path
from typing import Any
from . import boundary, config, frontmatter
from .config import nfc as _nfc
_AUTHOR_RE = re.compile(r"作者[::]\s*(.+)")
_FIELD_BREAK = re.compile(r"\s*(期刊|DOI|标签|摘要)[::]")
_TAG_RE = re.compile(r"<[^>]+>")
def _root_notes(vault: Path) -> dict[str, Path]:
# Root-level source notes only (wiki/ and attachments/ are subdirectories).
# Links are not source notes: their target is outside the vault.
boundary.bind(vault)
try:
entries = boundary.entries(vault, ".md")
except boundary.BoundaryError:
return {}
return {_nfc(entry.name): entry.path for entry in entries}
def _resolve(src: str, root_by_norm: dict[str, Path]) -> Path | None:
name = _nfc(src)
if name in root_by_norm:
return root_by_norm[name]
# sources[] entries may be truncated mid-title; match by longest common prefix.
stem = name[:-3] if name.endswith(".md") else name
pref = stem[:60]
best: tuple[str, Path] | None = None
for norm, path in root_by_norm.items():
cand = norm[:-3] if norm.endswith(".md") else norm
if (cand.startswith(pref) or stem.startswith(cand[:60])) and (best is None or len(cand) < len(best[0])):
best = (cand, path)
return best[1] if best else None
def _authors_row(path: Path) -> str:
text = boundary.read_text(path, encoding="utf-8", errors="replace")
for line in text.splitlines():
if "作者" in line and "|" in line:
plain = _TAG_RE.sub("", line).replace("|", " ").strip()
match = _AUTHOR_RE.search(plain)
if match:
return _FIELD_BREAK.split(match.group(1).strip())[0].strip()
return ""
def extract(vault: str | Path) -> dict[str, list[dict[str, Any]]]:
"""Per-topic raw author strings resolved from each source note."""
boundary.bind(vault)
vault = Path(vault)
boundary.bind(vault)
root_by_norm = _root_notes(vault)
out: dict[str, list[dict[str, Any]]] = {}
try:
topics = boundary.entries(config.topics_dir(vault), ".md")
except boundary.BoundaryError:
# The topics directory is a link: there is nothing inside the vault to extract.
return {}
for entry in topics:
try:
text = entry.read_text(encoding="utf-8-sig")
except (UnicodeDecodeError, OSError):
continue
meta, _ = frontmatter.parse(text)
entries: list[dict[str, Any]] = []
for src in meta.get("sources") or []:
resolved = _resolve(str(src), root_by_norm)
entries.append({
"src": str(src)[:40],
"file": resolved.name[:40] if resolved else None,
"authors": _authors_row(resolved) if resolved else "",
})
out[_nfc(entry.name)] = entries
return out
def first_author(raw: str) -> str:
s = raw.lstrip("*").strip()
if not s:
return ""
first = s.split(";")[0].strip()
return first.replace("et al.", "").strip().strip(",").strip()
def aggregate(extracted: dict[str, list[dict[str, Any]]]) -> dict[str, list[str]]:
"""Deduplicated first author per topic, order preserved."""
out: dict[str, list[str]] = {}
for topic, entries in extracted.items():
seen: list[str] = []
for entry in entries:
name = first_author(entry.get("authors", ""))
if name and name not in seen:
seen.append(name)
out[topic] = seen
return out
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |