Skip to content

Dianel555/DSkills / skills/agent-wiki

agent-wiki

Unverified

Incremental 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'.

FileKindSize
.env.exampleother408 B
README.mdmarkdown15.3 KB
SKILL.mdskill md23.3 KB
pyproject.tomlmanifest2.1 KB
references/cli-matrix.mdmarkdown5.9 KB
references/homepage.mdmarkdown6.1 KB
references/index-schema.mdmarkdown6.9 KB
references/site-export.mdmarkdown3.1 KB
references/topic-authoring.mdmarkdown5.1 KB
scripts/agent_wiki/__init__.pyscript103 B
scripts/agent_wiki/authors.pyscript3.9 KB
scripts/agent_wiki/bases.pyscript4.0 KB
scripts/agent_wiki/batch.pyscript3.7 KB
scripts/agent_wiki/boundary.pyscript55.8 KB
scripts/agent_wiki/cache.pyscript5.5 KB
scripts/agent_wiki/canvas.pyscript8.0 KB
scripts/agent_wiki/cleanup.pyscript2.4 KB
scripts/agent_wiki/cli.pyscript97 B
scripts/agent_wiki/commands.pyscript28.3 KB
scripts/agent_wiki/config.pyscript4.2 KB
scripts/agent_wiki/coverage.pyscript2.1 KB
scripts/agent_wiki/frontmatter.pyscript1.6 KB
scripts/agent_wiki/home.pyscript7.9 KB
scripts/agent_wiki/keywords.pyscript2.0 KB
scripts/agent_wiki/links.pyscript14.7 KB
scripts/agent_wiki/plugins.pyscript2.1 KB
scripts/agent_wiki/quality.pyscript7.6 KB
scripts/agent_wiki/scanner.pyscript6.7 KB
scripts/agent_wiki/site.pyscript39.2 KB
scripts/agent_wiki/source_type.pyscript3.2 KB
scripts/agent_wiki/wiki_index.pyscript17.4 KB
scripts/agent_wiki/worklist.pyscript5.7 KB
scripts/agent_wiki_cli.pyscript5.5 KB
templates/home/academic.mdmarkdown2.9 KB
templates/home/dashboard.mdmarkdown2.7 KB
templates/home/magazine.mdmarkdown2.5 KB
templates/query/research.mdmarkdown787 B
tests/conftest.pyscript177 B
tests/fixtures/sample_vault/attachments/image.pngbinary26 B
tests/fixtures/sample_vault/课程/双缝实验.mdmarkdown47 B
tests/fixtures/sample_vault/课程/量子力学.mdmarkdown75 B
tests/test_alias_resolution.pyscript7.5 KB
tests/test_authors.pyscript2.2 KB
tests/test_backlinks.pyscript7.0 KB
tests/test_bases.pyscript4.7 KB
tests/test_batch.pyscript3.0 KB
tests/test_benchmark_index.pyscript2.1 KB
tests/test_boundary_platform.pyscript695 B
tests/test_cache.pyscript2.1 KB
tests/test_cache_strict.pyscript2.1 KB
tests/test_canvas.pyscript8.3 KB
tests/test_capture.pyscript5.5 KB
tests/test_cleanup.pyscript1.2 KB
tests/test_cleanup_init_strict.pyscript2.1 KB
tests/test_cli.pyscript6.2 KB
tests/test_config.pyscript2.0 KB
tests/test_coverage.pyscript7.2 KB
tests/test_e2e.pyscript2.5 KB
tests/test_evaluate_enhancements.pyscript14.7 KB
tests/test_featured_base.pyscript4.3 KB
tests/test_final_security_review.pyscript6.6 KB
tests/test_frontmatter.pyscript1.1 KB
tests/test_gen_home.pyscript4.9 KB
tests/test_gen_site_cli.pyscript3.9 KB
tests/test_home.pyscript7.7 KB
tests/test_immutability.pyscript1.4 KB
tests/test_immutability_capture.pyscript2.4 KB
tests/test_index_capture.pyscript4.5 KB
tests/test_index_cli.pyscript5.4 KB
tests/test_index_extension.pyscript17.0 KB
tests/test_index_source_count.pyscript3.0 KB
tests/test_package_structure.pyscript3.4 KB
tests/test_plugins.pyscript3.1 KB
tests/test_quality.pyscript21.3 KB
tests/test_quality_cli.pyscript5.5 KB
tests/test_quality_prose_weight.pyscript3.8 KB
tests/test_quality_script_fairness.pyscript4.7 KB
tests/test_quality_tier_refactor.pyscript4.0 KB
tests/test_scanner.pyscript2.6 KB
tests/test_scanner_fast_path.pyscript3.5 KB
tests/test_scanner_strict.pyscript2.1 KB
tests/test_secure_temporary_writes.pyscript978 B
tests/test_site.pyscript20.2 KB
tests/test_site_import_isolation.pyscript3.9 KB
tests/test_site_slug_refactor.pyscript3.6 KB
tests/test_source_type.pyscript3.5 KB
tests/test_status_metrics.pyscript4.1 KB
tests/test_status_quality.pyscript5.3 KB
tests/test_status_worklist.pyscript3.0 KB
tests/test_structure.pyscript501 B
tests/test_topic_category.pyscript4.2 KB
tests/test_topic_path_boundary.pyscript2.2 KB
tests/test_vault_boundary.pyscript24.3 KB
tests/test_wiki_index.pyscript13.3 KB
tests/test_worklist.pyscript12.3 KB
tests/test_worklist_cli.pyscript1.9 KB

