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/cleanup.py
View on GitHub"""Cleanup operations for deleted sources."""
from __future__ import annotations
from datetime import date
from pathlib import Path
from typing import Any
from . import boundary, config, frontmatter
class TopicError(ValueError):
def __init__(self, code: str):
super().__init__(code)
self.code = code
def _read_topic(topic_path: Path) -> tuple[dict[str, Any], str, bool]:
try:
raw = boundary.read_bytes(topic_path)
has_bom = raw.startswith(b"\xef\xbb\xbf")
text = raw.decode("utf-8-sig")
except UnicodeDecodeError as exc:
raise TopicError("topic_decode_failed") from exc
try:
meta, body = frontmatter.parse(text)
except frontmatter.FrontmatterError as exc:
raise TopicError("frontmatter_parse_failed") from exc
return meta, body, has_bom
def remove_source_from_topic(topic_path: str | Path, deleted_rel: str) -> bool:
path = Path(topic_path)
meta, body, has_bom = _read_topic(path)
deleted = config.normalize_relpath(deleted_rel)
sources = [config.normalize_relpath(item) for item in meta.get("sources", [])]
meta["sources"] = [source for source in sources if source != deleted]
text = frontmatter.dump(meta, body)
if has_bom:
text = "" + text
boundary.write_text(path, text.encode("utf-8"))
return bool(meta["sources"])
def archive_topic(topic_path: str | Path, archive_dir: str | Path, today: date | str) -> Path:
"""Move the source atomically through held directories without overwriting.
Even an identical existing target is a conflict: comparing captured bytes then
unlinking the source could delete a concurrent edit. Unsupported atomic moves
and cross-filesystem moves fail closed, preserving both paths for reconciliation.
"""
source = Path(topic_path)
date_text = today.isoformat() if hasattr(today, "isoformat") else str(today)
target_dir = Path(archive_dir) / date_text
boundary.ensure_directory(target_dir)
target = target_dir / source.name
fs = boundary.fs_for(source)
try:
with fs.open_directory(source.parent) as src, fs.open_directory(target_dir) as dst:
src.move_to(source.name, dst, target.name)
except FileExistsError:
raise TopicError("archive_target_conflict") from None
except FileNotFoundError:
raise TopicError("archive_source_missing") from None
return target
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 |