Compile a single deck from the KB's wiki via the chosen skill. Args: skill_name: Which deck skill to run. Defaults to the built-in ``openkb-deck-neon``. Pass ``"deck-guizang-editorial"`` etc. to route to a third-party skill installed under ``~/.openkb
(
*,
kb_dir: Path,
deck_name: str,
intent: str,
model: str,
critique: bool,
skill_name: str = DEFAULT_DECK_SKILL,
)
| 40 | |
| 41 | |
| 42 | async def run_deck_create( |
| 43 | *, |
| 44 | kb_dir: Path, |
| 45 | deck_name: str, |
| 46 | intent: str, |
| 47 | model: str, |
| 48 | critique: bool, |
| 49 | skill_name: str = DEFAULT_DECK_SKILL, |
| 50 | ) -> SkillRunResult: |
| 51 | """Compile a single deck from the KB's wiki via the chosen skill. |
| 52 | |
| 53 | Args: |
| 54 | skill_name: Which deck skill to run. Defaults to the built-in |
| 55 | ``openkb-deck-neon``. Pass ``"deck-guizang-editorial"`` |
| 56 | etc. to route to a third-party skill installed under |
| 57 | ``~/.openkb/skills/``. |
| 58 | |
| 59 | Returns the :class:`SkillRunResult` from the producer skill (carries |
| 60 | ``output_path`` and ``validation`` populated by ``run_skill`` per |
| 61 | the skill's frontmatter contract). |
| 62 | |
| 63 | Raises ``RuntimeError`` if the skill is missing, hits the turn cap, |
| 64 | or doesn't write its declared output path. |
| 65 | |
| 66 | When ``critique=True`` the html-critic skill runs as a second pass |
| 67 | on the produced file. Missing critic skill is a soft failure (the |
| 68 | deck still ships, just unpatched). |
| 69 | """ |
| 70 | # Ensure the conventional deck dir exists. Skills that use |
| 71 | # output_path_template = "output/decks/{slug}/index.html" need this; |
| 72 | # skills that pick their own location won't be hindered. |
| 73 | deck_root = deck_dir(kb_dir, deck_name) |
| 74 | deck_root.mkdir(parents=True, exist_ok=True) |
| 75 | |
| 76 | try: |
| 77 | result = await run_skill( |
| 78 | skill_name=skill_name, |
| 79 | intent=intent, |
| 80 | kb_dir=kb_dir, |
| 81 | model=model, |
| 82 | slug=deck_name, |
| 83 | max_turns=MAX_TURNS_WITH_CRITIQUE if critique else MAX_TURNS, |
| 84 | ) |
| 85 | except SkillNotFoundError as exc: |
| 86 | raise RuntimeError( |
| 87 | f"Deck skill {skill_name!r} is not installed. " |
| 88 | f"Drop a SKILL.md into ~/.openkb/skills/{skill_name}/ (or " |
| 89 | f"<kb>/skills/{skill_name}/) and re-run." |
| 90 | ) from exc |
| 91 | |
| 92 | if critique: |
| 93 | # The producer's output_path tells the critic which file to patch. |
| 94 | # If the producer didn't template a path, fall back to the |
| 95 | # conventional location. |
| 96 | # |
| 97 | # ``result.output_path`` is already ``.resolve()``-d by run_skill; |
| 98 | # ``kb_dir`` may still hold an un-resolved form (e.g. ``/tmp/...`` |
| 99 | # on macOS where ``/tmp`` symlinks to ``/private/tmp``). Resolve |