tests/test_cli.py

View on GitHub
import json
import os
import subprocess
import sys
from pathlib import Path

from agent_wiki import frontmatter

ROOT = Path(__file__).resolve().parents[1]
CLI = ROOT / "scripts" / "agent_wiki_cli.py"


def run_cli(*args, env=None):
    full_env = os.environ.copy()
    if env:
        full_env.update(env)
    return subprocess.run(
        [sys.executable, str(CLI), *args],
        text=True,
        encoding="utf-8",
        capture_output=True,
        env=full_env,
    )


def test_cli_missing_vault_returns_json_error(monkeypatch, tmp_path):
    # Create an isolated environment without vault config
    env = os.environ.copy()
    env.pop("AGENT_WIKI_VAULT", None)
    env["DOTENV_DISABLE"] = "1"  # Disable .env loading for this test

    result = subprocess.run(
        [sys.executable, str(CLI), "status"],
        text=True,
        encoding="utf-8",
        capture_output=True,
        env=env,
        cwd=tmp_path,  # Run from temp dir
    )

    assert result.returncode == 2
    assert json.loads(result.stderr)["error"] == "vault path required"


def test_cli_version():
    result = run_cli("--version")

    assert result.returncode == 0
    assert result.stdout.strip() == "agent-wiki 0.1.0"


def test_init_fresh_partial_and_idempotent(tmp_path):
    result = run_cli("init", "--vault", str(tmp_path))

    assert result.returncode == 0, result.stderr
    payload = json.loads(result.stdout)
    assert payload["status"] == "ok"
    assert (tmp_path / "wiki" / "index.md").exists()
    assert (tmp_path / "wiki" / "log.md").exists()
    assert (tmp_path / "wiki" / "topics").is_dir()

    second = run_cli("init", "--vault", str(tmp_path))
    assert json.loads(second.stdout) == {"status": "already_initialized", "created": []}


def test_cache_put_get_round_trip(tmp_path):
    (tmp_path / "note.md").write_text("hello", encoding="utf-8")
    assert run_cli("init", "--vault", str(tmp_path)).returncode == 0

    put = run_cli("cache-put", "note.md", "--topics", "topic.md, other.md ", "--vault", str(tmp_path))
    assert put.returncode == 0, put.stderr
    put_payload = json.loads(put.stdout)
    assert put_payload["ok"] is True
    assert put_payload["path"] == "note.md"

    get = run_cli("cache-get", "note.md", "--vault", str(tmp_path))
    payload = json.loads(get.stdout)
    assert payload["path"] == "note.md"
    assert payload["derived_topics"] == ["topic.md", "other.md"]


