A v0.3 generator instance. Args: target_type: ``"skill"`` or ``"deck"``. name: kebab-case slug; becomes the output directory name. intent: natural-language description of the desired artifact. kb_dir: KB root. model: LiteLLM model name (from KB config).
| 44 | |
| 45 | |
| 46 | class Generator: |
| 47 | """A v0.3 generator instance. |
| 48 | |
| 49 | Args: |
| 50 | target_type: ``"skill"`` or ``"deck"``. |
| 51 | name: kebab-case slug; becomes the output directory name. |
| 52 | intent: natural-language description of the desired artifact. |
| 53 | kb_dir: KB root. |
| 54 | model: LiteLLM model name (from KB config). |
| 55 | critique: (deck only) opt-in second-pass via the |
| 56 | ``openkb-html-critic`` skill which patches the produced HTML |
| 57 | in place. Ignored for ``target_type="skill"``. |
| 58 | """ |
| 59 | |
| 60 | def __init__( |
| 61 | self, |
| 62 | *, |
| 63 | target_type: TargetType, |
| 64 | name: str, |
| 65 | intent: str, |
| 66 | kb_dir: Path, |
| 67 | model: str, |
| 68 | critique: bool = False, |
| 69 | skill_name: str | None = None, |
| 70 | ) -> None: |
| 71 | """Args: |
| 72 | skill_name: For ``target_type="deck"``, which deck skill to use. |
| 73 | Defaults to :data:`openkb.deck.creator.DEFAULT_DECK_SKILL` |
| 74 | (``"openkb-deck-neon"``). Ignored for skill target. |
| 75 | """ |
| 76 | if target_type not in ("skill", "deck"): |
| 77 | raise ValueError( |
| 78 | f"Unknown target_type {target_type!r}. v0.3 supports 'skill' and 'deck'." |
| 79 | ) |
| 80 | self.target_type: TargetType = target_type |
| 81 | self.name = name |
| 82 | self.intent = intent |
| 83 | self.kb_dir = kb_dir |
| 84 | self.model = model |
| 85 | self.critique = critique |
| 86 | self.skill_name = skill_name or DEFAULT_DECK_SKILL |
| 87 | self.output_dir = ( |
| 88 | deck_dir(kb_dir, name) if target_type == "deck" else skill_dir(kb_dir, name) |
| 89 | ) |
| 90 | self.validation: AnyValidationResult | None = None |
| 91 | |
| 92 | async def run(self) -> Path: |
| 93 | """Execute the generator. Returns the path to the produced artifact. |
| 94 | |
| 95 | Side-effects, in order: compile → validate → (skill only) publish |
| 96 | manifest. ``self.validation`` holds the result so callers can |
| 97 | surface issues without re-running the validator. For deck target, |
| 98 | validation runs inside ``run_skill`` via the producing skill's |
| 99 | frontmatter-declared grammar; we propagate it up. |
| 100 | """ |
| 101 | if self.target_type == "skill": |
| 102 | await run_skill_create( |
| 103 | kb_dir=self.kb_dir, |
no outgoing calls