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/batch.py
View on GitHub"""Batched ingest planning.
Splits the sources still needing ingest (scan ``new`` + ``modified``) into
fixed-size batches so the Agent processes a bounded number of documents per round
instead of loading the whole vault at once. Persists a machine-readable plan
(``wiki/.wiki-batch.json``) plus a human-readable checklist report under the
archive directory; each round is gated behind an explicit completion check.
"""
from __future__ import annotations
import json
from datetime import UTC, datetime
from pathlib import Path
from typing import Any
from . import boundary, cache, config, scanner
DEFAULT_BATCH_SIZE = 20
STATE_VERSION = 1
class BatchStateError(OSError):
pass
def _now() -> str:
return datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
def report_path(vault: str | Path) -> Path:
return config.archive_dir(vault) / "ingest-tasks.md"
def _pending_paths(vault: str | Path) -> list[str]:
classified = scanner.classify(vault, cache.load(vault))
items = classified.get("new", []) + classified.get("modified", [])
return sorted(item["path"] for item in items)
def _chunk(paths: list[str], size: int) -> list[list[str]]:
return [paths[i:i + size] for i in range(0, len(paths), size)]
def build_plan(vault: str | Path, batch_size: int) -> dict[str, Any]:
paths = _pending_paths(vault)
batches = [
{"id": index + 1, "status": "pending", "items": chunk}
for index, chunk in enumerate(_chunk(paths, batch_size))
]
return {
"version": STATE_VERSION,
"generated_at": _now(),
"batch_size": batch_size,
"total": len(paths),
"report": config.to_rel_posix(report_path(vault), vault),
"batches": batches,
}
def load_state(vault: str | Path) -> dict[str, Any] | None:
boundary.bind(vault)
path = config.batch_path(vault)
if not boundary.exists(path):
return None
try:
data = json.loads(boundary.read_text(path, encoding="utf-8"))
except (json.JSONDecodeError, OSError, UnicodeDecodeError):
return None
return data if isinstance(data, dict) else None
def save_state(vault: str | Path, data: dict[str, Any]) -> None:
boundary.bind(vault)
path = config.batch_path(vault)
try:
boundary.ensure_directory(path.parent)
boundary.write_text(path, json.dumps(data, ensure_ascii=False, indent=2) + "\n")
except OSError as exc:
raise BatchStateError(str(exc)) from exc
def render_report(state: dict[str, Any]) -> str:
lines = [
"# Ingest Task Report",
"",
f"- generated_at: {state['generated_at']}",
f"- batch_size: {state['batch_size']}",
f"- total_documents: {state['total']}",
f"- batches: {len(state['batches'])}",
"",
]
for batch in state["batches"]:
mark = "x" if batch["status"] == "done" else " "
lines.append(f"## Batch {batch['id']} ({len(batch['items'])}) [{mark}] {batch['status']}")
for item in batch["items"]:
lines.append(f"- [{mark}] {item}")
lines.append("")
return "\n".join(lines)
def write_report(vault: str | Path, state: dict[str, Any]) -> Path:
boundary.bind(vault)
path = report_path(vault)
boundary.ensure_directory(path.parent)
boundary.write_text(path, render_report(state))
return path
def is_ingested(vault: str | Path, rel: str, tracked: dict[str, Any]) -> bool:
"""A batch item counts as done only if its current content is cached."""
entry = tracked.get(config.normalize_relpath(rel))
if not entry:
return False
source = config.source_path(vault, rel)
if boundary.stat(source) is None:
return False
try:
return bool(cache.sha256_file(source) == entry.get("sha256"))
except OSError:
return False
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 |