def test_scan_reports_new_modified_deleted(tmp_path):
    (tmp_path / "a.md").write_text("a", encoding="utf-8")
    run_cli("init", "--vault", str(tmp_path))
    run_cli("cache-put", "a.md", "--topics", "A.md", "--vault", str(tmp_path))
    (tmp_path / "a.md").write_text("a2", encoding="utf-8")
    (tmp_path / "中文.md").write_text("new", encoding="utf-8")

    scan = run_cli("scan", "--vault", str(tmp_path))
    payload = json.loads(scan.stdout)

    assert [item["path"] for item in payload["modified"]] == ["a.md"]
    assert [item["path"] for item in payload["new"]] == ["中文.md"]

    (tmp_path / "a.md").unlink()
    deleted = json.loads(run_cli("scan", "--vault", str(tmp_path)).stdout)
    assert deleted["deleted"] == [{"path": "a.md", "derived_topics": ["A.md"]}]


def test_cleanup_archives_orphaned_topic_and_updates_cache(tmp_path):
    (tmp_path / "a.md").write_text("a", encoding="utf-8")
    run_cli("init", "--vault", str(tmp_path))
    topic = tmp_path / "wiki" / "topics" / "A.md"
    topic.write_text(frontmatter.dump({"title": "A", "sources": ["a.md"]}, "# A\n"), encoding="utf-8")
    run_cli("cache-put", "a.md", "--topics", "A.md", "--vault", str(tmp_path))
    (tmp_path / "a.md").unlink()

    result = run_cli("cleanup", "--vault", str(tmp_path))
    payload = json.loads(result.stdout)

    assert payload["removed"] == 1
    assert payload["archived"] == 1
    assert (tmp_path / "wiki" / "_archived").exists()
    assert json.loads(run_cli("cache-get", "a.md", "--vault", str(tmp_path)).stdout)["status"] == "absent"

    second = json.loads(run_cli("cleanup", "--vault", str(tmp_path)).stdout)
    assert second["removed"] == 0
    assert second["archived"] == 0


def test_status_reports_health(tmp_path):
    run_cli("init", "--vault", str(tmp_path))
    topic = tmp_path / "wiki" / "topics" / "orphan.md"
    topic.write_text(frontmatter.dump({"sources": []}, "body"), encoding="utf-8")

    result = run_cli("status", "--vault", str(tmp_path))
    payload = json.loads(result.stdout)

    assert payload["topics_total"] == 1
    assert payload["topics_orphaned"] == 1
    assert payload["sources_tracked"] == 0
    assert "last_log_entry" in payload


def test_plan_resume_reuses_existing_state(tmp_path):
    (tmp_path / "a.md").write_text("a", encoding="utf-8")
    run_cli("init", "--vault", str(tmp_path))
    first = json.loads(run_cli("plan", "--batch-size", "5", "--vault", str(tmp_path)).stdout)
    assert first["resumed"] is False and first["total"] == 1

    resumed = json.loads(run_cli("plan", "--resume", "--vault", str(tmp_path)).stdout)
    assert resumed["resumed"] is True
    assert resumed["batches"] == first["batches"]

    (tmp_path / "wiki" / ".wiki-batch.json").unlink()
    missing = run_cli("plan", "--resume", "--vault", str(tmp_path))
    assert missing.returncode == 1
    assert json.loads(missing.stderr)["error"] == "no_existing_plan"


def test_normalize_source_type_backfills_from_sources(tmp_path):
    run_cli("init", "--vault", str(tmp_path))
    topic = tmp_path / "wiki" / "topics" / "T.md"
    topic.write_text(frontmatter.dump({"title": "T", "sources": ["paper.pdf"]}, "body"), encoding="utf-8")

    payload = json.loads(run_cli("normalize-source-type", "--vault", str(tmp_path)).stdout)
    assert payload["changed"] == [{"path": "T.md", "source_type": "pdf"}]
    assert frontmatter.parse(topic.read_text(encoding="utf-8"))[0]["source_type"] == "pdf"

    again = json.loads(run_cli("normalize-source-type", "--vault", str(tmp_path)).stdout)
    assert again["changed"] == [] and again["skipped"] == 1


def test_verbose_writes_progress_to_stderr_only(tmp_path):
    run_cli("init", "--vault", str(tmp_path))
    result = run_cli("--verbose", "scan", "--vault", str(tmp_path))
    assert result.returncode == 0
    assert "[agent-wiki]" in result.stderr
    assert json.loads(result.stdout)["stats"]["total_sources"] == 0
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: 471kUpdated Claude CodeCodexVerifiedInstall
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: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
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 availableStars: 322kUpdated Claude CodeCodexVerifiedInstall